[gnome-games] ui: Display runner errors with an ErrorDisplay
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Display runner errors with an ErrorDisplay
- Date: Wed, 17 Aug 2016 06:27:56 +0000 (UTC)
commit 97113a64f960ab2a2ada951daf5ef7fcd100dbf0
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Aug 15 08:30:25 2016 +0200
ui: Display runner errors with an ErrorDisplay
When an error occurs when running a game, displays the error in a
RunError widget rather than an info box.
This displays errors in a much nicer way.
https://bugzilla.gnome.org/show_bug.cgi?id=769801
data/ui/display-box.ui | 24 ++++++++++++++++++++++++
src/ui/application-window.vala | 32 +++++++++++++++++---------------
src/ui/display-box.vala | 19 ++++++++++++++++---
3 files changed, 57 insertions(+), 18 deletions(-)
---
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index c056305..04161bf 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -32,6 +32,30 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GamesErrorDisplay" id="error_display">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="name">error</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEventBox" id="display_bin">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="name">display</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index ec43863..5b6f097 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -174,27 +174,29 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
private void run_game_with_cancellable (Game game, Cancellable cancellable) {
- Runner runner = null;
+ ui_state = UiState.DISPLAY;
+ display_header_bar.game_title = game.name;
+ display_box.header_bar.game_title = game.name;
+
try {
- runner = get_runner_for_game (game);
+ display_box.runner = get_runner_for_game (game);
+ display_header_bar.can_fullscreen = display_box.runner.can_fullscreen;
+ display_box.header_bar.can_fullscreen = display_box.runner.can_fullscreen;
}
catch (Error e) {
- warning ("%s\n", e.message);
- collection_box.display_error (e.message);
+ display_box.runner = null;
+ display_header_bar.can_fullscreen = false;
+ display_box.header_bar.can_fullscreen = false;
+
+ warning (e.message);
+ display_box.display_running_game_failed (e, game);
return;
}
- display_header_bar.game_title = game.name;
- display_header_bar.can_fullscreen = runner.can_fullscreen;
- display_box.header_bar.game_title = game.name;
- display_box.header_bar.can_fullscreen = runner.can_fullscreen;
- display_box.runner = runner;
- ui_state = UiState.DISPLAY;
-
var resume = false;
- if (runner.can_resume) {
+ if (display_box.runner.can_resume) {
var dialog = new ResumeDialog ();
dialog.set_transient_for (this);
@@ -223,9 +225,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
try {
if (resume)
- runner.resume ();
+ display_box.runner.resume ();
else
- runner.start ();
+ display_box.runner.start ();
}
catch (Error e) {
warning (@"$(e.message)\n");
@@ -251,7 +253,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return;
case Gtk.ResponseType.ACCEPT:
default:
- runner.start ();
+ display_box.runner.start ();
break;
}
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 8f9b462..166b03b 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -15,6 +15,8 @@ private class Games.DisplayBox : Gtk.EventBox {
private Runner _runner;
public Runner runner {
set {
+ stack.visible_child = display_bin;
+
_runner = value;
remove_display ();
@@ -30,6 +32,12 @@ private class Games.DisplayBox : Gtk.EventBox {
[GtkChild]
private Gtk.Overlay overlay;
[GtkChild]
+ private Gtk.Stack stack;
+ [GtkChild]
+ private ErrorDisplay error_display;
+ [GtkChild]
+ private Gtk.EventBox display_bin;
+ [GtkChild]
private Gtk.Revealer fullscreen_header_bar_revealer;
[GtkChild]
private DisplayHeaderBar fullscreen_header_bar;
@@ -46,6 +54,11 @@ private class Games.DisplayBox : Gtk.EventBox {
timeout_id = -1;
}
+ public void display_running_game_failed (Error e, Game game) {
+ stack.visible_child = error_display;
+ error_display.running_game_failed (game);
+ }
+
[GtkCallback]
private void on_fullscreen_changed () {
on_activity ();
@@ -104,13 +117,13 @@ private class Games.DisplayBox : Gtk.EventBox {
private void set_display (Gtk.Widget display) {
remove_display ();
- overlay.add (display);
+ display_bin.add (display);
display.visible = true;
}
private void remove_display () {
- var child = overlay.get_child ();
+ var child = display_bin.get_child ();
if (child != null)
- overlay.remove (child);
+ display_bin.remove (child);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]