diff --git a/.cvsignore b/.cvsignore index b0984be..da6947a 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -gnome-system-monitor-2.23.3.tar.bz2 +gnome-system-monitor-2.23.5.tar.bz2 diff --git a/gnome-system-monitor-2.12.1-monitor.patch b/gnome-system-monitor-2.12.1-monitor.patch deleted file mode 100644 index 29c01ea..0000000 --- a/gnome-system-monitor-2.12.1-monitor.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.monitor 2005-11-22 00:58:38.000000000 -0500 -+++ gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in 2005-11-22 00:58:56.000000000 -0500 -@@ -8,7 +8,7 @@ - Terminal=false - Type=Application - StartupNotify=true --Categories=Application;System; -+Categories=Application;System;Monitor;X-Red-Hat-Base - X-GNOME-Bugzilla-Bugzilla=GNOME - X-GNOME-Bugzilla-Product=system-monitor - X-GNOME-Bugzilla-Component=general ---- gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.in.monitor 2005-11-22 00:57:34.000000000 -0500 -+++ gnome-system-monitor-2.12.1/gnome-system-monitor.desktop.in.in 2005-11-22 00:58:25.000000000 -0500 -@@ -8,7 +8,7 @@ - Terminal=false - Type=Application - StartupNotify=true --Categories=Application;System; -+Categories=Application;System;Monitor;X-Red-Hat-Base - X-GNOME-Bugzilla-Bugzilla=GNOME - X-GNOME-Bugzilla-Product=system-monitor - X-GNOME-Bugzilla-Component=general diff --git a/gnome-system-monitor-2.17.2.1-fedora.patch b/gnome-system-monitor-2.17.2.1-fedora.patch deleted file mode 100644 index 8916165..0000000 --- a/gnome-system-monitor-2.17.2.1-fedora.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- gnome-system-monitor-2.17.2.1/src/sysinfo.cpp.fedora 2006-11-02 13:45:35.000000000 -0500 -+++ gnome-system-monitor-2.17.2.1/src/sysinfo.cpp 2006-11-18 01:09:14.000000000 -0500 -@@ -141,10 +141,55 @@ - }; - - -+ class RedHatSysInfo -+ : public SysInfo -+ { -+ public: -+ RedHatSysInfo() : SysInfo(_("Unknown distro")) -+ { -+ this->load_redhat_info(); -+ } -+ -+ private: -+ void load_redhat_info() -+ { -+ gchar *text, *t, *s; -+ -+ if (!g_file_get_contents ("/etc/redhat-release", &text, NULL, NULL)) -+ return; -+ -+ t = strstr (text, " release"); -+ -+ if (!t) -+ { -+ g_free (text); -+ return; -+ } -+ -+ *t = '\0'; -+ -+ t += strlen (" release"); -+ -+ while (*t == ' ') -+ t++; -+ -+ s = strchr (t, ' '); -+ -+ if (s) -+ *s = '\0'; -+ -+ this->distro_name = text; -+ this->distro_version = t; -+ } -+ }; -+ -+ - SysInfo* get_sysinfo() - { - if (g_file_test("/etc/debian_version", G_FILE_TEST_EXISTS)) - return new DebianSysInfo; -+ else if (g_file_test("/etc/redhat-release", G_FILE_TEST_EXISTS)) -+ return new RedHatSysInfo; - else - return new SysInfo(_("Unknown distro")); - } diff --git a/gnome-system-monitor-2.21.5-polkit.patch b/gnome-system-monitor-2.21.5-polkit.patch deleted file mode 100644 index 93daf8a..0000000 --- a/gnome-system-monitor-2.21.5-polkit.patch +++ /dev/null @@ -1,1474 +0,0 @@ -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 -+POLKIT_GNOME_REQUIRED=0.7 -+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 librsvg-2.0 >= $RSVG_REQUIRED) - -+# PolicyKit detection; defaults to 'auto' (use it if it's available) -+# -+POLKIT_GNOME_CFLAGS= -+POLKIT_GNOME_LIBS= -+POLKIT_DBUS_CFLAGS= -+POLKIT_DBUS_LIBS= -+AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit],[Enable PolicyKit support (auto)]),enable_polkit=$enableval,enable_polkit=auto) -+if test "x$enable_polkit" = "xno" ; then -+ HAVE_POLKIT=no -+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 -+ -+ if test "x$HAVE_POLKIT" = "xyes" ; then -+ AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled]) -+ PKG_CHECK_MODULES(POLKIT_DBUS, polkit-dbus >= $POLKIT_DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0) -+ fi -+fi -+AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes") -+AC_SUBST(POLKIT_GNOME_CFLAGS) -+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]) - -@@ -114,6 +145,7 @@ Configuration: - CFLAGS: ${CFLAGS} - CXXFLAGS: ${CXXFLAGS} - pcrecpp: ${enable_pcrecpp} -+ PolicyKit support: ${HAVE_POLKIT} - Maintainer mode: ${USER_MAINTAINER_MODE} - Languages: ${ALL_LINGUAS} - " -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@ \ -- @PCRECPP_CFLAGS@ -+ @PCRECPP_CFLAGS@ \ -+ @POLKIT_DBUS_CFLAGS@ \ -+ @POLKIT_GNOME_CFLAGS@ - - bin_PROGRAMS = gnome-system-monitor - -@@ -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 -@@ -53,8 +59,44 @@ schema_ins = gnome-system-monitor.schem - schema_DATA = $(schema_ins:.schemas.in=.schemas) - @INTLTOOL_SCHEMAS_RULE@ - -+###################################################################### -+if HAVE_POLKIT -+ -+polkit_policydir = $(datadir)/PolicyKit/policy -+dist_polkit_policy_DATA = org.gnome.system-monitor.policy -+# You will need a recent intltool or the patch from this bug http://bugzilla.gnome.org/show_bug.cgi?id=462312 -+@INTLTOOL_POLICY_RULE@ -+ -+gnome-system-monitor-mechanism-client-glue.h: gnome-system-monitor-mechanism.xml Makefile.am -+ dbus-binding-tool --prefix=gnome_system_monitor_mechanism --mode=glib-client --output=gnome-system-monitor-mechanism-client-glue.h gnome-system-monitor-mechanism.xml -+ -+gnome-system-monitor-mechanism-glue.h: gnome-system-monitor-mechanism.xml Makefile.am -+ dbus-binding-tool --prefix=gnome_system_monitor_mechanism --mode=glib-server --output=gnome-system-monitor-mechanism-glue.h gnome-system-monitor-mechanism.xml -+ -+dbusconfdir = $(sysconfdir)/dbus-1/system.d -+dbusconf_DATA = org.gnome.SystemMonitor.Mechanism.conf -+ -+org.gnome.SystemMonitor.Mechanism.service : org.gnome.SystemMonitor.Mechanism.service.in Makefile.am -+ sed -e s_libexecdir_$(libexecdir)_ org.gnome.SystemMonitor.Mechanism.service.in > org.gnome.SystemMonitor.Mechanism.service -+ -+dbussyssvcdir = $(datadir)/dbus-1/system-services -+dbussyssvc_DATA = org.gnome.SystemMonitor.Mechanism.service -+ -+libexec_PROGRAMS = gnome-system-monitor-mechanism -+gnome_system_monitor_mechanism_SOURCES = \ -+ gnome-system-monitor-mechanism-glue.h \ -+ gnome-system-monitor-mechanism.c -+ -+gnome_system_monitor_mechanism_CFLAGS = $(POLKIT_DBUS_CFLAGS) -+gnome_system_monitor_mechanism_LDADD = $(POLKIT_DBUS_LIBS) -+endif -+###################################################################### -+ -+ - EXTRA_DIST = \ -- $(schema_ins) -+ $(schema_ins) \ -+ org.gnome.system-monitor.policy.in \ -+ org.gnome.system-monitor.service.in - - CLEANFILES = \ - $(schema_DATA) -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 -*- -+ * -+ * Copyright (C) 2007 David Zeuthen -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static gboolean no_exit = FALSE; -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+ -+#define GNOME_SYSTEM_MONITOR_TYPE_MECHANISM (gnome_system_monitor_mechanism_get_type ()) -+#define GNOME_SYSTEM_MONITOR_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanism)) -+#define GNOME_SYSTEM_MONITOR_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismClass)) -+#define GNOME_SYSTEM_MONITOR_IS_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)) -+#define GNOME_SYSTEM_MONITOR_IS_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)) -+#define GNOME_SYSTEM_MONITOR_MECHANISM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismClass)) -+ -+typedef struct GnomeSystemMonitorMechanismPrivate GnomeSystemMonitorMechanismPrivate; -+ -+typedef struct -+{ -+ GObject parent; -+ GnomeSystemMonitorMechanismPrivate *priv; -+} GnomeSystemMonitorMechanism; -+ -+typedef struct -+{ -+ GObjectClass parent_class; -+} GnomeSystemMonitorMechanismClass; -+ -+typedef enum -+{ -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, -+ GNOME_SYSTEM_MONITOR_MECHANISM_NUM_ERRORS -+} GnomeSystemMonitorMechanismError; -+ -+#define GNOME_SYSTEM_MONITOR_MECHANISM_ERROR gnome_system_monitor_mechanism_error_quark () -+ -+GType gnome_system_monitor_mechanism_error_get_type (void); -+#define GNOME_SYSTEM_MONITOR_MECHANISM_TYPE_ERROR (gnome_system_monitor_mechanism_error_get_type ()) -+ -+ -+GQuark gnome_system_monitor_mechanism_error_quark (void); -+GType gnome_system_monitor_mechanism_get_type (void); -+GnomeSystemMonitorMechanism *gnome_system_monitor_mechanism_new (void); -+ -+/* exported methods */ -+gboolean gnome_system_monitor_mechanism_kill (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int sig, -+ DBusGMethodInvocation *context); -+ -+gboolean gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int nice_value, -+ DBusGMethodInvocation *context); -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+#include "gnome-system-monitor-mechanism-glue.h" -+ -+static gboolean -+do_exit (gpointer user_data) -+{ -+ g_debug ("Exiting due to inactivity"); -+ exit (1); -+ return FALSE; -+} -+ -+static void -+reset_killtimer (void) -+{ -+ static guint timer_id = 0; -+ -+ if (no_exit) -+ return; -+ -+ if (timer_id > 0) { -+ g_source_remove (timer_id); -+ } -+ g_debug ("Setting killtimer to 30 seconds..."); -+ timer_id = g_timeout_add (30 * 1000, do_exit, NULL); -+} -+ -+struct GnomeSystemMonitorMechanismPrivate -+{ -+ DBusGConnection *system_bus_connection; -+ DBusGProxy *system_bus_proxy; -+ PolKitContext *pol_ctx; -+}; -+ -+static void gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass); -+static void gnome_system_monitor_mechanism_init (GnomeSystemMonitorMechanism *seat); -+static void gnome_system_monitor_mechanism_finalize (GObject *object); -+ -+G_DEFINE_TYPE (GnomeSystemMonitorMechanism, gnome_system_monitor_mechanism, G_TYPE_OBJECT) -+ -+#define GNOME_SYSTEM_MONITOR_MECHANISM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismPrivate)) -+ -+GQuark -+gnome_system_monitor_mechanism_error_quark (void) -+{ -+ static GQuark ret = 0; -+ -+ if (ret == 0) { -+ ret = g_quark_from_static_string ("gnome_system_monitor_mechanism_error"); -+ } -+ -+ return ret; -+} -+ -+ -+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } -+ -+GType -+gnome_system_monitor_mechanism_error_get_type (void) -+{ -+ static GType etype = 0; -+ -+ if (etype == 0) -+ { -+ static const GEnumValue values[] = -+ { -+ ENUM_ENTRY (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, "GeneralError"), -+ ENUM_ENTRY (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, "NotPrivileged"), -+ { 0, 0, 0 } -+ }; -+ -+ g_assert (GNOME_SYSTEM_MONITOR_MECHANISM_NUM_ERRORS == G_N_ELEMENTS (values) - 1); -+ -+ etype = g_enum_register_static ("GnomeSystemMonitorMechanismError", values); -+ } -+ -+ return etype; -+} -+ -+ -+static GObject * -+gnome_system_monitor_mechanism_constructor (GType type, -+ guint n_construct_properties, -+ GObjectConstructParam *construct_properties) -+{ -+ GnomeSystemMonitorMechanism *mechanism; -+ GnomeSystemMonitorMechanismClass *klass; -+ -+ klass = GNOME_SYSTEM_MONITOR_MECHANISM_CLASS (g_type_class_peek (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)); -+ -+ mechanism = GNOME_SYSTEM_MONITOR_MECHANISM ( -+ G_OBJECT_CLASS (gnome_system_monitor_mechanism_parent_class)->constructor (type, -+ n_construct_properties, -+ construct_properties)); -+ -+ return G_OBJECT (mechanism); -+} -+ -+static void -+gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass) -+{ -+ GObjectClass *object_class = G_OBJECT_CLASS (klass); -+ -+ object_class->constructor = gnome_system_monitor_mechanism_constructor; -+ object_class->finalize = gnome_system_monitor_mechanism_finalize; -+ -+ g_type_class_add_private (klass, sizeof (GnomeSystemMonitorMechanismPrivate)); -+ -+ dbus_g_object_type_install_info (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, &dbus_glib_gnome_system_monitor_mechanism_object_info); -+ -+ dbus_g_error_domain_register (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, NULL, GNOME_SYSTEM_MONITOR_MECHANISM_TYPE_ERROR); -+ -+} -+ -+static void -+gnome_system_monitor_mechanism_init (GnomeSystemMonitorMechanism *mechanism) -+{ -+ mechanism->priv = GNOME_SYSTEM_MONITOR_MECHANISM_GET_PRIVATE (mechanism); -+ -+} -+ -+static void -+gnome_system_monitor_mechanism_finalize (GObject *object) -+{ -+ GnomeSystemMonitorMechanism *mechanism; -+ -+ g_return_if_fail (object != NULL); -+ g_return_if_fail (GNOME_SYSTEM_MONITOR_IS_MECHANISM (object)); -+ -+ mechanism = GNOME_SYSTEM_MONITOR_MECHANISM (object); -+ -+ g_return_if_fail (mechanism->priv != NULL); -+ -+ g_object_unref (mechanism->priv->system_bus_proxy); -+ -+ G_OBJECT_CLASS (gnome_system_monitor_mechanism_parent_class)->finalize (object); -+} -+ -+static gboolean -+pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data) -+{ -+ int fd; -+ PolKitContext *pk_context = user_data; -+ fd = g_io_channel_unix_get_fd (channel); -+ polkit_context_io_func (pk_context, fd); -+ return TRUE; -+} -+ -+static int -+pk_io_add_watch (PolKitContext *pk_context, int fd) -+{ -+ guint id = 0; -+ GIOChannel *channel; -+ channel = g_io_channel_unix_new (fd); -+ if (channel == NULL) -+ goto out; -+ id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context); -+ if (id == 0) { -+ g_io_channel_unref (channel); -+ goto out; -+ } -+ g_io_channel_unref (channel); -+out: -+ return id; -+} -+ -+static void -+pk_io_remove_watch (PolKitContext *pk_context, int watch_id) -+{ -+ g_source_remove (watch_id); -+} -+ -+static gboolean -+register_mechanism (GnomeSystemMonitorMechanism *mechanism) -+{ -+ GError *error = NULL; -+ -+ mechanism->priv->pol_ctx = polkit_context_new (); -+ polkit_context_set_io_watch_functions (mechanism->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch); -+ if (!polkit_context_init (mechanism->priv->pol_ctx, NULL)) { -+ g_critical ("cannot initialize libpolkit"); -+ goto error; -+ } -+ -+ error = NULL; -+ mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -+ if (mechanism->priv->system_bus_connection == NULL) { -+ if (error != NULL) { -+ g_critical ("error getting system bus: %s", error->message); -+ g_error_free (error); -+ } -+ goto error; -+ } -+ -+ dbus_g_connection_register_g_object (mechanism->priv->system_bus_connection, "/", -+ G_OBJECT (mechanism)); -+ -+ mechanism->priv->system_bus_proxy = dbus_g_proxy_new_for_name (mechanism->priv->system_bus_connection, -+ DBUS_SERVICE_DBUS, -+ DBUS_PATH_DBUS, -+ DBUS_INTERFACE_DBUS); -+ -+ reset_killtimer (); -+ -+ return TRUE; -+ -+error: -+ return FALSE; -+} -+ -+ -+GnomeSystemMonitorMechanism * -+gnome_system_monitor_mechanism_new (void) -+{ -+ GObject *object; -+ gboolean res; -+ -+ object = g_object_new (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, NULL); -+ -+ res = register_mechanism (GNOME_SYSTEM_MONITOR_MECHANISM (object)); -+ if (! res) { -+ g_object_unref (object); -+ return NULL; -+ } -+ -+ return GNOME_SYSTEM_MONITOR_MECHANISM (object); -+} -+ -+static PolKitCaller * -+get_caller_from_context (GnomeSystemMonitorMechanism *mechanism, DBusGMethodInvocation *context) -+{ -+ const char *sender; -+ GError *error; -+ DBusError dbus_error; -+ PolKitCaller *pk_caller; -+ -+ sender = dbus_g_method_get_sender (context); -+ dbus_error_init (&dbus_error); -+ pk_caller = polkit_caller_new_from_dbus_name ( -+ dbus_g_connection_get_connection (mechanism->priv->system_bus_connection), -+ sender, -+ &dbus_error); -+ if (pk_caller == NULL) { -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error getting information about caller: %s: %s", -+ dbus_error.name, dbus_error.message); -+ dbus_error_free (&dbus_error); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return NULL; -+ } -+ -+ return pk_caller; -+} -+ -+/* note, we take ownership of the passed PolKitCaller object */ -+static gboolean -+_check_polkit_for_action_for_caller (GnomeSystemMonitorMechanism *mechanism, -+ DBusGMethodInvocation *context, -+ PolKitCaller *pk_caller, -+ const char *action, -+ const char *action_secondary) -+{ -+ GError *error; -+ PolKitAction *pk_action; -+ PolKitResult pk_result; -+ -+ error = NULL; -+ -+ pk_action = polkit_action_new (); -+ polkit_action_set_action_id (pk_action, action); -+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, -+ pk_action, -+ pk_caller, -+ TRUE, -+ NULL); -+ if (pk_result != POLKIT_RESULT_YES) { -+ polkit_action_set_action_id (pk_action, action_secondary); -+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, -+ pk_action, -+ pk_caller, -+ TRUE, -+ NULL); -+ } -+ polkit_action_unref (pk_action); -+ polkit_caller_unref (pk_caller); -+ -+ if (pk_result != POLKIT_RESULT_YES) { -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, -+ "%s %s <-- (action, result)", -+ action, -+ polkit_result_to_string_representation (pk_result)); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ return TRUE; -+} -+ -+static gboolean -+_check_polkit_for_action (GnomeSystemMonitorMechanism *mechanism, -+ DBusGMethodInvocation *context, -+ const char *action, -+ const char *action_secondary) -+{ -+ PolKitCaller *pk_caller; -+ -+ /* Check that caller is privileged */ -+ if ((pk_caller = get_caller_from_context (mechanism, context)) == NULL) -+ return FALSE; -+ -+ return _check_polkit_for_action_for_caller (mechanism, context, pk_caller, action, action_secondary); -+} -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+/* exported methods */ -+ -+gboolean -+gnome_system_monitor_mechanism_kill (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int sig, -+ DBusGMethodInvocation *context) -+{ -+ reset_killtimer (); -+ -+ if (!_check_polkit_for_action (mechanism, context, "org.gnome.system-monitor.kill", NULL)) -+ return FALSE; -+ -+ g_debug ("Sending signal %d to pid %d", sig, pid); -+ -+ if (kill (pid, sig) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error sending signal %d to pid %d: %m", sig, pid); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ dbus_g_method_return (context); -+ return TRUE; -+} -+ -+gboolean -+gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int nice_value, -+ DBusGMethodInvocation *context) -+{ -+ uid_t caller_uid; -+ uid_t process_uid; -+ PolKitCaller *pk_caller; -+ char *procpath; -+ struct stat statbuf; -+ const char *action_id; -+ const char *action_id_secondary; -+ -+ reset_killtimer (); -+ -+ /* Hmm; is there a better way to do this? This may be Linux specific.. */ -+ procpath = g_strdup_printf ("/proc/%d", pid); -+ if (stat (procpath, &statbuf) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error figuring out uid for pid %d", pid); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ g_free (procpath); -+ return FALSE; -+ } -+ g_free (procpath); -+ process_uid = statbuf.st_uid; -+ -+ pk_caller = get_caller_from_context (mechanism, context); -+ if (pk_caller == NULL) -+ return FALSE; -+ -+ if (!polkit_caller_get_uid (pk_caller, &caller_uid)) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error figuring out uid of caller"); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ polkit_caller_unref (pk_caller); -+ return FALSE; -+ } -+ -+ if (caller_uid == process_uid) { -+ /* we need either .increase-own-priority or .change-priority */ -+ action_id = "org.gnome.system-monitor.increase-own-priority"; -+ action_id_secondary = "org.gnome.system-monitor.change-priority"; -+ } else { -+ action_id = "org.gnome.system-monitor.change-priority"; -+ action_id_secondary = NULL; -+ } -+ -+ if (!_check_polkit_for_action_for_caller (mechanism, context, pk_caller, action_id, action_id_secondary)) { -+ return FALSE; -+ } -+ -+ g_debug ("Renicing pid %d (owned by uid %d) to priority %d on behalf of uid %d (action_id=%s)", -+ pid, process_uid, nice_value, caller_uid, action_id); -+ -+ errno = 0; -+ if (setpriority (PRIO_PROCESS, pid, nice_value) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error renicing pid %d to priority %d: %m", pid, nice_value); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ dbus_g_method_return (context); -+ return TRUE; -+} -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+ -+#define BUS_NAME "org.gnome.SystemMonitor.Mechanism" -+ -+static gboolean -+acquire_name_on_proxy (DBusGProxy *bus_proxy) -+{ -+ GError *error; -+ guint result; -+ gboolean res; -+ gboolean ret; -+ -+ ret = FALSE; -+ -+ if (bus_proxy == NULL) { -+ goto out; -+ } -+ -+ error = NULL; -+ res = dbus_g_proxy_call (bus_proxy, -+ "RequestName", -+ &error, -+ G_TYPE_STRING, BUS_NAME, -+ G_TYPE_UINT, 0, -+ G_TYPE_INVALID, -+ G_TYPE_UINT, &result, -+ G_TYPE_INVALID); -+ if (! res) { -+ if (error != NULL) { -+ g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); -+ g_error_free (error); -+ } else { -+ g_warning ("Failed to acquire %s", BUS_NAME); -+ } -+ goto out; -+ } -+ -+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { -+ if (error != NULL) { -+ g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); -+ g_error_free (error); -+ } else { -+ g_warning ("Failed to acquire %s", BUS_NAME); -+ } -+ goto out; -+ } -+ -+ ret = TRUE; -+ -+ out: -+ return ret; -+} -+ -+int -+main (int argc, char **argv) -+{ -+ GMainLoop *loop; -+ GnomeSystemMonitorMechanism *mechanism; -+ DBusGProxy *bus_proxy; -+ DBusGConnection *connection; -+ int ret; -+ GError *error; -+ GOptionContext *context; -+ static GOptionEntry entries [] = { -+ { "no-exit", 0, 0, G_OPTION_ARG_NONE, &no_exit, N_("Don't exit after 30 seconds of inactivity"), NULL }, -+ { NULL } -+ }; -+ -+ ret = 1; -+ -+ g_type_init (); -+ -+ context = g_option_context_new (_("PolicyKit GNOME session daemon")); -+ g_option_context_add_main_entries (context, entries, NULL); -+ g_option_context_parse (context, &argc, &argv, NULL); -+ g_option_context_free (context); -+ -+ -+ error = NULL; -+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -+ if (connection == NULL) { -+ g_warning ("Couldn't connect to system bus: %s", error->message); -+ g_error_free (error); -+ goto out; -+ } -+ -+ bus_proxy = dbus_g_proxy_new_for_name (connection, -+ DBUS_SERVICE_DBUS, -+ DBUS_PATH_DBUS, -+ DBUS_INTERFACE_DBUS); -+ if (bus_proxy == NULL) { -+ g_warning ("Could not construct bus_proxy object; bailing out"); -+ goto out; -+ } -+ -+ if (!acquire_name_on_proxy (bus_proxy) ) { -+ g_warning ("Could not acquire name; bailing out"); -+ goto out; -+ } -+ -+ mechanism = gnome_system_monitor_mechanism_new (); -+ -+ if (mechanism == NULL) { -+ goto out; -+ } -+ -+ loop = g_main_loop_new (NULL, FALSE); -+ -+ g_main_loop_run (loop); -+ -+ g_object_unref (mechanism); -+ g_main_loop_unref (loop); -+ ret = 0; -+ -+out: -+ return ret; -+} -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 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -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 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -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-2.21.92-polkit.patch b/gnome-system-monitor-2.21.92-polkit.patch deleted file mode 100644 index 5eb3a34..0000000 --- a/gnome-system-monitor-2.21.92-polkit.patch +++ /dev/null @@ -1,1477 +0,0 @@ -diff -up gnome-system-monitor-2.21.92/po/POTFILES.in.polkit gnome-system-monitor-2.21.92/po/POTFILES.in ---- gnome-system-monitor-2.21.92/po/POTFILES.in.polkit 2008-02-25 10:15:16.000000000 -0500 -+++ gnome-system-monitor-2.21.92/po/POTFILES.in 2008-02-26 00:13:35.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.92/configure.in.polkit gnome-system-monitor-2.21.92/configure.in ---- gnome-system-monitor-2.21.92/configure.in.polkit 2008-02-25 10:01:45.000000000 -0500 -+++ gnome-system-monitor-2.21.92/configure.in 2008-02-26 00:29:05.000000000 -0500 -@@ -33,11 +33,45 @@ GNOME_ICON_THEME_REQUIRED=2.15.3 - GTKMM_REQUIRED=2.8 - GLIBMM_REQUIRED=2.14 - LIBXML_REQUIRED=2.0 -+POLKIT_GNOME_REQUIRED=0.7 -+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 librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED) - - -+# PolicyKit detection; defaults to 'auto' (use it if it's available) -+# -+POLKIT_GNOME_CFLAGS= -+POLKIT_GNOME_LIBS= -+POLKIT_DBUS_CFLAGS= -+POLKIT_DBUS_LIBS= -+AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit],[Enable PolicyKit support (auto)]),enable_polkit=$enableval,enable_polkit=auto) -+if test "x$enable_polkit" = "xno" ; then -+ HAVE_POLKIT=no -+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 -+ -+ if test "x$HAVE_POLKIT" = "xyes" ; then -+ AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled]) -+ PKG_CHECK_MODULES(POLKIT_DBUS, polkit-dbus >= $POLKIT_DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0) -+ fi -+fi -+AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes") -+AC_SUBST(POLKIT_GNOME_CFLAGS) -+AC_SUBST(POLKIT_GNOME_LIBS) -+AC_SUBST(POLKIT_DBUS_CFLAGS) -+AC_SUBST(POLKIT_DBUS_LIBS) -+ -+ - AC_ARG_ENABLE(more-warnings, - [AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings])], - set_more_warnings="$enableval",[ -@@ -96,6 +130,7 @@ Configuration: - C++ Compiler: ${CXX} - CFLAGS: ${CFLAGS} - CXXFLAGS: ${CXXFLAGS} -+ PolicyKit support: ${HAVE_POLKIT} - Maintainer mode: ${USER_MAINTAINER_MODE} - Languages: ${ALL_LINGUAS} - " -diff -up gnome-system-monitor-2.21.92/src/Makefile.am.polkit gnome-system-monitor-2.21.92/src/Makefile.am ---- gnome-system-monitor-2.21.92/src/Makefile.am.polkit 2008-02-20 14:58:48.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/Makefile.am 2008-02-26 00:13:35.000000000 -0500 -@@ -4,7 +4,9 @@ INCLUDES = \ - -DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DDATADIR=\""$(datadir)"\" \ -- @PROCMAN_CFLAGS@ -+ @PROCMAN_CFLAGS@ \ -+ @POLKIT_DBUS_CFLAGS@ \ -+ @POLKIT_GNOME_CFLAGS@ - - bin_PROGRAMS = gnome-system-monitor - -@@ -34,8 +36,11 @@ 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@ libbacon.la -+gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @POLKIT_GNOME_LIBS@ libbacon.la - - - noinst_LTLIBRARIES = libbacon.la -@@ -51,8 +56,44 @@ schema_ins = gnome-system-monitor.schem - schema_DATA = $(schema_ins:.schemas.in=.schemas) - @INTLTOOL_SCHEMAS_RULE@ - -+###################################################################### -+if HAVE_POLKIT -+ -+polkit_policydir = $(datadir)/PolicyKit/policy -+dist_polkit_policy_DATA = org.gnome.system-monitor.policy -+# You will need a recent intltool or the patch from this bug http://bugzilla.gnome.org/show_bug.cgi?id=462312 -+@INTLTOOL_POLICY_RULE@ -+ -+gnome-system-monitor-mechanism-client-glue.h: gnome-system-monitor-mechanism.xml Makefile.am -+ dbus-binding-tool --prefix=gnome_system_monitor_mechanism --mode=glib-client --output=gnome-system-monitor-mechanism-client-glue.h gnome-system-monitor-mechanism.xml -+ -+gnome-system-monitor-mechanism-glue.h: gnome-system-monitor-mechanism.xml Makefile.am -+ dbus-binding-tool --prefix=gnome_system_monitor_mechanism --mode=glib-server --output=gnome-system-monitor-mechanism-glue.h gnome-system-monitor-mechanism.xml -+ -+dbusconfdir = $(sysconfdir)/dbus-1/system.d -+dbusconf_DATA = org.gnome.SystemMonitor.Mechanism.conf -+ -+org.gnome.SystemMonitor.Mechanism.service : org.gnome.SystemMonitor.Mechanism.service.in Makefile.am -+ sed -e s_libexecdir_$(libexecdir)_ org.gnome.SystemMonitor.Mechanism.service.in > org.gnome.SystemMonitor.Mechanism.service -+ -+dbussyssvcdir = $(datadir)/dbus-1/system-services -+dbussyssvc_DATA = org.gnome.SystemMonitor.Mechanism.service -+ -+libexec_PROGRAMS = gnome-system-monitor-mechanism -+gnome_system_monitor_mechanism_SOURCES = \ -+ gnome-system-monitor-mechanism-glue.h \ -+ gnome-system-monitor-mechanism.c -+ -+gnome_system_monitor_mechanism_CFLAGS = $(POLKIT_DBUS_CFLAGS) -+gnome_system_monitor_mechanism_LDADD = $(POLKIT_DBUS_LIBS) -+endif -+###################################################################### -+ -+ - EXTRA_DIST = \ -- $(schema_ins) -+ $(schema_ins) \ -+ org.gnome.system-monitor.policy.in \ -+ org.gnome.system-monitor.service.in - - CLEANFILES = \ - $(schema_DATA) -diff -up /dev/null gnome-system-monitor-2.21.92/src/gnome-system-monitor-mechanism.c ---- /dev/null 2008-02-25 20:11:08.647008951 -0500 -+++ gnome-system-monitor-2.21.92/src/gnome-system-monitor-mechanism.c 2008-02-26 00:13:35.000000000 -0500 -@@ -0,0 +1,640 @@ -+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- -+ * -+ * Copyright (C) 2007 David Zeuthen -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static gboolean no_exit = FALSE; -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+ -+#define GNOME_SYSTEM_MONITOR_TYPE_MECHANISM (gnome_system_monitor_mechanism_get_type ()) -+#define GNOME_SYSTEM_MONITOR_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanism)) -+#define GNOME_SYSTEM_MONITOR_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismClass)) -+#define GNOME_SYSTEM_MONITOR_IS_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)) -+#define GNOME_SYSTEM_MONITOR_IS_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)) -+#define GNOME_SYSTEM_MONITOR_MECHANISM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismClass)) -+ -+typedef struct GnomeSystemMonitorMechanismPrivate GnomeSystemMonitorMechanismPrivate; -+ -+typedef struct -+{ -+ GObject parent; -+ GnomeSystemMonitorMechanismPrivate *priv; -+} GnomeSystemMonitorMechanism; -+ -+typedef struct -+{ -+ GObjectClass parent_class; -+} GnomeSystemMonitorMechanismClass; -+ -+typedef enum -+{ -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, -+ GNOME_SYSTEM_MONITOR_MECHANISM_NUM_ERRORS -+} GnomeSystemMonitorMechanismError; -+ -+#define GNOME_SYSTEM_MONITOR_MECHANISM_ERROR gnome_system_monitor_mechanism_error_quark () -+ -+GType gnome_system_monitor_mechanism_error_get_type (void); -+#define GNOME_SYSTEM_MONITOR_MECHANISM_TYPE_ERROR (gnome_system_monitor_mechanism_error_get_type ()) -+ -+ -+GQuark gnome_system_monitor_mechanism_error_quark (void); -+GType gnome_system_monitor_mechanism_get_type (void); -+GnomeSystemMonitorMechanism *gnome_system_monitor_mechanism_new (void); -+ -+/* exported methods */ -+gboolean gnome_system_monitor_mechanism_kill (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int sig, -+ DBusGMethodInvocation *context); -+ -+gboolean gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int nice_value, -+ DBusGMethodInvocation *context); -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+#include "gnome-system-monitor-mechanism-glue.h" -+ -+static gboolean -+do_exit (gpointer user_data) -+{ -+ g_debug ("Exiting due to inactivity"); -+ exit (1); -+ return FALSE; -+} -+ -+static void -+reset_killtimer (void) -+{ -+ static guint timer_id = 0; -+ -+ if (no_exit) -+ return; -+ -+ if (timer_id > 0) { -+ g_source_remove (timer_id); -+ } -+ g_debug ("Setting killtimer to 30 seconds..."); -+ timer_id = g_timeout_add (30 * 1000, do_exit, NULL); -+} -+ -+struct GnomeSystemMonitorMechanismPrivate -+{ -+ DBusGConnection *system_bus_connection; -+ DBusGProxy *system_bus_proxy; -+ PolKitContext *pol_ctx; -+}; -+ -+static void gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass); -+static void gnome_system_monitor_mechanism_init (GnomeSystemMonitorMechanism *seat); -+static void gnome_system_monitor_mechanism_finalize (GObject *object); -+ -+G_DEFINE_TYPE (GnomeSystemMonitorMechanism, gnome_system_monitor_mechanism, G_TYPE_OBJECT) -+ -+#define GNOME_SYSTEM_MONITOR_MECHANISM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, GnomeSystemMonitorMechanismPrivate)) -+ -+GQuark -+gnome_system_monitor_mechanism_error_quark (void) -+{ -+ static GQuark ret = 0; -+ -+ if (ret == 0) { -+ ret = g_quark_from_static_string ("gnome_system_monitor_mechanism_error"); -+ } -+ -+ return ret; -+} -+ -+ -+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } -+ -+GType -+gnome_system_monitor_mechanism_error_get_type (void) -+{ -+ static GType etype = 0; -+ -+ if (etype == 0) -+ { -+ static const GEnumValue values[] = -+ { -+ ENUM_ENTRY (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, "GeneralError"), -+ ENUM_ENTRY (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, "NotPrivileged"), -+ { 0, 0, 0 } -+ }; -+ -+ g_assert (GNOME_SYSTEM_MONITOR_MECHANISM_NUM_ERRORS == G_N_ELEMENTS (values) - 1); -+ -+ etype = g_enum_register_static ("GnomeSystemMonitorMechanismError", values); -+ } -+ -+ return etype; -+} -+ -+ -+static GObject * -+gnome_system_monitor_mechanism_constructor (GType type, -+ guint n_construct_properties, -+ GObjectConstructParam *construct_properties) -+{ -+ GnomeSystemMonitorMechanism *mechanism; -+ GnomeSystemMonitorMechanismClass *klass; -+ -+ klass = GNOME_SYSTEM_MONITOR_MECHANISM_CLASS (g_type_class_peek (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM)); -+ -+ mechanism = GNOME_SYSTEM_MONITOR_MECHANISM ( -+ G_OBJECT_CLASS (gnome_system_monitor_mechanism_parent_class)->constructor (type, -+ n_construct_properties, -+ construct_properties)); -+ -+ return G_OBJECT (mechanism); -+} -+ -+static void -+gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass) -+{ -+ GObjectClass *object_class = G_OBJECT_CLASS (klass); -+ -+ object_class->constructor = gnome_system_monitor_mechanism_constructor; -+ object_class->finalize = gnome_system_monitor_mechanism_finalize; -+ -+ g_type_class_add_private (klass, sizeof (GnomeSystemMonitorMechanismPrivate)); -+ -+ dbus_g_object_type_install_info (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, &dbus_glib_gnome_system_monitor_mechanism_object_info); -+ -+ dbus_g_error_domain_register (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, NULL, GNOME_SYSTEM_MONITOR_MECHANISM_TYPE_ERROR); -+ -+} -+ -+static void -+gnome_system_monitor_mechanism_init (GnomeSystemMonitorMechanism *mechanism) -+{ -+ mechanism->priv = GNOME_SYSTEM_MONITOR_MECHANISM_GET_PRIVATE (mechanism); -+ -+} -+ -+static void -+gnome_system_monitor_mechanism_finalize (GObject *object) -+{ -+ GnomeSystemMonitorMechanism *mechanism; -+ -+ g_return_if_fail (object != NULL); -+ g_return_if_fail (GNOME_SYSTEM_MONITOR_IS_MECHANISM (object)); -+ -+ mechanism = GNOME_SYSTEM_MONITOR_MECHANISM (object); -+ -+ g_return_if_fail (mechanism->priv != NULL); -+ -+ g_object_unref (mechanism->priv->system_bus_proxy); -+ -+ G_OBJECT_CLASS (gnome_system_monitor_mechanism_parent_class)->finalize (object); -+} -+ -+static gboolean -+pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data) -+{ -+ int fd; -+ PolKitContext *pk_context = user_data; -+ fd = g_io_channel_unix_get_fd (channel); -+ polkit_context_io_func (pk_context, fd); -+ return TRUE; -+} -+ -+static int -+pk_io_add_watch (PolKitContext *pk_context, int fd) -+{ -+ guint id = 0; -+ GIOChannel *channel; -+ channel = g_io_channel_unix_new (fd); -+ if (channel == NULL) -+ goto out; -+ id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context); -+ if (id == 0) { -+ g_io_channel_unref (channel); -+ goto out; -+ } -+ g_io_channel_unref (channel); -+out: -+ return id; -+} -+ -+static void -+pk_io_remove_watch (PolKitContext *pk_context, int watch_id) -+{ -+ g_source_remove (watch_id); -+} -+ -+static gboolean -+register_mechanism (GnomeSystemMonitorMechanism *mechanism) -+{ -+ GError *error = NULL; -+ -+ mechanism->priv->pol_ctx = polkit_context_new (); -+ polkit_context_set_io_watch_functions (mechanism->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch); -+ if (!polkit_context_init (mechanism->priv->pol_ctx, NULL)) { -+ g_critical ("cannot initialize libpolkit"); -+ goto error; -+ } -+ -+ error = NULL; -+ mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -+ if (mechanism->priv->system_bus_connection == NULL) { -+ if (error != NULL) { -+ g_critical ("error getting system bus: %s", error->message); -+ g_error_free (error); -+ } -+ goto error; -+ } -+ -+ dbus_g_connection_register_g_object (mechanism->priv->system_bus_connection, "/", -+ G_OBJECT (mechanism)); -+ -+ mechanism->priv->system_bus_proxy = dbus_g_proxy_new_for_name (mechanism->priv->system_bus_connection, -+ DBUS_SERVICE_DBUS, -+ DBUS_PATH_DBUS, -+ DBUS_INTERFACE_DBUS); -+ -+ reset_killtimer (); -+ -+ return TRUE; -+ -+error: -+ return FALSE; -+} -+ -+ -+GnomeSystemMonitorMechanism * -+gnome_system_monitor_mechanism_new (void) -+{ -+ GObject *object; -+ gboolean res; -+ -+ object = g_object_new (GNOME_SYSTEM_MONITOR_TYPE_MECHANISM, NULL); -+ -+ res = register_mechanism (GNOME_SYSTEM_MONITOR_MECHANISM (object)); -+ if (! res) { -+ g_object_unref (object); -+ return NULL; -+ } -+ -+ return GNOME_SYSTEM_MONITOR_MECHANISM (object); -+} -+ -+static PolKitCaller * -+get_caller_from_context (GnomeSystemMonitorMechanism *mechanism, DBusGMethodInvocation *context) -+{ -+ const char *sender; -+ GError *error; -+ DBusError dbus_error; -+ PolKitCaller *pk_caller; -+ -+ sender = dbus_g_method_get_sender (context); -+ dbus_error_init (&dbus_error); -+ pk_caller = polkit_caller_new_from_dbus_name ( -+ dbus_g_connection_get_connection (mechanism->priv->system_bus_connection), -+ sender, -+ &dbus_error); -+ if (pk_caller == NULL) { -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error getting information about caller: %s: %s", -+ dbus_error.name, dbus_error.message); -+ dbus_error_free (&dbus_error); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return NULL; -+ } -+ -+ return pk_caller; -+} -+ -+/* note, we take ownership of the passed PolKitCaller object */ -+static gboolean -+_check_polkit_for_action_for_caller (GnomeSystemMonitorMechanism *mechanism, -+ DBusGMethodInvocation *context, -+ PolKitCaller *pk_caller, -+ const char *action, -+ const char *action_secondary) -+{ -+ GError *error; -+ PolKitAction *pk_action; -+ PolKitResult pk_result; -+ -+ error = NULL; -+ -+ pk_action = polkit_action_new (); -+ polkit_action_set_action_id (pk_action, action); -+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, -+ pk_action, -+ pk_caller, -+ TRUE, -+ NULL); -+ if (pk_result != POLKIT_RESULT_YES) { -+ polkit_action_set_action_id (pk_action, action_secondary); -+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, -+ pk_action, -+ pk_caller, -+ TRUE, -+ NULL); -+ } -+ polkit_action_unref (pk_action); -+ polkit_caller_unref (pk_caller); -+ -+ if (pk_result != POLKIT_RESULT_YES) { -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, -+ "%s %s <-- (action, result)", -+ action, -+ polkit_result_to_string_representation (pk_result)); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ return TRUE; -+} -+ -+static gboolean -+_check_polkit_for_action (GnomeSystemMonitorMechanism *mechanism, -+ DBusGMethodInvocation *context, -+ const char *action, -+ const char *action_secondary) -+{ -+ PolKitCaller *pk_caller; -+ -+ /* Check that caller is privileged */ -+ if ((pk_caller = get_caller_from_context (mechanism, context)) == NULL) -+ return FALSE; -+ -+ return _check_polkit_for_action_for_caller (mechanism, context, pk_caller, action, action_secondary); -+} -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+/* exported methods */ -+ -+gboolean -+gnome_system_monitor_mechanism_kill (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int sig, -+ DBusGMethodInvocation *context) -+{ -+ reset_killtimer (); -+ -+ if (!_check_polkit_for_action (mechanism, context, "org.gnome.system-monitor.kill", NULL)) -+ return FALSE; -+ -+ g_debug ("Sending signal %d to pid %d", sig, pid); -+ -+ if (kill (pid, sig) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error sending signal %d to pid %d: %m", sig, pid); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ dbus_g_method_return (context); -+ return TRUE; -+} -+ -+gboolean -+gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism, -+ int pid, -+ int nice_value, -+ DBusGMethodInvocation *context) -+{ -+ uid_t caller_uid; -+ uid_t process_uid; -+ PolKitCaller *pk_caller; -+ char *procpath; -+ struct stat statbuf; -+ const char *action_id; -+ const char *action_id_secondary; -+ -+ reset_killtimer (); -+ -+ /* Hmm; is there a better way to do this? This may be Linux specific.. */ -+ procpath = g_strdup_printf ("/proc/%d", pid); -+ if (stat (procpath, &statbuf) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error figuring out uid for pid %d", pid); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ g_free (procpath); -+ return FALSE; -+ } -+ g_free (procpath); -+ process_uid = statbuf.st_uid; -+ -+ pk_caller = get_caller_from_context (mechanism, context); -+ if (pk_caller == NULL) -+ return FALSE; -+ -+ if (!polkit_caller_get_uid (pk_caller, &caller_uid)) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error figuring out uid of caller"); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ polkit_caller_unref (pk_caller); -+ return FALSE; -+ } -+ -+ if (caller_uid == process_uid) { -+ /* we need either .increase-own-priority or .change-priority */ -+ action_id = "org.gnome.system-monitor.increase-own-priority"; -+ action_id_secondary = "org.gnome.system-monitor.change-priority"; -+ } else { -+ action_id = "org.gnome.system-monitor.change-priority"; -+ action_id_secondary = NULL; -+ } -+ -+ if (!_check_polkit_for_action_for_caller (mechanism, context, pk_caller, action_id, action_id_secondary)) { -+ return FALSE; -+ } -+ -+ g_debug ("Renicing pid %d (owned by uid %d) to priority %d on behalf of uid %d (action_id=%s)", -+ pid, process_uid, nice_value, caller_uid, action_id); -+ -+ errno = 0; -+ if (setpriority (PRIO_PROCESS, pid, nice_value) != 0) { -+ GError *error; -+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, -+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, -+ "Error renicing pid %d to priority %d: %m", pid, nice_value); -+ g_warning ("Error: %s", error->message); -+ dbus_g_method_return_error (context, error); -+ g_error_free (error); -+ return FALSE; -+ } -+ -+ dbus_g_method_return (context); -+ return TRUE; -+} -+ -+/*--------------------------------------------------------------------------------------------------------------*/ -+ -+#define BUS_NAME "org.gnome.SystemMonitor.Mechanism" -+ -+static gboolean -+acquire_name_on_proxy (DBusGProxy *bus_proxy) -+{ -+ GError *error; -+ guint result; -+ gboolean res; -+ gboolean ret; -+ -+ ret = FALSE; -+ -+ if (bus_proxy == NULL) { -+ goto out; -+ } -+ -+ error = NULL; -+ res = dbus_g_proxy_call (bus_proxy, -+ "RequestName", -+ &error, -+ G_TYPE_STRING, BUS_NAME, -+ G_TYPE_UINT, 0, -+ G_TYPE_INVALID, -+ G_TYPE_UINT, &result, -+ G_TYPE_INVALID); -+ if (! res) { -+ if (error != NULL) { -+ g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); -+ g_error_free (error); -+ } else { -+ g_warning ("Failed to acquire %s", BUS_NAME); -+ } -+ goto out; -+ } -+ -+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { -+ if (error != NULL) { -+ g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message); -+ g_error_free (error); -+ } else { -+ g_warning ("Failed to acquire %s", BUS_NAME); -+ } -+ goto out; -+ } -+ -+ ret = TRUE; -+ -+ out: -+ return ret; -+} -+ -+int -+main (int argc, char **argv) -+{ -+ GMainLoop *loop; -+ GnomeSystemMonitorMechanism *mechanism; -+ DBusGProxy *bus_proxy; -+ DBusGConnection *connection; -+ int ret; -+ GError *error; -+ GOptionContext *context; -+ static GOptionEntry entries [] = { -+ { "no-exit", 0, 0, G_OPTION_ARG_NONE, &no_exit, N_("Don't exit after 30 seconds of inactivity"), NULL }, -+ { NULL } -+ }; -+ -+ ret = 1; -+ -+ g_type_init (); -+ -+ context = g_option_context_new (_("PolicyKit GNOME session daemon")); -+ g_option_context_add_main_entries (context, entries, NULL); -+ g_option_context_parse (context, &argc, &argv, NULL); -+ g_option_context_free (context); -+ -+ -+ error = NULL; -+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); -+ if (connection == NULL) { -+ g_warning ("Couldn't connect to system bus: %s", error->message); -+ g_error_free (error); -+ goto out; -+ } -+ -+ bus_proxy = dbus_g_proxy_new_for_name (connection, -+ DBUS_SERVICE_DBUS, -+ DBUS_PATH_DBUS, -+ DBUS_INTERFACE_DBUS); -+ if (bus_proxy == NULL) { -+ g_warning ("Could not construct bus_proxy object; bailing out"); -+ goto out; -+ } -+ -+ if (!acquire_name_on_proxy (bus_proxy) ) { -+ g_warning ("Could not acquire name; bailing out"); -+ goto out; -+ } -+ -+ mechanism = gnome_system_monitor_mechanism_new (); -+ -+ if (mechanism == NULL) { -+ goto out; -+ } -+ -+ loop = g_main_loop_new (NULL, FALSE); -+ -+ g_main_loop_run (loop); -+ -+ g_object_unref (mechanism); -+ g_main_loop_unref (loop); -+ ret = 0; -+ -+out: -+ return ret; -+} -diff -up /dev/null gnome-system-monitor-2.21.92/src/gnome-system-monitor-mechanism.xml ---- /dev/null 2008-02-25 20:11:08.647008951 -0500 -+++ gnome-system-monitor-2.21.92/src/gnome-system-monitor-mechanism.xml 2008-02-26 00:13:35.000000000 -0500 -@@ -0,0 +1,15 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff -up /dev/null gnome-system-monitor-2.21.92/src/org.gnome.SystemMonitor.Mechanism.service.in ---- /dev/null 2008-02-25 20:11:08.647008951 -0500 -+++ gnome-system-monitor-2.21.92/src/org.gnome.SystemMonitor.Mechanism.service.in 2008-02-26 00:13:35.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.92/src/org.gnome.system-monitor.policy.in ---- /dev/null 2008-02-25 20:11:08.647008951 -0500 -+++ gnome-system-monitor-2.21.92/src/org.gnome.system-monitor.policy.in 2008-02-26 00:13:35.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.92/src/procactions.cpp.polkit gnome-system-monitor-2.21.92/src/procactions.cpp ---- gnome-system-monitor-2.21.92/src/procactions.cpp.polkit 2007-12-22 10:03:34.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/procactions.cpp 2008-02-26 00:13:35.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.92/src/callbacks.cpp.polkit gnome-system-monitor-2.21.92/src/callbacks.cpp ---- gnome-system-monitor-2.21.92/src/callbacks.cpp.polkit 2008-02-22 15:50:07.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/callbacks.cpp 2008-02-26 00:13:35.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.92/src/procman.cpp.polkit gnome-system-monitor-2.21.92/src/procman.cpp ---- gnome-system-monitor-2.21.92/src/procman.cpp.polkit 2008-02-24 05:06:57.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/procman.cpp 2008-02-26 00:13:35.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.92/src/procman.h.polkit gnome-system-monitor-2.21.92/src/procman.h ---- gnome-system-monitor-2.21.92/src/procman.h.polkit 2008-01-14 13:14:34.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/procman.h 2008-02-26 00:13:35.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.92/src/org.gnome.SystemMonitor.Mechanism.conf ---- /dev/null 2008-02-25 20:11:08.647008951 -0500 -+++ gnome-system-monitor-2.21.92/src/org.gnome.SystemMonitor.Mechanism.conf 2008-02-26 00:13:35.000000000 -0500 -@@ -0,0 +1,11 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff -up gnome-system-monitor-2.21.92/src/procdialogs.cpp.polkit gnome-system-monitor-2.21.92/src/procdialogs.cpp ---- gnome-system-monitor-2.21.92/src/procdialogs.cpp.polkit 2007-12-22 10:03:34.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/procdialogs.cpp 2008-02-26 00:13:35.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.92/src/interface.cpp.polkit gnome-system-monitor-2.21.92/src/interface.cpp ---- gnome-system-monitor-2.21.92/src/interface.cpp.polkit 2008-02-20 15:40:44.000000000 -0500 -+++ gnome-system-monitor-2.21.92/src/interface.cpp 2008-02-26 00:13:35.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 */ -@@ -670,6 +680,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); -@@ -677,7 +726,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), -@@ -774,23 +822,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-2.22.0-system-tab-arg.patch b/gnome-system-monitor-2.22.0-system-tab-arg.patch deleted file mode 100644 index 52335cf..0000000 --- a/gnome-system-monitor-2.22.0-system-tab-arg.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff -up gnome-system-monitor-2.22.0/src/procman.h.system-tab-arg gnome-system-monitor-2.22.0/src/procman.h ---- gnome-system-monitor-2.22.0/src/procman.h.system-tab-arg 2008-04-01 17:09:29.000000000 -0400 -+++ gnome-system-monitor-2.22.0/src/procman.h 2008-04-01 17:09:29.000000000 -0400 -@@ -58,6 +58,7 @@ enum - static const unsigned MIN_UPDATE_INTERVAL = 1 * 1000; - static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000; - -+#define SHOW_SYSTEM_TAB_CMD "SHOWSYSTAB" /* elegant, eh */ - - enum ProcmanTab - { -diff -up gnome-system-monitor-2.22.0/src/procman.cpp.system-tab-arg gnome-system-monitor-2.22.0/src/procman.cpp ---- gnome-system-monitor-2.22.0/src/procman.cpp.system-tab-arg 2008-04-01 17:09:29.000000000 -0400 -+++ gnome-system-monitor-2.22.0/src/procman.cpp 2008-04-01 17:10:20.000000000 -0400 -@@ -626,14 +626,19 @@ cb_server (const gchar *msg, gpointer us - { - GdkWindow *window; - ProcData *procdata; -- guint32 timestamp; -+ guint32 timestamp = 0; - - window = gdk_get_default_root_window (); - - procdata = *(ProcData**)user_data; - g_assert (procdata != NULL); - -- timestamp = strtoul(msg, NULL, 0); -+ procman_debug("cb_server(%s)", msg); -+ if (msg != NULL && strcmp(SHOW_SYSTEM_TAB_CMD, msg) == 0) { -+ procman_debug("Changing to PROCMAN_TAB_SYSINFO via bacon message"); -+ gtk_notebook_set_current_page(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO); -+ } else -+ timestamp = strtoul(msg, NULL, 0); - - if (timestamp == 0) - { -@@ -669,12 +674,28 @@ main (int argc, char *argv[]) - ProcData *procdata; - BaconMessageConnection *conn; - -+ /* Parse commandline arguments */ -+ GError *error = NULL; -+ GOptionContext *context; -+ static gboolean show_system_tab = FALSE; -+ static GOptionEntry entries[] = -+ { -+ { "show-system-tab", 's', 0, G_OPTION_ARG_NONE, &show_system_tab, "Show the System tab", NULL }, -+ { NULL } -+ }; -+ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - startup_timestamp = get_startup_timestamp(); - -+ context = g_option_context_new("- a simple process and system monitor."); -+ g_option_context_set_ignore_unknown_options(context, TRUE); -+ g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE); -+ g_option_context_parse(context, &argc, &argv, &error); -+ g_option_context_free(context); -+ - Gtk::Main kit(&argc, &argv); - procman_debug("post gtk_init"); - -@@ -691,6 +712,9 @@ main (int argc, char *argv[]) - - timestamp = g_strdup_printf ("%" G_GUINT32_FORMAT, startup_timestamp); - -+ if (show_system_tab) -+ bacon_message_connection_send(conn, SHOW_SYSTEM_TAB_CMD); -+ - bacon_message_connection_send (conn, timestamp); - - gdk_notify_startup_complete (); -@@ -727,6 +751,11 @@ main (int argc, char *argv[]) - - g_assert(procdata->app); - -+ if (show_system_tab) { -+ procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request"); -+ gtk_notebook_set_current_page(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO); -+ } -+ - gtk_widget_show(procdata->app); - - procman_debug("begin gtk_main"); diff --git a/gnome-system-monitor-2.9.90-libgnomesu.patch b/gnome-system-monitor-2.9.90-libgnomesu.patch deleted file mode 100644 index 0853da8..0000000 --- a/gnome-system-monitor-2.9.90-libgnomesu.patch +++ /dev/null @@ -1,435 +0,0 @@ ---- gnome-system-monitor-2.9.90/configure.in.libgnomesu 2005-01-24 09:06:57.000000000 -0500 -+++ gnome-system-monitor-2.9.90/configure.in 2005-02-02 15:03:45.000000000 -0500 -@@ -19,9 +19,8 @@ - LIBGTOP_REQUIRED=2.9.5 - GTK_REQUIRED=2.5.0 - GNOME_VFS_REQUIRED=2.6.0 --LIBGNOMESU_REQUIRED=0.9.3 - --PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_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 libgnomesu-1.0 >= $LIBGNOMESU_REQUIRED) -+PKG_CHECK_MODULES(PROCMAN, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_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) - - - AC_ARG_ENABLE(more-warnings, ---- gnome-system-monitor-2.9.90/src/procdialogs.c.libgnomesu 2005-01-13 19:05:00.000000000 -0500 -+++ gnome-system-monitor-2.9.90/src/procdialogs.c 2005-02-02 15:03:45.000000000 -0500 -@@ -23,7 +23,6 @@ - - #include - #include --#include - #include "procdialogs.h" - #include "favorites.h" - #include "proctable.h" -@@ -815,13 +814,101 @@ - void procdialog_create_root_password_dialog (gint type, ProcData *procdata, gint pid, - gint extra_value, gchar *text) - { -+ GtkWidget *dialog; -+ GtkWidget *error_dialog; -+ GtkWidget *main_vbox; -+ GtkWidget *hbox; -+ GtkWidget *entry; -+ GtkWidget *label; -+ gchar *title = NULL, *button_label; - gchar *command; -+ gchar *password, *blank; -+ gint retval; -+ -+ if (type == 0) { -+ if (extra_value == SIGKILL) { -+ title = g_strdup (_("Kill Process")); -+ button_label = g_strdup (_("_Kill Process")); -+ } -+ else { -+ title = g_strdup (_("End Process")); -+ button_label = g_strdup (_("_End Process")); -+ } -+ } -+ else { -+ title = g_strdup (_("Change Priority")); -+ button_label = g_strdup (_("Change _Priority")); -+ } -+ -+ dialog = gtk_dialog_new_with_buttons (title, NULL, GTK_DIALOG_DESTROY_WITH_PARENT, -+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, -+ button_label, 100, -+ NULL); -+ -+ main_vbox = GTK_DIALOG (dialog)->vbox; -+ -+ label = gtk_label_new (_(text)); -+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); -+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 2 * GNOME_PAD); -+ gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); -+ -+ hbox = gtk_hbox_new (FALSE, 0); -+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL); -+ gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); -+ -+ label = gtk_label_new (_("Root Password :")); -+ gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD_SMALL, 0); -+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0); -+ -+ entry = gtk_entry_new (); -+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE); -+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 0); -+ g_signal_connect (G_OBJECT (entry), "activate", -+ G_CALLBACK (entry_activate_cb), dialog); -+ -+ gtk_widget_show_all (main_vbox); -+ -+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); -+ gtk_widget_grab_focus (entry); -+ -+ g_free (title); -+ g_free (button_label); -+ -+ retval = gtk_dialog_run (GTK_DIALOG (dialog)); -+ gtk_widget_hide (dialog); -+ -+ if (retval == 100) { -+ password = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); -+ -+ if (!password) -+ password = ""; -+ blank = g_strdup (password); -+ if (strlen (blank)) -+ memset (blank, ' ', strlen (blank)); -+ -+ gtk_entry_set_text (GTK_ENTRY (entry), blank); -+ gtk_entry_set_text (GTK_ENTRY (entry), ""); -+ g_free (blank); -+ -+ if (type == 0) -+ command = g_strdup_printf ("kill -s %d %d", extra_value, pid); -+ else -+ command = g_strdup_printf ("renice %d %d", extra_value, pid); -+ -+ if (su_run_with_password (command, password) == -1) { -+ error_dialog = gtk_message_dialog_new (NULL, -+ GTK_DIALOG_DESTROY_WITH_PARENT, -+ GTK_MESSAGE_ERROR, -+ GTK_BUTTONS_OK, -+ "%s", -+ _("Wrong Password.")); -+ gtk_dialog_run (GTK_DIALOG (error_dialog)); -+ gtk_widget_destroy (error_dialog); -+ } -+ g_free (command); -+ -+ } -+ gtk_widget_destroy (dialog); - -- if (type == 0) -- command = g_strdup_printf ("kill -s %d %d", extra_value, pid); -- else -- command = g_strdup_printf ("renice %d %d", extra_value, pid); -- gnomesu_exec (command); -- g_free (command); - } - ---- gnome-system-monitor-2.9.90/src/util.c.libgnomesu 2005-01-08 17:43:35.000000000 -0500 -+++ gnome-system-monitor-2.9.90/src/util.c 2005-02-02 15:08:57.000000000 -0500 -@@ -1,10 +1,294 @@ --#include "util.h" - -+#define _GNU_SOURCE - #include - -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+#ifdef __FreeBSD__ -+# include -+# include -+#endif -+ -+#ifdef __sun -+# include -+# include -+# include -+# include -+# include -+# include -+#endif -+ -+#include "util.h" -+ - #include --#include - -+/* ABORT() kills GTK if we're not root, else it just exits. -+ */ -+#define ABORT(root) \ -+ if (root == 0) \ -+ GTK_ABORT(); \ -+ else \ -+ _exit(-1) -+ -+/* GTK_ABORT() is supposed to kill GTK and exit. -+ */ -+#define GTK_ABORT() do { \ -+ gtk_main_quit(); \ -+ _exit(0); \ -+ } while (0) -+ -+/* OPEN_TTY() is supposed to return a file descriptor to a pseudo-terminal. -+ */ -+#define OPEN_TTY() getpt() -+ -+#ifdef __FreeBSD__ -+/* FreeBSD doesn't have getpt(). This function emulates it's behaviour. */ -+int getpt (void); -+ -+int -+getpt () -+{ -+ int master, slave; -+ -+ if (openpty (&master, &slave, NULL, NULL, NULL) < 0) { -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ return master; -+} -+#endif -+ -+#ifdef __sun -+/* Sun doesn't have getpt(). This function emulates it's behavior. */ -+int getpt (void); -+ -+int -+getpt () -+{ -+ int fdm, fds; -+ extern int errno; -+ char *slavename; -+ /* extern char *ptsname(); */ -+ -+ /* open master */ -+ fdm = open("/dev/ptmx", O_RDWR); -+ if ( fdm < 0 ) { -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ if ( grantpt(fdm) < 0 ) { /* change permission ofslave */ -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ if ( unlockpt(fdm) < 0 ) { /* unlock slave */ -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ slavename = ptsname(fdm); /* get name of slave */ -+ if ( slavename == NULL ) { -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ fds = open(slavename, O_RDWR); /* open slave */ -+ if ( fds < 0 ) { -+ /* Simulate getpt()'s only error condition. */ -+ errno = ENOENT; -+ return -1; -+ } -+ ioctl(fds, I_PUSH, "ptem"); /* push ptem * / -+ ioctl(fds, I_PUSH, "ldterm"); /* push ldterm */ -+ -+ return fds; -+} -+ -+/* Handle the fact that solaris doesn't have an asprintf */ -+/* pinched from -+http://samba.anu.edu.au/rsync/doxygen/head/snprintf_8c-source.html */ -+ -+#ifndef HAVE_VASPRINTF -+int vasprintf(char **ptr, const char *format, va_list ap) -+{ -+ int ret; -+ -+ ret = vsnprintf(NULL, 0, format, ap); -+ if (ret <= 0) return ret; -+ -+ (*ptr) = (char *)malloc(ret+1); -+ if (!*ptr) return -1; -+ ret = vsnprintf(*ptr, ret+1, format, ap); -+ -+ return ret; -+} -+#endif -+ -+ -+#ifndef HAVE_ASPRINTF -+ int asprintf(char **ptr, const char *format, ...) -+{ -+ va_list ap; -+ int ret; -+ -+ va_start(ap, format); -+ ret = vasprintf(ptr, format, ap); -+ va_end(ap); -+ -+ return ret; -+} -+#endif -+#endif -+ -+static int root = 0; /* if we are root, no password is -+ required */ -+ -+static gint -+exec_su (gchar *exec_path, gchar *user, gchar *pwd) -+{ -+ gchar *exec_p, *user_p; /* command to execute, user name */ -+ pid_t pid; -+ int t_fd; -+ -+ exec_p = g_strdup (exec_path); -+ -+#if 0 -+ if (asprintf (&exec_p, "%s&", exec_path) < 0) { -+ perror ("Unable to allocate memory chunk"); -+ g_free (exec_p); -+ return 0; -+ } -+#endif -+ -+ user_p = (user ? user : "root"); -+ -+ if ((pwd == NULL) || (*pwd == '\0')) { -+ g_free (exec_p); -+ return 0; -+ } -+ -+ /* -+ * Make su think we're sending the password from a terminal: -+ */ -+ -+ if (((t_fd = OPEN_TTY()) < 0) || (grantpt(t_fd) < 0) || (unlockpt(t_fd) < 0)) { -+ fprintf (stderr, "Unable to open a terminal\n"); -+ ABORT (root); -+ } -+ -+ if ((pid = fork()) < 0) { -+ perror ("Unable to fork a new process"); -+ ABORT (root); -+ } -+ -+ if (pid > 0) { /* parent process */ -+ int status; -+ -+ sleep(1); -+ -+ /* su(1) won't want a password if we're already root. -+ */ -+ if (root == 0) { -+ write (t_fd, pwd, strlen(pwd)); -+ -+ /* Need the \n to flush the password */ -+ write (t_fd, "\n", 1); -+ } -+ -+ waitpid (pid, &status, 0); -+ -+ if (WIFEXITED (status) && WEXITSTATUS (status) && (WEXITSTATUS(status) < 255)) { -+/* error_box (_("Incorrect password.")); */ -+ g_free (exec_p); -+ return -1; -+ } -+ else { -+ memset (pwd, 0, strlen (pwd)); -+ } -+ } -+ else { /* child process */ -+ struct passwd *pw; -+ char *env, *home, *pts; -+ -+ /* We have rights to run X (obviously). We need to ensure the -+ * destination user has the right stuff in the environment -+ * to be able to continue to run X. -+ * su will change $HOME to the new users home, so we will -+ * need an XAUTHORITY / ICEAUTHORITY pointing to the -+ * authorization files. -+ */ -+ -+ if ((home = getenv ("HOME")) == NULL) { -+ if ((env = getenv ("USER")) == NULL) -+ pw = getpwuid(getuid()); -+ else -+ pw = getpwnam(env); -+ if (pw) -+ home = pw->pw_dir; -+ else { -+ perror ("Unable to find home directory"); -+ _exit (-1); -+ } -+ } -+ -+ if ((env = getenv ("XAUTHORITY")) == NULL) { -+ if (asprintf (&env, "XAUTHORITY=%s/.Xauthority", home) > 0) -+ putenv (env); -+ else { -+ perror ("Unable to allocate memory chunk"); -+ _exit (-1); -+ } -+ } -+ -+ if ((env = getenv ("ICEAUTHORITY")) == NULL) { -+ if (asprintf (&env, "ICEAUTHORITY=%s/.ICEauthority", home) > 0) -+ putenv (env); -+ else { -+ perror ("Unable to allocate memory chunk"); -+ _exit (-1); -+ } -+ } -+ -+ if(((pts = ptsname(t_fd)) == NULL) || ((t_fd = open(pts, O_RDWR | O_NOCTTY)) < 0)) { -+ perror ("Unable to open pseudo slave terminal"); -+ _exit (-1); -+ } -+ dup2 (t_fd, 0); -+ -+#if 0 -+ freopen ("/dev/null", "w", stderr); -+ freopen ("/dev/null", "w", stdout); -+#endif -+ -+ execlp ("su", "su", "-m", user_p, "-c", exec_p, NULL); -+ _exit (0); -+ -+ } -+ -+ g_free (exec_p); -+ -+ return 0; -+} -+ -+gint -+su_run_with_password (gchar *exec_path, gchar *password) -+{ -+ return exec_su (exec_path, "root", password); -+} -+ -+#if 1 - void _procman_array_gettext_init(const char * strings[], size_t n) - { - size_t i; -@@ -15,3 +299,4 @@ - strings[i] = _(strings[i]); - } - } -+#endif diff --git a/gnome-system-monitor-graph-cpu.patch b/gnome-system-monitor-graph-cpu.patch deleted file mode 100644 index 8e7a5f2..0000000 --- a/gnome-system-monitor-graph-cpu.patch +++ /dev/null @@ -1,446 +0,0 @@ -diff -up gnome-system-monitor-2.22.1/src/load-graph.cpp.graph-cpu gnome-system-monitor-2.22.1/src/load-graph.cpp ---- gnome-system-monitor-2.22.1/src/load-graph.cpp.graph-cpu 2008-04-18 09:09:18.000000000 -0400 -+++ gnome-system-monitor-2.22.1/src/load-graph.cpp 2008-04-18 09:09:49.000000000 -0400 -@@ -63,87 +63,84 @@ unsigned LoadGraph::num_bars() const - void draw_background(LoadGraph *g) { - double dash[2] = { 1.0, 2.0 }; - cairo_t *cr; -- cairo_t* tmp_cr; - guint i; - unsigned num_bars; - char *caption; - cairo_text_extents_t extents; - -- - num_bars = g->num_bars(); - g->graph_dely = (g->draw_height - 15) / num_bars; /* round to int to avoid AA blur */ - g->real_draw_height = g->graph_dely * num_bars; - g->graph_delx = (g->draw_width - 2.0 - g->rmargin - g->indent) / (LoadGraph::NUM_POINTS - 3); - g->graph_buffer_offset = (int) (1.5 * g->graph_delx) + FRAME_WIDTH ; - -- cr = cairo_create (g->buffer); -- g->background_buffer = cairo_surface_create_similar (cairo_get_target (cr), -- CAIRO_CONTENT_COLOR_ALPHA, -- g->draw_width + (2*FRAME_WIDTH), -- g->draw_height + (2*FRAME_WIDTH)); // ** We need the whole area as we are now setting the background colour here -+ g->background = gdk_pixmap_new (GDK_DRAWABLE (g->disp->window), -+ g->disp->allocation.width, -+ g->disp->allocation.height, -+ -1); -+ cr = gdk_cairo_create (g->background); - -- tmp_cr = cairo_create (g->background_buffer); -- - // set the background colour - GtkStyle *style = gtk_widget_get_style (ProcData::get_instance()->notebook); -- gdk_cairo_set_source_color (tmp_cr, &style->bg[GTK_STATE_NORMAL]); -- cairo_paint (tmp_cr); -+ gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]); -+ cairo_paint (cr); - - /* draw frame */ -- cairo_translate (tmp_cr, FRAME_WIDTH, FRAME_WIDTH); -+ cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH); - - /* Draw background rectangle */ -- cairo_set_source_rgb (tmp_cr, 1.0, 1.0, 1.0); -- cairo_rectangle (tmp_cr, g->rmargin + g->indent, 0, -+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); -+ cairo_rectangle (cr, g->rmargin + g->indent, 0, - g->draw_width - g->rmargin - g->indent, g->real_draw_height); -- cairo_fill(tmp_cr); -+ cairo_fill(cr); - -- cairo_set_line_width (tmp_cr, 1.0); -- cairo_set_dash (tmp_cr, dash, 2, 0); -- cairo_set_font_size (tmp_cr, g->fontsize); -+ cairo_set_line_width (cr, 1.0); -+ cairo_set_dash (cr, dash, 2, 0); -+ cairo_set_font_size (cr, g->fontsize); - - for (i = 0; i <= num_bars; ++i) { - double y; - - if (i == 0) -- y = 0.5 + g->fontsize / 2.0; -+ y = 0.5 + g->fontsize / 2.0; - else if (i == num_bars) -- y = i * g->graph_dely + 0.5; -+ y = i * g->graph_dely + 0.5; - else -- y = i * g->graph_dely + g->fontsize / 2.0; -- gdk_cairo_set_source_color (tmp_cr, &style->fg[GTK_STATE_NORMAL]); -+ y = i * g->graph_dely + g->fontsize / 2.0; -+ -+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]); - if (g->type == LOAD_GRAPH_NET) { - // operation orders matters so it's 0 if i == num_bars - unsigned rate = g->net.max - (i * g->net.max / num_bars); - const std::string caption(procman::format_rate(rate, g->net.max)); -- cairo_text_extents (tmp_cr, caption.c_str(), &extents); -- cairo_move_to (tmp_cr, g->indent - extents.width + 20, y); -- cairo_show_text (tmp_cr, caption.c_str()); -+ cairo_text_extents (cr, caption.c_str(), &extents); -+ cairo_move_to (cr, g->indent - extents.width + 20, y); -+ cairo_show_text (cr, caption.c_str()); - } else { - // operation orders matters so it's 0 if i == num_bars - caption = g_strdup_printf("%d %%", 100 - i * (100 / num_bars)); -- cairo_text_extents (tmp_cr, caption, &extents); -- cairo_move_to (tmp_cr, g->indent - extents.width + 20, y); -- cairo_show_text (tmp_cr, caption); -+ cairo_text_extents (cr, caption, &extents); -+ cairo_move_to (cr, g->indent - extents.width + 20, y); -+ cairo_show_text (cr, caption); - g_free (caption); - } - -- cairo_set_source_rgba (tmp_cr, 0, 0, 0, 0.75); -- cairo_move_to (tmp_cr, g->rmargin + g->indent - 3, i * g->graph_dely + 0.5); -- cairo_line_to (tmp_cr, g->draw_width - 0.5, i * g->graph_dely + 0.5); -+ cairo_set_source_rgba (cr, 0, 0, 0, 0.75); -+ cairo_move_to (cr, g->rmargin + g->indent - 3, i * g->graph_dely + 0.5); -+ cairo_line_to (cr, g->draw_width - 0.5, i * g->graph_dely + 0.5); - } -- cairo_stroke (tmp_cr); -+ cairo_stroke (cr); - -- cairo_set_dash (tmp_cr, dash, 2, 1.5); -+ cairo_set_dash (cr, dash, 2, 1.5); - - const unsigned total_seconds = g->speed * (LoadGraph::NUM_POINTS - 2) / 1000; - - for (unsigned int i = 0; i < 7; i++) { - double x = (i) * (g->draw_width - g->rmargin - g->indent) / 6; -- cairo_set_source_rgba (tmp_cr, 0, 0, 0, 0.75); -- cairo_move_to (tmp_cr, (ceil(x) + 0.5) + g->rmargin + g->indent, 0.5); -- cairo_line_to (tmp_cr, (ceil(x) + 0.5) + g->rmargin + g->indent, g->real_draw_height + 4.5); -- cairo_stroke(tmp_cr); -+ cairo_set_source_rgba (cr, 0, 0, 0, 0.75); -+ cairo_move_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, 0.5); -+ cairo_line_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, g->real_draw_height + 4.5); -+ cairo_stroke(cr); - unsigned seconds = total_seconds - i * total_seconds / 6; - const char* format; - if (i == 0) -@@ -151,89 +148,26 @@ void draw_background(LoadGraph *g) { - else - format = "%u"; - caption = g_strdup_printf(format, seconds); -- cairo_text_extents (tmp_cr, caption, &extents); -- cairo_move_to (tmp_cr, ((ceil(x) + 0.5) + g->rmargin + g->indent) - (extents.width/2), g->draw_height); -- gdk_cairo_set_source_color (tmp_cr, &style->fg[GTK_STATE_NORMAL]); -- cairo_show_text (tmp_cr, caption); -+ cairo_text_extents (cr, caption, &extents); -+ cairo_move_to (cr, ((ceil(x) + 0.5) + g->rmargin + g->indent) - (extents.width/2), g->draw_height); -+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]); -+ cairo_show_text (cr, caption); - g_free (caption); - } - -- cairo_stroke (tmp_cr); -- cairo_destroy (tmp_cr); -- cairo_destroy (cr); -+ cairo_stroke (cr); -+ cairo_destroy (cr); - } - - /* Redraws the backing buffer for the load graph and updates the window */ - void - load_graph_draw (LoadGraph *g) - { -- cairo_t *cr; -- guint i, j; -- gdouble tmp; -- -- cr = cairo_create (g->buffer); -- -- /* draw the graph */ -- if ((g->render_counter == 0)) { -- cairo_surface_destroy(g->graph_buffer); -- cairo_t* tmp_cr; -- -- g->graph_buffer = cairo_surface_create_similar (cairo_get_target (cr), -- CAIRO_CONTENT_COLOR_ALPHA, -- g->draw_width, -- g->draw_height); -- tmp_cr = cairo_create (g->graph_buffer); -- -- cairo_set_line_width (tmp_cr, 1.5); -- cairo_set_line_cap (tmp_cr, CAIRO_LINE_CAP_ROUND); -- cairo_set_line_join (tmp_cr, CAIRO_LINE_JOIN_ROUND); -- -- for (j = 0; j < g->n; ++j) { -- cairo_move_to (tmp_cr, -- g->draw_width - 2.0, -- (1.0f - g->data[0][j]) * g->real_draw_height); -- gdk_cairo_set_source_color (tmp_cr, &(g->colors [j])); -- -- for (i = 1; i < LoadGraph::NUM_POINTS; ++i) { -- if (g->data[i][j] == -1.0f) -- continue; -- -- cairo_curve_to (tmp_cr, -- (g->draw_width - (i-1) * g->graph_delx) - (g->graph_delx/2), -- (1.0f - g->data[i-1][j]) * g->real_draw_height, -- (g->draw_width - i * g->graph_delx) + (g->graph_delx/2), -- (1.0f - g->data[i][j]) * g->real_draw_height, -- g->draw_width - i * g->graph_delx, -- (1.0f - g->data[i][j]) * g->real_draw_height); -- } -- -- cairo_stroke (tmp_cr); -- -- } -- cairo_destroy (tmp_cr); -- } -- -- /* Composite and clip the surfaces together */ -- if (g->background_buffer == NULL) { -- draw_background(g); -- } -- cairo_set_source_surface (cr, g->background_buffer, 0, 0); -- cairo_paint (cr); -- -- tmp = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS; -- tmp = tmp / g->frames_per_unit; -- tmp = tmp * g->render_counter; -- cairo_set_source_surface (cr, g->graph_buffer, g->graph_buffer_offset - tmp, FRAME_WIDTH); -- cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1, -- g->draw_width - g->rmargin - g->indent - 1 , g->real_draw_height + FRAME_WIDTH - 1); -- cairo_fill (cr); -- cairo_destroy (cr); -- - /* repaint */ - gtk_widget_queue_draw (g->disp); - } - --static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;) -+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;) - - static gboolean - load_graph_configure (GtkWidget *widget, -@@ -241,37 +175,16 @@ load_graph_configure (GtkWidget *widget, - gpointer data_ptr) - { - LoadGraph * const g = static_cast(data_ptr); -- cairo_t *cr; -- - g->draw_width = widget->allocation.width - 2 * FRAME_WIDTH; - g->draw_height = widget->allocation.height - 2 * FRAME_WIDTH; - -- // FIXME: -- // g->frames_per_unit = g->draw_width/(LoadGraph::NUM_POINTS); -- // knock FRAMES down to 5 until cairo gets faster -- -- if(g->timer_index) { -- g_source_remove (g->timer_index); -- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit, -- load_graph_update, -- g); -+ if (g->background) { -+ g_object_unref (g->background); -+ g->background = NULL; - } - -- cr = gdk_cairo_create (widget->window); -- -- if (g->buffer) -- cairo_surface_destroy (g->buffer); -- -- g->buffer = cairo_surface_create_similar (cairo_get_target (cr), -- CAIRO_CONTENT_COLOR, -- widget->allocation.width, -- widget->allocation.height); -- -- cairo_destroy (cr); -- -- if (g->background_buffer != NULL) { -- cairo_surface_destroy(g->background_buffer); -- g->background_buffer = NULL; -+ if (g->gc == NULL) { -+ g->gc = gdk_gc_new (GDK_DRAWABLE (widget->window)); - } - - load_graph_draw (g); -@@ -285,13 +198,60 @@ load_graph_expose (GtkWidget *widget, - gpointer data_ptr) - { - LoadGraph * const g = static_cast(data_ptr); -- cairo_t *cr; - -- cr = gdk_cairo_create(widget->window); -+ guint i, j; -+ gdouble tmp, x_offset; -+ -+ if (g->background == NULL) { -+ draw_background(g); -+ } -+ gdk_draw_drawable (g->disp->window, -+ g->gc, -+ g->background, -+ 0, 0, 0, 0, -+ g->disp->allocation.width, -+ g->disp->allocation.height); -+ -+ tmp = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS; -+ tmp = tmp / g->frames_per_unit; -+ tmp = tmp * (g->render_counter + 1); -+ -+ /* draw the graph */ -+ cairo_t* cr; -+ -+ cr = gdk_cairo_create (g->disp->window); -+ -+ cairo_set_line_width (cr, 1); -+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); -+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); -+ cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1, -+ g->draw_width - g->rmargin - g->indent - 1 , g->real_draw_height + FRAME_WIDTH - 1); -+ cairo_clip(cr); -+ -+ x_offset = g->rmargin - tmp; - -- cairo_set_source_surface(cr, g->buffer, 0, 0); -- cairo_paint(cr); -- cairo_destroy(cr); -+ for (j = 0; j < g->n; ++j) { -+ cairo_move_to (cr, -+ x_offset + g->draw_width - 2.0, -+ (1.0f - g->data[0][j]) * g->real_draw_height); -+ gdk_cairo_set_source_color (cr, &(g->colors [j])); -+ -+ for (i = 1; i < LoadGraph::NUM_POINTS; ++i) { -+ if (g->data[i][j] == -1.0f) -+ continue; -+ cairo_curve_to (cr, -+ x_offset + (g->draw_width - (i-1) * g->graph_delx) - (g->graph_delx/2), -+ (1.0f - g->data[i-1][j]) * g->real_draw_height+3.5, -+ x_offset + (g->draw_width - i * g->graph_delx) + (g->graph_delx/2), -+ (1.0f - g->data[i][j]) * g->real_draw_height+3.5, -+ x_offset + g->draw_width - i * g->graph_delx, -+ (1.0f - g->data[i][j]) * g->real_draw_height+3.5); -+ } -+ cairo_stroke (cr); -+ -+ } -+ -+ cairo_destroy (cr); - - return TRUE; - } -@@ -478,12 +438,6 @@ net_scale (LoadGraph *g, unsigned din, u - procman_debug("dmax = %u max = %u new_max = %u", dmax, g->net.max, new_max); - - g->net.max = new_max; -- -- // force the graph background to be redrawn now that scale has changed -- if (g->background_buffer != NULL) { -- cairo_surface_destroy(g->background_buffer); -- g->background_buffer = NULL; -- } - } - - static void -@@ -559,7 +513,7 @@ load_graph_update (gpointer user_data) - { - LoadGraph * const g = static_cast(user_data); - -- if (g->render_counter == 0) { -+ if (g->render_counter == 4) { - std::rotate(&g->data[0], &g->data[LoadGraph::NUM_POINTS - 1], &g->data[LoadGraph::NUM_POINTS]); - - switch (g->type) { -@@ -597,10 +551,8 @@ LoadGraph::~LoadGraph() - if (this->timer_index) - g_source_remove(this->timer_index); - -- if (this->buffer) { -- cairo_surface_destroy(this->buffer); -- this->buffer = NULL; -- } -+ if (this->background) -+ g_object_unref (this->background); - } - - -@@ -633,9 +585,8 @@ LoadGraph::LoadGraph(guint type) - graph_buffer_offset(0), - main_widget(NULL), - disp(NULL), -- buffer(NULL), -- graph_buffer(NULL), -- background_buffer(NULL), -+ gc(NULL), -+ background(NULL), - timer_index(0), - draw(FALSE), - mem_color_picker(NULL), -@@ -643,6 +594,9 @@ LoadGraph::LoadGraph(guint type) - { - LoadGraph * const g = this; - -+ // FIXME: -+ // on configure, g->frames_per_unit = g->draw_width/(LoadGraph::NUM_POINTS); -+ // knock FRAMES down to 5 until cairo gets faster - g->frames_per_unit = 5; // this will be changed but needs initialising - g->fontsize = 8.0; - g->rmargin = 3.5 * g->fontsize; -@@ -700,9 +654,7 @@ LoadGraph::LoadGraph(guint type) - } - - g->timer_index = 0; -- g->render_counter = g->frames_per_unit; -- g->background_buffer = NULL; -- g->graph_buffer = NULL; -+ g->render_counter = (g->frames_per_unit - 1); - g->draw = FALSE; - - g->main_widget = gtk_vbox_new (FALSE, FALSE); -@@ -730,10 +682,6 @@ LoadGraph::LoadGraph(guint type) - g->data[i] = &g->data_block[0] + i * g->n; - - gtk_widget_show_all (g->main_widget); -- -- load_graph_start(g); -- load_graph_stop(g); -- - } - - void -@@ -767,17 +715,9 @@ load_graph_change_speed (LoadGraph *g, - - g->speed = new_speed; - -- g_assert(g->timer_index); -- -- if(g->timer_index) { -- g_source_remove (g->timer_index); -- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit, -- load_graph_update, -- g); -- } -- if (g->background_buffer != NULL) { -- cairo_surface_destroy(g->background_buffer); -- g->background_buffer = NULL; -+ if (g->background != NULL) { -+ g_object_unref(g->background); -+ g->background = NULL; - } - } - -diff -up gnome-system-monitor-2.22.1/src/load-graph.h.graph-cpu gnome-system-monitor-2.22.1/src/load-graph.h ---- gnome-system-monitor-2.22.1/src/load-graph.h.graph-cpu 2008-04-18 09:09:47.000000000 -0400 -+++ gnome-system-monitor-2.22.1/src/load-graph.h 2008-04-18 09:09:49.000000000 -0400 -@@ -65,9 +65,8 @@ struct LoadGraph { - GtkWidget *main_widget; - GtkWidget *disp; - -- cairo_surface_t *buffer; -- cairo_surface_t *graph_buffer; -- cairo_surface_t *background_buffer; -+ GdkGC *gc; -+ GdkDrawable *background; - - guint timer_index; - diff --git a/gnome-system-monitor.spec b/gnome-system-monitor.spec index b319301..d787f55 100644 --- a/gnome-system-monitor.spec +++ b/gnome-system-monitor.spec @@ -12,8 +12,8 @@ Summary: Simple process monitor Name: gnome-system-monitor -Version: 2.23.3 -Release: 2%{?dist} +Version: 2.23.5 +Release: 1%{?dist} License: GPLv2+ Group: Applications/System URL: http://www.gnome.org/ @@ -122,6 +122,9 @@ scrollkeeper-update -q %changelog +* Tue Jul 22 2008 Matthias Clasen - 2.23.5-1 +- Update to 2.23.5 + * Thu Jun 05 2008 Than Ngo 2.23.3-2 - don't show it in KDE menu diff --git a/sources b/sources index 2458255..6381456 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -dc800bbb06c24f70614f31173f3b79bc gnome-system-monitor-2.23.3.tar.bz2 +77bcef6336fa72e1f96a920d3070ad17 gnome-system-monitor-2.23.5.tar.bz2