[gnome-photos/wip/rishi/item-manager: 7/11] base-manager: Make get_object_by_id a virtual method



commit a2db4d0568107792dd723ad936736df28bdae085
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Jul 25 10:37:48 2016 +0200

    base-manager: Make get_object_by_id a virtual method
    
    This is required to split PhotosItemManager to have a separate child
    manager for each mode.

 src/photos-base-manager.c |   32 ++++++++++++++++++++------------
 src/photos-base-manager.h |    1 +
 2 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 5fea604..41c9b68 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -87,6 +87,24 @@ photos_base_manager_default_get_filter (PhotosBaseManager *self, gint flags)
 }
 
 
+static GObject *
+photos_base_manager_default_get_object_by_id (PhotosBaseManager *self, const gchar *id)
+{
+  PhotosBaseManagerPrivate *priv;
+  GObject *ret_val = NULL;
+
+  priv = photos_base_manager_get_instance_private (self);
+
+  if (id == NULL)
+    goto out;
+
+  ret_val = g_hash_table_lookup (priv->objects, id);
+
+ out:
+  return ret_val;
+}
+
+
 static gchar *
 photos_base_manager_default_get_where (PhotosBaseManager *self, gint flags)
 {
@@ -208,6 +226,7 @@ photos_base_manager_class_init (PhotosBaseManagerClass *class)
   object_class->set_property = photos_base_manager_set_property;
   class->add_object = photos_base_manager_default_add_object;
   class->get_filter = photos_base_manager_default_get_filter;
+  class->get_object_by_id = photos_base_manager_default_get_object_by_id;
   class->get_where = photos_base_manager_default_get_where;
   class->remove_object_by_id = photos_base_manager_default_remove_object_by_id;
   class->set_active_object = photos_base_manager_default_set_active_object;
@@ -379,18 +398,7 @@ photos_base_manager_get_filter (PhotosBaseManager *self, gint flags)
 GObject *
 photos_base_manager_get_object_by_id (PhotosBaseManager *self, const gchar *id)
 {
-  PhotosBaseManagerPrivate *priv;
-  GObject *ret_val = NULL;
-
-  priv = photos_base_manager_get_instance_private (self);
-
-  if (id == NULL)
-    goto out;
-
-  ret_val = g_hash_table_lookup (priv->objects, id);
-
- out:
-  return ret_val;
+  return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_object_by_id (self, id);
 }
 
 
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index 143087f..153f371 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -67,6 +67,7 @@ struct _PhotosBaseManagerClass
   /* virtual methods */
   void (*add_object)      (PhotosBaseManager *self, GObject *object);
   gchar *(*get_filter)    (PhotosBaseManager *self, gint flags);
+  GObject *(*get_object_by_id) (PhotosBaseManager *self, const gchar *id);
   gchar *(*get_where)    (PhotosBaseManager *self, gint flags);
   void (*remove_object_by_id) (PhotosBaseManager *self, const gchar *id);
   gboolean (*set_active_object)    (PhotosBaseManager *self, GObject *object);


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