[gnome-games/wip/exalm/subprocess: 48/49] error-display: Support showing crashes



commit e75c27977f5fc363114a771a0fa30dce7f803f72
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 dd61af6f..3861309d 100644
--- a/data/ui/error-display.ui
+++ b/data/ui/error-display.ui
@@ -40,5 +40,15 @@
         <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>
   </template>
 </interface>
diff --git a/src/ui/error-display.vala b/src/ui/error-display.vala
index 6369ef08..acfe260d 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 = primary;
                secondary_label.label = secondary;
        }
+
+       [GtkCallback]
+       private void restart_cb () {
+               restart ();
+       }
 }


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