[gnome-games/wip/exalm/tnum: 11/24] collections-page: Replace get_current_collection() with a prop




commit ca97444c0f5646f30bcf979254e53ae384579443
Author: Neville <nevilleantony98 gmail com>
Date:   Fri Aug 7 17:52:08 2020 +0530

    collections-page: Replace get_current_collection() with a prop

 src/ui/collection-view.vala  |  2 +-
 src/ui/collections-page.vala | 24 +++++++++++++++---------
 2 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 1ce4ea927..7ba53239e 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -385,7 +385,7 @@ private class Games.CollectionView : Gtk.Box, UiView {
                else {
                        collection_manager.toggle_favorite (collections_page.get_selected_games ());
 
-                       var current_collection = collections_page.get_current_collection ();
+                       var current_collection = collections_page.current_collection;
                        if (current_collection != null && current_collection.get_id () == "Favorites") {
                                collections_page.update_is_collection_empty ();
                                select_none ();
diff --git a/src/ui/collections-page.vala b/src/ui/collections-page.vala
index 1f5274c83..d2a80e4d5 100644
--- a/src/ui/collections-page.vala
+++ b/src/ui/collections-page.vala
@@ -16,7 +16,6 @@ private class Games.CollectionsPage : Gtk.Bin {
        [GtkChild]
        private CollectionEmpty collection_empty_subpage;
 
-       private Collection current_collection;
        private CollectionManager collection_manager;
 
        private bool _is_collection_empty;
@@ -39,9 +38,22 @@ private class Games.CollectionsPage : Gtk.Bin {
                }
        }
 
+       private Collection? _current_collection;
+       public Collection? current_collection {
+               get { return _current_collection; }
+               set {
+                       _current_collection = value;
+
+                       if (current_collection != null)
+                               is_showing_user_collection = current_collection.get_collection_type () ==
+                                                            Collection.CollectionType.USER;
+               }
+       }
+
        public bool is_search_mode { get; set; }
        public bool is_subpage_open { get; set; }
        public bool is_selection_mode { get; set; }
+       public bool is_showing_user_collection { get; set; }
        public bool can_swipe_back { get; set; }
        public string collection_title { get; set; }
 
@@ -110,13 +122,6 @@ private class Games.CollectionsPage : Gtk.Bin {
                return on_subpage_back_clicked ();
        }
 
-       public Collection? get_current_collection () {
-               if (!is_subpage_open)
-                       return null;
-
-               return current_collection;
-       }
-
        public void invalidate_filter () {
                collections_main_page.invalidate_filter ();
        }
@@ -128,13 +133,14 @@ private class Games.CollectionsPage : Gtk.Bin {
 
                is_search_mode = false;
                collections_deck.visible_child = collections_main_page;
+               current_collection = null;
                return true;
        }
 
        [GtkCallback]
        private void on_collection_activated (Collection collection) {
                if (collection.get_collection_type () ==
-                   Collection.CollectionType.NEW_COLLECTION_PLACEHOLDER) {
+                   Collection.CollectionType.PLACEHOLDER) {
                                var dialog = new CollectionActionWindow ();
                                dialog.transient_for = get_toplevel () as ApplicationWindow;
                                dialog.modal = true;


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