gnome-system-monitor r2263 - trunk/src
- From: bdejean svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-system-monitor r2263 - trunk/src
- Date: Sun, 6 Jan 2008 15:59:55 +0000 (GMT)
Author: bdejean
Date: Sun Jan 6 15:59:55 2008
New Revision: 2263
URL: http://svn.gnome.org/viewvc/gnome-system-monitor?rev=2263&view=rev
Log:
Fixed string surgery.
No longer needed since we don't need to align values anymore.
Modified:
trunk/src/interface.cpp
trunk/src/load-graph.cpp
trunk/src/load-graph.h
Modified: trunk/src/interface.cpp
==============================================================================
--- trunk/src/interface.cpp (original)
+++ trunk/src/interface.cpp Sun Jan 6 15:59:55 2008
@@ -376,7 +376,7 @@
gtk_table_attach (GTK_TABLE (table), label, 1, 7, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->memused,
+ load_graph_get_labels(mem_graph)->memory,
1,
2,
1,
@@ -385,37 +385,6 @@
GTK_FILL,
0,
0);
- // xgettext: user memory: 123 MiB of 512MiB
- label = gtk_label_new (_("of"));
- gtk_table_attach (GTK_TABLE (table), label, 5, 6, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
-
- gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->memtotal,
- 6,
- 7,
- 1,
- 2,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->mempercent,
- 3,
- 4,
- 1,
- 2,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- label = gtk_label_new (_("("));
- gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
-
- label = gtk_label_new (_(")"));
- gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
table = gtk_table_new (2, 7, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
@@ -433,7 +402,7 @@
gtk_table_attach (GTK_TABLE (table), label, 1, 7, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->swapused,
+ load_graph_get_labels(mem_graph)->swap,
1,
2,
1,
@@ -442,37 +411,6 @@
GTK_FILL,
0,
0);
- // xgettext: swap: 10MiB of 1GiB
- label = gtk_label_new (_("of"));
- gtk_table_attach (GTK_TABLE (table), label, 5, 6, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
-
- gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->swaptotal,
- 6,
- 7,
- 1,
- 2,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- gtk_table_attach (GTK_TABLE (table),
- load_graph_get_labels(mem_graph)->swappercent,
- 3,
- 4,
- 1,
- 2,
- GTK_FILL,
- GTK_FILL,
- 0,
- 0);
-
- label = gtk_label_new (_("("));
- gtk_table_attach (GTK_TABLE (table), label, 2, 3, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
-
- label = gtk_label_new (_(")"));
- gtk_table_attach (GTK_TABLE (table), label, 4, 5, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
procdata->mem_graph = mem_graph;
Modified: trunk/src/load-graph.cpp
==============================================================================
--- trunk/src/load-graph.cpp (original)
+++ trunk/src/load-graph.cpp Sun Jan 6 15:59:55 2008
@@ -400,11 +400,34 @@
}
+namespace
+{
+
+ void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+ guint64 used, guint64 total, double percent)
+ {
+ char* used_text;
+ char* total_text;
+ char* text;
+
+ used_text = SI_gnome_vfs_format_file_size_for_display(used);
+ total_text = SI_gnome_vfs_format_file_size_for_display(total);
+ // xgettext: 540MiB (53 %) of 1.0 GiB
+ text = g_strdup_printf(_("%s (%.1f %%) of %s"), used_text, percent, total_text);
+ gtk_label_set_text(label, text);
+ g_free(used_text);
+ g_free(total_text);
+ g_free(text);
+
+ if (picker)
+ gsm_color_button_set_fraction(picker, percent);
+ }
+}
+
static void
get_memory (LoadGraph *g)
{
float mempercent, swappercent;
- gchar *text1, *text2, *text3;
glibtop_mem mem;
glibtop_swap swap;
@@ -416,29 +439,13 @@
swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
mempercent = (float)mem.user / (float)mem.total;
- text1 = SI_gnome_vfs_format_file_size_for_display (mem.total);
- text2 = SI_gnome_vfs_format_file_size_for_display (mem.user);
- text3 = g_strdup_printf ("%.1f %%", mempercent * 100.0f);
- gtk_label_set_text (GTK_LABEL (g->labels.memused), text2);
- gtk_label_set_text (GTK_LABEL (g->labels.memtotal), text1);
- gtk_label_set_text (GTK_LABEL (g->labels.mempercent), text3);
- if (g->mem_color_picker != NULL)
- gsm_color_button_set_fraction(GSM_COLOR_BUTTON(g->mem_color_picker), mempercent);
- g_free (text1);
- g_free (text2);
- g_free (text3);
-
- text1 = SI_gnome_vfs_format_file_size_for_display (swap.total);
- text2 = SI_gnome_vfs_format_file_size_for_display (swap.used);
- text3 = g_strdup_printf ("%.1f %%", swappercent * 100.0f);
- gtk_label_set_text (GTK_LABEL (g->labels.swapused), text2);
- gtk_label_set_text (GTK_LABEL (g->labels.swaptotal), text1);
- gtk_label_set_text (GTK_LABEL (g->labels.swappercent), text3);
- if (g->swap_color_picker != NULL)
- gsm_color_button_set_fraction(GSM_COLOR_BUTTON(g->swap_color_picker), swappercent);
- g_free (text1);
- g_free (text2);
- g_free (text3);
+ set_memory_label_and_picker(GTK_LABEL(g->labels.memory),
+ GSM_COLOR_BUTTON(g->mem_color_picker),
+ mem.user, mem.total, mempercent);
+
+ set_memory_label_and_picker(GTK_LABEL(g->labels.swap),
+ GSM_COLOR_BUTTON(g->swap_color_picker),
+ swap.used, swap.total, swappercent);
g->data[0][0] = mempercent;
g->data[0][1] = swappercent;
@@ -727,12 +734,8 @@
case LOAD_GRAPH_MEM:
g->n = 2;
- g->labels.memused = gtk_label_new(NULL);
- g->labels.memtotal = gtk_label_new(NULL);
- g->labels.mempercent = gtk_label_new(NULL);
- g->labels.swapused = gtk_label_new(NULL);
- g->labels.swaptotal = gtk_label_new(NULL);
- g->labels.swappercent = gtk_label_new(NULL);
+ g->labels.memory = gtk_label_new(NULL);
+ g->labels.swap = gtk_label_new(NULL);
break;
case LOAD_GRAPH_NET:
Modified: trunk/src/load-graph.h
==============================================================================
--- trunk/src/load-graph.h (original)
+++ trunk/src/load-graph.h Sun Jan 6 15:59:55 2008
@@ -20,12 +20,8 @@
struct _LoadGraphLabels
{
GtkWidget *cpu[GLIBTOP_NCPU];
- GtkWidget *memused;
- GtkWidget *memtotal;
- GtkWidget *mempercent;
- GtkWidget *swapused;
- GtkWidget *swaptotal;
- GtkWidget *swappercent;
+ GtkWidget *memory;
+ GtkWidget *swap;
GtkWidget *net_in;
GtkWidget *net_in_total;
GtkWidget *net_out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]