[gnome-photos] application: Don't miss changes to the current child BaseManager



commit d5d28be0e85adaa521c11a0c05ee317c8a3a2a54
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 16 19:24:52 2018 +0100

    application: Don't miss changes to the current child BaseManager
    
    ItemManager::items-changed is only emitted if a BaseItem was added or
    removed from the union of all the child BaseManagers (ie. the 0th
    child). Therefore, due to a mode change, if the current child is
    cleared and populated with new items, the addition of new items won't
    lead to ItemManager::items-changed if they were already present in one
    of the other children. In that case, various GSimpleActions that were
    disabled by the clearing of the child BaseManager won't be re-enabled
    after the addition of new items.
    
    This is easily observed while searching because entering SEARCH clears
    the corresponding BaseManager. eg., if the first 50 items in OVERVIEW
    are all LocalItems, and searching for local content would lead to the
    same 50 LocalItems to be shown in SEARCH.

 src/photos-application.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index b22e8d5c..4f8de9f4 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1623,9 +1623,25 @@ photos_application_theme_changed (GtkSettings *settings)
 
 
 static void
-photos_application_window_mode_changed (PhotosApplication *self)
+photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMode mode, PhotosWindowMode 
old_mode)
 {
+  PhotosBaseManager *item_mngr_chld;
+
+  g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
+
+  if (old_mode != PHOTOS_WINDOW_MODE_NONE)
+    {
+      item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), 
old_mode);
+      g_signal_handlers_disconnect_by_func (item_mngr_chld, photos_application_items_changed, self);
+    }
+
   photos_application_actions_update (self);
+
+  item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
+  g_signal_connect_swapped (item_mngr_chld,
+                            "items-changed",
+                            G_CALLBACK (photos_application_items_changed),
+                            self);
 }
 
 
@@ -2103,10 +2119,6 @@ photos_application_startup (GApplication *application)
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), detailed_action_name, zoom_out_accels);
   g_free (detailed_action_name);
 
-  g_signal_connect_swapped (self->state->item_mngr,
-                            "items-changed",
-                            G_CALLBACK (photos_application_items_changed),
-                            self);
   g_signal_connect_swapped (self->state->item_mngr,
                             "load-finished",
                             G_CALLBACK (photos_application_load_changed),


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