[gnome-taquin] Clean code.



commit f262574048c4fcbb2840ba2da87e4d952f317c57
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Mar 25 13:38:28 2015 +0100

    Clean code.

 data/taquin-screens.ui |   35 +++++++++++++++--------------------
 data/taquin.css        |   16 ++++++++--------
 src/taquin-main.vala   |   25 +++----------------------
 3 files changed, 26 insertions(+), 50 deletions(-)
---
diff --git a/data/taquin-screens.ui b/data/taquin-screens.ui
index b194c29..123f38f 100644
--- a/data/taquin-screens.ui
+++ b/data/taquin-screens.ui
@@ -38,6 +38,7 @@
     <property name="orientation">vertical</property>
     <property name="visible">True</property>
     <property name="spacing">6</property>
+    <property name="width-request">400</property>
     <child>
       <object class="GtkBox">
         <property name="orientation">horizontal</property>
@@ -45,32 +46,29 @@
         <property name="homogeneous">True</property>
         <property name="spacing">6</property>
         <child>
-          <object class="GtkRadioButton" id="radio-fifteen">
+          <object class="GtkModelButton">
             <property name="visible">True</property>
             <property name="name">radio-fifteen</property>
-            <style><class name="radio-like-toggle"/></style>
+            <style><class name="radio-like-toggle"/><class name="flat"/></style>
             <property name="focus-on-click">False</property>
-            <property name="relief">none</property> <!-- could probably be replaced by a use of the "flat" 
style-class -->
-            <property name="action-name">app.change-type</property>
+            <property name="action-name">app.type</property>
             <property name="action-target">'fifteen'</property>
-            <property name="draw-indicator">False</property>
-            <property name="label" translatable="yes">15-Puzzle</property>
-            <property name="width-request">197</property>
+            <property name="text" translatable="yes">15-Puzzle</property>
+            <property name="iconic">True</property>
+            <property name="centered">True</property>
           </object>
         </child>
         <child>
-          <object class="GtkRadioButton" id="radio-sixteen">
+          <object class="GtkModelButton">
             <property name="visible">True</property>
             <property name="name">radio-sixteen</property>
-            <style><class name="radio-like-toggle"/></style>
+            <style><class name="radio-like-toggle"/><class name="flat"/></style>
             <property name="focus-on-click">False</property>
-            <property name="relief">none</property>
-            <property name="action-name">app.change-type</property>
+            <property name="action-name">app.type</property>
             <property name="action-target">'sixteen'</property>
-            <property name="group">radio-fifteen</property>
-            <property name="draw-indicator">False</property>
-            <property name="label" translatable="yes">16-Puzzle</property>
-            <property name="width-request">197</property>
+            <property name="text" translatable="yes">16-Puzzle</property>
+            <property name="iconic">True</property>
+            <property name="centered">True</property>
           </object>
         </child>
       </object>
@@ -91,8 +89,7 @@
             <property name="use-underline">True</property>
             <property name="menu-model">size-menu</property>
             <property name="height-request">60</property>
-            <style><class name="menubutton-like-combo"/></style>
-            <property name="relief">none</property> <!-- could probably be replaced by a use of the "flat" 
style-class -->
+            <style><class name="menubutton-like-combo"/><class name="flat"/></style>
           </object>
           <packing>
             <property name="expand">True</property>
@@ -105,8 +102,7 @@
             <property name="use-underline">True</property>
             <property name="menu-model">theme-menu</property>
             <property name="height-request">60</property>
-            <style><class name="menubutton-like-combo"/></style>
-            <property name="relief">none</property>
+            <style><class name="menubutton-like-combo"/><class name="flat"/></style>
           </object>
           <packing>
             <property name="expand">True</property>
@@ -115,7 +111,6 @@
         </child>
       </object>
       <packing>
-        <property name="expand">True</property>
         <property name="fill">True</property>
       </packing>
     </child>
diff --git a/data/taquin.css b/data/taquin.css
index 04b9298..38bd4b7 100644
--- a/data/taquin.css
+++ b/data/taquin.css
@@ -1,24 +1,24 @@
-GtkRadioButton.radio-like-toggle#radio-fifteen {
+GtkModelButton.radio-like-toggle#radio-fifteen {
     background-image: url("resource://org/gnome/taquin/images/15-Puzzle.png");
 }
-GtkRadioButton.radio-like-toggle#radio-sixteen {
+GtkModelButton.radio-like-toggle#radio-sixteen {
     background-image: url("resource://org/gnome/taquin/images/16-Puzzle.png");
 }
 
-GtkRadioButton.radio-like-toggle {
+GtkModelButton.radio-like-toggle {
     background-repeat: no-repeat;
-    /* width is requested by the widget: 197 */
-    padding-top: 15px;
-    padding-bottom: 185px;
     background-position: center 25px;
     color: @theme_fg_color;
     background-color: transparent;
 }
-GtkRadioButton.radio-like-toggle:backdrop {
+GtkModelButton.radio-like-toggle GtkLabel {
+    padding-bottom: 165px;
+}
+GtkModelButton.radio-like-toggle:backdrop {
     color: @theme_unfocused_fg_color;
 }
 
-GtkRadioButton.radio-like-toggle,
+GtkModelButton.radio-like-toggle,
 GtkMenuButton.menubutton-like-combo {
     border-radius:15px;
     outline-radius:13px;
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index 992f009..f5f87a5 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -26,7 +26,6 @@ public class Taquin : Gtk.Application
     private GLib.Settings settings;
     private static int tmp_size = 0;
     private GameType? tmp_type = null;
-    private bool type_changed = false;
     private bool size_changed = false;
     private bool theme_changed = false;
     private static bool? sound = null;
@@ -55,11 +54,10 @@ public class Taquin : Gtk.Application
 
     private const GLib.ActionEntry app_actions[] =
     {
-        /* {"change-type", null, "s", null, null, change_type_cb},  TODO SimpleActionChangeStateCallback is 
deprecated...
+        /* TODO SimpleActionChangeStateCallback is deprecated...
         {"change-size", null, "s", null, null, change_size_cb},     
http://valadoc.org/#!api=gio-2.0/GLib.SimpleActionChangeStateCallback
         {"change-theme", null, "s", null, null, change_theme_cb},   see comments about window.add_action 
(settings.create_action (…)) */
 
-        {"change-type", change_type_cb, "s"},
         {"change-size", change_size_cb, "s"},
         {"change-theme", change_theme_cb, "s"},
 
@@ -167,22 +165,11 @@ public class Taquin : Gtk.Application
         });
         update_theme (settings.get_string ("theme"));
 
-        settings.changed["type"].connect (() => {
-            if (!type_changed)
-            {
-                var button_name = "radio-" + settings.get_string ("type");
-                ((RadioButton) builder.get_object (button_name)).set_active (true);
-            }
-            type_changed = false;
-        });
-        var button_name = "radio-" + settings.get_string ("type");
-        ((RadioButton) builder.get_object (button_name)).set_active (true);
-
         add_action_entries (app_actions, this);
         add_action (settings.create_action ("sound"));
-        // TODO window.add_action (settings.create_action ("type"));        // Problem: same bug as in 
Iagno, the settings are resetted to the first radiobutton found
+        add_action (settings.create_action ("type"));        // TODO window action?
         // TODO window.add_action (settings.create_action ("size"));        // Problem: cannot use this way 
for an integer from a menu; works for radiobuttons in Iagno
-        // TODO window.add_action (settings.create_action ("theme"));       // Problem: a bug that exists in 
the three tries, and in Iagno: you cannot manually change the gsetting or it bugs completely (gsetting 
between two states)
+        // TODO window.add_action (settings.create_action ("theme"));
 
         add_window (window);
         start_game ();
@@ -311,12 +298,6 @@ public class Taquin : Gtk.Application
     * * Options of the start-screen
     \*/
 
-    private void change_type_cb (SimpleAction action, Variant? variant)
-    {
-        type_changed = true;
-        settings.set_string ("type", variant.get_string ());
-    }
-
     private void change_size_cb (SimpleAction action, Variant? variant)
     {
         size_changed = true;


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