Author: phoudoin Date: 2011-03-02 17:08:24 +0100 (Wed, 02 Mar 2011) New Revision: 40780 Changeset: http://dev.haiku-os.org/changeset/40780 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 Log: Use string_for_size() to format and localize sizes in a consistent way. Modified: haiku/trunk/src/apps/processcontroller/Jamfile =================================================================== --- haiku/trunk/src/apps/processcontroller/Jamfile 2011-03-02 15:34:15 UTC (rev 40779) +++ haiku/trunk/src/apps/processcontroller/Jamfile 2011-03-02 16:08:24 UTC (rev 40780) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src apps processcontroller ; UsePrivateSystemHeaders ; +UsePrivateHeaders shared ; Application ProcessController : AutoIcon.cpp @@ -20,7 +21,7 @@ ThreadBarMenu.cpp ThreadBarMenuItem.cpp Utilities.cpp - : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) + : be libshared.a $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : ProcessController.rdef ; Modified: haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp =================================================================== --- haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp 2011-03-02 15:34:15 UTC (rev 40779) +++ haiku/trunk/src/apps/processcontroller/KernelMemoryBarMenuItem.cpp 2011-03-02 16:08:24 UTC (rev 40780) @@ -1,20 +1,20 @@ /* ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. - Copyright (C) 2004 beunited.org + Copyright (C) 2004 beunited.org - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -27,6 +27,7 @@ #include <stdio.h> #include <Catalog.h> +#include <StringForSize.h> #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "ProcessController" @@ -152,13 +153,11 @@ menu->SetHighColor(kBlack); char infos[128]; - snprintf(infos, sizeof(infos), - B_TRANSLATE("%.1f MiB"), fCachedMemory / 1024.f); + string_for_size(fCachedMemory * 1024.0, infos, sizeof(infos)); BPoint loc(cadre.left, cadre.bottom + 1); loc.x -= kMargin + gMemoryTextWidth / 2 + menu->StringWidth(infos); menu->DrawString(infos, loc); - snprintf(infos, sizeof(infos), - B_TRANSLATE("%.1f MiB"), fCommittedMemory / 1024.f); + string_for_size(fCommittedMemory * 1024.0, infos, sizeof(infos)); 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-03-02 15:34:15 UTC (rev 40779) +++ haiku/trunk/src/apps/processcontroller/MemoryBarMenu.cpp 2011-03-02 16:08:24 UTC (rev 40780) @@ -1,20 +1,20 @@ /* ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. - Copyright (C) 2004 beunited.org + Copyright (C) 2004 beunited.org - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -26,6 +26,7 @@ #include <Bitmap.h> #include <Catalog.h> #include <Roster.h> +#include <StringForSize.h> #include <Window.h> #include <stdlib.h> @@ -57,7 +58,9 @@ fTeamList[k++] = -1; } - gMemoryTextWidth = 2 * StringWidth(B_TRANSLATE("99999 KiB")) + 20; + char buffer[64]; + string_for_size(99999999.9, buffer, sizeof(buffer)); + gMemoryTextWidth = 2 * StringWidth(buffer) + 32; fRecycleCount = EXTRA; fRecycleList = (MRecycleItem*)malloc(sizeof(MRecycleItem) * fRecycleCount); Modified: haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp =================================================================== --- haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp 2011-03-02 15:34:15 UTC (rev 40779) +++ haiku/trunk/src/apps/processcontroller/MemoryBarMenuItem.cpp 2011-03-02 16:08:24 UTC (rev 40780) @@ -1,20 +1,20 @@ /* ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. - Copyright (C) 2004 beunited.org + Copyright (C) 2004 beunited.org - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -26,6 +26,7 @@ #include <Bitmap.h> #include <Catalog.h> +#include <StringForSize.h> #include <stdio.h> @@ -214,13 +215,13 @@ menu->SetHighColor(kBlack); char infos[128]; - snprintf(infos, sizeof(infos), B_TRANSLATE("%d KiB"), fWriteMemory); + string_for_size(fWriteMemory * 1024.0, infos, sizeof(infos)); BPoint loc(rect.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth(infos), rect.bottom + 1); menu->DrawString(infos, loc); - snprintf(infos, sizeof(infos), B_TRANSLATE("%d KiB"), fAllMemory); + string_for_size(fAllMemory * 1024.0, infos, sizeof(infos)); loc.x = rect.left - kMargin - menu->StringWidth(infos); menu->DrawString(infos, loc); }