diff options
author | infirit <[email protected]> | 2014-12-18 21:30:25 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-18 21:31:13 +0100 |
commit | 6034caada16eab3b07e090c0f2b29a1a3dd9d105 (patch) | |
tree | 8d7d47e968444258975bdd887821f7694241451d /src/util.cpp | |
parent | ad78931540508c4f3d52d938852c47086ce7b03f (diff) | |
download | mate-system-monitor-6034caada16eab3b07e090c0f2b29a1a3dd9d105.tar.bz2 mate-system-monitor-6034caada16eab3b07e090c0f2b29a1a3dd9d105.tar.xz |
Priority column to the process table to show user-friendly nice values
Taken from GSM commit: 6fcbf5aaa65d63dd751c812c3ac05a937b50450d
From: Robert Roth <[email protected]>
Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=131802
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index 97119ec..ac4405f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -210,6 +210,20 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits) } } +gchar * +procman::get_nice_level (gint nice) +{ + if (nice < -7) + return _("Very High"); + else if (nice < -2) + return _("High"); + else if (nice < 3) + return _("Normal"); + else if (nice < 7) + return _("Low"); + else + return _("Very Low"); +} gboolean @@ -471,6 +485,37 @@ namespace procman g_object_set(renderer, "text", str, NULL); } + void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer, + GtkTreeModel *model, GtkTreeIter *iter, + gpointer user_data) + { + const guint index = GPOINTER_TO_UINT(user_data); + + GValue value = { 0 }; + + gtk_tree_model_get_value(model, iter, index, &value); + + gint priority = g_value_get_int(&value); + + g_value_unset(&value); + + g_object_set(renderer, "text", procman::get_nice_level(priority), NULL); + + } + + gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first, + GtkTreeIter* second, gpointer user_data) + { + const guint index = GPOINTER_TO_UINT(user_data); + GValue value1 = { 0 }; + GValue value2 = { 0 }; + gtk_tree_model_get_value(model, first, index, &value1); + gtk_tree_model_get_value(model, second, index, &value2); + gint result = g_value_get_int(&value1) - g_value_get_int(&value2); + g_value_unset(&value1); + g_value_unset(&value2); + return result; + } template<> void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value) |