[gnome-2048] Refresh the Congratulations dialog.



commit 74abe4f39c8dbec4e9c5d028a8649adc15ad8371
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 25 13:04:57 2019 +0100

    Refresh the Congratulations dialog.
    
    Use a custom MessageDialog, for having a
    more modern feeling with a correct look.
    Add mnemonic to the two actions buttons.
    
    It would be great to make it more easily
    moved, but it's hard to find a solution.

 data/congrats.ui     | 109 ++++++++++++++-------------------------------------
 src/application.vala |  10 ++---
 2 files changed, 33 insertions(+), 86 deletions(-)
---
diff --git a/data/congrats.ui b/data/congrats.ui
index d789846..3f109cf 100644
--- a/data/congrats.ui
+++ b/data/congrats.ui
@@ -17,100 +17,51 @@
 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
-  <object class="GtkDialog" id="congratsdialog">
+  <object class="GtkMessageDialog" id="congratsdialog">
     <property name="can-focus">False</property>
-    <property name="border-width">12</property>
     <!-- Translators: title of the dialog that appears (with default settings) when you reach 2048 -->
-    <property name="title" translatable="yes">Congratulations!</property>
+    <property name="text" translatable="yes">Congratulations!</property>
     <property name="resizable">False</property>
-    <property name="type-hint">dialog</property>
-    <child internal-child="vbox">
+    <property name="buttons">none</property>
+    <child internal-child="message_area">
       <object class="GtkBox">
-        <property name="can-focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox">
-            <property name="can-focus">False</property>
-            <property name="layout-style">end</property>
-            <child>
-              <object class="GtkButton" id="button1">
-                <!-- Translators: button in the "Congratulations" dialog that appears (with default 
settings) when you reach 2048 -->
-                <property name="label" translatable="yes">New Game</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="receives-default">True</property>
-                <style>
-                  <class name="suggested-action"/>
-                </style>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button2">
-                <!-- Translators: button in the "Congratulations" dialog that appears (with default 
settings) when you reach 2048; the player can continue playing after 2048 -->
-                <property name="label" translatable="yes">Keep Playing</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="receives-default">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
-          <object class="GtkGrid">
+          <object class="GtkImage">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
-            <property name="column-homogeneous">True</property>
-            <child>
-              <object class="GtkLabel" id="messagelabel">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="pixel-size">145</property>
-                <property name="icon-name">face-wink</property>
-                <property name="icon-size">6</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-              </packing>
-            </child>
+            <property name="pixel-size">64</property>
+            <property name="icon-name">face-wink</property>
+            <property name="icon-size">6</property>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
       </object>
     </child>
+    <child type="action">
+      <object class="GtkButton" id="new-game-button">
+        <property name="visible">True</property>
+        <!-- Translators: button in the "Congratulations" dialog that appears (with default settings) when 
you reach 2048 (with a mnemonic that appears pressing Alt)-->
+        <property name="label" translatable="yes">_New Game</property>
+        <property name="use-underline">True</property>
+      </object>
+    </child>
+    <child type="action">
+      <object class="GtkButton" id="continue-button">
+        <property name="visible">True</property>
+        <!-- Translators: button in the "Congratulations" dialog that appears (with default settings) when 
you reach 2048; the player can continue playing after 2048 (with a mnemonic that appears pressing Alt) -->
+        <property name="label" translatable="yes">_Keep Playing</property>
+        <property name="use-underline">True</property>
+        <property name="can-default">True</property>
+        <style>
+          <class name="suggested-action"/>
+        </style>
+      </object>
+    </child>
     <action-widgets>
-      <action-widget response="0">button1</action-widget>
-      <action-widget response="1">button2</action-widget>
+      <action-widget response="0">new-game-button</action-widget>
+      <action-widget response="1" default="true">continue-button</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/src/application.vala b/src/application.vala
index 0dd76dd..7a15682 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -35,7 +35,6 @@ public class Application : Gtk.Application
     /* private widgets */
     private Window _window;
     private HeaderBar _header_bar;
-    private Label _congrats_message;
     private Label _score;
     private MenuButton _new_game_button;
     private MenuButton _hamburger_button;
@@ -418,14 +417,14 @@ public class Application : Gtk.Application
     * * congratulations dialog
     \*/
 
-    private Dialog _congrats_dialog;
+    private MessageDialog _congrats_dialog;
 
     private bool _should_create_congrats_dialog = true;
     private inline void _create_congrats_dialog ()
     {
         Builder builder = new Builder.from_resource ("/org/gnome/gnome-2048/data/congrats.ui");
 
-        _congrats_dialog = (Dialog) builder.get_object ("congratsdialog");
+        _congrats_dialog = (MessageDialog) builder.get_object ("congratsdialog");
         _congrats_dialog.set_transient_for (_window);
 
         _congrats_dialog.response.connect ((response_id) => {
@@ -436,8 +435,6 @@ public class Application : Gtk.Application
         _congrats_dialog.delete_event.connect ((response_id) => {
                 return _congrats_dialog.hide_on_delete ();
             });
-
-        _congrats_message = (Label) builder.get_object ("messagelabel");
     }
 
     private inline void target_value_reached_cb (uint target_value)
@@ -451,8 +448,7 @@ public class Application : Gtk.Application
             }
 
             /* Translators: text of the dialog that appears when the user obtains the first 2048 tile in the 
game; the %u is replaced by the number the user wanted to reach (usually, 2048) */
-            string message = _("You have obtained the %u tile for the first time!").printf (target_value);
-            _congrats_message.set_text (message);
+            _congrats_dialog.format_secondary_text (_("You have obtained the %u tile for the first time!"), 
target_value);
             _congrats_dialog.present ();
             _settings.set_boolean ("do-congrat", false);
         }


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