[gnome-photos/wip/rishi/collection: 2/6] item-manager: collection_list



commit 94b4ba77ad3915bae367f712162e229fc094c0c0
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jul 27 15:11:41 2017 +0200

    item-manager: collection_list

 src/photos-item-manager.c |   23 ++++++++++++++---------
 src/photos-item-manager.h |    1 +
 2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 16b0108..bae11d8 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -245,8 +245,7 @@ photos_item_manager_info_updated (PhotosBaseItem *item, gpointer user_data)
 
   if (is_collection)
     {
-      if (self->active_collection == NULL)
-        photos_item_manager_try_to_add_item_for_mode (self, item, PHOTOS_WINDOW_MODE_COLLECTIONS);
+      photos_item_manager_try_to_add_item_for_mode (self, item, PHOTOS_WINDOW_MODE_COLLECTIONS);
     }
   else
     {
@@ -258,13 +257,14 @@ photos_item_manager_info_updated (PhotosBaseItem *item, gpointer user_data)
 
   if (is_collection)
     {
+      photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_COLLECTION_VIEW],
+                                         G_OBJECT (item));
       photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_FAVORITES], G_OBJECT 
(item));
       photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_OVERVIEW], G_OBJECT 
(item));
     }
   else
     {
-      if (self->active_collection == NULL)
-        photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_COLLECTIONS], G_OBJECT 
(item));
+      photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_COLLECTIONS], G_OBJECT 
(item));
 
       if (!is_favorite)
         photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_FAVORITES], G_OBJECT 
(item));
@@ -292,8 +292,7 @@ photos_item_manager_add_cursor_for_mode (PhotosItemManager *self,
   is_collection = photos_item_manager_cursor_is_collection (cursor);
   g_return_if_fail ((is_collection
                      && (mode == PHOTOS_WINDOW_MODE_COLLECTIONS || mode == PHOTOS_WINDOW_MODE_SEARCH))
-                    || (!is_collection
-                        && (mode != PHOTOS_WINDOW_MODE_COLLECTIONS || self->active_collection != NULL)));
+                    || (!is_collection && mode != PHOTOS_WINDOW_MODE_COLLECTIONS));
 
   if (!force && !photos_item_manager_can_add_cursor_for_mode (self, cursor, mode))
     goto out;
@@ -686,6 +685,11 @@ photos_item_manager_set_active_object (PhotosBaseManager *manager, GObject *obje
 
   if (is_collection)
     {
+      window_mode_changed = photos_item_manager_set_window_mode_internal (self,
+                                                                          PHOTOS_WINDOW_MODE_COLLECTION_VIEW,
+                                                                          &old_mode);
+      g_assert_true (window_mode_changed);
+
       g_assert_null (self->active_collection);
       self->active_collection = g_object_ref (PHOTOS_BASE_ITEM (object));
       self->load_state = PHOTOS_LOAD_STATE_NONE;
@@ -729,12 +733,12 @@ photos_item_manager_set_active_object (PhotosBaseManager *manager, GObject *obje
 
       g_signal_emit (self, signals[LOAD_STARTED], 0, PHOTOS_BASE_ITEM (object));
 
-      if (window_mode_changed)
-        g_signal_emit (self, signals[WINDOW_MODE_CHANGED], 0, PHOTOS_WINDOW_MODE_PREVIEW, old_mode);
-
       g_assert (self->active_object != (GObject *) self->active_collection);
     }
 
+  if (window_mode_changed)
+    g_signal_emit (self, signals[WINDOW_MODE_CHANGED], 0, PHOTOS_WINDOW_MODE_PREVIEW, old_mode);
+
  out:
   return ret_val;
 }
@@ -1388,6 +1392,7 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
 
   g_return_if_fail (PHOTOS_IS_MODE_CONTROLLER (self));
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
+  g_return_if_fail (mode != PHOTOS_WINDOW_MODE_COLLECTION_VIEW);
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_PREVIEW);
 
   if (mode == PHOTOS_WINDOW_MODE_EDIT)
diff --git a/src/photos-item-manager.h b/src/photos-item-manager.h
index e95314e..f418928 100644
--- a/src/photos-item-manager.h
+++ b/src/photos-item-manager.h
@@ -58,6 +58,7 @@ typedef enum
 typedef enum
 {
   PHOTOS_WINDOW_MODE_NONE,
+  PHOTOS_WINDOW_MODE_COLLECTION_VIEW,
   PHOTOS_WINDOW_MODE_COLLECTIONS,
   PHOTOS_WINDOW_MODE_EDIT,
   PHOTOS_WINDOW_MODE_FAVORITES,


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