Display the memory usage as bytes instead of a percentage when show-memory-in-xbytes is set (#6503)

- move the percentage calculation to init_timeout(), use g_format_size() here too
- carry memory/swap used vs total all around
- make the XtmProcessStatusbar swap and memory properties strings instead of float

Based on a diff from  Ján Sucan, thanks!

Note to translators: this changes some strings, mostly removing % in format printing
This commit is contained in:
Landry Breuil
2014-12-04 20:52:12 +01:00
parent 7e7521cf2f
commit c6c74cd959
6 changed files with 57 additions and 37 deletions

View File

@@ -408,7 +408,7 @@ xtm_process_window_get_model (XtmProcessWindow *window)
}
void
xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processes, gfloat cpu, gfloat memory, gfloat swap)
xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processes, gfloat cpu, gfloat memory, gchar* memory_str, gfloat swap, gchar* swap_str)
{
gchar text[100];
gchar value[4];
@@ -416,7 +416,7 @@ xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processe
g_return_if_fail (XTM_IS_PROCESS_WINDOW (window));
g_return_if_fail (GTK_IS_STATUSBAR (window->statusbar));
g_object_set (window->statusbar, "num-processes", num_processes, "cpu", cpu, "memory", memory, "swap", swap, NULL);
g_object_set (window->statusbar, "num-processes", num_processes, "cpu", cpu, "memory", memory_str, "swap", swap_str, NULL);
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->cpu_monitor), cpu / 100.0);
g_snprintf (value, 4, "%.0f", cpu);
@@ -424,8 +424,7 @@ xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processe
gtk_widget_set_tooltip_text (window->cpu_monitor, text);
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->mem_monitor), memory / 100.0);
g_snprintf (value, 4, "%.0f", memory);
g_snprintf (text, 100, _("Memory: %s%%"), value);
g_snprintf (text, 100, _("Memory: %s"), memory_str);
gtk_widget_set_tooltip_text (window->mem_monitor, text);
}