[gnome-games/wip/exalm/views2: 22/23] collection-box: Merge into CollectionView
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views2: 22/23] collection-box: Merge into CollectionView
- Date: Sat, 6 Oct 2018 21:47:44 +0000 (UTC)
commit 0b0e689eb3284fd5d1e74060124fe46cf51f77d2
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Fri Oct 5 00:33:58 2018 +0500
collection-box: Merge into CollectionView
data/org.gnome.Games.gresource.xml | 1 -
data/ui/collection-box.ui | 112 ------------------------
data/ui/collection-view.ui | 105 +++++++++++++++++++++-
src/meson.build | 1 -
src/ui/collection-box.vala | 172 -------------------------------------
src/ui/collection-view.vala | 143 ++++++++++++++++++++++++++----
6 files changed, 227 insertions(+), 307 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 7fe72629..74eb5322 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -12,7 +12,6 @@
<file preprocess="xml-stripblanks">gesture/stick-symbolic.svg</file>
<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-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 327a2e8e..b4732212 100644
--- a/data/ui/collection-view.ui
+++ b/data/ui/collection-view.ui
@@ -2,15 +2,114 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.16"/>
- <template class="GamesCollectionView" parent="GtkBin">
+ <template class="GamesCollectionView" parent="GtkBox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<child>
- <object class="GamesCollectionBox" id="box">
+ <object class="GamesSearchBar" id="search_bar">
<property name="visible">True</property>
- <signal name="game-activated" handler="on_game_activated"/>
+ <signal name="notify::text" handler="on_search_text_notify"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkOverlay">
+ <property name="visible">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkStack" id="viewstack">
+ <property name="visible">True</property>
+ <property name="visible-child">collection_view</property>
+ <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
+ <signal name="notify::visible-child" handler="on_visible_child_changed"/>
+ <child>
+ <object class="GamesEmptyCollection" id="empty_collection">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">empty</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GamesCollectionIconView" id="collection_view">
+ <property name="visible">True</property>
+ <signal name="game-activated" handler="on_game_activated"/>
+ </object>
+ <packing>
+ <property name="name">games</property>
+ <property name="title" translatable="yes">Games</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GamesDevelopersView" id="developer_view">
+ <property name="visible">True</property>
+ <signal name="game-activated" handler="on_game_activated"/>
+ </object>
+ <packing>
+ <property name="name">developer</property>
+ <property name="title" translatable="yes">Developers</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GamesPlatformsView" id="platform_view">
+ <property name="visible">True</property>
+ <signal name="game-activated" handler="on_game_activated"/>
+ </object>
+ <packing>
+ <property name="name">platform</property>
+ <property name="title" translatable="yes">Platforms</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkRevealer" id="loading_notification_revealer">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkSpinner">
+ <property name="visible">True</property>
+ <property name="active">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Loading</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="image">close_icon</property>
+ <property name="always_show_image">True</property>
+ <signal name="clicked" handler="on_loading_notification_closed"/>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
+ <style>
+ <class name="app-notification"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
+ <object class="GtkImage" id="close_icon">
+ <property name="visible">True</property>
+ <property name="icon_name">window-close-symbolic</property>
+ </object>
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="show-close-button">True</property>
diff --git a/src/meson.build b/src/meson.build
index e79a9010..baaf3cb8 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -127,7 +127,6 @@ vala_sources = [
'ui/application-view.vala',
'ui/application-window.vala',
'ui/checkmark-item.vala',
- 'ui/collection-box.vala',
'ui/collection-icon-view.vala',
'ui/collection-view.vala',
'ui/developer-list-item.vala',
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
index 06a0f08a..f6e93a14 100644
--- a/src/ui/collection-view.vala
+++ b/src/ui/collection-view.vala
@@ -1,11 +1,23 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/collection-view.ui")]
-private class Games.CollectionView: Gtk.Bin, ApplicationView {
+private class Games.CollectionView: Gtk.Box, ApplicationView {
public signal void game_activated (Game game);
[GtkChild]
- private CollectionBox box;
+ private SearchBar search_bar;
+ [GtkChild]
+ private Gtk.Revealer loading_notification_revealer;
+ [GtkChild]
+ private EmptyCollection empty_collection;
+ [GtkChild]
+ private CollectionIconView collection_view;
+ [GtkChild]
+ private DevelopersView developer_view;
+ [GtkChild]
+ private PlatformsView platform_view;
+ [GtkChild]
+ private Gtk.Stack viewstack;
[GtkChild]
private Gtk.Stack title_stack;
[GtkChild]
@@ -42,7 +54,6 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
get { return _collection; }
construct set {
_collection = value;
- box.collection = _collection;
collection.items_changed.connect (() => {
is_collection_empty = collection.get_n_items () == 0;
@@ -59,39 +70,51 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
get { return _is_collection_empty; }
set {
_is_collection_empty = value;
- if (_is_collection_empty)
+ if (_is_collection_empty) {
+ viewstack.visible_child = empty_collection;
title_stack.visible_child = empty_title;
- else
+ }
+ else {
+ viewstack.visible_child = collection_view;
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 collection_binding;
+ private Binding developer_collection_binding;
+ private Binding platform_collection_binding;
+
construct {
- view_switcher.stack = box.viewstack;
+ view_switcher.stack = viewstack;
is_collection_empty = true;
- loading_notification_binding = bind_property ("loading-notification", box,
- "loading-notification",
+ loading_notification_binding = bind_property ("loading-notification",
+ loading_notification_revealer,
+ "reveal-child",
BindingFlags.DEFAULT);
- box_search_binding = bind_property ("search-mode", box, "search-mode",
+ box_search_binding = bind_property ("search-mode", search_bar,
+ "search-mode-enabled",
BindingFlags.BIDIRECTIONAL);
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);
+ collection_binding = bind_property ("collection", collection_view, "model",
+ BindingFlags.BIDIRECTIONAL);
+ developer_collection_binding = bind_property ("collection", developer_view,
+ "model", BindingFlags.BIDIRECTIONAL);
+ platform_collection_binding = bind_property ("collection", platform_view,
+ "model", BindingFlags.BIDIRECTIONAL);
}
public CollectionView (ListModel collection) {
- box.collection = collection;
+ this.collection = collection;
}
public bool on_button_pressed (Gdk.EventButton event) {
@@ -109,19 +132,103 @@ private class Games.CollectionView: Gtk.Bin, ApplicationView {
return true;
}
- return box.search_bar_handle_event (event);
+ return search_bar.handle_event (event);
}
public bool gamepad_button_press_event (Manette.Event event) {
- return window.is_active && box.gamepad_button_press_event (event);
+ if (!window.is_active || !get_mapped ())
+ return false;
+
+ uint16 button;
+ if (!event.get_button (out button))
+ return false;
+
+ if (is_collection_empty)
+ return false;
+
+ switch (button) {
+ case EventCode.BTN_TL:
+ var views = viewstack.get_children ();
+ unowned List<Gtk.Widget> current_view = views.find (viewstack.visible_child);
+
+ assert (current_view != null);
+
+ if (current_view.prev != null && current_view.prev.data != empty_collection)
+ viewstack.visible_child = current_view.prev.data;
+
+ return true;
+ case EventCode.BTN_TR:
+ var views = viewstack.get_children ();
+ unowned List<Gtk.Widget> current_view = views.find (viewstack.visible_child);
+
+ assert (current_view != null);
+
+ if (current_view.next != null && current_view.next.data != empty_collection)
+ viewstack.visible_child = current_view.next.data;
+
+ return true;
+ default:
+ if (viewstack.visible_child == platform_view)
+ return platform_view.gamepad_button_press_event (event);
+ else if (viewstack.visible_child == developer_view)
+ return developer_view.gamepad_button_press_event (event);
+ else
+ return collection_view.gamepad_button_press_event (event);
+ }
}
public bool gamepad_button_release_event (Manette.Event event) {
- return window.is_active && box.gamepad_button_release_event (event);
+ if (!window.is_active || !get_mapped ())
+ return false;
+
+ if (viewstack.visible_child == platform_view)
+ return platform_view.gamepad_button_release_event (event);
+ else if (viewstack.visible_child == developer_view)
+ return developer_view.gamepad_button_release_event (event);
+ else
+ return collection_view.gamepad_button_release_event (event);
}
public bool gamepad_absolute_axis_event (Manette.Event event) {
- return window.is_active && box.gamepad_absolute_axis_event (event);
+ if (!window.is_active || !get_mapped ())
+ return false;
+
+ if (viewstack.visible_child == platform_view)
+ return platform_view.gamepad_absolute_axis_event (event);
+ else if (viewstack.visible_child == developer_view)
+ return developer_view.gamepad_absolute_axis_event (event);
+ else
+ return collection_view.gamepad_absolute_axis_event (event);
+ }
+
+ [GtkCallback]
+ private void on_loading_notification_closed () {
+ loading_notification_revealer.set_reveal_child (false);
+ }
+
+ [GtkCallback]
+ private void on_visible_child_changed () {
+ if (viewstack.visible_child == platform_view) {
+ platform_view.select_default_row ();
+ }
+ else if (viewstack.visible_child == developer_view) {
+ developer_view.select_default_row ();
+ }
+ else {
+ collection_view.reset_scroll_position ();
+ }
+ }
+
+ [GtkCallback]
+ private void on_search_text_notify () {
+ if (viewstack.visible_child == platform_view) {
+ platform_view.filtering_text = search_bar.text;
+ }
+ else if (viewstack.visible_child == developer_view) {
+ developer_view.filtering_text = search_bar.text;
+ }
+ else
+ collection_view.filtering_text = search_bar.text;
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]