From: Marco Pesenti Gritti Date: Tue, 10 May 2005 08:31:20 +0000 (+0000) Subject: Check for uri correctness/existence X-Git-Tag: EVINCE_0_3_1~48 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f6813ee5f28316ee9ee4bbef262900fc7d8bb9ec;p=evince.git Check for uri correctness/existence 2005-05-10 Marco Pesenti Gritti * shell/ev-window.c: (sanity_check_uri), (ev_window_open): Check for uri correctness/existence --- diff --git a/ChangeLog b/ChangeLog index 2529d2a2..15a7d40b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-10 Marco Pesenti Gritti + + * shell/ev-window.c: (sanity_check_uri), (ev_window_open): + + Check for uri correctness/existence + 2005-05-09 Juerg Billeter * shell/ev-window.c: (using_postscript_printer): diff --git a/shell/ev-window.c b/shell/ev-window.c index eeeb97b3..253830a3 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -59,6 +59,7 @@ #include #include +#include #include #include @@ -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);