[haiku-commits] r35355 - haiku/trunk/src/apps/deskbar

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 31 Jan 2010 03:49:10 +0100 (CET)

Author: stpere
Date: 2010-01-31 03:49:10 +0100 (Sun, 31 Jan 2010)
New Revision: 35355
Changeset: http://dev.haiku-os.org/changeset/35355/haiku
Ticket: http://dev.haiku-os.org/ticket/5007

Modified:
   haiku/trunk/src/apps/deskbar/BarApp.cpp
   haiku/trunk/src/apps/deskbar/BarApp.h
   haiku/trunk/src/apps/deskbar/BeMenu.cpp
   haiku/trunk/src/apps/deskbar/BeMenu.h
   haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp
Log:
DeskBar: Adds a new setting (called ...Enabled) to determine if we show a 
particular Recent Menu.

 * the previous behaviour was to consider it enabled if the count was above 0, 
and disabled otherwise.
 * the new behaviour is to consider it disabled if the count is 0, but also 
allows to disable it by unchecking the box in the pref window, without setting 
the count to 0 (losing its value).

Fixes ticket #5007.


Modified: haiku/trunk/src/apps/deskbar/BarApp.cpp
===================================================================
--- haiku/trunk/src/apps/deskbar/BarApp.cpp     2010-01-31 02:28:29 UTC (rev 
35354)
+++ haiku/trunk/src/apps/deskbar/BarApp.cpp     2010-01-31 02:49:10 UTC (rev 
35355)
@@ -199,6 +199,9 @@
                fSettingsFile->Write(&fSettings.superExpando, sizeof(bool));
                fSettingsFile->Write(&fSettings.expandNewTeams, sizeof(bool));
                fSettingsFile->Write(&fSettings.autoRaise, sizeof(bool));
+               fSettingsFile->Write(&fSettings.recentAppsEnabled, 
sizeof(bool));
+               fSettingsFile->Write(&fSettings.recentDocsEnabled, 
sizeof(bool));
+               fSettingsFile->Write(&fSettings.recentFoldersEnabled, 
sizeof(bool));
        }
 }
 
@@ -228,6 +231,9 @@
        settings.superExpando = false;
        settings.expandNewTeams = false;
        settings.autoRaise = false;
+       settings.recentAppsEnabled = true;
+       settings.recentDocsEnabled = true;
+       settings.recentFoldersEnabled = true;
 
        BPath dirPath;
        const char* settingsFileName = "Deskbar_settings";
@@ -288,6 +294,16 @@
                        }
                        if (size >= kValidSettingsSize10)
                                fSettingsFile->Read(&settings.autoRaise, 
sizeof(bool));
+
+                       if (size >= kValidSettingsSize11) {
+                               
fSettingsFile->Read(&settings.recentAppsEnabled, sizeof(bool));
+                               
fSettingsFile->Read(&settings.recentDocsEnabled, sizeof(bool));
+                               
fSettingsFile->Read(&settings.recentFoldersEnabled, sizeof(bool));
+                       } else {
+                               settings.recentAppsEnabled = 
settings.recentAppsCount > 0;
+                               settings.recentDocsEnabled = 
settings.recentDocsCount > 0;
+                               settings.recentFoldersEnabled = 
settings.recentFoldersCount > 0;
+                       }
                }
        }
 
@@ -299,6 +315,7 @@
 TBarApp::MessageReceived(BMessage* message)
 {
        int32 count;
+       bool enabled;
        switch (message->what) {
                case 'gloc':
                case 'sloc':
@@ -335,10 +352,18 @@
                case kUpdateRecentCounts:
                        if (message->FindInt32("applications", &count) == B_OK)
                                fSettings.recentAppsCount = count;
+                       if (message->FindBool("applicationsEnabled", &enabled) 
== B_OK)
+                               fSettings.recentAppsEnabled = enabled && count 
> 0;
+
                        if (message->FindInt32("folders", &count) == B_OK)
                                fSettings.recentFoldersCount = count;
+                       if (message->FindBool("foldersEnabled", &enabled) == 
B_OK)
+                               fSettings.recentFoldersEnabled = enabled && 
count > 0;
+
                        if (message->FindInt32("documents", &count) == B_OK)
                                fSettings.recentDocsCount = count;
+                       if (message->FindBool("documentsEnabled", &enabled) == 
B_OK)
+                               fSettings.recentDocsEnabled = enabled && count 
> 0;
                        break;
 
                case kConfigClose:

Modified: haiku/trunk/src/apps/deskbar/BarApp.h
===================================================================
--- haiku/trunk/src/apps/deskbar/BarApp.h       2010-01-31 02:28:29 UTC (rev 
35354)
+++ haiku/trunk/src/apps/deskbar/BarApp.h       2010-01-31 02:49:10 UTC (rev 
35355)
@@ -112,6 +112,9 @@
        bool superExpando;                      // version 9
        bool expandNewTeams;
        bool autoRaise;                         // version 10
+       bool recentAppsEnabled;         // version 11
+       bool recentDocsEnabled;
+       bool recentFoldersEnabled;      
 };
 
 // the following structures are defined to compute
@@ -128,6 +131,7 @@
 const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
 const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
 const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9;
+const uint32 kValidSettingsSize11 = 3 * sizeof(bool) + kValidSettingsSize10;
 
 class TBarView;
 class BFile;

Modified: haiku/trunk/src/apps/deskbar/BeMenu.cpp
===================================================================
--- haiku/trunk/src/apps/deskbar/BeMenu.cpp     2010-01-31 02:28:29 UTC (rev 
35354)
+++ haiku/trunk/src/apps/deskbar/BeMenu.cpp     2010-01-31 02:49:10 UTC (rev 
35355)
@@ -155,23 +155,24 @@
                        kRecentApplications};
                const int recentTypes = 3;
                TRecentsMenu* recentItem[recentTypes];
-               int count = 0;
 
+               bool enabled = false;
+
                for (int i = 0; i < recentTypes; i++) {
                        recentItem[i] = new TRecentsMenu(recentTitle[i], 
fBarView,
                                recentType[i]);
 
                        if (recentItem[i])
-                               count += recentItem[i]->RecentsCount();
+                               enabled |= recentItem[i]->RecentsEnabled();
                }
-               if (count > 0) {
+               if (enabled) {
                        AddSeparatorItem();
 
-                       for (int i = 0;i < recentTypes;i++) {
+                       for (int i = 0; i < recentTypes; i++) {
                                if (!recentItem[i])
                                        continue;
 
-                               if (recentItem[i]->RecentsCount() > 0) {
+                               if (recentItem[i]->RecentsEnabled()) {
                                        
recentItem[i]->SetTypesList(TypesList());
                                        recentItem[i]->SetTarget(Target());
                                        AddItem(recentItem[i]);
@@ -391,6 +392,7 @@
        fAppRef(NULL),
        fSignature(NULL),
        fRecentsCount(0),
+       fRecentsEnabled(false),
        fItemIndex(0),
        fBarView(bar)
 {
@@ -401,12 +403,15 @@
        switch (which) {
                case kRecentDocuments:
                        fRecentsCount = app->Settings()->recentDocsCount;
+                       fRecentsEnabled = app->Settings()->recentDocsEnabled;
                        break;
                case kRecentApplications:
                        fRecentsCount = app->Settings()->recentAppsCount;
+                       fRecentsEnabled = app->Settings()->recentAppsEnabled;
                        break;
                case kRecentAppDocuments:
                        fRecentsCount = app->Settings()->recentDocsCount;
+                       fRecentsEnabled = app->Settings()->recentDocsEnabled;
                        if (signature != NULL)
                                fSignature = strdup(signature);
                        if (appRef != NULL)
@@ -414,6 +419,7 @@
                        break;
                case kRecentFolders:
                        fRecentsCount = app->Settings()->recentFoldersCount;
+                       fRecentsEnabled = app->Settings()->recentFoldersEnabled;
                        break;
        }
 }
@@ -454,7 +460,7 @@
 bool
 TRecentsMenu::AddNextItem()
 {
-       if (fRecentsCount > 0 && AddRecents(fRecentsCount))
+       if (fRecentsCount > 0 && fRecentsEnabled && AddRecents(fRecentsCount))
                return true;
 
        fItemIndex = 0;

Modified: haiku/trunk/src/apps/deskbar/BeMenu.h
===================================================================
--- haiku/trunk/src/apps/deskbar/BeMenu.h       2010-01-31 02:28:29 UTC (rev 
35354)
+++ haiku/trunk/src/apps/deskbar/BeMenu.h       2010-01-31 02:49:10 UTC (rev 
35355)
@@ -58,6 +58,7 @@
                void                    ResetTargets();
 
                int32                   RecentsCount();
+               bool                    RecentsEnabled();
 
        private:
                virtual bool    StartBuildingItemList();
@@ -71,6 +72,7 @@
                entry_ref               *fAppRef;
                char                    *fSignature;
                int32                   fRecentsCount;
+               bool                    fRecentsEnabled;
 
                int32                   fItemIndex;
                BMessage                fRecentList;
@@ -86,6 +88,13 @@
 }
 
 
+inline bool
+TRecentsMenu::RecentsEnabled()
+{
+       return fRecentsEnabled;
+}
+
+
 class TBeMenu : public BNavMenu {
        public:
                TBeMenu(TBarView* bar);

Modified: haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp
===================================================================
--- haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp  2010-01-31 02:28:29 UTC 
(rev 35354)
+++ haiku/trunk/src/apps/deskbar/PreferencesWindow.cpp  2010-01-31 02:49:10 UTC 
(rev 35355)
@@ -87,33 +87,19 @@
        fAppsShowExpanders->SetValue(appSettings->superExpando);
        fAppsExpandNew->SetValue(appSettings->expandNewTeams);
 
-       fMenuRecentDocuments->SetValue(false);
-       fMenuRecentApplications->SetValue(false);
-       fMenuRecentFolders->SetValue(false);
-
-       fMenuRecentDocumentCount->SetEnabled(false);
-       fMenuRecentApplicationCount->SetEnabled(false);
-       fMenuRecentFolderCount->SetEnabled(false);
-
        int32 docCount = appSettings->recentDocsCount;
        int32 appCount = appSettings->recentAppsCount;
        int32 folderCount = appSettings->recentFoldersCount;
 
-       if (docCount > 0) {
-               fMenuRecentDocuments->SetValue(true);
-               fMenuRecentDocumentCount->SetEnabled(true);
-       }
+       fMenuRecentDocuments->SetValue(appSettings->recentDocsEnabled);
+       fMenuRecentDocumentCount->SetEnabled(appSettings->recentDocsEnabled);
+       
+       fMenuRecentApplications->SetValue(appSettings->recentAppsEnabled);
+       fMenuRecentApplicationCount->SetEnabled(appSettings->recentAppsEnabled);
+       
+       fMenuRecentFolders->SetValue(appSettings->recentFoldersEnabled);
+       fMenuRecentFolderCount->SetEnabled(appSettings->recentFoldersEnabled);
 
-       if (appCount > 0) {
-               fMenuRecentApplications->SetValue(true);
-               fMenuRecentApplicationCount->SetEnabled(true);
-       }
-
-       if (folderCount > 0) {
-               fMenuRecentFolders->SetValue(true);
-               fMenuRecentFolderCount->SetEnabled(true);
-       }
-
        BString docString;
        BString appString;
        BString folderString;
@@ -281,21 +267,14 @@
        int32 appCount = atoi(fMenuRecentApplicationCount->Text());
        int32 folderCount = atoi(fMenuRecentFolderCount->Text());
 
-       if (docCount <= 0 || fMenuRecentDocuments->Value() == false)
-               message.AddInt32("documents", 0);
-       else
-               message.AddInt32("documents", docCount);
+       message.AddInt32("documents", max_c(0, docCount));
+       message.AddInt32("applications", max_c(0, appCount));
+       message.AddInt32("folders", max_c(0, folderCount));
 
-       if (appCount <= 0 || fMenuRecentApplications->Value() == false)
-               message.AddInt32("applications", 0);
-       else
-               message.AddInt32("applications", appCount);
+       message.AddBool("documentsEnabled", fMenuRecentDocuments->Value());
+       message.AddBool("applicationsEnabled", 
fMenuRecentApplications->Value());
+       message.AddBool("foldersEnabled", fMenuRecentFolders->Value());
 
-       if (folderCount <= 0 || fMenuRecentFolders->Value() == false)
-               message.AddInt32("folders", 0);
-       else
-               message.AddInt32("folders", folderCount);
-
        be_app->PostMessage(&message);
 
        _EnableDisableDependentItems();


Other related posts:

  • » [haiku-commits] r35355 - haiku/trunk/src/apps/deskbar - stpere