2 * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include "FileWindow.h"
8 #include "OpenWindow.h"
10 #include "ProbeView.h"
12 #include <Application.h>
14 #include <Directory.h>
15 #include <GroupLayout.h>
21 #include <be_apps/Tracker/RecentItems.h>
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "FileWindow"
28 FileWindow::FileWindow(BRect rect
, entry_ref
*ref
, const BMessage
*settings
)
29 : ProbeWindow(rect
, ref
)
31 SetLayout(new BGroupLayout(B_VERTICAL
, 0));
32 // Set alternative window title for devices
36 if (entry
.GetStat(&stat
) == B_OK
&& (S_ISBLK(stat
.st_mode
)
37 || S_ISCHR(stat
.st_mode
))) {
39 SetTitle(path
.Path());
40 } else if (entry
.IsDirectory()) {
41 BDirectory
directory(&entry
);
42 if (directory
.InitCheck() == B_OK
&& directory
.IsRootDirectory()) {
43 // use the volume name for root directories
44 BVolume
volume(stat
.st_dev
);
45 if (volume
.InitCheck() == B_OK
) {
46 char name
[B_FILE_NAME_LENGTH
];
47 if (volume
.GetName(name
) == B_OK
)
55 BMenuBar
*menuBar
= new BMenuBar("menu bar");
58 BMenu
*menu
= new BMenu(B_TRANSLATE("File"));
59 menu
->AddItem(new BMenuItem(B_TRANSLATE("New" B_UTF8_ELLIPSIS
),
60 new BMessage(kMsgOpenOpenWindow
), 'N', B_COMMAND_KEY
));
62 BMenu
*devicesMenu
= new BMenu(B_TRANSLATE("Open device"));
63 OpenWindow::CollectDevices(devicesMenu
);
64 devicesMenu
->SetTargetForItems(be_app
);
65 menu
->AddItem(new BMenuItem(devicesMenu
));
67 BMenu
*recentsMenu
= BRecentFilesList::NewFileListMenu(
68 B_TRANSLATE("Open file" B_UTF8_ELLIPSIS
),
69 NULL
, NULL
, be_app
, 10, false, NULL
, kSignature
);
71 menu
->AddItem(item
= new BMenuItem(recentsMenu
,
72 new BMessage(kMsgOpenFilePanel
)));
73 item
->SetShortcut('O', B_COMMAND_KEY
);
74 menu
->AddSeparatorItem();
76 // the ProbeView save menu items will be inserted here
77 item
= new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_CLOSE_REQUESTED
),
80 menu
->AddSeparatorItem();
82 // the ProbeView print menu items will be inserted here
84 menu
->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
85 new BMessage(B_QUIT_REQUESTED
), 'Q', B_COMMAND_KEY
));
86 menu
->SetTargetForItems(be_app
);
87 item
->SetTarget(this);
88 menuBar
->AddItem(menu
);
90 // add our interface widgets
92 fProbeView
= new ProbeView(ref
, NULL
, settings
);
95 fProbeView
->AddSaveMenuItems(menu
, 4);
96 fProbeView
->AddPrintMenuItems(menu
, menu
->CountItems() - 4);
97 fProbeView
->AddViewAsMenuItems();
102 FileWindow::QuitRequested()
104 bool quit
= fProbeView
->QuitRequested();
108 return ProbeWindow::QuitRequested();
113 FileWindow::Contains(const entry_ref
&ref
, const char *attribute
)
115 if (attribute
!= NULL
)