[gnome-system-monitor] Use nice values for priority GAction parameter instead of strings



commit 79b2edbc5504901f8b866f29b5d8fb9867fdc06e
Author: Robert Roth <robert roth off gmail com>
Date:   Thu Jul 25 01:35:29 2013 +0300

    Use nice values for priority GAction parameter instead of strings

 data/menus.ui     |   12 ++++++------
 src/interface.cpp |   31 ++++++++++---------------------
 src/proctable.cpp |   10 +++++-----
 3 files changed, 21 insertions(+), 32 deletions(-)
---
diff --git a/data/menus.ui b/data/menus.ui
index ce5bae0..0ee4755 100644
--- a/data/menus.ui
+++ b/data/menus.ui
@@ -92,34 +92,34 @@
           <item>
             <attribute name="label" translatable="yes">Very High</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">very-high</attribute>
+            <attribute name="target" type="i">-20</attribute>
           </item>
           <item>
             <attribute name="label" translatable="yes">High</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">high</attribute>
+            <attribute name="target" type="i">-5</attribute>
           </item>
           <item>
             <attribute name="label" translatable="yes">Normal</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">normal</attribute>
+            <attribute name="target" type="i">0</attribute>
           </item>
           <item>
             <attribute name="label" translatable="yes">Low</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">low</attribute>
+            <attribute name="target" type="i">5</attribute>
           </item>
           <item>
             <attribute name="label" translatable="yes">Very Low</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">very-low</attribute>
+            <attribute name="target" type="i">19</attribute>
           </item>
         </section>
         <section>
           <item>
             <attribute name="label" translatable="yes">Custom</attribute>
             <attribute name="action">win.priority</attribute>
-            <attribute name="target">custom</attribute>
+            <attribute name="target" type="i">32</attribute>
           </item>
         </section>
       </submenu>
diff --git a/src/interface.cpp b/src/interface.cpp
index 21944a7..c9945e1 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -456,27 +456,16 @@ on_activate_priority (GSimpleAction *action, GVariant *parameter, gpointer data)
 
     g_action_change_state (G_ACTION (action), parameter);
 
-    const char *priority = g_variant_get_string (parameter, NULL);
-
-    if (strcmp (priority, "custom") == 0) {
-        procdialog_create_renice_dialog (app);
-    } else {
-      int new_nice_value = 0;
-
-      if (strcmp (priority, "very-high") == 0) {
-          new_nice_value = -20;
-      } else if (strcmp (priority, "high") == 0) {
-          new_nice_value = -5;
-      } else if (strcmp (priority, "normal") == 0) {
-          new_nice_value = 0;
-      } else if (strcmp (priority, "low") == 0) {
-          new_nice_value = 5;
-      } else if (strcmp (priority, "very-low") == 0) {
-          new_nice_value = 19;
-      }
-
-      renice (app, new_nice_value);
+    const gint32 priority = g_variant_get_int32 (parameter);
+    switch (priority) {
+           case 32: 
+               procdialog_create_renice_dialog (app);
+               break;
+           default:
+               renice (app, priority);
+               break;
     }
+
 }
 
 static void
@@ -572,7 +561,7 @@ create_main_window (ProcmanApp *app)
         { "send-signal-cont", on_activate_send_signal, "i", NULL, NULL },
         { "send-signal-end", on_activate_send_signal, "i", NULL, NULL },
         { "send-signal-kill", on_activate_send_signal, "i", NULL, NULL },
-        { "priority", on_activate_priority, "s", "'normal'", change_priority_state },
+        { "priority", on_activate_priority, "i", "@i 0", change_priority_state },
         { "memory-maps", on_activate_memory_maps, NULL, NULL, NULL },
         { "open-files", on_activate_open_files, NULL, NULL, NULL },
         { "process-properties", on_activate_process_properties, NULL, NULL, NULL },
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 38a2a64..285774c 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -238,15 +238,15 @@ cb_row_selected (GtkTreeSelection *selection, gpointer data)
         GVariant *priority;
         gint nice = app->selected_process->nice;
         if (nice < -7)
-            priority = g_variant_new_string ("very-high");
+            priority = g_variant_new_int32 (-20);
         else if (nice < -2)
-            priority = g_variant_new_string ("high");
+            priority = g_variant_new_int32 (-5);
         else if (nice < 3)
-            priority = g_variant_new_string ("normal");
+            priority = g_variant_new_int32 (0);
         else if (nice < 7)
-            priority = g_variant_new_string ("low");
+            priority = g_variant_new_int32 (5);
         else
-            priority = g_variant_new_string ("very-low");
+            priority = g_variant_new_int32 (19);
 
         GAction *action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
                                                       "priority");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]