[buoh/cleanups] fixup! Port comic-list to GtkBuilder



commit b28140ebf1fc02c3abf1c290d701bdbd829e022e
Author: Jan Tojnar <jtojnar gmail com>
Date:   Mon Sep 24 05:01:18 2018 +0200

    fixup! Port comic-list to GtkBuilder

 data/ui/comic-list.ui |  1 +
 src/buoh-comic-list.c | 31 +++++++++++++++----------------
 src/buoh-comic-list.h |  2 +-
 src/buoh-window.c     |  5 ++++-
 4 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/data/ui/comic-list.ui b/data/ui/comic-list.ui
index 75c5ac2..01900b9 100644
--- a/data/ui/comic-list.ui
+++ b/data/ui/comic-list.ui
@@ -3,6 +3,7 @@
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <template class="BuohComicList" parent="GtkBin">
+    <property name="border-width">6</property>
     <child>
       <object class="GtkScrolledWindow">
         <property name="visible">1</property>
diff --git a/src/buoh-comic-list.c b/src/buoh-comic-list.c
index bb197e6..2938e1f 100644
--- a/src/buoh-comic-list.c
+++ b/src/buoh-comic-list.c
@@ -90,23 +90,13 @@ buoh_comic_list_visible (GtkTreeModel *model,
 static void
 buoh_comic_list_init (BuohComicList *buoh_comic_list)
 {
-        GtkTreeModel      *model;
 
         buoh_comic_list->priv = buoh_comic_list_get_instance_private (buoh_comic_list);
 
         buoh_comic_list->priv->comic_manager = NULL;
         buoh_comic_list->priv->view = NULL;
 
-        model = buoh_get_comics_model (BUOH);
-        buoh_comic_list->priv->model = gtk_tree_model_filter_new (model, NULL);
-        gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (buoh_comic_list->priv->model),
-                                                buoh_comic_list_visible,
-                                                NULL, NULL);
-
         gtk_widget_init_template (GTK_WIDGET (buoh_comic_list));
-
-        gtk_tree_view_set_model (GTK_TREE_VIEW (buoh_comic_list->priv->tree_view),
-                                 buoh_comic_list->priv->model);
 }
 
 static void
@@ -188,14 +178,23 @@ buoh_comic_list_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 }
 
 GtkWidget *
-buoh_comic_list_new (void)
+buoh_comic_list_new (GtkTreeModel *model)
 {
-        GtkWidget *buoh_comic_list;
+        GtkWidget *buoh_comic_list_widget;
+
+        buoh_comic_list_widget = GTK_WIDGET (g_object_new (BUOH_TYPE_COMIC_LIST, NULL));
+
+        BuohComicList *buoh_comic_list = BUOH_COMIC_LIST (buoh_comic_list_widget);
+
+        buoh_comic_list->priv->model = gtk_tree_model_filter_new (model, NULL);
+        gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (buoh_comic_list->priv->model),
+                                                buoh_comic_list_visible,
+                                                NULL, NULL);
+
+        gtk_tree_view_set_model (GTK_TREE_VIEW (buoh_comic_list->priv->tree_view),
+                                 buoh_comic_list->priv->model);
 
-        buoh_comic_list = GTK_WIDGET (g_object_new (BUOH_TYPE_COMIC_LIST,
-                                                    "border-width", 6,
-                                                    NULL));
-        return buoh_comic_list;
+        return buoh_comic_list_widget;
 }
 
 void
diff --git a/src/buoh-comic-list.h b/src/buoh-comic-list.h
index ccccc34..5b7ba57 100644
--- a/src/buoh-comic-list.h
+++ b/src/buoh-comic-list.h
@@ -48,7 +48,7 @@ struct _BuohComicListClass {
 };
 
 GType             buoh_comic_list_get_type        (void) G_GNUC_CONST;
-GtkWidget        *buoh_comic_list_new             (void);
+GtkWidget        *buoh_comic_list_new             (GtkTreeModel  *model);
 
 void              buoh_comic_list_set_view        (BuohComicList *comic_list,
                                                    BuohView      *view);
diff --git a/src/buoh-window.c b/src/buoh-window.c
index c133b88..3d43cc4 100644
--- a/src/buoh-window.c
+++ b/src/buoh-window.c
@@ -232,6 +232,7 @@ static void
 buoh_window_init (BuohWindow *buoh_window)
 {
         GtkWidget        *tree_view;
+        GtkTreeModel     *model;
         GtkTreeSelection *selection;
         GtkWidget        *vbox, *paned, *menubar;
         GtkWidget        *toolbar;
@@ -344,8 +345,10 @@ buoh_window_init (BuohWindow *buoh_window)
                          TRUE, FALSE);
         gtk_widget_show (GTK_WIDGET (buoh_window->priv->view));
 
+        model = buoh_get_comics_model (BUOH);
+
         /* buoh comic list */
-        buoh_window->priv->comic_list = BUOH_COMIC_LIST (buoh_comic_list_new ());
+        buoh_window->priv->comic_list = BUOH_COMIC_LIST (buoh_comic_list_new (model));
         buoh_comic_list_set_view (buoh_window->priv->comic_list, buoh_window->priv->view);
         gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (buoh_window->priv->comic_list),
                          TRUE, FALSE);


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