[gnome-control-center/wip/jsparber/background: 28/40] background: less exposure of the the wallpaper store



commit 9eb8204f7ba34aa19d5d02a89169257b1b954f1e
Author: Julian Sparber <julian sparber net>
Date:   Thu Feb 1 01:00:03 2018 +0100

    background: less exposure of the the wallpaper store
    
    use a wrapper to bind the GListModel to a flowbox
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788515

 panels/background/cc-background-panel.c |   10 +++++-----
 panels/background/cc-background-store.c |   14 +++++++++++---
 panels/background/cc-background-store.h |   13 ++++++++-----
 3 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 370cefb..c0b1736 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -792,11 +792,11 @@ cc_background_panel_init (CcBackgroundPanel *panel)
   update_preview (panel, panel->settings, NULL);
 
   /* Bind liststore to flowbox */
-  gtk_flow_box_bind_model (GTK_FLOW_BOX (WID("background-gallery")),
-                           G_LIST_MODEL (cc_background_store_get_liststore (panel->store)),
-                           create_gallery_item,
-                           panel,
-                           NULL);
+  cc_background_store_bind_flow_box (panel->store,
+                                     panel,
+                                     WID("background-gallery"),
+                                     create_gallery_item);
+
 
   /* Background settings */
   g_signal_connect (panel->settings, "changed", G_CALLBACK (on_settings_changed), panel);
diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c
index 2601297..1d11d89 100644
--- a/panels/background/cc-background-store.c
+++ b/panels/background/cc-background-store.c
@@ -95,11 +95,19 @@ cc_background_store_init (CcBackgroundStore *self)
   cc_background_xml_load_list_async (self->xml, NULL, list_load_cb, self);
 }
 
-GListStore *
-cc_background_store_get_liststore (CcBackgroundStore *self) {
-  return self->model;
+void 
+cc_background_store_bind_flow_box (CcBackgroundStore *self,
+                                   gpointer panel,
+                                   GtkWidget *widget,
+                                   GtkFlowBoxCreateWidgetFunc create_widget_fun) {
+  gtk_flow_box_bind_model (GTK_FLOW_BOX (widget),
+                           G_LIST_MODEL(self->model),
+                           create_widget_fun,
+                           panel,
+                           NULL);
 }
 
+
 CcBackgroundStore *
 cc_background_store_new ()
 {
diff --git a/panels/background/cc-background-store.h b/panels/background/cc-background-store.h
index faec580..d326407 100644
--- a/panels/background/cc-background-store.h
+++ b/panels/background/cc-background-store.h
@@ -22,6 +22,7 @@
 #define __CC_BACKGROUND_STORE_H__
 
 #include <glib-object.h>
+#include <gtk/gtk.h>
 /*
  * Potentially, include other headers on which this header depends.
  */
@@ -35,11 +36,13 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (CcBackgroundStore, cc_background_store, CC, BACKGROUND_STORE, GObject)
 
 /*
- * Method definitions.
- */
-CcBackgroundStore *cc_background_store_new (void);
-GListStore *cc_background_store_get_liststore (CcBackgroundStore *);
-
+* Method definitions.
+*/
+CcBackgroundStore       *cc_background_store_new           (void);
+void                    cc_background_store_bind_flow_box  (CcBackgroundStore           *self,
+                                                            gpointer                     panel,
+                                                            GtkWidget                   *widget,
+                                                            GtkFlowBoxCreateWidgetFunc   create_widget_fun);
 G_END_DECLS
 
 #endif /* __CC_BACKGROUND_STORE_H__ */


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