]> www.fi.muni.cz Git - evince.git/commitdiff
Do not append the extension to filename when saving an image if the
authorCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 19 Mar 2008 16:24:50 +0000 (16:24 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Wed, 19 Mar 2008 16:24:50 +0000 (16:24 +0000)
2008-03-19  Carlos Garcia Campos  <carlosgc@gnome.org>

* 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

ChangeLog
shell/ev-window.c

index 7628ac216924e591d99e63eedeb4760b16f1be78..bf084c59e7d8df3e2771d6186a8ca4c42c9c8bd3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-19  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * 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  <carlosgc@gnome.org>
 
        * shell/ev-view.[ch]: (ev_view_find_cancel):
index 3431fad5cd0b3528f0a172d87bc243f29bcccff3..9b2dedeca5e82e5c85a6a22512ae990d3bdc9f42 100644 (file)
@@ -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);