[haiku-commits] r40746 - haiku/trunk/src/apps/processcontroller

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 28 Feb 2011 22:59:23 +0100 (CET)

Author: siarzhuk
Date: 2011-02-28 22:59:23 +0100 (Mon, 28 Feb 2011)
New Revision: 40746
Changeset: http://dev.haiku-os.org/changeset/40746

Modified:
   haiku/trunk/src/apps/processcontroller/Jamfile
   haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp
   haiku/trunk/src/apps/processcontroller/MemoryBarMenu.cpp
   haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp
   haiku/trunk/src/apps/processcontroller/PriorityMenu.cpp
   haiku/trunk/src/apps/processcontroller/ProcessController.cpp
Log:
Localized some still missed strings pointed out by Diver. Thanks!
Use more safe snprintf calls instead of sprintf ones.



Modified: haiku/trunk/src/apps/processcontroller/Jamfile
===================================================================
--- haiku/trunk/src/apps/processcontroller/Jamfile      2011-02-28 21:28:50 UTC 
(rev 40745)
+++ haiku/trunk/src/apps/processcontroller/Jamfile      2011-02-28 21:59:23 UTC 
(rev 40746)
@@ -28,6 +28,8 @@
        x-vnd.Haiku-ProcessController
        :
        KernelMemoryBarMenuItem.cpp
+       MemoryBarMenu.cpp
+       MemoryBarMenuItem.cpp
        NoiseBarMenuItem.cpp
        PCWorld.cpp
        Preferences.cpp

Modified: haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp  
2011-02-28 21:28:50 UTC (rev 40745)
+++ haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp  
2011-02-28 21:59:23 UTC (rev 40746)
@@ -152,11 +152,13 @@
                menu->SetHighColor(kBlack);
 
                char infos[128];
-               sprintf(infos, B_TRANSLATE("%.1f MB"), fCachedMemory / 1024.f);
+               snprintf(infos, sizeof(infos),
+                               B_TRANSLATE("%.1f MB"), fCachedMemory / 1024.f);
                BPoint loc(cadre.left, cadre.bottom + 1);
                loc.x -= kMargin + gMemoryTextWidth / 2 + 
menu->StringWidth(infos);
                menu->DrawString(infos, loc);
-               sprintf(infos, B_TRANSLATE("%.1f MB"), fCommittedMemory / 
1024.f);
+               snprintf(infos, sizeof(infos),
+                               B_TRANSLATE("%.1f MB"), fCommittedMemory / 
1024.f);
                loc.x = cadre.left - kMargin - menu->StringWidth(infos);
                menu->DrawString(infos, loc);
                fLastSum = sum;

Modified: haiku/trunk/src/apps/processcontroller/MemoryBarMenu.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/MemoryBarMenu.cpp    2011-02-28 
21:28:50 UTC (rev 40745)
+++ haiku/trunk/src/apps/processcontroller/MemoryBarMenu.cpp    2011-02-28 
21:59:23 UTC (rev 40746)
@@ -24,6 +24,7 @@
 #include "ProcessController.h"
 
 #include <Bitmap.h>
+#include <Catalog.h>
 #include <Roster.h>
 #include <Window.h>
 
@@ -34,7 +35,10 @@
 
 float gMemoryTextWidth;
 
+#undef B_TRANSLATE_CONTEXT
+#define B_TRANSLATE_CONTEXT "MemoryBarMenu"
 
+
 MemoryBarMenu::MemoryBarMenu(const char* name, info_pack* infos, system_info& 
systemInfo)
        : BMenu(name),
        fFirstShow(true)
@@ -53,7 +57,7 @@
                fTeamList[k++] = -1;
        }
 
-       gMemoryTextWidth = 2 * StringWidth("99999 KB") + 20;
+       gMemoryTextWidth = 2 * StringWidth(B_TRANSLATE("99999 KB")) + 20;
 
        fRecycleCount = EXTRA;
        fRecycleList = (MRecycleItem*)malloc(sizeof(MRecycleItem) * 
fRecycleCount);

Modified: haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp        
2011-02-28 21:28:50 UTC (rev 40745)
+++ haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp        
2011-02-28 21:59:23 UTC (rev 40746)
@@ -25,10 +25,14 @@
 #include "ProcessController.h"
 
 #include <Bitmap.h>
+#include <Catalog.h>
 
 #include <stdio.h>
 
+#undef B_TRANSLATE_CONTEXT
+#define B_TRANSLATE_CONTEXT "MemoryBarMenu"
 
+
 MemoryBarMenuItem::MemoryBarMenuItem(const char *label, team_id team,
                BBitmap* icon, bool deleteIcon, BMessage* message)
        : BMenuItem(label, message),
@@ -210,13 +214,13 @@
        menu->SetHighColor(kBlack);
 
        char infos[128];
-       sprintf(infos, "%d KB", fWriteMemory);
+       snprintf(infos, sizeof(infos), B_TRANSLATE("%d KB"), fWriteMemory);
 
        BPoint loc(rect.left - kMargin - gMemoryTextWidth / 2 - 
menu->StringWidth(infos),
                rect.bottom + 1);
        menu->DrawString(infos, loc);
 
-       sprintf(infos, "%d KB", fAllMemory);
+       snprintf(infos, sizeof(infos), B_TRANSLATE("%d KB"), fAllMemory);
        loc.x = rect.left - kMargin - menu->StringWidth(infos);
        menu->DrawString(infos, loc);
 }

Modified: haiku/trunk/src/apps/processcontroller/PriorityMenu.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/PriorityMenu.cpp     2011-02-28 
21:28:50 UTC (rev 40745)
+++ haiku/trunk/src/apps/processcontroller/PriorityMenu.cpp     2011-02-28 
21:59:23 UTC (rev 40746)
@@ -68,7 +68,7 @@
        { "",   -1 }
 };
 
-PriorityRec customPriority = {"Custom", 0 };
+PriorityRec customPriority = { B_TRANSLATE("Custom priority"), 0 };
 
 
 void

Modified: haiku/trunk/src/apps/processcontroller/ProcessController.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/ProcessController.cpp        
2011-02-28 21:28:50 UTC (rev 40745)
+++ haiku/trunk/src/apps/processcontroller/ProcessController.cpp        
2011-02-28 21:59:23 UTC (rev 40746)
@@ -265,7 +265,7 @@
                                info_pack infos;
                                if (get_team_info(team, &infos.team_info) == 
B_OK) {
                                        get_team_name_and_icon(infos);
-                                       sprintf(question,
+                                       snprintf(question, sizeof(question),
                                        B_TRANSLATE("Do you really want to kill 
the team \"%s\"?"),
                                        infos.team_name);
                                        alert = new BAlert("", question,
@@ -289,16 +289,18 @@
                                thread_info     thinfo;
                                if (get_thread_info(thread, &thinfo) == B_OK) {
                                        #if DEBUG_THREADS
-                                       sprintf(question, B_TRANSLATE("What do 
you want to do "
-                                       "with the thread \"%s\"?"), 
thinfo.name);
+                                       snprintf(question, sizeof(question),
+                                               B_TRANSLATE("What do you want 
to do "
+                                               "with the thread \"%s\"?"), 
thinfo.name);
                                        alert = new BAlert("", question, 
B_TRANSLATE("Cancel"),
                                        B_TRANSLATE("Debug this thread!"),
                                        B_TRANSLATE("Kill this thread!"), 
B_WIDTH_AS_USUAL,
                                        B_STOP_ALERT);
                                        #define KILL 2
                                        #else
-                                       sprintf(question, B_TRANSLATE("Are you 
sure you want "
-                                       "to kill the thread \"%s\"?"), 
thinfo.name);
+                                       snprintf(question, sizeof(question),
+                                               B_TRANSLATE("Are you sure you 
want "
+                                               "to kill the thread \"%s\"?"), 
thinfo.name);
                                        alert = new BAlert("", question, 
B_TRANSLATE("Cancel"),
                                        B_TRANSLATE("Kill this thread!"), NULL, 
B_WIDTH_AS_USUAL,
                                        B_STOP_ALERT);


Other related posts: