From 74fd0c3667f1e2cf5f59b2f0da3f4b31866ea79f Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Thu, 25 Oct 2007 06:01:57 +0000 Subject: [PATCH] Let GnomeVFS check the URL, this allow more URL (like mailto:), and report 2007-10-25 Pascal Terjan * shell/ev-window.c: (launch_external_uri): Let GnomeVFS check the URL, this allow more URL (like mailto:), and report error if the URL is not supported (#489910). svn path=/trunk/; revision=2718 --- ChangeLog | 7 +++++++ shell/ev-window.c | 40 ++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87f92bbc..0485e7c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-25 Pascal Terjan + + * shell/ev-window.c: (launch_external_uri): + + Let GnomeVFS check the URL, this allow more URL (like mailto:), + and report error if the URL is not supported (#489910). + 2007-10-22 Carlos Garcia Campos * backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin): diff --git a/shell/ev-window.c b/shell/ev-window.c index cb09db46..8c0a19f8 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -4728,45 +4728,41 @@ launch_action (EvWindow *window, EvLinkAction *action) allowing to launch executables is a good idea though. -- marco */ } -static gboolean -uri_is_valid (const gchar *uri) -{ - gchar *p = (gchar *) uri; - - if (!p || !g_ascii_isalpha (*p)) - return FALSE; - - p++; - while (g_ascii_isalnum (*p)) - p++; - - return (g_ascii_strncasecmp (p, "://", strlen ("://")) == 0); -} - static void launch_external_uri (EvWindow *window, EvLinkAction *action) { const gchar *uri = ev_link_action_get_uri (action); - - if (!uri_is_valid (uri)) { - GtkWidget *dialog; + GnomeVFSResult result = gnome_vfs_url_show (uri); + GtkWidget *dialog; + gchar* message = NULL; + switch(result) { + case GNOME_VFS_OK: + break; + case GNOME_VFS_ERROR_BAD_PARAMETERS: + message = _("Invalid URI: “%s”"); + break; + case GNOME_VFS_ERROR_NOT_SUPPORTED: + message = _("Unsupported URI: “%s”"); + break; + default: + message = _("Unknown error"); + } + if(message) { dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Unable to open external link")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - _("Invalid URI: “%s”"), uri); + message, uri); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (dialog); - return; } - - gnome_vfs_url_show (uri); + return; } static void -- 2.43.5