diff options
author | infirit <[email protected]> | 2014-12-10 01:28:09 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-10 01:28:09 +0100 |
commit | 36f3ee27bcfcae71eb52f96dce27971e7b5a2107 (patch) | |
tree | 0d733b5abff9e53c251c2fc0397a9ea2dc1a30a8 | |
parent | cfb8266907bd3e41c8375934ec1440f020dd52d5 (diff) | |
download | atril-36f3ee27bcfcae71eb52f96dce27971e7b5a2107.tar.bz2 atril-36f3ee27bcfcae71eb52f96dce27971e7b5a2107.tar.xz |
Check all extensions when saving an image to avoid adding the extension twice
Taken from evince commit: 62844084382c2c4fcf8baf960ce84d99b7b9093d
From: Carlos Garcia Campos <[email protected]>
Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=637461
-rw-r--r-- | shell/ev-window.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c index 69d6c986..e11dcc8f 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -6666,6 +6666,30 @@ ev_view_popup_cmd_copy_link_address (GtkAction *action, EvWindow *window) ev_action); } +static GFile * +create_file_from_uri_for_format (const gchar *uri, + GdkPixbufFormat *format) +{ + GFile *target_file; + gchar **extensions; + gchar *uri_extension; + gint i; + + extensions = gdk_pixbuf_format_get_extensions (format); + for (i = 0; extensions[i]; i++) { + if (g_str_has_suffix (uri, extensions[i])) { + g_strfreev (extensions); + return g_file_new_for_uri (uri); + } + } + + uri_extension = g_strconcat (uri, ".", extensions[0], NULL); + target_file = g_file_new_for_uri (uri_extension); + g_free (uri_extension); + g_strfreev (extensions); + + return target_file; +} static void image_save_dialog_response_cb (GtkWidget *fc, @@ -6677,7 +6701,6 @@ image_save_dialog_response_cb (GtkWidget *fc, GError *error = NULL; GdkPixbuf *pixbuf; gchar *uri; - gchar **extensions; gchar *filename; gchar *file_format; GdkPixbufFormat *format; @@ -6715,19 +6738,9 @@ image_save_dialog_response_cb (GtkWidget *fc, return; } - extensions = gdk_pixbuf_format_get_extensions (format); - if (!g_str_has_suffix (uri, extensions[0])) { - gchar *uri_extension; - - uri_extension = g_strconcat (uri, ".", extensions[0], NULL); - target_file = g_file_new_for_uri (uri_extension); - g_free (uri_extension); - } else { - target_file = g_file_new_for_uri (uri); - } - g_strfreev (extensions); + target_file = create_file_from_uri_for_format (uri, format); g_free (uri); - + is_native = g_file_is_native (target_file); if (is_native) { filename = g_file_get_path (target_file); |