* Some reordering of methods to match declaration order.
* Some updating to new header indentation style * Improved consistency of asterix style in FileTypes.cpp. * Implemented passing -type some/type on the command line and having that type initially selected in the FileTypesWindow. (Unfortunately BOutlineListView::ScrollToSelection() is broken.) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40472 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -73,10 +73,11 @@ class FileTypes : public BApplication {
|
|||||||
Settings fSettings;
|
Settings fSettings;
|
||||||
BFilePanel* fFilePanel;
|
BFilePanel* fFilePanel;
|
||||||
BMessenger fFilePanelTarget;
|
BMessenger fFilePanelTarget;
|
||||||
BWindow *fTypesWindow;
|
FileTypesWindow* fTypesWindow;
|
||||||
BWindow* fApplicationTypesWindow;
|
BWindow* fApplicationTypesWindow;
|
||||||
uint32 fWindowCount;
|
uint32 fWindowCount;
|
||||||
uint32 fTypeWindowCount;
|
uint32 fTypeWindowCount;
|
||||||
|
BString fArgvType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -115,31 +116,6 @@ Settings::~Settings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Settings::_SetDefaults()
|
|
||||||
{
|
|
||||||
fMessage.AddRect("file_types_frame", BRect(80.0f, 80.0f, 600.0f, 480.0f));
|
|
||||||
fMessage.AddRect("app_types_frame", BRect(100.0f, 100.0f, 540.0f, 480.0f));
|
|
||||||
fMessage.AddBool("show_icons", true);
|
|
||||||
fMessage.AddBool("show_rule", false);
|
|
||||||
fMessage.AddFloat("left_split_weight", 0.2);
|
|
||||||
fMessage.AddFloat("right_split_weight", 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
Settings::_Open(BFile *file, int32 mode)
|
|
||||||
{
|
|
||||||
BPath path;
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
path.Append("FileTypes settings");
|
|
||||||
|
|
||||||
return file->SetTo(path.Path(), mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Settings::UpdateFrom(BMessage* message)
|
Settings::UpdateFrom(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -168,11 +144,37 @@ Settings::UpdateFrom(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Settings::_SetDefaults()
|
||||||
|
{
|
||||||
|
fMessage.AddRect("file_types_frame", BRect(80.0f, 80.0f, 600.0f, 480.0f));
|
||||||
|
fMessage.AddRect("app_types_frame", BRect(100.0f, 100.0f, 540.0f, 480.0f));
|
||||||
|
fMessage.AddBool("show_icons", true);
|
||||||
|
fMessage.AddBool("show_rule", false);
|
||||||
|
fMessage.AddFloat("left_split_weight", 0.2);
|
||||||
|
fMessage.AddFloat("right_split_weight", 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Settings::_Open(BFile* file, int32 mode)
|
||||||
|
{
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
path.Append("FileTypes settings");
|
||||||
|
|
||||||
|
return file->SetTo(path.Path(), mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
FileTypes::FileTypes()
|
FileTypes::FileTypes()
|
||||||
: BApplication(kSignature),
|
:
|
||||||
|
BApplication(kSignature),
|
||||||
fTypesWindow(NULL),
|
fTypesWindow(NULL),
|
||||||
fApplicationTypesWindow(NULL),
|
fApplicationTypesWindow(NULL),
|
||||||
fWindowCount(0),
|
fWindowCount(0),
|
||||||
@@ -272,10 +274,15 @@ FileTypes::RefsReceived(BMessage *message)
|
|||||||
void
|
void
|
||||||
FileTypes::ArgvReceived(int32 argc, char** argv)
|
FileTypes::ArgvReceived(int32 argc, char** argv)
|
||||||
{
|
{
|
||||||
|
if (argc == 3 && strcmp(argv[1], "-type") == 0) {
|
||||||
|
fArgvType = argv[2];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BMessage* message = CurrentMessage();
|
BMessage* message = CurrentMessage();
|
||||||
|
|
||||||
BDirectory currentDirectory;
|
BDirectory currentDirectory;
|
||||||
if (message)
|
if (message != NULL)
|
||||||
currentDirectory.SetTo(message->FindString("cwd"));
|
currentDirectory.SetTo(message->FindString("cwd"));
|
||||||
|
|
||||||
BMessage refs;
|
BMessage refs;
|
||||||
@@ -305,14 +312,6 @@ FileTypes::ArgvReceived(int32 argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
FileTypes::_WindowClosed()
|
|
||||||
{
|
|
||||||
if (--fWindowCount == 0 && !fFilePanel->IsShowing())
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FileTypes::MessageReceived(BMessage* message)
|
FileTypes::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -324,6 +323,13 @@ FileTypes::MessageReceived(BMessage *message)
|
|||||||
case kMsgOpenTypesWindow:
|
case kMsgOpenTypesWindow:
|
||||||
if (fTypesWindow == NULL) {
|
if (fTypesWindow == NULL) {
|
||||||
fTypesWindow = new FileTypesWindow(fSettings.Message());
|
fTypesWindow = new FileTypesWindow(fSettings.Message());
|
||||||
|
if (fArgvType.Length() > 0) {
|
||||||
|
// Set the window to the type that was requested on the
|
||||||
|
// command line (-type), we do this only once, if we
|
||||||
|
// ever opened more than one FileTypesWindow.
|
||||||
|
fTypesWindow->SelectType(fArgvType.String());
|
||||||
|
fArgvType = "";
|
||||||
|
}
|
||||||
fTypesWindow->Show();
|
fTypesWindow->Show();
|
||||||
fWindowCount++;
|
fWindowCount++;
|
||||||
} else
|
} else
|
||||||
@@ -440,6 +446,14 @@ FileTypes::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypes::_WindowClosed()
|
||||||
|
{
|
||||||
|
if (--fWindowCount == 0 && !fFilePanel->IsShowing())
|
||||||
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -495,7 +509,6 @@ int
|
|||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
FileTypes probe;
|
FileTypes probe;
|
||||||
|
|
||||||
probe.Run();
|
probe.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -944,6 +944,13 @@ FileTypesWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypesWindow::SelectType(const char* type)
|
||||||
|
{
|
||||||
|
fTypeListView->SelectType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FileTypesWindow::QuitRequested()
|
FileTypesWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
void SelectType(const char* type);
|
||||||
|
|
||||||
void PlaceSubWindow(BWindow* window);
|
void PlaceSubWindow(BWindow* window);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user