From: Carlos Garcia Campos Date: Wed, 19 Mar 2008 16:24:50 +0000 (+0000) Subject: Do not append the extension to filename when saving an image if the X-Git-Tag: EVINCE_2_22_1~20 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=08a9f7ae85046d4b4434927a2f0fbe8642287089;p=evince.git Do not append the extension to filename when saving an image if the 2008-03-19 Carlos Garcia Campos * shell/ev-window.c: (image_save_dialog_response_cb): Do not append the extension to filename when saving an image if the filename alredy contains the extension. Fixes bug #523069. svn path=/trunk/; revision=2972 --- diff --git a/ChangeLog b/ChangeLog index 7628ac21..bf084c59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-03-19 Carlos Garcia Campos + + * shell/ev-window.c: (image_save_dialog_response_cb): + + Do not append the extension to filename when saving an image + if the filename alredy contains the extension. Fixes bug #523069. + 2008-03-18 Carlos Garcia Campos * shell/ev-view.[ch]: (ev_view_find_cancel): diff --git a/shell/ev-window.c b/shell/ev-window.c index 3431fad5..9b2dedec 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -4754,7 +4754,6 @@ image_save_dialog_response_cb (GtkWidget *fc, GError *error = NULL; GdkPixbuf *pixbuf; gchar *uri; - gchar *uri_extension; gchar **extensions; gchar *filename; gchar *file_format; @@ -4785,27 +4784,31 @@ image_save_dialog_response_cb (GtkWidget *fc, } extensions = gdk_pixbuf_format_get_extensions (format); - uri_extension = g_strconcat (uri, ".", extensions[0], NULL); + if (strcmp (extensions[0], uri + strlen (uri) - strlen (extensions[0])) != 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); - file_format = gdk_pixbuf_format_get_name (format); + g_free (uri); - target_file = g_file_new_for_uri (uri_extension); is_native = g_file_is_native (target_file); - if (is_native) { filename = g_file_get_path (target_file); } else { filename = ev_tmp_filename ("saveimage"); } - - g_free (uri); - g_free (uri_extension); ev_document_doc_mutex_lock (); pixbuf = ev_document_images_get_image (EV_DOCUMENT_IMAGES (ev_window->priv->document), ev_window->priv->image); ev_document_doc_mutex_unlock (); - + + file_format = gdk_pixbuf_format_get_name (format); gdk_pixbuf_save (pixbuf, filename, file_format, &error, NULL); g_free (file_format); g_object_unref (pixbuf);