[gnome-games/wip/exalm/subprocess: 7/8] error-display: Support showing crashes



commit 0585a6185ee4efc2774d89de9f285a5fceba83d0
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Jan 10 18:57:08 2020 +0500

    error-display: Support showing crashes
    
    Add game_crashed() which would show different message and a restart button.
    
    Add restart signal.

 data/ui/error-display.ui  | 10 ++++++++++
 src/ui/error-display.vala | 17 +++++++++++++++++
 2 files changed, 27 insertions(+)
---
diff --git a/data/ui/error-display.ui b/data/ui/error-display.ui
index 37c45a4e..0bf2e103 100644
--- a/data/ui/error-display.ui
+++ b/data/ui/error-display.ui
@@ -43,6 +43,16 @@
             <property name="wrap">True</property>
           </object>
         </child>
+        <child>
+          <object class="GtkButton" id="restart_btn">
+            <property name="visible">True</property>
+            <property name="label">_Restart Game</property>
+            <property name="use-underline">True</property>
+            <property name="margin-top">12</property>
+            <property name="halign">center</property>
+            <signal name="clicked" handler="restart_cb"/>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/src/ui/error-display.vala b/src/ui/error-display.vala
index 97473ff8..068cac33 100644
--- a/src/ui/error-display.vala
+++ b/src/ui/error-display.vala
@@ -2,10 +2,14 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/error-display.ui")]
 private class Games.ErrorDisplay : Gtk.Box {
+       public signal void restart ();
+
        [GtkChild]
        private Gtk.Label primary_label;
        [GtkChild]
        private Gtk.Label secondary_label;
+       [GtkChild]
+       private Gtk.Button restart_btn;
 
        public void running_game_failed (Game game, string message) {
                string title;
@@ -15,10 +19,23 @@ private class Games.ErrorDisplay : Gtk.Box {
                        title = _("Oops! Unable to run the game");
 
                set_labels (title, message);
+               restart_btn.hide ();
+       }
+
+       public void game_crashed (Game game, string message) {
+               var title = _("Oops! The game ā€œ%sā€ crashed unexpectedly").printf (game.name);
+
+               set_labels (title, message);
+               restart_btn.show ();
        }
 
        private void set_labels (string primary, string secondary) {
                primary_label.label = @"<big><b>$(Markup.escape_text (primary))</b></big>";
                secondary_label.label = Markup.escape_text (secondary);
        }
+
+       [GtkCallback]
+       private void restart_cb () {
+               restart ();
+       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]