1
/* bg-flickr-source.c */
3
* Copyright (C) 2010 Intel, Inc
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
* Author: Thomas Wood <thomas.wood@intel.com>
23
#include "bg-flickr-source.h"
25
#include <libsocialweb-client/sw-client.h>
26
#include <libsocialweb-client/sw-item.h>
27
#include <libsocialweb-client/sw-client-service.h>
29
#include "cc-background-item.h"
30
#include <gdesktop-enums.h>
32
G_DEFINE_TYPE (BgFlickrSource, bg_flickr_source, BG_TYPE_SOURCE)
34
#define FLICKR_SOURCE_PRIVATE(o) \
35
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_FLICKR_SOURCE, BgFlickrSourcePrivate))
37
struct _BgFlickrSourcePrivate
40
SwClientService *service;
45
bg_flickr_source_dispose (GObject *object)
47
BgFlickrSourcePrivate *priv = BG_FLICKR_SOURCE (object)->priv;
51
g_object_unref (priv->client);
57
g_object_unref (priv->service);
61
G_OBJECT_CLASS (bg_flickr_source_parent_class)->dispose (object);
65
bg_flickr_source_finalize (GObject *object)
67
G_OBJECT_CLASS (bg_flickr_source_parent_class)->finalize (object);
71
bg_flickr_source_class_init (BgFlickrSourceClass *klass)
73
GObjectClass *object_class = G_OBJECT_CLASS (klass);
75
g_type_class_add_private (klass, sizeof (BgFlickrSourcePrivate));
77
object_class->dispose = bg_flickr_source_dispose;
78
object_class->finalize = bg_flickr_source_finalize;
82
_view_items_added_cb (SwClientItemView *item_view,
87
BgFlickrSource *source = (BgFlickrSource *) userdata;
88
GtkListStore *store = bg_source_get_liststore (BG_SOURCE (source));
90
for (l = items; l; l = l->next)
92
CcBackgroundItem *item;
94
SwItem *sw_item = (SwItem *) l->data;
95
const gchar *thumb_url;
97
item = cc_background_item_new (NULL);
99
g_object_set (G_OBJECT (item),
100
"placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM,
101
"name", sw_item_get_value (sw_item, "title"),
102
"primary-color", "#000000000000",
103
"seconday-color", "#000000000000",
104
"shading", G_DESKTOP_BACKGROUND_SHADING_SOLID,
105
"source-url", sw_item_get_value (sw_item, "x-flickr-photo-url"),
109
// cc_background_item_ensure_gnome_bg (item);
111
/* insert the item into the liststore */
112
thumb_url = sw_item_get_value (sw_item, "thumbnail");
113
pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb_url, THUMBNAIL_WIDTH,
114
THUMBNAIL_HEIGHT, TRUE,
116
gtk_list_store_insert_with_values (store, NULL, 0,
120
g_object_unref (pixbuf);
125
_query_open_view_cb (SwClientService *service,
126
SwClientItemView *item_view,
132
g_warning ("Could not connect to Flickr service");
136
g_signal_connect (item_view,
138
(GCallback)_view_items_added_cb,
140
sw_client_item_view_start (item_view);
144
bg_flickr_source_init (BgFlickrSource *self)
146
GnomeDesktopThumbnailFactory *thumb_factory;
147
BgFlickrSourcePrivate *priv;
149
priv = self->priv = FLICKR_SOURCE_PRIVATE (self);
151
priv->client = sw_client_new ();
152
priv->service = sw_client_get_service (priv->client, "flickr");
153
sw_client_service_query_open_view (priv->service,
159
thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
161
g_object_unref (thumb_factory);
165
bg_flickr_source_new (void)
167
return g_object_new (BG_TYPE_FLICKR_SOURCE, NULL);