[haiku-commits] r39286 - haiku/trunk/src/apps/showimage

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 3 Nov 2010 22:26:08 +0100 (CET)

Author: axeld
Date: 2010-11-03 22:26:08 +0100 (Wed, 03 Nov 2010)
New Revision: 39286
Changeset: http://dev.haiku-os.org/changeset/39286

Modified:
   haiku/trunk/src/apps/showimage/ShowImageApp.cpp
   haiku/trunk/src/apps/showimage/ShowImageApp.h
Log:
* Got rid of the useless fTrackerMessenger field.
* Ordered the methods in declaration order. Ordered BWindow hooks in "run"
  order.
* Renamed private methods to have the '_' prefix.


Modified: haiku/trunk/src/apps/showimage/ShowImageApp.cpp
===================================================================
--- haiku/trunk/src/apps/showimage/ShowImageApp.cpp     2010-11-03 21:04:51 UTC 
(rev 39285)
+++ haiku/trunk/src/apps/showimage/ShowImageApp.cpp     2010-11-03 21:26:08 UTC 
(rev 39286)
@@ -49,65 +49,6 @@
 
 
 void
-ShowImageApp::AboutRequested()
-{
-       const char* authors[] = {
-               "Fernando F. Oliveira",
-               "Michael Wilber",
-               "Michael Pfeiffer",
-               "Ryan Leavengood",
-               NULL
-       };
-       BAboutWindow about(B_TRANSLATE("ShowImage"), 2003, authors);
-       about.Show();
-}
-
-
-void
-ShowImageApp::ReadyToRun()
-{
-       if (CountWindows() == WINDOWS_TO_IGNORE)
-               fOpenPanel->Show();
-       else {
-               // If image windows are already open
-               // (paths supplied on the command line)
-               // start checking the number of open windows
-               StartPulse();
-       }
-
-       be_clipboard->StartWatching(be_app_messenger);
-               // tell the clipboard to notify this app when its contents 
change
-}
-
-
-void
-ShowImageApp::StartPulse()
-{
-       if (!fPulseStarted) {
-               // Tell the app to begin checking
-               // for the number of open windows
-               fPulseStarted = true;
-               SetPulseRate(250000);
-                       // Set pulse to every 1/4 second
-       }
-}
-
-
-void
-ShowImageApp::Pulse()
-{
-       // Bug: The BFilePanel is automatically closed if the volume that
-       // is displayed is unmounted.
-       if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE) {
-               // If the application is not launching and
-               // all windows are closed except for the file open panel,
-               // quit the application
-               PostMessage(B_QUIT_REQUESTED);
-       }
-}
-
-
-void
 ShowImageApp::ArgvReceived(int32 argc, char **argv)
 {
        BMessage message;
@@ -144,6 +85,23 @@
 
 
 void
+ShowImageApp::ReadyToRun()
+{
+       if (CountWindows() == WINDOWS_TO_IGNORE)
+               fOpenPanel->Show();
+       else {
+               // If image windows are already open
+               // (paths supplied on the command line)
+               // start checking the number of open windows
+               _StartPulse();
+       }
+
+       be_clipboard->StartWatching(be_app_messenger);
+               // tell the clipboard to notify this app when its contents 
change
+}
+
+
+void
 ShowImageApp::MessageReceived(BMessage* message)
 {
        switch (message->what) {
@@ -157,11 +115,11 @@
                case B_CANCEL:
                        // File open panel was closed,
                        // start checking count of open windows
-                       StartPulse();
+                       _StartPulse();
                        break;
 
                case B_CLIPBOARD_CHANGED:
-                       CheckClipboard();
+                       _CheckClipboard();
                        break;
 
                default:
@@ -172,36 +130,85 @@
 
 
 void
+ShowImageApp::AboutRequested()
+{
+       const char* authors[] = {
+               "Fernando F. Oliveira",
+               "Michael Wilber",
+               "Michael Pfeiffer",
+               "Ryan Leavengood",
+               NULL
+       };
+       BAboutWindow about(B_TRANSLATE("ShowImage"), 2003, authors);
+       about.Show();
+}
+
+
+void
+ShowImageApp::Pulse()
+{
+       // Bug: The BFilePanel is automatically closed if the volume that
+       // is displayed is unmounted.
+       if (!IsLaunching() && CountWindows() <= WINDOWS_TO_IGNORE) {
+               // If the application is not launching and
+               // all windows are closed except for the file open panel,
+               // quit the application
+               PostMessage(B_QUIT_REQUESTED);
+       }
+}
+
+
+void
 ShowImageApp::RefsReceived(BMessage* message)
 {
        // If a tracker window opened me, get a messenger from it.
+       BMessenger trackerMessenger;
        if (message->HasMessenger("TrackerViewToken"))
-               message->FindMessenger("TrackerViewToken", &fTrackerMessenger);
+               message->FindMessenger("TrackerViewToken", &trackerMessenger);
 
-       uint32 type;
-       int32 count;
-       status_t ret = message->GetInfo("refs", &type, &count);
-       if (ret != B_OK || type != B_REF_TYPE)
-               return;
-
        entry_ref ref;
-       for (int32 i = 0; i < count; i++) {
-               if (message->FindRef("refs", i, &ref) == B_OK)
-                       Open(&ref);
+       for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
+               _Open(&ref, trackerMessenger);
        }
 }
 
 
+bool
+ShowImageApp::QuitRequested()
+{
+       // Give the windows a chance to prompt the user if there are changes
+       bool result = BApplication::QuitRequested();
+       if (result)
+               be_clipboard->StopWatching(be_app_messenger);
+                       // tell clipboard we don't want anymore notification
+
+       return result;
+}
+
+
 void
-ShowImageApp::Open(const entry_ref* ref)
+ShowImageApp::_StartPulse()
 {
-       new ShowImageWindow(ref, fTrackerMessenger);
+       if (!fPulseStarted) {
+               // Tell the app to begin checking
+               // for the number of open windows
+               fPulseStarted = true;
+               SetPulseRate(250000);
+                       // Set pulse to every 1/4 second
+       }
 }
 
 
 void
-ShowImageApp::BroadcastToWindows(BMessage* message)
+ShowImageApp::_Open(const entry_ref* ref, BMessenger& trackerMessenger)
 {
+       new ShowImageWindow(ref, trackerMessenger);
+}
+
+
+void
+ShowImageApp::_BroadcastToWindows(BMessage* message)
+{
        const int32 count = CountWindows();
        for (int32 i = 0; i < count; i ++) {
                // BMessenger checks for us if BWindow is still a valid object
@@ -212,7 +219,7 @@
 
 
 void
-ShowImageApp::CheckClipboard()
+ShowImageApp::_CheckClipboard()
 {
        // Determines if the contents of the clipboard contain
        // data that is useful to this application.
@@ -233,23 +240,10 @@
 
        BMessage msg(MSG_CLIPBOARD_CHANGED);
        msg.AddBool("data_available", dataAvailable);
-       BroadcastToWindows(&msg);
+       _BroadcastToWindows(&msg);
 }
 
 
-bool
-ShowImageApp::QuitRequested()
-{
-       // Give the windows a chance to prompt the user if there are changes
-       bool result = BApplication::QuitRequested();
-       if (result)
-               be_clipboard->StopWatching(be_app_messenger);
-                       // tell clipboard we don't want anymore notification
-
-       return result;
-}
-
-
 //     #pragma mark -
 
 

Modified: haiku/trunk/src/apps/showimage/ShowImageApp.h
===================================================================
--- haiku/trunk/src/apps/showimage/ShowImageApp.h       2010-11-03 21:04:51 UTC 
(rev 39285)
+++ haiku/trunk/src/apps/showimage/ShowImageApp.h       2010-11-03 21:26:08 UTC 
(rev 39286)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
+ * Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -23,33 +23,33 @@
                                                                ShowImageApp();
        virtual                                         ~ShowImageApp();
 
+       virtual void                            ArgvReceived(int32 argc, char** 
argv);
+       virtual void                            ReadyToRun();
+       virtual void                            MessageReceived(BMessage* 
message);
        virtual void                            AboutRequested();
-       virtual void                            ArgvReceived(int32 argc, char 
**argv);
-       virtual void                            MessageReceived(BMessage 
*message);
-       virtual void                            ReadyToRun();
        virtual void                            Pulse();
-       virtual void                            RefsReceived(BMessage *message);
+       virtual void                            RefsReceived(BMessage* message);
        virtual bool                            QuitRequested();
 
                        ShowImageSettings*      Settings() { return &fSettings; 
}
 
 private:
-                       void                            StartPulse();
-                       void                            Open(const entry_ref 
*ref);
-                       void                            
BroadcastToWindows(BMessage *message);
-                       void                            CheckClipboard();
+                       void                            _StartPulse();
+                       void                            _Open(const entry_ref* 
ref,
+                                                                       
BMessenger& trackerMessenger);
+                       void                            
_BroadcastToWindows(BMessage* message);
+                       void                            _CheckClipboard();
 
-                       BMessenger                      fTrackerMessenger;
-                       BFilePanel                      *fOpenPanel;
+private:
+                       BFilePanel*                     fOpenPanel;
                        bool                            fPulseStarted;
                        ShowImageSettings       fSettings;
 };
 
 
-extern const char *kApplicationSignature;
+extern const char* kApplicationSignature;
 
 #define my_app dynamic_cast<ShowImageApp*>(be_app)
 
 
 #endif // SHOW_IMAGE_APP_H
-


Other related posts:

  • » [haiku-commits] r39286 - haiku/trunk/src/apps/showimage - axeld