summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas James Alexander Thurman <tthurman@src.gnome.org>2008-11-08 18:51:56 +0000
committerThomas James Alexander Thurman <tthurman@src.gnome.org>2008-11-08 18:51:56 +0000
commitc4768a3b9fec7a99b824a83cd1ce8e2bc3d5110b (patch)
treefca36059c45bc974f1378057c2dd25465265e8c2
parent51468bfb569cc279171db5e653b682666b5f037f (diff)
downloadmetacity-c4768a3b9fec7a99b824a83cd1ce8e2bc3d5110b.tar.gz
metacity-c4768a3b9fec7a99b824a83cd1ce8e2bc3d5110b.tar.bz2
added dependency on Zenity remove error_on_generic_command() and
* configure.in: added dependency on Zenity * src/core/keybindings.c: remove error_on_generic_command() and error_on_terminal_command(); rewrite error_on_command in terms of meta_show_dialog() * src/core/util.c: add meta_show_dialog() to call Zenity * src/include/util.h: ditto svn path=/trunk/; revision=4013
-rw-r--r--ChangeLog9
-rw-r--r--configure.in4
-rw-r--r--src/core/keybindings.c106
-rw-r--r--src/core/util.c72
-rw-r--r--src/include/util.h7
5 files changed, 131 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a1b7f1..6a6021b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-11-08 Thomas Thurman <tthurman@gnome.org>
+
+ * configure.in: added dependency on Zenity
+ * src/core/keybindings.c: remove error_on_generic_command() and
+ error_on_terminal_command(); rewrite error_on_command
+ in terms of meta_show_dialog()
+ * src/core/util.c: add meta_show_dialog() to call Zenity
+ * src/include/util.h: ditto
+
2008-11-03 Olav Vitters <olav@bkor.dhs.org>
* src/ui/theme-parser.c: Fix build by readding accidentally removed
diff --git a/configure.in b/configure.in
index 61a3010..07bfda1 100644
--- a/configure.in
+++ b/configure.in
@@ -471,6 +471,10 @@ else
GCONF_SCHEMAS_INSTALL_FALSE=
fi
+AC_PATH_PROG(ZENITY, zenity, no)
+if test x"$ZENITY" = xno; then
+ AC_MSG_ERROR([zenity not found in your path - needed for dialogs])
+fi
AC_ARG_ENABLE(debug,
[ --enable-debug enable debugging],,
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index b05fe27..6b733d7 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -36,6 +36,7 @@
#include "place.h"
#include "prefs.h"
#include "effects.h"
+#include "util.h"
#include <X11/keysym.h>
#include <string.h>
@@ -2343,81 +2344,52 @@ handle_switch_to_workspace (MetaDisplay *display,
}
static void
-error_on_generic_command (const char *key,
- const char *command,
- const char *message,
- int screen_number,
- guint32 timestamp)
-{
- GError *err;
- char *argv[10];
- char numbuf[32];
- char timestampbuf[32];
-
- sprintf (numbuf, "%d", screen_number);
- sprintf (timestampbuf, "%u", timestamp);
-
- argv[0] = METACITY_LIBEXECDIR"/metacity-dialog";
- argv[1] = "--screen";
- argv[2] = numbuf;
- argv[3] = "--timestamp";
- argv[4] = timestampbuf;
- argv[5] = "--command-failed-error";
- argv[6] = (char *)key;
- argv[7] = (char*) (command ? command : "");
- argv[8] = (char*) message;
- argv[9] = NULL;
-
- err = NULL;
- if (!g_spawn_async_with_pipes ("/",
- argv,
- NULL,
- 0,
- NULL, NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- &err))
- {
- meta_warning (_("Error launching metacity-dialog to print an error about a command: %s\n"),
- err->message);
- g_error_free (err);
- }
-}
-
-static void
error_on_command (int command_index,
const char *command,
const char *message,
int screen_number,
guint32 timestamp)
{
- char *key;
-
- meta_warning ("Error on command %d \"%s\": %s\n",
- command_index, command, message);
+ if (command_index < 0)
+ meta_warning ("Error on terminal command \"%s\": %s\n", command, message);
+ else
+ meta_warning ("Error on command %d \"%s\": %s\n",
+ command_index, command, message);
- key = meta_prefs_get_gconf_key_for_command (command_index);
+ /*
+ metacity-dialog said:
+
+ FIXME offer to change the value of the command's gconf key
+ */
- error_on_generic_command (key, command, message, screen_number, timestamp);
-
- g_free (key);
-}
+ if (command && strcmp(command, "")!=0)
+ {
+ char *text = g_strdup_printf (
+ /* Displayed when a keybinding which is
+ * supposed to launch a program fails.
+ */
+ _("There was an error running "
+ "<tt>%s</tt>:\n\n%s"),
+ command,
+ message);
-static void
-error_on_terminal_command (const char *command,
- const char *message,
- int screen_number,
- guint32 timestamp)
-{
- const char *key;
-
- meta_warning ("Error on terminal command \"%s\": %s\n", command, message);
+ meta_show_dialog ("--error",
+ text,
+ NULL,
+ screen_number,
+ NULL, NULL);
- key = meta_prefs_get_gconf_key_for_terminal_command ();
+ g_free (text);
- error_on_generic_command (key, command, message, screen_number, timestamp);
+ }
+ else
+ {
+ meta_show_dialog ("--error",
+ message,
+ NULL,
+ screen_number,
+ NULL, NULL);
+ }
}
static void
@@ -3497,7 +3469,7 @@ handle_run_terminal (MetaDisplay *display,
"keybinding press\n");
s = g_strdup_printf (_("No terminal command has been defined.\n"));
- error_on_terminal_command (NULL, s, screen->number, event->xkey.time);
+ error_on_command (-1, NULL, s, screen->number, event->xkey.time);
g_free (s);
return;
@@ -3506,8 +3478,8 @@ handle_run_terminal (MetaDisplay *display,
err = NULL;
if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{
- error_on_terminal_command (command, err->message, screen->number,
- event->xkey.time);
+ error_on_command (-1, command, err->message, screen->number,
+ event->xkey.time);
g_error_free (err);
}
diff --git a/src/core/util.c b/src/core/util.c
index e0da863..ca7df62 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -537,3 +537,75 @@ meta_gravity_to_string (int gravity)
break;
}
}
+
+void
+meta_show_dialog (const char *type,
+ const char *message,
+ const char *timeout,
+ const gint screen_number,
+ const char **columns,
+ const char **entries)
+{
+ GError *error = NULL;
+ char *screen_number_text = g_strdup_printf("%d", screen_number);
+
+ /*
+ We want:
+
+zenity --display X --screen S --title Metacity --error --text "There was an error running <tt>terminal</tt>:\n\nYour computer is on fire."
+ ** with no pipes
+
+zenity --display X --screen S --title Metacity --question --text "<big><b><tt>%s</tt> is not responding.</b></big>\n\n<i>You may choose to wait a short while for it to continue or force the application to quit entirely.</i>"
+
+zenity --display X --screen S --title Metacity --list --timeout 240 --text "These windows do not support \"save current setup\" and will have to be restarted manually next time you log in." --column "Window" --column "Class" "Firefox" "foo" "Duke Nukem Forever" "bar"
+ */
+
+ const char **argvl;
+ int i=0;
+ GPid child_pid;
+
+ argvl = g_malloc(sizeof (char*) *
+ (9 + (timeout?2:0))
+ );
+
+ argvl[i++] = "zenity";
+ argvl[i++] = type;
+ argvl[i++] = "--screen";
+ argvl[i++] = screen_number_text;
+ argvl[i++] = "--title";
+ /* Translators: This is the title used on dialog boxes */
+ argvl[i++] = _("Metacity");
+ argvl[i++] = "--text";
+ argvl[i++] = message;
+
+ if (timeout)
+ {
+ argvl[i++] = "--timeout";
+ argvl[i++] = timeout;
+ }
+
+ argvl[i] = NULL;
+
+ g_spawn_async_with_pipes (
+ "/",
+ (char**) argvl, /* ugh */
+ NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL, NULL,
+ &child_pid,
+ NULL, NULL, NULL,
+ &error
+ );
+
+ g_free (argvl);
+ g_free (screen_number_text);
+
+ if (error)
+ {
+ meta_warning ("%s\n", error->message);
+ g_error_free (error);
+ }
+}
+
+/* eof util.c */
+
diff --git a/src/include/util.h b/src/include/util.h
index 161ae93..5041f5e 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -97,6 +97,13 @@ char* meta_g_utf8_strndup (const gchar *src, gsize n);
void meta_free_gslist_and_elements (GSList *list_to_deep_free);
+void meta_show_dialog (const char *type,
+ const char *title,
+ const char *message,
+ gint timeout,
+ const char **columns,
+ const char **entries);
+
/* To disable verbose mode, we make these functions into no-ops */
#ifdef WITH_VERBOSE_MODE