background: derive background sources from a common source object
Add the BgSource object to define the common aspects of background sources and make sure the existing sources inherit from it.
This commit is contained in:
parent
ef9afe4830
commit
abdb42e9e2
13 changed files with 265 additions and 151 deletions
|
@ -23,6 +23,8 @@ libbackground_la_SOURCES = \
|
|||
background-module.c \
|
||||
cc-background-panel.c \
|
||||
cc-background-panel.h \
|
||||
bg-source.c \
|
||||
bg-source.h \
|
||||
bg-pictures-source.c \
|
||||
bg-pictures-source.h \
|
||||
bg-wallpapers-source.c \
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
<column type="guint"/>
|
||||
<!-- column-name readonly -->
|
||||
<column type="gboolean"/>
|
||||
<!-- column-name source-pointer -->
|
||||
<column type="gpointer"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkVBox" id="background-panel">
|
||||
|
|
|
@ -27,46 +27,14 @@
|
|||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, BG_TYPE_SOURCE)
|
||||
|
||||
#define COLORS_SOURCE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_COLORS_SOURCE, BgColorsSourcePrivate))
|
||||
|
||||
struct _BgColorsSourcePrivate
|
||||
{
|
||||
GtkListStore *store;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
bg_colors_source_dispose (GObject *object)
|
||||
{
|
||||
BgColorsSourcePrivate *priv = BG_COLORS_SOURCE (object)->priv;
|
||||
|
||||
if (priv->store)
|
||||
{
|
||||
g_object_unref (priv->store);
|
||||
priv->store = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (bg_colors_source_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
bg_colors_source_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (bg_colors_source_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
bg_colors_source_class_init (BgColorsSourceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (BgColorsSourcePrivate));
|
||||
|
||||
object_class->dispose = bg_colors_source_dispose;
|
||||
object_class->finalize = bg_colors_source_finalize;
|
||||
}
|
||||
|
||||
static gchar *colors[] =
|
||||
|
@ -103,13 +71,10 @@ static void
|
|||
bg_colors_source_init (BgColorsSource *self)
|
||||
{
|
||||
GnomeDesktopThumbnailFactory *thumb_factory;
|
||||
BgColorsSourcePrivate *priv;
|
||||
gchar **c, **n;
|
||||
GtkListStore *store;
|
||||
|
||||
|
||||
priv = self->priv = COLORS_SOURCE_PRIVATE (self);
|
||||
|
||||
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
|
||||
store = bg_source_get_liststore (BG_SOURCE (self));
|
||||
|
||||
thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
|
@ -136,7 +101,7 @@ bg_colors_source_init (BgColorsSource *self)
|
|||
pixbuf = gnome_wp_item_get_thumbnail (item,
|
||||
thumb_factory,
|
||||
100, 75);
|
||||
gtk_list_store_insert_with_values (priv->store, NULL, 0,
|
||||
gtk_list_store_insert_with_values (store, NULL, 0,
|
||||
0, pixbuf,
|
||||
1, item,
|
||||
-1);
|
||||
|
@ -151,8 +116,3 @@ bg_colors_source_new (void)
|
|||
return g_object_new (BG_TYPE_COLORS_SOURCE, NULL);
|
||||
}
|
||||
|
||||
GtkListStore *
|
||||
bg_colors_source_get_liststore (BgColorsSource *source)
|
||||
{
|
||||
return source->priv->store;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define _BG_COLORS_SOURCE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "bg-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -51,24 +52,20 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _BgColorsSource BgColorsSource;
|
||||
typedef struct _BgColorsSourceClass BgColorsSourceClass;
|
||||
typedef struct _BgColorsSourcePrivate BgColorsSourcePrivate;
|
||||
|
||||
struct _BgColorsSource
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
BgColorsSourcePrivate *priv;
|
||||
BgSource parent;
|
||||
};
|
||||
|
||||
struct _BgColorsSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
BgSourceClass parent_class;
|
||||
};
|
||||
|
||||
GType bg_colors_source_get_type (void) G_GNUC_CONST;
|
||||
|
||||
BgColorsSource *bg_colors_source_new (void);
|
||||
GtkListStore * bg_colors_source_get_liststore (BgColorsSource *source);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -28,15 +28,13 @@
|
|||
|
||||
#include "gnome-wp-item.h"
|
||||
|
||||
G_DEFINE_TYPE (BgFlickrSource, bg_flickr_source, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (BgFlickrSource, bg_flickr_source, BG_TYPE_SOURCE)
|
||||
|
||||
#define FLICKR_SOURCE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_FLICKR_SOURCE, BgFlickrSourcePrivate))
|
||||
|
||||
struct _BgFlickrSourcePrivate
|
||||
{
|
||||
GtkListStore *store;
|
||||
|
||||
SwClient *client;
|
||||
SwClientService *service;
|
||||
};
|
||||
|
@ -47,12 +45,6 @@ bg_flickr_source_dispose (GObject *object)
|
|||
{
|
||||
BgFlickrSourcePrivate *priv = BG_FLICKR_SOURCE (object)->priv;
|
||||
|
||||
if (priv->store)
|
||||
{
|
||||
g_object_unref (priv->store);
|
||||
priv->store = NULL;
|
||||
}
|
||||
|
||||
if (priv->client)
|
||||
{
|
||||
g_object_unref (priv->client);
|
||||
|
@ -91,7 +83,8 @@ _view_items_added_cb (SwClientItemView *item_view,
|
|||
gpointer userdata)
|
||||
{
|
||||
GList *l;
|
||||
BgFlickrSourcePrivate *priv = (BgFlickrSourcePrivate *) userdata;
|
||||
BgFlickrSource *source = (BgFlickrSource *) userdata;
|
||||
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
|
||||
|
||||
for (l = items; l; l = l->next)
|
||||
{
|
||||
|
@ -119,7 +112,7 @@ _view_items_added_cb (SwClientItemView *item_view,
|
|||
thumb_url = sw_item_get_value (sw_item, "thumbnail");
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb_url, 100, 75, TRUE,
|
||||
NULL);
|
||||
gtk_list_store_insert_with_values (priv->store, NULL, 0,
|
||||
gtk_list_store_insert_with_values (store, NULL, 0,
|
||||
0, pixbuf,
|
||||
1, item,
|
||||
-1);
|
||||
|
@ -159,14 +152,10 @@ bg_flickr_source_init (BgFlickrSource *self)
|
|||
"feed",
|
||||
NULL,
|
||||
_query_open_view_cb,
|
||||
priv);
|
||||
|
||||
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
|
||||
self);
|
||||
|
||||
thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
|
||||
|
||||
g_object_unref (thumb_factory);
|
||||
}
|
||||
|
||||
|
@ -176,8 +165,3 @@ bg_flickr_source_new (void)
|
|||
return g_object_new (BG_TYPE_FLICKR_SOURCE, NULL);
|
||||
}
|
||||
|
||||
GtkListStore *
|
||||
bg_flickr_source_get_liststore (BgFlickrSource *source)
|
||||
{
|
||||
return source->priv->store;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define _BG_FLICKR_SOURCE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "bg-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -55,20 +56,19 @@ typedef struct _BgFlickrSourcePrivate BgFlickrSourcePrivate;
|
|||
|
||||
struct _BgFlickrSource
|
||||
{
|
||||
GObject parent;
|
||||
BgSource parent;
|
||||
|
||||
BgFlickrSourcePrivate *priv;
|
||||
};
|
||||
|
||||
struct _BgFlickrSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
BgSourceClass parent_class;
|
||||
};
|
||||
|
||||
GType bg_flickr_source_get_type (void) G_GNUC_CONST;
|
||||
|
||||
BgFlickrSource *bg_flickr_source_new (void);
|
||||
GtkListStore * bg_flickr_source_get_liststore (BgFlickrSource *source);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -29,15 +29,13 @@
|
|||
#include <libgnomeui/gnome-desktop-thumbnail.h>
|
||||
|
||||
|
||||
G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, BG_TYPE_SOURCE)
|
||||
|
||||
#define PICTURES_SOURCE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_PICTURES_SOURCE, BgPicturesSourcePrivate))
|
||||
|
||||
struct _BgPicturesSourcePrivate
|
||||
{
|
||||
GtkListStore *liststore;
|
||||
|
||||
GFile *dir;
|
||||
|
||||
GCancellable *cancellable;
|
||||
|
@ -84,12 +82,6 @@ bg_pictures_source_dispose (GObject *object)
|
|||
priv->cancellable = NULL;
|
||||
}
|
||||
|
||||
if (priv->liststore)
|
||||
{
|
||||
g_object_unref (priv->liststore);
|
||||
priv->liststore = NULL;
|
||||
}
|
||||
|
||||
if (priv->thumb_factory)
|
||||
{
|
||||
g_object_unref (priv->thumb_factory);
|
||||
|
@ -129,11 +121,13 @@ file_info_async_ready (GObject *source,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
BgPicturesSourcePrivate *priv = BG_PICTURES_SOURCE (user_data)->priv;
|
||||
BgPicturesSource *bg_source = BG_PICTURES_SOURCE (user_data);
|
||||
BgPicturesSourcePrivate *priv = bg_source->priv;
|
||||
GList *files, *l;
|
||||
GError *err = NULL;
|
||||
GFile *parent;
|
||||
gchar *path;
|
||||
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (bg_source));
|
||||
|
||||
files = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source),
|
||||
res,
|
||||
|
@ -192,14 +186,14 @@ file_info_async_ready (GObject *source,
|
|||
/* insert the item into the liststore */
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, 100, 75, TRUE,
|
||||
NULL);
|
||||
gtk_list_store_insert_with_values (priv->liststore, &iter, 0,
|
||||
gtk_list_store_insert_with_values (store, &iter, 0,
|
||||
0, pixbuf,
|
||||
1, item,
|
||||
-1);
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->liststore),
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store),
|
||||
&iter);
|
||||
item->rowref =
|
||||
gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->liststore),
|
||||
gtk_tree_row_reference_new (GTK_TREE_MODEL (store),
|
||||
tree_path);
|
||||
gtk_tree_path_free (tree_path);
|
||||
|
||||
|
@ -247,9 +241,6 @@ bg_pictures_source_init (BgPicturesSource *self)
|
|||
BgPicturesSourcePrivate *priv;
|
||||
priv = self->priv = PICTURES_SOURCE_PRIVATE (self);
|
||||
|
||||
|
||||
priv->liststore = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
|
||||
|
||||
priv->cancellable = g_cancellable_new ();
|
||||
|
||||
pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
|
||||
|
@ -273,8 +264,3 @@ bg_pictures_source_new (void)
|
|||
return g_object_new (BG_TYPE_PICTURES_SOURCE, NULL);
|
||||
}
|
||||
|
||||
GtkListStore*
|
||||
bg_pictures_source_get_liststore (BgPicturesSource *source)
|
||||
{
|
||||
return source->priv->liststore;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define _BG_PICTURES_SOURCE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "bg-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -56,20 +57,19 @@ typedef struct _BgPicturesSourcePrivate BgPicturesSourcePrivate;
|
|||
|
||||
struct _BgPicturesSource
|
||||
{
|
||||
GObject parent;
|
||||
BgSource parent;
|
||||
|
||||
BgPicturesSourcePrivate *priv;
|
||||
};
|
||||
|
||||
struct _BgPicturesSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
BgSourceClass parent_class;
|
||||
};
|
||||
|
||||
GType bg_pictures_source_get_type (void) G_GNUC_CONST;
|
||||
|
||||
BgPicturesSource *bg_pictures_source_new (void);
|
||||
GtkListStore *bg_pictures_source_get_liststore (BgPicturesSource *source);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
129
panels/background/bg-source.c
Normal file
129
panels/background/bg-source.c
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Intel, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bg-source.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (BgSource, bg_source, G_TYPE_OBJECT)
|
||||
|
||||
#define SOURCE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_SOURCE, BgSourcePrivate))
|
||||
|
||||
struct _BgSourcePrivate
|
||||
{
|
||||
GtkListStore *store;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_LISTSTORE = 1
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
bg_source_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
BgSource *source = BG_SOURCE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_LISTSTORE:
|
||||
g_value_set_object (value, bg_source_get_liststore (source));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bg_source_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bg_source_dispose (GObject *object)
|
||||
{
|
||||
BgSourcePrivate *priv = BG_SOURCE (object)->priv;
|
||||
|
||||
if (priv->store)
|
||||
{
|
||||
g_object_unref (priv->store);
|
||||
priv->store = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (bg_source_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
bg_source_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (bg_source_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
bg_source_class_init (BgSourceClass *klass)
|
||||
{
|
||||
GParamSpec *pspec;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (BgSourcePrivate));
|
||||
|
||||
object_class->get_property = bg_source_get_property;
|
||||
object_class->set_property = bg_source_set_property;
|
||||
object_class->dispose = bg_source_dispose;
|
||||
object_class->finalize = bg_source_finalize;
|
||||
|
||||
pspec = g_param_spec_object ("liststore",
|
||||
"Liststore",
|
||||
"Liststore used in the source",
|
||||
GTK_TYPE_LIST_STORE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (object_class, PROP_LISTSTORE, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
bg_source_init (BgSource *self)
|
||||
{
|
||||
BgSourcePrivate *priv;
|
||||
|
||||
priv = self->priv = SOURCE_PRIVATE (self);
|
||||
|
||||
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
GtkListStore*
|
||||
bg_source_get_liststore (BgSource *source)
|
||||
{
|
||||
g_return_val_if_fail (BG_IS_SOURCE (source), NULL);
|
||||
|
||||
return source->priv->store;
|
||||
}
|
73
panels/background/bg-source.h
Normal file
73
panels/background/bg-source.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Intel, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Thomas Wood <thomas.wood@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BG_SOURCE_H
|
||||
#define _BG_SOURCE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define BG_TYPE_SOURCE bg_source_get_type()
|
||||
|
||||
#define BG_SOURCE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
BG_TYPE_SOURCE, BgSource))
|
||||
|
||||
#define BG_SOURCE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
BG_TYPE_SOURCE, BgSourceClass))
|
||||
|
||||
#define BG_IS_SOURCE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||
BG_TYPE_SOURCE))
|
||||
|
||||
#define BG_IS_SOURCE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||
BG_TYPE_SOURCE))
|
||||
|
||||
#define BG_SOURCE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
BG_TYPE_SOURCE, BgSourceClass))
|
||||
|
||||
typedef struct _BgSource BgSource;
|
||||
typedef struct _BgSourceClass BgSourceClass;
|
||||
typedef struct _BgSourcePrivate BgSourcePrivate;
|
||||
|
||||
struct _BgSource
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
BgSourcePrivate *priv;
|
||||
};
|
||||
|
||||
struct _BgSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType bg_source_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkListStore* bg_source_get_liststore (BgSource *source);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _BG_SOURCE_H */
|
|
@ -29,7 +29,7 @@
|
|||
#include <libgnomeui/gnome-desktop-thumbnail.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_DEFINE_TYPE (BgWallpapersSource, bg_wallpapers_source, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (BgWallpapersSource, bg_wallpapers_source, BG_TYPE_SOURCE)
|
||||
|
||||
#define WALLPAPERS_SOURCE_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_WALLPAPERS_SOURCE, BgWallpapersSourcePrivate))
|
||||
|
@ -72,12 +72,6 @@ bg_wallpapers_source_dispose (GObject *object)
|
|||
{
|
||||
BgWallpapersSourcePrivate *priv = BG_WALLPAPERS_SOURCE (object)->priv;
|
||||
|
||||
if (priv->store)
|
||||
{
|
||||
g_object_unref (priv->store);
|
||||
priv->store = NULL;
|
||||
}
|
||||
|
||||
if (priv->thumb_factory)
|
||||
{
|
||||
g_object_unref (priv->thumb_factory);
|
||||
|
@ -160,24 +154,26 @@ item_changed_cb (GnomeBG *bg,
|
|||
|
||||
|
||||
static void
|
||||
load_wallpapers (gchar *key,
|
||||
GnomeWPItem *item,
|
||||
BgWallpapersSourcePrivate *priv)
|
||||
load_wallpapers (gchar *key,
|
||||
GnomeWPItem *item,
|
||||
BgWallpapersSource *source)
|
||||
{
|
||||
BgWallpapersSourcePrivate *priv = source->priv;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
|
||||
|
||||
if (item->deleted == TRUE)
|
||||
return;
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (priv->store), &iter);
|
||||
gtk_list_store_append (store, &iter);
|
||||
|
||||
pixbuf = gnome_wp_item_get_thumbnail (item, priv->thumb_factory,
|
||||
100, 75);
|
||||
gnome_wp_item_update_description (item);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (priv->store), &iter,
|
||||
gtk_list_store_set (store, &iter,
|
||||
0, pixbuf,
|
||||
1, item,
|
||||
-1);
|
||||
|
@ -185,9 +181,8 @@ load_wallpapers (gchar *key,
|
|||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->store), &iter);
|
||||
item->rowref = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->store), path);
|
||||
///g_signal_connect (item->bg, "changed", G_CALLBACK (item_changed_cb), priv->wp_xml);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
|
||||
item->rowref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
|
@ -199,8 +194,6 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
|
|||
|
||||
priv = self->priv = WALLPAPERS_SOURCE_PRIVATE (self);
|
||||
|
||||
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
|
||||
|
||||
priv->thumb_factory =
|
||||
gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
|
||||
|
||||
|
@ -208,7 +201,7 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
|
|||
wp_xml = g_new0 (GnomeWpXml, 1);
|
||||
wp_xml->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
wp_xml->client = gconf_client_get_default ();
|
||||
wp_xml->wp_model = priv->store;
|
||||
wp_xml->wp_model = bg_source_get_liststore (BG_SOURCE (self));
|
||||
wp_xml->thumb_width = 100;
|
||||
wp_xml->thumb_height = 75;
|
||||
wp_xml->thumb_factory = priv->thumb_factory;
|
||||
|
@ -216,7 +209,7 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
|
|||
gnome_wp_xml_load_list (wp_xml);
|
||||
g_hash_table_foreach (wp_xml->wp_hash,
|
||||
(GHFunc) load_wallpapers,
|
||||
priv);
|
||||
self);
|
||||
|
||||
g_hash_table_destroy (wp_xml->wp_hash);
|
||||
g_object_unref (wp_xml->client);
|
||||
|
@ -229,9 +222,3 @@ bg_wallpapers_source_new (void)
|
|||
return g_object_new (BG_TYPE_WALLPAPERS_SOURCE, NULL);
|
||||
}
|
||||
|
||||
|
||||
GtkListStore *
|
||||
bg_wallpapers_source_get_liststore (BgWallpapersSource *source)
|
||||
{
|
||||
return source->priv->store;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define _BG_WALLPAPERS_SOURCE_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "bg-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -56,14 +57,14 @@ typedef struct _BgWallpapersSourcePrivate BgWallpapersSourcePrivate;
|
|||
|
||||
struct _BgWallpapersSource
|
||||
{
|
||||
GObject parent;
|
||||
BgSource parent;
|
||||
|
||||
BgWallpapersSourcePrivate *priv;
|
||||
};
|
||||
|
||||
struct _BgWallpapersSourceClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
BgSourceClass parent_class;
|
||||
};
|
||||
|
||||
GType bg_wallpapers_source_get_type (void) G_GNUC_CONST;
|
||||
|
|
|
@ -53,8 +53,6 @@ struct _CcBackgroundPanelPrivate
|
|||
BgFlickrSource *flickr_source;
|
||||
#endif
|
||||
|
||||
GtkListStore *selected_store;
|
||||
|
||||
GConfClient *client;
|
||||
|
||||
GnomeDesktopThumbnailFactory *thumb_factory;
|
||||
|
@ -202,34 +200,21 @@ source_changed_cb (GtkTreeSelection *selection,
|
|||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
GtkIconView *view;
|
||||
guint type;
|
||||
BgSource *source;
|
||||
|
||||
gtk_tree_selection_get_selected (selection, &model, &iter);
|
||||
gtk_tree_model_get (model, &iter,
|
||||
1, &type,
|
||||
2, &priv->current_source_readonly, -1);
|
||||
2, &priv->current_source_readonly,
|
||||
3, &source, -1);
|
||||
|
||||
view = (GtkIconView *) gtk_builder_get_object (priv->builder,
|
||||
"backgrounds-iconview");
|
||||
|
||||
if (type == SOURCE_WALLPAPERS)
|
||||
store = bg_wallpapers_source_get_liststore (priv->wallpapers_source);
|
||||
else if (type == SOURCE_PICTURES)
|
||||
store = bg_pictures_source_get_liststore (priv->pictures_source);
|
||||
else if (type == SOURCE_COLORS)
|
||||
store = bg_colors_source_get_liststore (priv->colors_source);
|
||||
#ifdef HAVE_LIBSOCIALWEB
|
||||
else if (type == SOURCE_FLICKR)
|
||||
store = bg_flickr_source_get_liststore (priv->flickr_source);
|
||||
#endif
|
||||
else
|
||||
store = NULL;
|
||||
|
||||
priv->selected_store = store;
|
||||
|
||||
gtk_icon_view_set_model (view, GTK_TREE_MODEL (store));
|
||||
gtk_icon_view_set_model (view,
|
||||
GTK_TREE_MODEL (bg_source_get_liststore (source)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -551,30 +536,38 @@ cc_background_panel_init (CcBackgroundPanel *self)
|
|||
store = (GtkListStore*) gtk_builder_get_object (priv->builder,
|
||||
"sources-liststore");
|
||||
|
||||
priv->pictures_source = bg_pictures_source_new ();
|
||||
priv->wallpapers_source = bg_wallpapers_source_new ();
|
||||
gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
|
||||
0, _("Wallpapers"),
|
||||
1, SOURCE_WALLPAPERS,
|
||||
2, TRUE, -1);
|
||||
2, TRUE,
|
||||
3, priv->wallpapers_source,
|
||||
-1);
|
||||
|
||||
priv->wallpapers_source = bg_wallpapers_source_new ();
|
||||
priv->pictures_source = bg_pictures_source_new ();
|
||||
gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
|
||||
0, _("Pictures Folder"),
|
||||
1, SOURCE_PICTURES,
|
||||
2, FALSE, -1);
|
||||
2, FALSE,
|
||||
3, priv->pictures_source,
|
||||
-1);
|
||||
|
||||
priv->colors_source = bg_colors_source_new ();
|
||||
gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
|
||||
0, _("Colors"),
|
||||
1, SOURCE_COLORS,
|
||||
2, TRUE, -1);
|
||||
2, TRUE,
|
||||
3, priv->colors_source,
|
||||
-1);
|
||||
|
||||
#ifdef HAVE_LIBSOCIALWEB
|
||||
priv->flickr_source = bg_flickr_source_new ();
|
||||
gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
|
||||
0, _("Flickr"),
|
||||
1, SOURCE_FLICKR,
|
||||
2, FALSE, -1);
|
||||
2, FALSE,
|
||||
3, priv->flickr_source,
|
||||
-1);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue