diff --git a/g-s-m-polkit-3.patch b/gnome-system-monitor-2.21.5-polkit.patch similarity index 90% rename from g-s-m-polkit-3.patch rename to gnome-system-monitor-2.21.5-polkit.patch index fd0ce70..93daf8a 100644 --- a/g-s-m-polkit-3.patch +++ b/gnome-system-monitor-2.21.5-polkit.patch @@ -1,8 +1,18 @@ -Index: configure.in -=================================================================== ---- configure.in (revision 2210) -+++ configure.in (working copy) -@@ -33,10 +33,41 @@ +diff -up gnome-system-monitor-2.21.5/po/POTFILES.in.polkit gnome-system-monitor-2.21.5/po/POTFILES.in +--- gnome-system-monitor-2.21.5/po/POTFILES.in.polkit 2008-01-14 13:31:35.000000000 -0500 ++++ gnome-system-monitor-2.21.5/po/POTFILES.in 2008-01-14 19:44:43.000000000 -0500 +@@ -6,6 +6,7 @@ src/callbacks.cpp + src/defaulttable.h + src/disks.cpp + src/e_date.c ++src/gnome-system-monitor.policy.in + src/gnome-system-monitor.schemas.in + src/gsm_color_button.c + src/interface.cpp +diff -up gnome-system-monitor-2.21.5/configure.in.polkit gnome-system-monitor-2.21.5/configure.in +--- gnome-system-monitor-2.21.5/configure.in.polkit 2007-12-25 14:48:49.000000000 -0500 ++++ gnome-system-monitor-2.21.5/configure.in 2008-01-14 20:25:51.000000000 -0500 +@@ -33,10 +33,41 @@ GNOME_ICON_THEME_REQUIRED=2.15.3 PCRECPP_REQUIRED=6.4 GTKMM_REQUIRED=2.8 LIBXML_REQUIRED=2.0 @@ -10,8 +20,9 @@ Index: configure.in +POLKIT_DBUS_REQUIRED=0.7 +DBUS_GLIB_REQUIRED=0.71 +DBUS_REQUIRED=1.1.2 + RSVG_REQUIRED=2.12 - PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED) + PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED) +# PolicyKit detection; defaults to 'auto' (use it if it's available) +# @@ -25,7 +36,7 @@ Index: configure.in +else + HAVE_POLKIT=no + PKG_CHECK_MODULES(POLKIT_GNOME, polkit-gnome >= $POLKIT_GNOME_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, HAVE_POLKIT=no) - ++ + if test "x$enable_polkit" = "xyes" -a "x$HAVE_POLKIT" = "xno" ; then + AC_MSG_ERROR(PolicyKit support explicity enabled but not available) + fi @@ -40,11 +51,10 @@ Index: configure.in +AC_SUBST(POLKIT_GNOME_LIBS) +AC_SUBST(POLKIT_DBUS_CFLAGS) +AC_SUBST(POLKIT_DBUS_LIBS) -+ + AC_ARG_ENABLE([pcrecpp], AS_HELP_STRING([--enable-pcrecpp], [Enable pcrecpp. You really want this ! (but default: disabled)]), [enable_pcrecpp=$enableval], [enable_pcrecpp=no]) - if test "x$enable_pcrecpp" = "xyes" ; then -@@ -113,6 +144,7 @@ +@@ -114,6 +145,7 @@ Configuration: CFLAGS: ${CFLAGS} CXXFLAGS: ${CXXFLAGS} pcrecpp: ${enable_pcrecpp} @@ -52,616 +62,10 @@ Index: configure.in Maintainer mode: ${USER_MAINTAINER_MODE} Languages: ${ALL_LINGUAS} " -Index: src/procman.h -=================================================================== ---- src/procman.h (revision 2210) -+++ src/procman.h (working copy) -@@ -32,6 +32,11 @@ - - #include - -+#ifdef HAVE_POLKIT -+# include -+# include -+#endif -+ - typedef struct _ProcConfig ProcConfig; - struct ProcInfo; - struct ProcData; -@@ -197,7 +202,19 @@ - GtkWidget *app; - GtkUIManager *menu; - -+#ifdef HAVE_POLKIT -+ DBusGProxy *mechanism_proxy; - -+ PolKitAction *pk_action_kill; -+ PolKitAction *pk_action_change_priority; -+ PolKitAction *pk_action_increase_own_priority; -+ -+ PolKitGnomeAction *sigstop_action; -+ PolKitGnomeAction *sigcont_action; -+ PolKitGnomeAction *sigterm_action; -+ PolKitGnomeAction *sigkill_action; -+#endif -+ - /* cached username */ - GStringChunk *users; - -Index: src/procman.cpp -=================================================================== ---- src/procman.cpp (revision 2210) -+++ src/procman.cpp (working copy) -@@ -33,6 +33,10 @@ - #include - #include - -+#ifdef HAVE_POLKIT -+# include -+#endif -+ - #include "load-graph.h" - #include "procman.h" - #include "interface.h" -@@ -55,9 +59,36 @@ - disk_timeout(0), - cpu_total_time(1), - cpu_total_time_last(1) --{ } -+{ -+#ifdef HAVE_POLKIT -+ GError *error; -+ DBusGConnection *bus; - -+ error = NULL; -+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -+ if (bus == NULL) { -+ g_warning ("Couldn't connect to system bus: %s", error->message); -+ g_error_free (error); -+ this->mechanism_proxy = NULL; -+ } else { -+ this->mechanism_proxy = dbus_g_proxy_new_for_name (bus, -+ "org.gnome.SystemMonitor.Mechanism", -+ "/", -+ "org.gnome.SystemMonitor.Mechanism"); -+ } - -+ this->pk_action_kill = polkit_action_new (); -+ polkit_action_set_action_id (this->pk_action_kill, "org.gnome.system-monitor.kill"); -+ -+ this->pk_action_change_priority = polkit_action_new (); -+ polkit_action_set_action_id (this->pk_action_change_priority, "org.gnome.system-monitor.change-priority"); -+ -+ this->pk_action_increase_own_priority = polkit_action_new (); -+ polkit_action_set_action_id (this->pk_action_increase_own_priority, "org.gnome.system-monitor.increase-own-priority"); -+#endif -+} -+ -+ - ProcData* ProcData::get_instance() - { - static ProcData instance; -Index: src/interface.cpp -=================================================================== ---- src/interface.cpp (revision 2210) -+++ src/interface.cpp (working copy) -@@ -30,6 +30,10 @@ - #include - #include - -+#ifdef HAVE_POLKIT -+# include -+#endif -+ - #include "procman.h" - #include "callbacks.h" - #include "interface.h" -@@ -57,6 +61,7 @@ - N_("Quit the program"), G_CALLBACK (cb_app_exit) }, - - -+#ifndef HAVE_POLKIT - { "StopProcess", NULL, N_("_Stop Process"), "S", - N_("Stop process"), G_CALLBACK(cb_kill_sigstop) }, - { "ContProcess", NULL, N_("_Continue Process"), "C", -@@ -66,6 +71,7 @@ - N_("Force process to finish normally"), G_CALLBACK (cb_end_process) }, - { "KillProcess", NULL, N_("_Kill Process"), "K", - N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) }, -+#endif - { "ChangePriority", NULL, N_("_Change Priority..."), "R", - N_("Change the order of priority of process"), G_CALLBACK (cb_renice) }, - { "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, -@@ -180,10 +186,14 @@ - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0); - -+#ifdef HAVE_POLKIT -+ procdata->endprocessbutton = polkit_gnome_action_create_button (procdata->sigterm_action); -+#else - procdata->endprocessbutton = gtk_button_new_with_mnemonic (_("End _Process")); -- gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked", - G_CALLBACK (cb_end_process_button_pressed), procdata); -+#endif -+ gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0); - - - /* create popup_menu */ -@@ -704,6 +714,45 @@ - G_CALLBACK(cb_radio_processes), - procdata); - -+#ifdef HAVE_POLKIT -+ procdata->sigstop_action = polkit_gnome_action_new_default ("StopProcess", -+ NULL, -+ _("_Stop Process"), -+ _("Stop process")); -+ g_object_set (procdata->sigstop_action, "auth-label", _("_Stop Process..."), NULL); -+ g_signal_connect (procdata->sigstop_action, "activate", G_CALLBACK (cb_kill_sigstop), procdata); -+ gtk_action_group_add_action_with_accel (procdata->action_group, -+ GTK_ACTION (procdata->sigstop_action), -+ "S"); -+ -+ procdata->sigcont_action = polkit_gnome_action_new_default ("ContProcess", -+ NULL, -+ _("_Continue Process"), -+ _("Continue process")); -+ g_object_set (procdata->sigcont_action, "auth-label", _("_Continue Process..."), NULL); -+ g_signal_connect (procdata->sigcont_action, "activate", G_CALLBACK (cb_kill_sigcont), procdata); -+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigcont_action), -+ "C"); -+ -+ procdata->sigterm_action = polkit_gnome_action_new_default ("EndProcess", -+ NULL, -+ _("End _Process"), -+ _("Force process to finish normally")); -+ g_object_set (procdata->sigterm_action, "auth-label", _("End _Process..."), NULL); -+ g_signal_connect (procdata->sigterm_action, "activate", G_CALLBACK (cb_end_process), procdata); -+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigterm_action), -+ "E"); -+ -+ procdata->sigkill_action = polkit_gnome_action_new_default ("KillProcess", -+ NULL, -+ _("_Kill Process"), -+ _("Force process to finish immediately")); -+ g_object_set (procdata->sigkill_action, "auth-label", _("_Kill Process..."), NULL); -+ g_signal_connect (procdata->sigkill_action, "activate", G_CALLBACK (cb_kill_process), procdata); -+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigkill_action), -+ "K"); -+#endif -+ - gtk_ui_manager_insert_action_group (procdata->uimanager, - procdata->action_group, - 0); -@@ -711,7 +760,6 @@ - menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar"); - gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0); - -- - /* create the main notebook */ - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (main_box), -@@ -807,23 +855,53 @@ - processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES); - selected_sensitivity = (processes_sensitivity && data->selected_process != NULL); - -+#ifndef HAVE_POLKIT - if(data->endprocessbutton) { - /* avoid error on startup if endprocessbutton - has not been built yet */ - gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity); - } -+#endif - - for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) { - action = gtk_action_group_get_action(data->action_group, - processes_actions[i]); -- gtk_action_set_sensitive(action, processes_sensitivity); -+ gtk_action_set_sensitive(action, selected_sensitivity); - } - - for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) { - action = gtk_action_group_get_action(data->action_group, - selected_actions[i]); -- gtk_action_set_sensitive(action, selected_sensitivity); -+#ifdef HAVE_POLKIT -+ if (POLKIT_GNOME_IS_ACTION (action)) { -+ polkit_gnome_action_set_sensitive (POLKIT_GNOME_ACTION (action), processes_sensitivity); -+ } else { -+ gtk_action_set_sensitive(action, processes_sensitivity); -+ } -+#else -+ gtk_action_set_sensitive(action, processes_sensitivity); -+#endif - } -+ -+#ifdef HAVE_POLKIT -+ /* update the PolicyKit actions */ -+ if (data->selected_process != NULL) { -+ ProcInfo *pi = data->selected_process; -+ PolKitAction *pk_action; -+ -+ /* TODO: multiple processes may be selected; consider all of them */ -+ -+ if (pi->uid == getuid ()) { -+ pk_action = NULL; -+ } else { -+ pk_action = data->pk_action_kill; -+ } -+ g_object_set (data->sigstop_action, "polkit-action", pk_action, NULL); -+ g_object_set (data->sigcont_action, "polkit-action", pk_action, NULL); -+ g_object_set (data->sigterm_action, "polkit-action", pk_action, NULL); -+ g_object_set (data->sigkill_action, "polkit-action", pk_action, NULL); -+ } -+#endif - } - - static void -Index: src/procdialogs.cpp -=================================================================== ---- src/procdialogs.cpp (revision 2210) -+++ src/procdialogs.cpp (working copy) -@@ -35,6 +35,11 @@ - #include "procman_gnomesu.h" - #include "procman_gksu.h" - -+#ifdef HAVE_POLKIT -+# include "gnome-system-monitor-mechanism-client-glue.h" -+# include -+#endif -+ - static GtkWidget *renice_dialog = NULL; - static GtkWidget *prefs_dialog = NULL; - static gint new_nice_value = 0; -@@ -121,29 +126,89 @@ - return _("(Very Low Priority)"); - } - -+typedef struct { -+ GtkWidget *priority_label; -+ ProcData *procdata; -+#ifdef HAVE_POLKIT -+ PolKitGnomeAction *renice_action; -+#endif -+} ReniceClosure; -+ -+#ifdef HAVE_POLKIT - static void -+_renice_compute_polkit_action (ReniceClosure *rc) -+{ -+ if (rc->procdata->selected_process != NULL) { -+ ProcInfo *pi = rc->procdata->selected_process; -+ -+ if (pi->uid == getuid ()) { -+ if (new_nice_value < pi->nice) { -+ GValue v; -+ GValueArray *va; -+ -+ g_warning ("foo"); -+ -+ memset (&v, 0, sizeof (GValue)); -+ g_value_init (&v, G_TYPE_POINTER); -+ g_value_set_pointer (&v, rc->procdata->pk_action_change_priority); -+ va = g_value_array_new (1); -+ g_value_array_prepend (va, &v); -+ -+ g_object_set (rc->renice_action, -+ "polkit-action", -+ rc->procdata->pk_action_increase_own_priority, -+ "polkit-action-sufficient", -+ va, -+ NULL); -+ -+ g_value_array_free (va); -+ goto out; -+ } -+ } else { -+ g_object_set (rc->renice_action, -+ "polkit-action", -+ rc->procdata->pk_action_change_priority, NULL); -+ goto out; -+ } -+ } -+ -+ g_object_set (rc->renice_action, "polkit-action", NULL, NULL); -+ -+out: -+ ; -+} -+#endif -+ -+static void - renice_scale_changed (GtkAdjustment *adj, gpointer data) - { -- GtkWidget *label = GTK_WIDGET (data); -- -+ ReniceClosure *rc = (ReniceClosure *) data; -+ - new_nice_value = int(adj->value); -- gtk_label_set_text (GTK_LABEL (label), get_nice_level (new_nice_value)); -- -+ gtk_label_set_text (GTK_LABEL (rc->priority_label), get_nice_level (new_nice_value)); -+#ifdef HAVE_POLKIT -+ _renice_compute_polkit_action (rc); -+#endif - } - - static void - renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data) - { -- ProcData *procdata = static_cast(data); -- -+ ReniceClosure *rc = (ReniceClosure *) data; -+ - if (id == 100) { - if (new_nice_value == -100) - return; -- renice(procdata, new_nice_value); -+ renice (rc->procdata, new_nice_value); - } - - gtk_widget_destroy (GTK_WIDGET (dialog)); - renice_dialog = NULL; -+ -+#ifdef HAVE_POLKIT -+ g_object_unref (G_OBJECT (rc->renice_action)); -+#endif -+ g_free (rc); - } - - void -@@ -153,22 +218,28 @@ - GtkWidget *dialog = NULL; - GtkWidget *dialog_vbox; - GtkWidget *vbox; -- GtkWidget *hbox; - GtkWidget *label; - GtkWidget *priority_label; - GtkWidget *table; - GtkObject *renice_adj; - GtkWidget *hscale; - GtkWidget *button; -+#ifndef HAVE_POLKIT -+ GtkWidget *hbox; - GtkWidget *align; - GtkWidget *icon; -+#endif - gchar *text; -+ ReniceClosure *rc; - - if (renice_dialog) - return; - - if (!info) - return; -+ -+ rc = g_new0 (ReniceClosure, 1); -+ rc->procdata = procdata; - - dialog = gtk_dialog_new_with_buttons (_("Change Priority"), NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, -@@ -178,7 +249,20 @@ - gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE); - gtk_dialog_set_has_separator (GTK_DIALOG (renice_dialog), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5); -- -+ -+#ifdef HAVE_POLKIT -+ rc->renice_action = polkit_gnome_action_new_default ("ReniceProcessButton", -+ NULL, -+ _("Change _Priority"), -+ NULL); -+ g_object_set (rc->renice_action, -+ "auth-label", _("Change _Priority..."), -+ "yes-icon-name", GTK_STOCK_OK, -+ NULL); -+ -+ button = polkit_gnome_action_create_button (rc->renice_action); -+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); -+#else - button = gtk_button_new (); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - -@@ -195,7 +279,9 @@ - gtk_label_set_mnemonic_widget (GTK_LABEL (label), button); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - -+#endif - gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100); -+ - gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100); - new_nice_value = -100; - -@@ -236,15 +322,17 @@ - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - g_free (text); -+ -+ rc->priority_label = priority_label; -+ new_nice_value = info->nice; -+ _renice_compute_polkit_action (rc); - - g_signal_connect (G_OBJECT (dialog), "response", -- G_CALLBACK (renice_dialog_button_pressed), procdata); -+ G_CALLBACK (renice_dialog_button_pressed), rc); - g_signal_connect (G_OBJECT (renice_adj), "value_changed", -- G_CALLBACK (renice_scale_changed), priority_label); -+ G_CALLBACK (renice_scale_changed), rc); - - gtk_widget_show_all (dialog); -- -- - } - - static void -Index: src/callbacks.cpp -=================================================================== ---- src/callbacks.cpp (revision 2210) -+++ src/callbacks.cpp (working copy) -@@ -36,25 +36,21 @@ - #include "disks.h" - #include "lsof.h" - -- - void - cb_kill_sigstop(GtkAction *action, gpointer data) - { - ProcData * const procdata = static_cast(data); - -- /* no confirmation */ -+ /* no confirmation */ - kill_process (procdata, SIGSTOP); - } - -- -- -- - void - cb_kill_sigcont(GtkAction *action, gpointer data) - { - ProcData * const procdata = static_cast(data); - -- /* no confirmation */ -+ /* no confirmation */ - kill_process (procdata, SIGCONT); - } - -@@ -208,11 +204,13 @@ - - - -+#ifndef HAVE_POLKIT - void - cb_end_process_button_pressed (GtkButton *button, gpointer data) - { - kill_process_helper(static_cast(data), SIGTERM); - } -+#endif - - - static void change_gconf_color(GConfClient *client, const char *key, -Index: src/procactions.cpp -=================================================================== ---- src/procactions.cpp (revision 2210) -+++ src/procactions.cpp (working copy) -@@ -31,6 +31,10 @@ - #include "procdialogs.h" - #include "callbacks.h" - -+#ifdef HAVE_POLKIT -+# include "gnome-system-monitor-mechanism-client-glue.h" -+# include -+#endif - - static void - renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) -@@ -48,6 +52,10 @@ - if (!info) - return; - -+ /* docs for getpriority suggest clearing errno before the call -+ * since -1 is a legitimate return value */ -+ errno = 0; -+ - error = setpriority (PRIO_PROCESS, info->pid, args->nice_value); - - /* success */ -@@ -55,6 +63,28 @@ - - saved_errno = errno; - -+#ifdef HAVE_POLKIT -+ /* need to be root */ -+ if (errno == EPERM || errno == EACCES) { -+ GError *error = NULL; -+ -+ if (!org_gnome_SystemMonitor_Mechanism_renice (args->procdata->mechanism_proxy, -+ info->pid, -+ args->nice_value, -+ &error)) { -+ /* TODO: Handle "require privileges" */ -+ error_msg = g_strdup_printf ( -+ _("Cannot renice process with pid %d to nice value %d: " -+ "%s"), -+ info->pid, args->nice_value, error->message); -+ g_error_free (error); -+ } else { -+ return; -+ } -+ } else { -+ return; -+ } -+#else - /* need to be root */ - if(errno == EPERM || errno == EACCES) { - gboolean success; -@@ -69,10 +99,11 @@ - saved_errno = errno; - } - } -+#endif - - /* failed */ - error_msg = g_strdup_printf ( -- _("Cannot change the priority of process with pid %d to %d.\n" -+ _("Cannot change the priority of process with pid %d to %d: " - "%s"), - info->pid, args->nice_value, g_strerror(saved_errno)); - -@@ -135,6 +166,28 @@ - - saved_errno = errno; - -+#ifdef HAVE_POLKIT -+ /* need to be root */ -+ if (errno == EPERM) { -+ GError *error = NULL; -+ -+ if (!org_gnome_SystemMonitor_Mechanism_kill (args->procdata->mechanism_proxy, -+ info->pid, -+ args->signal, -+ &error)) { -+ /* TODO: Handle "require privileges" */ -+ error_msg = g_strdup_printf ( -+ _("Cannot kill process with pid %d with signal %d.\n" -+ "%s"), -+ info->pid, args->signal, error->message); -+ g_error_free (error); -+ } else { -+ return; -+ } -+ } else { -+ return; -+ } -+#else - /* need to be root */ - if(errno == EPERM) { - gboolean success; -@@ -149,12 +202,12 @@ - saved_errno = errno; - } - } -- - /* failed */ - error_msg = g_strdup_printf ( - _("Cannot kill process with pid %d with signal %d.\n" - "%s"), - info->pid, args->signal, g_strerror(saved_errno)); -+#endif - - dialog = gtk_message_dialog_new ( - NULL, -@@ -188,3 +241,4 @@ - procdata); - proctable_update_all (procdata); - } -+ -Index: src/Makefile.am -=================================================================== ---- src/Makefile.am (revision 2210) -+++ src/Makefile.am (working copy) -@@ -5,7 +5,9 @@ +diff -up gnome-system-monitor-2.21.5/src/Makefile.am.polkit gnome-system-monitor-2.21.5/src/Makefile.am +--- gnome-system-monitor-2.21.5/src/Makefile.am.polkit 2007-12-28 07:51:43.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/Makefile.am 2008-01-14 19:44:43.000000000 -0500 +@@ -5,7 +5,9 @@ INCLUDES = \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -DDATADIR=\""$(datadir)"\" \ @PROCMAN_CFLAGS@ \ @@ -672,23 +76,21 @@ Index: src/Makefile.am bin_PROGRAMS = gnome-system-monitor -@@ -35,10 +37,14 @@ - iconthemewrapper.cpp iconthemewrapper.h \ - e_date.c e_date.h +@@ -36,8 +38,12 @@ gnome_system_monitor_SOURCES = \ + e_date.c e_date.h \ + gsm_color_button.c gsm_color_button.h +if HAVE_POLKIT +gnome_system_monitor_SOURCES += gnome-system-monitor-mechanism-client-glue.h +endif ++ -gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @PCRECPP_LIBS@ libbacon.la - +gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @PCRECPP_LIBS@ @POLKIT_GNOME_LIBS@ libbacon.la -+ + noinst_LTLIBRARIES = libbacon.la - libbacon_la_SOURCES = \ - bacon-message-connection.c \ -@@ -52,8 +58,44 @@ +@@ -53,8 +59,44 @@ schema_ins = gnome-system-monitor.schem schema_DATA = $(schema_ins:.schemas.in=.schemas) @INTLTOOL_SCHEMAS_RULE@ @@ -734,73 +136,9 @@ Index: src/Makefile.am CLEANFILES = \ $(schema_DATA) -Index: po/POTFILES.in -=================================================================== ---- po/POTFILES.in (revision 2210) -+++ po/POTFILES.in (working copy) -@@ -6,6 +6,7 @@ - src/defaulttable.h - src/disks.cpp - src/e_date.c -+src/gnome-system-monitor.policy.in - src/gnome-system-monitor.schemas.in - src/interface.cpp - src/load-graph.cpp ---- /dev/null 2007-12-21 05:01:42.582083906 -0500 -+++ src/org.gnome.system-monitor.policy.in 2007-12-04 20:59:31.000000000 -0500 -@@ -0,0 +1,50 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ The GNOME Project -+ http://online.gnome.org/application?id=gnome-system-monitor -+ utilities-system-monitor -+ -+ -+ <_description>Change priority of a process owned by another user -+ <_message>Changing the priority of a process owned by another user requires privileges -+ -+ no -+ auth_admin -+ -+ -+ -+ -+ <_description>Increase the priority of a processes -+ <_message>Increasing the priority of one of your own processes requires privileges -+ -+ no -+ auth_self_keep_always -+ -+ -+ -+ -+ <_description>Kill a process owned by another user -+ <_message>Killing a process owned by another user requires privileges -+ -+ no -+ auth_admin -+ -+ -+ -+ ---- /dev/null 2007-12-21 05:01:42.582083906 -0500 -+++ src/gnome-system-monitor-mechanism.c 2007-12-04 23:09:55.000000000 -0500 +diff -up /dev/null gnome-system-monitor-2.21.5/src/gnome-system-monitor-mechanism.c +--- /dev/null 2008-01-14 08:18:45.065255138 -0500 ++++ gnome-system-monitor-2.21.5/src/gnome-system-monitor-mechanism.c 2008-01-14 19:44:43.000000000 -0500 @@ -0,0 +1,640 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * @@ -1442,8 +780,9 @@ Index: po/POTFILES.in +out: + return ret; +} ---- /dev/null 2007-12-21 05:01:42.582083906 -0500 -+++ src/gnome-system-monitor-mechanism.xml 2007-10-21 12:32:38.000000000 -0400 +diff -up /dev/null gnome-system-monitor-2.21.5/src/gnome-system-monitor-mechanism.xml +--- /dev/null 2008-01-14 08:18:45.065255138 -0500 ++++ gnome-system-monitor-2.21.5/src/gnome-system-monitor-mechanism.xml 2008-01-14 19:44:43.000000000 -0500 @@ -0,0 +1,15 @@ + + @@ -1460,8 +799,315 @@ Index: po/POTFILES.in + + + ---- /dev/null 2007-12-21 05:01:42.582083906 -0500 -+++ src/org.gnome.SystemMonitor.Mechanism.conf 2007-10-30 19:45:18.000000000 -0400 +diff -up /dev/null gnome-system-monitor-2.21.5/src/org.gnome.SystemMonitor.Mechanism.service.in +--- /dev/null 2008-01-14 08:18:45.065255138 -0500 ++++ gnome-system-monitor-2.21.5/src/org.gnome.SystemMonitor.Mechanism.service.in 2008-01-14 19:44:43.000000000 -0500 +@@ -0,0 +1,4 @@ ++[D-BUS Service] ++Name=org.gnome.SystemMonitor.Mechanism ++Exec=libexecdir/gnome-system-monitor-mechanism ++User=root +diff -up /dev/null gnome-system-monitor-2.21.5/src/org.gnome.system-monitor.policy.in +--- /dev/null 2008-01-14 08:18:45.065255138 -0500 ++++ gnome-system-monitor-2.21.5/src/org.gnome.system-monitor.policy.in 2008-01-14 19:44:43.000000000 -0500 +@@ -0,0 +1,50 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ The GNOME Project ++ http://online.gnome.org/application?id=gnome-system-monitor ++ utilities-system-monitor ++ ++ ++ <_description>Change priority of a process owned by another user ++ <_message>Changing the priority of a process owned by another user requires privileges ++ ++ no ++ auth_admin ++ ++ ++ ++ ++ <_description>Increase the priority of a processes ++ <_message>Increasing the priority of one of your own processes requires privileges ++ ++ no ++ auth_self_keep_always ++ ++ ++ ++ ++ <_description>Kill a process owned by another user ++ <_message>Killing a process owned by another user requires privileges ++ ++ no ++ auth_admin ++ ++ ++ ++ +diff -up gnome-system-monitor-2.21.5/src/procactions.cpp.polkit gnome-system-monitor-2.21.5/src/procactions.cpp +--- gnome-system-monitor-2.21.5/src/procactions.cpp.polkit 2007-01-02 17:15:36.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/procactions.cpp 2008-01-14 19:44:43.000000000 -0500 +@@ -31,6 +31,10 @@ + #include "procdialogs.h" + #include "callbacks.h" + ++#ifdef HAVE_POLKIT ++# include "gnome-system-monitor-mechanism-client-glue.h" ++# include ++#endif + + static void + renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +@@ -48,6 +52,10 @@ renice_single_process (GtkTreeModel *mod + if (!info) + return; + ++ /* docs for getpriority suggest clearing errno before the call ++ * since -1 is a legitimate return value */ ++ errno = 0; ++ + error = setpriority (PRIO_PROCESS, info->pid, args->nice_value); + + /* success */ +@@ -55,6 +63,28 @@ renice_single_process (GtkTreeModel *mod + + saved_errno = errno; + ++#ifdef HAVE_POLKIT ++ /* need to be root */ ++ if (errno == EPERM || errno == EACCES) { ++ GError *error = NULL; ++ ++ if (!org_gnome_SystemMonitor_Mechanism_renice (args->procdata->mechanism_proxy, ++ info->pid, ++ args->nice_value, ++ &error)) { ++ /* TODO: Handle "require privileges" */ ++ error_msg = g_strdup_printf ( ++ _("Cannot renice process with pid %d to nice value %d: " ++ "%s"), ++ info->pid, args->nice_value, error->message); ++ g_error_free (error); ++ } else { ++ return; ++ } ++ } else { ++ return; ++ } ++#else + /* need to be root */ + if(errno == EPERM || errno == EACCES) { + gboolean success; +@@ -69,10 +99,11 @@ renice_single_process (GtkTreeModel *mod + saved_errno = errno; + } + } ++#endif + + /* failed */ + error_msg = g_strdup_printf ( +- _("Cannot change the priority of process with pid %d to %d.\n" ++ _("Cannot change the priority of process with pid %d to %d: " + "%s"), + info->pid, args->nice_value, g_strerror(saved_errno)); + +@@ -135,6 +166,28 @@ kill_single_process (GtkTreeModel *model + + saved_errno = errno; + ++#ifdef HAVE_POLKIT ++ /* need to be root */ ++ if (errno == EPERM) { ++ GError *error = NULL; ++ ++ if (!org_gnome_SystemMonitor_Mechanism_kill (args->procdata->mechanism_proxy, ++ info->pid, ++ args->signal, ++ &error)) { ++ /* TODO: Handle "require privileges" */ ++ error_msg = g_strdup_printf ( ++ _("Cannot kill process with pid %d with signal %d.\n" ++ "%s"), ++ info->pid, args->signal, error->message); ++ g_error_free (error); ++ } else { ++ return; ++ } ++ } else { ++ return; ++ } ++#else + /* need to be root */ + if(errno == EPERM) { + gboolean success; +@@ -149,12 +202,12 @@ kill_single_process (GtkTreeModel *model + saved_errno = errno; + } + } +- + /* failed */ + error_msg = g_strdup_printf ( + _("Cannot kill process with pid %d with signal %d.\n" + "%s"), + info->pid, args->signal, g_strerror(saved_errno)); ++#endif + + dialog = gtk_message_dialog_new ( + NULL, +@@ -188,3 +241,4 @@ kill_process (ProcData *procdata, int si + procdata); + proctable_update_all (procdata); + } ++ +diff -up gnome-system-monitor-2.21.5/src/callbacks.cpp.polkit gnome-system-monitor-2.21.5/src/callbacks.cpp +--- gnome-system-monitor-2.21.5/src/callbacks.cpp.polkit 2007-12-28 08:24:05.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/callbacks.cpp 2008-01-14 19:44:43.000000000 -0500 +@@ -36,25 +36,21 @@ + #include "disks.h" + #include "lsof.h" + +- + void + cb_kill_sigstop(GtkAction *action, gpointer data) + { + ProcData * const procdata = static_cast(data); + +- /* no confirmation */ ++ /* no confirmation */ + kill_process (procdata, SIGSTOP); + } + +- +- +- + void + cb_kill_sigcont(GtkAction *action, gpointer data) + { + ProcData * const procdata = static_cast(data); + +- /* no confirmation */ ++ /* no confirmation */ + kill_process (procdata, SIGCONT); + } + +@@ -208,11 +204,13 @@ cb_app_delete (GtkWidget *window, GdkEve + + + ++#ifndef HAVE_POLKIT + void + cb_end_process_button_pressed (GtkButton *button, gpointer data) + { + kill_process_helper(static_cast(data), SIGTERM); + } ++#endif + + + static void change_gconf_color(GConfClient *client, const char *key, +diff -up gnome-system-monitor-2.21.5/src/procman.cpp.polkit gnome-system-monitor-2.21.5/src/procman.cpp +--- gnome-system-monitor-2.21.5/src/procman.cpp.polkit 2007-12-25 14:48:49.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/procman.cpp 2008-01-14 19:44:43.000000000 -0500 +@@ -33,6 +33,10 @@ + #include + #include + ++#ifdef HAVE_POLKIT ++# include ++#endif ++ + #include "load-graph.h" + #include "procman.h" + #include "interface.h" +@@ -55,7 +59,34 @@ ProcData::ProcData() + disk_timeout(0), + cpu_total_time(1), + cpu_total_time_last(1) +-{ } ++{ ++#ifdef HAVE_POLKIT ++ GError *error; ++ DBusGConnection *bus; ++ ++ error = NULL; ++ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); ++ if (bus == NULL) { ++ g_warning ("Couldn't connect to system bus: %s", error->message); ++ g_error_free (error); ++ this->mechanism_proxy = NULL; ++ } else { ++ this->mechanism_proxy = dbus_g_proxy_new_for_name (bus, ++ "org.gnome.SystemMonitor.Mechanism", ++ "/", ++ "org.gnome.SystemMonitor.Mechanism"); ++ } ++ ++ this->pk_action_kill = polkit_action_new (); ++ polkit_action_set_action_id (this->pk_action_kill, "org.gnome.system-monitor.kill"); ++ ++ this->pk_action_change_priority = polkit_action_new (); ++ polkit_action_set_action_id (this->pk_action_change_priority, "org.gnome.system-monitor.change-priority"); ++ ++ this->pk_action_increase_own_priority = polkit_action_new (); ++ polkit_action_set_action_id (this->pk_action_increase_own_priority, "org.gnome.system-monitor.increase-own-priority"); ++#endif ++} + + + ProcData* ProcData::get_instance() +diff -up gnome-system-monitor-2.21.5/src/procman.h.polkit gnome-system-monitor-2.21.5/src/procman.h +--- gnome-system-monitor-2.21.5/src/procman.h.polkit 2008-01-12 11:18:29.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/procman.h 2008-01-14 19:44:43.000000000 -0500 +@@ -32,6 +32,11 @@ + + #include + ++#ifdef HAVE_POLKIT ++# include ++# include ++#endif ++ + typedef struct _ProcConfig ProcConfig; + struct ProcInfo; + struct ProcData; +@@ -198,6 +203,18 @@ struct ProcData + GtkWidget *app; + GtkUIManager *menu; + ++#ifdef HAVE_POLKIT ++ DBusGProxy *mechanism_proxy; ++ ++ PolKitAction *pk_action_kill; ++ PolKitAction *pk_action_change_priority; ++ PolKitAction *pk_action_increase_own_priority; ++ ++ PolKitGnomeAction *sigstop_action; ++ PolKitGnomeAction *sigcont_action; ++ PolKitGnomeAction *sigterm_action; ++ PolKitGnomeAction *sigkill_action; ++#endif + + /* cached username */ + GStringChunk *users; +diff -up /dev/null gnome-system-monitor-2.21.5/src/org.gnome.SystemMonitor.Mechanism.conf +--- /dev/null 2008-01-14 08:18:45.065255138 -0500 ++++ gnome-system-monitor-2.21.5/src/org.gnome.SystemMonitor.Mechanism.conf 2008-01-14 19:44:43.000000000 -0500 @@ -0,0 +1,11 @@ + + @@ -1474,10 +1120,355 @@ Index: po/POTFILES.in + + + ---- /dev/null 2007-12-21 05:01:42.582083906 -0500 -+++ src/org.gnome.SystemMonitor.Mechanism.service.in 2007-12-04 20:52:03.000000000 -0500 -@@ -0,0 +1,4 @@ -+[D-BUS Service] -+Name=org.gnome.SystemMonitor.Mechanism -+Exec=libexecdir/gnome-system-monitor-mechanism -+User=root +diff -up gnome-system-monitor-2.21.5/src/procdialogs.cpp.polkit gnome-system-monitor-2.21.5/src/procdialogs.cpp +--- gnome-system-monitor-2.21.5/src/procdialogs.cpp.polkit 2008-01-12 11:19:15.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/procdialogs.cpp 2008-01-14 19:44:43.000000000 -0500 +@@ -35,6 +35,11 @@ + #include "procman_gnomesu.h" + #include "procman_gksu.h" + ++#ifdef HAVE_POLKIT ++# include "gnome-system-monitor-mechanism-client-glue.h" ++# include ++#endif ++ + static GtkWidget *renice_dialog = NULL; + static GtkWidget *prefs_dialog = NULL; + static gint new_nice_value = 0; +@@ -121,29 +126,89 @@ get_nice_level (gint nice) + return _("(Very Low Priority)"); + } + ++typedef struct { ++ GtkWidget *priority_label; ++ ProcData *procdata; ++#ifdef HAVE_POLKIT ++ PolKitGnomeAction *renice_action; ++#endif ++} ReniceClosure; ++ ++#ifdef HAVE_POLKIT ++static void ++_renice_compute_polkit_action (ReniceClosure *rc) ++{ ++ if (rc->procdata->selected_process != NULL) { ++ ProcInfo *pi = rc->procdata->selected_process; ++ ++ if (pi->uid == getuid ()) { ++ if (new_nice_value < pi->nice) { ++ GValue v; ++ GValueArray *va; ++ ++ g_warning ("foo"); ++ ++ memset (&v, 0, sizeof (GValue)); ++ g_value_init (&v, G_TYPE_POINTER); ++ g_value_set_pointer (&v, rc->procdata->pk_action_change_priority); ++ va = g_value_array_new (1); ++ g_value_array_prepend (va, &v); ++ ++ g_object_set (rc->renice_action, ++ "polkit-action", ++ rc->procdata->pk_action_increase_own_priority, ++ "polkit-action-sufficient", ++ va, ++ NULL); ++ ++ g_value_array_free (va); ++ goto out; ++ } ++ } else { ++ g_object_set (rc->renice_action, ++ "polkit-action", ++ rc->procdata->pk_action_change_priority, NULL); ++ goto out; ++ } ++ } ++ ++ g_object_set (rc->renice_action, "polkit-action", NULL, NULL); ++ ++out: ++ ; ++} ++#endif ++ + static void + renice_scale_changed (GtkAdjustment *adj, gpointer data) + { +- GtkWidget *label = GTK_WIDGET (data); +- ++ ReniceClosure *rc = (ReniceClosure *) data; ++ + new_nice_value = int(adj->value); +- gtk_label_set_text (GTK_LABEL (label), get_nice_level (new_nice_value)); +- ++ gtk_label_set_text (GTK_LABEL (rc->priority_label), get_nice_level (new_nice_value)); ++#ifdef HAVE_POLKIT ++ _renice_compute_polkit_action (rc); ++#endif + } + + static void + renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data) + { +- ProcData *procdata = static_cast(data); +- ++ ReniceClosure *rc = (ReniceClosure *) data; ++ + if (id == 100) { + if (new_nice_value == -100) + return; +- renice(procdata, new_nice_value); ++ renice (rc->procdata, new_nice_value); + } + + gtk_widget_destroy (GTK_WIDGET (dialog)); + renice_dialog = NULL; ++ ++#ifdef HAVE_POLKIT ++ g_object_unref (G_OBJECT (rc->renice_action)); ++#endif ++ g_free (rc); + } + + void +@@ -153,22 +218,28 @@ procdialog_create_renice_dialog (ProcDat + GtkWidget *dialog = NULL; + GtkWidget *dialog_vbox; + GtkWidget *vbox; +- GtkWidget *hbox; + GtkWidget *label; + GtkWidget *priority_label; + GtkWidget *table; + GtkObject *renice_adj; + GtkWidget *hscale; + GtkWidget *button; ++#ifndef HAVE_POLKIT ++ GtkWidget *hbox; + GtkWidget *align; + GtkWidget *icon; ++#endif + gchar *text; ++ ReniceClosure *rc; + + if (renice_dialog) + return; + + if (!info) + return; ++ ++ rc = g_new0 (ReniceClosure, 1); ++ rc->procdata = procdata; + + dialog = gtk_dialog_new_with_buttons (_("Change Priority"), NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, +@@ -178,7 +249,20 @@ procdialog_create_renice_dialog (ProcDat + gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE); + gtk_dialog_set_has_separator (GTK_DIALOG (renice_dialog), FALSE); + gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5); +- ++ ++#ifdef HAVE_POLKIT ++ rc->renice_action = polkit_gnome_action_new_default ("ReniceProcessButton", ++ NULL, ++ _("Change _Priority"), ++ NULL); ++ g_object_set (rc->renice_action, ++ "auth-label", _("Change _Priority..."), ++ "yes-icon-name", GTK_STOCK_OK, ++ NULL); ++ ++ button = polkit_gnome_action_create_button (rc->renice_action); ++ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); ++#else + button = gtk_button_new (); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + +@@ -195,7 +279,9 @@ procdialog_create_renice_dialog (ProcDat + gtk_label_set_mnemonic_widget (GTK_LABEL (label), button); + gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); + ++#endif + gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100); ++ + gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100); + new_nice_value = -100; + +@@ -236,15 +322,17 @@ procdialog_create_renice_dialog (ProcDat + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + g_free (text); ++ ++ rc->priority_label = priority_label; ++ new_nice_value = info->nice; ++ _renice_compute_polkit_action (rc); + + g_signal_connect (G_OBJECT (dialog), "response", +- G_CALLBACK (renice_dialog_button_pressed), procdata); ++ G_CALLBACK (renice_dialog_button_pressed), rc); + g_signal_connect (G_OBJECT (renice_adj), "value_changed", +- G_CALLBACK (renice_scale_changed), priority_label); ++ G_CALLBACK (renice_scale_changed), rc); + + gtk_widget_show_all (dialog); +- +- + } + + static void +diff -up gnome-system-monitor-2.21.5/src/interface.cpp.polkit gnome-system-monitor-2.21.5/src/interface.cpp +--- gnome-system-monitor-2.21.5/src/interface.cpp.polkit 2008-01-12 11:19:55.000000000 -0500 ++++ gnome-system-monitor-2.21.5/src/interface.cpp 2008-01-14 20:26:44.000000000 -0500 +@@ -30,6 +30,10 @@ + #include + #include + ++#ifdef HAVE_POLKIT ++# include ++#endif ++ + #include "procman.h" + #include "callbacks.h" + #include "interface.h" +@@ -58,6 +62,7 @@ static const GtkActionEntry menu_entries + N_("Quit the program"), G_CALLBACK (cb_app_exit) }, + + ++#ifndef HAVE_POLKIT + { "StopProcess", NULL, N_("_Stop Process"), "S", + N_("Stop process"), G_CALLBACK(cb_kill_sigstop) }, + { "ContProcess", NULL, N_("_Continue Process"), "C", +@@ -67,6 +72,7 @@ static const GtkActionEntry menu_entries + N_("Force process to finish normally"), G_CALLBACK (cb_end_process) }, + { "KillProcess", NULL, N_("_Kill Process"), "K", + N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) }, ++#endif + { "ChangePriority", NULL, N_("_Change Priority..."), "N", + N_("Change the order of priority of process"), G_CALLBACK (cb_renice) }, + { "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, +@@ -186,10 +192,14 @@ create_proc_view (ProcData *procdata) + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0); + ++#ifdef HAVE_POLKIT ++ procdata->endprocessbutton = polkit_gnome_action_create_button (procdata->sigterm_action); ++#else + procdata->endprocessbutton = gtk_button_new_with_mnemonic (_("End _Process")); +- gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked", + G_CALLBACK (cb_end_process_button_pressed), procdata); ++#endif ++ gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0); + + + /* create popup_menu */ +@@ -678,6 +688,45 @@ create_main_window (ProcData *procdata) + G_CALLBACK(cb_radio_processes), + procdata); + ++#ifdef HAVE_POLKIT ++ procdata->sigstop_action = polkit_gnome_action_new_default ("StopProcess", ++ NULL, ++ _("_Stop Process"), ++ _("Stop process")); ++ g_object_set (procdata->sigstop_action, "auth-label", _("_Stop Process..."), NULL); ++ g_signal_connect (procdata->sigstop_action, "activate", G_CALLBACK (cb_kill_sigstop), procdata); ++ gtk_action_group_add_action_with_accel (procdata->action_group, ++ GTK_ACTION (procdata->sigstop_action), ++ "S"); ++ ++ procdata->sigcont_action = polkit_gnome_action_new_default ("ContProcess", ++ NULL, ++ _("_Continue Process"), ++ _("Continue process")); ++ g_object_set (procdata->sigcont_action, "auth-label", _("_Continue Process..."), NULL); ++ g_signal_connect (procdata->sigcont_action, "activate", G_CALLBACK (cb_kill_sigcont), procdata); ++ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigcont_action), ++ "C"); ++ ++ procdata->sigterm_action = polkit_gnome_action_new_default ("EndProcess", ++ NULL, ++ _("End _Process"), ++ _("Force process to finish normally")); ++ g_object_set (procdata->sigterm_action, "auth-label", _("End _Process..."), NULL); ++ g_signal_connect (procdata->sigterm_action, "activate", G_CALLBACK (cb_end_process), procdata); ++ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigterm_action), ++ "E"); ++ ++ procdata->sigkill_action = polkit_gnome_action_new_default ("KillProcess", ++ NULL, ++ _("_Kill Process"), ++ _("Force process to finish immediately")); ++ g_object_set (procdata->sigkill_action, "auth-label", _("_Kill Process..."), NULL); ++ g_signal_connect (procdata->sigkill_action, "activate", G_CALLBACK (cb_kill_process), procdata); ++ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigkill_action), ++ "K"); ++#endif ++ + gtk_ui_manager_insert_action_group (procdata->uimanager, + procdata->action_group, + 0); +@@ -685,7 +734,6 @@ create_main_window (ProcData *procdata) + menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar"); + gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0); + +- + /* create the main notebook */ + procdata->notebook = notebook = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (main_box), +@@ -782,23 +830,53 @@ update_sensitivity(ProcData *data) + processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES); + selected_sensitivity = (processes_sensitivity && data->selected_process != NULL); + ++#ifndef HAVE_POLKIT + if(data->endprocessbutton) { + /* avoid error on startup if endprocessbutton + has not been built yet */ + gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity); + } ++#endif + + for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) { + action = gtk_action_group_get_action(data->action_group, + processes_actions[i]); +- gtk_action_set_sensitive(action, processes_sensitivity); ++ gtk_action_set_sensitive(action, selected_sensitivity); + } + + for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) { + action = gtk_action_group_get_action(data->action_group, + selected_actions[i]); +- gtk_action_set_sensitive(action, selected_sensitivity); ++#ifdef HAVE_POLKIT ++ if (POLKIT_GNOME_IS_ACTION (action)) { ++ polkit_gnome_action_set_sensitive (POLKIT_GNOME_ACTION (action), processes_sensitivity); ++ } else { ++ gtk_action_set_sensitive(action, processes_sensitivity); ++ } ++#else ++ gtk_action_set_sensitive(action, processes_sensitivity); ++#endif + } ++ ++#ifdef HAVE_POLKIT ++ /* update the PolicyKit actions */ ++ if (data->selected_process != NULL) { ++ ProcInfo *pi = data->selected_process; ++ PolKitAction *pk_action; ++ ++ /* TODO: multiple processes may be selected; consider all of them */ ++ ++ if (pi->uid == getuid ()) { ++ pk_action = NULL; ++ } else { ++ pk_action = data->pk_action_kill; ++ } ++ g_object_set (data->sigstop_action, "polkit-action", pk_action, NULL); ++ g_object_set (data->sigcont_action, "polkit-action", pk_action, NULL); ++ g_object_set (data->sigterm_action, "polkit-action", pk_action, NULL); ++ g_object_set (data->sigkill_action, "polkit-action", pk_action, NULL); ++ } ++#endif + } + + static void diff --git a/gnome-system-monitor.spec b/gnome-system-monitor.spec index 88371d0..d96593f 100644 --- a/gnome-system-monitor.spec +++ b/gnome-system-monitor.spec @@ -40,7 +40,7 @@ BuildRequires: PolicyKit-gnome-devel >= %{polkit_gnome_version} BuildRequires: autoconf, automake, libtool # send upstream: http://bugzilla.gnome.org/show_bug.cgi?id=491462 -Patch0: g-s-m-polkit-3.patch +Patch0: gnome-system-monitor-2.21.5-polkit.patch Requires: PolicyKit-gnome >= %{polkit_gnome_version} Requires(pre): GConf2 >= %{gconf_version} @@ -54,7 +54,7 @@ gnome-system-monitor is a simple process and system monitor. %prep %setup -q -%patch0 -p0 -b .polkit +%patch0 -p1 -b .polkit %build autoreconf