[gnome-control-center/wip/jsparber/background] [refactor] remove private struct of cc-background-store https://bugzilla.gnome.org/show_bug.cgi?id=7



commit dfe26375e5aa0dbbbc28518bec997033f93609ab
Author: Julian Sparber <julian sparber net>
Date:   Mon Jan 15 15:38:43 2018 +0100

    [refactor] remove private struct of cc-background-store
    https://bugzilla.gnome.org/show_bug.cgi?id=788515

 panels/background/cc-background-store.c |   53 ++++++-------------------------
 1 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c
index 05eb09c..f351bb1 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));
+  CcBackgroundStore *self = 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);
-  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
@@ -103,21 +75,18 @@ 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_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 (priv->xml, NULL, list_load_cb, self);
+  cc_background_xml_load_list_async (self->xml, NULL, list_load_cb, self);
 }
 
-
-
 static void
 cc_background_store_class_init (CcBackgroundStoreClass *klass)
 {
@@ -131,15 +100,13 @@ cc_background_store_class_init (CcBackgroundStoreClass *klass)
 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 ();
 }
 
 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]