[gthumb] desktop background: fixed creation of a new filename



commit 24a1391b9b94769860933267b72beaeea7fa2d2b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Sep 18 18:47:52 2013 +0200

    desktop background: fixed creation of a new filename

 extensions/desktop_background/actions.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
index 7b1106c..257ce74 100644
--- a/extensions/desktop_background/actions.c
+++ b/extensions/desktop_background/actions.c
@@ -128,21 +128,24 @@ get_wallpaper_file_n (int n)
 
 
 static GFile *
-get_new_wallpaper_file (void)
+get_new_wallpaper_file (WallpaperData *wdata)
 {
        GFile *wallpaper_file;
+       int    i;
 
-       wallpaper_file = get_wallpaper_file_n (1);
-       if (g_file_query_exists (wallpaper_file, NULL)) {
-               /* Use a new filename to force an update. */
+       /* Use a new filename to force an update. */
 
+       wallpaper_file = NULL;
+       for (i = 1; i <= 2; i++) {
+               wallpaper_file = get_wallpaper_file_n (i);
+               if ((wdata->old_style.file != NULL) && g_file_equal (wallpaper_file, wdata->old_style.file))
+                       break;
                g_object_unref (wallpaper_file);
-
-               wallpaper_file = get_wallpaper_file_n (2);
-               if (g_file_query_exists (wallpaper_file, NULL))
-                       g_file_delete (wallpaper_file, NULL, NULL);
        }
 
+       if (wallpaper_file != NULL)
+               g_file_delete (wallpaper_file, NULL, NULL);
+
        return wallpaper_file;
 }
 
@@ -156,7 +159,7 @@ wallpaper_data_new (GthBrowser *browser)
        wdata->browser = browser;
        wallpaper_style_init_from_current (&wdata->old_style);
        wallpaper_style_init (&wdata->new_style);
-       wdata->new_style.file = get_new_wallpaper_file ();
+       wdata->new_style.file = get_new_wallpaper_file (wdata);
 
        return wdata;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]