diff -Naur xfce4-taskmanager-1.0.0-orig/src/main.c xfce4-taskmanager-1.0.0/src/main.c --- xfce4-taskmanager-1.0.0-orig/src/main.c 2010-06-10 02:52:32.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/main.c 2013-06-20 19:17:38.977462245 +0200 @@ -83,12 +83,31 @@ init_timeout (void) { guint num_processes; - gfloat cpu, memory, swap; - guint64 swap_free, swap_total; - gchar tooltip[1024]; + gfloat cpu, memory_percent, swap_percent; + guint64 swap_used, swap_free, swap_total, memory_used, memory_total; + gchar tooltip[1024], memory_info[64], swap_info[64], used[64], total[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); + + memory_percent = (memory_total != 0) ? memory_used * 100 / (gdouble)memory_total : 0; + + g_object_get (settings, "show-memory-in-xbytes", &show_memory_in_xbytes, NULL); + if (show_memory_in_xbytes) { + memory_human_size(memory_used, used); + memory_human_size(memory_total, total); + g_snprintf (memory_info, 64,"%s / %s", used, total); + + memory_human_size(swap_used, used); + memory_human_size(swap_total, total); + g_snprintf (swap_info, 64,"%s / %s", used, total); + } else { + swap_percent = (swap_total != 0) ? swap_used * 100 / (gdouble)swap_total : 0; + g_snprintf (memory_info, 64, "%.0f%%", memory_percent); + g_snprintf (swap_info, 64, "%.0f%%", swap_percent); + } - xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory, &swap); - xtm_process_window_set_system_info (XTM_PROCESS_WINDOW (window), num_processes, cpu, memory, swap); + xtm_process_window_set_system_info (XTM_PROCESS_WINDOW (window), num_processes, cpu, memory_info, memory_percent, swap_info); xtm_task_manager_get_swap_usage (task_manager, &swap_free, &swap_total); xtm_process_window_show_swap_usage (XTM_PROCESS_WINDOW (window), (swap_total > 0)); @@ -99,17 +118,17 @@ g_snprintf (tooltip, 1024, _("Processes: %u\n" "CPU: %.0f%%\n" - "Memory: %.0f%%\n" - "Swap: %.0f%%"), - num_processes, cpu, memory, swap); + "Memory: %s\n" + "Swap: %s"), + num_processes, cpu, memory_info, swap_info); gtk_status_icon_set_tooltip_markup (GTK_STATUS_ICON (status_icon), tooltip); #else g_snprintf (tooltip, 1024, _("Processes: %u\n" "CPU: %.0f%%\n" - "Memory: %.0f%%\n" - "Swap: %.0f%%"), - num_processes, cpu, memory, swap); + "Memory: %s\n" + "Swap: %s"), + num_processes, cpu, memory_info, swap_info); gtk_status_icon_set_tooltip (GTK_STATUS_ICON (status_icon), tooltip); #endif } @@ -173,6 +192,7 @@ 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 (settings, "notify::show-status-icon", G_CALLBACK (show_hide_status_icon), NULL); + g_signal_connect (settings, "notify::show-storage-in-bytes", G_CALLBACK (force_timeout_update), NULL); g_signal_connect (window, "destroy", G_CALLBACK (destroy_window), NULL); g_signal_connect (window, "delete-event", G_CALLBACK (delete_window), NULL); diff -Naur xfce4-taskmanager-1.0.0-orig/src/process-statusbar.c xfce4-taskmanager-1.0.0/src/process-statusbar.c --- xfce4-taskmanager-1.0.0-orig/src/process-statusbar.c 2010-06-02 01:02:40.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/process-statusbar.c 2013-06-20 18:54:13.071548850 +0200 @@ -45,8 +45,8 @@ GtkWidget * label_swap; gfloat cpu; - gfloat memory; - gfloat swap; + gchar memory[64]; + gchar swap[64]; guint num_processes; }; G_DEFINE_TYPE (XtmProcessStatusbar, xtm_process_statusbar, GTK_TYPE_STATUSBAR) @@ -64,11 +64,11 @@ class->finalize = xtm_process_statusbar_finalize; class->set_property = xtm_process_statusbar_set_property; g_object_class_install_property (class, PROP_CPU, - g_param_spec_float ("cpu", "CPU", "CPU usage", 0, 100, 0, G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); + g_param_spec_float ("cpu", "CPU", "CPU usage", 0, 100, 0, G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); g_object_class_install_property (class, PROP_MEMORY, - g_param_spec_float ("memory", "Memory", "Memory usage", 0, 100, 0, G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); + g_param_spec_string ("memory", "Memory", "Memory usage", "", G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); g_object_class_install_property (class, PROP_SWAP, - g_param_spec_float ("swap", "Swap", "Swap usage", 0, 100, 0, G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); + g_param_spec_string ("swap", "Swap", "Swap usage", "", G_PARAM_CONSTRUCT|G_PARAM_WRITABLE)); g_object_class_install_property (class, PROP_SHOW_SWAP, g_param_spec_boolean ("show-swap", "ShowSwap", "Show or hide swap usage", TRUE, G_PARAM_WRITABLE)); g_object_class_install_property (class, PROP_NUM_PROCESSES, @@ -139,6 +139,7 @@ XtmProcessStatusbar *statusbar = XTM_PROCESS_STATUSBAR (object); gchar *text; gchar *float_value; + gchar *string_value; switch (property_id) { @@ -152,20 +153,16 @@ break; case PROP_MEMORY: - statusbar->memory = g_value_get_float (value); - float_value = rounded_float_value (statusbar->memory, statusbar->settings); - text = g_strdup_printf (_("Memory: %s%%"), float_value); + text = g_strdup_printf (_("Memory: %s"), g_value_get_string (value)); + g_strlcpy(statusbar->memory, text, 64); gtk_label_set_text (GTK_LABEL (statusbar->label_memory), text); - g_free (float_value); g_free (text); break; case PROP_SWAP: - statusbar->swap = g_value_get_float (value); - float_value = rounded_float_value (statusbar->swap, statusbar->settings); - text = g_strdup_printf (_("Swap: %s%%"), float_value); + text = g_strdup_printf (_("Swap: %s"), g_value_get_string (value)); + g_strlcpy(statusbar->swap, text, 64); gtk_label_set_text (GTK_LABEL (statusbar->label_swap), text); - g_free (float_value); g_free (text); break; @@ -196,4 +193,3 @@ { return g_object_new (XTM_TYPE_PROCESS_STATUSBAR, NULL); } - diff -Naur xfce4-taskmanager-1.0.0-orig/src/process-window.c xfce4-taskmanager-1.0.0/src/process-window.c --- xfce4-taskmanager-1.0.0-orig/src/process-window.c 2010-06-13 17:59:12.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/process-window.c 2013-06-20 19:19:04.770553857 +0200 @@ -364,6 +364,7 @@ menu_preferences_append_item (GTK_MENU (menu), _("More precision"), "more-precision", window->priv->settings); menu_preferences_append_item (GTK_MENU (menu), _("Full command line"), "full-command-line", window->priv->settings); menu_preferences_append_item (GTK_MENU (menu), _("Show status icon"), "show-status-icon", window->priv->settings); + menu_preferences_append_item (GTK_MENU (menu), _("Show memory usage in bytes"), "show-memory-in-xbytes", window->priv->settings); refresh_rate_menu = build_refresh_rate_menu (window->priv->settings); mi = gtk_menu_item_new_with_label (_("Refresh rate")); @@ -491,7 +492,7 @@ } 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, gchar *memory, gfloat memory_percent, gchar *swap) { gchar text[100]; gchar value[4]; @@ -506,9 +507,8 @@ g_snprintf (text, 100, _("CPU: %s%%"), value); gtk_widget_set_tooltip_text (window->priv->cpu_monitor, text); - xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->priv->mem_monitor), memory / 100.0); - g_snprintf (value, 4, "%.0f", memory); - g_snprintf (text, 100, _("Memory: %s%%"), value); + xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->priv->mem_monitor), memory_percent / 100); + g_snprintf (text, 100, _("Memory: %s"), memory); gtk_widget_set_tooltip_text (window->priv->mem_monitor, text); } @@ -519,4 +519,3 @@ g_return_if_fail (GTK_IS_STATUSBAR (window->priv->statusbar)); g_object_set (window->priv->statusbar, "show-swap", show_swap_usage, NULL); } - diff -Naur xfce4-taskmanager-1.0.0-orig/src/process-window.h xfce4-taskmanager-1.0.0/src/process-window.h --- xfce4-taskmanager-1.0.0-orig/src/process-window.h 2010-06-08 22:41:38.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/process-window.h 2013-06-20 18:54:13.072548863 +0200 @@ -29,7 +29,7 @@ GType xtm_process_window_get_type (void); GtkWidget * xtm_process_window_new (); GtkTreeModel * 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); +void xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processes, gfloat cpu, gchar *memory, gfloat memory_percent, gchar *swap); void xtm_process_window_show_swap_usage (XtmProcessWindow *window, gboolean show_swap_usage); #endif /* !PROCESS_WINDOW_H */ diff -Naur xfce4-taskmanager-1.0.0-orig/src/settings.c xfce4-taskmanager-1.0.0/src/settings.c --- xfce4-taskmanager-1.0.0-orig/src/settings.c 2010-06-02 01:02:40.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/settings.c 2013-06-20 19:20:19.579505646 +0200 @@ -35,6 +35,7 @@ PROP_MORE_PRECISION, PROP_FULL_COMMAND_LINE, PROP_SHOW_STATUS_ICON, + PROP_SHOW_MEMORY_IN_XBYTES, PROP_REFRESH_RATE, PROP_COLUMNS_POSITIONS, PROP_COLUMN_UID, @@ -88,6 +89,8 @@ 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_param_spec_boolean ("show-status-icon", "ShowStatusIcon", "Show/hide the status icon", TRUE, 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_REFRESH_RATE, g_param_spec_uint ("refresh-rate", "RefreshRate", "Refresh rate in milliseconds", 0, G_MAXUINT, 750, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_COLUMNS_POSITIONS, diff -Naur xfce4-taskmanager-1.0.0-orig/src/task-manager.c xfce4-taskmanager-1.0.0/src/task-manager.c --- xfce4-taskmanager-1.0.0-orig/src/task-manager.c 2010-06-08 22:41:38.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/task-manager.c 2013-06-20 18:54:13.073548876 +0200 @@ -219,28 +219,6 @@ } static void -memory_human_size (guint64 mem, gchar *mem_str) -{ - guint64 mem_tmp; - - mem_tmp = mem / 1024 / 1024; - if (mem_tmp > 3) - { - g_snprintf (mem_str, 64, _("%lu MiB"), (gulong)mem_tmp); - return; - } - - mem_tmp = mem / 1024; - if (mem_tmp > 8) - { - g_snprintf (mem_str, 64, _("%lu KiB"), (gulong)mem_tmp); - return; - } - - g_snprintf (mem_str, 64, _("%lu B"), (gulong)mem); -} - -static void #ifdef HAVE_WNCK model_update_tree_iter (GtkTreeModel *model, GtkTreeIter *iter, Task *task, App *app) #else @@ -396,10 +374,11 @@ } void -xtm_task_manager_get_system_info (XtmTaskManager *manager, guint *num_processes, gfloat *cpu, gfloat *memory, gfloat *swap) -{ - guint64 memory_used, swap_used; +xtm_task_manager_get_system_info (XtmTaskManager *manager, guint *num_processes, gfloat *cpu, + guint64 *memory_used, guint64 *memory_total, + guint64 *swap_used, guint64 *swap_total) +{ g_return_if_fail (XTM_IS_TASK_MANAGER (manager)); /* Set number of processes */ @@ -409,11 +388,10 @@ get_memory_usage (&manager->memory_total, &manager->memory_free, &manager->memory_cache, &manager->memory_buffers, &manager->swap_total, &manager->swap_free); - memory_used = manager->memory_total - manager->memory_free - manager->memory_cache - manager->memory_buffers; - swap_used = manager->swap_total - manager->swap_free; - - *memory = (manager->memory_total != 0) ? memory_used * 100 / (gdouble)manager->memory_total : 0; - *swap = (manager->swap_total != 0) ? swap_used * 100 / (gdouble)manager->swap_total : 0; + *memory_used = manager->memory_total - manager->memory_free - manager->memory_cache - manager->memory_buffers; + *memory_total = manager->memory_total; + *swap_used = manager->swap_total - manager->swap_free; + *swap_total = manager->swap_total; /* Set CPU usage */ get_cpu_usage (&manager->cpu_count, &manager->cpu_user, &manager->cpu_system); @@ -631,6 +609,28 @@ void +memory_human_size (guint64 mem, gchar *mem_str) +{ + guint64 mem_tmp; + + mem_tmp = mem / 1024 / 1024; + if (mem_tmp > 3) + { + g_snprintf (mem_str, 64, _("%lu MiB"), (gulong)mem_tmp); + return; + } + + mem_tmp = mem / 1024; + if (mem_tmp > 8) + { + g_snprintf (mem_str, 64, _("%lu KiB"), (gulong)mem_tmp); + return; + } + + g_snprintf (mem_str, 64, _("%lu B"), (gulong)mem); +} + +void get_owner_uid (guint *owner_uid, gchar **owner_uid_name) { uid_t uid; diff -Naur xfce4-taskmanager-1.0.0-orig/src/task-manager.h xfce4-taskmanager-1.0.0/src/task-manager.h --- xfce4-taskmanager-1.0.0-orig/src/task-manager.h 2010-06-09 13:50:23.000000000 +0200 +++ xfce4-taskmanager-1.0.0/src/task-manager.h 2013-06-20 18:54:13.074548889 +0200 @@ -64,7 +64,9 @@ XtmTaskManager * xtm_task_manager_new (GtkTreeModel *model); const gchar * xtm_task_manager_get_username (XtmTaskManager *manager); const gchar * xtm_task_manager_get_hostname (XtmTaskManager *manager); -void xtm_task_manager_get_system_info (XtmTaskManager *manager, guint *num_processes, gfloat *cpu, gfloat *memory, gfloat *swap); +void xtm_task_manager_get_system_info (XtmTaskManager *manager, guint *num_processes, gfloat *cpu, + guint64 *memory_used, guint64 *memory_total, + guint64 *swap_used, guint64 *swap_total); void xtm_task_manager_get_swap_usage (XtmTaskManager *manager, guint64 *swap_free, guint64 *swap_total); const GArray * xtm_task_manager_get_task_list (XtmTaskManager *manager); void xtm_task_manager_update_model (XtmTaskManager *manager); @@ -90,6 +92,7 @@ XTM_PRIORITY_VERY_HIGH, }; +void memory_human_size (guint64 mem, gchar *mem_str); void get_owner_uid (guint *owner_uid, gchar **owner_uid_name); gchar * get_hostname (); gboolean send_signal_to_pid (guint pid, gint xtm_signal);