[gnome-photos/wip/rishi/manager-model: 6/6] WIP



commit 2e44cda4c675bfa0faddcea8657fc3c3b14dc158
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Oct 27 11:43:30 2016 +0200

    WIP

 src/photos-base-manager.c |   32 ++++++++++++++++++++++++++++++++
 src/photos-item-manager.c |    2 +-
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index e85a9db..ae1cc81 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -67,11 +67,41 @@ G_DEFINE_TYPE_WITH_CODE (PhotosBaseManager, photos_base_manager, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, 
photos_base_manager_list_model_iface_init));
 
 
+typedef struct _PhotosBaseManagerHiddenItem PhotosBaseManagerHiddenItem;
+
+struct _PhotosBaseManagerHiddenItem
+{
+  GObject *object;
+  GSequenceIter *iter;
+};
+
+
+static PhotosBaseManagerHiddenItem *
+photos_base_manager_hidden_item_new (GObject *object, GSequenceIter *iter)
+{
+  PhotosBaseManagerHiddenItem *hidden_item;
+
+  hidden_item = g_slice_new0 (PhotosBaseManagerHiddenItem);
+  hidden_item->object = g_object_ref (object);
+  hidden_item->iter = iter;
+  return hidden_item;
+}
+
+
+static void
+photos_base_manager_hidden_item_free (PhotosBaseManagerHiddenItem *hidden_item)
+{
+  g_object_unref (hidden_item->object);
+  g_slice_free (PhotosBaseManagerHiddenItem, hidden_item);
+}
+
+
 static void
 photos_base_manager_default_add_object (PhotosBaseManager *self, GObject *object)
 {
   PhotosBaseManagerPrivate *priv;
   GObject *old_object;
+  GSequenceIter *iter;
   const gchar *id;
 
   priv = photos_base_manager_get_instance_private (self);
@@ -81,7 +111,9 @@ photos_base_manager_default_add_object (PhotosBaseManager *self, GObject *object
   if (old_object != NULL)
     return;
 
+  iter = g_sequence_append (priv->sequence, g_object_ref (object));
   g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object));
+
   g_signal_emit (self, signals[OBJECT_ADDED], 0, object);
 }
 
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 39d3d59..33cbde3 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -127,7 +127,7 @@ static void
 photos_item_manager_hidden_item_free (PhotosItemManagerHiddenItem *hidden_item)
 {
   g_free (hidden_item->modes);
-  g_object_ref (hidden_item->item);
+  g_object_unref (hidden_item->item);
   g_slice_free (PhotosItemManagerHiddenItem, hidden_item);
 }
 


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