Commit e721f417 authored by Thomas Wood's avatar Thomas Wood

Add initial implementation of "background" panel

The background settings panel provides a way for users to change the
desktop background by selecting an image and/or colour.
parent d662b23f
......@@ -274,6 +274,23 @@ AC_MSG_RESULT([$enable_examples])
AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_examples" = "xyes")
dnl ==============================================
dnl libsocialweb
dnl ==============================================
AC_MSG_CHECKING([Enable libsocialweb support])
AC_ARG_WITH([libsocialweb],
AC_HELP_STRING([--with-libsocialweb],
[enable libsocialweb support]),,
[with_libsocialweb=no])
AC_MSG_RESULT([$with_libsocialweb])
if test "x$with_libsocialweb" == "xyes"; then
PKG_CHECK_MODULES(SOCIALWEB, libsocialweb-client)
AC_DEFINE(HAVE_LIBSOCIALWEB, 1, [Defined if libsocialweb is available])
fi
AM_CONDITIONAL(WITH_LIBSOCIALWEB, test "x$with_libsocialweb" = "xyes")
dnl =======================================
dnl Update Mime Database
......@@ -356,6 +373,8 @@ help/Makefile
libgnome-control-center/Makefile
libgnome-control-center/libgnome-control-center.pc
panels/Makefile
panels/background/Makefile
panels/background/gnome-background-panel.desktop.in
panels/datetime/Makefile
panels/datetime/gnome-datetime-panel.desktop.in
panels/default-applications/Makefile
......
SUBDIRS=display \
SUBDIRS= \
background \
display \
mouse \
keyboard \
network \
......
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = background
uidir = $(pkgdatadir)/ui/background
dist_ui_DATA = \
background.ui
INCLUDES = \
$(PANEL_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(DBUS_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DDATADIR="\"$(uidir)\"" \
-DGNOME_DESKTOP_USE_UNSTABLE_API \
$(NULL)
ccpanelsdir = $(PANELS_DIR)
ccpanels_LTLIBRARIES = libbackground.la
libbackground_la_SOURCES = \
background-module.c \
cc-background-panel.c \
cc-background-panel.h \
bg-pictures-source.c \
bg-pictures-source.h \
bg-wallpapers-source.c \
bg-wallpapers-source.h \
bg-colors-source.c \
bg-colors-source.h \
gnome-wp-info.c gnome-wp-item.c gnome-wp-xml.c \
gnome-wp-info.h gnome-wp-item.h gnome-wp-xml.h
libbackground_la_LIBADD = $(PANEL_LIBS) $(DBUS_LIBS)
libbackground_la_LDFLAGS = $(PANEL_LDFLAGS)
if WITH_LIBSOCIALWEB
libbackground_la_SOURCES += bg-flickr-source.c bg-flickr-source.h
INCLUDES += $(SOCIALWEB_CFLAGS)
libbackground_la_LIBADD += $(SOCIALWEB_LIBS)
endif
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = gnome-background-panel.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
CLEANFILES = $(desktop_in_files) $(desktop_DATA)
-include $(top_srcdir)/git.mk
/*
* 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 <config.h>
#include "cc-background-panel.h"
#include <glib/gi18n.h>
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
/* register the panel */
cc_background_panel_register (module);
}
void
g_io_module_unload (GIOModule *module)
{
}
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="style-liststore">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name value -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Tile</col>
<col id="1">wallpaper</col>
</row>
<row>
<col id="0" translatable="yes">Zoom</col>
<col id="1">zoom</col>
</row>
<row>
<col id="0" translatable="yes">Center</col>
<col id="1">centered</col>
</row>
<row>
<col id="0" translatable="yes">Scale</col>
<col id="1">scaled</col>
</row>
<row>
<col id="0" translatable="yes">Fill</col>
<col id="1">stretched</col>
</row>
<row>
<col id="0" translatable="yes">Span</col>
<col id="1">spanned</col>
</row>
</data>
</object>
<object class="GtkListStore" id="backgrounds-liststore">
<columns>
<!-- column-name pixbuf -->
<column type="GdkPixbuf"/>
<!-- column-name data -->
<column type="gpointer"/>
<!-- column-name source-id -->
<column type="guint"/>
</columns>
</object>
<object class="GtkListStore" id="sources-liststore">
<columns>
<!-- column-name source-name -->
<column type="gchararray"/>
<!-- column-name source-id -->
<column type="guint"/>
<!-- column-name readonly -->
<column type="gboolean"/>
</columns>
</object>
<object class="GtkVBox" id="background-panel">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkHBox" id="pictures-vbox">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="sources-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">sources-liststore</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title">Sources</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="width_request">400</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkIconView" id="backgrounds-iconview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="row_spacing">4</property>
<property name="column_spacing">4</property>
<property name="margin">4</property>
<child>
<object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/>
<attributes>
<attribute name="pixbuf">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="details-box">
<property name="width_request">175</property>
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkDrawingArea" id="preview-area">
<property name="width_request">200</property>
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="background-label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="edit-hbox">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkComboBox" id="style-combobox">
<property name="visible">True</property>
<property name="model">style-liststore</property>
<property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="style-color">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>
/* bg-colors-source.c */
/*
* 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 <config.h>
#include "bg-colors-source.h"
#include "gnome-wp-item.h"
#include <glib/gi18n-lib.h>
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, G_TYPE_OBJECT)
#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[] =
{
"#c4a000",
"#ce5c00",
"#8f5902",
"#4e9a06",
"#204a87",
"#5c3566",
"#a40000",
"#babdb6",
"#2e3436",
"#000000",
NULL
};
static gchar *color_names[] =
{
N_("Butter"),
N_("Orange"),
N_("Chocolate"),
N_("Chameleon"),
N_("Blue"),
N_("Plum"),
N_("Red"),
N_("Aluminium"),
N_("Gray"),
N_("Black"),
NULL
};
static void
bg_colors_source_init (BgColorsSource *self)
{
GnomeDesktopThumbnailFactory *thumb_factory;
BgColorsSourcePrivate *priv;
gchar **c, **n;
priv = self->priv = COLORS_SOURCE_PRIVATE (self);
priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);
for (c = colors, n = color_names; *c; c++, n++)
{
GnomeWPItem *item;
GdkPixbuf *pixbuf;
GdkColor color;
item = g_new0 (GnomeWPItem, 1);
item->filename = g_strdup ("(none)");
item->name = g_strdup (_(*n));
gdk_color_parse (*c, &color);
item->pcolor = gdk_color_copy (&color);
item->scolor = gdk_color_copy (&color);
item->shade_type = GNOME_BG_COLOR_SOLID;
gnome_wp_item_ensure_gnome_bg (item);
/* insert the item into the liststore */
pixbuf = gnome_wp_item_get_thumbnail (item,
thumb_factory,
100, 75);
gtk_list_store_insert_with_values (priv->store, NULL, 0,
0, pixbuf,
1, item,
-1);
}
g_object_unref (thumb_factory);
}
BgColorsSource *
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;
}
/* bg-colors-source.h */
/*
* 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_COLORS_SOURCE_H
#define _BG_COLORS_SOURCE_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define BG_TYPE_COLORS_SOURCE bg_colors_source_get_type()
#define BG_COLORS_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
BG_TYPE_COLORS_SOURCE, BgColorsSource))
#define BG_COLORS_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
BG_TYPE_COLORS_SOURCE, BgColorsSourceClass))
#define BG_IS_COLORS_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
BG_TYPE_COLORS_SOURCE))
#define BG_IS_COLORS_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
BG_TYPE_COLORS_SOURCE))
#define BG_COLORS_SOURCE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
BG_TYPE_COLORS_SOURCE, BgColorsSourceClass))
typedef struct _BgColorsSource BgColorsSource;
typedef struct _BgColorsSourceClass BgColorsSourceClass;
typedef struct _BgColorsSourcePrivate BgColorsSourcePrivate;
struct _BgColorsSource
{
GObject parent;
BgColorsSourcePrivate *priv;
};
struct _BgColorsSourceClass
{
GObjectClass 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
#endif /* _BG_COLORS_SOURCE_H */
/* bg-flickr-source.c */
/*
* 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-flickr-source.h"
#include <libsocialweb-client/sw-client.h>
#include <libsocialweb-client/sw-item.h>
#include <libsocialweb-client/sw-client-service.h>
#include "gnome-wp-item.h"
G_DEFINE_TYPE (BgFlickrSource, bg_flickr_source, G_TYPE_OBJECT)
#define FLICKR_SOURCE_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_FLICKR_SOURCE, BgFlickrSourcePrivate))
struct _BgFlickrSourcePrivate
{
GtkListStore *store;
SwClient *client;
SwClientService *service;
};
static void
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);
priv->client = NULL;
}
if (priv->service)
{
g_object_unref (priv->service);
priv->service = NULL;
}
G_OBJECT_CLASS (bg_flickr_source_parent_class)->dispose (object);
}
static void
bg_flickr_source_finalize (GObject *object)
{
G_OBJECT_CLASS (bg_flickr_source_parent_class)->finalize (object);
}
static void
bg_flickr_source_class_init (BgFlickrSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (BgFlickrSourcePrivate));
object_class->dispose = bg_flickr_source_dispose;
object_class->finalize = bg_flickr_source_finalize;
}
static void
_view_items_added_cb (SwClientItemView *item_view,
GList *items,
gpointer userdata)
{
GList *l;
BgFlickrSourcePrivate *priv = (BgFlickrSourcePrivate *) userdata;
for (l = items; l; l = l->next)
{
GnomeWPItem *item;
GdkPixbuf *pixbuf;
GdkColor color = { 0, 0, 0, 0 };
SwItem *sw_item = (SwItem *) l->data;
const gchar *thumb_url;
item = g_new0 (GnomeWPItem, 1);
item->options = GNOME_BG_PLACEMENT_ZOOMED;
item->name = g_strdup (sw_item_get_value (sw_item, "title"));
item->source_url = g_strdup (sw_item_get_value (sw_item,
"x-flickr-photo-url"));
item->pcolor = gdk_color_copy (&color);
item->scolor = gdk_color_copy (&color);
item->shade_type = GNOME_BG_COLOR_SOLID;
gnome_wp_item_ensure_gnome_bg (item);
/* insert the item into the liststore */
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,
0, pixbuf,
1, item,
-1);
}
}
static void
_query_open_view_cb (SwClientService *service,
SwClientItemView *item_view,
gpointer userdata)
{
if (!item_view)
{
g_warning ("Could not connect to Flickr service");
return;
}
g_signal_connect (item_view,
"items-added",
(GCallback)_view_items_added_cb,
userdata);
sw_client_item_view_start (item_view);
}