diff options
author | Federico Mena Quintero <federico@ximian.com> | 2002-07-29 23:34:01 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2002-07-29 23:34:01 +0000 |
commit | 115ac611cf4dde8585e94e78662089f6ca0abc04 (patch) | |
tree | 183524b5b3b36cef4e7ca29d3a1f9c52b51aaa33 /shell | |
parent | b15e148d4a235fa9c7f39abf669c10ce3dc8872c (diff) | |
download | eog-115ac611cf4dde8585e94e78662089f6ca0abc04.tar.gz |
Fixes #89372.
2002-07-29 Federico Mena Quintero <federico@ximian.com>
Fixes #89372.
* shell/main.c (show_nonexistent_files): Oops,
gtk_message_dialog_new() takes a printf() format, so use it - if
our filenames contained percent characters, we would screw up.
(make_canonical_uri): Escape the filename before passing it to
gnome-vfs.
* shell/eog-window.c (eog_window_open_dialog): Likewise.
* shell/util.c (open_failure_dialog): Unescape the URI.
2002-07-29 Federico Mena Quintero <federico@ximian.com>
* libeog/image-view.c (image_view_scroll_event): Reverted
scrollwheel change. No modifiers means zoom, shift+wheel means
scroll, shift+control+wheel means scroll in the other direction.
Rationale: you can already scroll around the image by simply
dragging it around. Zooming is more useful, I think, so that you
can completely navigate around the image without ever touching the
keyboard.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/eog-window.c | 33 | ||||
-rw-r--r-- | shell/main.c | 53 | ||||
-rw-r--r-- | shell/util.c | 13 | ||||
-rw-r--r-- | shell/util.h | 2 |
4 files changed, 60 insertions, 41 deletions
diff --git a/shell/eog-window.c b/shell/eog-window.c index e1bd8dfa..5b6314df 100644 --- a/shell/eog-window.c +++ b/shell/eog-window.c @@ -289,8 +289,8 @@ activate_uri_cb (BonoboControlFrame *control_frame, const char *uri, gboolean re g_return_if_fail (uri != NULL); window = EOG_WINDOW (eog_window_new ()); - - if (g_ascii_strncasecmp ("file:", uri, 5) == 0) + + if (g_ascii_strncasecmp ("file:", uri, 5) == 0) path = g_strdup ((uri+5)); else path = g_strdup (uri); @@ -554,7 +554,8 @@ open_dnd_files (EogWindow *window, gboolean need_new_window) g_return_if_fail (EOG_IS_WINDOW (window)); - if (window->priv->dnd_files == NULL) return; + if (window->priv->dnd_files == NULL) + return; for (l = window->priv->dnd_files; l; l = l->next) { g_assert (l->data != NULL); @@ -715,9 +716,9 @@ eog_window_close (EogWindow *window) /* Open image dialog */ -/* Opens an image in a new window */ +/* Opens an image in a new window; takes in an escaped URI */ static void -open_new_window (EogWindow *window, const char *filename) +open_new_window (EogWindow *window, const char *text_uri) { EogWindowPrivate *priv; GtkWidget *new_window; @@ -729,11 +730,11 @@ open_new_window (EogWindow *window, const char *filename) else new_window = eog_window_new (); - if (eog_window_open (EOG_WINDOW (new_window), filename)) { + if (eog_window_open (EOG_WINDOW (new_window), text_uri)) { gtk_widget_show_now (new_window); raise_and_focus (new_window); } else { - open_failure_dialog (GTK_WINDOW (new_window), filename); + open_failure_dialog (GTK_WINDOW (new_window), text_uri); if (new_window != GTK_WIDGET (window)) gtk_widget_destroy (new_window); @@ -767,10 +768,16 @@ eog_window_open_dialog (EogWindow *window) gtk_widget_destroy (dlg); if (response == GTK_RESPONSE_OK) { + char *escaped; + + escaped = gnome_vfs_escape_path_string (filename); + if (gconf_client_get_bool (priv->client, "/apps/eog/window/open_new_window", NULL)) - open_new_window (window, filename); - else if (!eog_window_open (window, filename)) - open_failure_dialog (GTK_WINDOW (window), filename); + open_new_window (window, escaped); + else if (!eog_window_open (window, escaped)) + open_failure_dialog (GTK_WINDOW (window), escaped); + + g_free (escaped); } if (filename) @@ -1163,7 +1170,7 @@ add_control_to_ui (EogWindow *window, Bonobo_Control control) /** * window_open: * @window: A window. - * @filename: An path to the object to load (image/directory). + * @filename: An escaped text URI for the object to load. * * Opens an image file and puts it into a window. Even if loading fails, the * image structure will be created and put in the window. @@ -1195,10 +1202,8 @@ eog_window_open (EogWindow *window, const char *text_uri) GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS | GNOME_VFS_FILE_INFO_GET_MIME_TYPE); - if (result != GNOME_VFS_OK) { - g_warning ("Error while obtaining file informations."); + if (result != GNOME_VFS_OK) return FALSE; - } control = CORBA_OBJECT_NIL; diff --git a/shell/main.c b/shell/main.c index 59536889..205af800 100644 --- a/shell/main.c +++ b/shell/main.c @@ -53,24 +53,33 @@ create_app_list (gpointer data) } static GnomeVFSURI* -make_canonical_uri (const gchar *path) +make_canonical_uri (const char *path) { GnomeVFSURI *uri; - gchar *current_dir; - gchar *canonical; - gchar *concat_path; + char *escaped; + char *current_dir; + char *canonical; + char *concat_path; g_return_val_if_fail (path != NULL, NULL); - if (strchr (path, ':') != NULL) - return gnome_vfs_uri_new (path); + uri = NULL; - if (path[0] == '/') - return gnome_vfs_uri_new (path); + escaped = gnome_vfs_escape_path_string (path); + + if (strchr (escaped, ':') != NULL) { + uri = gnome_vfs_uri_new (escaped); + goto out; + } + + if (escaped[0] == '/') { + uri = gnome_vfs_uri_new (escaped); + goto out; + } current_dir = g_get_current_dir (); /* g_get_current_dir returns w/o trailing / */ - concat_path = g_strconcat (current_dir, "/", path, NULL); + concat_path = g_strconcat (current_dir, "/", escaped, NULL); canonical = gnome_vfs_make_path_name_canonical (concat_path); uri = gnome_vfs_uri_new (canonical); @@ -79,6 +88,8 @@ make_canonical_uri (const gchar *path) g_free (canonical); g_free (concat_path); + out: + g_free (escaped); return uri; } @@ -272,8 +283,8 @@ error_dialog_response_cb (GtkDialog *dialog, gint response_id) static void show_nonexistent_files (GList *error_list) { - char *str; char *msg; + char *str; int n; GtkWidget *dialog; @@ -282,25 +293,23 @@ show_nonexistent_files (GList *error_list) str = concat_string_list_with_newlines (error_list, &n); if (n == 1) - msg = g_strdup_printf (_("Could not access %s\n" - "Eye of Gnome will not be able to display this file."), - str); + msg = _("Could not access %s\n" + "Eye of Gnome will not be able to display this file."); else - msg = g_strdup_printf (_("The following files cannot be displayed " - "because Eye of Gnome was not able to " - "access them:\n" - "%s"), - str); - - g_free (str); + msg = _("The following files cannot be displayed " + "because Eye of Gnome was not able to " + "access them:\n" + "%s"); dialog = gtk_message_dialog_new ( NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CANCEL, - msg); - g_free (msg); + msg, + str); + + g_free (str); g_signal_connect (dialog, "response", G_CALLBACK (error_dialog_response_cb), diff --git a/shell/util.c b/shell/util.c index 21bff38c..fa3545e7 100644 --- a/shell/util.c +++ b/shell/util.c @@ -22,6 +22,7 @@ #include <config.h> #include <gtk/gtkmessagedialog.h> #include <libgnome/gnome-i18n.h> +#include <libgnomevfs/gnome-vfs-utils.h> #include "util.h" @@ -29,24 +30,28 @@ /** * open_failure_dialog: * @parent: Parent window for the dialog. - * @filename: Name of file that could not be loaded. + * @filename: URI that could not be loaded. * * Displays a dialog to indicate failure when loading a file. **/ void -open_failure_dialog (GtkWindow *parent, const char *filename) +open_failure_dialog (GtkWindow *parent, const char *text_uri) { GtkWidget *msg; + char *unescaped; - g_return_if_fail (filename != NULL); + g_return_if_fail (text_uri != NULL); g_return_if_fail (!parent || GTK_IS_WINDOW (parent)); + unescaped = gnome_vfs_unescape_string_for_display (text_uri); + msg = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not open `%s'"), - filename); + unescaped); + g_free (unescaped); gtk_dialog_run (GTK_DIALOG (msg)); diff --git a/shell/util.h b/shell/util.h index 7391331f..e95c81af 100644 --- a/shell/util.h +++ b/shell/util.h @@ -26,7 +26,7 @@ -void open_failure_dialog (GtkWindow *parent, const char *filename); +void open_failure_dialog (GtkWindow *parent, const char *text_uri); |