[devhelp/wip/stuff: 3/3] book tree: use constructed to setup the book manager



commit 304ae4a6ce4c75040fd2ec237afb9e048288a4b2
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Wed Jul 24 14:25:27 2013 +0200

    book tree: use constructed to setup the book manager

 src/dh-book-tree.c |   76 ++++++++++++++++++++++++++-------------------------
 1 files changed, 39 insertions(+), 37 deletions(-)
---
diff --git a/src/dh-book-tree.c b/src/dh-book-tree.c
index e7c428d..56f41ff 100644
--- a/src/dh-book-tree.c
+++ b/src/dh-book-tree.c
@@ -163,35 +163,6 @@ dh_book_tree_set_property (GObject      *object,
 }
 
 static void
-dh_book_tree_class_init (DhBookTreeClass *klass)
-{
-        GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-        object_class->dispose = dh_book_tree_dispose;
-        object_class->get_property = dh_book_tree_get_property;
-        object_class->set_property = dh_book_tree_set_property;
-
-        g_object_class_install_property (object_class,
-                                         PROP_BOOK_MANAGER,
-                                         g_param_spec_object ("book-manager",
-                                                              "Book Manager",
-                                                              "The book maanger",
-                                                              DH_TYPE_BOOK_MANAGER,
-                                                              G_PARAM_READWRITE |
-                                                              G_PARAM_CONSTRUCT_ONLY));
-
-        signals[LINK_SELECTED] =
-                g_signal_new ("link-selected",
-                             G_TYPE_FROM_CLASS (klass),
-                             G_SIGNAL_RUN_LAST,
-                             0,
-                             NULL, NULL,
-                             g_cclosure_marshal_VOID__POINTER,
-                             G_TYPE_NONE,
-                             1, G_TYPE_POINTER);
-}
-
-static void
 dh_book_tree_init (DhBookTree *tree)
 {
         DhBookTreePrivate *priv;
@@ -749,14 +720,11 @@ book_tree_init_selection (DhBookTree *tree)
                                           tree);
 }
 
-GtkWidget *
-dh_book_tree_new (DhBookManager *book_manager)
+static void
+dh_book_tree_constructed (GObject *object)
 {
-        DhBookTree       *tree;
-        DhBookTreePrivate   *priv;
-
-       tree = g_object_new (DH_TYPE_BOOK_TREE, "book-manager", book_manager, NULL);
-        priv = dh_book_tree_get_instance_private (tree);
+        DhBookTree *tree = DH_BOOK_TREE (object);
+        DhBookTreePrivate *priv = dh_book_tree_get_instance_private (tree);
 
         priv->book_created_id = g_signal_connect (priv->book_manager,
                                                   "book-created",
@@ -782,8 +750,42 @@ dh_book_tree_new (DhBookManager *book_manager)
         book_tree_populate_tree (tree);
 
         book_tree_init_selection (tree);
+}
+
+static void
+dh_book_tree_class_init (DhBookTreeClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = dh_book_tree_dispose;
+        object_class->get_property = dh_book_tree_get_property;
+        object_class->set_property = dh_book_tree_set_property;
+        object_class->constructed = dh_book_tree_constructed;
+
+        g_object_class_install_property (object_class,
+                                         PROP_BOOK_MANAGER,
+                                         g_param_spec_object ("book-manager",
+                                                              "Book Manager",
+                                                              "The book maanger",
+                                                              DH_TYPE_BOOK_MANAGER,
+                                                              G_PARAM_READWRITE |
+                                                              G_PARAM_CONSTRUCT_ONLY));
 
-        return GTK_WIDGET (tree);
+        signals[LINK_SELECTED] =
+                g_signal_new ("link-selected",
+                             G_TYPE_FROM_CLASS (klass),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__POINTER,
+                             G_TYPE_NONE,
+                             1, G_TYPE_POINTER);
+}
+
+GtkWidget *
+dh_book_tree_new (DhBookManager *book_manager)
+{
+        return GTK_WIDGET (g_object_new (DH_TYPE_BOOK_TREE, "book-manager", book_manager, NULL));
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]