From 42f39580d88b708efb4eefb4b53ffc93441ddc7a Mon Sep 17 00:00:00 2001 From: shatty Date: Wed, 7 Jan 2004 10:46:20 +0000 Subject: [PATCH] assorted warnings patches, look and feel patches, populate the preferred application field prettily git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5977 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/tracker/filetype/AppTypeView.cpp | 4 +- src/add-ons/tracker/filetype/AppTypeView.h | 4 +- .../tracker/filetype/AppTypeWindow.cpp | 11 +++- src/add-ons/tracker/filetype/FileTypeApp.cpp | 1 - src/add-ons/tracker/filetype/FileTypeApp.h | 2 +- src/add-ons/tracker/filetype/FileTypeView.cpp | 51 +++++++++++++++++-- src/add-ons/tracker/filetype/FileTypeView.h | 2 +- .../tracker/filetype/FileTypeWindow.cpp | 6 +-- 8 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/add-ons/tracker/filetype/AppTypeView.cpp b/src/add-ons/tracker/filetype/AppTypeView.cpp index 697ac69654..ee52a13219 100644 --- a/src/add-ons/tracker/filetype/AppTypeView.cpp +++ b/src/add-ons/tracker/filetype/AppTypeView.cpp @@ -4,8 +4,8 @@ #include AppTypeView::AppTypeView(BRect viewFrame) - : BView(viewFrame, "AppTypeView", B_FOLLOW_ALL, - B_FRAME_EVENTS|B_WILL_DRAW) + : BBox(viewFrame, "AppTypeView", B_FOLLOW_ALL, + B_FRAME_EVENTS|B_WILL_DRAW, B_PLAIN_BORDER) { SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); diff --git a/src/add-ons/tracker/filetype/AppTypeView.h b/src/add-ons/tracker/filetype/AppTypeView.h index e2cab8bc1c..860ef25e1b 100644 --- a/src/add-ons/tracker/filetype/AppTypeView.h +++ b/src/add-ons/tracker/filetype/AppTypeView.h @@ -1,14 +1,14 @@ #ifndef APP_TYPE_VIEW_H #define APP_TYPE_VIEW_H +#include #include -#include class AppTypeAppFlagsView; class AppTypeSupportedTypesView; class AppTypeVersionInfoView; -class AppTypeView : public BView { +class AppTypeView : public BBox { public: AppTypeView(BRect viewFrame); ~AppTypeView(); diff --git a/src/add-ons/tracker/filetype/AppTypeWindow.cpp b/src/add-ons/tracker/filetype/AppTypeWindow.cpp index 3a5ff8c109..d26a9b613d 100644 --- a/src/add-ons/tracker/filetype/AppTypeWindow.cpp +++ b/src/add-ons/tracker/filetype/AppTypeWindow.cpp @@ -115,12 +115,19 @@ AppTypeWindow::QuitRequested() } } +static const char * application_file_types = "BEOS:FILE_TYPES"; +static const char * application_flags_name = "BEOS:APP_FLAGS"; +static const char * application_large_standard_icon_name = "BEOS:L:STD_ICON"; +static const char * application_median_standard_icon_name = "BEOS:M:STD_ICON"; +static const char * application_signature_name = "BEOS:APP_SIG"; +static const char * application_version_name = "BEOS:APP_VERSION"; + status_t AppTypeWindow::SaveRequested() { status_t result = B_OK; - // TODO : save new settings + // TODO : save new settings to all attributes and resources matching the name return result; } @@ -137,4 +144,6 @@ AppTypeWindow::SetEntry(const BEntry * entry) SetTitle(strdup(title.String())); // TODO : set old settings + + } diff --git a/src/add-ons/tracker/filetype/FileTypeApp.cpp b/src/add-ons/tracker/filetype/FileTypeApp.cpp index aa38b81470..e57aa50a9f 100644 --- a/src/add-ons/tracker/filetype/FileTypeApp.cpp +++ b/src/add-ons/tracker/filetype/FileTypeApp.cpp @@ -157,7 +157,6 @@ FileTypeApp::ArgvReceived(int32 argc, const char * argv[], const char * cwd) (strcmp(argv[i],"-H") == 0) || (strcmp(argv[i],"-help") == 0) || (strcmp(argv[i],"--help") == 0)) { - void * item; for (int32 i = 0 ; (i < entryList.CountItems()) ; i++) { delete entryList.ItemAt(i); } diff --git a/src/add-ons/tracker/filetype/FileTypeApp.h b/src/add-ons/tracker/filetype/FileTypeApp.h index 2517a94933..ef843d1999 100644 --- a/src/add-ons/tracker/filetype/FileTypeApp.h +++ b/src/add-ons/tracker/filetype/FileTypeApp.h @@ -12,7 +12,7 @@ class FileTypeApp public: FileTypeApp(); virtual void MessageReceived(BMessage *message); - virtual void ArgvReceived(int32 argc, const char *argv[], const char * cwd); + void ArgvReceived(int32 argc, const char *argv[], const char * cwd); virtual void RefsReceived(BMessage *message); virtual void ReadyToRun(); diff --git a/src/add-ons/tracker/filetype/FileTypeView.cpp b/src/add-ons/tracker/filetype/FileTypeView.cpp index f87d4fc465..748fe26110 100644 --- a/src/add-ons/tracker/filetype/FileTypeView.cpp +++ b/src/add-ons/tracker/filetype/FileTypeView.cpp @@ -1,10 +1,11 @@ #include - +#include +#include #include FileTypeView::FileTypeView(BRect viewFrame) - : BView(viewFrame, "FileTypeView", B_FOLLOW_ALL, - B_FRAME_EVENTS|B_WILL_DRAW) + : BBox(viewFrame, "FileTypeView", B_FOLLOW_ALL, + B_FRAME_EVENTS|B_WILL_DRAW, B_PLAIN_BORDER) { SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); @@ -52,6 +53,50 @@ FileTypeView::SetFileType(const char * fileType) { fFileType.SetTo(fileType); fFileTypeTextControl->SetText(fileType); + BMimeType mime(fileType); + if (mime.InitCheck() != B_OK) { + return; + } + BMessage applications; + if (mime.GetSupportingApps(&applications) != B_OK) { + return; + } + int32 subs = 0; + if (applications.FindInt32("be:sub", &subs) != B_OK) { + subs = 0; + } + int32 supers = 0; + if (applications.FindInt32("be:super", &supers) != B_OK) { + supers = 0; + } + for (int i = fPreferredAppMenu->CountItems() ; (i > 2) ; i--) { + BMenuItem * item = fPreferredAppMenu->ItemAt(i); + fPreferredAppMenu->RemoveItem(i); + delete item; + } + bool separator = false; + for (int i = 0 ; (i < subs+supers) ; i++) { + const char * str; + if (applications.FindString("applications", i, &str) == B_OK) { + BMimeType app_mime(str); + BMessage * message = NULL; + entry_ref ref; + if (app_mime.InitCheck() == B_OK) { + if (app_mime.GetAppHint(&ref) == B_OK) { + message = new BMessage(); + message->AddString("mimetype",str); + str = ref.name; + } + } + if (i < subs) { + separator = true; + } else if (separator) { + fPreferredAppMenu->AddSeparatorItem(); + separator = false; + } + fPreferredAppMenu->AddItem(new BMenuItem(str,message)); + } + } } void diff --git a/src/add-ons/tracker/filetype/FileTypeView.h b/src/add-ons/tracker/filetype/FileTypeView.h index 5c64a13c9d..9c4775c942 100644 --- a/src/add-ons/tracker/filetype/FileTypeView.h +++ b/src/add-ons/tracker/filetype/FileTypeView.h @@ -8,7 +8,7 @@ #include #include -class FileTypeView : public BView { +class FileTypeView : public BBox { public: FileTypeView(BRect viewFrame); ~FileTypeView(); diff --git a/src/add-ons/tracker/filetype/FileTypeWindow.cpp b/src/add-ons/tracker/filetype/FileTypeWindow.cpp index 6b9da6a489..1874217293 100644 --- a/src/add-ons/tracker/filetype/FileTypeWindow.cpp +++ b/src/add-ons/tracker/filetype/FileTypeWindow.cpp @@ -44,10 +44,10 @@ FileTypeWindow::FileTypeWindow(const BList * entryList) FileTypeWindow::~FileTypeWindow() { if (fEntryList != 0) { - void * item; - for (int32 i = 0 ; item = fEntryList->ItemAt(i) ; i++) { - delete item; + for (int32 i = 0 ; (i < fEntryList->CountItems()) ; i++) { + delete fEntryList->ItemAt(i); } + fEntryList->MakeEmpty(); delete fEntryList; } }