[gnome-photos] Listen to ItemManager::active-collection-changed only when needed



commit 176c42d6f955bc7e20259f79777b9021186ddb15
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Sep 12 13:27:00 2017 +0200

    Listen to ItemManager::active-collection-changed only when needed
    
    Collections can only be listed and browsed in the COLLECTIONS and
    SEARCH modes. Therefore, there is no need to connect to
    ItemManager::active-collection-changed in any of the other modes.
    
    Secondly, listening to this signal has nothing to do with adding a
    selection button.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786936

 src/photos-main-toolbar.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index a1135db..dc1be19 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -321,12 +321,6 @@ photos_main_toolbar_add_selection_button (PhotosMainToolbar *self)
   gtk_actionable_set_action_name (GTK_ACTIONABLE (selection_button), "app.selection-mode");
   gtk_header_bar_pack_end (GTK_HEADER_BAR (self->header_bar), selection_button);
 
-  g_signal_connect_object (self->item_mngr,
-                           "active-collection-changed",
-                           G_CALLBACK (photos_main_toolbar_col_active_changed),
-                           self,
-                           G_CONNECT_SWAPPED);
-
   return selection_button;
 }
 
@@ -447,6 +441,12 @@ photos_main_toolbar_populate_for_collections (PhotosMainToolbar *self)
   photos_main_toolbar_add_selection_button (self);
   photos_main_toolbar_add_search_button (self);
 
+  g_signal_connect_object (self->item_mngr,
+                           "active-collection-changed",
+                           G_CALLBACK (photos_main_toolbar_col_active_changed),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (self->item_mngr));
   photos_main_toolbar_col_active_changed (self, collection);
 }
@@ -578,6 +578,12 @@ photos_main_toolbar_populate_for_search (PhotosMainToolbar *self)
   photos_main_toolbar_add_selection_button (self);
   photos_main_toolbar_add_search_button (self);
 
+  g_signal_connect_object (self->item_mngr,
+                           "active-collection-changed",
+                           G_CALLBACK (photos_main_toolbar_col_active_changed),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (self->item_mngr));
   photos_main_toolbar_col_active_changed (self, collection);
 }


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