[gnome-control-center] background: Also look for items in ~/.cache



commit 87f05ef0edc0c41b7ae82b48629cf657c673a096
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 14 10:52:12 2011 +0000

    background: Also look for items in ~/.cache
    
    We'll be saving items in ~/.cache/gnome-control-center/backgrounds
    for the Flickr and manual additions of items, so look there as well.

 panels/background/bg-pictures-source.c |   34 ++++++++++++++++++++++---------
 panels/background/bg-pictures-source.h |    3 +-
 2 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 2c55eac..2a1f7c4 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -36,8 +36,6 @@ G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, BG_TYPE_SOURCE)
 
 struct _BgPicturesSourcePrivate
 {
-  GFile *dir;
-
   GCancellable *cancellable;
 
   GnomeDesktopThumbnailFactory *thumb_factory;
@@ -88,12 +86,6 @@ bg_pictures_source_dispose (GObject *object)
       priv->thumb_factory = NULL;
     }
 
-  if (priv->dir)
-    {
-      g_object_unref (priv->dir);
-      priv->dir = NULL;
-    }
-
   G_OBJECT_CLASS (bg_pictures_source_parent_class)->dispose (object);
 }
 
@@ -277,24 +269,46 @@ dir_enum_async_ready (GObject      *source,
                                       user_data);
 }
 
+char *
+bg_pictures_get_cache_path (void)
+{
+  return g_build_filename (g_get_user_cache_dir (),
+			   "gnome-control-center",
+			   "backgrounds",
+			   NULL);
+}
+
 static void
 bg_pictures_source_init (BgPicturesSource *self)
 {
   const gchar *pictures_path;
   BgPicturesSourcePrivate *priv;
+  GFile *dir;
+  char *cache_path;
+
   priv = self->priv = PICTURES_SOURCE_PRIVATE (self);
 
   priv->cancellable = g_cancellable_new ();
 
   pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
-  priv->dir = g_file_new_for_path (pictures_path);
+  dir = g_file_new_for_path (pictures_path);
+  g_file_enumerate_children_async (dir,
+                                   G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                                   G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                   G_FILE_QUERY_INFO_NONE,
+                                   G_PRIORITY_LOW, priv->cancellable,
+                                   dir_enum_async_ready, self);
+  g_object_unref (dir);
 
-  g_file_enumerate_children_async (priv->dir,
+  cache_path = bg_pictures_get_cache_path ();
+  dir = g_file_new_for_path (cache_path);
+  g_file_enumerate_children_async (dir,
                                    G_FILE_ATTRIBUTE_STANDARD_NAME ","
                                    G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
                                    G_FILE_QUERY_INFO_NONE,
                                    G_PRIORITY_LOW, priv->cancellable,
                                    dir_enum_async_ready, self);
+  g_object_unref (dir);
 
   priv->thumb_factory =
     gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
diff --git a/panels/background/bg-pictures-source.h b/panels/background/bg-pictures-source.h
index 0835202..79480be 100644
--- a/panels/background/bg-pictures-source.h
+++ b/panels/background/bg-pictures-source.h
@@ -69,7 +69,8 @@ struct _BgPicturesSourceClass
 
 GType bg_pictures_source_get_type (void) G_GNUC_CONST;
 
-BgPicturesSource *bg_pictures_source_new (void);
+BgPicturesSource *bg_pictures_source_new     (void);
+char             *bg_pictures_get_cache_path (void);
 
 G_END_DECLS
 



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