[gnome-games/wip/exalm/spinner-performance: 11/19] ui: Separate SidebarView and CollectionIconView
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/spinner-performance: 11/19] ui: Separate SidebarView and CollectionIconView
- Date: Sun, 23 Sep 2018 10:47:34 +0000 (UTC)
commit 5eee5951a47c40dc33a19655fc292a8dd3c539e2
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Fri Sep 21 18:15:27 2018 +0500
ui: Separate SidebarView and CollectionIconView
data/ui/collection-box.ui | 63 +++++++++++++++++++++++++++-------------------
data/ui/sidebar-view.ui | 9 +------
src/ui/collection-box.vala | 24 ++++++++----------
src/ui/sidebar-view.vala | 31 ++++++++++++-----------
4 files changed, 65 insertions(+), 62 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index fd620dda..64f7fb64 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -19,7 +19,7 @@
<child>
<object class="GtkStack" id="empty_stack">
<property name="visible">True</property>
- <property name="visible-child">viewstack</property>
+ <property name="visible-child">sidebar_box</property>
<property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
<child>
<object class="GamesEmptyCollection" id="empty_collection">
@@ -30,40 +30,51 @@
</packing>
</child>
<child>
- <object class="GtkStack" id="viewstack">
+ <object class="GtkBox" id="sidebar_box">
<property name="visible">True</property>
- <property name="visible-child">games_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="GamesGamesView" id="games_view">
+ <object class="GtkStack" id="viewstack">
<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"/>
+ <property name="visible-child">games_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="GamesGamesView" id="games_view">
+ <property name="visible">True</property>
+ </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>
+ <property name="collection-view">collection_view</property>
+ </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>
+ <property name="collection-view">collection_view</property>
+ </object>
+ <packing>
+ <property name="name">platform</property>
+ <property name="title" translatable="yes">Platforms</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="name">developer</property>
- <property name="title" translatable="yes">Developers</property>
- </packing>
</child>
<child>
- <object class="GamesPlatformsView" id="platform_view">
+ <object class="GamesCollectionIconView" id="collection_view">
<property name="visible">True</property>
+ <property name="expand">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>
diff --git a/data/ui/sidebar-view.ui b/data/ui/sidebar-view.ui
index 8b8f8d27..50d84178 100644
--- a/data/ui/sidebar-view.ui
+++ b/data/ui/sidebar-view.ui
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
- <template class="GamesSidebarView" parent="GtkBox">
+ <template class="GamesSidebarView" parent="GtkBin">
<property name="visible">True</property>
- <property name="expand">True</property>
<signal name="map" after="yes" handler="on_map"/>
<signal name="unmap" after="no" handler="on_unmap"/>
<child>
@@ -23,12 +22,6 @@
</child>
</object>
</child>
- <child>
- <object class="GamesCollectionIconView" id="collection_view">
- <property name="visible">True</property>
- <property name="expand">True</property>
- </object>
- </child>
</template>
<object class="GamesGamepadBrowse" id="gamepad_browse">
<signal name="browse" handler="on_gamepad_browse"/>
diff --git a/src/ui/collection-box.vala b/src/ui/collection-box.vala
index 01bab091..b792d1f6 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -13,8 +13,12 @@ private class Games.CollectionBox : Gtk.Box {
[GtkChild]
private Gtk.Revealer loading_notification_revealer;
[GtkChild]
+ private Gtk.Box sidebar_box;
+ [GtkChild]
private EmptyCollection empty_collection;
[GtkChild]
+ private CollectionIconView collection_view;
+ [GtkChild]
private GamesView games_view;
[GtkChild]
private DevelopersView developer_view;
@@ -36,13 +40,11 @@ private class Games.CollectionBox : Gtk.Box {
if (_is_collection_empty)
empty_stack.visible_child = empty_collection;
else
- empty_stack.visible_child = viewstack;
+ empty_stack.visible_child = sidebar_box;
}
}
private Binding collection_binding;
- private Binding developer_collection_binding;
- private Binding platform_collection_binding;
private Binding search_binding;
private Binding loading_notification_binding;
@@ -51,15 +53,8 @@ private class Games.CollectionBox : Gtk.Box {
}
construct {
- collection_binding = bind_property ("collection", games_view, "model",
+ 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);
-
search_binding = bind_property ("search-mode", search_bar, "search-mode-enabled",
BindingFlags.BIDIRECTIONAL);
loading_notification_binding = bind_property ("loading-notification",
loading_notification_revealer, "reveal-child",
@@ -135,6 +130,9 @@ private class Games.CollectionBox : Gtk.Box {
[GtkCallback]
private void on_visible_child_changed () {
+ collection_view.filtering_developer = null;
+ collection_view.filtering_platform = null;
+
var view = viewstack.visible_child as SidebarView;
view.select_default_row ();
@@ -142,9 +140,7 @@ private class Games.CollectionBox : Gtk.Box {
[GtkCallback]
private void on_search_text_notify () {
- var view = viewstack.visible_child as SidebarView;
-
- view.filtering_text = search_bar.text;
+ collection_view.filtering_text = search_bar.text;
}
public bool search_bar_handle_event (Gdk.Event event) {
diff --git a/src/ui/sidebar-view.vala b/src/ui/sidebar-view.vala
index f3f5996e..4cec2e0f 100644
--- a/src/ui/sidebar-view.vala
+++ b/src/ui/sidebar-view.vala
@@ -1,14 +1,25 @@
// This file is part of GNOME Games. License: GPL-3.0+.
[GtkTemplate (ui = "/org/gnome/Games/ui/sidebar-view.ui")]
-private abstract class Games.SidebarView : Gtk.Box {
- public signal void game_activated (Game game);
+private abstract class Games.SidebarView : Gtk.Bin {
+ private ulong model_items_changed_id;
- public string filtering_text {
- set { collection_view.filtering_text = value; }
- }
+ private Binding model_binding;
- private ulong model_items_changed_id;
+ private CollectionIconView _collection_view;
+ public CollectionIconView collection_view {
+ get { return _collection_view; }
+ set {
+ if (_collection_view != null)
+ model_binding.unbind ();
+
+ _collection_view = value;
+
+ if (_collection_view != null)
+ model_binding = bind_property ("model", collection_view, "model",
+ BindingFlags.BIDIRECTIONAL);
+ }
+ }
private ListModel _model;
public ListModel model {
@@ -20,7 +31,6 @@ private abstract class Games.SidebarView : Gtk.Box {
}
_model = value;
- collection_view.model = _model;
if (model != null)
model_items_changed_id = model.items_changed.connect (on_model_changed);
@@ -44,9 +54,6 @@ private abstract class Games.SidebarView : Gtk.Box {
}
}
- [GtkChild]
- protected CollectionIconView collection_view;
-
[GtkChild]
protected Gtk.ListBox list_box;
@@ -55,10 +62,6 @@ private abstract class Games.SidebarView : Gtk.Box {
construct {
list_box.set_sort_func (sort_rows);
-
- collection_view.game_activated.connect ((game) => {
- game_activated (game);
- });
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]