[gnome-games/wip/exalm/views: 3/14] application-window: Use CollectionView



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

    application-window: Use CollectionView

 data/ui/application-window.ui  | 14 +-------------
 src/ui/application-window.vala | 40 +++++++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 30 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 9efae3e7..b75b4732 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">
@@ -37,15 +34,6 @@
     <child type="titlebar">
       <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 7082d393..d1aaa302 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.header_bar;
+
+                               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;
@@ -68,15 +72,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;
@@ -105,7 +107,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        private KonamiCode konami_code;
 
        public ApplicationWindow (ListModel collection) {
-               collection_box.collection = collection;
+               collection_view.window = this;
+               collection_view.collection = collection;
                collection.items_changed.connect (() => {
                        is_collection_empty = collection.get_n_items () == 0;
                });
@@ -113,6 +116,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
        }
 
        construct {
+               header_bar.add (collection_view.header_bar);
+               header_bar.visible_child = collection_view.header_bar;
+
                settings = new Settings ("org.gnome.Games");
 
                int width, height;
@@ -127,11 +133,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.collection_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.collection_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.collection_header_bar, "search-mode",
                                                           BindingFlags.BIDIRECTIONAL);
 
                box_fullscreen_binding = bind_property ("is-fullscreen", display_box, "is-fullscreen",
@@ -139,16 +145,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.collection_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.collection_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;
@@ -158,6 +162,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
 
                if (Config.PROFILE == "Devel")
                        get_style_context ().add_class ("devel");
+
+               ui_state = UiState.COLLECTION;
        }
 
        public void run_game (Game game) {
@@ -271,7 +277,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.collection_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);
@@ -305,7 +311,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.collection_box.gamepad_button_release_event 
(event);
                default:
                        return false;
                }
@@ -314,7 +320,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.collection_box.gamepad_absolute_axis_event 
(event);
                default:
                        return false;
                }
@@ -609,7 +615,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                        return true;
                }
 
-               return collection_box.search_bar_handle_event (event);
+               return collection_view.collection_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]