From e0610b2e0cea191f631dc825cdc8023cdcd9433d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 11 Jan 2009 14:20:50 +0000 Subject: Continue chipping away at EMFolderView and EMFolderBrowser. Migrate from gnome_url_show() to e_show_uri(). svn path=/branches/kill-bonobo/; revision=37038 --- e-util/e-util.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'e-util/e-util.c') diff --git a/e-util/e-util.c b/e-util/e-util.c index 148d89a414..a5e6c6b548 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 -- cgit v1.2.3