]> www.fi.muni.cz Git - evince.git/commitdiff
Let GnomeVFS check the URL, this allow more URL (like mailto:), and report
authorPascal Terjan <pterjan@linuxfr.org>
Thu, 25 Oct 2007 06:01:57 +0000 (06:01 +0000)
committerPascal Terjan <pterjan@src.gnome.org>
Thu, 25 Oct 2007 06:01:57 +0000 (06:01 +0000)
2007-10-25  Pascal Terjan  <pterjan@linuxfr.org>

        * 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
shell/ev-window.c

index 87f92bbc875f9aef22e44d08b14bc618b161df9a..0485e7c71ef788ce3ad135332e165131ef58ee67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-25  Pascal Terjan  <pterjan@linuxfr.org>
+
+       * 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  <carlosgc@gnome.org>
 
        * backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin):
index cb09db468697f1e77aab13028134ee7950b7b241..8c0a19f85f10fdd168d58bbd6bfe095831a5b5b3 100644 (file)
@@ -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