]> www.fi.muni.cz Git - evince.git/commitdiff
Check for uri correctness/existence
authorMarco Pesenti Gritti <mpg@redhat.com>
Tue, 10 May 2005 08:31:20 +0000 (08:31 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Tue, 10 May 2005 08:31:20 +0000 (08:31 +0000)
2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-window.c: (sanity_check_uri), (ev_window_open):

        Check for uri correctness/existence

ChangeLog
shell/ev-window.c

index 2529d2a2f3ad51fff143a7f2980a3d8ed6205168..15a7d40bacf4b208d63a3206456d6d539e7aa2ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-window.c: (sanity_check_uri), (ev_window_open):
+
+       Check for uri correctness/existence
+
 2005-05-09  Juerg Billeter  <j@bitron.ch>
 
        * shell/ev-window.c: (using_postscript_printer):
index eeeb97b3e220ca2bfbc7809011523c907b851cee..253830a33d54eb94e2f53c95757c6db8c46ebf97 100644 (file)
@@ -59,6 +59,7 @@
 
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 
 #include <gconf/gconf-client.h>
@@ -749,6 +750,29 @@ start_loading_document (EvWindow   *ev_window,
        return FALSE;
 }
 
+static gboolean
+sanity_check_uri (EvWindow *window, const char *uri)
+{
+       gboolean result = FALSE;
+       GnomeVFSURI *vfs_uri;
+       char *err;
+
+       vfs_uri = gnome_vfs_uri_new (uri);
+       if (vfs_uri) {
+               if (gnome_vfs_uri_exists (vfs_uri)) {
+                       result = TRUE;
+               }
+       }
+
+       if (!result) {
+               err = g_strdup_printf (_("The file %s does not exist."), uri);
+               unable_to_load (window, err);
+               g_free (err);
+       }
+
+       return result;
+}
+
 void
 ev_window_open (EvWindow *ev_window, const char *uri)
 {
@@ -756,6 +780,10 @@ ev_window_open (EvWindow *ev_window, const char *uri)
        GType document_type;
        char *mime_type = NULL;
 
+       if (!sanity_check_uri (ev_window, uri)) {
+               return;
+       }
+
        g_free (ev_window->priv->uri);
        ev_window->priv->uri = g_strdup (uri);