[haiku-commits] haiku: hrev45592 - in src: apps/workspaces apps/deskcalc kits/shared apps/processcontroller preferences/locale

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 1 May 2013 10:14:41 +0200 (CEST)

hrev45592 adds 1 changeset to branch 'master'
old head: 196ab88d06ca479b6d6ab2ab974c1dd0c899a088
new head: 31535ac63b726cbcd1933c5fa429543eca4e7509
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=31535ac+%5E196ab88

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

31535ac: Make BAboutWindow modal
  
   �* Set its type to B_MODAL_WINDO, and also set B_NOT_MOVABLE
   * Since this removes the window tab, add an "Ok" button to close the window
   * Remove the GetWindow mess and just use it as any regular window
   * Adjust all callers again
  
  The AlertPosition method doesn't seem to work right, the window pops up
  offset to the right. I also noticed that some of our calls to BAboutWindow
  are actually not reacable because we removed Abutrequested from the apps.
  Maybe we should clean them up (locale preflet and activity monitor are 
examples)
  
  More annoying is the fact that opening a modal window from a deskbar replicant
  is modal against the whole deskbar. Not sure what to do about that.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

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

Revision:    hrev45592
Commit:      31535ac63b726cbcd1933c5fa429543eca4e7509
URL:         http://cgit.haiku-os.org/haiku/commit/?id=31535ac
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Wed May  1 08:10:37 2013 UTC

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

7 files changed, 94 insertions(+), 140 deletions(-)
headers/private/shared/AboutWindow.h             |  5 --
src/apps/deskcalc/CalcView.cpp                   | 46 ++++++++----------
src/apps/networkstatus/NetworkStatusView.cpp     | 27 +++++------
src/apps/processcontroller/ProcessController.cpp | 39 +++++++--------
src/apps/workspaces/Workspaces.cpp               | 51 +++++++++-----------
src/kits/shared/AboutWindow.cpp                  | 34 ++++---------
src/preferences/locale/LocalePreflet.cpp         | 32 +++++-------

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

diff --git a/headers/private/shared/AboutWindow.h 
b/headers/private/shared/AboutWindow.h
index 55829c0..a8ec0b5 100644
--- a/headers/private/shared/AboutWindow.h
+++ b/headers/private/shared/AboutWindow.h
@@ -45,13 +45,8 @@ class BAboutWindow : public BWindow {
 
                        const char*             Version();
                        void                    SetVersion(const char* version);
-
-       static  BAboutWindow*   GetWindow(const char* appName,
-                                                               const char* 
signature, bool* needsInit = NULL);
  private:
                        AboutView*              fAboutView;
-
-       static  BAboutWindow*   sAboutWindow;
 };
 
 #endif // B_ABOUT_WINDOW_H
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 8af748e..c9a0f9c 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -267,32 +267,26 @@ CalcView::MessageReceived(BMessage* message)
                        // (replicant) about box requested
                        case B_ABOUT_REQUESTED:
                        {
-                               bool needsInit;
-                               BAboutWindow* window = 
BAboutWindow::GetWindow(kAppName,
-                                       kSignature, &needsInit);
-
-                               if (needsInit) {
-                                       // create the about window
-                                       const char* extraCopyrights[] = {
-                                               "1997, 1998 R3 Software Ltd.",
-                                               NULL
-                                       };
-
-                                       const char* authors[] = {
-                                               "Stephan Aßmus",
-                                               "John Scipione",
-                                               "Timothy Wayper",
-                                               "Ingo Weinhold",
-                                               NULL
-                                       };
-
-                                       window->AddCopyright(2006, "Haiku, 
Inc.", extraCopyrights);
-                                       window->AddAuthors(authors);
-                               }
-
-                               if (window->IsHidden())
-                                       window->Show();
-                               window->Activate();
+                               BAboutWindow* window = new 
BAboutWindow(kAppName, kSignature);
+
+                               // create the about window
+                               const char* extraCopyrights[] = {
+                                       "1997, 1998 R3 Software Ltd.",
+                                       NULL
+                               };
+
+                               const char* authors[] = {
+                                       "Stephan Aßmus",
+                                       "John Scipione",
+                                       "Timothy Wayper",
+                                       "Ingo Weinhold",
+                                       NULL
+                               };
+
+                               window->AddCopyright(2006, "Haiku, Inc.", 
extraCopyrights);
+                               window->AddAuthors(authors);
+
+                               window->Show();
 
                                break;
                        }
diff --git a/src/apps/networkstatus/NetworkStatusView.cpp 
b/src/apps/networkstatus/NetworkStatusView.cpp
index faef66b..cdff48e 100644
--- a/src/apps/networkstatus/NetworkStatusView.cpp
+++ b/src/apps/networkstatus/NetworkStatusView.cpp
@@ -504,24 +504,19 @@ NetworkStatusView::MouseDown(BPoint point)
 void
 NetworkStatusView::_AboutRequested()
 {
-       bool needsInit;
-       BAboutWindow* window = BAboutWindow::GetWindow(
-               B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature, 
&needsInit);
+       BAboutWindow* window = new BAboutWindow(
+               B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature);
        
-       if (needsInit) {
-               const char* authors[] = {
-                       "Axel Dörfler",
-                       "Hugo Santos",
-                       NULL
-               };
-
-               window->AddCopyright(2007, "Haiku, Inc.");
-               window->AddAuthors(authors);
-       }
+       const char* authors[] = {
+               "Axel Dörfler",
+               "Hugo Santos",
+               NULL
+       };
+
+       window->AddCopyright(2007, "Haiku, Inc.");
+       window->AddAuthors(authors);
 
-       if (window->IsHidden())
-               window->Show();
-       window->Activate();
+       window->Show();
 }
 
 
diff --git a/src/apps/processcontroller/ProcessController.cpp 
b/src/apps/processcontroller/ProcessController.cpp
index b7fe26e..17aae5c 100644
--- a/src/apps/processcontroller/ProcessController.cpp
+++ b/src/apps/processcontroller/ProcessController.cpp
@@ -433,29 +433,24 @@ ProcessController::MessageReceived(BMessage *message)
 void
 ProcessController::AboutRequested()
 {
-       bool needsInit;
-       BAboutWindow* window = BAboutWindow::GetWindow(
-               B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature, 
&needsInit);
-
-       if (needsInit) {
-               const char* extraCopyrights[] = {
-                       "2004 beunited.org",
-                       "1997-2001 Georges-Edouard Berenger",
-                       NULL
-               };
-
-               const char* authors[] = {
-                       "Georges-Edouard Berenger",
-                       NULL
-               };
-
-               window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
-               window->AddAuthors(authors);
-       }
+       BAboutWindow* window = new BAboutWindow(
+               B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature);
+
+       const char* extraCopyrights[] = {
+               "2004 beunited.org",
+               "1997-2001 Georges-Edouard Berenger",
+               NULL
+       };
+
+       const char* authors[] = {
+               "Georges-Edouard Berenger",
+               NULL
+       };
+
+       window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
+       window->AddAuthors(authors);
 
-       if (window->IsHidden())
-               window->Show();
-       window->Activate();
+       window->Show();
 }
 
 
diff --git a/src/apps/workspaces/Workspaces.cpp 
b/src/apps/workspaces/Workspaces.cpp
index 3f87647..30f8f16 100644
--- a/src/apps/workspaces/Workspaces.cpp
+++ b/src/apps/workspaces/Workspaces.cpp
@@ -400,36 +400,31 @@ WorkspacesView::Archive(BMessage* archive, bool deep) 
const
 void
 WorkspacesView::_AboutRequested()
 {
-       bool needsInit;
-       BAboutWindow* window = BAboutWindow::GetWindow(
-               B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature, &needsInit);
-
-       if (needsInit) {
-               const char* authors[] = {
-                       "Axel Dörfler",
-                       "Oliver \"Madison\" Kohl",
-                       "Matt Madia",
-                       "François Revol",
-                       NULL
-               };
-
-               const char* extraCopyrights[] = {
-                       "2002 François Revol",
-                       NULL
-               };
-
-               const char* extraInfo = "Send windows behind using the Option 
key. "
-                       "Move windows to front using the Control key.\n";
-
-               window->AddCopyright(2002, "Haiku, Inc.",
+       BAboutWindow* window = new BAboutWindow(
+               B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature);
+
+       const char* authors[] = {
+               "Axel Dörfler",
+               "Oliver \"Madison\" Kohl",
+               "Matt Madia",
+               "François Revol",
+               NULL
+       };
+
+       const char* extraCopyrights[] = {
+               "2002 François Revol",
+               NULL
+       };
+
+       const char* extraInfo = "Send windows behind using the Option key. "
+               "Move windows to front using the Control key.\n";
+
+       window->AddCopyright(2002, "Haiku, Inc.",
                        extraCopyrights);
-               window->AddAuthors(authors);
-               window->AddExtraInfo(extraInfo);
-       }
+       window->AddAuthors(authors);
+       window->AddExtraInfo(extraInfo);
 
-       if (window->IsHidden())
-               window->Show();
-       window->Activate();
+       window->Show();
 }
 
 
diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp
index f2d6d50..84d17ea 100644
--- a/src/kits/shared/AboutWindow.cpp
+++ b/src/kits/shared/AboutWindow.cpp
@@ -16,6 +16,7 @@
 #include <Alert.h>
 #include <AppFileInfo.h>
 #include <Bitmap.h>
+#include <Button.h>
 #include <File.h>
 #include <Font.h>
 #include <GroupLayoutBuilder.h>
@@ -182,6 +183,11 @@ AboutView::AboutView(const char* appName, const char* 
signature)
 
        fStripeView = new StripeView(_GetIconFromSignature(signature));
 
+       const char* ok = B_TRANSLATE_MARK("Ok");
+       BButton* closeButton = new BButton("ok",
+               gSystemCatalog.GetString(ok, "AboutWindow"),
+               new BMessage(B_QUIT_REQUESTED));
+
        GroupLayout()->SetSpacing(0);
        BLayoutBuilder::Group<>(this)
                .AddGroup(B_HORIZONTAL, 0)
@@ -192,6 +198,7 @@ AboutView::AboutView(const char* appName, const char* 
signature)
                                .Add(fNameView)
                                .Add(fVersionView)
                                .Add(infoViewScroller)
+                               .Add(closeButton)
                                .End()
                        .AddGlue()
                        .End();
@@ -352,12 +359,10 @@ AboutView::SetIcon(BBitmap* icon)
 
 
 BAboutWindow::BAboutWindow(const char* appName, const char* signature)
-       :       BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_TITLED_WINDOW,
-               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
-                       | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
+       :       BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_MODAL_WINDOW,
+               B_ASYNCHRONOUS_CONTROLS | B_NOT_MOVABLE | B_NOT_ZOOMABLE
+                       | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | 
B_CLOSE_ON_ESCAPE)
 {
-       sAboutWindow = this;
-
        SetLayout(new BGroupLayout(B_VERTICAL));
 
        const char* about = B_TRANSLATE_MARK("About %app%");
@@ -376,8 +381,6 @@ BAboutWindow::BAboutWindow(const char* appName, const char* 
signature)
 
 BAboutWindow::~BAboutWindow()
 {
-       sAboutWindow = NULL;
-
        fAboutView->RemoveSelf();
        delete fAboutView;
        fAboutView = NULL;
@@ -613,20 +616,3 @@ BAboutWindow::SetIcon(BBitmap* icon)
        fAboutView->SetIcon(icon);
 }
 
-/* static */ BAboutWindow*
-BAboutWindow::GetWindow(const char* appName, const char* signature,
-       bool* needsInit)
-{
-       if(needsInit != NULL)
-               *needsInit = (sAboutWindow == NULL);
-               
-       if(sAboutWindow == NULL) {
-               new BAboutWindow(appName, signature);
-       }
-
-       return sAboutWindow;
-}
-
-
-/* static */ BAboutWindow*
-BAboutWindow::sAboutWindow = NULL;
diff --git a/src/preferences/locale/LocalePreflet.cpp 
b/src/preferences/locale/LocalePreflet.cpp
index 3976889..594e94d 100644
--- a/src/preferences/locale/LocalePreflet.cpp
+++ b/src/preferences/locale/LocalePreflet.cpp
@@ -74,26 +74,20 @@ LocalePreflet::MessageReceived(BMessage* message)
 
                case B_ABOUT_REQUESTED:
                {
-                       bool needsInit;
-                       BAboutWindow* window = BAboutWindow::GetWindow(kAppName,
-                               kSignature, &needsInit);
-
-                       if (needsInit) {
-                               const char* authors[] = {
-                                       "Axel Dörfler",
-                                       "Adrien Destugues",
-                                       "Oliver Tappe",
-                                       NULL
-                               };
-
-                               window = new BAboutWindow(kAppName, kSignature);
-                               window->AddCopyright(2005, "Haiku, Inc.");
-                               window->AddAuthors(authors);
-                       }
+                       BAboutWindow* window = new BAboutWindow(kAppName, 
kSignature);
+
+                       const char* authors[] = {
+                               "Axel Dörfler",
+                               "Adrien Destugues",
+                               "Oliver Tappe",
+                               NULL
+                       };
+
+                       window = new BAboutWindow(kAppName, kSignature);
+                       window->AddCopyright(2005, "Haiku, Inc.");
+                       window->AddAuthors(authors);
 
-                       if (window->IsHidden())
-                               window->Show();
-                       window->Activate();
+                       window->Show();
 
                        break;
                }


Other related posts: