[gnome-games/wip/exalm/views: 17/30] application-window: Use CollectionView
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 17/30] application-window: Use CollectionView
- Date: Wed, 21 Nov 2018 15:28:50 +0000 (UTC)
commit 201c5483e36de993bfa87decc1fe91b3f38fe120
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 | 39 ++++++++++++++++++++++-----------------
2 files changed, 23 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 443036a7..f15d29ae 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;
@@ -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,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
construct {
+ header_bar.add (collection_view.titlebar);
+ header_bar.visible_child = collection_view.titlebar;
+ ui_state = UiState.COLLECTION;
+
settings = new Settings ("org.gnome.Games");
int width, height;
@@ -127,11 +134,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",
@@ -139,16 +146,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;
@@ -273,7 +278,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);
@@ -307,7 +312,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;
}
@@ -316,7 +321,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;
}
@@ -612,7 +617,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]