* 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:
Stephan Aßmus
2011-02-12 22:12:21 +00:00
parent 05b101b223
commit 0b4ddda5f0
3 changed files with 95 additions and 73 deletions
+50 -37
View File
@@ -73,10 +73,11 @@ class FileTypes : public BApplication {
Settings fSettings;
BFilePanel* fFilePanel;
BMessenger fFilePanelTarget;
BWindow *fTypesWindow;
FileTypesWindow* fTypesWindow;
BWindow* fApplicationTypesWindow;
uint32 fWindowCount;
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
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 -
FileTypes::FileTypes()
: BApplication(kSignature),
:
BApplication(kSignature),
fTypesWindow(NULL),
fApplicationTypesWindow(NULL),
fWindowCount(0),
@@ -272,10 +274,15 @@ FileTypes::RefsReceived(BMessage *message)
void
FileTypes::ArgvReceived(int32 argc, char** argv)
{
if (argc == 3 && strcmp(argv[1], "-type") == 0) {
fArgvType = argv[2];
return;
}
BMessage* message = CurrentMessage();
BDirectory currentDirectory;
if (message)
if (message != NULL)
currentDirectory.SetTo(message->FindString("cwd"));
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
FileTypes::MessageReceived(BMessage* message)
{
@@ -324,6 +323,13 @@ FileTypes::MessageReceived(BMessage *message)
case kMsgOpenTypesWindow:
if (fTypesWindow == NULL) {
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();
fWindowCount++;
} else
@@ -440,6 +446,14 @@ FileTypes::QuitRequested()
}
void
FileTypes::_WindowClosed()
{
if (--fWindowCount == 0 && !fFilePanel->IsShowing())
PostMessage(B_QUIT_REQUESTED);
}
// #pragma mark -
@@ -495,7 +509,6 @@ int
main(int argc, char** argv)
{
FileTypes probe;
probe.Run();
return 0;
}
@@ -944,6 +944,13 @@ FileTypesWindow::MessageReceived(BMessage* message)
}
void
FileTypesWindow::SelectType(const char* type)
{
fTypeListView->SelectType(type);
}
bool
FileTypesWindow::QuitRequested()
{
@@ -39,6 +39,8 @@ public:
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
void SelectType(const char* type);
void PlaceSubWindow(BWindow* window);
private: