diff options
Diffstat (limited to 'gksu')
-rw-r--r-- | gksu/Makefile.am | 4 | ||||
-rw-r--r-- | gksu/libcaja-gksu.c | 109 | ||||
-rw-r--r-- | gksu/libcaja-gksu.caja-extension.desktop.in.in | 4 |
3 files changed, 69 insertions, 48 deletions
diff --git a/gksu/Makefile.am b/gksu/Makefile.am index e973dff..aac9e40 100644 --- a/gksu/Makefile.am +++ b/gksu/Makefile.am @@ -31,7 +31,11 @@ extensiondir = $(datadir)/caja/extensions extension_in_files = libcaja-gksu.caja-extension.desktop.in extension_DATA = $(extension_in_files:.caja-extension.desktop.in=.caja-extension) $(extension_DATA): $(extension_in_files) +if USE_NLS $(AM_V_GEN) $(MSGFMT) --desktop --keyword= --keyword=Copyright --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ +else + $(AM_V_GEN) cp $< $@ +endif CLEANFILES = $(extension_DATA) diff --git a/gksu/libcaja-gksu.c b/gksu/libcaja-gksu.c index 18c8db1..e996ae5 100644 --- a/gksu/libcaja-gksu.c +++ b/gksu/libcaja-gksu.c @@ -1,22 +1,19 @@ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib/gi18n-lib.h> + #include <stdlib.h> #include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> #include <string.h> -#include <pthread.h> #include <glib.h> #include <gtk/gtk.h> #include <gio/gio.h> #include <libcaja-extension/caja-extension-types.h> #include <libcaja-extension/caja-menu-provider.h> -#include "../config.h" - -#include <libintl.h> -#define _(x) dgettext (GETTEXT_PACKAGE, x) - #define GKSU_TYPE_CONTEXT_MENU (gksu_context_menu_get_type ()) -#define GKSU_CONTEXT_MENU(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GKSU_TYPE_CONTEXT_MENU)) typedef struct { GObject parent; @@ -62,7 +59,8 @@ gksu_context_menu_register_type (GTypeModule *module) NULL, sizeof (GksuContextMenu), 0, - (GInstanceInitFunc) gksu_context_menu_init + (GInstanceInitFunc) gksu_context_menu_init, + NULL }; static const GInterfaceInfo menu_provider_iface_info = { (GInterfaceInitFunc)menu_provider_iface_init, @@ -143,41 +141,11 @@ gksu_context_menu_get_file_items (CajaMenuProvider *provider, return items; } -gboolean -is_gksu_dead (gpointer data) -{ - GPid pid = GPOINTER_TO_INT(data); - if (waitpid (pid, NULL, WNOHANG) > 0) - return FALSE; - return TRUE; -} - -static void* -start_gksu_thread (void *data) -{ - GPid pid; - gchar **argv = (gchar**) g_malloc (sizeof (gchar*) * 3); - gchar *full_cmd = (gchar*) data; - - argv[0] = g_strdup ("gksu"); - argv[1] = full_cmd; - argv[2] = NULL; - - g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, - &pid, NULL); - g_timeout_add (5000, is_gksu_dead, GINT_TO_POINTER(pid)); - - g_free (argv[0]); - g_free (full_cmd); - g_free (argv); - - return NULL; -} - static void gksu_context_menu_activate (CajaMenuItem *item, CajaFileInfo *file) { + gchar *exec_path; gchar *uri = NULL; gchar *mime_type = NULL; gchar *cmd = NULL; @@ -247,12 +215,55 @@ gksu_context_menu_activate (CajaMenuItem *item, g_free (cmd); } - { - pthread_t new_thread; - pthread_create (&new_thread, NULL, start_gksu_thread, (void*)full_cmd); - } + if ((exec_path = g_find_program_in_path ("gksu")) == NULL) + { + if ((exec_path = g_find_program_in_path ("beesu")) == NULL) + { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new_with_markup (NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("<big><b>" + "Unable to determine the graphical wrapper for su" + "</b></big>\n\n" + "The item you selected cannot be open with " + "administrator powers because the graphical wrapper " + "for su cannot be determined, such as gtksu or beesu.")); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + } + + if (exec_path != NULL) + { + GError *error = NULL; + gchar **argv = (gchar**) g_malloc (sizeof (gchar*) * 3); + + argv[0] = exec_path; + argv[1] = full_cmd; + argv[2] = NULL; + + if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error)) + { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Error: %s"), + error->message); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + g_error_free (error); + } + g_strfreev (argv); + } + else + { + g_free (full_cmd); + } - /* full_cmd is freed by start_gksu_thread */ g_free (uri); g_free (mime_type); } @@ -261,12 +272,18 @@ gksu_context_menu_activate (CajaMenuItem *item, void caja_module_initialize (GTypeModule *module) { + g_print ("Initializing caja-gksu extension\n"); gksu_context_menu_register_type (module); +#ifdef ENABLE_NLS + bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif /* ENABLE_NLS */ } void caja_module_shutdown (void) { + g_print ("Shutting down caja-gksu extension\n"); } void diff --git a/gksu/libcaja-gksu.caja-extension.desktop.in.in b/gksu/libcaja-gksu.caja-extension.desktop.in.in index 4d7b242..83a24f4 100644 --- a/gksu/libcaja-gksu.caja-extension.desktop.in.in +++ b/gksu/libcaja-gksu.caja-extension.desktop.in.in @@ -4,6 +4,6 @@ Icon=system Name=Gksu Description=Privilege granting extension Author=Gustavo Noronha Silva -Copyright=Copyright (C) 2002-2005 Gustavo Noronha Silva +Copyright=Copyright (C) 2002-2005 Gustavo Noronha Silva\nCopyright (C) 2013-2014 Stefano Karapetsas\nCopyright (C) 2015-2021 MATE developers Version=@VERSION@ -Website=https://mate-desktop.org/ +Website=@PACKAGE_URL@ |