[gnome-games/wip/exalm/views2: 21/23] collection-header-bar: Merge into CollectionView



commit f57fc2881200e4f7b24cacd91747bc819cb200f4
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Fri Oct 5 00:22:21 2018 +0500

    collection-header-bar: Merge into CollectionView

 data/org.gnome.Games.gresource.xml |   1 -
 data/ui/collection-header-bar.ui   | 150 -------------------------------------
 data/ui/collection-view.ui         | 147 +++++++++++++++++++++++++++++++++++-
 src/meson.build                    |   1 -
 src/ui/collection-header-bar.vala  |  42 -----------
 src/ui/collection-view.vala        |  34 ++++++---
 6 files changed, 169 insertions(+), 206 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 59dc783f..7fe72629 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -13,7 +13,6 @@
     <file preprocess="xml-stripblanks">ui/application-window.ui</file>
     <file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-box.ui</file>
-    <file preprocess="xml-stripblanks">ui/collection-header-bar.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-icon-view.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-view.ui</file>
     <file preprocess="xml-stripblanks">ui/developer-list-item.ui</file>
diff --git a/data/ui/collection-view.ui b/data/ui/collection-view.ui
index 14810906..327a2e8e 100644
--- a/data/ui/collection-view.ui
+++ b/data/ui/collection-view.ui
@@ -11,8 +11,151 @@
       </object>
     </child>
   </template>
-  <object class="GamesCollectionHeaderBar" id="header_bar">
+  <object class="GtkHeaderBar" id="header_bar">
     <property name="visible">True</property>
-    <property name="show_close_button">True</property>
+    <property name="show-close-button">True</property>
+    <child>
+      <object class="GtkButton" id="add_game">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="use-underline">True</property>
+        <property name="action-name">app.add-game-files</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="a11y-back">
+            <property name="accessible-name" translatable="yes">Add game files…</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="add_game_image">
+            <property name="visible">True</property>
+            <property name="icon-name">list-add-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">start</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkMenuButton" id="menu">
+        <property name="popover">menu_popover</property>
+        <!-- Translators: tooltip for the application menu button -->
+        <property name="tooltip_text" translatable="yes">Menu</property>
+        <property name="use-underline">True</property>
+        <property name="valign">center</property>
+        <property name="visible">True</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage" id="menu_image">
+            <property name="visible">True</property>
+            <property name="icon-name">open-menu-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+    <child type="title">
+      <object class="GtkStack" id="title_stack">
+        <property name="visible">True</property>
+        <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
+        <child>
+          <object class="GtkStackSwitcher" id="view_switcher">
+            <property name="visible">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel" id="empty_title">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Games</property>
+            <style>
+              <class name="title"/>
+            </style>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkToggleButton" id="search">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="use-underline">True</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="a11y-search">
+            <property name="accessible-name" translatable="yes">Search</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="search_image">
+            <property name="visible">True</property>
+            <property name="icon-name">edit-find-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkPopover" id="menu_popover">
+    <property name="visible">False</property>
+    <child>
+      <object class="GtkBox">
+        <property name="margin">12</property>
+        <property name="orientation">vertical</property>
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkModelButton">
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Preferences</property>
+            <property name="action-name">app.preferences</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkSeparator">
+            <property name="margin-top">6</property>
+            <property name="margin-bottom">6</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Shortcuts</property>
+            <property name="action-name">app.shortcuts</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Help</property>
+            <property name="action-name">app.help</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">About</property>
+            <property name="action-name">app.about</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
+      </object>
+    </child>
   </object>
 </interface>
diff --git a/src/meson.build b/src/meson.build
index a987ef12..e79a9010 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -129,7 +129,6 @@ vala_sources = [
   'ui/checkmark-item.vala',
   'ui/collection-box.vala',
   'ui/collection-icon-view.vala',
-  'ui/collection-header-bar.vala',
   'ui/collection-view.vala',
   'ui/developer-list-item.vala',
   'ui/developers-view.vala',
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 6fd83f40..06a0f08a 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -7,7 +7,15 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
        [GtkChild]
        private CollectionBox box;
        [GtkChild]
-       private CollectionHeaderBar header_bar;
+       private Gtk.Stack title_stack;
+       [GtkChild]
+       private Gtk.Label empty_title;
+       [GtkChild]
+       private Gtk.StackSwitcher view_switcher;
+       [GtkChild]
+       private Gtk.ToggleButton search;
+       [GtkChild]
+       private Gtk.HeaderBar header_bar;
 
        public Gtk.Widget titlebar {
                get { return header_bar; }
@@ -45,16 +53,27 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
 
        public bool loading_notification { get; set; }
        public bool search_mode { get; set; }
-       public bool is_collection_empty { get; set; }
+
+       private bool _is_collection_empty;
+       public bool is_collection_empty {
+               get { return _is_collection_empty; }
+               set {
+                       _is_collection_empty = value;
+                       if (_is_collection_empty)
+                               title_stack.visible_child = empty_title;
+                       else
+                               title_stack.visible_child = view_switcher;
+                       search.sensitive = !_is_collection_empty;
+               }
+       }
 
        private Binding loading_notification_binding;
        private Binding box_search_binding;
        private Binding box_empty_collection_binding;
        private Binding header_bar_search_binding;
-       private Binding header_bar_empty_collection_binding;
 
        construct {
-               header_bar.viewstack = box.viewstack;
+               view_switcher.stack = box.viewstack;
                is_collection_empty = true;
 
                loading_notification_binding = bind_property ("loading-notification", box,
@@ -63,17 +82,12 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
 
                box_search_binding = bind_property ("search-mode", box, "search-mode",
                                                    BindingFlags.BIDIRECTIONAL);
-               header_bar_search_binding = bind_property ("search-mode", header_bar,
-                                                          "search-mode",
+               header_bar_search_binding = bind_property ("search-mode", search, "active",
                                                           BindingFlags.BIDIRECTIONAL);
 
                box_empty_collection_binding = bind_property ("is-collection-empty", box,
                                                              "is-collection-empty",
                                                              BindingFlags.BIDIRECTIONAL);
-               header_bar_empty_collection_binding = bind_property ("is-collection-empty",
-                                                                    header_bar,
-                                                                    "is-collection-empty",
-                                                                    BindingFlags.BIDIRECTIONAL);
        }
 
        public CollectionView (ListModel collection) {


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