[gnome-system-monitor] Port process popup menu to GAction



commit 0e766b2dbbdb3484655e100a19b13c2d4cd1170f
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Jul 18 17:47:48 2013 +0200

    Port process popup menu to GAction
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704467

 Makefile.am           |    3 +-
 data/interface.ui     |   86 +++++++++++++++++-
 data/popups.ui        |   24 -----
 src/callbacks.cpp     |  151 ++----------------------------
 src/callbacks.h       |   20 ----
 src/gsm.gresource.xml |    1 -
 src/interface.cpp     |  247 ++++++++++++++++++++++++++-----------------------
 src/interface.h       |    1 -
 src/procman-app.cpp   |   12 ---
 src/procman-app.h     |   15 ---
 src/proctable.cpp     |   26 +++++-
 11 files changed, 251 insertions(+), 335 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index a376f6f..d1be33a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,8 +9,7 @@ ui_files = \
        data/lsof.ui \
        data/openfiles.ui \
        data/interface.ui \
-       data/menus.ui \
-       data/popups.ui
+       data/menus.ui
 
 pixmap_files = \
        pixmaps/download.svg \
diff --git a/data/interface.ui b/data/interface.ui
index faf8403..9924ca3 100644
--- a/data/interface.ui
+++ b/data/interface.ui
@@ -132,7 +132,7 @@
                     <property name="receives_default">True</property>
                     <property name="halign">end</property>
                     <property name="use_underline">True</property>
-                    <accelerator key="Delete" signal="clicked"/>
+                    <property name="action_name">win.send-signal-end</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -645,4 +645,88 @@
       </item>
     </section>
   </menu>
+  <menu id="process-popup-menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Stop Process</attribute>
+        <attribute name="action">win.send-signal-stop</attribute>
+        <attribute name="accel">&lt;Primary&gt;s</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Continue Process</attribute>
+        <attribute name="action">win.send-signal-cont</attribute>
+        <attribute name="accel">&lt;Primary&gt;c</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_End Process</attribute>
+        <attribute name="action">win.send-signal-end</attribute>
+        <attribute name="accel">&lt;Primary&gt;e</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Kill Process</attribute>
+        <attribute name="action">win.send-signal-kill</attribute>
+        <attribute name="accel">&lt;Primary&gt;k</attribute>
+      </item>
+    </section>
+    <section>
+      <submenu>
+        <attribute name="label" translatable="yes">_Change Priority</attribute>
+        <section>
+          <item>
+            <attribute name="label" translatable="yes">Very High</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">very-high</attribute>
+          </item>
+          <item>
+            <attribute name="label" translatable="yes">High</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">high</attribute>
+          </item>
+          <item>
+            <attribute name="label" translatable="yes">Normal</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">normal</attribute>
+          </item>
+          <item>
+            <attribute name="label" translatable="yes">Low</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">low</attribute>
+          </item>
+          <item>
+            <attribute name="label" translatable="yes">Very Low</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">very-low</attribute>
+          </item>
+        </section>
+        <section>
+          <item>
+            <attribute name="label" translatable="yes">Custom</attribute>
+            <attribute name="action">win.priority</attribute>
+            <attribute name="target">custom</attribute>
+          </item>
+        </section>
+      </submenu>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Memory Maps</attribute>
+        <attribute name="action">win.memory-maps</attribute>
+        <attribute name="accel">&lt;Primary&gt;m</attribute>
+      </item>
+      <item>
+        <!-- Translators: this means 'Files that are open' (open is no verb here) -->
+        <attribute name="label" translatable="yes">Open _Files</attribute>
+        <attribute name="action">win.open-files</attribute>
+        <attribute name="accel">&lt;Primary&gt;f</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Properties</attribute>
+        <attribute name="action">win.process-properties</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/src/callbacks.cpp b/src/callbacks.cpp
index d149de5..534a11e 100644
--- a/src/callbacks.cpp
+++ b/src/callbacks.cpp
@@ -32,47 +32,11 @@
 #include "procactions.h"
 #include "procman-app.h"
 #include "procdialogs.h"
-#include "memmaps.h"
-#include "openfiles.h"
-#include "procproperties.h"
 #include "load-graph.h"
 #include "disks.h"
 #include "lsof.h"
 
 void
-cb_kill_sigstop(GtkAction *action, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    /* no confirmation */
-    kill_process (app, SIGSTOP);
-}
-
-
-
-
-void
-cb_kill_sigcont(GtkAction *action, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    /* no confirmation */
-    kill_process (app, SIGCONT);
-}
-
-
-
-static void
-kill_process_helper(ProcmanApp *app, int sig)
-{
-    if (app->config.show_kill_warning)
-        procdialog_create_kill_dialog (app, sig);
-    else
-        kill_process (app, sig);
-}
-
-
-void
 cb_edit_preferences (GtkAction *action, gpointer data)
 {
     ProcmanApp *app = static_cast<ProcmanApp *>(data);
@@ -82,68 +46,6 @@ cb_edit_preferences (GtkAction *action, gpointer data)
 
 
 void
-cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    gint selected = gtk_radio_action_get_current_value(current);
-
-    if (selected == CUSTOM_PRIORITY)
-    {
-       procdialog_create_renice_dialog (app);
-    } else {
-       gint new_nice_value = 0;
-       switch (selected) {
-           case VERY_HIGH_PRIORITY: new_nice_value = -20; break;
-           case HIGH_PRIORITY: new_nice_value = -5; break;
-           case NORMAL_PRIORITY: new_nice_value = 0; break;
-           case LOW_PRIORITY: new_nice_value = 5; break;
-           case VERY_LOW_PRIORITY: new_nice_value = 19; break;
-       }
-       renice(app, new_nice_value);
-    }
-}
-
-
-void
-cb_end_process (GtkAction *action, gpointer data)
-{
-    kill_process_helper(static_cast<ProcmanApp *>(data), SIGTERM);
-}
-
-
-void
-cb_kill_process (GtkAction *action, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-    kill_process_helper(app, SIGKILL);
-}
-
-
-void
-cb_show_memory_maps (GtkAction *action, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    create_memmaps_dialog (app);
-}
-
-void
-cb_show_open_files (GtkAction *action, gpointer data)
-{
-    ProcmanApp *app = static_cast<ProcmanApp *>(data);
-
-    create_openfiles_dialog (app);
-}
-
-void
-cb_show_process_properties (GtkAction *action, gpointer data)
-{
-    ProcmanApp *app = static_cast<ProcmanApp *>(data);
-    create_procproperties_dialog (app);
-}
-
-void
 cb_show_lsof(GtkAction *action, gpointer data)
 {
     ProcmanApp *app = static_cast<ProcmanApp *>(data);
@@ -221,14 +123,6 @@ cb_main_window_delete (GtkWidget *window, GdkEvent *event, gpointer data)
     return TRUE;
 }
 
-
-void
-cb_end_process_button_pressed (GtkButton *button, gpointer data)
-{
-    ProcmanApp *app = static_cast<ProcmanApp *>(data);
-    kill_process_helper(app, SIGTERM);
-}
-
 void
 cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
 {
@@ -327,55 +221,28 @@ cb_row_selected (GtkTreeSelection *selection, gpointer data)
     gtk_tree_selection_selected_foreach (app->selection, get_last_selected,
                                          &app->selected_process);
     if (app->selected_process) {
-        gint value;
+        GVariant *priority;
         gint nice = app->selected_process->nice;
         if (nice < -7)
-            value = VERY_HIGH_PRIORITY;
+            priority = g_variant_new_string ("very-high");
         else if (nice < -2)
-            value = HIGH_PRIORITY;
+            priority = g_variant_new_string ("high");
         else if (nice < 3)
-            value = NORMAL_PRIORITY;
+            priority = g_variant_new_string ("normal");
         else if (nice < 7)
-            value = LOW_PRIORITY;
+            priority = g_variant_new_string ("low");
         else
-            value = VERY_LOW_PRIORITY;
+            priority = g_variant_new_string ("very-low");
 
-        GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(app->action_group, "Normal"));
-        block_priority_changed_handlers(app, TRUE);
-        gtk_radio_action_set_current_value(normal, value);
-        block_priority_changed_handlers(app, FALSE);
+        GAction *action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
+                                                      "priority");
 
+        g_action_change_state (action, priority);
     }
     update_sensitivity(app);
 }
 
 
-gboolean
-cb_tree_button_pressed (GtkWidget *widget,
-                        GdkEventButton *event,
-                        gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
-        do_popup_menu (app, event);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-
-gboolean
-cb_tree_popup_menu (GtkWidget *widget, gpointer data)
-{
-    ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
-    do_popup_menu (app, NULL);
-
-    return TRUE;
-}
-
-
 gint
 cb_timeout (gpointer data)
 {
diff --git a/src/callbacks.h b/src/callbacks.h
index 6b083a8..2d57ed1 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -25,13 +25,7 @@
 #include "gsm_color_button.h"
 
 
-void            cb_show_memory_maps (GtkAction *action, gpointer data);
-void            cb_show_open_files (GtkAction *action, gpointer data);
-void            cb_show_process_properties (GtkAction *action, gpointer data);
 void            cb_show_lsof(GtkAction *action, gpointer data);
-void            cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data);
-void            cb_end_process (GtkAction *action, gpointer data);
-void            cb_kill_process (GtkAction *action, gpointer data);
 void            cb_edit_preferences (GtkAction *action, gpointer data);
 
 void            cb_help_contents (GtkAction *action, gpointer data);
@@ -39,9 +33,6 @@ void            cb_about (GtkAction *action, gpointer data);
 
 gboolean        cb_main_window_delete (GtkWidget *window, GdkEvent *event, gpointer data);
 
-void            cb_end_process_button_pressed (GtkButton *button, gpointer data);
-void            cb_logout (GtkButton *button, gpointer data);
-
 void            cb_info_button_pressed (GtkButton *button, gpointer user_data);
 
 void            cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
@@ -52,10 +43,6 @@ void            cb_net_out_color_changed (GSMColorButton *widget, gpointer user_
 
 void            cb_row_selected (GtkTreeSelection *selection, gpointer data);
 
-gboolean        cb_tree_popup_menu (GtkWidget *widget, gpointer data);
-gboolean        cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event,
-                                        gpointer data);
-
 gint            cb_update_disks (gpointer data);
 gint            cb_timeout (gpointer data);
 
@@ -63,13 +50,6 @@ void            cb_refresh_icons (GtkIconTheme *theme, gpointer data);
 
 void            cb_column_resized (GtkWidget* column, GParamSpec* param, gpointer data);
 
-
-void            cb_kill_sigstop(GtkAction *action,
-                                gpointer data);
-
-void            cb_kill_sigcont(GtkAction *action,
-                                gpointer data);
-
 gboolean        cb_column_header_clicked (GtkTreeViewColumn* column, 
                                           GdkEvent* event, 
                                           gpointer data);
diff --git a/src/gsm.gresource.xml b/src/gsm.gresource.xml
index 3a82705..d6b4a8d 100644
--- a/src/gsm.gresource.xml
+++ b/src/gsm.gresource.xml
@@ -7,7 +7,6 @@
     <file preprocess="xml-stripblanks">data/preferences.ui</file>
     <file preprocess="xml-stripblanks">data/renice.ui</file>
     <file preprocess="xml-stripblanks">data/menus.ui</file>
-    <file preprocess="xml-stripblanks">data/popups.ui</file>
     <file preprocess="xml-stripblanks">pixmaps/download.svg</file>
     <file preprocess="xml-stripblanks">pixmaps/upload.svg</file>
   </gresource>
diff --git a/src/interface.cpp b/src/interface.cpp
index f6be564..e55e63a 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -34,57 +34,21 @@
 #include "interface.h"
 #include "proctable.h"
 #include "procactions.h"
+#include "procdialogs.h"
+#include "memmaps.h"
+#include "openfiles.h"
+#include "procproperties.h"
 #include "load-graph.h"
 #include "util.h"
 #include "disks.h"
 #include "gsm_color_button.h"
 
-static const GtkActionEntry menu_entries[] =
-{
-    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
-      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
-    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
-      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
-
-    { "EndProcess", NULL, N_("_End Process"), "<control>E",
-      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
-    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
-      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
-    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
-      N_("Change the order of priority of process"), NULL },
-
-    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
-      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
-    // Translators: this means 'Files that are open' (open is no verb here)
-    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
-      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
-    { "ProcessProperties", NULL, N_("_Properties"), NULL,
-      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
-};
-
-static const GtkRadioActionEntry priority_menu_entries[] =
-{
-    { "VeryHigh", NULL, N_("Very High"), NULL,
-      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
-    { "High", NULL, N_("High"), NULL,
-      N_("Set process priority to high"), HIGH_PRIORITY },
-    { "Normal", NULL, N_("Normal"), NULL,
-      N_("Set process priority to normal"), NORMAL_PRIORITY },
-    { "Low", NULL, N_("Low"), NULL,
-      N_("Set process priority to low"), LOW_PRIORITY },
-    { "VeryLow", NULL, N_("Very Low"), NULL,
-      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
-    { "Custom", NULL, N_("Custom"), NULL,
-      N_("Set process priority manually"), CUSTOM_PRIORITY }
-};
 
 static void 
 create_proc_view(ProcmanApp *app, GtkBuilder * builder)
 {
     GtkWidget *proctree;
     GtkWidget *scrolled;
-    GtkWidget *viewmenu;
-    GtkAction *action;
     char* string;
 
     /* create the processes tab */
@@ -98,12 +62,10 @@ create_proc_view(ProcmanApp *app, GtkBuilder * builder)
 
     gtk_container_add (GTK_CONTAINER (scrolled), proctree);
 
-    app->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
-    g_signal_connect (G_OBJECT (app->endprocessbutton), "clicked",
-                      G_CALLBACK (cb_end_process_button_pressed), app);
-
     /* create popup_menu for the processes tab */
-    app->popup_menu = gtk_ui_manager_get_widget (app->uimanager, "/PopupMenu");
+    GMenuModel *menu_model = G_MENU_MODEL (gtk_builder_get_object (builder, "process-popup-menu"));
+    app->popup_menu = gtk_menu_new_from_model (menu_model);
+    gtk_menu_attach_to_widget (GTK_MENU (app->popup_menu), app->main_window, NULL);
 }
 
 static void
@@ -279,6 +241,73 @@ on_activate_refresh (GSimpleAction *, GVariant *, gpointer data)
     proctable_update_all (app);
 }
 
+static void
+kill_process_with_confirmation (ProcmanApp *app, int signal) {
+    gboolean kill_dialog = g_settings_get_boolean (app->settings, "kill-dialog");
+
+    if (kill_dialog)
+        procdialog_create_kill_dialog (app, signal);
+    else
+        kill_process (app, signal);
+}
+
+static void
+on_activate_send_signal_stop (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    /* no confirmation */
+    kill_process (app, SIGSTOP);
+}
+
+static void
+on_activate_send_signal_cont (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    /* no confirmation */
+    kill_process (app, SIGCONT);
+}
+
+static void
+on_activate_send_signal_end (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    kill_process_with_confirmation (app, SIGTERM);
+}
+
+static void
+on_activate_send_signal_kill (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    kill_process_with_confirmation (app, SIGKILL);
+}
+
+static void
+on_activate_memory_maps (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    create_memmaps_dialog (app);
+}
+
+static void
+on_activate_open_files (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    create_openfiles_dialog (app);
+}
+
+static void
+on_activate_process_properties (GSimpleAction *, GVariant *, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    create_procproperties_dialog (app);
+}
 
 static void
 on_activate_radio (GSimpleAction *action, GVariant *parameter, gpointer data)
@@ -321,6 +350,42 @@ change_show_dependencies_state (GSimpleAction *action, GVariant *state, gpointer
     g_settings_set_value (app->settings, "show-dependencies", state);
 }
 
+static void
+on_activate_priority (GSimpleAction *action, GVariant *parameter, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) 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);
+    }
+}
+
+static void
+change_priority_state (GSimpleAction *action, GVariant *state, gpointer data)
+{
+    g_simple_action_set_state (action, state);
+}
+
 void
 update_page_activities (ProcmanApp *app)
 {
@@ -381,7 +446,6 @@ cb_change_current_page (GtkNotebook *notebook, GParamSpec *pspec, gpointer data)
 void
 create_main_window (ProcmanApp *app)
 {
-    gint i;
     gint width, height, xpos, ypos;
     GtkWidget *main_window;
     GtkWidget *notebook;
@@ -396,6 +460,14 @@ create_main_window (ProcmanApp *app)
 
     GActionEntry win_action_entries[] = {
         { "about", on_activate_about, NULL, NULL, NULL },
+        { "send-signal-stop", on_activate_send_signal_stop, NULL, NULL, NULL },
+        { "send-signal-cont", on_activate_send_signal_cont, NULL, NULL, NULL },
+        { "send-signal-end", on_activate_send_signal_end, NULL, NULL, NULL },
+        { "send-signal-kill", on_activate_send_signal_kill, NULL, NULL, NULL },
+        { "priority", on_activate_priority, "s", "'normal'", 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 },
         { "refresh", on_activate_refresh, NULL, NULL, NULL },
         { "show-page", on_activate_radio, "i", "0", change_show_page_state },
         { "show-whose-processes", on_activate_radio, "s", "'all'", change_show_processes_state },
@@ -424,35 +496,6 @@ create_main_window (ProcmanApp *app)
         gtk_window_maximize(GTK_WINDOW(main_window));
     }
 
-    app->uimanager = gtk_ui_manager_new ();
-
-    gtk_window_add_accel_group (GTK_WINDOW (main_window),
-                                gtk_ui_manager_get_accel_group (app->uimanager));
-
-    if (!gtk_ui_manager_add_ui_from_resource (app->uimanager,
-                                              "/org/gnome/gnome-system-monitor/data/popups.ui",
-                                              NULL)) {
-        g_error("building menus failed");
-    }
-
-    app->action_group = gtk_action_group_new ("ProcmanActions");
-    gtk_action_group_set_translation_domain (app->action_group, NULL);
-    gtk_action_group_add_actions (app->action_group,
-                                  menu_entries,
-                                  G_N_ELEMENTS (menu_entries),
-                                  app);
-
-    gtk_action_group_add_radio_actions (app->action_group,
-                                        priority_menu_entries,
-                                        G_N_ELEMENTS (priority_menu_entries),
-                                        NORMAL_PRIORITY,
-                                        G_CALLBACK(cb_renice),
-                                        app);
-
-    gtk_ui_manager_insert_action_group (app->uimanager,
-                                        app->action_group,
-                                        0);
-
     /* create the main notebook */
     app->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
 
@@ -484,8 +527,6 @@ create_main_window (ProcmanApp *app)
     g_action_change_state (action,
                            g_settings_get_value (app->settings, "show-whose-processes"));
 
-    gtk_builder_connect_signals (builder, NULL);
-
     gtk_widget_show_all(main_window);
 
     g_object_unref (G_OBJECT (builder));
@@ -513,14 +554,14 @@ do_popup_menu (ProcmanApp *app, GdkEventButton *event)
 void
 update_sensitivity(ProcmanApp *app)
 {
-    const char * const selected_actions[] = { "StopProcess",
-                                              "ContProcess",
-                                              "EndProcess",
-                                              "KillProcess",
-                                              "ChangePriority",
-                                              "MemoryMaps",
-                                              "OpenFiles",
-                                              "ProcessProperties" };
+    const char * const selected_actions[] = { "send-signal-stop",
+                                              "send-signal-cont",
+                                              "send-signal-end",
+                                              "send-signal-kill",
+                                              "priority",
+                                              "memory-maps",
+                                              "open-files",
+                                              "process-properties" };
 
     const char * const processes_actions[] = { "refresh",
                                                "show-whose-processes",
@@ -528,46 +569,20 @@ update_sensitivity(ProcmanApp *app)
 
     size_t i;
     gboolean processes_sensitivity, selected_sensitivity;
-    GtkAction *action;
-    GAction *gaction;
+    GAction *action;
 
     processes_sensitivity = (g_settings_get_int (app->settings, "current-tab") == PROCMAN_TAB_PROCESSES);
     selected_sensitivity = (processes_sensitivity && app->selected_process != NULL);
 
-    if(app->endprocessbutton) {
-        /* avoid error on startup if endprocessbutton
-           has not been built yet */
-        gtk_widget_set_sensitive(app->endprocessbutton, selected_sensitivity);
-    }
-
     for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
-        gaction = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
+        action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
                                               processes_actions[i]);
-        g_simple_action_set_enabled (G_SIMPLE_ACTION (gaction), processes_sensitivity);
+        g_simple_action_set_enabled (G_SIMPLE_ACTION (action), processes_sensitivity);
     }
 
     for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
-        action = gtk_action_group_get_action(app->action_group,
+        action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
                                              selected_actions[i]);
-        gtk_action_set_sensitive(action, selected_sensitivity);
-    }
-}
-
-void
-block_priority_changed_handlers(ProcmanApp *app, bool block)
-{
-    gint i;
-    if (block) {
-        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
-            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(app->action_group,
-                                             priority_menu_entries[i].name));
-            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, app);
-        }
-    } else {
-        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
-            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(app->action_group,
-                                             priority_menu_entries[i].name));
-            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, app);
-        }
+        g_simple_action_set_enabled (G_SIMPLE_ACTION (action), selected_sensitivity);
     }
 }
diff --git a/src/interface.h b/src/interface.h
index 6c08231..675b7fe 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -26,7 +26,6 @@
 
 void            create_main_window (ProcmanApp *app);
 void            update_sensitivity (ProcmanApp *app);
-void            block_priority_changed_handlers(ProcmanApp *app, bool block);
 void            do_popup_menu(ProcmanApp *app, GdkEventButton *event);
 
 #endif /* _PROCMAN_INTERFACE_H_ */
diff --git a/src/procman-app.cpp b/src/procman-app.cpp
index a6d58fe..d18239d 100644
--- a/src/procman-app.cpp
+++ b/src/procman-app.cpp
@@ -87,16 +87,6 @@ cb_show_whose_processes_changed (GSettings *settings, const gchar *key, gpointer
 }
 
 static void
-warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
-{
-    ProcmanApp *app = static_cast<ProcmanApp *>(data);
-
-    if (g_str_equal (key, "kill-dialog")) {
-        app->config.show_kill_warning = g_settings_get_boolean (settings, key);
-    }
-}
-
-static void
 timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
 {
     ProcmanApp *app = static_cast<ProcmanApp *>(data);
@@ -266,8 +256,6 @@ ProcmanApp::load_settings()
     detail_string = "changed::" + procman::settings::network_in_bits;
     g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), 
this);
 
-    config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
-    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), this);
     config.update_interval = g_settings_get_int (settings, "update-interval");
     g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), this);
     config.graph_update_interval = g_settings_get_int (settings,
diff --git a/src/procman-app.h b/src/procman-app.h
index 6aea147..3d178bf 100644
--- a/src/procman-app.h
+++ b/src/procman-app.h
@@ -12,16 +12,6 @@ struct LoadGraph;
 
 #define GSM_GSETTINGS_SCHEMA "org.gnome.gnome-system-monitor"
 
-enum
-{
-    VERY_HIGH_PRIORITY,
-    HIGH_PRIORITY,
-    NORMAL_PRIORITY,
-    LOW_PRIORITY,
-    VERY_LOW_PRIORITY,
-    CUSTOM_PRIORITY
-};
-
 static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
 static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
 
@@ -41,7 +31,6 @@ struct ProcConfig
     gint            xpos;
     gint            ypos;
     gboolean        maximized;
-    gboolean        show_kill_warning;
     gboolean        show_all_fs;
     int             update_interval;
     int             graph_update_interval;
@@ -174,11 +163,8 @@ public:
     void save_config();
     void shutdown();
 
-    GtkUIManager     *uimanager;
-    GtkActionGroup   *action_group;
     GtkWidget        *tree;
     GtkWidget        *loadavg;
-    GtkWidget        *endprocessbutton;
     GtkWidget        *popup_menu;
     GtkWidget        *disk_list;
     GtkWidget        *notebook;
@@ -201,7 +187,6 @@ public:
 
     GSettings        *settings;
     GtkWidget        *main_window;
-    GtkUIManager     *menu;
 
     unsigned         frequency;
 
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 9587c53..d01ef10 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -189,6 +189,29 @@ cb_proctree_destroying (GtkTreeView *self, gpointer data)
     g_signal_handlers_disconnect_by_func(self, (gpointer) cb_columns_changed, data);
 }
 
+static gboolean
+cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    if (gdk_event_triggers_context_menu ((GdkEvent *) event)) {
+        do_popup_menu (app, event);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static gboolean
+cb_tree_popup_menu (GtkWidget *widget, gpointer data)
+{
+    ProcmanApp *app = (ProcmanApp *) data;
+
+    do_popup_menu (app, NULL);
+
+    return TRUE;
+}
+
 GtkWidget *
 proctable_new (ProcmanApp * const app)
 {
@@ -973,7 +996,8 @@ proctable_update_list (ProcmanApp *app)
     pid_t* pid_list;
     glibtop_proclist proclist;
     glibtop_cpu cpu;
-    gint which, arg;
+    int which = 0;
+    int arg = 0;
 
     const char* whose_processes = g_settings_get_string (app->settings, "show-whose-processes");
     if (strcmp (whose_processes, "all") == 0) {


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