[haiku-commits] r40910 - haiku/trunk/src/apps/pulse

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 10 Mar 2011 23:32:23 +0100 (CET)

Author: siarzhuk
Date: 2011-03-10 23:32:12 +0100 (Thu, 10 Mar 2011)
New Revision: 40910
Changeset: http://dev.haiku-os.org/changeset/40910
Ticket: http://dev.haiku-os.org/ticket/7347

Modified:
   haiku/trunk/src/apps/pulse/CPUButton.cpp
   haiku/trunk/src/apps/pulse/ConfigView.cpp
   haiku/trunk/src/apps/pulse/DeskbarPulseView.cpp
   haiku/trunk/src/apps/pulse/Jamfile
   haiku/trunk/src/apps/pulse/MiniPulseView.cpp
   haiku/trunk/src/apps/pulse/NormalPulseView.cpp
   haiku/trunk/src/apps/pulse/PrefsWindow.cpp
   haiku/trunk/src/apps/pulse/PulseApp.cpp
   haiku/trunk/src/apps/pulse/PulseApp.h
   haiku/trunk/src/apps/pulse/PulseView.cpp
   haiku/trunk/src/apps/pulse/PulseWindow.cpp
Log:
Applying revized localization patch prepared by Jorma Karvonen.
Fixes #7347. Thanks.

Additionally: single function for About alert added - replaces the triplication 
of 
the same text in original code.



Modified: haiku/trunk/src/apps/pulse/CPUButton.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/CPUButton.cpp    2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/CPUButton.cpp    2011-03-10 22:32:12 UTC (rev 
40910)
@@ -16,9 +16,8 @@
 #include <Alert.h>
 #include <Catalog.h>
 #include <Dragger.h>
-#include <Locale.h>
 #include <PopUpMenu.h>
-
+#include <TextView.h>
 #include <ViewPrivate.h>
 
 #include <syscalls.h>
@@ -241,8 +240,10 @@
        if (!LastEnabledCPU(fCPU)) {
                _kern_set_cpu_enabled(fCPU, Value());
        } else {
-               BAlert *alert = new BAlert(NULL, B_TRANSLATE("You can't disable 
the "
-                       "last active CPU."), B_TRANSLATE("OK"));
+               BAlert *alert = new BAlert(B_TRANSLATE("Info"),
+                       B_TRANSLATE("You can't disable the last active CPU."),
+                       B_TRANSLATE("OK"));
+               alert->SetShortcut(0, B_ESCAPE);
                alert->Go(NULL);
                SetValue(!Value());
        }
@@ -276,11 +277,7 @@
 {
        switch (message->what) {
                case B_ABOUT_REQUESTED: {
-                       BAlert *alert = new BAlert(B_TRANSLATE("Info"), 
-                               B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve 
Hjønnevåg\n"
-                               "Revised by Daniel Switkin"), 
B_TRANSLATE("OK"));
-                       // Use the asynchronous version so we don't block the 
window's thread
-                       alert->Go(NULL);
+                       PulseApp::ShowAbout();
                        break;
                }
                case PV_REPLICANT_PULSE: {

Modified: haiku/trunk/src/apps/pulse/ConfigView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/ConfigView.cpp   2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/ConfigView.cpp   2011-03-10 22:32:12 UTC (rev 
40910)
@@ -16,7 +16,6 @@
 
 #include <Catalog.h>
 #include <CheckBox.h>
-#include <Locale.h>
 #include <RadioButton.h>
 #include <TextControl.h>
 

Modified: haiku/trunk/src/apps/pulse/DeskbarPulseView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/DeskbarPulseView.cpp     2011-03-10 22:25:29 UTC 
(rev 40909)
+++ haiku/trunk/src/apps/pulse/DeskbarPulseView.cpp     2011-03-10 22:32:12 UTC 
(rev 40910)
@@ -8,19 +8,23 @@
 //
 
//****************************************************************************************
 
+
 #include "DeskbarPulseView.h"
-#include "Common.h"
-#include "Prefs.h"
-#include <app/Application.h>
-#include <Catalog.h>
-#include <interface/Deskbar.h>
-#include <interface/Alert.h>
-#include <Locale.h>
-#include <Roster.h>
+
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
+#include <Alert.h>
+#include <Application.h>
+#include <Catalog.h>
+#include <Deskbar.h>
+#include <Roster.h>
+
+#include "Common.h"
+#include "Prefs.h"
+#include "PulseApp.h"
+
 #undef B_TRANSLATE_CONTEXT
 #define B_TRANSLATE_CONTEXT "DeskbarPulseView"
 
@@ -124,10 +128,7 @@
                        prefswindow->Show();
                        break;
                case PV_ABOUT: {
-                       BAlert *alert = new BAlert(B_TRANSLATE("Info"), 
-                               B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve 
Hjønnevåg\n"
-                               "Revised by Daniel Switkin"), 
B_TRANSLATE("OK"));
-                       alert->Go(NULL);
+                       PulseApp::ShowAbout();
                        break;
                }
                case PV_QUIT:
@@ -175,10 +176,13 @@
        BDeskbar *deskbar = new BDeskbar();
        status_t err = deskbar->RemoveItem("DeskbarPulseView");
        if (err != B_OK) {
-               char temp[255];
-               sprintf(temp, B_TRANSLATE("Remove(): %s"), strerror(err));
-               BAlert *alert = new BAlert(B_TRANSLATE("Info"), temp, 
+               BString str;
+               snprintf(str.LockBuffer(512), 512,
+                       B_TRANSLATE("Removing from Deskbar failed.\n%s"), 
strerror(err));
+               str.UnlockBuffer();
+               BAlert *alert = new BAlert(B_TRANSLATE("Info"), str.String(),
                        B_TRANSLATE("OK"));
+               alert->SetShortcut(0, B_ESCAPE);
                alert->Go(NULL);
        }
        delete deskbar;

Modified: haiku/trunk/src/apps/pulse/Jamfile
===================================================================
--- haiku/trunk/src/apps/pulse/Jamfile  2011-03-10 22:25:29 UTC (rev 40909)
+++ haiku/trunk/src/apps/pulse/Jamfile  2011-03-10 22:32:12 UTC (rev 40910)
@@ -40,3 +40,9 @@
        PrefsWindow.cpp
        PulseWindow.cpp
 ;
+
+AddCatalogEntryAttribute Pulse 
+       :
+       x-vnd.Haiku-Pulse:PulseWindow:Pulse
+;
+

Modified: haiku/trunk/src/apps/pulse/MiniPulseView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/MiniPulseView.cpp        2011-03-10 22:25:29 UTC 
(rev 40909)
+++ haiku/trunk/src/apps/pulse/MiniPulseView.cpp        2011-03-10 22:32:12 UTC 
(rev 40910)
@@ -11,7 +11,6 @@
 #include "MiniPulseView.h"
 #include "Common.h"
 #include <Catalog.h>
-#include <Locale.h>
 #include <interface/Window.h>
 
 #undef B_TRANSLATE_CONTEXT

Modified: haiku/trunk/src/apps/pulse/NormalPulseView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/NormalPulseView.cpp      2011-03-10 22:25:29 UTC 
(rev 40909)
+++ haiku/trunk/src/apps/pulse/NormalPulseView.cpp      2011-03-10 22:32:12 UTC 
(rev 40910)
@@ -16,7 +16,6 @@
 #include <Catalog.h>
 #include <Bitmap.h>
 #include <Dragger.h>
-#include <Locale.h>
 #include <Window.h>
 
 #include <stdlib.h>
@@ -203,9 +202,9 @@
        char buffer[64];
        int32 cpuSpeed = get_rounded_cpu_speed();
        if (cpuSpeed > 1000 && (cpuSpeed % 10) == 0)
-               snprintf(buffer, sizeof(buffer), "%.2f GHz", cpuSpeed / 
1000.0f);
+               snprintf(buffer, sizeof(buffer), B_TRANSLATE("%.2f GHz"), 
cpuSpeed / 1000.0f);
        else
-               snprintf(buffer, sizeof(buffer), "%ld MHz", cpuSpeed);
+               snprintf(buffer, sizeof(buffer), B_TRANSLATE("%ld MHz"), 
cpuSpeed);
        
        // We can't assume anymore that a CPU clock speed is always static.
        // Let's compute the best font size for the CPU speed string each 
time...

Modified: haiku/trunk/src/apps/pulse/PrefsWindow.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PrefsWindow.cpp  2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/PrefsWindow.cpp  2011-03-10 22:32:12 UTC (rev 
40910)
@@ -16,7 +16,6 @@
 
 #include <Catalog.h>
 #include <Button.h>
-#include <Locale.h>
 #include <TabView.h>
 #include <TextControl.h>
 

Modified: haiku/trunk/src/apps/pulse/PulseApp.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PulseApp.cpp     2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/PulseApp.cpp     2011-03-10 22:32:12 UTC (rev 
40910)
@@ -21,8 +21,8 @@
 #include <Alert.h>
 #include <Catalog.h>
 #include <Deskbar.h>
-#include <Locale.h>
 #include <Rect.h>
+#include <TextView.h>
 
 #include <syscalls.h>
 
@@ -160,6 +160,41 @@
 }
 
 
+void
+PulseApp::AboutRequested()
+{
+       PulseApp::ShowAbout();
+}
+
+
+void
+PulseApp::ShowAbout()
+{
+       // static version to be used in replicant mode
+       BString name(B_TRANSLATE("Pulse"));
+       BString message;
+       snprintf(message.LockBuffer(512), 512,
+               B_TRANSLATE("%s\n\nBy David Ramsey and Arve Hjønnevåg\n"
+               "Revised by Daniel Switkin\n"), name.String());
+       message.UnlockBuffer();
+
+       BAlert *alert = new BAlert(B_TRANSLATE("Info"),
+               message.String(), B_TRANSLATE("OK"));
+
+       BTextView* view = alert->TextView();
+       BFont font;
+                               
+       view->SetStylable(true);                        
+       view->GetFont(&font);
+       
+       font.SetSize(18);
+       font.SetFace(B_BOLD_FACE);
+       view->SetFontAndColor(0, name.Length(), &font);
+       alert->SetShortcut(0, B_ESCAPE);
+       // Use the asynchronous version so we don't block the window's thread
+       alert->Go(NULL);
+}
+
 //     #pragma mark -
 
 
@@ -234,7 +269,13 @@
        delete replicant;
        delete deskbar;
        if (err != B_OK) {
-               BAlert *alert = new BAlert(NULL, strerror(err), 
B_TRANSLATE("OK"));
+               BString message;
+               snprintf(message.LockBuffer(512), 512,
+                       B_TRANSLATE("Installing in Deskbar failed\n%s"), 
strerror(err));
+               message.UnlockBuffer();
+               BAlert *alert = new BAlert(B_TRANSLATE("Error"),
+                       message.String(), B_TRANSLATE("OK"));
+               alert->SetShortcut(0, B_ESCAPE);
                alert->Go(NULL);
                return false;
        }

Modified: haiku/trunk/src/apps/pulse/PulseApp.h
===================================================================
--- haiku/trunk/src/apps/pulse/PulseApp.h       2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/PulseApp.h       2011-03-10 22:32:12 UTC (rev 
40910)
@@ -23,6 +23,9 @@
                                                PulseApp(int argc, char **argv);
                                                ~PulseApp();
 
+       virtual void            AboutRequested();
+       static  void            ShowAbout();
+
                        Prefs*          prefs;
 
 private:

Modified: haiku/trunk/src/apps/pulse/PulseView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PulseView.cpp    2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/PulseView.cpp    2011-03-10 22:32:12 UTC (rev 
40910)
@@ -16,7 +16,6 @@
 
 #include <Alert.h>
 #include <Catalog.h>
-#include <Locale.h>
 
 #include <syscalls.h>
 
@@ -128,8 +127,10 @@
        if (!LastEnabledCPU(which)) {
                _kern_set_cpu_enabled(which, 
(int)!cpu_menu_items[which]->IsMarked());
        } else {
-               BAlert *alert = new BAlert(NULL, B_TRANSLATE("You can't disable 
the "
-                       "last active CPU."), B_TRANSLATE("OK"));
+               BAlert *alert = new BAlert(B_TRANSLATE("Info"),
+                       B_TRANSLATE("You can't disable the last active CPU."),
+                       B_TRANSLATE("OK"));
+               alert->SetShortcut(0, B_ESCAPE);
                alert->Go(NULL);
        }
 }
@@ -138,3 +139,4 @@
        if (popupmenu != NULL) delete popupmenu;
        if (cpu_menu_items != NULL) delete cpu_menu_items;
 }
+

Modified: haiku/trunk/src/apps/pulse/PulseWindow.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PulseWindow.cpp  2011-03-10 22:25:29 UTC (rev 
40909)
+++ haiku/trunk/src/apps/pulse/PulseWindow.cpp  2011-03-10 22:32:12 UTC (rev 
40910)
@@ -17,8 +17,8 @@
 #include <Alert.h>
 #include <Catalog.h>
 #include <Deskbar.h>
-#include <Locale.h>
 #include <Screen.h>
+#include <TextView.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -103,11 +103,7 @@
                        break;
                }
                case PV_ABOUT: {
-                       BAlert *alert = new BAlert(B_TRANSLATE("Info"), 
-                               B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve 
Hjønnevåg\n"
-                               "Revised by Daniel Switkin"), 
B_TRANSLATE("OK"));
-                       // Use the asynchronous version so we don't block the 
window's thread
-                       alert->Go(NULL);
+                       PulseApp::ShowAbout();
                        break;
                }
                case PV_QUIT:


Other related posts:

  • » [haiku-commits] r40910 - haiku/trunk/src/apps/pulse - zharik