[gnome-games] ui: Show a spinner notification when loading games
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Show a spinner notification when loading games
- Date: Tue, 31 Jan 2017 10:06:45 +0000 (UTC)
commit 5b964c6660d324830b4fe11b73b6420072905c79
Author: theawless <theawless gmail com>
Date: Tue Jan 31 15:14:18 2017 +0530
ui: Show a spinner notification when loading games
Add an overlayed revealable notification over collection icon view box.
https://bugzilla.gnome.org/show_bug.cgi?id=773882
data/ui/collection-box.ui | 72 ++++++++++++++++++++++++++++++++++++++-
po/POTFILES.in | 1 +
src/ui/application-window.vala | 5 +++
src/ui/application.vala | 14 ++++++++
src/ui/collection-box.vala | 11 ++++++
5 files changed, 101 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index 9cef3be..fb1e6c3 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -21,9 +21,72 @@
</packing>
</child>
<child>
- <object class="GamesCollectionIconView" id="icon_view">
+ <object class="GtkOverlay">
<property name="visible">True</property>
- <signal name="game-activated" handler="on_game_activated"/>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GamesCollectionIconView" id="icon_view">
+ <property name="visible">True</property>
+ <signal name="game-activated" handler="on_game_activated"/>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkRevealer" id="loading_notification_revealer">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">18</property>
+ <child>
+ <object class="GtkSpinner">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Loading</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</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>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <style>
+ <class name="app-notification"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">True</property>
@@ -31,4 +94,9 @@
</packing>
</child>
</template>
+ <object class="GtkImage" id="close_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-close</property>
+ </object>
</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5fa3749..94af8e3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
data/org.gnome.Games.appdata.xml.in
data/org.gnome.Games.desktop.in
[type: gettext/glade]data/gtk/menus.ui
+[type: gettext/glade]data/ui/collection-box.ui
[type: gettext/glade]data/ui/collection-header-bar.ui
[type: gettext/glade]data/ui/display-header-bar.ui
[type: gettext/glade]data/ui/dummy-display.ui
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 8f3da0a..a8d1a12 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -56,6 +56,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
get { return _search_mode; }
}
+ public bool loading_notification { set; get; }
+
[GtkChild]
private Gtk.Stack content_box;
[GtkChild]
@@ -74,6 +76,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
private Binding box_fullscreen_binding;
private Binding header_bar_search_binding;
private Binding header_bar_fullscreen_binding;
+ private Binding loading_notification_binding;
private Cancellable run_game_cancellable;
private Cancellable quit_game_cancellable;
@@ -90,6 +93,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
construct {
box_search_binding = bind_property ("search-mode", collection_box, "search-mode",
BindingFlags.BIDIRECTIONAL);
+ loading_notification_binding = bind_property ("loading-notification", collection_box,
"loading-notification",
+ BindingFlags.DEFAULT);
header_bar_search_binding = bind_property ("search-mode", collection_header_bar,
"search-mode",
BindingFlags.BIDIRECTIONAL);
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 376f2a6..4eac304 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -5,6 +5,7 @@ private extern const string VERSION;
public class Games.Application : Gtk.Application {
private ListStore collection;
private ApplicationWindow window;
+ private bool game_list_loaded;
internal Application () {
Object (application_id: "org.gnome.Games",
@@ -115,6 +116,15 @@ public class Games.Application : Gtk.Application {
quit_application ();
});
window.show ();
+
+ GLib.Timeout.add (500, show_loading_notification);
+ }
+
+ private bool show_loading_notification () {
+ if (!game_list_loaded)
+ window.loading_notification = true;
+
+ return false;
}
internal async void load_game_list () {
@@ -135,6 +145,10 @@ public class Games.Application : Gtk.Application {
foreach (var source in sources)
yield source.each_game (add_game);
+
+ game_list_loaded = true;
+ if (window != null)
+ window.loading_notification = false;
}
private void add_game (Game game) {
diff --git a/src/ui/collection-box.vala b/src/ui/collection-box.vala
index 7649fa2..f144308 100644
--- a/src/ui/collection-box.vala
+++ b/src/ui/collection-box.vala
@@ -6,14 +6,18 @@ private class Games.CollectionBox : Gtk.Box {
public ListModel collection { construct set; get; }
public bool search_mode { set; get; }
+ public bool loading_notification { set; get; }
[GtkChild]
private SearchBar search_bar;
[GtkChild]
+ private Gtk.Revealer loading_notification_revealer;
+ [GtkChild]
private CollectionIconView icon_view;
private Binding collection_binding;
private Binding search_binding;
+ private Binding loading_notification_binding;
public CollectionBox (ListStore collection) {
Object (collection: collection);
@@ -24,6 +28,13 @@ private class Games.CollectionBox : Gtk.Box {
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",
+ BindingFlags.DEFAULT);
+ }
+
+ [GtkCallback]
+ private void on_loading_notification_closed () {
+ loading_notification_revealer.set_reveal_child (false);
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]