[gnome-photos/wip/rishi/item-manager] item-manager: Check for collections



commit 6c6047f671016dd998dd700f0a21bc2c1cb32f29
Author: Umang Jain <mailumangjain gmail com>
Date:   Mon Aug 15 19:11:32 2016 +0530

    item-manager: Check for collections
    
    Now, we have child base managers so the object should be inserted
    into one of the child base managers. Therefore, item_manager_add_object makes
    no real sense. Also, check for "collections" should also be shifted to
    item_manager_add_item function.

 src/photos-item-manager.c |   46 +++++++++++++++++---------------------------
 1 files changed, 18 insertions(+), 28 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index acc6723..efc3a1c 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -96,30 +96,7 @@ static GObject* photos_item_manager_get_active_object (PhotosBaseManager *mngr);
 static void
 photos_item_manager_add_object (PhotosBaseManager *mngr, GObject *object)
 {
-  PhotosItemManager *self = PHOTOS_ITEM_MANAGER (mngr);
-  PhotosBaseItem *item;
-  const gchar *id;
-  gpointer *old_collection;
-
-  g_return_if_fail (PHOTOS_IS_BASE_ITEM (object));
-
-  item = PHOTOS_BASE_ITEM (object);
-
-  if (!photos_base_item_is_collection (item))
-    goto end;
-
-  id = photos_filterable_get_id (PHOTOS_FILTERABLE (item));
-  if (id == NULL)
-    goto end;
-
-  old_collection = g_hash_table_lookup (self->collections, id);
-  if (old_collection != NULL)
-    goto end;
-
-  g_hash_table_insert (self->collections, g_strdup (id), g_object_ref (item));
-
- end:
-  PHOTOS_BASE_MANAGER_CLASS (photos_item_manager_parent_class)->add_object (mngr, object);
+  g_assert_not_reached ();
 }
 
 
@@ -682,6 +659,7 @@ photos_item_manager_add_item (PhotosItemManager *self, PhotosWindowMode mode, Tr
   PhotosBaseManager *item_mngr_chld;
   GObject *object;
   const gchar *id;
+  gpointer *old_collection;
 
   item_mngr_chld = self->item_mngr_chldrn[mode];
 
@@ -689,9 +667,21 @@ photos_item_manager_add_item (PhotosItemManager *self, PhotosWindowMode mode, Tr
   object = photos_base_manager_get_object_by_id (item_mngr_chld, id);
   if (object != NULL)
     {
-      g_signal_emit_by_name (self, "object-added", object);
-      goto out;
-    }
+      item = PHOTOS_BASE_ITEM (object);
+      g_return_if_fail (PHOTOS_IS_BASE_ITEM (object));
+      if (!photos_base_item_is_collection (item))
+       goto out;
+
+      old_collection = g_hash_table_lookup (self->collections, id);
+      if (old_collection != NULL)
+       goto out;
+
+      g_hash_table_insert (self->collections, g_strdup (id), g_object_ref (item));
+
+out:
+       g_signal_emit_by_name (self, "object-added", object);
+       goto end;
+      }
 
   item = photos_item_manager_get_object_by_id_from_children (self, id);
   if (item != NULL)
@@ -701,7 +691,7 @@ photos_item_manager_add_item (PhotosItemManager *self, PhotosWindowMode mode, Tr
 
   photos_base_manager_add_object (item_mngr_chld, G_OBJECT (item));
 
- out:
+ end:
   g_clear_object (&item);
 }
 


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