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

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 18 Apr 2012 05:13:04 +0200 (CEST)

hrev44048 adds 2 changesets to branch 'master'
old head: 889692191d3374f5ad42e7b0d02a45e3dfd65294
new head: 0d2ac94c4df1061e1f2b835703f018553c929744

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

30a5580: Remove Time Interval radio buttons from Deskbar Prefs.
  
  * 12/24 hour clock is set from the Locale prefs only.
  * Redirect B_LOCALE_CHANGED message to the replicant tray instead
    of the time view and tell the replicant tray to update the time
    instead of updating the time view directly. This is because there
    was a bug where if the AM/PM marker grew the time view over the
    replicant tray icons when switching from 24 hour to 12 hour clock
    it wouldn't reflow the replicant tray icons like it should.
  * Rename the replicant tray view from "Status" to "_replicant_tray_"
    because BarApp uses FindView() to get the view by name and I'm
    assuming that this method can have conflicts. Following the example
    of the "_deskbar_tv_" naming convention.

0d2ac94: Rename the TReplicantTray view "_deskbar_rt_"
  
  instead of "_replicant_tray_". That follows the convention a bit
  better and is less likely to cause name collisions. While I am at
  it put the BView line below the : as is our usual convention.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

6 files changed, 24 insertions(+), 70 deletions(-)
src/apps/deskbar/BarApp.cpp            |    7 +++--
src/apps/deskbar/DeskbarMenu.cpp       |    1 -
src/apps/deskbar/PreferencesWindow.cpp |   33 ------------------------
src/apps/deskbar/PreferencesWindow.h   |    4 ---
src/apps/deskbar/StatusView.cpp        |   38 +++++++++++----------------
src/apps/deskbar/TimeView.cpp          |   11 +++-----

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

Commit:      30a5580244604caad54b5314c1a23d88c1d58fa8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=30a5580
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Apr 18 02:48:57 2012 UTC

Remove Time Interval radio buttons from Deskbar Prefs.

* 12/24 hour clock is set from the Locale prefs only.
* Redirect B_LOCALE_CHANGED message to the replicant tray instead
  of the time view and tell the replicant tray to update the time
  instead of updating the time view directly. This is because there
  was a bug where if the AM/PM marker grew the time view over the
  replicant tray icons when switching from 24 hour to 12 hour clock
  it wouldn't reflow the replicant tray icons like it should.
* Rename the replicant tray view from "Status" to "_replicant_tray_"
  because BarApp uses FindView() to get the view by name and I'm
  assuming that this method can have conflicts. Following the example
  of the "_deskbar_tv_" naming convention.

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

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index e31c6f1..0c348aa 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -640,10 +640,11 @@ TBarApp::MessageReceived(BMessage* message)
                        if (message->FindBool("filesys", &localize) == B_OK)
                                gLocalizedNamePreferred = localize;
 
-                       
BMessenger(fBarWindow->FindView("_deskbar_tv_")).SendMessage(
+                       
BMessenger(fBarWindow->FindView("_replicant_tray_")).SendMessage(
                                message);
-                               // Notify the TimeView that the format has 
changed and it should
-                               // recompute its size
+                               // Notify the replicant tray that the time 
interval has
+                               // changed and it should update the time view 
and reflow
+                               // the tray icons.
                        break;
                }
 
diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp
index 13a9cad..4b8c88c 100644
--- a/src/apps/deskbar/DeskbarMenu.cpp
+++ b/src/apps/deskbar/DeskbarMenu.cpp
@@ -399,7 +399,6 @@ TDeskbarMenu::ResetTargets()
                                        break;
 
                                case kShowHideTime:
-                               case kTimeIntervalChanged:
                                case kShowSeconds:
                                case kShowDayOfWeek:
                                case kShowTimeZone:
diff --git a/src/apps/deskbar/PreferencesWindow.cpp 
b/src/apps/deskbar/PreferencesWindow.cpp
index c1eb196..cf8386b 100644
--- a/src/apps/deskbar/PreferencesWindow.cpp
+++ b/src/apps/deskbar/PreferencesWindow.cpp
@@ -86,16 +86,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                new BMessage(kAutoHide));
 
        // Clock controls
-       BMessage* timeInterval12HoursMessage = new 
BMessage(kTimeIntervalChanged);
-       timeInterval12HoursMessage->AddBool("use24HourClock", false);
-       fTimeInterval12HourRadioButton = new BRadioButton("time inteval",
-               B_TRANSLATE("12 hour"), timeInterval12HoursMessage);
-
-       BMessage* timeInterval24HoursMessage = new 
BMessage(kTimeIntervalChanged);
-       timeInterval24HoursMessage->AddBool("use24HourClock", true);
-       fTimeInterval24HourRadioButton = new BRadioButton("time inteval",
-               B_TRANSLATE("24 hour"), timeInterval24HoursMessage);
-
        fShowSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
                new BMessage(kShowSeconds));
        fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"),
@@ -163,13 +153,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowAutoHide->SetValue(settings->autoHide);
 
        // Clock settings
-       BFormattingConventions conventions;
-       BLocale::Default()->GetFormattingConventions(&conventions);
-       if (conventions.Use24HourClock())
-               fTimeInterval24HourRadioButton->SetValue(B_CONTROL_ON);
-       else
-               fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON);
-
        TReplicantTray* replicantTray = barApp->BarView()->ReplicantTray();
        if (replicantTray->Time() != NULL) {
                fShowSeconds->SetValue(replicantTray->Time()->ShowSeconds());
@@ -194,9 +177,6 @@ PreferencesWindow::PreferencesWindow(BRect frame)
        fWindowAutoRaise->SetTarget(be_app);
        fWindowAutoHide->SetTarget(be_app);
 
-       fTimeInterval12HourRadioButton->SetTarget(replicantTray);
-       fTimeInterval24HourRadioButton->SetTarget(replicantTray);
-
        fShowSeconds->SetTarget(replicantTray);
        fShowDayOfWeek->SetTarget(replicantTray);
        fShowTimeZone->SetTarget(replicantTray);
@@ -271,23 +251,10 @@ PreferencesWindow::PreferencesWindow(BRect frame)
                .View();
        fWindowBox->AddChild(view);
 
-       BGroupLayout* timeIntervalLayout = new BGroupLayout(B_VERTICAL, 0);
-       timeIntervalLayout->SetInsets(B_USE_DEFAULT_SPACING, 0, 0, 0);
-       BView* timeIntervalView = new BView("interval", 0, timeIntervalLayout);
-       timeIntervalView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       timeIntervalView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       timeIntervalView->AddChild(fTimeInterval12HourRadioButton);
-       timeIntervalView->AddChild(fTimeInterval24HourRadioButton);
-
        view = BLayoutBuilder::Group<>()
                .AddGroup(B_VERTICAL, 0)
                        .AddGroup(B_VERTICAL, 0)
                                .SetInsets(0, 0, 0, B_USE_DEFAULT_SPACING)
-                               .Add(new BStringView("interval", 
B_TRANSLATE("Interval")))
-                               .Add(timeIntervalView)
-                               .End()
-                       .AddGroup(B_VERTICAL, 0)
-                               .SetInsets(0, 0, 0, B_USE_DEFAULT_SPACING)
                                .Add(fShowSeconds)
                                .Add(fShowDayOfWeek)
                                .Add(fShowTimeZone)
diff --git a/src/apps/deskbar/PreferencesWindow.h 
b/src/apps/deskbar/PreferencesWindow.h
index 286417f..1d26197 100644
--- a/src/apps/deskbar/PreferencesWindow.h
+++ b/src/apps/deskbar/PreferencesWindow.h
@@ -24,7 +24,6 @@ const uint32 kAutoRaise                               = 
'AtRs';
 const uint32 kAutoHide                         = 'AtHd';
 
 const uint32 kShowHideTime                     = 'ShTm';
-const uint32 kTimeIntervalChanged      = 'TiCh';
 const uint32 kShowSeconds                      = 'SwSc';
 const uint32 kShowDayOfWeek                    = 'SwDw';
 const uint32 kShowTimeZone                     = 'SwTz';
@@ -75,9 +74,6 @@ private:
                        BCheckBox*              fWindowAutoRaise;
                        BCheckBox*              fWindowAutoHide;
 
-                       BRadioButton*   fTimeInterval24HourRadioButton;
-                       BRadioButton*   fTimeInterval12HourRadioButton;
-
                        BCheckBox*              fShowSeconds;
                        BCheckBox*              fShowDayOfWeek;
                        BCheckBox*              fShowTimeZone;
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index b9aab75..e47c3f2 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -54,7 +54,6 @@ All rights reserved.
 #include <FindDirectory.h>
 #include <Locale.h>
 #include <MenuItem.h>
-#include <MutableLocaleRoster.h>
 #include <NodeInfo.h>
 #include <NodeMonitor.h>
 #include <Path.h>
@@ -125,8 +124,8 @@ DumpList(BList* itemlist)
 // don't change the name of this view to anything other than "Status"!
 
 TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
-       : BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP,
-                       B_WILL_DRAW | B_FRAME_EVENTS),
+       : BView(BRect(0, 0, 1, 1), "_replicant_tray_",
+                       B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | 
B_FRAME_EVENTS),
        fTime(NULL),
        fBarView(parent),
        fShelf(new TReplicantShelf(this)),
@@ -276,33 +275,27 @@ void
 TReplicantTray::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case kShowHideTime:
-                       // from context menu in clock and in this view
-                       ShowHideTime();
-                       break;
-
-               case kTimeIntervalChanged:
+               case B_LOCALE_CHANGED:
                {
                        if (fTime == NULL)
                                return;
 
-                       bool use24HourClock;
-                       if (message->FindBool("use24HourClock", &use24HourClock)
-                               == B_OK) {
-                               BFormattingConventions conventions;
-                               
BLocale::Default()->GetFormattingConventions(&conventions);
-                               
conventions.SetExplicitUse24HourClock(use24HourClock);
-                               BPrivate::MutableLocaleRoster::Default()->
-                                       
SetDefaultFormattingConventions(conventions);
-                               fTime->SetUse24HourClock(use24HourClock);
-                               // time string reformat -> realign
-                               RealignReplicants();
-                               AdjustPlacement();
-                       }
+                       // Locale may have updated 12/24 hour clock
+                       BFormattingConventions conventions;
+                       
BLocale::Default()->GetFormattingConventions(&conventions);
+                       fTime->SetUse24HourClock(conventions.Use24HourClock());
 
+                       // time string reformat -> realign
+                       RealignReplicants();
+                       AdjustPlacement();
                        break;
                }
 
+               case kShowHideTime:
+                       // from context menu in clock and in this view
+                       ShowHideTime();
+                       break;
+
                case kShowSeconds:
                        if (fTime == NULL)
                                return;
diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
index 9aedbee..6b90bda 100644
--- a/src/apps/deskbar/TimeView.cpp
+++ b/src/apps/deskbar/TimeView.cpp
@@ -66,6 +66,7 @@ enum {
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "TimeView"
 
+
 TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock,
        bool showSeconds, bool showDayOfWeek, bool showTimeZone)
        :
@@ -194,10 +195,6 @@ void
 TTimeView::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case B_LOCALE_CHANGED:
-                       Update();
-                       break;
-
                case kChangeTime:
                        // launch the time prefs app
                        be_roster->Launch("application/x-vnd.Haiku-Time");
@@ -487,16 +484,16 @@ void
 TTimeView::Update()
 {
        fLocale = *BLocale::Default();
+       UpdateTimeFormat();
+
        GetCurrentTime();
        GetCurrentDate();
        SetToolTip(fCurrentDateStr);
 
-       UpdateTimeFormat();
-
        CalculateTextPlacement();
        ResizeToPreferred();
 
-       if (fParent)
+       if (fParent != NULL)
                fParent->Invalidate();
 }
 

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

Revision:    hrev44048
Commit:      0d2ac94c4df1061e1f2b835703f018553c929744
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0d2ac94
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Apr 18 03:08:35 2012 UTC

Rename the TReplicantTray view "_deskbar_rt_"

instead of "_replicant_tray_". That follows the convention a bit
better and is less likely to cause name collisions. While I am at
it put the BView line below the : as is our usual convention.

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

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 0c348aa..ba3e766 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -640,7 +640,7 @@ TBarApp::MessageReceived(BMessage* message)
                        if (message->FindBool("filesys", &localize) == B_OK)
                                gLocalizedNamePreferred = localize;
 
-                       
BMessenger(fBarWindow->FindView("_replicant_tray_")).SendMessage(
+                       
BMessenger(fBarWindow->FindView("_deskbar_rt_")).SendMessage(
                                message);
                                // Notify the replicant tray that the time 
interval has
                                // changed and it should update the time view 
and reflow
diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index e47c3f2..aad0290 100644
--- a/src/apps/deskbar/StatusView.cpp
+++ b/src/apps/deskbar/StatusView.cpp
@@ -124,8 +124,9 @@ DumpList(BList* itemlist)
 // don't change the name of this view to anything other than "Status"!
 
 TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)
-       : BView(BRect(0, 0, 1, 1), "_replicant_tray_",
-                       B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | 
B_FRAME_EVENTS),
+       :
+       BView(BRect(0, 0, 1, 1), "_deskbar_rt_", B_FOLLOW_LEFT | B_FOLLOW_TOP,
+               B_WILL_DRAW | B_FRAME_EVENTS),
        fTime(NULL),
        fBarView(parent),
        fShelf(new TReplicantShelf(this)),


Other related posts: