[gnome-terminal] Change terminal_util_show_error_dialog to take a GError
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-terminal] Change terminal_util_show_error_dialog to take a GError
- Date: Sun, 26 Jul 2009 11:28:28 +0000 (UTC)
commit 5211261b6f401e1dab094d597c47792ba4ef4332
Author: Christian Persch <chpe gnome org>
Date: Sun Jul 26 13:06:10 2009 +0200
Change terminal_util_show_error_dialog to take a GError
Instead of passing the error->message by the format arguments using %s in the
format, pass the GError directly and format it as secondary text.
src/skey-popup.c | 4 ++--
src/terminal-screen.c | 5 +++--
src/terminal-util.c | 23 +++++++++++++++--------
src/terminal-util.h | 3 ++-
src/terminal.c | 5 ++---
5 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/src/skey-popup.c b/src/skey-popup.c
index 415c267..4ec5a5e 100644
--- a/src/skey-popup.c
+++ b/src/skey-popup.c
@@ -160,7 +160,7 @@ terminal_skey_do_popup (GtkWindow *window,
{
if (!extract_seq_and_seed (skey_match, &seq, &seed))
{
- terminal_util_show_error_dialog (window, NULL,
+ terminal_util_show_error_dialog (window, NULL, NULL,
_("The text you clicked on doesn't "
"seem to be a valid S/Key "
"challenge."));
@@ -171,7 +171,7 @@ terminal_skey_do_popup (GtkWindow *window,
{
if (!extract_hash_seq_and_seed (skey_match, &hash, &seq, &seed))
{
- terminal_util_show_error_dialog (window, NULL,
+ terminal_util_show_error_dialog (window, NULL, NULL,
_("The text you clicked on doesn't "
"seem to be a valid OTP "
"challenge."));
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 472dfbc..e463218 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -1272,8 +1272,8 @@ show_command_error_dialog (TerminalScreen *screen,
{
g_assert (error != NULL);
- terminal_util_show_error_dialog ((GtkWindow*) gtk_widget_get_ancestor (GTK_WIDGET (screen), GTK_TYPE_WINDOW), NULL,
- _("There was a problem with the command for this terminal: %s"), error->message);
+ terminal_util_show_error_dialog ((GtkWindow*) gtk_widget_get_ancestor (GTK_WIDGET (screen), GTK_TYPE_WINDOW), NULL, error,
+ "%s", _("There was a problem with the command for this terminal"));
}
static gboolean
@@ -1577,6 +1577,7 @@ terminal_screen_launch_child (TerminalScreen *screen)
{
terminal_util_show_error_dialog ((GtkWindow*) gtk_widget_get_ancestor (GTK_WIDGET (screen), GTK_TYPE_WINDOW), NULL,
+ error,
"%s", _("There was an error creating the child process for this terminal"));
}
diff --git a/src/terminal-util.c b/src/terminal-util.c
index a8103ce..5813468 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -57,6 +57,7 @@ terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
* terminal_util_show_error_dialog:
* @transient_parent: parent of the future dialog window;
* @weap_ptr: pointer to a #Widget pointer, to control the population.
+ * @error: a #GError, or %NULL
* @message_format: printf() style format string
*
* Create a #GtkMessageDialog window with the message, and present it, handling its buttons.
@@ -65,9 +66,12 @@ terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
* present <literal>*weak_ptr</literal>. Note that in this last case, the message <emph>will</emph>
* be changed.
*/
-
void
-terminal_util_show_error_dialog (GtkWindow *transient_parent, GtkWidget **weak_ptr, const char *message_format, ...)
+terminal_util_show_error_dialog (GtkWindow *transient_parent,
+ GtkWidget **weak_ptr,
+ GError *error,
+ const char *message_format,
+ ...)
{
char *message;
va_list args;
@@ -90,6 +94,10 @@ terminal_util_show_error_dialog (GtkWindow *transient_parent, GtkWidget **weak_p
message ? "%s" : NULL,
message);
+ if (error != NULL)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", error->message);
+
g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL);
if (weak_ptr != NULL)
@@ -169,9 +177,8 @@ terminal_util_show_help (const char *topic,
if (!open_url (GTK_WINDOW (parent), url, gtk_get_current_event_time (), &error))
{
- terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL,
- _("There was an error displaying help: %s"),
- error->message);
+ terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL, error,
+ _("There was an error displaying help"));
g_error_free (error);
}
@@ -243,9 +250,9 @@ terminal_util_open_url (GtkWidget *parent,
if (!open_url (GTK_WINDOW (parent), uri, user_time, &error))
{
- terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL,
- _("Could not open the address â??%sâ??:\n%s"),
- uri, error->message);
+ terminal_util_show_error_dialog (GTK_WINDOW (parent), NULL, error,
+ _("Could not open the address â??%sâ??"),
+ uri);
g_error_free (error);
}
diff --git a/src/terminal-util.h b/src/terminal-util.h
index 8c10517..5480634 100644
--- a/src/terminal-util.h
+++ b/src/terminal-util.h
@@ -30,7 +30,8 @@ void terminal_util_set_unique_role (GtkWindow *window, const char *prefix);
void terminal_util_show_error_dialog (GtkWindow *transient_parent,
GtkWidget **weap_ptr,
- const char *message_format, ...) G_GNUC_PRINTF(3, 4);
+ GError *error,
+ const char *message_format, ...) G_GNUC_PRINTF(4, 5);
void terminal_util_show_help (const char *topic, GtkWindow *transient_parent);
diff --git a/src/terminal.c b/src/terminal.c
index aaf072a..41285e5 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -191,9 +191,8 @@ about_url_hook (GtkAboutDialog *about,
gtk_get_current_event_time (),
&error))
{
- terminal_util_show_error_dialog (GTK_WINDOW (about), NULL,
- _("Could not open link: %s"),
- error->message);
+ terminal_util_show_error_dialog (GTK_WINDOW (about), NULL, error,
+ "%s", _("Could not open link"));
g_error_free (error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]