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

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Nov 2009 19:11:58 +0100 (CET)

Author: kirilla
Date: 2009-11-15 19:11:58 +0100 (Sun, 15 Nov 2009)
New Revision: 34062
Changeset: http://dev.haiku-os.org/changeset/34062/haiku

Modified:
   haiku/trunk/src/preferences/locale/Locale.h
   haiku/trunk/src/preferences/locale/LocaleWindow.cpp
   haiku/trunk/src/preferences/locale/LocaleWindow.h
Log:
Double-clicking to select/deselect preferred languages added.

Modified: haiku/trunk/src/preferences/locale/Locale.h
===================================================================
--- haiku/trunk/src/preferences/locale/Locale.h 2009-11-15 16:15:28 UTC (rev 
34061)
+++ haiku/trunk/src/preferences/locale/Locale.h 2009-11-15 18:11:58 UTC (rev 
34062)
@@ -14,6 +14,8 @@
 static const uint32 kMsgCountrySelection = 'csel';
 static const uint32 kMsgSettingsChanged = 'SeCh';
 static const uint32 kMsgPrefLanguagesChanged = 'lang';
+static const uint32 kMsgLangInvoked = 'laiv';
+static const uint32 kMsgPrefLangInvoked = 'pliv';
 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 16:15:28 UTC 
(rev 34061)
+++ haiku/trunk/src/preferences/locale/LocaleWindow.cpp 2009-11-15 18:11:58 UTC 
(rev 34062)
@@ -317,11 +317,13 @@
        
        {
                // first list: available languages
-               LanguageListView* listView = new LanguageListView("available",
+               fLanguageListView = new LanguageListView("available",
                        B_MULTIPLE_SELECTION_LIST);
-               BScrollView* scrollView = new BScrollView("scroller", listView,
+               BScrollView* scrollView = new BScrollView("scroller", 
fLanguageListView,
                        B_WILL_DRAW | B_FRAME_EVENTS, false, true);
 
+               fLanguageListView->SetInvocationMessage(new 
BMessage(kMsgLangInvoked));
+
                // Fill the language list from the LocaleRoster data
                BMessage installedLanguages;
                if (be_locale_roster->GetInstalledLanguages(&installedLanguages)
@@ -342,7 +344,7 @@
                                languageFullName.toUTF8(bbs);
                                LanguageListItem* si
                                        = new LanguageListItem(str, 
currentLanguage.String());
-                               listView->AddItem(si);
+                               fLanguageListView->AddItem(si);
                        }
 
                } else {
@@ -360,6 +362,9 @@
                BScrollView* scrollViewEnabled = new BScrollView("scroller",
                        fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, 
false, true);
 
+               fPreferredListView
+                       ->SetInvocationMessage(new 
BMessage(kMsgPrefLangInvoked));
+
                // get the preferred languages from the Settings. Move them 
here from
                // the other list.
                BMessage msg;
@@ -369,11 +374,12 @@
                                        == B_OK;
                                index++) {
                        for (int listPos = 0; LanguageListItem* lli
-                                       = 
static_cast<LanguageListItem*>(listView->ItemAt(listPos));
+                                       = static_cast<LanguageListItem*>
+                                               
(fLanguageListView->ItemAt(listPos));
                                        listPos++) {
                                if (langCode == lli->LanguageCode()) {
                                        fPreferredListView->AddItem(lli);
-                                       listView->RemoveItem(lli);
+                                       fLanguageListView->RemoveItem(lli);
                                }
                        }
                }
@@ -499,6 +505,37 @@
                        break;
                }
 
+               case kMsgLangInvoked:
+               {
+                       int32 index = 0;
+                       if (message->FindInt32("index", &index) == B_OK) {
+                               LanguageListItem* listItem
+                                       = static_cast<LanguageListItem*>
+                                               
(fLanguageListView->RemoveItem(index));
+                               fPreferredListView->AddItem(listItem);
+                               fPreferredListView
+                                       ->Invoke(new 
BMessage(kMsgPrefLanguagesChanged));
+                       }
+                       break;
+               }
+
+               case kMsgPrefLangInvoked:
+               {
+                       if (fPreferredListView->CountItems() == 1)
+                               break;
+
+                       int32 index = 0;
+                       if (message->FindInt32("index", &index) == B_OK) {
+                               LanguageListItem* listItem
+                                       = static_cast<LanguageListItem*>
+                                               
(fPreferredListView->RemoveItem(index));
+                               fLanguageListView->AddItem(listItem);
+                               fPreferredListView
+                                       ->Invoke(new 
BMessage(kMsgPrefLanguagesChanged));
+                       }
+                       break;
+               }
+
                default:
                        BWindow::MessageReceived(message);
                        break;

Modified: haiku/trunk/src/preferences/locale/LocaleWindow.h
===================================================================
--- haiku/trunk/src/preferences/locale/LocaleWindow.h   2009-11-15 16:15:28 UTC 
(rev 34061)
+++ haiku/trunk/src/preferences/locale/LocaleWindow.h   2009-11-15 18:11:58 UTC 
(rev 34062)
@@ -22,6 +22,7 @@
 
 private:
                        BButton*                fRevertButton;
+                       BListView*              fLanguageListView;
                        BListView*              fPreferredListView;
                        FormatView*             fFormatView;
 };


Other related posts:

  • » [haiku-commits] r34062 - haiku/trunk/src/preferences/locale - jonas