[gnome-control-center/wip/jsparber/background: 14/28] background: refactor cc-background-store
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 14/28] background: refactor cc-background-store
- Date: Sat, 17 Feb 2018 19:42:41 +0000 (UTC)
commit 6bd21359ca14b902cfb28240d607465f83c1986b
Author: Julian Sparber <julian sparber net>
Date: Mon Jan 15 15:38:43 2018 +0100
background: refactor cc-background-store
- remove private struct of cc-background-store
- remove CcBackgroundStore constructor
https://bugzilla.gnome.org/show_bug.cgi?id=788515
panels/background/cc-background-store.c | 74 +++++++--------------------------
1 file changed, 16 insertions(+), 58 deletions(-)
---
diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c
index 05eb09c27..26012976a 100644
--- a/panels/background/cc-background-store.c
+++ b/panels/background/cc-background-store.c
@@ -27,39 +27,19 @@ struct _CcBackgroundStore
{
GObject parent_instance;
- /* Other members, including private data. */
- //CcBackgroundStorePrivate *priv;
-};
-
-/* Private structure definition. */
-typedef struct _CcBackgroundStorePrivate CcBackgroundStorePrivate;
-
-struct _CcBackgroundStorePrivate
-{
GListStore *model;
CcBackgroundXml *xml;
};
-G_DEFINE_TYPE_WITH_PRIVATE (CcBackgroundStore, cc_background_store, G_TYPE_OBJECT)
-
+G_DEFINE_TYPE (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.
- */
+ CcBackgroundStore *self = CC_BACKGROUND_STORE (gobject);
- /* 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);
- g_clear_object (&priv->xml);
+ g_clear_object (&self->model);
+ g_clear_object (&self->xml);
/* Always chain up to the parent class; there is no need to check if
* the parent class implements the dispose() virtual function: it is
@@ -71,13 +51,6 @@ cc_background_store_dispose (GObject *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);
}
@@ -87,8 +60,7 @@ item_added (CcBackgroundXml *xml,
CcBackgroundItem *item,
CcBackgroundStore *self)
{
- CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (self);
- g_list_store_append (priv->model, item);
+ g_list_store_append (self->model, item);
}
static void
@@ -99,47 +71,33 @@ list_load_cb (GObject *source_object,
cc_background_xml_load_list_finish (res);
}
-static void
-cc_background_store_constructed (GObject *object)
-{
- CcBackgroundStore *self = CC_BACKGROUND_STORE (object);
- CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (self);
-
- G_OBJECT_CLASS (cc_background_store_parent_class)->constructed (object);
-
- g_signal_connect (G_OBJECT (priv->xml), "added",
- G_CALLBACK (item_added), self);
-
- /* Try adding the default background first */
- //load_default_bg (self);
-
- cc_background_xml_load_list_async (priv->xml, NULL, list_load_cb, self);
-}
-
-
-
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->constructed = cc_background_store_constructed;
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());
- priv->xml = cc_background_xml_new ();
+ self->model = g_list_store_new (cc_background_item_get_type());
+ self->xml = cc_background_xml_new ();
+
+ g_signal_connect (G_OBJECT (self->xml), "added",
+ G_CALLBACK (item_added), self);
+
+ /* Try adding the default background first */
+ //load_default_bg (self);
+
+ cc_background_xml_load_list_async (self->xml, NULL, list_load_cb, self);
}
GListStore *
cc_background_store_get_liststore (CcBackgroundStore *self) {
- CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (self);
- return priv->model;
+ return self->model;
}
CcBackgroundStore *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]