[gnome-games/wip/exalm/views: 96/109] application-window: Use CollectionView



commit 647c5dc0e346899c9bb7897364a9a052fb46a48f
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Oct 4 17:50:06 2018 +0500

    application-window: Use CollectionView
    
    Use a CollectionView object instead of adding CollectionBox and
    CollectionHeaderBar separately.

 data/ui/application-window.ui  | 14 +-------------
 src/ui/application-window.vala | 41 ++++++++++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 30 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 443f718e..2a713d45 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -15,13 +15,10 @@
       <object class="GtkStack" id="content_box">
         <property name="visible">True</property>
         <child>
-          <object class="GamesCollectionBox" id="collection_box">
+          <object class="GamesCollectionView" id="collection_view">
             <property name="visible">True</property>
             <signal name="game-activated" handler="on_game_activated"/>
           </object>
-          <packing>
-            <property name="name">collection</property>
-          </packing>
         </child>
         <child>
           <object class="GamesDisplayBox" id="display_box">
@@ -40,15 +37,6 @@
         <child>
           <object class="GtkStack" id="header_bar">
             <property name="visible">True</property>
-            <child>
-              <object class="GamesCollectionHeaderBar" id="collection_header_bar">
-                <property name="visible">True</property>
-                <property name="show-close-button">True</property>
-              </object>
-              <packing>
-                <property name="name">collection</property>
-              </packing>
-            </child>
             <child>
               <object class="GamesDisplayHeaderBar" id="display_header_bar">
                 <property name="visible">True</property>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 14a566a8..c00c545a 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -18,8 +18,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                        switch (ui_state) {
                        case UiState.COLLECTION:
-                               content_box.visible_child = collection_box;
-                               header_bar.visible_child = collection_header_bar;
+                               content_box.visible_child = collection_view;
+                               header_bar.visible_child = collection_view.titlebar;
+
+                               collection_view.is_view_active = true;
 
                                is_fullscreen = false;
 
@@ -33,6 +35,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                                content_box.visible_child = display_box;
                                header_bar.visible_child = display_header_bar;
 
+                               collection_view.is_view_active = false;
+
                                search_mode = false;
 
                                break;
@@ -71,15 +75,13 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        [GtkChild]
        private Gtk.Stack content_box;
        [GtkChild]
-       private CollectionBox collection_box;
+       private CollectionView collection_view;
        [GtkChild]
        private DisplayBox display_box;
 
        [GtkChild]
        private Gtk.Stack header_bar;
        [GtkChild]
-       private CollectionHeaderBar collection_header_bar;
-       [GtkChild]
        private DisplayHeaderBar display_header_bar;
 
        private Settings settings;
@@ -110,7 +112,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        public ApplicationWindow (Application application, ListModel collection) {
                Object(application: application);
 
-               collection_box.collection = collection;
+               collection_view.collection = collection;
                collection.items_changed.connect (() => {
                        is_collection_empty = collection.get_n_items () == 0;
                });
@@ -118,6 +120,13 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        construct {
+               header_bar.add (collection_view.titlebar);
+               header_bar.visible_child = collection_view.titlebar;
+
+               collection_view.window = this;
+
+               ui_state = UiState.COLLECTION;
+
                settings = new Settings ("org.gnome.Games");
 
                int width, height;
@@ -132,11 +141,11 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                if (settings.get_boolean ("window-maximized"))
                        maximize ();
 
-               box_search_binding = bind_property ("search-mode", collection_box, "search-mode",
+               box_search_binding = bind_property ("search-mode", collection_view.box, "search-mode",
                                                    BindingFlags.BIDIRECTIONAL);
-               loading_notification_binding = bind_property ("loading-notification", collection_box, 
"loading-notification",
+               loading_notification_binding = bind_property ("loading-notification", collection_view.box, 
"loading-notification",
                                                              BindingFlags.DEFAULT);
-               header_bar_search_binding = bind_property ("search-mode", collection_header_bar, 
"search-mode",
+               header_bar_search_binding = bind_property ("search-mode", collection_view.header_bar, 
"search-mode",
                                                           BindingFlags.BIDIRECTIONAL);
 
                box_fullscreen_binding = bind_property ("is-fullscreen", display_box, "is-fullscreen",
@@ -144,16 +153,14 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                header_bar_fullscreen_binding = bind_property ("is-fullscreen", display_header_bar, 
"is-fullscreen",
                                                               BindingFlags.BIDIRECTIONAL);
 
-               box_empty_collection_binding = bind_property ("is-collection-empty", collection_box, 
"is-collection-empty",
+               box_empty_collection_binding = bind_property ("is-collection-empty", collection_view.box, 
"is-collection-empty",
                                                              BindingFlags.BIDIRECTIONAL);
-               header_bar_empty_collection_binding = bind_property ("is-collection-empty", 
collection_header_bar, "is-collection-empty",
+               header_bar_empty_collection_binding = bind_property ("is-collection-empty", 
collection_view.header_bar, "is-collection-empty",
                                                                     BindingFlags.BIDIRECTIONAL);
 
                konami_code = new KonamiCode (this);
                konami_code.code_performed.connect (on_konami_code_performed);
 
-               collection_header_bar.viewstack = collection_box.viewstack;
-
                window_size_update_timeout = -1;
                focus_out_timeout_id = -1;
                inhibit_cookie = 0;
@@ -280,7 +287,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        public bool gamepad_button_press_event (Manette.Event event) {
                switch (ui_state) {
                case UiState.COLLECTION:
-                       return is_active && collection_box.gamepad_button_press_event (event);
+                       return is_active && collection_view.box.gamepad_button_press_event (event);
                case UiState.DISPLAY:
                        if (resume_dialog != null)
                                return resume_dialog.is_active && resume_dialog.gamepad_button_press_event 
(event);
@@ -314,7 +321,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        public bool gamepad_button_release_event (Manette.Event event) {
                switch (ui_state) {
                case UiState.COLLECTION:
-                       return is_active && collection_box.gamepad_button_release_event (event);
+                       return is_active && collection_view.box.gamepad_button_release_event (event);
                default:
                        return false;
                }
@@ -323,7 +330,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        public bool gamepad_absolute_axis_event (Manette.Event event) {
                switch (ui_state) {
                case UiState.COLLECTION:
-                       return is_active && collection_box.gamepad_absolute_axis_event (event);
+                       return is_active && collection_view.box.gamepad_absolute_axis_event (event);
                default:
                        return false;
                }
@@ -635,7 +642,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return true;
                }
 
-               return collection_box.search_bar_handle_event (event);
+               return collection_view.box.search_bar_handle_event (event);
        }
 
        private bool handle_display_key_event (Gdk.EventKey event) {


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