[gnome-games/wip/exalm/spinner: 13/17] ui: Add loading state
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/spinner: 13/17] ui: Add loading state
- Date: Mon, 7 Jan 2019 17:26:46 +0000 (UTC)
commit 6fa6bfbd8a1916d6678ce26069241c6252a949a3
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Sep 5 19:36:10 2018 +0500
ui: Add loading state
Add UiState.LOADING state represented by LoadingBox and LoadingHeaderBar
widgets.
This will be used in subsequent commits to show loading collection.
data/org.gnome.Games.gresource.xml | 2 ++
data/ui/application-window.ui | 17 +++++++++++++++++
data/ui/loading-box.ui | 13 +++++++++++++
data/ui/loading-header-bar.ui | 7 +++++++
src/meson.build | 2 ++
src/ui/application-window.vala | 28 ++++++++++++++++++++--------
src/ui/loading-box.vala | 5 +++++
src/ui/loading-header-bar.vala | 5 +++++
src/ui/ui-state.vala | 1 +
9 files changed, 72 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 9cf2e1bc..0bf24453 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -29,6 +29,8 @@
<file preprocess="xml-stripblanks">ui/input-mode-switcher.ui</file>
<file preprocess="xml-stripblanks">ui/keyboard-mapper.ui</file>
<file preprocess="xml-stripblanks">ui/keyboard-tester.ui</file>
+ <file preprocess="xml-stripblanks">ui/loading-box.ui</file>
+ <file preprocess="xml-stripblanks">ui/loading-header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
<file preprocess="xml-stripblanks">ui/media-selector.ui</file>
<file preprocess="xml-stripblanks">ui/platform-list-item.ui</file>
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 443f718e..acd6e444 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -14,6 +14,14 @@
<child>
<object class="GtkStack" id="content_box">
<property name="visible">True</property>
+ <child>
+ <object class="GamesLoadingBox" id="loading_box">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">loading</property>
+ </packing>
+ </child>
<child>
<object class="GamesCollectionBox" id="collection_box">
<property name="visible">True</property>
@@ -40,6 +48,15 @@
<child>
<object class="GtkStack" id="header_bar">
<property name="visible">True</property>
+ <child>
+ <object class="GamesLoadingHeaderBar" id="loading_header_bar">
+ <property name="visible">True</property>
+ <property name="show_close_button">True</property>
+ </object>
+ <packing>
+ <property name="name">loading</property>
+ </packing>
+ </child>
<child>
<object class="GamesCollectionHeaderBar" id="collection_header_bar">
<property name="visible">True</property>
diff --git a/data/ui/loading-box.ui b/data/ui/loading-box.ui
new file mode 100644
index 00000000..ec2190f6
--- /dev/null
+++ b/data/ui/loading-box.ui
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="GamesLoadingBox" parent="GtkBin">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSpinner">
+ <property name="visible">True</property>
+ <property name="active">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/loading-header-bar.ui b/data/ui/loading-header-bar.ui
new file mode 100644
index 00000000..c489c09a
--- /dev/null
+++ b/data/ui/loading-header-bar.ui
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="GamesLoadingHeaderBar" parent="GtkHeaderBar">
+ <property name="visible">True</property>
+ </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index 0bfe554f..4020f58d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -150,6 +150,8 @@ vala_sources = [
'ui/input-mode-switcher.vala',
'ui/keyboard-mapper.vala',
'ui/keyboard-tester.vala',
+ 'ui/loading-box.vala',
+ 'ui/loading-header-bar.vala',
'ui/konami-code.vala',
'ui/media-selector.vala',
'ui/media-menu-button.vala',
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 443036a7..005cd093 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -17,25 +17,33 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
_ui_state = value;
switch (ui_state) {
+ case UiState.LOADING:
+ content_box.visible_child = loading_box;
+ header_bar.visible_child = loading_header_bar;
+
+ break;
case UiState.COLLECTION:
content_box.visible_child = collection_box;
header_bar.visible_child = collection_header_bar;
- is_fullscreen = false;
-
- if (display_box.runner != null) {
- display_box.runner.stop ();
- display_box.runner = null;
- }
-
break;
case UiState.DISPLAY:
content_box.visible_child = display_box;
header_bar.visible_child = display_header_bar;
+ break;
+ }
+
+ if (ui_state != UiState.COLLECTION)
search_mode = false;
- break;
+ if (ui_state != UiState.DISPLAY) {
+ is_fullscreen = false;
+
+ if (display_box.runner != null) {
+ display_box.runner.stop ();
+ display_box.runner = null;
+ }
}
konami_code.reset ();
@@ -68,6 +76,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
[GtkChild]
private Gtk.Stack content_box;
[GtkChild]
+ private LoadingBox loading_box;
+ [GtkChild]
private CollectionBox collection_box;
[GtkChild]
private DisplayBox display_box;
@@ -75,6 +85,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
[GtkChild]
private Gtk.Stack header_bar;
[GtkChild]
+ private LoadingHeaderBar loading_header_bar;
+ [GtkChild]
private CollectionHeaderBar collection_header_bar;
[GtkChild]
private DisplayHeaderBar display_header_bar;
diff --git a/src/ui/loading-box.vala b/src/ui/loading-box.vala
new file mode 100644
index 00000000..d74a4301
--- /dev/null
+++ b/src/ui/loading-box.vala
@@ -0,0 +1,5 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/loading-box.ui")]
+private class Games.LoadingBox : Gtk.Bin {
+}
diff --git a/src/ui/loading-header-bar.vala b/src/ui/loading-header-bar.vala
new file mode 100644
index 00000000..aecc72e8
--- /dev/null
+++ b/src/ui/loading-header-bar.vala
@@ -0,0 +1,5 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/loading-header-bar.ui")]
+private class Games.LoadingHeaderBar : Gtk.HeaderBar {
+}
diff --git a/src/ui/ui-state.vala b/src/ui/ui-state.vala
index 68324f60..e504b6fd 100644
--- a/src/ui/ui-state.vala
+++ b/src/ui/ui-state.vala
@@ -1,6 +1,7 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private enum Games.UiState {
+ LOADING,
COLLECTION,
DISPLAY,
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]