[haiku-commits] haiku: hrev45368 - src/apps/deskbar

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 16 Mar 2013 02:47:43 +0100 (CET)

hrev45368 adds 10 changesets to branch 'master'
old head: 41130d1c524259bf5600cbd84c41af0e8cd8285c
new head: 5bfc9c7091f3b728bb6a7083e82fac4d21682f7f
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=5bfc9c7+%5E41130d1

----------------------------------------------------------------------------

93a58e5: Reformat Deskbar prefs all in one with no tabs

cb0602c: Implement Revert and Default buttons in Deskbar prefs

1ec3d37: Rename 'Sort running applications' to 'Sort applications by name'

cb42238: Destroy prefs window on close once again

43917ef: Refactor settings so that defaults get set in 1 place.
  
  * Move desk_settings and clock_settings struct to a new header entitled
    'BarSettings.h' so it can be included in BarApp.h and PreferencesWindow.h.
  * Refactor desk_settings to only include used, or at least relevant settings,
    some cruft had built up over time.
  * Refactor the InitSettings() method, all the B_OK checking wasn't working so
    I removed it. Defaults get set up to and if the corresponding setting is
    found in the settings file it is replaced, else, it is not.
  * Reorder the struct and code so it goes in the order that the settings 
appear:
    applications, then recent items, then window settings.
  * Simplify the preferences window revert and defaults code based on using the
    prebuild desk_settings structs in BarApp instead of creating our own and
    copying. All initial setup is in the constructor.

633232d: Reorder buttons.
  
  Defaults then Revert both on left like Tracker and Locale and other preflets.

a601c3f: Add 'Open menu in Tracker' button at bottom

a3f512d: Rename Recent items back to Menu and tweak to make fit.
  
  * Put the Open in Tracker... button back in Menu.
  * Put the window checkboxes in 2 columns.
  * Use vertical struts instead of insets for spacing in a couple places.

f49eecb: Use horizontal strut instead of insets

5bfc9c7: Save and load prefs window position to and from a file.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

6 files changed, 605 insertions(+), 325 deletions(-)
src/apps/deskbar/BarApp.cpp            | 311 +++++++++-----------
src/apps/deskbar/BarApp.h              |  49 +---
src/apps/deskbar/BarSettings.h         |  74 +++++
src/apps/deskbar/DeskbarMenu.cpp       |   1 +
src/apps/deskbar/PreferencesWindow.cpp | 456 +++++++++++++++++++++--------
src/apps/deskbar/PreferencesWindow.h   |  39 ++-

############################################################################

Commit:      93a58e5028e3bd021644b8b662851ea6415b6386
URL:         http://cgit.haiku-os.org/haiku/commit/?id=93a58e5
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Mar  6 17:32:15 2013 UTC

Reformat Deskbar prefs all in one with no tabs

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index a43f918..103d59b 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -12,6 +12,7 @@
 
 #include <ctype.h>
 
+#include <Box.h>
 #include <Button.h>
 #include <Catalog.h>
 #include <CheckBox.h>
@@ -26,7 +27,6 @@
 #include <Roster.h>
 #include <SeparatorView.h>
 #include <Slider.h>
-#include <TabView.h>
 #include <TextControl.h>
 #include <View.h>
 
@@ -164,34 +164,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowAutoRaise->SetTarget(be_app);
        fWindowAutoHide->SetTarget(be_app);
 
-       // Layout
-       BView* menuSettingsView = BLayoutBuilder::Group<>()
-               .AddGroup(B_VERTICAL, 0)
-                       .AddGroup(B_HORIZONTAL, 0)
-                               .AddGroup(B_VERTICAL, 0)
-                                       .Add(fMenuRecentDocuments)
-                                       .Add(fMenuRecentFolders)
-                                       .Add(fMenuRecentApplications)
-                                       .End()
-                               .AddGroup(B_VERTICAL, 0)
-                                       .Add(fMenuRecentDocumentCount)
-                                       .Add(fMenuRecentFolderCount)
-                                       .Add(fMenuRecentApplicationCount)
-                                       .End()
-                               .End()
-                       .AddGroup(B_VERTICAL, 0)
-                               .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0)
-                               .Add(new BButton(B_TRANSLATE("Edit menu" 
B_UTF8_ELLIPSIS),
-                                       new BMessage(kEditMenuInTracker)))
-                               .End()
-                       .AddGlue()
-                       .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
-                               B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
-                       .End()
-               .View();
-       menuSettingsView->SetName(B_TRANSLATE("Menu"));
-
-       BView* applicationsSettingsView = BLayoutBuilder::Group<>()
+       // Applications
+       BBox* appsSettingsBox = new BBox("applications");
+       appsSettingsBox->SetLabel(B_TRANSLATE("Applications"));
+       appsSettingsBox->AddChild(BLayoutBuilder::Group<>()
                .AddGroup(B_VERTICAL, 0)
                        .Add(fAppsSort)
                        .Add(fAppsSortTrackerFirst)
@@ -209,10 +185,36 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
-               .View();
-       applicationsSettingsView->SetName(B_TRANSLATE("Applications"));
+               .View());
 
-       BView* windowSettingsView = BLayoutBuilder::Group<>()
+       // Recent items
+       BBox* recentItemsBox = new BBox("recent items");
+       recentItemsBox->SetLabel(B_TRANSLATE("Recent items"));
+       recentItemsBox->AddChild(BLayoutBuilder::Group<>()
+               .AddGroup(B_VERTICAL, 0)
+                       .AddGroup(B_HORIZONTAL, 0)
+                               .AddGroup(B_VERTICAL, 0)
+                                       .Add(fMenuRecentDocuments)
+                                       .Add(fMenuRecentFolders)
+                                       .Add(fMenuRecentApplications)
+                                       .End()
+                               .AddGroup(B_VERTICAL, 0)
+                                       .Add(fMenuRecentDocumentCount)
+                                       .Add(fMenuRecentFolderCount)
+                                       .Add(fMenuRecentApplicationCount)
+                                       .End()
+                               .End()
+                       //.Add(new BButton(B_TRANSLATE("Edit menu" 
B_UTF8_ELLIPSIS),
+                       //      new BMessage(kEditMenuInTracker)))
+                       .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
+                               B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
+                       .End()
+               .View());
+
+       // Window
+       BBox* windowSettingsBox = new BBox("window");
+       windowSettingsBox->SetLabel(B_TRANSLATE("Window"));
+       windowSettingsBox->AddChild(BLayoutBuilder::Group<>()
                .AddGroup(B_VERTICAL, 0)
                        .Add(fWindowAlwaysOnTop)
                        .Add(fWindowAutoRaise)
@@ -221,16 +223,16 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
-               .View();
-       windowSettingsView->SetName(B_TRANSLATE("Window"));
-
-       BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
-       tabView->AddTab(menuSettingsView);
-       tabView->AddTab(applicationsSettingsView);
-       tabView->AddTab(windowSettingsView);
+               .View());
 
+       // Layout
        BLayoutBuilder::Group<>(this)
-               .Add(tabView)
+               .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
+                       .Add(appsSettingsBox)
+                       .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
+                               .Add(recentItemsBox)
+                               .Add(windowSettingsBox)
+                       .End()
                .SetInsets(B_USE_DEFAULT_SPACING)
                .End();
 

############################################################################

Commit:      cb0602cf812bf04a72f60e4c4c76f6d8ca8b2f11
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cb0602c
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Mar  7 01:39:46 2013 UTC

Implement Revert and Default buttons in Deskbar prefs

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index afb2451..bc9706d 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -485,6 +485,8 @@ TBarApp::MessageReceived(BMessage* message)
                                fSettings.recentDocsCount = count;
                        if (message->FindBool("documentsEnabled", &enabled) == 
B_OK)
                                fSettings.recentDocsEnabled = enabled && count 
> 0;
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case B_SOME_APP_LAUNCHED:
@@ -530,12 +532,14 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.alwaysOnTop = !fSettings.alwaysOnTop;
                        fBarWindow->SetFeel(fSettings.alwaysOnTop ?
                                B_FLOATING_ALL_WINDOW_FEEL : 
B_NORMAL_WINDOW_FEEL);
-                       fPreferencesWindow->PostMessage(kStateChanged);
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kAutoRaise:
                        fSettings.autoRaise = fSettings.alwaysOnTop ? false :
                                !fSettings.autoRaise;
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kAutoHide:
@@ -544,6 +548,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->HideDeskbar(fSettings.autoHide);
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kTrackerFirst:
@@ -552,6 +558,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kSortRunningApps:
@@ -560,6 +568,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kUnsubscribe:
@@ -576,6 +586,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kExpandNewTeams:
@@ -584,6 +596,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kHideLabels:
@@ -592,6 +606,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarWindow->Lock();
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kResizeTeamIcons:
@@ -620,6 +636,8 @@ TBarApp::MessageReceived(BMessage* message)
                                fBarView->UpdatePlacement();
 
                        fBarWindow->Unlock();
+
+                       fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
                }
 
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 40ece97..ed6f336 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -69,6 +69,9 @@ const int32 kMinimumIconSize = 16;
 const int32 kMaximumIconSize = 96;
 const int32 kIconSizeInterval = 8;
 
+// update preferences message constant
+const uint32 kUpdatePreferences = 'Pref';
+
 /* --------------------------------------------- */
 
 struct desk_settings {
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 103d59b..2331702 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -48,6 +48,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW,
                B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
 {
+       // Set the default and intial settings used by default and revert 
buttons
+       _SetDefaultSettings();
+       _SetInitialSettings();
+
        // Menu controls
        fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"),
                new BMessage(kUpdateRecentCounts));
@@ -75,7 +79,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fAppsHideLabels = new BCheckBox(B_TRANSLATE("Hide application names"),
                new BMessage(kHideLabels));
        fAppsIconSizeSlider = new BSlider("icon_size", B_TRANSLATE("Icon size"),
-               NULL, kMinimumIconSize / kIconSizeInterval,
+               new BMessage(kResizeTeamIcons), kMinimumIconSize / 
kIconSizeInterval,
                kMaximumIconSize / kIconSizeInterval, B_HORIZONTAL);
        fAppsIconSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
        fAppsIconSizeSlider->SetHashMarkCount((kMaximumIconSize - 
kMinimumIconSize)
@@ -92,10 +96,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowAutoHide = new BCheckBox(B_TRANSLATE("Auto-hide"),
                new BMessage(kAutoHide));
 
-       // Get settings from BarApp
-       TBarApp* barApp = static_cast<TBarApp*>(be_app);
-       desk_settings* settings = barApp->Settings();
-
        // Menu settings
        BTextView* docTextView = fMenuRecentDocumentCount->TextView();
        BTextView* appTextView = fMenuRecentApplicationCount->TextView();
@@ -113,18 +113,18 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        appTextView->SetMaxBytes(4);
        folderTextView->SetMaxBytes(4);
 
-       int32 docCount = settings->recentDocsCount;
-       int32 appCount = settings->recentAppsCount;
-       int32 folderCount = settings->recentFoldersCount;
+       int32 docCount = fInitialSettings.recentDocsCount;
+       int32 appCount = fInitialSettings.recentAppsCount;
+       int32 folderCount = fInitialSettings.recentFoldersCount;
 
-       fMenuRecentDocuments->SetValue(settings->recentDocsEnabled);
-       fMenuRecentDocumentCount->SetEnabled(settings->recentDocsEnabled);
+       fMenuRecentDocuments->SetValue(fInitialSettings.recentDocsEnabled);
+       
fMenuRecentDocumentCount->SetEnabled(fInitialSettings.recentDocsEnabled);
 
-       fMenuRecentApplications->SetValue(settings->recentAppsEnabled);
-       fMenuRecentApplicationCount->SetEnabled(settings->recentAppsEnabled);
+       fMenuRecentApplications->SetValue(fInitialSettings.recentAppsEnabled);
+       
fMenuRecentApplicationCount->SetEnabled(fInitialSettings.recentAppsEnabled);
 
-       fMenuRecentFolders->SetValue(settings->recentFoldersEnabled);
-       fMenuRecentFolderCount->SetEnabled(settings->recentFoldersEnabled);
+       fMenuRecentFolders->SetValue(fInitialSettings.recentFoldersEnabled);
+       
fMenuRecentFolderCount->SetEnabled(fInitialSettings.recentFoldersEnabled);
 
        BString docString;
        BString appString;
@@ -139,23 +139,25 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fMenuRecentFolderCount->SetText(folderString.String());
 
        // Applications settings
-       fAppsSort->SetValue(settings->sortRunningApps);
-       fAppsSortTrackerFirst->SetValue(settings->trackerAlwaysFirst);
-       fAppsShowExpanders->SetValue(settings->superExpando);
-       fAppsExpandNew->SetValue(settings->expandNewTeams);
-       fAppsHideLabels->SetValue(settings->hideLabels);
-       fAppsIconSizeSlider->SetValue(settings->iconSize / kIconSizeInterval);
+       fAppsSort->SetValue(fInitialSettings.sortRunningApps);
+       fAppsSortTrackerFirst->SetValue(fInitialSettings.trackerAlwaysFirst);
+       fAppsShowExpanders->SetValue(fInitialSettings.superExpando);
+       fAppsExpandNew->SetValue(fInitialSettings.expandNewTeams);
+       fAppsHideLabels->SetValue(fInitialSettings.hideLabels);
+       fAppsIconSizeSlider->SetValue(fInitialSettings.iconSize
+               / kIconSizeInterval);
 
        // Window settings
-       fWindowAlwaysOnTop->SetValue(settings->alwaysOnTop);
-       fWindowAutoRaise->SetValue(settings->autoRaise);
-       fWindowAutoHide->SetValue(settings->autoHide);
+       fWindowAlwaysOnTop->SetValue(fInitialSettings.alwaysOnTop);
+       fWindowAutoRaise->SetValue(fInitialSettings.autoRaise);
+       fWindowAutoHide->SetValue(fInitialSettings.autoHide);
 
-       EnableDisableDependentItems();
+       _EnableDisableDependentItems();
 
        // Targets
        fAppsSort->SetTarget(be_app);
        fAppsSortTrackerFirst->SetTarget(be_app);
+       fAppsShowExpanders->SetTarget(be_app);
        fAppsExpandNew->SetTarget(be_app);
        fAppsHideLabels->SetTarget(be_app);
        fAppsIconSizeSlider->SetTarget(be_app);
@@ -204,8 +206,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                        .Add(fMenuRecentApplicationCount)
                                        .End()
                                .End()
-                       //.Add(new BButton(B_TRANSLATE("Edit menu" 
B_UTF8_ELLIPSIS),
-                       //      new BMessage(kEditMenuInTracker)))
+                               //.Add(new BButton(B_TRANSLATE("Open in 
Tracker" B_UTF8_ELLIPSIS),
+                               //      new BMessage(kOpenInTracker)))
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
@@ -225,16 +227,29 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .End()
                .View());
 
+       // Action Buttons
+       fRevertButton = new BButton(B_TRANSLATE("Revert"),
+               new BMessage(kRevert));
+       fDefaultsButton = new BButton(B_TRANSLATE("Defaults"),
+               new BMessage(kDefaults));
+
        // Layout
        BLayoutBuilder::Group<>(this)
-               .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
-                       .Add(appsSettingsBox)
-                       .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
-                               .Add(recentItemsBox)
-                               .Add(windowSettingsBox)
+               .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
+                       .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
+                               .Add(appsSettingsBox)
+                               .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
+                                       .Add(recentItemsBox)
+                                       .Add(windowSettingsBox)
+                               .End()
                        .End()
-               .SetInsets(B_USE_DEFAULT_SPACING)
-               .End();
+                       .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
+                               .Add(fRevertButton)
+                               .AddGlue()
+                               .Add(fDefaultsButton)
+                               .End()
+                       .SetInsets(B_USE_DEFAULT_SPACING)
+                       .End();
 
        CenterOnScreen();
 }
@@ -242,7 +257,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
 
 PreferencesWindow::~PreferencesWindow()
 {
-       UpdateRecentCounts();
+       _UpdateRecentCounts();
 }
 
 
@@ -250,21 +265,30 @@ void
 PreferencesWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case kEditMenuInTracker:
+               case kOpenInTracker:
                        OpenWithTracker(B_USER_DESKBAR_DIRECTORY);
                        break;
 
-               case kUpdateRecentCounts:
-                       UpdateRecentCounts();
+               case kUpdatePreferences:
+                       _EnableDisableDependentItems();
+                       _UpdateButtons();
                        break;
 
-               case kSuperExpando:
-                       EnableDisableDependentItems();
-                       be_app->PostMessage(message);
+               case kUpdateRecentCounts:
+                       _UpdateRecentCounts();
+                       _UpdateButtons();
                        break;
 
                case kStateChanged:
-                       EnableDisableDependentItems();
+                       _EnableDisableDependentItems();
+                       break;
+
+               case kRevert:
+                       _UpdatePreferences(fInitialSettings);
+                       break;
+
+               case kDefaults:
+                       _UpdatePreferences(fDefaultSettings);
                        break;
 
                default:
@@ -289,8 +313,11 @@ void
 PreferencesWindow::Show()
 {
        if (IsHidden()) {
-               // move to current workspace
                SetWorkspaces(B_CURRENT_WORKSPACE);
+                       // move to current workspace
+               _SetInitialSettings();
+               _UpdateButtons();
+                       // update initial settings for revert
        }
 
        BWindow::Show();
@@ -305,31 +332,11 @@ PreferencesWindow::WindowActivated(bool active)
 }
 
 
-void
-PreferencesWindow::UpdateRecentCounts()
-{
-       BMessage message(kUpdateRecentCounts);
-
-       int32 docCount = atoi(fMenuRecentDocumentCount->Text());
-       int32 appCount = atoi(fMenuRecentApplicationCount->Text());
-       int32 folderCount = atoi(fMenuRecentFolderCount->Text());
-
-       message.AddInt32("documents", max_c(0, docCount));
-       message.AddInt32("applications", max_c(0, appCount));
-       message.AddInt32("folders", max_c(0, folderCount));
-
-       message.AddBool("documentsEnabled", fMenuRecentDocuments->Value());
-       message.AddBool("applicationsEnabled", 
fMenuRecentApplications->Value());
-       message.AddBool("foldersEnabled", fMenuRecentFolders->Value());
-
-       be_app->PostMessage(&message);
-
-       EnableDisableDependentItems();
-}
+//     #pragma mark - private methods
 
 
 void
-PreferencesWindow::EnableDisableDependentItems()
+PreferencesWindow::_EnableDisableDependentItems()
 {
        TBarApp* barApp = static_cast<TBarApp*>(be_app);
        if (barApp->BarView()->Vertical()
@@ -343,11 +350,226 @@ PreferencesWindow::EnableDisableDependentItems()
 
        fMenuRecentDocumentCount->SetEnabled(
                fMenuRecentDocuments->Value() != B_CONTROL_OFF);
-       fMenuRecentApplicationCount->SetEnabled(
-               fMenuRecentApplications->Value() != B_CONTROL_OFF);
        fMenuRecentFolderCount->SetEnabled(
                fMenuRecentFolders->Value() != B_CONTROL_OFF);
+       fMenuRecentApplicationCount->SetEnabled(
+               fMenuRecentApplications->Value() != B_CONTROL_OFF);
 
        fWindowAutoRaise->SetEnabled(
                fWindowAlwaysOnTop->Value() == B_CONTROL_OFF);
 }
+
+
+bool
+PreferencesWindow::_IsDefaultable()
+{
+       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
+
+       return fDefaultSettings.sortRunningApps != settings->sortRunningApps
+               || fDefaultSettings.trackerAlwaysFirst != 
settings->trackerAlwaysFirst
+               || fDefaultSettings.superExpando != settings->superExpando
+               || fDefaultSettings.expandNewTeams != settings->expandNewTeams
+               || fDefaultSettings.hideLabels != settings->hideLabels
+               || fDefaultSettings.iconSize != settings->iconSize
+               || fDefaultSettings.recentAppsEnabled != 
settings->recentAppsEnabled
+               || fDefaultSettings.recentDocsEnabled != 
settings->recentDocsEnabled
+               || fDefaultSettings.recentFoldersEnabled
+                       != settings->recentFoldersEnabled
+               || fDefaultSettings.recentAppsCount != settings->recentAppsCount
+               || fDefaultSettings.recentDocsCount != settings->recentDocsCount
+               || fDefaultSettings.recentFoldersCount != 
settings->recentFoldersCount
+               || fDefaultSettings.alwaysOnTop != settings->alwaysOnTop
+               || fDefaultSettings.autoRaise != settings->autoRaise
+               || fDefaultSettings.autoHide != settings->autoHide;
+}
+
+
+bool
+PreferencesWindow::_IsRevertable()
+{
+       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
+
+       return fInitialSettings.sortRunningApps != settings->sortRunningApps
+               || fInitialSettings.trackerAlwaysFirst != 
settings->trackerAlwaysFirst
+               || fInitialSettings.superExpando != settings->superExpando
+               || fInitialSettings.expandNewTeams != settings->expandNewTeams
+               || fInitialSettings.hideLabels != settings->hideLabels
+               || fInitialSettings.iconSize != settings->iconSize
+               || fInitialSettings.recentAppsEnabled != 
settings->recentAppsEnabled
+               || fInitialSettings.recentDocsEnabled != 
settings->recentDocsEnabled
+               || fInitialSettings.recentFoldersEnabled
+                       != settings->recentFoldersEnabled
+               || fInitialSettings.recentAppsCount != settings->recentAppsCount
+               || fInitialSettings.recentDocsCount != settings->recentDocsCount
+               || fInitialSettings.recentFoldersCount != 
settings->recentFoldersCount
+               || fInitialSettings.alwaysOnTop != settings->alwaysOnTop
+               || fInitialSettings.autoRaise != settings->autoRaise
+               || fInitialSettings.autoHide != settings->autoHide;
+}
+
+
+void
+PreferencesWindow::_SetDefaultSettings()
+{
+       // applications
+       fDefaultSettings.sortRunningApps = false;
+       fDefaultSettings.trackerAlwaysFirst = false;
+       fDefaultSettings.superExpando = false;
+       fDefaultSettings.expandNewTeams = false;
+       fDefaultSettings.hideLabels = false;
+       fDefaultSettings.iconSize = kMinimumIconSize;
+
+       // recent items
+       fDefaultSettings.recentAppsEnabled = true;
+       fDefaultSettings.recentDocsEnabled = true;
+       fDefaultSettings.recentFoldersEnabled = true;
+       fDefaultSettings.recentAppsCount = 10;
+       fDefaultSettings.recentDocsCount = 10;
+       fDefaultSettings.recentFoldersCount = 10;
+
+       // window
+       fDefaultSettings.alwaysOnTop = false;
+       fDefaultSettings.autoRaise = false;
+       fDefaultSettings.autoHide = false;
+}
+
+
+void
+PreferencesWindow::_SetInitialSettings()
+{
+       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
+
+       // applications
+       fInitialSettings.sortRunningApps = settings->sortRunningApps;
+       fInitialSettings.trackerAlwaysFirst = settings->trackerAlwaysFirst;
+       fInitialSettings.superExpando = settings->superExpando;
+       fInitialSettings.expandNewTeams = settings->expandNewTeams;
+       fInitialSettings.hideLabels = settings->hideLabels;
+       fInitialSettings.iconSize = settings->iconSize;
+
+       // recent items
+       fInitialSettings.recentAppsEnabled = settings->recentAppsEnabled;
+       fInitialSettings.recentDocsEnabled = settings->recentDocsEnabled;
+       fInitialSettings.recentFoldersEnabled = settings->recentFoldersEnabled;
+       fInitialSettings.recentAppsCount = settings->recentAppsCount;
+       fInitialSettings.recentDocsCount = settings->recentDocsCount;
+       fInitialSettings.recentFoldersCount = settings->recentFoldersCount;
+
+       // window
+       fInitialSettings.alwaysOnTop = settings->alwaysOnTop;
+       fInitialSettings.autoRaise = settings->autoRaise;
+       fInitialSettings.autoHide = settings->autoHide;
+}
+
+
+
+void
+PreferencesWindow::_UpdateButtons()
+{
+       fRevertButton->SetEnabled(_IsRevertable());
+       fDefaultsButton->SetEnabled(_IsDefaultable());
+}
+
+
+void
+PreferencesWindow::_UpdatePreferences(pref_settings prefs)
+{
+       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
+       bool updateRecentCounts = false;
+
+       if (settings->sortRunningApps != prefs.sortRunningApps) {
+               fAppsSort->SetValue(prefs.sortRunningApps);
+               fAppsSort->Invoke();
+       }
+       if (settings->trackerAlwaysFirst != prefs.trackerAlwaysFirst) {
+               fAppsSortTrackerFirst->SetValue(prefs.trackerAlwaysFirst);
+               fAppsSortTrackerFirst->Invoke();
+       }
+       if (settings->superExpando != prefs.superExpando) {
+               fAppsShowExpanders->SetValue(prefs.superExpando);
+               fAppsShowExpanders->Invoke();
+       }
+       if (settings->expandNewTeams != prefs.expandNewTeams) {
+               fAppsExpandNew->SetValue(prefs.expandNewTeams);
+               fAppsExpandNew->Invoke();
+       }
+       if (settings->hideLabels != prefs.hideLabels) {
+               fAppsHideLabels->SetValue(prefs.hideLabels);
+               fAppsHideLabels->Invoke();
+       }
+       if (settings->iconSize != prefs.iconSize) {
+               fAppsIconSizeSlider->SetValue(prefs.iconSize / 
kIconSizeInterval);
+               fAppsIconSizeSlider->Invoke();
+       }
+       if (settings->recentDocsEnabled != prefs.recentDocsEnabled) {
+               fMenuRecentDocuments->SetValue(prefs.recentDocsEnabled
+                       ? B_CONTROL_ON : B_CONTROL_OFF);
+               updateRecentCounts = true;
+       }
+       if (settings->recentFoldersEnabled != prefs.recentFoldersEnabled) {
+               fMenuRecentFolders->SetValue(prefs.recentFoldersEnabled
+                       ? B_CONTROL_ON : B_CONTROL_OFF);
+               updateRecentCounts = true;
+       }
+       if (settings->recentAppsEnabled != fDefaultSettings.recentAppsEnabled) {
+               fMenuRecentApplications->SetValue(prefs.recentAppsEnabled
+                       ? B_CONTROL_ON : B_CONTROL_OFF);
+               updateRecentCounts = true;
+       }
+       if (settings->recentDocsCount != prefs.recentDocsCount) {
+               BString docString;
+               docString << prefs.recentDocsCount;
+               fMenuRecentDocumentCount->SetText(docString.String());
+               updateRecentCounts = true;
+       }
+       if (settings->recentFoldersCount != prefs.recentFoldersCount) {
+               BString folderString;
+               folderString << prefs.recentFoldersCount;
+               fMenuRecentFolderCount->SetText(folderString.String());
+               updateRecentCounts = true;
+       }
+       if (settings->recentAppsCount != prefs.recentAppsCount) {
+               BString appString;
+               appString << prefs.recentAppsCount;
+               fMenuRecentApplicationCount->SetText(appString.String());
+               updateRecentCounts = true;
+       }
+       if (settings->alwaysOnTop != prefs.alwaysOnTop) {
+               fWindowAlwaysOnTop->SetValue(prefs.alwaysOnTop);
+               fWindowAlwaysOnTop->Invoke();
+       }
+       if (settings->autoRaise != prefs.autoRaise) {
+               fWindowAutoRaise->SetValue(prefs.autoRaise);
+               fWindowAutoRaise->Invoke();
+       }
+       if (settings->autoHide != prefs.autoHide) {
+               fWindowAutoHide->SetValue(prefs.autoHide);
+               fWindowAutoHide->Invoke();
+       }
+
+       if (updateRecentCounts)
+               _UpdateRecentCounts();
+}
+
+
+void
+PreferencesWindow::_UpdateRecentCounts()
+{
+       BMessage message(kUpdateRecentCounts);
+
+       int32 docCount = atoi(fMenuRecentDocumentCount->Text());
+       int32 appCount = atoi(fMenuRecentApplicationCount->Text());
+       int32 folderCount = atoi(fMenuRecentFolderCount->Text());
+
+       message.AddInt32("documents", max_c(0, docCount));
+       message.AddInt32("applications", max_c(0, appCount));
+       message.AddInt32("folders", max_c(0, folderCount));
+
+       message.AddBool("documentsEnabled", fMenuRecentDocuments->Value());
+       message.AddBool("applicationsEnabled", 
fMenuRecentApplications->Value());
+       message.AddBool("foldersEnabled", fMenuRecentFolders->Value());
+
+       be_app->PostMessage(&message);
+
+       _EnableDisableDependentItems();
+}
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index ac1cbbc..6f11588 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -11,7 +11,7 @@
 
 const uint32 kConfigShow                       = 'show';
 const uint32 kUpdateRecentCounts       = 'upct';
-const uint32 kEditMenuInTracker                = 'mtrk';
+const uint32 kOpenInTracker                    = 'otrk';
 
 const uint32 kTrackerFirst                     = 'TkFt';
 const uint32 kSortRunningApps          = 'SAps';
@@ -22,6 +22,32 @@ const uint32 kResizeTeamIcons                = 'RTIs';
 const uint32 kAutoRaise                                = 'AtRs';
 const uint32 kAutoHide                         = 'AtHd';
 
+const uint32 kDefaults                         = 'dflt';
+const uint32 kRevert                           = 'rvrt';
+
+
+struct pref_settings {
+       // applications
+       bool trackerAlwaysFirst;
+       bool sortRunningApps;
+       bool superExpando;
+       bool expandNewTeams;
+       bool hideLabels;
+       int32 iconSize;
+       // recent items
+       int32 recentAppsCount;
+       int32 recentDocsCount;
+       int32 recentFoldersCount;
+       bool recentAppsEnabled;
+       bool recentDocsEnabled;
+       bool recentFoldersEnabled;
+       // window
+       bool alwaysOnTop;
+       bool autoRaise;
+       bool autoHide;
+};
+
+
 class BCheckBox;
 class BRadioButton;
 class BSlider;
@@ -38,8 +64,18 @@ public:
        virtual void                    Show();
        virtual void                    WindowActivated(bool active);
 
-                       void                    UpdateRecentCounts();
-                       void                    EnableDisableDependentItems();
+private:
+                       void                    _EnableDisableDependentItems();
+
+                       bool                    _IsDefaultable();
+                       bool                    _IsRevertable();
+
+                       void                    _SetDefaultSettings();
+                       void                    _SetInitialSettings();
+
+                       void                    _UpdateButtons();
+                       void                    
_UpdatePreferences(pref_settings prefs);
+                       void                    _UpdateRecentCounts();
 
 private:
                        BCheckBox*              fMenuRecentDocuments;
@@ -60,6 +96,13 @@ private:
                        BCheckBox*              fWindowAlwaysOnTop;
                        BCheckBox*              fWindowAutoRaise;
                        BCheckBox*              fWindowAutoHide;
+
+                       BButton*                fRevertButton;
+                       BButton*                fDefaultsButton;
+
+private:
+                       pref_settings   fDefaultSettings;
+                       pref_settings   fInitialSettings;
 };
 
 

############################################################################

Commit:      1ec3d372525d8c8c8ed4cb37dee6c773cf764303
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1ec3d37
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Mar  9 00:48:27 2013 UTC

Rename 'Sort running applications' to 'Sort applications by name'

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 2331702..6348565 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -68,7 +68,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                new BMessage(kUpdateRecentCounts));
 
        // Applications controls
-       fAppsSort = new BCheckBox(B_TRANSLATE("Sort running applications"),
+       fAppsSort = new BCheckBox(B_TRANSLATE("Sort applications by name"),
                new BMessage(kSortRunningApps));
        fAppsSortTrackerFirst = new BCheckBox(B_TRANSLATE("Tracker always 
first"),
                new BMessage(kTrackerFirst));

############################################################################

Commit:      cb42238603639d60d3775a92b765715ef41edb97
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cb42238
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Mar  9 01:37:33 2013 UTC

Destroy prefs window on close once again

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index bc9706d..a8f5580 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -172,21 +172,10 @@ TBarApp::~TBarApp()
 bool
 TBarApp::QuitRequested()
 {
-       // don't allow user quitting
+       // don't allow the user to quit
        if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) {
-               // but allow quitting to hide fPreferencesWindow
-               int32 index = 0;
-               BWindow* window = NULL;
-               while ((window = WindowAt(index++)) != NULL) {
-                       if (window == fPreferencesWindow) {
-                               if (fPreferencesWindow->Lock()) {
-                                       if (fPreferencesWindow->IsActive())
-                                               
fPreferencesWindow->PostMessage(B_QUIT_REQUESTED);
-                                       fPreferencesWindow->Unlock();
-                               }
-                               break;
-                       }
-               }
+               // but close the preferences window
+               QuitPreferencesWindow();
                return false;
        }
 
@@ -449,8 +438,13 @@ TBarApp::MessageReceived(BMessage* message)
                        ShowPreferencesWindow();
                        break;
 
+               case kConfigQuit:
+                       QuitPreferencesWindow();
+                       break;
+
                case kStateChanged:
-                       fPreferencesWindow->PostMessage(kStateChanged);
+                       if (fPreferencesWindow != NULL)
+                               fPreferencesWindow->PostMessage(kStateChanged);
                        break;
 
                case kShowDeskbarMenu:
@@ -486,7 +480,8 @@ TBarApp::MessageReceived(BMessage* message)
                        if (message->FindBool("documentsEnabled", &enabled) == 
B_OK)
                                fSettings.recentDocsEnabled = enabled && count 
> 0;
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case B_SOME_APP_LAUNCHED:
@@ -532,14 +527,16 @@ TBarApp::MessageReceived(BMessage* message)
                        fSettings.alwaysOnTop = !fSettings.alwaysOnTop;
                        fBarWindow->SetFeel(fSettings.alwaysOnTop ?
                                B_FLOATING_ALL_WINDOW_FEEL : 
B_NORMAL_WINDOW_FEEL);
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kAutoRaise:
                        fSettings.autoRaise = fSettings.alwaysOnTop ? false :
                                !fSettings.autoRaise;
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kAutoHide:
@@ -549,7 +546,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->HideDeskbar(fSettings.autoHide);
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kTrackerFirst:
@@ -559,7 +557,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kSortRunningApps:
@@ -569,7 +568,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kUnsubscribe:
@@ -587,7 +587,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kExpandNewTeams:
@@ -597,7 +598,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kHideLabels:
@@ -607,7 +609,8 @@ TBarApp::MessageReceived(BMessage* message)
                        fBarView->PlaceApplicationBar();
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
 
                case kResizeTeamIcons:
@@ -637,7 +640,8 @@ TBarApp::MessageReceived(BMessage* message)
 
                        fBarWindow->Unlock();
 
-                       fPreferencesWindow->PostMessage(kUpdatePreferences);
+                       if (fPreferencesWindow != NULL)
+                               
fPreferencesWindow->PostMessage(kUpdatePreferences);
                        break;
                }
 
@@ -911,14 +915,33 @@ TBarApp::ShowPreferencesWindow()
        if (fPreferencesWindow == NULL) {
                fPreferencesWindow = new PreferencesWindow(BRect(0, 0, 320, 
240));
                fPreferencesWindow->Show();
-       } else {
-               if (fPreferencesWindow->Lock()) {
-                       if (fPreferencesWindow->IsHidden())
-                               fPreferencesWindow->Show();
-                       else
-                               fPreferencesWindow->Activate();
+       } else if (fPreferencesWindow->Lock()) {
+               if (fPreferencesWindow->IsHidden())
+                       fPreferencesWindow->Show();
+               else
+                       fPreferencesWindow->Activate();
+
+               fPreferencesWindow->Unlock();
+       }
+}
+
 
-                       fPreferencesWindow->Unlock();
+void
+TBarApp::QuitPreferencesWindow()
+{
+       if (fPreferencesWindow == NULL)
+               return;
+
+       int32 index = 0;
+       BWindow* window = NULL;
+       while ((window = WindowAt(index++)) != NULL) {
+               if (window == fPreferencesWindow) {
+                       if (fPreferencesWindow->Lock()) {
+                               fPreferencesWindow->Quit();
+                                       // Quit() destroys the window so don't 
unlock
+                               fPreferencesWindow = NULL;
+                       }
+                       break;
                }
        }
 }
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index ed6f336..42b2889 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -159,6 +159,8 @@ private:
                        void                                    SaveSettings();
 
                        void                                    
ShowPreferencesWindow();
+                       void                                    
QuitPreferencesWindow();
+
                        void                                    
ResizeTeamIcons();
                        void                                    
FetchAppIcon(const char* signature,
                                                                                
BBitmap* icon);
diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp
index b85c082..24d5265 100644
--- a/src/apps/deskbar/DeskbarMenu.cpp
+++ b/src/apps/deskbar/DeskbarMenu.cpp
@@ -379,6 +379,7 @@ TDeskbarMenu::ResetTargets()
                                case kShowSplash:
                                case kToggleDraggers:
                                case kConfigShow:
+                               case kConfigQuit:
                                case kAlwaysTop:
                                case kExpandNewTeams:
                                case kHideLabels:
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 6348565..5a62739 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -301,10 +301,8 @@ PreferencesWindow::MessageReceived(BMessage* message)
 bool
 PreferencesWindow::QuitRequested()
 {
-       if (IsHidden())
-               return true;
+       be_app->PostMessage(kConfigQuit);
 
-       Hide();
        return false;
 }
 
@@ -312,23 +310,12 @@ PreferencesWindow::QuitRequested()
 void
 PreferencesWindow::Show()
 {
-       if (IsHidden()) {
+       if (IsHidden())
                SetWorkspaces(B_CURRENT_WORKSPACE);
-                       // move to current workspace
-               _SetInitialSettings();
-               _UpdateButtons();
-                       // update initial settings for revert
-       }
-
-       BWindow::Show();
-}
 
+       _UpdateButtons();
 
-void
-PreferencesWindow::WindowActivated(bool active)
-{
-       if (!active && IsMinimized())
-               PostMessage(B_QUIT_REQUESTED);
+       BWindow::Show();
 }
 
 
@@ -462,7 +449,6 @@ PreferencesWindow::_SetInitialSettings()
 }
 
 
-
 void
 PreferencesWindow::_UpdateButtons()
 {
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index 6f11588..4b885d8 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -9,7 +9,8 @@
 #include <Window.h>
 
 
-const uint32 kConfigShow                       = 'show';
+const uint32 kConfigShow                       = 'PrSh';
+const uint32 kConfigQuit                       = 'PrQt';
 const uint32 kUpdateRecentCounts       = 'upct';
 const uint32 kOpenInTracker                    = 'otrk';
 
@@ -62,7 +63,6 @@ public:
        virtual void                    MessageReceived(BMessage* message);
        virtual bool                    QuitRequested();
        virtual void                    Show();
-       virtual void                    WindowActivated(bool active);
 
 private:
                        void                    _EnableDisableDependentItems();

############################################################################

Commit:      43917ef2e0654197d1d98dc0ed50095f6c813d7a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=43917ef
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Mar  9 03:30:14 2013 UTC

Refactor settings so that defaults get set in 1 place.

* Move desk_settings and clock_settings struct to a new header entitled
  'BarSettings.h' so it can be included in BarApp.h and PreferencesWindow.h.
* Refactor desk_settings to only include used, or at least relevant settings,
  some cruft had built up over time.
* Refactor the InitSettings() method, all the B_OK checking wasn't working so
  I removed it. Defaults get set up to and if the corresponding setting is
  found in the settings file it is replaced, else, it is not.
* Reorder the struct and code so it goes in the order that the settings appear:
  applications, then recent items, then window settings.
* Simplify the preferences window revert and defaults code based on using the
  prebuild desk_settings structs in BarApp instead of creating our own and
  copying. All initial setup is in the constructor.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index a8f5580..cf0c059 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -192,20 +192,15 @@ TBarApp::SaveSettings()
        if (fSettingsFile->InitCheck() == B_OK) {
                fSettingsFile->Seek(0, SEEK_SET);
                BMessage storedSettings;
+
                storedSettings.AddBool("vertical", fSettings.vertical);
                storedSettings.AddBool("left", fSettings.left);
                storedSettings.AddBool("top", fSettings.top);
-               storedSettings.AddInt32("state", fSettings.state);
+               storedSettings.AddUInt32("state", fSettings.state);
                storedSettings.AddFloat("width", fSettings.width);
-               storedSettings.AddBool("showClock", fSettings.showClock);
                storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc);
-               storedSettings.AddInt32("recentAppsCount", 
fSettings.recentAppsCount);
-               storedSettings.AddInt32("recentDocsCount", 
fSettings.recentDocsCount);
-               storedSettings.AddBool("timeShowSeconds", 
fSettings.timeShowSeconds);
-               storedSettings.AddInt32("recentFoldersCount",
-                       fSettings.recentFoldersCount);
-               storedSettings.AddBool("alwaysOnTop", fSettings.alwaysOnTop);
-               storedSettings.AddBool("timeFullDate", fSettings.timeFullDate);
+               storedSettings.AddBool("showClock", fSettings.showClock);
+               // applications
                storedSettings.AddBool("trackerAlwaysFirst",
                        fSettings.trackerAlwaysFirst);
                storedSettings.AddBool("sortRunningApps", 
fSettings.sortRunningApps);
@@ -213,14 +208,23 @@ TBarApp::SaveSettings()
                storedSettings.AddBool("expandNewTeams", 
fSettings.expandNewTeams);
                storedSettings.AddBool("hideLabels", fSettings.hideLabels);
                storedSettings.AddInt32("iconSize", fSettings.iconSize);
-               storedSettings.AddBool("autoRaise", fSettings.autoRaise);
-               storedSettings.AddBool("autoHide", fSettings.autoHide);
-               storedSettings.AddBool("recentAppsEnabled",
-                       fSettings.recentAppsEnabled);
+               // recent items
                storedSettings.AddBool("recentDocsEnabled",
                        fSettings.recentDocsEnabled);
                storedSettings.AddBool("recentFoldersEnabled",
                        fSettings.recentFoldersEnabled);
+               storedSettings.AddBool("recentAppsEnabled",
+                       fSettings.recentAppsEnabled);
+               storedSettings.AddInt32("recentDocsCount",
+                       fSettings.recentDocsCount);
+               storedSettings.AddInt32("recentFoldersCount",
+                       fSettings.recentFoldersCount);
+               storedSettings.AddInt32("recentAppsCount",
+                       fSettings.recentAppsCount);
+               // window
+               storedSettings.AddBool("alwaysOnTop", fSettings.alwaysOnTop);
+               storedSettings.AddBool("autoRaise", fSettings.autoRaise);
+               storedSettings.AddBool("autoHide", fSettings.autoHide);
 
                storedSettings.Flatten(fSettingsFile);
        }
@@ -245,30 +249,32 @@ void
 TBarApp::InitSettings()
 {
        desk_settings settings;
-       settings.vertical = true;
-       settings.left = false;
-       settings.top = true;
-       settings.state = kExpandoState;
-       settings.width = 0;
-       settings.showClock = true;
-       settings.switcherLoc = BPoint(5000, 5000);
-       settings.recentAppsCount = 10;
-       settings.recentDocsCount = 10;
-       settings.timeShowSeconds = false;
-       settings.recentFoldersCount = 10;
-       settings.alwaysOnTop = false;
-       settings.timeFullDate = false;
-       settings.trackerAlwaysFirst = false;
-       settings.sortRunningApps = false;
-       settings.superExpando = false;
-       settings.expandNewTeams = false;
-       settings.hideLabels = false;
-       settings.iconSize = kMinimumIconSize;
-       settings.autoRaise = false;
-       settings.autoHide = false;
-       settings.recentAppsEnabled = true;
-       settings.recentDocsEnabled = true;
-       settings.recentFoldersEnabled = true;
+       settings.vertical = fDefaultSettings.vertical = true;
+       settings.left = fDefaultSettings.left = false;
+       settings.top = fDefaultSettings.top = true;
+       settings.state = fDefaultSettings.state = kExpandoState;
+       settings.width = fDefaultSettings.width = 0;
+       settings.switcherLoc = fDefaultSettings.switcherLoc = BPoint(5000, 
5000);
+       settings.showClock = fDefaultSettings.showClock = true;
+       // applications
+       settings.trackerAlwaysFirst = fDefaultSettings.trackerAlwaysFirst = 
false;
+       settings.sortRunningApps = fDefaultSettings.sortRunningApps = false;
+       settings.superExpando = fDefaultSettings.superExpando = false;
+       settings.expandNewTeams = fDefaultSettings.expandNewTeams = false;
+       settings.hideLabels = fDefaultSettings.hideLabels = false;
+       settings.iconSize = fDefaultSettings.iconSize = kMinimumIconSize;
+       // recent items
+       settings.recentDocsEnabled = fDefaultSettings.recentDocsEnabled = true;
+       settings.recentFoldersEnabled
+               = fDefaultSettings.recentFoldersEnabled = true;
+       settings.recentAppsEnabled = fDefaultSettings.recentAppsEnabled = true;
+       settings.recentDocsCount = fDefaultSettings.recentDocsCount = 10;
+       settings.recentFoldersCount = fDefaultSettings.recentFoldersCount = 10;
+       settings.recentAppsCount = fDefaultSettings.recentAppsCount = 10;
+       // window
+       settings.alwaysOnTop = fDefaultSettings.alwaysOnTop = false;
+       settings.autoRaise = fDefaultSettings.autoRaise = false;
+       settings.autoHide = fDefaultSettings.autoHide = false;
 
        clock_settings clock;
        clock.showSeconds = false;
@@ -292,6 +298,45 @@ TBarApp::InitSettings()
                                theDir.CreateFile(settingsFileName, 
fSettingsFile);
                }
 
+               BMessage storedSettings;
+               if (fSettingsFile->InitCheck() == B_OK
+                       && storedSettings.Unflatten(fSettingsFile) == B_OK) {
+                       storedSettings.FindBool("vertical", &settings.vertical);
+                       storedSettings.FindBool("left", &settings.left);
+                       storedSettings.FindBool("top", &settings.top);
+                       storedSettings.FindUInt32("state", &settings.state);
+                       storedSettings.FindFloat("width", &settings.width);
+                       storedSettings.FindPoint("switcherLoc", 
&settings.switcherLoc);
+                       storedSettings.FindBool("showClock", 
&settings.showClock);
+                       // applications
+                       storedSettings.FindBool("trackerAlwaysFirst",
+                               &settings.trackerAlwaysFirst);
+                       storedSettings.FindBool("sortRunningApps",
+                               &settings.sortRunningApps);
+                       storedSettings.FindBool("superExpando", 
&settings.superExpando);
+                       storedSettings.FindBool("expandNewTeams",
+                               &settings.expandNewTeams);
+                       storedSettings.FindBool("hideLabels", 
&settings.hideLabels);
+                       storedSettings.FindInt32("iconSize", 
&settings.iconSize);
+                       // recent items
+                       storedSettings.FindBool("recentDocsEnabled",
+                               &settings.recentDocsEnabled);
+                       storedSettings.FindBool("recentFoldersEnabled",
+                               &settings.recentFoldersEnabled);
+                       storedSettings.FindBool("recentAppsEnabled",
+                               &settings.recentAppsEnabled);
+                       storedSettings.FindInt32("recentDocsCount",
+                               &settings.recentDocsCount);
+                       storedSettings.FindInt32("recentFoldersCount",
+                               &settings.recentFoldersCount);
+                       storedSettings.FindInt32("recentAppsCount",
+                               &settings.recentAppsCount);
+                       // window
+                       storedSettings.FindBool("alwaysOnTop", 
&settings.alwaysOnTop);
+                       storedSettings.FindBool("autoRaise", 
&settings.autoRaise);
+                       storedSettings.FindBool("autoHide", &settings.autoHide);
+               }
+
                filePath = dirPath;
                filePath.Append(clockSettingsFileName);
                fClockSettingsFile = new BFile(filePath.Path(), O_RDWR);
@@ -301,113 +346,11 @@ TBarApp::InitSettings()
                                theDir.CreateFile(clockSettingsFileName, 
fClockSettingsFile);
                }
 
-               BMessage storedSettings;
-               if (fSettingsFile->InitCheck() == B_OK
-                       && storedSettings.Unflatten(fSettingsFile) == B_OK) {
-                       if (storedSettings.FindBool("vertical", 
&settings.vertical)
-                                       != B_OK) {
-                               settings.vertical = true;
-                       }
-                       if (storedSettings.FindBool("left", &settings.left) != 
B_OK)
-                               settings.left = false;
-                       if (storedSettings.FindBool("top", &settings.top) != 
B_OK)
-                               settings.top = true;
-                       if (storedSettings.FindInt32("state", 
(int32*)&settings.state)
-                                       != B_OK) {
-                               settings.state = kExpandoState;
-                       }
-                       if (storedSettings.FindFloat("width", &settings.width) 
!= B_OK)
-                               settings.width = 0;
-                       if (storedSettings.FindBool("showClock", 
&settings.showClock)
-                                       != B_OK) {
-                               settings.showClock = true;
-                       }
-                       if (storedSettings.FindPoint("switcherLoc", 
&settings.switcherLoc)
-                                       != B_OK) {
-                               settings.switcherLoc = BPoint(5000, 5000);
-                       }
-                       if (storedSettings.FindInt32("recentAppsCount",
-                                       &settings.recentAppsCount) != B_OK) {
-                               settings.recentAppsCount = 10;
-                       }
-                       if (storedSettings.FindInt32("recentDocsCount",
-                                       &settings.recentDocsCount) != B_OK) {
-                               settings.recentDocsCount = 10;
-                       }
-                       if (storedSettings.FindBool("timeShowSeconds",
-                                       &settings.timeShowSeconds) != B_OK) {
-                               settings.timeShowSeconds = false;
-                       }
-                       if (storedSettings.FindInt32("recentFoldersCount",
-                                       &settings.recentFoldersCount) != B_OK) {
-                               settings.recentFoldersCount = 10;
-                       }
-                       if (storedSettings.FindBool("alwaysOnTop", 
&settings.alwaysOnTop)
-                                       != B_OK) {
-                               settings.alwaysOnTop = false;
-                       }
-                       if (storedSettings.FindBool("timeFullDate", 
&settings.timeFullDate)
-                                       != B_OK) {
-                               settings.timeFullDate = false;
-                       }
-                       if (storedSettings.FindBool("trackerAlwaysFirst",
-                                       &settings.trackerAlwaysFirst) != B_OK) {
-                               settings.trackerAlwaysFirst = false;
-                       }
-                       if (storedSettings.FindBool("sortRunningApps",
-                                       &settings.sortRunningApps) != B_OK) {
-                               settings.sortRunningApps = false;
-                       }
-                       if (storedSettings.FindBool("superExpando", 
&settings.superExpando)
-                                       != B_OK) {
-                               settings.superExpando = false;
-                       }
-                       if (storedSettings.FindBool("expandNewTeams",
-                                       &settings.expandNewTeams) != B_OK) {
-                               settings.expandNewTeams = false;
-                       }
-                       if (storedSettings.FindBool("hideLabels", 
&settings.hideLabels)
-                                       != B_OK) {
-                               settings.hideLabels = false;
-                       }
-                       if (storedSettings.FindInt32("iconSize", 
(int32*)&settings.iconSize)
-                                       != B_OK) {
-                               settings.iconSize = kMinimumIconSize;
-                       }
-                       if (storedSettings.FindBool("autoRaise", 
&settings.autoRaise)
-                                       != B_OK) {
-                               settings.autoRaise = false;
-                       }
-                       if (storedSettings.FindBool("autoHide", 
&settings.autoHide) != B_OK)
-                               settings.autoHide = false;
-                       if (storedSettings.FindBool("recentAppsEnabled",
-                                       &settings.recentAppsEnabled) != B_OK) {
-                               settings.recentAppsEnabled = true;
-                       }
-                       if (storedSettings.FindBool("recentDocsEnabled",
-                                       &settings.recentDocsEnabled) != B_OK) {
-                               settings.recentDocsEnabled = true;
-                       }
-                       if (storedSettings.FindBool("recentFoldersEnabled",
-                                       &settings.recentFoldersEnabled) != 
B_OK) {
-                               settings.recentFoldersEnabled = true;
-                       }
-               }
-
                if (fClockSettingsFile->InitCheck() == B_OK
                        && storedSettings.Unflatten(fClockSettingsFile) == 
B_OK) {
-                       if (storedSettings.FindBool("showSeconds", 
&clock.showSeconds)
-                                       != B_OK) {
-                               clock.showSeconds = false;
-                       }
-                       if (storedSettings.FindBool("showDayOfWeek",
-                                       &clock.showDayOfWeek) != B_OK) {
-                               clock.showDayOfWeek = false;
-                       }
-                       if (storedSettings.FindBool("showTimeZone",
-                                       &clock.showTimeZone) != B_OK) {
-                               clock.showDayOfWeek = false;
-                       }
+                       storedSettings.FindBool("showSeconds", 
&clock.showSeconds);
+                       storedSettings.FindBool("showDayOfWeek", 
&clock.showDayOfWeek);
+                       storedSettings.FindBool("showTimeZone", 
&clock.showTimeZone);
                }
        }
 
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 42b2889..3dcd05e 100644
--- a/src/apps/deskbar/BarApp.h
+++ b/src/apps/deskbar/BarApp.h
@@ -38,6 +38,9 @@ All rights reserved.
 
 #include <Application.h>
 
+#include "BarSettings.h"
+
+
 /* ------------------------------------ */
 // Private app_server defines that I need to use
 
@@ -74,40 +77,6 @@ const uint32 kUpdatePreferences = 'Pref';
 
 /* --------------------------------------------- */
 
-struct desk_settings {
-       bool vertical;
-       bool left;
-       bool top;
-       uint32 state;
-       float width;
-       bool showClock;
-       BPoint switcherLoc;
-       int32 recentAppsCount;
-       int32 recentDocsCount;
-       bool timeShowSeconds;
-       int32 recentFoldersCount;
-       bool alwaysOnTop;
-       bool timeFullDate;
-       bool trackerAlwaysFirst;
-       bool sortRunningApps;
-       bool superExpando;
-       bool expandNewTeams;
-       bool hideLabels;
-       int32 iconSize;
-       bool autoRaise;
-       bool autoHide;
-       bool recentAppsEnabled;
-       bool recentDocsEnabled;
-       bool recentFoldersEnabled;
-};
-
-struct clock_settings {
-       bool showSeconds;
-       bool showDayOfWeek;
-       bool showTimeZone;
-};
-
-
 class BFile;
 class BList;
 class BBitmap;
@@ -139,6 +108,8 @@ public:
        virtual void                                    RefsReceived(BMessage* 
refs);
 
                        desk_settings*                  Settings() { return 
&fSettings; }
+                       desk_settings*                  DefaultSettings()
+                                                                               
{ return &fDefaultSettings; }
                        clock_settings*                 ClockSettings() { 
return &fClockSettings; }
 
                        TBarView*                               BarView() const 
{ return fBarView; }
@@ -166,6 +137,8 @@ private:
                                                                                
BBitmap* icon);
 
                        BRect                                   IconRect();
+
+private:
                        TBarWindow*                             fBarWindow;
                        TBarView*                               fBarView;
                        BMessenger                              
fSwitcherMessenger;
@@ -173,6 +146,7 @@ private:
                        BFile*                                  fSettingsFile;
                        BFile*                                  
fClockSettingsFile;
                        desk_settings                   fSettings;
+                       desk_settings                   fDefaultSettings;
                        clock_settings                  fClockSettings;
                        PreferencesWindow*              fPreferencesWindow;
 
@@ -182,4 +156,4 @@ private:
 };
 
 
-#endif /* BAR_APP_H */
+#endif // BAR_APP_H
diff --git a/src/apps/deskbar/BarSettings.h b/src/apps/deskbar/BarSettings.h
new file mode 100644
index 0000000..21b3e1a
--- /dev/null
+++ b/src/apps/deskbar/BarSettings.h
@@ -0,0 +1,74 @@
+/*
+Open Tracker License
+
+Terms and Conditions
+
+Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice applies to all licensees
+and shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN 
CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of Be Incorporated shall not be
+used in advertising or otherwise to promote the sale, use or other dealings in
+this Software without prior written authorization from Be Incorporated.
+
+Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
+trademarks of Be Incorporated in the United States and other countries. Other
+brand product names are registered trademarks or trademarks of their respective
+holders.
+All rights reserved.
+*/
+#ifndef BAR_SETTINGS_H
+#define BAR_SETTINGS_H
+
+
+struct desk_settings {
+       bool vertical;
+       bool left;
+       bool top;
+       uint32 state;
+       float width;
+       BPoint switcherLoc;
+       bool showClock;
+       // applications
+       bool trackerAlwaysFirst;
+       bool sortRunningApps;
+       bool superExpando;
+       bool expandNewTeams;
+       bool hideLabels;
+       int32 iconSize;
+       // recent items
+       bool recentDocsEnabled;
+       bool recentFoldersEnabled;
+       bool recentAppsEnabled;
+       int32 recentDocsCount;
+       int32 recentFoldersCount;
+       int32 recentAppsCount;
+       // window
+       bool alwaysOnTop;
+       bool autoRaise;
+       bool autoHide;
+};
+
+struct clock_settings {
+       bool showSeconds;
+       bool showDayOfWeek;
+       bool showTimeZone;
+};
+
+
+#endif // BAR_SETTINGS_H
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 5a62739..9a00953 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -11,6 +11,7 @@
 #include "PreferencesWindow.h"
 
 #include <ctype.h>
+#include <stdio.h>
 
 #include <Box.h>
 #include <Button.h>
@@ -48,9 +49,9 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW,
                B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
 {
-       // Set the default and intial settings used by default and revert 
buttons
-       _SetDefaultSettings();
-       _SetInitialSettings();
+       // Initial settings (used by revert button)
+       memcpy(&fSettings, static_cast<TBarApp*>(be_app)->Settings(),
+               sizeof(desk_settings));
 
        // Menu controls
        fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"),
@@ -113,18 +114,18 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        appTextView->SetMaxBytes(4);
        folderTextView->SetMaxBytes(4);
 
-       int32 docCount = fInitialSettings.recentDocsCount;
-       int32 appCount = fInitialSettings.recentAppsCount;
-       int32 folderCount = fInitialSettings.recentFoldersCount;
+       int32 docCount = fSettings.recentDocsCount;
+       int32 appCount = fSettings.recentAppsCount;
+       int32 folderCount = fSettings.recentFoldersCount;
 
-       fMenuRecentDocuments->SetValue(fInitialSettings.recentDocsEnabled);
-       
fMenuRecentDocumentCount->SetEnabled(fInitialSettings.recentDocsEnabled);
+       fMenuRecentDocuments->SetValue(fSettings.recentDocsEnabled);
+       fMenuRecentDocumentCount->SetEnabled(fSettings.recentDocsEnabled);
 
-       fMenuRecentApplications->SetValue(fInitialSettings.recentAppsEnabled);
-       
fMenuRecentApplicationCount->SetEnabled(fInitialSettings.recentAppsEnabled);
+       fMenuRecentApplications->SetValue(fSettings.recentAppsEnabled);
+       fMenuRecentApplicationCount->SetEnabled(fSettings.recentAppsEnabled);
 
-       fMenuRecentFolders->SetValue(fInitialSettings.recentFoldersEnabled);
-       
fMenuRecentFolderCount->SetEnabled(fInitialSettings.recentFoldersEnabled);
+       fMenuRecentFolders->SetValue(fSettings.recentFoldersEnabled);
+       fMenuRecentFolderCount->SetEnabled(fSettings.recentFoldersEnabled);
 
        BString docString;
        BString appString;
@@ -139,18 +140,18 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fMenuRecentFolderCount->SetText(folderString.String());
 
        // Applications settings
-       fAppsSort->SetValue(fInitialSettings.sortRunningApps);
-       fAppsSortTrackerFirst->SetValue(fInitialSettings.trackerAlwaysFirst);
-       fAppsShowExpanders->SetValue(fInitialSettings.superExpando);
-       fAppsExpandNew->SetValue(fInitialSettings.expandNewTeams);
-       fAppsHideLabels->SetValue(fInitialSettings.hideLabels);
-       fAppsIconSizeSlider->SetValue(fInitialSettings.iconSize
+       fAppsSort->SetValue(fSettings.sortRunningApps);
+       fAppsSortTrackerFirst->SetValue(fSettings.trackerAlwaysFirst);
+       fAppsShowExpanders->SetValue(fSettings.superExpando);
+       fAppsExpandNew->SetValue(fSettings.expandNewTeams);
+       fAppsHideLabels->SetValue(fSettings.hideLabels);
+       fAppsIconSizeSlider->SetValue(fSettings.iconSize
                / kIconSizeInterval);
 
        // Window settings
-       fWindowAlwaysOnTop->SetValue(fInitialSettings.alwaysOnTop);
-       fWindowAutoRaise->SetValue(fInitialSettings.autoRaise);
-       fWindowAutoHide->SetValue(fInitialSettings.autoHide);
+       fWindowAlwaysOnTop->SetValue(fSettings.alwaysOnTop);
+       fWindowAutoRaise->SetValue(fSettings.autoRaise);
+       fWindowAutoHide->SetValue(fSettings.autoHide);
 
        _EnableDisableDependentItems();
 
@@ -284,11 +285,12 @@ PreferencesWindow::MessageReceived(BMessage* message)
                        break;
 
                case kRevert:
-                       _UpdatePreferences(fInitialSettings);
+                       _UpdatePreferences(&fSettings);
                        break;
 
                case kDefaults:
-                       _UpdatePreferences(fDefaultSettings);
+                       _UpdatePreferences(
+                               
static_cast<TBarApp*>(be_app)->DefaultSettings());
                        break;
 
                default:
@@ -351,23 +353,24 @@ bool
 PreferencesWindow::_IsDefaultable()
 {
        desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
-
-       return fDefaultSettings.sortRunningApps != settings->sortRunningApps
-               || fDefaultSettings.trackerAlwaysFirst != 
settings->trackerAlwaysFirst
-               || fDefaultSettings.superExpando != settings->superExpando
-               || fDefaultSettings.expandNewTeams != settings->expandNewTeams
-               || fDefaultSettings.hideLabels != settings->hideLabels
-               || fDefaultSettings.iconSize != settings->iconSize
-               || fDefaultSettings.recentAppsEnabled != 
settings->recentAppsEnabled
-               || fDefaultSettings.recentDocsEnabled != 
settings->recentDocsEnabled
-               || fDefaultSettings.recentFoldersEnabled
+       desk_settings* defaults = 
static_cast<TBarApp*>(be_app)->DefaultSettings();
+
+       return defaults->sortRunningApps != settings->sortRunningApps
+               || defaults->trackerAlwaysFirst != settings->trackerAlwaysFirst
+               || defaults->superExpando != settings->superExpando
+               || defaults->expandNewTeams != settings->expandNewTeams
+               || defaults->hideLabels != settings->hideLabels
+               || defaults->iconSize != settings->iconSize
+               || defaults->recentAppsEnabled != settings->recentAppsEnabled
+               || defaults->recentDocsEnabled != settings->recentDocsEnabled
+               || defaults->recentFoldersEnabled
                        != settings->recentFoldersEnabled
-               || fDefaultSettings.recentAppsCount != settings->recentAppsCount
-               || fDefaultSettings.recentDocsCount != settings->recentDocsCount
-               || fDefaultSettings.recentFoldersCount != 
settings->recentFoldersCount
-               || fDefaultSettings.alwaysOnTop != settings->alwaysOnTop
-               || fDefaultSettings.autoRaise != settings->autoRaise
-               || fDefaultSettings.autoHide != settings->autoHide;
+               || defaults->recentAppsCount != settings->recentAppsCount
+               || defaults->recentDocsCount != settings->recentDocsCount
+               || defaults->recentFoldersCount != settings->recentFoldersCount
+               || defaults->alwaysOnTop != settings->alwaysOnTop
+               || defaults->autoRaise != settings->autoRaise
+               || defaults->autoHide != settings->autoHide;
 }
 
 
@@ -376,76 +379,22 @@ PreferencesWindow::_IsRevertable()
 {
        desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
 
-       return fInitialSettings.sortRunningApps != settings->sortRunningApps
-               || fInitialSettings.trackerAlwaysFirst != 
settings->trackerAlwaysFirst
-               || fInitialSettings.superExpando != settings->superExpando
-               || fInitialSettings.expandNewTeams != settings->expandNewTeams
-               || fInitialSettings.hideLabels != settings->hideLabels
-               || fInitialSettings.iconSize != settings->iconSize
-               || fInitialSettings.recentAppsEnabled != 
settings->recentAppsEnabled
-               || fInitialSettings.recentDocsEnabled != 
settings->recentDocsEnabled
-               || fInitialSettings.recentFoldersEnabled
+       return fSettings.sortRunningApps != settings->sortRunningApps
+               || fSettings.trackerAlwaysFirst != settings->trackerAlwaysFirst
+               || fSettings.superExpando != settings->superExpando
+               || fSettings.expandNewTeams != settings->expandNewTeams
+               || fSettings.hideLabels != settings->hideLabels
+               || fSettings.iconSize != settings->iconSize
+               || fSettings.recentAppsEnabled != settings->recentAppsEnabled
+               || fSettings.recentDocsEnabled != settings->recentDocsEnabled
+               || fSettings.recentFoldersEnabled
                        != settings->recentFoldersEnabled
-               || fInitialSettings.recentAppsCount != settings->recentAppsCount
-               || fInitialSettings.recentDocsCount != settings->recentDocsCount
-               || fInitialSettings.recentFoldersCount != 
settings->recentFoldersCount
-               || fInitialSettings.alwaysOnTop != settings->alwaysOnTop
-               || fInitialSettings.autoRaise != settings->autoRaise
-               || fInitialSettings.autoHide != settings->autoHide;
-}
-
-
-void
-PreferencesWindow::_SetDefaultSettings()
-{
-       // applications
-       fDefaultSettings.sortRunningApps = false;
-       fDefaultSettings.trackerAlwaysFirst = false;
-       fDefaultSettings.superExpando = false;
-       fDefaultSettings.expandNewTeams = false;
-       fDefaultSettings.hideLabels = false;
-       fDefaultSettings.iconSize = kMinimumIconSize;
-
-       // recent items
-       fDefaultSettings.recentAppsEnabled = true;
-       fDefaultSettings.recentDocsEnabled = true;
-       fDefaultSettings.recentFoldersEnabled = true;
-       fDefaultSettings.recentAppsCount = 10;
-       fDefaultSettings.recentDocsCount = 10;
-       fDefaultSettings.recentFoldersCount = 10;
-
-       // window
-       fDefaultSettings.alwaysOnTop = false;
-       fDefaultSettings.autoRaise = false;
-       fDefaultSettings.autoHide = false;
-}
-
-
-void
-PreferencesWindow::_SetInitialSettings()
-{
-       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
-
-       // applications
-       fInitialSettings.sortRunningApps = settings->sortRunningApps;
-       fInitialSettings.trackerAlwaysFirst = settings->trackerAlwaysFirst;
-       fInitialSettings.superExpando = settings->superExpando;
-       fInitialSettings.expandNewTeams = settings->expandNewTeams;
-       fInitialSettings.hideLabels = settings->hideLabels;
-       fInitialSettings.iconSize = settings->iconSize;
-
-       // recent items
-       fInitialSettings.recentAppsEnabled = settings->recentAppsEnabled;
-       fInitialSettings.recentDocsEnabled = settings->recentDocsEnabled;
-       fInitialSettings.recentFoldersEnabled = settings->recentFoldersEnabled;
-       fInitialSettings.recentAppsCount = settings->recentAppsCount;
-       fInitialSettings.recentDocsCount = settings->recentDocsCount;
-       fInitialSettings.recentFoldersCount = settings->recentFoldersCount;
-
-       // window
-       fInitialSettings.alwaysOnTop = settings->alwaysOnTop;
-       fInitialSettings.autoRaise = settings->autoRaise;
-       fInitialSettings.autoHide = settings->autoHide;
+               || fSettings.recentAppsCount != settings->recentAppsCount
+               || fSettings.recentDocsCount != settings->recentDocsCount
+               || fSettings.recentFoldersCount != settings->recentFoldersCount
+               || fSettings.alwaysOnTop != settings->alwaysOnTop
+               || fSettings.autoRaise != settings->autoRaise
+               || fSettings.autoHide != settings->autoHide;
 }
 
 
@@ -458,78 +407,78 @@ PreferencesWindow::_UpdateButtons()
 
 
 void
-PreferencesWindow::_UpdatePreferences(pref_settings prefs)
+PreferencesWindow::_UpdatePreferences(desk_settings* settings)
 {
-       desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();
+       desk_settings* current = static_cast<TBarApp*>(be_app)->Settings();
        bool updateRecentCounts = false;
 
-       if (settings->sortRunningApps != prefs.sortRunningApps) {
-               fAppsSort->SetValue(prefs.sortRunningApps);
+       if (current->sortRunningApps != settings->sortRunningApps) {
+               fAppsSort->SetValue(settings->sortRunningApps);
                fAppsSort->Invoke();
        }
-       if (settings->trackerAlwaysFirst != prefs.trackerAlwaysFirst) {
-               fAppsSortTrackerFirst->SetValue(prefs.trackerAlwaysFirst);
+       if (current->trackerAlwaysFirst != settings->trackerAlwaysFirst) {
+               fAppsSortTrackerFirst->SetValue(settings->trackerAlwaysFirst);
                fAppsSortTrackerFirst->Invoke();
        }
-       if (settings->superExpando != prefs.superExpando) {
-               fAppsShowExpanders->SetValue(prefs.superExpando);
+       if (current->superExpando != settings->superExpando) {
+               fAppsShowExpanders->SetValue(settings->superExpando);
                fAppsShowExpanders->Invoke();
        }
-       if (settings->expandNewTeams != prefs.expandNewTeams) {
-               fAppsExpandNew->SetValue(prefs.expandNewTeams);
+       if (current->expandNewTeams != settings->expandNewTeams) {
+               fAppsExpandNew->SetValue(settings->expandNewTeams);
                fAppsExpandNew->Invoke();
        }
-       if (settings->hideLabels != prefs.hideLabels) {
-               fAppsHideLabels->SetValue(prefs.hideLabels);
+       if (current->hideLabels != settings->hideLabels) {
+               fAppsHideLabels->SetValue(settings->hideLabels);
                fAppsHideLabels->Invoke();
        }
-       if (settings->iconSize != prefs.iconSize) {
-               fAppsIconSizeSlider->SetValue(prefs.iconSize / 
kIconSizeInterval);
+       if (current->iconSize != settings->iconSize) {
+               fAppsIconSizeSlider->SetValue(settings->iconSize / 
kIconSizeInterval);
                fAppsIconSizeSlider->Invoke();
        }
-       if (settings->recentDocsEnabled != prefs.recentDocsEnabled) {
-               fMenuRecentDocuments->SetValue(prefs.recentDocsEnabled
+       if (current->recentDocsEnabled != settings->recentDocsEnabled) {
+               fMenuRecentDocuments->SetValue(settings->recentDocsEnabled
                        ? B_CONTROL_ON : B_CONTROL_OFF);
                updateRecentCounts = true;
        }
-       if (settings->recentFoldersEnabled != prefs.recentFoldersEnabled) {
-               fMenuRecentFolders->SetValue(prefs.recentFoldersEnabled
+       if (current->recentFoldersEnabled != settings->recentFoldersEnabled) {
+               fMenuRecentFolders->SetValue(settings->recentFoldersEnabled
                        ? B_CONTROL_ON : B_CONTROL_OFF);
                updateRecentCounts = true;
        }
-       if (settings->recentAppsEnabled != fDefaultSettings.recentAppsEnabled) {
-               fMenuRecentApplications->SetValue(prefs.recentAppsEnabled
+       if (current->recentAppsEnabled != settings->recentAppsEnabled) {
+               fMenuRecentApplications->SetValue(settings->recentAppsEnabled
                        ? B_CONTROL_ON : B_CONTROL_OFF);
                updateRecentCounts = true;
        }
-       if (settings->recentDocsCount != prefs.recentDocsCount) {
+       if (current->recentDocsCount != settings->recentDocsCount) {
                BString docString;
-               docString << prefs.recentDocsCount;
+               docString << settings->recentDocsCount;
                fMenuRecentDocumentCount->SetText(docString.String());
                updateRecentCounts = true;
        }
-       if (settings->recentFoldersCount != prefs.recentFoldersCount) {
+       if (current->recentFoldersCount != settings->recentFoldersCount) {
                BString folderString;
-               folderString << prefs.recentFoldersCount;
+               folderString << settings->recentFoldersCount;
                fMenuRecentFolderCount->SetText(folderString.String());
                updateRecentCounts = true;
        }
-       if (settings->recentAppsCount != prefs.recentAppsCount) {
+       if (current->recentAppsCount != settings->recentAppsCount) {
                BString appString;
-               appString << prefs.recentAppsCount;
+               appString << settings->recentAppsCount;
                fMenuRecentApplicationCount->SetText(appString.String());
                updateRecentCounts = true;
        }
-       if (settings->alwaysOnTop != prefs.alwaysOnTop) {
-               fWindowAlwaysOnTop->SetValue(prefs.alwaysOnTop);
+       if (current->alwaysOnTop != settings->alwaysOnTop) {
+               fWindowAlwaysOnTop->SetValue(settings->alwaysOnTop);
                fWindowAlwaysOnTop->Invoke();
        }
-       if (settings->autoRaise != prefs.autoRaise) {
-               fWindowAutoRaise->SetValue(prefs.autoRaise);
+       if (current->autoRaise != settings->autoRaise) {
+               fWindowAutoRaise->SetValue(settings->autoRaise);
                fWindowAutoRaise->Invoke();
        }
-       if (settings->autoHide != prefs.autoHide) {
-               fWindowAutoHide->SetValue(prefs.autoHide);
+       if (current->autoHide != settings->autoHide) {
+               fWindowAutoHide->SetValue(settings->autoHide);
                fWindowAutoHide->Invoke();
        }
 
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index 4b885d8..b7d2062 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -8,6 +8,8 @@
 
 #include <Window.h>
 
+#include "BarSettings.h"
+
 
 const uint32 kConfigShow                       = 'PrSh';
 const uint32 kConfigQuit                       = 'PrQt';
@@ -27,28 +29,6 @@ const uint32 kDefaults                               = 
'dflt';
 const uint32 kRevert                           = 'rvrt';
 
 
-struct pref_settings {
-       // applications
-       bool trackerAlwaysFirst;
-       bool sortRunningApps;
-       bool superExpando;
-       bool expandNewTeams;
-       bool hideLabels;
-       int32 iconSize;
-       // recent items
-       int32 recentAppsCount;
-       int32 recentDocsCount;
-       int32 recentFoldersCount;
-       bool recentAppsEnabled;
-       bool recentDocsEnabled;
-       bool recentFoldersEnabled;
-       // window
-       bool alwaysOnTop;
-       bool autoRaise;
-       bool autoHide;
-};
-
-
 class BCheckBox;
 class BRadioButton;
 class BSlider;
@@ -70,11 +50,10 @@ private:
                        bool                    _IsDefaultable();
                        bool                    _IsRevertable();
 
-                       void                    _SetDefaultSettings();
                        void                    _SetInitialSettings();
 
                        void                    _UpdateButtons();
-                       void                    
_UpdatePreferences(pref_settings prefs);
+                       void                    
_UpdatePreferences(desk_settings* settings);
                        void                    _UpdateRecentCounts();
 
 private:
@@ -101,9 +80,8 @@ private:
                        BButton*                fDefaultsButton;
 
 private:
-                       pref_settings   fDefaultSettings;
-                       pref_settings   fInitialSettings;
+                       desk_settings   fSettings;
 };
 
 
-#endif /* _PREFERENCES_WINDOW_H */
+#endif // _PREFERENCES_WINDOW_H

############################################################################

Commit:      633232da4cd49e7bb51951928e5c05071c2a7a47
URL:         http://cgit.haiku-os.org/haiku/commit/?id=633232d
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Mar  9 03:46:59 2013 UTC

Reorder buttons.

Defaults then Revert both on left like Tracker and Locale and other preflets.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 9a00953..006e143 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -229,10 +229,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                .View());
 
        // Action Buttons
-       fRevertButton = new BButton(B_TRANSLATE("Revert"),
-               new BMessage(kRevert));
        fDefaultsButton = new BButton(B_TRANSLATE("Defaults"),
                new BMessage(kDefaults));
+       fRevertButton = new BButton(B_TRANSLATE("Revert"),
+               new BMessage(kRevert));
 
        // Layout
        BLayoutBuilder::Group<>(this)
@@ -245,9 +245,9 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                .End()
                        .End()
                        .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
+                               .Add(fDefaultsButton)
                                .Add(fRevertButton)
                                .AddGlue()
-                               .Add(fDefaultsButton)
                                .End()
                        .SetInsets(B_USE_DEFAULT_SPACING)
                        .End();
@@ -401,8 +401,8 @@ PreferencesWindow::_IsRevertable()
 void
 PreferencesWindow::_UpdateButtons()
 {
-       fRevertButton->SetEnabled(_IsRevertable());
        fDefaultsButton->SetEnabled(_IsDefaultable());
+       fRevertButton->SetEnabled(_IsRevertable());
 }
 
 
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index b7d2062..489316b 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -76,8 +76,8 @@ private:
                        BCheckBox*              fWindowAutoRaise;
                        BCheckBox*              fWindowAutoHide;
 
-                       BButton*                fRevertButton;
                        BButton*                fDefaultsButton;
+                       BButton*                fRevertButton;
 
 private:
                        desk_settings   fSettings;

############################################################################

Commit:      a601c3f172a7159f7587bfbe4683cc996d84fa52
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a601c3f
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sat Mar  9 18:13:32 2013 UTC

Add 'Open menu in Tracker' button at bottom

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 006e143..3d04ee0 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -207,8 +207,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                        .Add(fMenuRecentApplicationCount)
                                        .End()
                                .End()
-                               //.Add(new BButton(B_TRANSLATE("Open in 
Tracker" B_UTF8_ELLIPSIS),
-                               //      new BMessage(kOpenInTracker)))
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
@@ -248,6 +246,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                .Add(fDefaultsButton)
                                .Add(fRevertButton)
                                .AddGlue()
+                               .Add(new BButton(B_TRANSLATE("Open menu in 
Tracker"
+                                       B_UTF8_ELLIPSIS), new 
BMessage(kOpenInTracker)))
                                .End()
                        .SetInsets(B_USE_DEFAULT_SPACING)
                        .End();

############################################################################

Commit:      a3f512d524efcf4ecb48fe4181d6c8f61e5b4cc7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a3f512d
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon Mar 11 23:45:25 2013 UTC

Rename Recent items back to Menu and tweak to make fit.

* Put the Open in Tracker... button back in Menu.
* Put the window checkboxes in 2 columns.
* Use vertical struts instead of insets for spacing in a couple places.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 3d04ee0..4fe248e 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -28,6 +28,7 @@
 #include <Roster.h>
 #include <SeparatorView.h>
 #include <Slider.h>
+#include <SpaceLayoutItem.h>
 #include <TextControl.h>
 #include <View.h>
 
@@ -180,20 +181,19 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                .Add(fAppsExpandNew)
                                .End()
                        .Add(fAppsHideLabels)
-                       .AddGroup(B_HORIZONTAL, 0)
-                               .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0)
-                               .Add(fAppsIconSizeSlider)
-                               .End()
                        .AddGlue()
+                       .Add(BSpaceLayoutItem::CreateVerticalStrut(
+                               B_USE_SMALL_SPACING))
+                       .Add(fAppsIconSizeSlider)
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
                .View());
 
-       // Recent items
-       BBox* recentItemsBox = new BBox("recent items");
-       recentItemsBox->SetLabel(B_TRANSLATE("Recent items"));
-       recentItemsBox->AddChild(BLayoutBuilder::Group<>()
+       // Menu
+       BBox* menuBox = new BBox("menu");
+       menuBox->SetLabel(B_TRANSLATE("Menu"));
+       menuBox->AddChild(BLayoutBuilder::Group<>()
                .AddGroup(B_VERTICAL, 0)
                        .AddGroup(B_HORIZONTAL, 0)
                                .AddGroup(B_VERTICAL, 0)
@@ -207,6 +207,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                        .Add(fMenuRecentApplicationCount)
                                        .End()
                                .End()
+                               .Add(BSpaceLayoutItem::CreateVerticalStrut(
+                                       B_USE_SMALL_SPACING))
+                               .Add(new BButton(B_TRANSLATE("Open in Tracker"
+                                       B_UTF8_ELLIPSIS), new 
BMessage(kOpenInTracker)))
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
@@ -216,10 +220,12 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        BBox* windowSettingsBox = new BBox("window");
        windowSettingsBox->SetLabel(B_TRANSLATE("Window"));
        windowSettingsBox->AddChild(BLayoutBuilder::Group<>()
-               .AddGroup(B_VERTICAL, 0)
-                       .Add(fWindowAlwaysOnTop)
-                       .Add(fWindowAutoRaise)
-                       .Add(fWindowAutoHide)
+               .AddGroup(B_HORIZONTAL, 0)
+                       .AddGrid(B_USE_SMALL_SPACING, 0, 1)
+                               .Add(fWindowAlwaysOnTop, 0, 0)
+                               .Add(fWindowAutoRaise, 0, 1)
+                               .Add(fWindowAutoHide, 1, 0)
+                               .End()
                        .AddGlue()
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
@@ -238,7 +244,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
                                .Add(appsSettingsBox)
                                .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
-                                       .Add(recentItemsBox)
+                                       .Add(menuBox)
                                        .Add(windowSettingsBox)
                                .End()
                        .End()
@@ -246,8 +252,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                .Add(fDefaultsButton)
                                .Add(fRevertButton)
                                .AddGlue()
-                               .Add(new BButton(B_TRANSLATE("Open menu in 
Tracker"
-                                       B_UTF8_ELLIPSIS), new 
BMessage(kOpenInTracker)))
                                .End()
                        .SetInsets(B_USE_DEFAULT_SPACING)
                        .End();

############################################################################

Commit:      f49eecb5644d440689d78495d2e0c60e6ac9101a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f49eecb
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon Mar 11 23:53:16 2013 UTC

Use horizontal strut instead of insets

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index 4fe248e..c824eae 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -177,13 +177,12 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .Add(fAppsSortTrackerFirst)
                        .Add(fAppsShowExpanders)
                        .AddGroup(B_HORIZONTAL, 0)
-                               .SetInsets(kIndentSpacing, 0, 0, 0)
+                               
.Add(BSpaceLayoutItem::CreateHorizontalStrut(kIndentSpacing))
                                .Add(fAppsExpandNew)
                                .End()
                        .Add(fAppsHideLabels)
                        .AddGlue()
-                       .Add(BSpaceLayoutItem::CreateVerticalStrut(
-                               B_USE_SMALL_SPACING))
+                       
.Add(BSpaceLayoutItem::CreateVerticalStrut(B_USE_SMALL_SPACING))
                        .Add(fAppsIconSizeSlider)
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)

############################################################################

Revision:    hrev45368
Commit:      5bfc9c7091f3b728bb6a7083e82fac4d21682f7f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5bfc9c7
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Mar 13 03:03:15 2013 UTC

Save and load prefs window position to and from a file.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index cf0c059..48f5267 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -856,7 +856,7 @@ void
 TBarApp::ShowPreferencesWindow()
 {
        if (fPreferencesWindow == NULL) {
-               fPreferencesWindow = new PreferencesWindow(BRect(0, 0, 320, 
240));
+               fPreferencesWindow = new PreferencesWindow(BRect(100, 100, 320, 
240));
                fPreferencesWindow->Show();
        } else if (fPreferencesWindow->Lock()) {
                if (fPreferencesWindow->IsHidden())
@@ -875,17 +875,10 @@ TBarApp::QuitPreferencesWindow()
        if (fPreferencesWindow == NULL)
                return;
 
-       int32 index = 0;
-       BWindow* window = NULL;
-       while ((window = WindowAt(index++)) != NULL) {
-               if (window == fPreferencesWindow) {
-                       if (fPreferencesWindow->Lock()) {
-                               fPreferencesWindow->Quit();
-                                       // Quit() destroys the window so don't 
unlock
-                               fPreferencesWindow = NULL;
-                       }
-                       break;
-               }
+       if (fPreferencesWindow->Lock()) {
+               fPreferencesWindow->Quit();
+                       // Quit() destroys the window so don't unlock
+               fPreferencesWindow = NULL;
        }
 }
 
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index c824eae..7f3af94 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -11,22 +11,24 @@
 #include "PreferencesWindow.h"
 
 #include <ctype.h>
-#include <stdio.h>
 
 #include <Box.h>
 #include <Button.h>
 #include <Catalog.h>
 #include <CheckBox.h>
 #include <ControlLook.h>
+#include <File.h>
 #include <FormattingConventions.h>
 #include <GroupLayout.h>
 #include <ListView.h>
 #include <Locale.h>
 #include <LayoutBuilder.h>
 #include <OpenWithTracker.h>
+#include <Path.h>
 #include <RadioButton.h>
 #include <Roster.h>
 #include <SeparatorView.h>
+#include <Screen.h>
 #include <Slider.h>
 #include <SpaceLayoutItem.h>
 #include <TextControl.h>
@@ -39,6 +41,7 @@
 static const float kIndentSpacing
        = be_control_look->DefaultItemSpacing() * 2.3;
 static const uint32 kSettingsViewChanged = 'Svch';
+static const char* kSettingsFileName = "Deskbar_prefs_window_settings";
 
 
 #undef B_TRANSLATION_CONTEXT
@@ -208,8 +211,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                                .End()
                                .Add(BSpaceLayoutItem::CreateVerticalStrut(
                                        B_USE_SMALL_SPACING))
-                               .Add(new BButton(B_TRANSLATE("Open in Tracker"
-                                       B_UTF8_ELLIPSIS), new 
BMessage(kOpenInTracker)))
+                               .Add(new BButton(B_TRANSLATE("Edit in Tracker"
+                                       B_UTF8_ELLIPSIS), new 
BMessage(kEditInTracker)))
                        .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
                                B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
                        .End()
@@ -255,7 +258,14 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                        .SetInsets(B_USE_DEFAULT_SPACING)
                        .End();
 
-       CenterOnScreen();
+       BMessage windowSettings;
+       BPoint where;
+       if (_LoadSettings(&windowSettings) == B_OK
+               && windowSettings.FindPoint("window_position", &where) == B_OK
+               && BScreen(this).Frame().Contains(where)) {
+               MoveTo(where);
+       } else
+               CenterOnScreen();
 }
 
 
@@ -269,7 +279,7 @@ void
 PreferencesWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case kOpenInTracker:
+               case kEditInTracker:
                        OpenWithTracker(B_USER_DESKBAR_DIRECTORY);
                        break;
 
@@ -306,6 +316,10 @@ PreferencesWindow::MessageReceived(BMessage* message)
 bool
 PreferencesWindow::QuitRequested()
 {
+       BMessage windowSettings;
+       windowSettings.AddPoint("window_position", Frame().LeftTop());
+       _SaveSettings(&windowSettings);
+
        be_app->PostMessage(kConfigQuit);
 
        return false;
@@ -401,6 +415,52 @@ PreferencesWindow::_IsRevertable()
 }
 
 
+status_t
+PreferencesWindow::_InitSettingsFile(BFile* file, bool write)
+{
+       BPath prefsPath;
+       status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &prefsPath);
+       if (status != B_OK)
+               return status;
+
+       status = prefsPath.Append(kSettingsFileName);
+       if (status != B_OK)
+               return status;
+
+       if (write) {
+               status = file->SetTo(prefsPath.Path(),
+                       B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
+       } else
+               status = file->SetTo(prefsPath.Path(), B_READ_ONLY);
+
+       return status;
+}
+
+
+status_t
+PreferencesWindow::_LoadSettings(BMessage* settings)
+{
+       BFile prefsFile;
+       status_t status = _InitSettingsFile(&prefsFile, false);
+       if (status != B_OK)
+               return status;
+
+       return settings->Unflatten(&prefsFile);
+}
+
+
+status_t
+PreferencesWindow::_SaveSettings(BMessage* settings)
+{
+       BFile prefsFile;
+       status_t status = _InitSettingsFile(&prefsFile, true);
+       if (status != B_OK)
+               return status;
+
+       return settings->Flatten(&prefsFile);
+}
+
+
 void
 PreferencesWindow::_UpdateButtons()
 {
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index 489316b..4a8beae 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -14,7 +14,7 @@
 const uint32 kConfigShow                       = 'PrSh';
 const uint32 kConfigQuit                       = 'PrQt';
 const uint32 kUpdateRecentCounts       = 'upct';
-const uint32 kOpenInTracker                    = 'otrk';
+const uint32 kEditInTracker                    = 'etrk';
 
 const uint32 kTrackerFirst                     = 'TkFt';
 const uint32 kSortRunningApps          = 'SAps';
@@ -30,6 +30,8 @@ const uint32 kRevert                          = 'rvrt';
 
 
 class BCheckBox;
+class BFile;
+class BMessage;
 class BRadioButton;
 class BSlider;
 class BTextControl;
@@ -50,6 +52,10 @@ private:
                        bool                    _IsDefaultable();
                        bool                    _IsRevertable();
 
+                       status_t                _InitSettingsFile(BFile* file, 
bool write);
+                       status_t                _LoadSettings(BMessage* 
settings);
+                       status_t                _SaveSettings(BMessage* 
settings);
+
                        void                    _SetInitialSettings();
 
                        void                    _UpdateButtons();


Other related posts: