[haiku-commits] r34060 - haiku/trunk/src/preferences/locale

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Nov 2009 16:07:56 +0100 (CET)

Author: kirilla
Date: 2009-11-15 16:07:55 +0100 (Sun, 15 Nov 2009)
New Revision: 34060
Changeset: http://dev.haiku-os.org/changeset/34060/haiku

Modified:
   haiku/trunk/src/preferences/locale/Locale.cpp
   haiku/trunk/src/preferences/locale/Locale.h
   haiku/trunk/src/preferences/locale/LocaleWindow.cpp
   haiku/trunk/src/preferences/locale/LocaleWindow.h
Log:
Simplified quitting. Propagate settings from window to application/settings 
when they change instead of collecting them when quitting.

Modified: haiku/trunk/src/preferences/locale/Locale.cpp
===================================================================
--- haiku/trunk/src/preferences/locale/Locale.cpp       2009-11-15 13:09:37 UTC 
(rev 34059)
+++ haiku/trunk/src/preferences/locale/Locale.cpp       2009-11-15 15:07:55 UTC 
(rev 34060)
@@ -52,7 +52,6 @@
 
        virtual void                    MessageReceived(BMessage* message);
        virtual void                    AboutRequested();
-       virtual bool                    QuitRequested();
 
 private:
                                Settings        fSettings;
@@ -187,19 +186,6 @@
 }
 
 
-bool
-LocalePreflet::QuitRequested()
-{
-       if (fLocaleWindow != NULL) {
-               fLocaleWindow->PostMessage(B_QUIT_REQUESTED);
-               fLocaleWindow = NULL;
-               return false;
-       }
-
-       return true;
-}
-
-
 //     #pragma mark -
 
 

Modified: haiku/trunk/src/preferences/locale/Locale.h
===================================================================
--- haiku/trunk/src/preferences/locale/Locale.h 2009-11-15 13:09:37 UTC (rev 
34059)
+++ haiku/trunk/src/preferences/locale/Locale.h 2009-11-15 15:07:55 UTC (rev 
34060)
@@ -13,7 +13,7 @@
 
 static const uint32 kMsgCountrySelection = 'csel';
 static const uint32 kMsgSettingsChanged = 'SeCh';
-static const uint32 kMsgSelectLanguage = 'slng';
+static const uint32 kMsgPrefLanguagesChanged = 'lang';
 static const uint32 kMsgDefaults = 'dflt';
 static const uint32 kMsgRevert = 'revt';
 

Modified: haiku/trunk/src/preferences/locale/LocaleWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/locale/LocaleWindow.cpp 2009-11-15 13:09:37 UTC 
(rev 34059)
+++ haiku/trunk/src/preferences/locale/LocaleWindow.cpp 2009-11-15 15:07:55 UTC 
(rev 34060)
@@ -107,6 +107,7 @@
                                                fDropIndex = -1;
                                        }
                                }
+                               Invoke(new BMessage(kMsgPrefLanguagesChanged));
                        } else BListView::MessageReceived(message);
                }
        private:
@@ -297,7 +298,8 @@
 LocaleWindow::LocaleWindow()
        :
        BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_NOT_RESIZABLE
-               | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | 
B_AUTO_UPDATE_SIZE_LIMITS)
+               | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | 
B_AUTO_UPDATE_SIZE_LIMITS
+               | B_QUIT_ON_WINDOW_CLOSE)
 {
        BCountry* defaultCountry;
        be_locale_roster->GetDefaultCountry(&defaultCountry);
@@ -453,27 +455,6 @@
 }
 
 
-bool
-LocaleWindow::QuitRequested()
-{
-       BMessage update(kMsgSettingsChanged);
-       update.AddPoint("window_location", Frame().LeftTop());
-       int index = 0;
-       while (index < fPreferredListView->CountItems()) {
-               update.AddString("language", static_cast<LanguageListItem*>
-                       (fPreferredListView->ItemAt(index))->LanguageCode());
-               index++;
-       }
-       // TODO also save Country tab settings
-       be_app_messenger.SendMessage(&update);
-
-       be_app_messenger.SendMessage(B_QUIT_REQUESTED);
-       be_app_messenger.SendMessage(B_QUIT_REQUESTED);
-               // app eats the first message
-       return true;
-}
-
-
 void
 LocaleWindow::MessageReceived(BMessage* message)
 {
@@ -486,6 +467,19 @@
                        // TODO
                        break;
 
+               case kMsgPrefLanguagesChanged:
+               {
+                               BMessage update(kMsgSettingsChanged);
+                               int index = 0;
+                               while (index < 
fPreferredListView->CountItems()) {
+                                       update.AddString("language", 
static_cast<LanguageListItem*>
+                                               
(fPreferredListView->ItemAt(index))->LanguageCode());
+                                       index++;
+                               }
+                               be_app_messenger.SendMessage(&update);
+                       break;
+               }
+
                case kMsgCountrySelection:
                {
                        // Country selection changed.
@@ -511,3 +505,12 @@
        }
 }
 
+
+void
+LocaleWindow::FrameMoved(BPoint newPosition)
+{
+       BMessage update(kMsgSettingsChanged);
+       update.AddPoint("window_location", newPosition);
+       be_app_messenger.SendMessage(&update);
+}
+

Modified: haiku/trunk/src/preferences/locale/LocaleWindow.h
===================================================================
--- haiku/trunk/src/preferences/locale/LocaleWindow.h   2009-11-15 13:09:37 UTC 
(rev 34059)
+++ haiku/trunk/src/preferences/locale/LocaleWindow.h   2009-11-15 15:07:55 UTC 
(rev 34060)
@@ -17,8 +17,8 @@
 public:
                                                        LocaleWindow();
 
-       virtual bool                    QuitRequested();
        virtual void                    MessageReceived(BMessage* message);
+       virtual void                    FrameMoved(BPoint newPosition);
 
 private:
                        BButton*                fRevertButton;


Other related posts: