Always show memory usage in bytes and percent (Fixes #24)
This commit is contained in:
committed by
Simon Steinbeiss
parent
21cac5760b
commit
34c8d28309
12
src/main.c
12
src/main.c
@@ -101,30 +101,23 @@ init_timeout (void)
|
|||||||
gfloat cpu, memory_percent, swap_percent;
|
gfloat cpu, memory_percent, swap_percent;
|
||||||
guint64 swap_used, swap_free, swap_total, memory_used, memory_total;
|
guint64 swap_used, swap_free, swap_total, memory_used, memory_total;
|
||||||
gchar *used, *total, tooltip[1024], memory_info[64], swap_info[64];
|
gchar *used, *total, tooltip[1024], memory_info[64], swap_info[64];
|
||||||
gboolean show_memory_in_xbytes;
|
|
||||||
|
|
||||||
xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory_used, &memory_total, &swap_used, &swap_total);
|
xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory_used, &memory_total, &swap_used, &swap_total);
|
||||||
|
|
||||||
memory_percent = (memory_total != 0) ? ((memory_used * 100.0f) / (float)memory_total) : 0.0f;
|
memory_percent = (memory_total != 0) ? ((memory_used * 100.0f) / (float)memory_total) : 0.0f;
|
||||||
swap_percent = (swap_total != 0) ? ((swap_used * 100.0f) / (float)swap_total) : 0.0f;
|
swap_percent = (swap_total != 0) ? ((swap_used * 100.0f) / (float)swap_total) : 0.0f;
|
||||||
|
|
||||||
g_object_get (settings, "show-memory-in-xbytes", &show_memory_in_xbytes, NULL);
|
|
||||||
if (show_memory_in_xbytes) {
|
|
||||||
used = g_format_size_full(memory_used, G_FORMAT_SIZE_IEC_UNITS);
|
used = g_format_size_full(memory_used, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
total = g_format_size_full(memory_total, G_FORMAT_SIZE_IEC_UNITS);
|
total = g_format_size_full(memory_total, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
g_snprintf (memory_info, sizeof(memory_info), "%s / %s", used, total);
|
g_snprintf (memory_info, sizeof(memory_info), "%.0f%% (%s / %s)", used, total, memory_percent);
|
||||||
g_free(used);
|
g_free(used);
|
||||||
g_free(total);
|
g_free(total);
|
||||||
|
|
||||||
used = g_format_size_full(swap_used, G_FORMAT_SIZE_IEC_UNITS);
|
used = g_format_size_full(swap_used, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
total = g_format_size_full(swap_total, G_FORMAT_SIZE_IEC_UNITS);
|
total = g_format_size_full(swap_total, G_FORMAT_SIZE_IEC_UNITS);
|
||||||
g_snprintf (swap_info, sizeof(swap_info), "%s / %s", used, total);
|
g_snprintf (swap_info, sizeof(swap_info), "%.0f%% (%s / %s)", used, total, swap_percent);
|
||||||
g_free(used);
|
g_free(used);
|
||||||
g_free(total);
|
g_free(total);
|
||||||
} else {
|
|
||||||
g_snprintf (memory_info, sizeof(memory_info), "%.0f%%", memory_percent);
|
|
||||||
g_snprintf (swap_info, sizeof(swap_info), "%.0f%%", swap_percent);
|
|
||||||
}
|
|
||||||
|
|
||||||
xtm_process_window_set_system_info (XTM_PROCESS_WINDOW (window), num_processes, cpu, memory_percent, memory_info, swap_percent, swap_info);
|
xtm_process_window_set_system_info (XTM_PROCESS_WINDOW (window), num_processes, cpu, memory_percent, memory_info, swap_percent, swap_info);
|
||||||
|
|
||||||
@@ -249,7 +242,6 @@ int main (int argc, char *argv[])
|
|||||||
g_signal_connect_after (settings, "notify::more-precision", G_CALLBACK (force_timeout_update), NULL);
|
g_signal_connect_after (settings, "notify::more-precision", G_CALLBACK (force_timeout_update), NULL);
|
||||||
g_signal_connect_after (settings, "notify::full-command-line", G_CALLBACK (force_timeout_update), NULL);
|
g_signal_connect_after (settings, "notify::full-command-line", G_CALLBACK (force_timeout_update), NULL);
|
||||||
g_signal_connect (settings, "notify::show-status-icon", G_CALLBACK (show_hide_status_icon), NULL);
|
g_signal_connect (settings, "notify::show-status-icon", G_CALLBACK (show_hide_status_icon), NULL);
|
||||||
g_signal_connect (settings, "notify::show-memory-in-xbytes", G_CALLBACK (force_timeout_update), NULL);
|
|
||||||
|
|
||||||
g_signal_connect (window, "destroy", G_CALLBACK (destroy_window), NULL);
|
g_signal_connect (window, "destroy", G_CALLBACK (destroy_window), NULL);
|
||||||
g_signal_connect (window, "delete-event", G_CALLBACK (delete_window), NULL);
|
g_signal_connect (window, "delete-event", G_CALLBACK (delete_window), NULL);
|
||||||
|
|||||||
@@ -138,21 +138,6 @@
|
|||||||
<property name="position">4</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="button-show-memory-in-xbytes">
|
|
||||||
<property name="label" translatable="yes">Show memory usage in bytes</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="hbox-toolbar-style">
|
<object class="GtkBox" id="hbox-toolbar-style">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ xtm_settings_dialog_init (XtmSettingsDialog *dialog)
|
|||||||
builder_bind_toggle_button (builder, "button-more-precision", dialog->settings, "more-precision");
|
builder_bind_toggle_button (builder, "button-more-precision", dialog->settings, "more-precision");
|
||||||
builder_bind_toggle_button (builder, "button-prompt-terminate-task", dialog->settings, "prompt-terminate-task");
|
builder_bind_toggle_button (builder, "button-prompt-terminate-task", dialog->settings, "prompt-terminate-task");
|
||||||
builder_bind_toggle_button (builder, "button-show-status-icon", dialog->settings, "show-status-icon");
|
builder_bind_toggle_button (builder, "button-show-status-icon", dialog->settings, "show-status-icon");
|
||||||
builder_bind_toggle_button (builder, "button-show-memory-in-xbytes", dialog->settings, "show-memory-in-xbytes");
|
|
||||||
builder_bind_toggle_button (builder, "button-process-tree", dialog->settings, "process-tree");
|
builder_bind_toggle_button (builder, "button-process-tree", dialog->settings, "process-tree");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,20 +99,6 @@
|
|||||||
<property name="position">4</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="button-show-memory-in-xbytes">
|
|
||||||
<property name="label" translatable="yes">Show memory usage in bytes</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="hbox-toolbar-style">
|
<object class="GtkHBox" id="hbox-toolbar-style">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ enum
|
|||||||
PROP_MORE_PRECISION,
|
PROP_MORE_PRECISION,
|
||||||
PROP_FULL_COMMAND_LINE,
|
PROP_FULL_COMMAND_LINE,
|
||||||
PROP_SHOW_STATUS_ICON,
|
PROP_SHOW_STATUS_ICON,
|
||||||
PROP_SHOW_MEMORY_IN_XBYTES,
|
|
||||||
PROP_MONITOR_PAINT_BOX,
|
PROP_MONITOR_PAINT_BOX,
|
||||||
PROP_SHOW_APPLICATION_ICONS,
|
PROP_SHOW_APPLICATION_ICONS,
|
||||||
PROP_TOOLBAR_STYLE,
|
PROP_TOOLBAR_STYLE,
|
||||||
@@ -97,8 +96,6 @@ xtm_settings_class_init (XtmSettingsClass *klass)
|
|||||||
g_param_spec_boolean ("full-command-line", "FullCommandLine", "Full command line", FALSE, G_PARAM_READWRITE));
|
g_param_spec_boolean ("full-command-line", "FullCommandLine", "Full command line", FALSE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (class, PROP_SHOW_STATUS_ICON,
|
g_object_class_install_property (class, PROP_SHOW_STATUS_ICON,
|
||||||
g_param_spec_boolean ("show-status-icon", "ShowStatusIcon", "Show/hide the status icon", FALSE, G_PARAM_READWRITE));
|
g_param_spec_boolean ("show-status-icon", "ShowStatusIcon", "Show/hide the status icon", FALSE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (class, PROP_SHOW_MEMORY_IN_XBYTES,
|
|
||||||
g_param_spec_boolean ("show-memory-in-xbytes", "ShowMemoryInXBytes", "Show memory usage in bytes", FALSE, G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (class, PROP_MONITOR_PAINT_BOX,
|
g_object_class_install_property (class, PROP_MONITOR_PAINT_BOX,
|
||||||
g_param_spec_boolean ("monitor-paint-box", "MonitorPaintBox", "Paint box around monitor", TRUE, G_PARAM_READWRITE));
|
g_param_spec_boolean ("monitor-paint-box", "MonitorPaintBox", "Paint box around monitor", TRUE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (class, PROP_SHOW_APPLICATION_ICONS,
|
g_object_class_install_property (class, PROP_SHOW_APPLICATION_ICONS,
|
||||||
|
|||||||
Reference in New Issue
Block a user