[haiku-commits] haiku: hrev43805 - in src/apps: expander mediaplayer/settings aboutsystem

  • From: humdingerb@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 29 Feb 2012 21:37:01 +0100 (CET)

hrev43805 adds 8 changesets to branch 'master'
old head: ea81d6eaf00849fcf8bb46d5e2c2f59142dfc19b
new head: a697ddedc5a0bfbbeffead67621cfec948e1cbf3

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

c2060a1: Added more translators, mostly GCI students.

108d217: Tuned spacing in the settings layout a bit.

eb3fc7f: Sentence case for file info window

4c9dc4c: Cosmetical improvements.

a866fc6: Remodeled the settings window after MediaPlayer.

98cce52: Clean up. No functional change.

ddec539: Now sets back its settings when closing the settings window with 
"Cancel".
  
  * Pulled reading and writing settings into private functions.
  * Call _ReadSettings() when canceling settings window to revert to
    original settings.

a697dde: Cancel settings window on ESC, small cleanup.

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

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

5 files changed, 219 insertions(+), 161 deletions(-)
src/apps/aboutsystem/AboutSystem.cpp             |   18 ++
src/apps/expander/ExpanderPreferences.cpp        |  246 +++++++++++-------
src/apps/expander/ExpanderPreferences.h          |   83 +++----
src/apps/mediaplayer/InfoWin.cpp                 |    2 +-
src/apps/mediaplayer/settings/SettingsWindow.cpp |   31 +--

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

Commit:      c2060a1f34940c8fe5296330bf0f0442dd8d1f20
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c2060a1
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Tue Feb 28 17:47:45 2012 UTC

Added more translators, mostly GCI students.

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

diff --git a/src/apps/aboutsystem/AboutSystem.cpp 
b/src/apps/aboutsystem/AboutSystem.cpp
index 9233eb8..08c1fdc 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -90,6 +90,7 @@ static const Translation gTranslations[] =
 {
        { "ar",
                "Khaled Berraoui - khallebal\n"
+               "Kendhia\n"
        },
        { "be",
                "Michael Bulash\n"
@@ -110,8 +111,10 @@ static const Translation gTranslations[] =
                "Mirko Israel\n"
                "leszek\n"
                "Christian Morgenroth\n"
+               "Aleksas Pantechovskis\n"
                "Joachim Seemer - Humdinger\n"
                "Matthias Spreiter\n"
+               "Ivaylo Tsenkov\n"
                "svend\n"
        },
        { "el",
@@ -135,6 +138,7 @@ static const Translation gTranslations[] =
        { "fi",
                "Jorma Karvonen - Karvjorm\n"
                "Jaakko Leikas - Garjala\n"
+               "Slavi Stefanov Sotirov\n"
        },
        { "fr",
                "Jean-Loïc Charroud\n"
@@ -144,6 +148,7 @@ static const Translation gTranslations[] =
        },
        { "hi",
                "Abhishek Arora\n"
+               "Dhruwat Bhagat\n"
                "Jayneil Dalal\n"
                "Atharva Lath\n"
        },
@@ -203,8 +208,14 @@ static const Translation gTranslations[] =
        },
        { "ro",
                "Victor Carbune\n"
+               "Silviu Dureanu\n"
+               "Alexsander Krustev\n"
+               "Danca Monica\n"
                "Florentina Mușat\n"
                "Dragos Serban\n"
+               "Hedeș Cristian Teodor\n"
+               "Ivaylo Tsenkov\n"
+               "Călinescu Valentin\n"
        },
        { "ru",
                "Tatyana Fursic - iceid\n"
@@ -215,6 +226,9 @@ static const Translation gTranslations[] =
                "Michael Smirnov\n"
                "Vladimir Vasilenko\n"
        },
+       { "sk",
+               "Ivan Masár\n"
+       },
        { "sr",
                "Nikola Miljković\n"
        },
@@ -226,7 +240,11 @@ static const Translation gTranslations[] =
                "Victor Widell\n"
        },
        { "tr",
+               "Hüseyin Aksu\n"
+               "Halil İbrahim Azak\n"
                "Aras Ergus\n"
+               "Enes Burhan Kuran\n"
+               "Ali Rıza Nazlı\n"
        },
        { "uk",
                "Mariya Pilipchuk\n"

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

Commit:      108d2173b9459286649635c770acbaca5f85931f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=108d217
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Tue Feb 28 17:46:24 2012 UTC

Tuned spacing in the settings layout a bit.

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

diff --git a/src/apps/mediaplayer/settings/SettingsWindow.cpp 
b/src/apps/mediaplayer/settings/SettingsWindow.cpp
index 3026120..bd3258a 100644
--- a/src/apps/mediaplayer/settings/SettingsWindow.cpp
+++ b/src/apps/mediaplayer/settings/SettingsWindow.cpp
@@ -16,6 +16,7 @@
 #include <Button.h>
 #include <Catalog.h>
 #include <CheckBox.h>
+#include <ControlLook.h>
 #include <LayoutBuilder.h>
 #include <Locale.h>
 #include <OptionPopUp.h>
@@ -39,11 +40,6 @@ enum {
 };
 
 
-#define SPACE 10
-#define SPACEING 7
-#define BUTTONHEIGHT 20
-
-
 SettingsWindow::SettingsWindow(BRect frame)
        :
        BWindow(frame, B_TRANSLATE("MediaPlayer settings"), 
B_FLOATING_WINDOW_LOOK,
@@ -51,11 +47,13 @@ SettingsWindow::SettingsWindow(BRect frame)
                B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
                        | B_AUTO_UPDATE_SIZE_LIMITS)
 {
+       const float kSpacing = be_control_look->DefaultItemSpacing();
+       
        BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
-       BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5);
+       BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 
2);
        settingsBox->SetLayout(settingsLayout);
        BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
-       BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5);
+       BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 
2);
        buttonBox->SetLayout(buttonLayout);
 
        BStringView* playModeLabel = new BStringView("stringViewPlayMode",
@@ -136,27 +134,26 @@ SettingsWindow::SettingsWindow(BRect frame)
                new BMessage(M_SETTINGS_SAVE));
        okButton->MakeDefault(true);
 
-
        // Build the layout
        BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
                .AddGroup(settingsLayout)
-                       .SetInsets(5, 5, 15, 5)
+                       .SetInsets(kSpacing, kSpacing, kSpacing * 2, 0)
                        .Add(playModeLabel)
                        .AddGroup(B_HORIZONTAL, 0)
-                               .AddStrut(10)
+                               .AddStrut(kSpacing)
                                .AddGroup(B_VERTICAL, 0)
                                        .Add(fAutostartCB)
-                                       .AddGrid(5, 0)
-                                               
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0)
+                                       .AddGrid(kSpacing, 0)
+                                               
.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 0)
                                                .Add(fCloseWindowMoviesCB, 1, 0)
-                                               
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1)
+                                               
.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 1)
                                                .Add(fCloseWindowSoundsCB, 1, 1)
                                        .End()
                                        .Add(fLoopMoviesCB)
                                        .Add(fLoopSoundsCB)
                                .End()
                        .End()
-                       .AddStrut(5)
+                       .AddStrut(kSpacing)
 
                        .Add(viewOptionsLabel)
                        .AddGroup(B_HORIZONTAL, 0)
@@ -169,7 +166,7 @@ SettingsWindow::SettingsWindow(BRect frame)
                                        .Add(fSubtitlePlacementOP)
                                .End()
                        .End()
-                       .AddStrut(5)
+                       .AddStrut(kSpacing)
 
                        .Add(bgMoviesModeLabel)
                        .AddGroup(B_HORIZONTAL, 0)
@@ -180,10 +177,10 @@ SettingsWindow::SettingsWindow(BRect frame)
                                        .Add(fMutedVolumeBGMoviesRB)
                                .End()
                        .End()
-                       .AddStrut(5)
+                       .AddStrut(kSpacing)
                .End()
                .AddGroup(buttonLayout)
-                       .SetInsets(5)
+                       .SetInsets(kSpacing)
                        .Add(fRevertB)
                        .AddGlue()
                        .Add(cancelButton)

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

Commit:      eb3fc7f079d20fba9f56a579fbf54e808d01ab32
URL:         http://cgit.haiku-os.org/haiku/commit/?id=eb3fc7f
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Sun Feb 26 10:23:04 2012 UTC

Sentence case for file info window

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

diff --git a/src/apps/mediaplayer/InfoWin.cpp b/src/apps/mediaplayer/InfoWin.cpp
index 0e9c9fa..71d987a 100644
--- a/src/apps/mediaplayer/InfoWin.cpp
+++ b/src/apps/mediaplayer/InfoWin.cpp
@@ -40,7 +40,7 @@
 #include "PlaylistItem.h"
 
 
-#define NAME "File Info"
+#define NAME "File info"
 #define MIN_WIDTH 400
 
 #define BASE_HEIGHT (32 + 32)

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

Commit:      4c9dc4c6420a3f5a274effbb36d214aa64cde2db
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4c9dc4c
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Fri Feb 24 17:08:09 2012 UTC

Cosmetical improvements.

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

diff --git a/src/apps/expander/ExpanderPreferences.cpp 
b/src/apps/expander/ExpanderPreferences.cpp
index 9e5073d..3153056 100644
--- a/src/apps/expander/ExpanderPreferences.cpp
+++ b/src/apps/expander/ExpanderPreferences.cpp
@@ -6,6 +6,7 @@
 #include "ExpanderPreferences.h"
 #include <Box.h>
 #include <Catalog.h>
+#include <ControlLook.h>
 #include <GroupLayout.h>
 #include <GroupLayoutBuilder.h>
 #include <Locale.h>
@@ -60,44 +61,49 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
        fAutoShow = new BCheckBox("autoShow",
                B_TRANSLATE("Automatically show contents listing"), NULL);
 
+       const float kSpacing = be_control_look->DefaultItemSpacing();
+
        BView* view = new BGroupView();
        view->SetLayout(new BGroupLayout(B_HORIZONTAL));
-       view->AddChild(BGroupLayoutBuilder(B_VERTICAL)
+       view->AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
                .AddGroup(B_HORIZONTAL)
                        .Add(new BStringView("expansion", 
B_TRANSLATE("Expansion:")))
                        .AddGlue()
                .End()
-               .AddGroup(B_VERTICAL, 1)
+               .AddGroup(B_VERTICAL, 0)
                        .Add(fAutoExpand)
                        .Add(fCloseWindow)
-                       .SetInsets(10, 0, 0, 10)
+                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
                .End()
-               .AddGroup(B_HORIZONTAL)
+               .AddGroup(B_HORIZONTAL, 0)
                        .Add(new BStringView("destinationFolder",
                                B_TRANSLATE("Destination folder:")))
                        .AddGlue()
+                       .SetInsets(0, kSpacing, 0, 0)
                .End()
-               .AddGroup(B_VERTICAL, 1)
+               .AddGroup(B_VERTICAL, 0)
                        .Add(fLeaveDest)
                        .Add(fSameDest)
                        .Add(fDestUse)
-                       .AddGroup(B_HORIZONTAL, 5)
+                       .AddGroup(B_HORIZONTAL, 0)
                                .Add(fDestText, 0.8)
+                               
.AddStrut(be_control_look->DefaultLabelSpacing())
                                .Add(fSelect, 0.2)
-                               .SetInsets(20, 0, 0, 0)
+                               .SetInsets(kSpacing * 2, 0, 0, 0)
                        .End()
-                       .SetInsets(10, 0, 0, 10)
+                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
                .End()
-               .AddGroup(B_HORIZONTAL)
+               .AddGroup(B_HORIZONTAL, 0)
                        .Add(new BStringView("other", B_TRANSLATE("Other:")))
                        .AddGlue()
+                                       .SetInsets(0, kSpacing / 2, 0, 0)
                .End()
-               .AddGroup(B_VERTICAL, 1)
+               .AddGroup(B_VERTICAL, 0)
                        .Add(fOpenDest)
                        .Add(fAutoShow)
-                       .SetInsets(10, 0, 0, 0)
+                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
                .End()
-               .SetInsets(10, 10, 10, 10)
+               .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
        );
        box->AddChild(view);
 
@@ -110,12 +116,12 @@ ExpanderPreferences::ExpanderPreferences(BMessage 
*settings)
        SetLayout(new BGroupLayout(B_HORIZONTAL));
        AddChild(BGroupLayoutBuilder(B_VERTICAL, 11)
                .Add(box)
-               .AddGroup(B_HORIZONTAL, 10)
+               .AddGroup(B_HORIZONTAL, kSpacing)
                        .AddGlue()
                        .Add(cancel)
                        .Add(button)
                .End()
-               .SetInsets(10, 10, 10, 10)
+               .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
        );
 
        CenterOnScreen();

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

Commit:      a866fc60f923d0a481a2e1c21009e7a63194791a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a866fc6
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Mon Feb 27 19:57:09 2012 UTC

Remodeled the settings window after MediaPlayer.

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

diff --git a/src/apps/expander/ExpanderPreferences.cpp 
b/src/apps/expander/ExpanderPreferences.cpp
index 3153056..c3b3b27 100644
--- a/src/apps/expander/ExpanderPreferences.cpp
+++ b/src/apps/expander/ExpanderPreferences.cpp
@@ -7,8 +7,7 @@
 #include <Box.h>
 #include <Catalog.h>
 #include <ControlLook.h>
-#include <GroupLayout.h>
-#include <GroupLayoutBuilder.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
 #include <Path.h>
 #include <Screen.h>
@@ -26,13 +25,31 @@ const uint32 MSG_DESTSELECT = 'mDes';
 #define B_TRANSLATE_CONTEXT "ExpanderPreferences"
 
 ExpanderPreferences::ExpanderPreferences(BMessage *settings)
-       : BWindow(BRect(0, 0, 325, 305), "Expander", B_MODAL_WINDOW,
-               B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
+       : BWindow(BRect(0, 0, 325, 305), B_TRANSLATE("Expander settings"),
+               B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, 
B_NOT_CLOSABLE
+                       | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
        fSettings(settings),
        fUsePanel(NULL)
 {
-       BBox* box = new BBox("background");
-       box->SetLabel(B_TRANSLATE("Expander settings"));
+       const float kSpacing = be_control_look->DefaultItemSpacing();
+
+       BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
+       BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 
2);
+       settingsBox->SetLayout(settingsLayout);
+       BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
+       BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 
2);
+       buttonBox->SetLayout(buttonLayout);
+
+       BStringView *expansionLabel = new BStringView("stringViewExpansion",
+               B_TRANSLATE("Expansion"));
+       expansionLabel->SetFont(be_bold_font);
+       BStringView *destinationLabel = new BStringView("stringViewDestination",
+               B_TRANSLATE("Destination folder"));
+       destinationLabel->SetFont(be_bold_font);
+       BStringView *otherLabel = new BStringView("stringViewOther",
+               B_TRANSLATE("Other"));
+       otherLabel->SetFont(be_bold_font);
+
 
        fAutoExpand = new BCheckBox("autoExpand",
                B_TRANSLATE("Automatically expand files"), NULL);
@@ -61,68 +78,61 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
        fAutoShow = new BCheckBox("autoShow",
                B_TRANSLATE("Automatically show contents listing"), NULL);
 
-       const float kSpacing = be_control_look->DefaultItemSpacing();
-
-       BView* view = new BGroupView();
-       view->SetLayout(new BGroupLayout(B_HORIZONTAL));
-       view->AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
-               .AddGroup(B_HORIZONTAL)
-                       .Add(new BStringView("expansion", 
B_TRANSLATE("Expansion:")))
-                       .AddGlue()
-               .End()
-               .AddGroup(B_VERTICAL, 0)
-                       .Add(fAutoExpand)
-                       .Add(fCloseWindow)
-                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
-               .End()
-               .AddGroup(B_HORIZONTAL, 0)
-                       .Add(new BStringView("destinationFolder",
-                               B_TRANSLATE("Destination folder:")))
-                       .AddGlue()
-                       .SetInsets(0, kSpacing, 0, 0)
-               .End()
-               .AddGroup(B_VERTICAL, 0)
-                       .Add(fLeaveDest)
-                       .Add(fSameDest)
-                       .Add(fDestUse)
-                       .AddGroup(B_HORIZONTAL, 0)
-                               .Add(fDestText, 0.8)
-                               
.AddStrut(be_control_look->DefaultLabelSpacing())
-                               .Add(fSelect, 0.2)
-                               .SetInsets(kSpacing * 2, 0, 0, 0)
-                       .End()
-                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
-               .End()
-               .AddGroup(B_HORIZONTAL, 0)
-                       .Add(new BStringView("other", B_TRANSLATE("Other:")))
-                       .AddGlue()
-                                       .SetInsets(0, kSpacing / 2, 0, 0)
-               .End()
-               .AddGroup(B_VERTICAL, 0)
-                       .Add(fOpenDest)
-                       .Add(fAutoShow)
-                       .SetInsets(kSpacing, kSpacing / 2, 0, 0)
-               .End()
-               .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
-       );
-       box->AddChild(view);
-
-       BButton* button = new BButton("OKButton", B_TRANSLATE("OK"),
+       BButton* okbutton = new BButton("OKButton", B_TRANSLATE("OK"),
                new BMessage(MSG_OK));
-       button->MakeDefault(true);
+       okbutton->MakeDefault(true);
        BButton* cancel = new BButton("CancelButton", B_TRANSLATE("Cancel"),
                new BMessage(MSG_CANCEL));
 
-       SetLayout(new BGroupLayout(B_HORIZONTAL));
-       AddChild(BGroupLayoutBuilder(B_VERTICAL, 11)
-               .Add(box)
-               .AddGroup(B_HORIZONTAL, kSpacing)
-                       .AddGlue()
-                       .Add(cancel)
-                       .Add(button)
+       // Build the layout
+       BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
+               .AddGroup(settingsLayout)
+                       .AddGroup(B_HORIZONTAL)
+                               .Add(expansionLabel)
+                               .AddGlue()
+                       .End()
+                       .AddGroup(B_VERTICAL, 0)
+                               .Add(fAutoExpand)
+                               .Add(fCloseWindow)
+                               .SetInsets(kSpacing, 0, 0, 0)
+                       .End()
+                       .AddGroup(B_HORIZONTAL, 0)
+                               .Add(destinationLabel)
+                               .AddGlue()
+                               .SetInsets(0, kSpacing, 0, 0)
+                       .End()
+                       .AddGroup(B_VERTICAL, 0)
+                               .Add(fLeaveDest)
+                               .Add(fSameDest)
+                               .Add(fDestUse)
+                               .AddGroup(B_HORIZONTAL, 0)
+                                       .Add(fDestText, 0.8)
+                                       
.AddStrut(be_control_look->DefaultLabelSpacing())
+                                       .Add(fSelect, 0.2)
+                                       .SetInsets(kSpacing * 2, 0, kSpacing / 
2, 0)
+                               .End()
+                               .SetInsets(kSpacing, 0, 0, 0)
+                       .End()
+                       .AddGroup(B_HORIZONTAL, 0)
+                               .Add(otherLabel)
+                               .AddGlue()
+                               .SetInsets(0, kSpacing / 2, 0, 0)
+                       .End()
+                       .AddGroup(B_VERTICAL, 0)
+                               .Add(fOpenDest)
+                               .Add(fAutoShow)
+                               .SetInsets(kSpacing, 0, 0, 0)
+                       .End()
+                       .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
                .End()
-               .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
-       );
+               .AddGroup(buttonLayout)
+                       .AddGroup(B_HORIZONTAL, kSpacing)
+                               .AddGlue()
+                               .Add(cancel)
+                               .Add(okbutton)
+                       .End()
+                       .SetInsets(kSpacing, kSpacing, kSpacing, kSpacing)
+               .End();
 
        CenterOnScreen();
 

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

Commit:      98cce525f01af60d70b908762aae3ca99be70440
URL:         http://cgit.haiku-os.org/haiku/commit/?id=98cce52
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Tue Feb 28 16:42:01 2012 UTC

Clean up. No functional change.

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

diff --git a/src/apps/expander/ExpanderPreferences.cpp 
b/src/apps/expander/ExpanderPreferences.cpp
index c3b3b27..91a0dd4 100644
--- a/src/apps/expander/ExpanderPreferences.cpp
+++ b/src/apps/expander/ExpanderPreferences.cpp
@@ -1,9 +1,12 @@
 /*
- * Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
+ * Copyright 2004-2012, Haiku. All rights reserved.
  * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Jérôme Duval
+ *             Humdinger <humdingerb@xxxxxxxxx>
  */
 
-#include "ExpanderPreferences.h"
 #include <Box.h>
 #include <Catalog.h>
 #include <ControlLook.h>
@@ -13,18 +16,21 @@
 #include <Screen.h>
 #include <StringView.h>
 
+#include "ExpanderPreferences.h"
+
 const uint32 MSG_OK                    = 'mgOK';
 const uint32 MSG_CANCEL                = 'mCan';
-const uint32 MSG_LEAVEDEST = 'mLed';
-const uint32 MSG_SAMEDIR = 'mSad';
-const uint32 MSG_DESTUSE = 'mDeu';
-const uint32 MSG_DESTTEXT = 'mDet';
+const uint32 MSG_LEAVEDEST     = 'mLed';
+const uint32 MSG_SAMEDIR       = 'mSad';
+const uint32 MSG_DESTUSE       = 'mDeu';
+const uint32 MSG_DESTTEXT      = 'mDet';
 const uint32 MSG_DESTSELECT = 'mDes';
 
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "ExpanderPreferences"
 
-ExpanderPreferences::ExpanderPreferences(BMessage *settings)
+
+ExpanderPreferences::ExpanderPreferences(BMessage* settings)
        : BWindow(BRect(0, 0, 325, 305), B_TRANSLATE("Expander settings"),
                B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, 
B_NOT_CLOSABLE
                        | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
@@ -40,17 +46,16 @@ ExpanderPreferences::ExpanderPreferences(BMessage *settings)
        BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 
2);
        buttonBox->SetLayout(buttonLayout);
 
-       BStringView *expansionLabel = new BStringView("stringViewExpansion",
+       BStringView* expansionLabel = new BStringView("stringViewExpansion",
                B_TRANSLATE("Expansion"));
        expansionLabel->SetFont(be_bold_font);
-       BStringView *destinationLabel = new BStringView("stringViewDestination",
+       BStringView* destinationLabel = new BStringView("stringViewDestination",
                B_TRANSLATE("Destination folder"));
        destinationLabel->SetFont(be_bold_font);
-       BStringView *otherLabel = new BStringView("stringViewOther",
+       BStringView* otherLabel = new BStringView("stringViewOther",
                B_TRANSLATE("Other"));
        otherLabel->SetFont(be_bold_font);
 
-
        fAutoExpand = new BCheckBox("autoExpand",
                B_TRANSLATE("Automatically expand files"), NULL);
        fCloseWindow = new BCheckBox("closeWindowWhenDone",
@@ -219,26 +224,34 @@ ExpanderPreferences::MessageReceived(BMessage* msg)
                        break;
                }
                case B_REFS_RECEIVED:
+               {
                        if (msg->FindRef("refs", 0, &fRef) == B_OK) {
                                BEntry entry(&fRef, true);
                                BPath path(&entry);
                                fDestText->SetText(path.Path());
                        }
                        break;
+               }
                case MSG_LEAVEDEST:
                case MSG_SAMEDIR:
+               {
                        fDestText->SetEnabled(false);
                        fSelect->SetEnabled(false);
                        break;
+               }
                case MSG_DESTUSE:
+               {
                        fDestText->SetEnabled(true);
                        fSelect->SetEnabled(true);
                        fDestText->TextView()->MakeEditable(false);
                        break;
+               }
                case MSG_CANCEL:
                        Hide();
                        break;
+                       
                case MSG_OK:
+               {
                        fSettings->ReplaceBool("automatically_expand_files",
                                fAutoExpand->Value() == B_CONTROL_ON);
                        fSettings->ReplaceBool("close_when_done",
@@ -253,6 +266,7 @@ ExpanderPreferences::MessageReceived(BMessage* msg)
                                fAutoShow->Value() == B_CONTROL_ON);
                        Hide();
                        break;
+               }
                default:
                        break;
        }
diff --git a/src/apps/expander/ExpanderPreferences.h 
b/src/apps/expander/ExpanderPreferences.h
index 48944f5..31b930d 100644
--- a/src/apps/expander/ExpanderPreferences.h
+++ b/src/apps/expander/ExpanderPreferences.h
@@ -1,57 +1,42 @@
-/*****************************************************************************/
-// Expander
-// Written by Jérôme Duval
-//
-// ExpanderPreferences.h
-//
-//
-// Copyright (c) 2004 OpenBeOS Project
-//
-// 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 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 MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS 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.
-/*****************************************************************************/
-
-#ifndef _ExpanderPreferences_h
-#define _ExpanderPreferences_h
+/*
+ * Copyright 2004-2012, Haiku. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Jérôme Duval
+ */
+#ifndef _EXPANDERPREFERENCES_H
+#define _EXPANDERPREFERENCES_H
+
 
-#include "DirectoryFilePanel.h"
-#include <Window.h>
-#include <Message.h>
 #include <Button.h>
-#include <Entry.h>
-#include <TextControl.h>
 #include <CheckBox.h>
+#include <Entry.h>
+#include <Message.h>
 #include <RadioButton.h>
+#include <TextControl.h>
+#include <Window.h>
+
+#include "DirectoryFilePanel.h"
+
 
 class ExpanderPreferences : public BWindow {
-       public:
-               ExpanderPreferences(BMessage *settings);
-               virtual ~ExpanderPreferences();
-               virtual void MessageReceived(BMessage *msg);
-
-       private:
-               BMessage *fSettings;
-               BCheckBox *fAutoExpand, *fCloseWindow, *fAutoShow, *fOpenDest;
-               BRadioButton *fDestUse, *fSameDest, *fLeaveDest;
-               BButton *fSelect;
-               BTextControl *fDestText;
-               entry_ref fRef;
-               DirectoryFilePanel *fUsePanel;
+public:
+                                               ExpanderPreferences(BMessage* 
settings);
+       virtual                         ~ExpanderPreferences();
+       virtual void            MessageReceived(BMessage* msg);
+
+private:
+       void                            _LoadSettings();
+       void                            _SaveSettings();
+
+       BButton                         *fSelect;
+       BCheckBox                       *fAutoExpand, *fCloseWindow, 
*fAutoShow, *fOpenDest;
+       BMessage                        *fSettings;
+       BRadioButton            *fDestUse, *fSameDest, *fLeaveDest;
+       BTextControl            *fDestText;
+       DirectoryFilePanel      *fUsePanel;
+       entry_ref                       fRef;
 };
 
-#endif /* _ExpanderPreferences_h */
+#endif // _EXPANDERPREFERENCES_H

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

Commit:      ddec5397e46ba4144aaf69924f49145e943b03ff
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ddec539
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Tue Feb 28 16:55:57 2012 UTC

Now sets back its settings when closing the settings window with "Cancel".

* Pulled reading and writing settings into private functions.
* Call _ReadSettings() when canceling settings window to revert to
  original settings.

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

diff --git a/src/apps/expander/ExpanderPreferences.cpp 
b/src/apps/expander/ExpanderPreferences.cpp
index 91a0dd4..8b8da50 100644
--- a/src/apps/expander/ExpanderPreferences.cpp
+++ b/src/apps/expander/ExpanderPreferences.cpp
@@ -141,21 +141,38 @@ ExpanderPreferences::ExpanderPreferences(BMessage* 
settings)
 
        CenterOnScreen();
 
+       _ReadSettings();
+}
+
+
+ExpanderPreferences::~ExpanderPreferences()
+{
+       if (fUsePanel && fUsePanel->RefFilter())
+               delete fUsePanel->RefFilter();
+
+       delete fUsePanel;
+}
+
+
+void
+ExpanderPreferences::_ReadSettings()
+{
        bool automatically_expand_files;
        bool close_when_done;
        int8 destination_folder;
        entry_ref ref;
        bool open_destination_folder;
        bool show_contents_listing;
-       if ((settings->FindBool("automatically_expand_files", 
&automatically_expand_files) == B_OK)
-               && automatically_expand_files)
+       if ((fSettings->FindBool("automatically_expand_files",
+                       &automatically_expand_files) == B_OK)
+                               && automatically_expand_files)
                fAutoExpand->SetValue(B_CONTROL_ON);
 
-       if ((settings->FindBool("close_when_done", &close_when_done) == B_OK)
-               && close_when_done)
+       if ((fSettings->FindBool("close_when_done", &close_when_done) == B_OK)
+                       && close_when_done)
                fCloseWindow->SetValue(B_CONTROL_ON);
 
-       if (settings->FindInt8("destination_folder", &destination_folder) == 
B_OK) {
+       if (fSettings->FindInt8("destination_folder", &destination_folder) == 
B_OK) {
                switch (destination_folder) {
                        case 0x63:
                                fSameDest->SetValue(B_CONTROL_ON);
@@ -171,7 +188,7 @@ ExpanderPreferences::ExpanderPreferences(BMessage* settings)
                }
        }
 
-       if (settings->FindRef("destination_folder_use", &fRef) == B_OK) {
+       if (fSettings->FindRef("destination_folder_use", &fRef) == B_OK) {
                BEntry entry(&fRef);
                if (entry.Exists()) {
                        BPath path(&entry);
@@ -179,22 +196,33 @@ ExpanderPreferences::ExpanderPreferences(BMessage* 
settings)
                }
        }
 
-       if ((settings->FindBool("open_destination_folder", 
&open_destination_folder) == B_OK)
-               && open_destination_folder)
+       if ((fSettings->FindBool("open_destination_folder",
+                       &open_destination_folder) == B_OK)
+                               && open_destination_folder)
                fOpenDest->SetValue(B_CONTROL_ON);
 
-       if ((settings->FindBool("show_contents_listing", 
&show_contents_listing) == B_OK)
-               && show_contents_listing)
+       if ((fSettings->FindBool("show_contents_listing",
+                       &show_contents_listing) == B_OK)
+                               && show_contents_listing)
                fAutoShow->SetValue(B_CONTROL_ON);
 }
 
 
-ExpanderPreferences::~ExpanderPreferences()
+void
+ExpanderPreferences::_WriteSettings()
 {
-       if (fUsePanel && fUsePanel->RefFilter())
-               delete fUsePanel->RefFilter();
-
-       delete fUsePanel;
+       fSettings->ReplaceBool("automatically_expand_files",
+               fAutoExpand->Value() == B_CONTROL_ON);
+       fSettings->ReplaceBool("close_when_done",
+               fCloseWindow->Value() == B_CONTROL_ON);
+       fSettings->ReplaceInt8("destination_folder",
+               (fSameDest->Value() == B_CONTROL_ON) ? 0x63
+               : ((fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 : 0x65));
+       fSettings->ReplaceRef("destination_folder_use", &fRef);
+       fSettings->ReplaceBool("open_destination_folder",
+               fOpenDest->Value() == B_CONTROL_ON);
+       fSettings->ReplaceBool("show_contents_listing",
+               fAutoShow->Value() == B_CONTROL_ON);
 }
 
 
@@ -247,26 +275,15 @@ ExpanderPreferences::MessageReceived(BMessage* msg)
                        break;
                }
                case MSG_CANCEL:
+                       _ReadSettings();
                        Hide();
                        break;
-                       
+
                case MSG_OK:
-               {
-                       fSettings->ReplaceBool("automatically_expand_files",
-                               fAutoExpand->Value() == B_CONTROL_ON);
-                       fSettings->ReplaceBool("close_when_done",
-                               fCloseWindow->Value() == B_CONTROL_ON);
-                       fSettings->ReplaceInt8("destination_folder",
-                               (fSameDest->Value() == B_CONTROL_ON) ? 0x63
-                               : ((fLeaveDest->Value() == B_CONTROL_ON) ? 0x66 
: 0x65));
-                       fSettings->ReplaceRef("destination_folder_use", &fRef);
-                       fSettings->ReplaceBool("open_destination_folder",
-                               fOpenDest->Value() == B_CONTROL_ON);
-                       fSettings->ReplaceBool("show_contents_listing",
-                               fAutoShow->Value() == B_CONTROL_ON);
+                       _WriteSettings();
                        Hide();
                        break;
-               }
+
                default:
                        break;
        }
diff --git a/src/apps/expander/ExpanderPreferences.h 
b/src/apps/expander/ExpanderPreferences.h
index 31b930d..576f5f7 100644
--- a/src/apps/expander/ExpanderPreferences.h
+++ b/src/apps/expander/ExpanderPreferences.h
@@ -27,8 +27,8 @@ public:
        virtual void            MessageReceived(BMessage* msg);
 
 private:
-       void                            _LoadSettings();
-       void                            _SaveSettings();
+       void                            _ReadSettings();
+       void                            _WriteSettings();
 
        BButton                         *fSelect;
        BCheckBox                       *fAutoExpand, *fCloseWindow, 
*fAutoShow, *fOpenDest;

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

Revision:    hrev43805
Commit:      a697ddedc5a0bfbbeffead67621cfec948e1cbf3
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a697dde
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Wed Feb 29 19:21:20 2012 UTC

Cancel settings window on ESC, small cleanup.

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

diff --git a/src/apps/expander/ExpanderPreferences.cpp 
b/src/apps/expander/ExpanderPreferences.cpp
index 8b8da50..cefe568 100644
--- a/src/apps/expander/ExpanderPreferences.cpp
+++ b/src/apps/expander/ExpanderPreferences.cpp
@@ -31,9 +31,10 @@ const uint32 MSG_DESTSELECT = 'mDes';
 
 
 ExpanderPreferences::ExpanderPreferences(BMessage* settings)
-       : BWindow(BRect(0, 0, 325, 305), B_TRANSLATE("Expander settings"),
-               B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, 
B_NOT_CLOSABLE
-                       | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
+       :
+       BWindow(BRect(0, 0, 325, 305), B_TRANSLATE("Expander settings"),
+               B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, 
B_NOT_RESIZABLE
+                       | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
        fSettings(settings),
        fUsePanel(NULL)
 {
@@ -234,8 +235,9 @@ ExpanderPreferences::MessageReceived(BMessage* msg)
                {
                        if (!fUsePanel) {
                                BMessenger messenger(this);
-                               fUsePanel = new 
DirectoryFilePanel(B_OPEN_PANEL, &messenger, NULL,
-                                       B_DIRECTORY_NODE, false, NULL, new 
DirectoryRefFilter(), true);
+                               fUsePanel = new 
DirectoryFilePanel(B_OPEN_PANEL, &messenger,
+                                       NULL, B_DIRECTORY_NODE, false, NULL,
+                                       new DirectoryRefFilter(), true);
                        }
                        fUsePanel->Show();
                        break;
@@ -274,16 +276,25 @@ ExpanderPreferences::MessageReceived(BMessage* msg)
                        fDestText->TextView()->MakeEditable(false);
                        break;
                }
+               case B_KEY_DOWN:
+               {
+                       int32 index;
+                       if (msg->FindInt32("key", &index) == B_OK && index != 1)
+                               break;
+                       // Falling through on ESC
+               }
                case MSG_CANCEL:
+               {
                        _ReadSettings();
                        Hide();
                        break;
-
+               }
                case MSG_OK:
+               {
                        _WriteSettings();
                        Hide();
                        break;
-
+               }
                default:
                        break;
        }


Other related posts:

  • » [haiku-commits] haiku: hrev43805 - in src/apps: expander mediaplayer/settings aboutsystem - humdingerb