[gnome-photos/wip/rishi/manager-model: 4/4] base-manager: Implement GListModel



commit 8acf057183529abba7c0c4d31263e542203c9df6
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Oct 13 07:13:52 2016 +0200

    base-manager: Implement GListModel

 src/photos-base-manager.c |   41 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index b5da8ad..ed42a48 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -25,6 +25,7 @@
 
 #include "config.h"
 
+#include <gio/gio.h>
 #include <glib.h>
 
 #include "photos-base-manager.h"
@@ -57,8 +58,12 @@ enum
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
+static void photos_base_manager_list_model_iface_init (GListModelInterface *iface);
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosBaseManager, photos_base_manager, G_TYPE_OBJECT);
+
+G_DEFINE_TYPE_WITH_CODE (PhotosBaseManager, photos_base_manager, G_TYPE_OBJECT,
+                         G_ADD_PRIVATE (PhotosBaseManager)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, 
photos_base_manager_list_model_iface_init));
 
 
 static void
@@ -166,6 +171,31 @@ photos_base_manager_default_set_active_object (PhotosBaseManager *self, GObject
 }
 
 
+static gpointer
+photos_base_manager_get_item (GListModel *list, guint position)
+{
+  return NULL;
+}
+
+
+static GType
+photos_base_manager_get_item_type (GListModel *list)
+{
+  return PHOTOS_TYPE_FILTERABLE;
+}
+
+
+static guint
+photos_base_manager_get_n_items (GListModel *list)
+{
+  PhotosBaseManager *self = PHOTOS_BASE_MANAGER (list);
+  guint count;
+
+  count = photos_base_manager_get_objects_count (self);
+  return count;
+}
+
+
 static void
 photos_base_manager_dispose (GObject *object)
 {
@@ -314,6 +344,15 @@ photos_base_manager_class_init (PhotosBaseManagerClass *class)
 }
 
 
+static void
+photos_base_manager_list_model_iface_init (GListModelInterface *iface)
+{
+  iface->get_item = photos_base_manager_get_item;
+  iface->get_item_type = photos_base_manager_get_item_type;
+  iface->get_n_items = photos_base_manager_get_n_items;
+}
+
+
 PhotosBaseManager *
 photos_base_manager_new (void)
 {


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