Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-window.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2005-05-10 08:31:20 (GMT)
committer Marco Pesenti Gritti <marco@src.gnome.org>2005-05-10 08:31:20 (GMT)
commitf6813ee5f28316ee9ee4bbef262900fc7d8bb9ec (patch)
tree832f56d2b1677d00f6b8acaacec3a6a2b95d5979 /shell/ev-window.c
parent85c23b189d1c83d7c84774b4ecc09334316ca143 (diff)
Check for uri correctness/existence
2005-05-10 Marco Pesenti Gritti <mpg@redhat.com> * shell/ev-window.c: (sanity_check_uri), (ev_window_open): Check for uri correctness/existence
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index eeeb97b..253830a 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -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);