[Xfce4-commits] <xfce-utils:xfce-4.8> Use entry icon to show spawn error (bug #7200).
Nick Schermer
noreply at xfce.org
Fri Jun 17 23:28:08 CEST 2011
Updating branch refs/heads/xfce-4.8
to 04f44271faec1005f6329219efe1f7ea4375119e (commit)
from 3bfa11aa7fb805286c5b6cfb633cdb28192baccc (commit)
commit 04f44271faec1005f6329219efe1f7ea4375119e
Author: Nick Schermer <nick at xfce.org>
Date: Fri Jun 17 20:22:56 2011 +0200
Use entry icon to show spawn error (bug #7200).
If gtk 2.16 is available, use entry icons to show error
messages when spawning failed.
(cherry picked from commit 1894922146c4e51521e4c7fe067392f0368cbb56)
xfrun/xfrun-dialog.c | 57 +++++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/xfrun/xfrun-dialog.c b/xfrun/xfrun-dialog.c
index c7f83ef..5cb44ff 100644
--- a/xfrun/xfrun-dialog.c
+++ b/xfrun/xfrun-dialog.c
@@ -511,6 +511,7 @@ xfrun_run_clicked(GtkWidget *widget,
gchar *new_cmdline;
gint argc;
gboolean manpage = FALSE;
+ gchar *primary;
cmdline = gtk_editable_get_chars(GTK_EDITABLE(dialog->priv->entry), 0, -1);
original_cmdline = g_strdup(cmdline);
@@ -557,9 +558,6 @@ xfrun_run_clicked(GtkWidget *widget,
xfrun_add_to_history(original_cmdline, manpage ? FALSE : in_terminal);
xfrun_dialog_delete_event(GTK_WIDGET(dialog), NULL);
} else {
- gchar *primary;
- gboolean exo_opened = FALSE;
-
if(!in_terminal
&& (exo_str_looks_like_an_uri (cmdline)
|| g_path_is_absolute (cmdline)
@@ -582,40 +580,43 @@ xfrun_run_clicked(GtkWidget *widget,
exo_argv, NULL, G_SPAWN_SEARCH_PATH,
xfrun_spawn_child_setup, NULL, NULL,
NULL)) {
- exo_opened = TRUE;
+ result = TRUE;
xfrun_add_to_history(original_cmdline, in_terminal);
xfrun_dialog_delete_event(GTK_WIDGET(dialog), NULL);
- g_error_free(error);
+ g_clear_error(&error);
}
g_strfreev(exo_argv);
}
-
- if(!exo_opened) {
- /* Display the first error */
- primary = g_strdup_printf(_("The command \"%s\" failed to run:"),
- cmdline);
- xfce_message_dialog(GTK_WINDOW(dialog), _("Run Error"),
- GTK_STOCK_DIALOG_ERROR, primary,
- error ? error->message : _("Unknown Error"),
- GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
- g_free(primary);
- if(error)
- g_error_free(error);
- }
- } else {
- primary = g_strdup_printf(_("The command \"%s\" failed to run:"),
- cmdline);
- xfce_message_dialog(GTK_WINDOW(dialog), _("Run Error"),
- GTK_STOCK_DIALOG_ERROR, primary,
- error ? error->message : _("Unknown Error"),
- GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
- g_free(primary);
- if(error)
- g_error_free(error);
}
}
+#if GTK_CHECK_VERSION (2, 16, 0)
+ if(!result) {
+ gchar *tmp = g_strdup_printf(_("The command \"%s\" failed to run:"), cmdline);
+ primary = g_markup_printf_escaped("<b>%s</b>\n\n%s", tmp, error ? error->message : _("Unknown Error"));
+ g_free(tmp);
+ } else
+ primary = NULL;
+
+ gtk_entry_set_icon_from_stock(GTK_ENTRY (dialog->priv->entry),
+ GTK_ENTRY_ICON_PRIMARY, result ? NULL : GTK_STOCK_DIALOG_ERROR);
+ gtk_entry_set_icon_tooltip_markup(GTK_ENTRY (dialog->priv->entry),
+ GTK_ENTRY_ICON_PRIMARY, primary);
+ g_free(primary);
+#else
+ if (!result) {
+ primary = g_strdup_printf(_("The command \"%s\" failed to run:"), cmdline);
+ xfce_message_dialog(GTK_WINDOW(dialog), _("Run Error"),
+ GTK_STOCK_DIALOG_ERROR, primary,
+ error ? error->message : _("Unknown Error"),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
+ g_free(primary);
+ }
+#endif
+
+ if(error)
+ g_error_free(error);
g_free(cmdline);
g_free(original_cmdline);
if(in_terminal)
More information about the Xfce4-commits
mailing list