2010-08-10 15:26:07 +01:00
|
|
|
/* 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
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-08-10 15:26:07 +01:00
|
|
|
*
|
|
|
|
* Author: Thomas Wood <thomas.wood@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "bg-colors-source.h"
|
|
|
|
|
2011-02-10 12:29:29 +00:00
|
|
|
#include "cc-background-item.h"
|
2010-08-10 15:26:07 +01:00
|
|
|
|
|
|
|
#include <glib/gi18n-lib.h>
|
2011-02-17 20:59:55 +01:00
|
|
|
#include <gdesktop-enums.h>
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2010-08-10 17:01:15 +01:00
|
|
|
G_DEFINE_TYPE (BgColorsSource, bg_colors_source, BG_TYPE_SOURCE)
|
2010-08-10 15:26:07 +01:00
|
|
|
|
|
|
|
#define COLORS_SOURCE_PRIVATE(o) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_COLORS_SOURCE, BgColorsSourcePrivate))
|
|
|
|
|
2010-12-15 16:46:53 +00:00
|
|
|
struct {
|
2012-05-22 11:34:20 -04:00
|
|
|
GDesktopBackgroundShading type;
|
|
|
|
int orientation;
|
|
|
|
const char *pcolor;
|
2010-12-15 16:46:53 +00:00
|
|
|
} items[] = {
|
2012-09-01 00:31:34 +02:00
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#db5d33" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#008094" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#5d479d" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#ab2876" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#fad166" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#437740" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#d272c4" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#ed9116" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#ff89a9" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#7a8aa2" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#888888" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#475b52" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#425265" },
|
|
|
|
{ G_DESKTOP_BACKGROUND_SHADING_SOLID, -1, "#7a634b" },
|
2010-08-10 15:26:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2014-06-16 14:38:36 +02:00
|
|
|
bg_colors_source_constructed (GObject *object)
|
2010-08-10 15:26:07 +01:00
|
|
|
{
|
2014-06-16 14:38:36 +02:00
|
|
|
BgColorsSource *self = BG_COLORS_SOURCE (object);
|
2010-08-10 15:26:07 +01:00
|
|
|
GnomeDesktopThumbnailFactory *thumb_factory;
|
2010-12-15 16:46:53 +00:00
|
|
|
guint i;
|
2010-08-10 17:01:15 +01:00
|
|
|
GtkListStore *store;
|
2014-06-16 14:38:36 +02:00
|
|
|
gint thumbnail_height;
|
|
|
|
gint thumbnail_width;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (bg_colors_source_parent_class)->constructed (object);
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2010-08-10 17:01:15 +01:00
|
|
|
store = bg_source_get_liststore (BG_SOURCE (self));
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2012-05-22 11:34:20 -04:00
|
|
|
thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
|
2014-06-16 14:38:36 +02:00
|
|
|
thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (self));
|
|
|
|
thumbnail_width = bg_source_get_thumbnail_width (BG_SOURCE (self));
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2010-12-15 16:46:53 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (items); i++)
|
2010-08-10 15:26:07 +01:00
|
|
|
{
|
2011-02-11 03:49:23 +00:00
|
|
|
CcBackgroundItemFlags flags;
|
2011-02-10 20:30:57 +00:00
|
|
|
CcBackgroundItem *item;
|
2010-12-14 20:29:33 +00:00
|
|
|
GIcon *pixbuf;
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-10 20:30:57 +00:00
|
|
|
item = cc_background_item_new (NULL);
|
2011-02-11 03:49:23 +00:00
|
|
|
flags = CC_BACKGROUND_ITEM_HAS_PCOLOR |
|
|
|
|
CC_BACKGROUND_ITEM_HAS_SCOLOR |
|
|
|
|
CC_BACKGROUND_ITEM_HAS_SHADING |
|
2011-02-14 19:48:38 +00:00
|
|
|
CC_BACKGROUND_ITEM_HAS_PLACEMENT |
|
2011-02-11 18:04:57 +00:00
|
|
|
CC_BACKGROUND_ITEM_HAS_URI;
|
|
|
|
/* It does have a URI, it's "none" */
|
2010-08-10 15:26:07 +01:00
|
|
|
|
2011-02-10 20:30:57 +00:00
|
|
|
g_object_set (G_OBJECT (item),
|
2012-08-24 16:25:53 +02:00
|
|
|
"uri", "file:///" DATADIR "/gnome-control-center/pixmaps/noise-texture-light.png",
|
2012-05-22 11:34:20 -04:00
|
|
|
"primary-color", items[i].pcolor,
|
|
|
|
"secondary-color", items[i].pcolor,
|
2011-02-10 20:30:57 +00:00
|
|
|
"shading", items[i].type,
|
2012-05-22 11:34:20 -04:00
|
|
|
"placement", G_DESKTOP_BACKGROUND_STYLE_WALLPAPER,
|
2011-02-11 03:49:23 +00:00
|
|
|
"flags", flags,
|
2011-02-10 20:30:57 +00:00
|
|
|
NULL);
|
2012-05-22 11:34:20 -04:00
|
|
|
cc_background_item_load (item, NULL);
|
2010-08-10 15:26:07 +01:00
|
|
|
|
|
|
|
/* insert the item into the liststore */
|
2011-02-10 12:29:29 +00:00
|
|
|
pixbuf = cc_background_item_get_thumbnail (item,
|
2011-02-10 20:30:57 +00:00
|
|
|
thumb_factory,
|
2014-06-16 14:38:36 +02:00
|
|
|
thumbnail_width, thumbnail_height);
|
2010-08-10 17:01:15 +01:00
|
|
|
gtk_list_store_insert_with_values (store, NULL, 0,
|
2010-08-10 15:26:07 +01:00
|
|
|
0, pixbuf,
|
|
|
|
1, item,
|
|
|
|
-1);
|
2010-08-12 11:23:55 +01:00
|
|
|
|
|
|
|
g_object_unref (pixbuf);
|
2013-10-02 13:35:21 +02:00
|
|
|
g_object_unref (item);
|
2010-08-10 15:26:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (thumb_factory);
|
|
|
|
}
|
|
|
|
|
2014-06-16 14:38:36 +02:00
|
|
|
bg_colors_source_init (BgColorsSource *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-17 11:59:58 +02:00
|
|
|
static void
|
|
|
|
bg_colors_source_class_init (BgColorsSourceClass *klass)
|
|
|
|
{
|
2014-06-16 14:38:36 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->constructed = bg_colors_source_constructed;
|
2014-06-17 11:59:58 +02:00
|
|
|
}
|
|
|
|
|
2010-08-10 15:26:07 +01:00
|
|
|
BgColorsSource *
|
2014-06-16 14:38:36 +02:00
|
|
|
bg_colors_source_new (GtkWindow *window)
|
2010-08-10 15:26:07 +01:00
|
|
|
{
|
2014-06-16 14:38:36 +02:00
|
|
|
return g_object_new (BG_TYPE_COLORS_SOURCE, "window", window, NULL);
|
2010-08-10 15:26:07 +01:00
|
|
|
}
|
|
|
|
|