[iagno] Use CSS (a little).



commit 8f10d9f53f96dfa6284e2311a0a5b34a4c917dea
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Feb 10 06:30:31 2015 +0100

    Use CSS (a little).

 data/Makefile.am        |    1 +
 data/iagno.css          |    3 ++
 data/iagno.ui           |   76 +++++++++++++++++++++-------------------------
 src/iagno.gresource.xml |    1 +
 src/iagno.vala          |   35 +++++----------------
 5 files changed, 48 insertions(+), 68 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 4e97078..5f98865 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = icons
 dist_noinst_DATA = \
        iagno-menus.ui \
        iagno.ui \
+       iagno.css \
        dark.svg \
        light.svg \
        mark.svg
diff --git a/data/iagno.css b/data/iagno.css
new file mode 100644
index 0000000..76de693
--- /dev/null
+++ b/data/iagno.css
@@ -0,0 +1,3 @@
+GtkLabel.bold-label {
+  font-weight: bold;
+}
diff --git a/data/iagno.ui b/data/iagno.ui
index 01f0b41..f5e38d8 100644
--- a/data/iagno.ui
+++ b/data/iagno.ui
@@ -61,37 +61,40 @@
         <child>
           <object class="GtkBox" id="start-box">
             <property name="orientation">vertical</property>
+            <property name="visible">True</property>
+            <property name="homogeneous">True</property>
             <property name="halign">center</property>
             <property name="valign">center</property>
             <property name="spacing">18</property>
-            <property name="visible">True</property>
             <child>
               <object class="GtkBox">
                 <property name="orientation">vertical</property>
                 <property name="visible">True</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="players-label">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="valign">center</property>
                     <property name="halign">start</property>
+                    <property name="label" translatable="yes">Players</property>
+                    <style>
+                      <class name="bold-label"/>
+                    </style>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkBox" id="num-players-box">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
+                    <property name="homogeneous">True</property>
                     <property name="spacing">12</property>
                     <child>
                       <object class="GtkRadioButton" id="one">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_One</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.num-players</property>
                         <property name="action-target">1</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -100,15 +103,13 @@
                     <child>
                       <object class="GtkRadioButton">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Two</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.num-players</property>
                         <property name="action-target">2</property>
                         <property name="group">one</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -127,27 +128,29 @@
                 <property name="visible">True</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="difficulty-label">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="valign">center</property>
                     <property name="halign">start</property>
+                    <property name="label" translatable="yes">Difficulty</property>
+                    <style>
+                      <class name="bold-label"/>
+                    </style>
                   </object>
                 </child>
                 <child>
                   <object class="GtkBox" id="difficulty-box">
                     <property name="visible">True</property>
+                    <property name="homogeneous">True</property>
                     <property name="spacing">12</property>
                     <child>
                       <object class="GtkRadioButton" id="easy">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Easy</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.computer-level</property>
                         <property name="action-target">1</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -156,15 +159,13 @@
                     <child>
                       <object class="GtkRadioButton">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Medium</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.computer-level</property>
                         <property name="action-target">2</property>
                         <property name="group">easy</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -173,15 +174,13 @@
                     <child>
                       <object class="GtkRadioButton">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Hard</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.computer-level</property>
                         <property name="action-target">3</property>
                         <property name="group">easy</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -197,27 +196,29 @@
                 <property name="visible">True</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="color-label">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="valign">center</property>
                     <property name="halign">start</property>
+                    <property name="label" translatable="yes">Color</property>
+                    <style>
+                      <class name="bold-label"/>
+                    </style>
                   </object>
                 </child>
                 <child>
                   <object class="GtkBox" id="color-box">
                     <property name="visible">True</property>
+                    <property name="homogeneous">True</property>
                     <property name="spacing">12</property>
                     <child>
                       <object class="GtkRadioButton" id="play_dark">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Dark</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.color</property>
                         <property name="action-target">'dark'</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -226,15 +227,13 @@
                     <child>
                       <object class="GtkRadioButton">
                         <property name="visible">True</property>
+                        <property name="height-request">50</property>
                         <property name="use_underline">True</property>
                         <property name="label" translatable="yes">_Light</property>
-                        <property name="halign">fill</property>
-                        <property name="valign">fill</property>
                         <property name="action-name">app.color</property>
                         <property name="action-target">'light'</property>
                         <property name="group">play_dark</property>
                         <property name="draw-indicator">False</property>
-                        <property name="expand">True</property>
                         <style>
                           <class name="button"/>
                         </style>
@@ -248,12 +247,10 @@
               </object>
             </child>
             <child>
-              <object class="GtkButton" id="start-button">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="use_underline">True</property>
                 <property name="label" translatable="yes">_Start Game</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
                 <property name="action-name">app.start-game</property>
                 <property name="tooltip-text" translatable="yes">Start a game</property>
                 <property name="height-request">50</property>
@@ -327,6 +324,9 @@
                           <object class="GtkLabel" id="dark-score-label">
                             <property name="visible">True</property>
                             <property name="label">00</property>
+                            <style>
+                              <class name="bold-label"/>
+                            </style>
                           </object>
                           <packing>
                             <property name="left-attach">2</property>
@@ -357,6 +357,9 @@
                           <object class="GtkLabel" id="light-score-label">
                             <property name="visible">True</property>
                             <property name="label">00</property>
+                            <style>
+                              <class name="bold-label"/>
+                            </style>
                           </object>
                           <packing>
                             <property name="left-attach">2</property>
@@ -409,13 +412,4 @@
       </object>
     </child>
   </object>
-  <object class="GtkSizeGroup">
-    <property name="mode">both</property>
-    <widgets>
-      <widget name="num-players-box"/>
-      <widget name="difficulty-box"/>
-      <widget name="color-box"/>
-      <widget name="start-button"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/src/iagno.gresource.xml b/src/iagno.gresource.xml
index 7a191ac..8260b10 100644
--- a/src/iagno.gresource.xml
+++ b/src/iagno.gresource.xml
@@ -7,6 +7,7 @@
   </gresource>
   <gresource prefix="/org/gnome/iagno/ui">
     <file preprocess="xml-stripblanks" alias="iagno.ui">../data/iagno.ui</file>
+    <file alias="iagno.css">../data/iagno.css</file>
   </gresource>
   <gresource prefix="/org/gnome/iagno/gtk">
     <file preprocess="xml-stripblanks" alias="menus.ui">../data/iagno-menus.ui</file>
diff --git a/src/iagno.vala b/src/iagno.vala
index b81e752..203ce8e 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -149,6 +149,10 @@ public class Iagno : Gtk.Application
     {
         base.startup ();
 
+        var css_provider = new Gtk.CssProvider ();
+        css_provider.load_from_resource ("/org/gnome/iagno/ui/iagno.css");
+        Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
         var builder = new Gtk.Builder.from_resource ("/org/gnome/iagno/ui/iagno.ui");
 
         /* Settings */
@@ -212,21 +216,6 @@ public class Iagno : Gtk.Application
         settings.set_int ("computer-level", computer_level);
         settings.set_int ("num-players", two_players ? 2 : 1);
 
-        var label = builder.get_object ("players-label") as Gtk.Label;
-        label.use_markup = true;
-        /* Label on new game screen */
-        label.label = "<b>%s</b>".printf (_("Players"));
-
-        label = builder.get_object ("difficulty-label") as Gtk.Label;
-        label.use_markup = true;
-        /* Label on new game screen */
-        label.label = "<b>%s</b>".printf (_("Difficulty"));
-
-        label = builder.get_object ("color-label") as Gtk.Label;
-        label.use_markup = true;
-        /* Label on new game screen */
-        label.label = "<b>%s</b>".printf (_("Color"));
-
         /* View construction */
         view = new GameView ();
         view.move.connect (player_move_cb);
@@ -376,19 +365,11 @@ public class Iagno : Gtk.Application
             undo_action.set_enabled (game.number_of_moves >= 2);
 
         /* Translators: this is a 2 digit representation of the current score. */
-        dark_score_label.set_markup ("<span font_weight='bold'>"+(_("%.2d").printf 
(game.n_dark_tiles))+"</span>");
-        light_score_label.set_markup ("<span font_weight='bold'>"+(_("%.2d").printf 
(game.n_light_tiles))+"</span>");
+        dark_score_label.set_text (_("%.2d").printf (game.n_dark_tiles));
+        light_score_label.set_text (_("%.2d").printf (game.n_light_tiles));
 
-        if (game.current_color == Player.DARK)
-        {
-            mark_icon_light.hide ();
-            mark_icon_dark.show ();
-        }
-        else if (game.current_color == Player.LIGHT)
-        {
-            mark_icon_dark.hide ();
-            mark_icon_light.show ();
-        }
+        mark_icon_dark.visible = (game.current_color == Player.DARK);
+        mark_icon_light.visible = (game.current_color == Player.LIGHT);
     }
 
     private void undo_move_cb ()


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