From 2b820fc4e2d6404ca281e279761cd5f877fdbf54 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 11 Jan 2009 13:55:04 +0000 Subject: New convenience function calls gtk_show_uri() and displays an error dialog 2009-01-11 Matthew Barnes * e-util/e-util.c (e_show_uri): New convenience function calls gtk_show_uri() and displays an error dialog if the URI cannot be shown. * addressbook/gui/widgets/eab-contact-display.c (eab_uri_popup_link_open), (on_link_clicked): * calendar/gui/e-cal-component-preview (on_link_clicked): * calendar/gui/e-cal-component-memo-preview (on_link_clicked): * calendar/gui/e-memo-table.c (open_url_cb): * calendar/gui/dialogs/comp-editor.c (open_attachment): * composer/e-msg-composer.c (msg_composer_link_clicked): * mail/em-folder-view.c (emfv_format_link_clicked): * mail/em-popup.c (emp_uri_popup_link_open): * plugins/mailing-list-actions/mailing-list-actions.c (emla_list_action_do): * shell/e-shell-window-commands.c (command_open_faq): * widgets/misc/e-attachment-bar.c (eab_icon_clicked_cb): * widgets/misc/e-url-entry.c (button_clicked_cb): Call e_show_uri() instead of gnome_url_show(). * e-util/e-error.c (ee_response): Call e_display_help() instead of gnome_url_show(). * mail/em-config.c: * mail/em-menu.c: Remove unneeded #include svn path=/trunk/; revision=37037 --- e-util/ChangeLog | 9 +++++++++ e-util/e-error.c | 10 ++-------- e-util/e-util.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ e-util/e-util.h | 2 ++ 4 files changed, 57 insertions(+), 8 deletions(-) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index a23eb07533..365589f575 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,12 @@ +2009-01-11 Matthew Barnes + + * e-error.c (ee_response): + Call e_display_help() instead of gnome_url_show(). + + * e-util.c (e_show_uri): + New convenience function calls gtk_show_uri() and displays an + error dialog if the URI cannot be shown. + 2009-01-10 Matthew Barnes * e-dialog-utils.c: diff --git a/e-util/e-error.c b/e-util/e-error.c index 763a9ca540..da4d034606 100644 --- a/e-util/e-error.c +++ b/e-util/e-error.c @@ -30,10 +30,10 @@ #include #include -#include #include +#include "e-util.h" #include "e-util-private.h" #include "e-error.h" @@ -395,15 +395,9 @@ ee_build_label(GString *out, const char *fmt, GPtrArray *args, static void ee_response(GtkWidget *w, guint button, struct _e_error *e) { - GError *err = NULL; - if (button == GTK_RESPONSE_HELP) { g_signal_stop_emission_by_name(w, "response"); - gnome_url_show(e->help_uri, &err); - if (err) { - g_warning("Unable to run help uri: %s", err->message); - g_error_free(err); - } + e_display_help (GTK_WINDOW (w), e->help_uri); } } diff --git a/e-util/e-util.c b/e-util/e-util.c index 0e43f092b2..d4bded2d6b 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -91,6 +91,50 @@ e_get_accels_filename (void) return filename; } +/** + * e_show_uri: + * @parent: a parent #GtkWindow or %NULL + * @uri: the URI to show + * + * Launches the default application to show the given URI. The URI must + * be of a form understood by GIO. If the URI cannot be shown, it presents + * a dialog describing the error. The dialog is set as transient to @parent + * if @parent is non-%NULL. + **/ +void +e_show_uri (GtkWindow *parent, + const gchar *uri) +{ + GtkWidget *dialog; + GdkScreen *screen = NULL; + GError *error = NULL; + guint32 timestamp; + + g_return_if_fail (uri != NULL); + + timestamp = gtk_get_current_event_time (); + + if (parent != NULL) + screen = gtk_widget_get_screen (GTK_WIDGET (parent)); + + if (gtk_show_uri (screen, uri, timestamp, &error)) + return; + + dialog = gtk_message_dialog_new_with_markup ( + parent, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + "%s", + _("Could not open the link.")); + + gtk_message_dialog_format_secondary_text ( + GTK_MESSAGE_DIALOG (dialog), "%s", error->message); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_destroy (dialog); + g_error_free (error); +} + /** * e_display_help: * @parent: a parent #GtkWindow or %NULL diff --git a/e-util/e-util.h b/e-util/e-util.h index e2eafacd75..4f82df471b 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -42,6 +42,8 @@ typedef enum { const gchar * e_get_user_data_dir (void); const gchar * e_get_accels_filename (void); +void e_show_uri (GtkWindow *parent, + const gchar *uri); void e_display_help (GtkWindow *parent, const gchar *link_id); -- cgit