[gnome-control-center/wip/jsparber/background: 1/29] background: start implementing the new design for the background panel
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 1/29] background: start implementing the new design for the background panel
- Date: Sat, 17 Feb 2018 18:10:30 +0000 (UTC)
commit efa4f489746914c1220e07fdf6fb9d994514a66a
Author: Julian Sparber <julian sparber net>
Date: Tue Dec 5 16:22:29 2017 +0100
background: start implementing the new design for the background panel
Start implementing the redesign v3 proposal made by Tobias Bernard
wiki page:
https://wiki.gnome.org/Design/SystemSettings/Background
https://bugzilla.gnome.org/show_bug.cgi?id=788515
panels/background/background.gresource.xml | 1 +
panels/background/background.ui | 275 ++++++-----------
panels/background/bg-source.c | 11 +-
panels/background/bg-wallpapers-source.c | 43 ++-
panels/background/bg-wallpapers-source.h | 2 +-
panels/background/cc-background-grid-item.c | 148 +++++++++
panels/background/cc-background-grid-item.h | 38 +++
panels/background/cc-background-panel.c | 463 +++++++++++++++++++++-------
panels/background/cc-background-store.c | 94 ++++++
panels/background/cc-background-store.h | 44 +++
panels/background/data/background.css | 7 +
11 files changed, 811 insertions(+), 315 deletions(-)
---
diff --git a/panels/background/background.gresource.xml b/panels/background/background.gresource.xml
index e8e4ff353..4a76129c2 100644
--- a/panels/background/background.gresource.xml
+++ b/panels/background/background.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/control-center/background">
<file preprocess="xml-stripblanks">background.ui</file>
+ <file alias="background.css">data/background.css</file>
</gresource>
</gresources>
diff --git a/panels/background/background.ui b/panels/background/background.ui
index abf79ea86..aae1f6bb1 100644
--- a/panels/background/background.ui
+++ b/panels/background/background.ui
@@ -4,245 +4,156 @@
<object class="GtkBox" id="background-panel">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin">32</property>
- <property name="spacing">12</property>
- <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkBox" id="background-preview">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">24</property>
+ <property name="margin">16</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="expand">False</property>
<child>
- <object class="GtkBox" id="vbox3">
+ <object class="GtkBox" id="background-preview-top">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
+ <property name="margin">6</property>
+ <property name="spacing">6</property>
<property name="orientation">vertical</property>
+ <style>
+ <class name="black-border"/>
+ </style>
<child>
- <object class="GtkButton" id="background-set-button">
+ <object class="GtkDrawingArea" id="background-desktop-drawingarea">
+ <property name="width_request">310</property>
+ <property name="height_request">170</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkBox" id="box2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin">6</property>
- <property name="spacing">6</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkDrawingArea" id="background-desktop-drawingarea">
- <property name="width_request">310</property>
- <property name="height_request">170</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Background</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">background-set-button</property>
- </object>
- </child>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="bottom-hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkBox" id="bottom-hbox">
+ <object class="GtkBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="halign">center</property>
+ <property name="margin_top">12</property>
+ <property name="spacing">2</property>
<child>
- <object class="GtkBox" id="hbox2">
+ <object class="GtkImage" id="slide_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="margin_top">12</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="slide_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">slideshow-symbolic</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="strut">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="slide-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="This refers to a slideshow
background">Changes throughout the day</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="icon_name">slideshow-symbolic</property>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="strut">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"> </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="slide-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes" comments="This refers to a slideshow
background">Changes throughout the day</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">2</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="backgroud-gallery-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkBox" id="vbox1">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="halign">start</property>
- <property name="valign">center</property>
+ <property name="hscrollbar_policy">never</property>
<child>
- <object class="GtkButton" id="background-lock-set-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkBox" id="box3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin">6</property>
- <property name="spacing">6</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkDrawingArea" id="background-lock-drawingarea">
- <property name="width_request">310</property>
- <property name="height_request">170</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" comments="To translators: This is a noun,
not a verb">_Lock Screen</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">background-lock-set-button</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="bottom-hbox1">
+ <object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="orientation">vertical</property>
+ <style>
+ <class name="background-gallery"/>
+ </style>
<child>
- <object class="GtkBox" id="hbox1">
+ <object class="GtkFlowBox" id="background-gallery">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="min-children-per-line">2</property>
+ <property name="row_spacing">5</property>
+ <property name="column_spacing">5</property>
<property name="halign">center</property>
- <property name="margin_top">12</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="slide_image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">slideshow-symbolic</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="strut1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="slide-label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes" comments="This refers to a slideshow
background">Changes throughout the day</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="valign">center</property>
+ <property name="margin">25</property>
+ <property name="margin_top">50</property>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
+
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/panels/background/bg-source.c b/panels/background/bg-source.c
index e48daf0f2..7d08dbd93 100644
--- a/panels/background/bg-source.c
+++ b/panels/background/bg-source.c
@@ -52,10 +52,12 @@ bg_source_calculate_thumbnail_dimensions (BgSource *source)
priv->thumbnail_height = THUMBNAIL_HEIGHT;
priv->thumbnail_width = THUMBNAIL_WIDTH;
- if (priv->window == NULL)
- return;
+ //if (priv->window == NULL)
+ // return;
- scale_factor = gtk_widget_get_scale_factor (priv->window);
+
+ //scale_factor = gtk_widget_get_scale_factor (priv->window);
+ scale_factor = 1;
if (scale_factor > 1)
{
priv->thumbnail_height *= scale_factor;
@@ -173,6 +175,9 @@ bg_source_get_scale_factor (BgSource *source)
g_return_val_if_fail (BG_IS_SOURCE (source), 1);
priv = bg_source_get_instance_private (source);
+
+ return 1;
+ g_print("Error Here 2\n");
return gtk_widget_get_scale_factor (priv->window);
}
diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c
index 50f40b369..f5b7da1b5 100644
--- a/panels/background/bg-wallpapers-source.c
+++ b/panels/background/bg-wallpapers-source.c
@@ -56,7 +56,7 @@ load_wallpapers (gchar *key,
if (deleted)
return;
- gtk_list_store_append (store, &iter);
+// gtk_list_store_append (store, &iter);
scale_factor = bg_source_get_scale_factor (BG_SOURCE (source));
thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (source));
@@ -68,26 +68,36 @@ load_wallpapers (gchar *key,
return;
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor, NULL);
- gtk_list_store_set (store, &iter,
- 0, surface,
- 1, item,
- 2, cc_background_item_get_name (item),
- -1);
+
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ 0, surface,
+ 1, item,
+ 2, cc_background_item_get_name (item),
+ -1);
+
+ /* gtk_list_store_set (store, &iter,
+ 0, surface,
+ 1, item,
+ 2, cc_background_item_get_name (item),
+ -1);
+ */
+
+out:
g_clear_pointer (&surface, (GDestroyNotify) cairo_surface_destroy);
}
static void
list_load_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+ GAsyncResult *res,
+ gpointer user_data)
{
cc_background_xml_load_list_finish (res);
}
static void
item_added (CcBackgroundXml *xml,
- CcBackgroundItem *item,
- BgWallpapersSource *self)
+ CcBackgroundItem *item,
+ BgWallpapersSource *self)
{
load_wallpapers (NULL, item, self);
}
@@ -105,10 +115,11 @@ load_default_bg (BgWallpapersSource *self)
g_autofree gchar *filename = NULL;
filename = g_build_filename (system_data_dirs[i],
- "gnome-background-properties",
- "adwaita.xml",
- NULL);
- if (cc_background_xml_load_xml (self->xml, filename))
+ "gnome-background-properties",
+ "adwaita.xml",
+ NULL);
+ if (cc_background_xml_load_xml (self->xml, filename)) {
+ g_free (filename);
break;
}
}
@@ -121,7 +132,7 @@ bg_wallpapers_source_constructed (GObject *object)
G_OBJECT_CLASS (bg_wallpapers_source_parent_class)->constructed (object);
g_signal_connect (G_OBJECT (self->xml), "added",
- G_CALLBACK (item_added), self);
+ G_CALLBACK (item_added), self);
/* Try adding the default background first */
load_default_bg (self);
@@ -144,7 +155,7 @@ static void
bg_wallpapers_source_init (BgWallpapersSource *self)
{
self->thumb_factory =
- gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+ gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
self->xml = cc_background_xml_new ();
}
diff --git a/panels/background/bg-wallpapers-source.h b/panels/background/bg-wallpapers-source.h
index 129c24931..729266910 100644
--- a/panels/background/bg-wallpapers-source.h
+++ b/panels/background/bg-wallpapers-source.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#define BG_TYPE_WALLPAPERS_SOURCE (bg_wallpapers_source_get_type ())
G_DECLARE_FINAL_TYPE (BgWallpapersSource, bg_wallpapers_source, BG, WALLPAPERS_SOURCE, BgSource)
-BgWallpapersSource *bg_wallpapers_source_new (GtkWindow *window);
+BgWallpapersSource *bg_wallpapers_source_new (GtkWindow *);
G_END_DECLS
diff --git a/panels/background/cc-background-grid-item.c b/panels/background/cc-background-grid-item.c
new file mode 100644
index 000000000..991267b06
--- /dev/null
+++ b/panels/background/cc-background-grid-item.c
@@ -0,0 +1,148 @@
+/* cc-background-grid-item.c
+ *
+ * Copyright (C) 2017 Julian Sparber <julian sparber net>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+#include "cc-background-grid-item.h"
+#include "cc-background-item.h"
+
+struct _CcBackgroundGridItem
+{
+ GtkFlowBoxChild parent;
+
+ GtkImage *image;
+
+ /* data */
+ CcBackgroundItem *item;
+
+};
+
+
+G_DEFINE_TYPE (CcBackgroundGridItem, cc_background_grid_item, GTK_TYPE_FLOW_BOX_CHILD)
+
+ enum {
+ PROP_0,
+ PROP_ITEM
+ };
+
+GtkWidget*
+cc_background_grid_item_new (CcBackgroundItem *item)
+{
+
+ return g_object_new (CC_TYPE_BACKGROUND_GRID_ITEM,
+ "item", item,
+ NULL);
+}
+
+CcBackgroundItem * cc_background_grid_item_get_ref (CcBackgroundGridItem *self)
+{
+ return self->item;
+}
+void
+cc_background_grid_item_set_ref (CcBackgroundGridItem *self, CcBackgroundItem *item)
+{
+ self->item = item;
+}
+
+static void
+cc_background_grid_item_finalize (GObject *object)
+{
+ //CcBackgroundGridItem *self = CC_BACKGROUND_GRID_ITEM (object);
+
+ G_OBJECT_CLASS (cc_background_grid_item_parent_class)->finalize (object);
+
+}
+
+static void
+cc_background_grid_item_dispose (GObject *object)
+{
+ //CcBackgroundGridItem *self = CC_BACKGROUND_GRID_ITEM (object);
+
+ G_OBJECT_CLASS (cc_background_grid_item_parent_class)->dispose (object);
+}
+
+static void
+cc_background_grid_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CcBackgroundGridItem *self = (CcBackgroundGridItem *) object;
+ switch (prop_id)
+ {
+
+ case PROP_ITEM:
+ self->item = g_value_dup_object (value);
+ g_debug ("Every set %p -> %p", value, self->item);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+cc_background_grid_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ CcBackgroundGridItem *self = (CcBackgroundGridItem *) object;
+
+ switch (prop_id)
+ {
+ case PROP_ITEM:
+ g_value_set_object (value, self->item);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+
+static void
+cc_background_grid_item_class_init (CcBackgroundGridItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = cc_background_grid_item_finalize;
+ object_class->dispose = cc_background_grid_item_dispose;
+ object_class->get_property = cc_background_grid_item_get_property;
+ object_class->set_property = cc_background_grid_item_set_property;
+
+ /*g_object_class_override_property (object_class,
+ PROP_ITEM,
+ "item");
+ */
+ g_object_class_install_property (object_class,
+ PROP_ITEM,
+ g_param_spec_object ("item",
+ "Background item reference",
+ "The reference to this background item",
+ CC_TYPE_BACKGROUND_ITEM,
+ G_PARAM_READWRITE));
+
+}
+
+static void
+cc_background_grid_item_init (CcBackgroundGridItem *self)
+{
+ g_debug ("Item ref: %p", self->item);
+ //gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/panels/background/cc-background-grid-item.h b/panels/background/cc-background-grid-item.h
new file mode 100644
index 000000000..025a56fab
--- /dev/null
+++ b/panels/background/cc-background-grid-item.h
@@ -0,0 +1,38 @@
+/* cc-background-grid-item.h
+ *
+ * Copyright (C) 2017 Julian Sparber <julian sparber net>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CC_BACKGROUND_GRID_ITEM_H
+#define CC_BACKGROUND_GRID_ITEM_H
+
+#include <gtk/gtk.h>
+#include "cc-background-item.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_BACKGROUND_GRID_ITEM (cc_background_grid_item_get_type())
+
+G_DECLARE_FINAL_TYPE (CcBackgroundGridItem, cc_background_grid_item, CC, BACKGROUND_GRID_LIST,
GtkFlowBoxChild)
+
+GtkWidget* cc_background_grid_item_new (CcBackgroundItem *);
+
+void cc_background_grid_item_set_ref (CcBackgroundGridItem *self, CcBackgroundItem *item);
+CcBackgroundItem * cc_background_grid_item_get_ref (CcBackgroundGridItem *self);
+
+G_END_DECLS
+
+#endif /* CC_BACKGROUND_GRID_ITEM_H */
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 8d54d5633..08863fce3 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -29,15 +29,15 @@
#include "cc-background-panel.h"
-#include "cc-background-chooser-dialog.h"
+#include "bg-wallpapers-source.h"
#include "cc-background-item.h"
+#include "cc-background-grid-item.h"
#include "cc-background-resources.h"
#include "cc-background-xml.h"
#include "bg-pictures-source.h"
#define WP_PATH_ID "org.gnome.desktop.background"
-#define WP_LOCK_PATH_ID "org.gnome.desktop.screensaver"
#define WP_URI_KEY "picture-uri"
#define WP_OPTIONS_KEY "picture-options"
#define WP_SHADING_KEY "color-shading-type"
@@ -50,19 +50,20 @@ struct _CcBackgroundPanel
GtkBuilder *builder;
GDBusConnection *connection;
-
GSettings *settings;
- GSettings *lock_settings;
GnomeDesktopThumbnailFactory *thumb_factory;
CcBackgroundItem *current_background;
- CcBackgroundItem *current_lock_background;
+
+ BgWallpapersSource *wallpapers_source;
GCancellable *copy_cancellable;
GtkWidget *spinner;
- GtkWidget *chooser;
+
+ GdkPixbuf *display_screenshot;
+ char *screenshot_path;
};
CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel)
@@ -85,9 +86,6 @@ cc_background_panel_dispose (GObject *object)
/* destroying the builder object will also destroy the spinner */
panel->spinner = NULL;
- g_clear_object (&panel->settings);
- g_clear_object (&panel->lock_settings);
-
if (panel->copy_cancellable)
{
/* cancel any copy operation */
@@ -96,12 +94,15 @@ cc_background_panel_dispose (GObject *object)
g_clear_object (&panel->copy_cancellable);
}
- if (panel->chooser)
+ if (panel->capture_cancellable)
{
- gtk_widget_destroy (panel->chooser);
- panel->chooser = NULL;
+ /* cancel screenshot operations */
+ g_cancellable_cancel (panel->capture_cancellable);
+
+ g_clear_object (&panel->capture_cancellable);
}
+ g_clear_object (&panel->wallpapers_source);
g_clear_object (&panel->thumb_factory);
G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
@@ -113,7 +114,6 @@ cc_background_panel_finalize (GObject *object)
CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (object);
g_clear_object (&panel->current_background);
- g_clear_object (&panel->current_lock_background);
G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object);
}
@@ -141,22 +141,19 @@ get_current_background (CcBackgroundPanel *panel, GSettings *settings)
static void
update_preview (CcBackgroundPanel *panel,
- GSettings *settings,
+ GSettings *settings,
CcBackgroundItem *item)
{
gboolean changes_with_time;
CcBackgroundItem *current_background;
- current_background = get_current_background (panel, settings);
+ current_background = panel->current_background;
if (item && current_background)
{
g_object_unref (current_background);
current_background = cc_background_item_copy (item);
- if (settings == panel->settings)
- panel->current_background = current_background;
- else
- panel->current_lock_background = current_background;
+ panel->current_background = current_background;
cc_background_item_load (current_background, NULL);
}
@@ -167,20 +164,10 @@ update_preview (CcBackgroundPanel *panel,
changes_with_time = cc_background_item_changes_with_time (current_background);
}
- if (settings == panel->settings)
- {
- gtk_widget_set_visible (WID ("slide_image"), changes_with_time);
- gtk_widget_set_visible (WID ("slide-label"), changes_with_time);
-
- gtk_widget_queue_draw (WID ("background-desktop-drawingarea"));
- }
- else
- {
- gtk_widget_set_visible (WID ("slide_image1"), changes_with_time);
- gtk_widget_set_visible (WID ("slide-label1"), changes_with_time);
+ gtk_widget_set_visible (WID ("slide_image"), changes_with_time);
+ gtk_widget_set_visible (WID ("slide-label"), changes_with_time);
- gtk_widget_queue_draw (WID ("background-lock-drawingarea"));
- }
+ gtk_widget_queue_draw (WID ("background-desktop-drawingarea"));
}
static gchar *
@@ -203,6 +190,7 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
const gint preview_height = 168;
gint scale_factor;
GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf_tmp;
pixbuf = g_object_get_data (G_OBJECT (background), "pixbuf");
if (pixbuf == NULL)
@@ -215,6 +203,32 @@ get_or_create_cached_pixbuf (CcBackgroundPanel *panel,
preview_height,
scale_factor,
-2, TRUE);
+
+ if (background == panel->current_background &&
+ panel->display_screenshot != NULL)
+ {
+ /* we need to add an alpha channel for for copy aera */
+ pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0,0,0);
+
+ pixbuf_tmp = gdk_pixbuf_scale_simple (panel->display_screenshot,
+ preview_width,
+ (preview_width
+ * gdk_pixbuf_get_height (panel->display_screenshot)
+ / gdk_pixbuf_get_width(panel->display_screenshot)),
+ GDK_INTERP_BILINEAR);
+
+ gdk_pixbuf_copy_area (pixbuf_tmp,
+ 0,
+ 0,
+ preview_width,
+ gdk_pixbuf_get_height(pixbuf_tmp),
+ pixbuf,
+ 0,
+ 0);
+
+ g_object_unref (pixbuf_tmp);
+ }
+
g_object_set_data_full (G_OBJECT (background), "pixbuf", pixbuf, g_object_unref);
}
@@ -239,28 +253,182 @@ update_display_preview (CcBackgroundPanel *panel,
cairo_destroy (cr);
}
+typedef struct {
+ CcBackgroundPanel *panel;
+ GdkRectangle capture_rect;
+ GdkRectangle monitor_rect;
+ GdkRectangle workarea_rect;
+ gboolean whole_monitor;
+} ScreenshotData;
+
+static void
+on_screenshot_finished (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ ScreenshotData *data = user_data;
+ CcBackgroundPanel *panel = data->panel;
+ GError *error;
+ GdkPixbuf *pixbuf;
+ GVariant *result;
+
+ error = NULL;
+ result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
+ res,
+ &error);
+
+ if (result == NULL) {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_error_free (error);
+ g_free (data);
+ return;
+ }
+ g_debug ("Unable to get screenshot: %s",
+ error->message);
+ g_error_free (error);
+ /* fallback? */
+ goto out;
+ }
+ g_variant_unref (result);
+
+ pixbuf = gdk_pixbuf_new_from_file (panel->screenshot_path, &error);
+ if (pixbuf == NULL)
+ {
+ g_debug ("Unable to use GNOME Shell's builtin screenshot interface: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_clear_object (&panel->display_screenshot);
+
+ if (data->whole_monitor) {
+ /* copy only top panel area from pixbuf */
+ gdk_pixbuf_copy_area (pixbuf,
+ 0,
+ 0,
+ data->monitor_rect.width,
+ data->monitor_rect.height - data->workarea_rect.height,
+ panel->display_screenshot,
+ 0,
+ 0);
+ g_object_unref (pixbuf);
+
+ }
+ else {
+ panel->display_screenshot = pixbuf;
+ }
+
+ /* invalidate existing cached pixbuf */
+ g_object_set_data (G_OBJECT (panel->current_background), "pixbuf", NULL);
+
+ /* remove the temporary file created by the shell */
+ g_unlink (panel->screenshot_path);
+ g_clear_pointer (&panel->screenshot_path, g_free);
+
+out:
+ update_display_preview (panel, WID ("background-desktop-drawingarea"), panel->current_background);
+ g_free (data);
+}
+
static gboolean
-on_preview_draw (GtkWidget *widget,
- cairo_t *cr,
- CcBackgroundPanel *panel)
+calculate_contiguous_workarea (ScreenshotData *data)
{
- update_display_preview (panel, widget, panel->current_background);
+ /* Optimise for the shell panel being the only non-workarea
+ * object at the top of the screen */
+ if (data->workarea_rect.x != data->monitor_rect.x)
+ return FALSE;
+ if ((data->workarea_rect.y + data->workarea_rect.height) != (data->monitor_rect.y +
data->monitor_rect.height))
+ return FALSE;
+
+ data->capture_rect.x = data->monitor_rect.x;
+ data->capture_rect.width = data->monitor_rect.width;
+ data->capture_rect.y = data->monitor_rect.y;
+ data->capture_rect.height = data->monitor_rect.height - data->workarea_rect.height;
return TRUE;
}
+static void
+get_screenshot_async (CcBackgroundPanel *panel)
+{
+ gchar *path, *tmpname;
+ const gchar *method_name;
+ GVariant *method_params;
+ GtkWidget *widget;
+ ScreenshotData *data;
+ int primary;
+
+ data = g_new0 (ScreenshotData, 1);
+ data->panel = panel;
+
+ widget = WID ("background-desktop-drawingarea");
+ primary = gdk_screen_get_primary_monitor (gtk_widget_get_screen (widget));
+ gdk_screen_get_monitor_geometry (gtk_widget_get_screen (widget), primary, &data->monitor_rect);
+ gdk_screen_get_monitor_workarea (gtk_widget_get_screen (widget), primary, &data->workarea_rect);
+ if (calculate_contiguous_workarea (data)) {
+ g_debug ("Capturing only a portion of the screen");
+ } else {
+ g_debug ("Capturing the whole monitor");
+ data->whole_monitor = TRUE;
+ data->capture_rect = data->monitor_rect;
+ }
+
+ g_debug ("Trying to capture rectangle %dx%d (at %d,%d)",
+ data->capture_rect.width, data->capture_rect.height, data->capture_rect.x, data->capture_rect.y);
+
+ path = g_build_filename (g_get_user_cache_dir (), "gnome-control-center", NULL);
+ g_mkdir_with_parents (path, USER_DIR_MODE);
+
+ tmpname = g_strdup_printf ("scr-%d.png", g_random_int ());
+ g_free (panel->screenshot_path);
+ panel->screenshot_path = g_build_filename (path, tmpname, NULL);
+ g_print (panel->screenshot_path);
+ g_free (path);
+ g_free (tmpname);
+
+ method_name = "ScreenshotArea";
+ method_params = g_variant_new ("(iiiibs)",
+ data->capture_rect.x, data->capture_rect.y,
+ data->capture_rect.width, data->capture_rect.height,
+ FALSE, /* flash */
+ panel->screenshot_path);
+
+ g_dbus_connection_call (panel->connection,
+ "org.gnome.Shell.Screenshot",
+ "/org/gnome/Shell/Screenshot",
+ "org.gnome.Shell.Screenshot",
+ method_name,
+ method_params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ panel->capture_cancellable,
+ on_screenshot_finished,
+ data);
+}
+
static gboolean
-on_lock_preview_draw (GtkWidget *widget,
- cairo_t *cr,
- CcBackgroundPanel *panel)
+on_preview_draw (GtkWidget *widget,
+ cairo_t *cr,
+ CcBackgroundPanel *panel)
{
- update_display_preview (panel, widget, panel->current_lock_background);
+ /* we have another shot in flight or an existing cache */
+ if (panel->display_screenshot == NULL
+ && panel->screenshot_path == NULL)
+ {
+ //get_screenshot_async (panel);
+ }
+ else
+ update_display_preview (panel, widget, panel->current_background);
+
return TRUE;
}
static void
reload_current_bg (CcBackgroundPanel *panel,
- GSettings *settings)
+ GSettings *settings
+ )
{
g_autoptr(CcBackgroundItem) saved = NULL;
CcBackgroundItem *configured;
@@ -269,7 +437,7 @@ reload_current_bg (CcBackgroundPanel *panel,
g_autofree gchar *scolor = NULL;
/* Load the saved configuration */
- uri = get_save_path (panel, settings);
+ uri = get_save_path ("last-edited.xml");
saved = cc_background_xml_get_item (uri);
/* initalise the current background information from settings */
@@ -303,23 +471,16 @@ reload_current_bg (CcBackgroundPanel *panel,
if (cc_background_item_get_placement (saved) == G_DESKTOP_BACKGROUND_STYLE_NONE)
flags &=~ (CC_BACKGROUND_ITEM_HAS_PCOLOR | CC_BACKGROUND_ITEM_HAS_SCOLOR);
g_object_set (G_OBJECT (configured),
- "name", cc_background_item_get_name (saved),
- "flags", flags,
- "source-url", cc_background_item_get_source_url (saved),
- "source-xml", cc_background_item_get_source_xml (saved),
- NULL);
+ "name", cc_background_item_get_name (saved),
+ "flags", flags,
+ "source-url", cc_background_item_get_source_url (saved),
+ "source-xml", cc_background_item_get_source_xml (saved),
+ NULL);
}
- if (settings == panel->settings)
- {
- g_clear_object (&panel->current_background);
- panel->current_background = configured;
- }
- else
- {
- g_clear_object (&panel->current_lock_background);
- panel->current_lock_background = configured;
- }
+ g_clear_object (&panel->current_background);
+ panel->current_background = configured;
+
cc_background_item_load (configured, NULL);
}
@@ -329,9 +490,9 @@ create_save_dir (void)
g_autofree char *path = NULL;
path = g_build_filename (g_get_user_config_dir (),
- "gnome-control-center",
- "backgrounds",
- NULL);
+ "gnome-control-center",
+ "backgrounds",
+ NULL);
if (g_mkdir_with_parents (path, USER_DIR_MODE) < 0)
{
g_warning ("Failed to create directory '%s'", path);
@@ -360,7 +521,7 @@ copy_finished_cb (GObject *source_object,
}
item = g_object_get_data (source_object, "item");
settings = g_object_get_data (source_object, "settings");
- current_background = get_current_background (panel, settings);
+ current_background = panel->current_background;
g_settings_apply (settings);
@@ -381,10 +542,10 @@ copy_finished_cb (GObject *source_object,
g_autofree gchar *filename = NULL;
update_preview (panel, settings, item);
- current_background = get_current_background (panel, settings);
+ current_background = panel->current_background;
/* Save the source XML if there is one */
- filename = get_save_path (panel, settings);
+ filename = get_save_path ("last-edited.xml");
if (create_save_dir ())
cc_background_xml_save (current_background, filename);
}
@@ -514,64 +675,132 @@ set_background (CcBackgroundPanel *panel,
g_settings_apply (settings);
/* Save the source XML if there is one */
- filename = get_save_path (panel, settings);
+ filename = get_save_path ("last-edited.xml");
if (create_save_dir ())
- cc_background_xml_save (get_current_background (panel, settings), filename);
+ cc_background_xml_save (panel->current_background, filename);
}
}
static void
-on_chooser_dialog_response (GtkDialog *dialog,
- int response_id,
- CcBackgroundPanel *panel)
+on_settings_changed (GSettings *settings,
+ gchar *key,
+ CcBackgroundPanel *self)
{
- if (response_id == GTK_RESPONSE_OK)
- {
- g_autoptr(CcBackgroundItem) item = NULL;
-
- item = cc_background_chooser_dialog_get_item (CC_BACKGROUND_CHOOSER_DIALOG (dialog));
- if (item != NULL)
- set_background (panel, g_object_get_data (G_OBJECT (dialog), "settings"), item);
- }
+ reload_current_bg (self, settings);
+ update_preview (self, settings, NULL);
+}
- gtk_widget_destroy (GTK_WIDGET (dialog));
+static GtkWidget *
+create_view (GtkWidget *parent, GtkTreeModel *model)
+{
+ GtkCellRenderer *renderer;
+ GtkWidget *icon_view;
+ GtkWidget *sw;
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_widget_set_hexpand (sw, TRUE);
+ gtk_widget_set_vexpand (sw, TRUE);
+
+ icon_view = gtk_icon_view_new ();
+ gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), model);
+ gtk_widget_set_hexpand (icon_view, TRUE);
+ gtk_container_add (GTK_CONTAINER (sw), icon_view);
+
+ gtk_icon_view_set_columns (GTK_ICON_VIEW (icon_view), 3);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view),
+ renderer,
+ FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view),
+ renderer,
+ "surface", 0,
+ NULL);
+
+ return sw;
}
static void
-launch_chooser (CcBackgroundPanel *panel,
- GSettings *settings)
+on_background_select (GtkFlowBox *box,
+ GtkFlowBoxChild *child,
+ gpointer user_data)
{
- GtkWidget *dialog;
-
- dialog = cc_background_chooser_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (WID
("background-panel"))));
- g_object_set_data (G_OBJECT (dialog), "settings", settings);
- gtk_widget_show (dialog);
- g_signal_connect (dialog, "response", G_CALLBACK (on_chooser_dialog_response), panel);
- panel->chooser = dialog;
- g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &panel->chooser);
+ CcBackgroundGridItem *selected = (CcBackgroundGridItem *) child;
+ CcBackgroundPanel *panel = user_data;
+ CcBackgroundItem *item;
+ item = cc_background_grid_item_get_ref (selected);
+
+ set_background (panel, panel->settings, item);
}
-static void
-on_background_button_clicked (GtkButton *button,
- CcBackgroundPanel *panel)
+gboolean
+do_foreach_background_item (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
{
- launch_chooser (panel, panel->settings);
+ CcBackgroundPanel *panel = data;
+ CcBackgroundGridItem *flow;
+ GtkWidget *widget;
+ GdkPixbuf *pixbuf;
+ CcBackgroundItem *item;
+ gint scale_factor;
+ const gint preview_width = 309;
+ const gint preview_height = 168;
+
+ gtk_tree_model_get (model, iter, 1, &item, -1);
+
+ scale_factor = gtk_widget_get_scale_factor (panel);
+
+ pixbuf = cc_background_item_get_frame_thumbnail (item,
+ panel->thumb_factory,
+ preview_width,
+ preview_height,
+ scale_factor,
+ -2, TRUE);
+
+ widget = gtk_image_new_from_pixbuf (pixbuf);
+
+ flow = cc_background_grid_item_new(item);
+ cc_background_grid_item_set_ref (flow, item);
+ gtk_widget_show (flow);
+ gtk_widget_show (widget);
+ gtk_container_add (flow, widget);
+
+ gtk_flow_box_insert (GTK_FLOW_BOX (WID("background-gallery")), flow, -1);
+ return TRUE;
}
static void
-on_lock_button_clicked (GtkButton *button,
- CcBackgroundPanel *panel)
+on_source_added_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
{
- launch_chooser (panel, panel->lock_settings);
+ //gtk_tree_model_foreach (model, foreach_background_item, user_data);
+ do_foreach_background_item (model, path, iter, user_data);
}
static void
-on_settings_changed (GSettings *settings,
- gchar *key,
- CcBackgroundPanel *panel)
+load_wallpapers (CcBackgroundPanel *panel, GtkWidget *parent)
{
- reload_current_bg (panel, settings);
- update_preview (panel, settings, NULL);
+ GtkListStore *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GValue *value = NULL;
+ gint scale_factor;
+
+ scale_factor = gtk_widget_get_scale_factor (panel);
+
+ panel->wallpapers_source = bg_wallpapers_source_new (GTK_WINDOW (NULL));
+ model = bg_source_get_liststore (BG_SOURCE (panel->wallpapers_source));
+
+ gtk_tree_model_foreach (model, do_foreach_background_item, panel);
+
+ g_signal_connect (model, "row-inserted", G_CALLBACK (on_source_added_cb), panel);
+ //g_signal_connect (model, "row-deleted", G_CALLBACK (on_source_removed_cb), chooser);
+ //g_signal_connect (model, "row-changed", G_CALLBACK (on_source_modified_cb), chooser);
}
static void
@@ -579,6 +808,9 @@ cc_background_panel_init (CcBackgroundPanel *panel)
{
gchar *objects[] = {"background-panel", NULL };
g_autoptr(GError) err = NULL;
+ GtkCssProvider *provider;
+ GtkStyleProvider *provider;
+ GtkStyleContext *context;
GtkWidget *widget;
panel->connection = g_application_get_dbus_connection (g_application_get_default ());
@@ -598,38 +830,43 @@ cc_background_panel_init (CcBackgroundPanel *panel)
panel->settings = g_settings_new (WP_PATH_ID);
g_settings_delay (panel->settings);
- panel->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
- g_settings_delay (panel->lock_settings);
-
/* add the top level widget */
widget = WID ("background-panel");
gtk_container_add (GTK_CONTAINER (panel), widget);
gtk_widget_show_all (GTK_WIDGET (panel));
+ /* add style */
+ widget = WID ("background-preview-top");
+ provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
+ gtk_css_provider_load_from_resource (provider,
+ "org/gnome/control-center/background/background.css");
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
+ provider,
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+
/* setup preview area */
widget = WID ("background-desktop-drawingarea");
g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), panel);
- widget = WID ("background-lock-drawingarea");
- g_signal_connect (widget, "draw", G_CALLBACK (on_lock_preview_draw), panel);
panel->copy_cancellable = g_cancellable_new ();
panel->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
+ /* add the gallery widget */
+ widget = WID ("background-gallery");
+
+ g_signal_connect (G_OBJECT (widget), "child-activated",
+ G_CALLBACK (on_background_select), panel);
+
+ load_wallpapers (panel, widget);
+
/* Load the backgrounds */
reload_current_bg (panel, panel->settings);
update_preview (panel, panel->settings, NULL);
- reload_current_bg (panel, panel->lock_settings);
- update_preview (panel, panel->lock_settings, NULL);
/* Background settings */
g_signal_connect (panel->settings, "changed", G_CALLBACK (on_settings_changed), panel);
- g_signal_connect (panel->lock_settings, "changed", G_CALLBACK (on_settings_changed), panel);
-
- /* Background buttons */
- widget = WID ("background-set-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), panel);
- widget = WID ("background-lock-set-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (on_lock_button_clicked), panel);
}
diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c
new file mode 100644
index 000000000..33c190049
--- /dev/null
+++ b/panels/background/cc-background-store.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 jsparber
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Julian Sparber <julian sparber net>
+ *
+ */
+
+#include <gio/gio.h>
+#include "cc-background-store.h"
+#include "cc-background-item.h"
+
+struct _CcBackgroundStore
+{
+ GObject parent_instance;
+
+ /* Other members, including private data. */
+};
+
+/* Private structure definition. */
+typedef struct _CcBackgroundStorePrivate CcBackgroundStorePrivate;
+
+struct _CcBackgroundStorePrivate
+{
+ GListStore * model;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (CcBackgroundStore, cc_background_store, G_TYPE_OBJECT)
+
+
+static void
+cc_background_store_dispose (GObject *gobject)
+{
+ CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (CC_BACKGROUND_STORE (gobject));
+
+ /* In dispose(), you are supposed to free all types referenced from this
+ * object which might themselves hold a reference to self. Generally,
+ * the most simple solution is to unref all members on which you own a
+ * reference.
+ */
+
+ /* dispose() might be called multiple times, so we must guard against
+ * calling g_object_unref() on an invalid GObject by setting the member
+ * NULL; g_clear_object() does this for us.
+ */
+ g_clear_object (&priv->model);
+
+ /* Always chain up to the parent class; there is no need to check if
+ * the parent class implements the dispose() virtual function: it is
+ * always guaranteed to do so
+ */
+ G_OBJECT_CLASS (cc_background_store_parent_class)->dispose (gobject);
+}
+
+static void
+cc_background_store_finalize (GObject *gobject)
+{
+ //CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (CC_BACKGROUND_STORE
(gobject));
+
+ //g_free (priv->filename);
+
+ /* Always chain up to the parent class; as with dispose(), finalize()
+ * is guaranteed to exist on the parent's class virtual function table
+ */
+ G_OBJECT_CLASS (cc_background_store_parent_class)->finalize (gobject);
+}
+
+static void
+cc_background_store_class_init (CcBackgroundStoreClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = cc_background_store_dispose;
+ object_class->finalize = cc_background_store_finalize;
+}
+
+static void
+cc_background_store_init (CcBackgroundStore *self)
+{
+ CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (self);
+ priv->model = g_list_store_new (cc_background_item_get_type());
+}
diff --git a/panels/background/cc-background-store.h b/panels/background/cc-background-store.h
new file mode 100644
index 000000000..40da76d8b
--- /dev/null
+++ b/panels/background/cc-background-store.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 jsparber
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Julian Sparber <julian sparber net>
+ *
+ */
+
+#ifndef __CC_BACKGROUND_STORE_H__
+#define __CC_BACKGROUND_STORE_H__
+
+#include <glib-object.h>
+/*
+ * Potentially, include other headers on which this header depends.
+ */
+
+G_BEGIN_DECLS
+
+/*
+ * Type declaration.
+ */
+#define CC_TYPE_BACKGROUND_STORE (cc_background_store_get_type ())
+G_DECLARE_FINAL_TYPE (CcBackgroundStore, cc_background_store, CC, BACKGROUND_STORE, GObject)
+
+/*
+ * Method definitions.
+ */
+CcBackgroundStore *cc_backgroud_store_new (void);
+
+G_END_DECLS
+
+#endif /* __CC_BACKGROUND_STORE_H__ */
diff --git a/panels/background/data/background.css b/panels/background/data/background.css
new file mode 100644
index 000000000..c2874a6bd
--- /dev/null
+++ b/panels/background/data/background.css
@@ -0,0 +1,7 @@
+.background-gallery {
+ background: #fff;
+}
+
+.black-border {
+ border: 1px solid black;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]