Add "Run Task Manager as root" item in "Execute" menu

This commit is contained in:
Mike Massonnet
2010-06-18 15:59:04 +02:00
parent a8d0079795
commit d70a495618
3 changed files with 38 additions and 3 deletions

View File

@@ -66,11 +66,13 @@ dnl ***********************************
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.5.0])
dnl ******************************************
dnl *** Check for optional package libwnck ***
dnl ******************************************
dnl ***********************************
dnl *** Check for optional packages ***
dnl ***********************************
XDT_CHECK_OPTIONAL_PACKAGE([WNCK], [libwnck-1.0], [2.0], [wnck], [building with libwnck for window icons/names], [yes])
AM_CONDITIONAL([HAVE_WNCK], [test x"$WNCK_FOUND" = x"yes"])
XDT_CHECK_OPTIONAL_PACKAGE([GKSU], [libgksu2], [2.0], [gksu], [building with libgksu to run as root], [yes])
AM_CONDITIONAL([HAVE_GKSU], [test x"$GKSU_FOUND" = x"yes"])
dnl ***********************************
dnl ********** Check for skel *********
@@ -144,6 +146,7 @@ dnl ***************************
echo
echo "Build Configuration:"
echo
echo "* Gksu: ${GKSU_FOUND:-no} "${GKSU_VERSION:+"(libgksu $GKSU_VERSION)"}
echo "* Wnck: ${WNCK_FOUND:-no} "${WNCK_VERSION:+"(libwnck $WNCK_VERSION)"}
echo "* Target OS: $target_os ($ac_os_implementation)"
echo "* Debug Support: $enable_debug"

View File

@@ -12,12 +12,14 @@ xfce4_taskmanager_CFLAGS = \
$(GTK_CFLAGS) \
$(CAIRO_CFLAGS) \
$(WNCK_CFLAGS) \
$(GKSU_CFLAGS) \
$(NULL)
xfce4_taskmanager_LDADD = \
$(GTK_LIBS) \
$(CAIRO_LIBS) \
$(WNCK_LIBS) \
$(GKSU_LIBS) \
$(NULL)
xfce4_taskmanager_SOURCES = \

View File

@@ -19,6 +19,10 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#ifdef HAVE_GKSU
#include <libgksu/libgksu.h>
#endif
#include "settings.h"
#include "process-window.h"
#include "process-window_ui.h"
@@ -210,6 +214,16 @@ monitor_update_step_size (XtmProcessWindow *window)
g_object_set (window->priv->mem_monitor, "step-size", refresh_rate / 1000.0, NULL);
}
#ifdef HAVE_GKSU
static void
run_as_root (XtmProcessWindow *window)
{
gtk_widget_hide (window->priv->window);
gksu_run (g_get_prgname (), NULL);
gtk_widget_show (window->priv->window);
}
#endif
static void
execute_command (const gchar *command)
{
@@ -256,6 +270,22 @@ show_menu_execute_task (XtmProcessWindow *window)
if (menu == NULL)
{
menu = gtk_menu_new ();
#ifdef HAVE_GKSU
/* Run task manager as root */
if (geteuid () != 0)
{
GtkWidget *image = gtk_image_new_from_icon_name ("utilities-system-monitor", GTK_ICON_SIZE_MENU);
GtkWidget *mi = gtk_image_menu_item_new_with_label ("Run Task Manager as root");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
g_signal_connect_swapped (mi, "activate", G_CALLBACK (run_as_root), window);
mi = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
}
#endif
/* Find a runner program */
if (program_exists ("xfrun4"))
menu_execute_append_item (GTK_MENU (menu), _("Run Program..."), "xfrun4", "system-run");