[gnome-clocks] Use css instead of pango markup for the buttons font



commit b23d236e08ec96e4d9fa3408a5265e0b07b6590f
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Feb 2 13:22:22 2013 +0100

    Use css instead of pango markup for the buttons font

 data/css/gnome-clocks.css |    4 ++++
 gnomeclocks/alarm.py      |   10 ++++++----
 gnomeclocks/stopwatch.py  |   17 +++++++++--------
 gnomeclocks/timer.py      |   18 ++++++++++--------
 4 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index bc675f6..2f03ac8 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -98,6 +98,10 @@
     color: white;
 }
 
+.clocks-button {
+    font-size: 18px;
+}
+
 .clocks-go {
     background-image: linear-gradient(to bottom,
                                       @clocks_go_color_a,
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index 27e292a..1b3128b 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -307,18 +307,20 @@ class AlarmStandalone(Gtk.EventBox):
         self.repeat_label.set_alignment(0.5, 0.5)
 
         self.left_button = Gtk.Button()
+        self.left_button.get_style_context().add_class("clocks-button")
         self.left_button.get_style_context().add_class("clocks-stop")
         self.left_button.set_size_request(200, -1)
         left_label = Gtk.Label()
+        left_label.set_text(_("Stop"))
+        left_label.set_padding(6, 0)
         self.left_button.add(left_label)
         self.right_button = Gtk.Button()
+        self.right_button.get_style_context().add_class("clocks-button")
         self.right_button.set_size_request(200, -1)
         right_label = Gtk.Label()
-        self.right_button.add(right_label)
-        left_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Stop")))
-        left_label.set_padding(6, 0)
-        right_label.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Snooze")))
+        right_label.set_text(_("Snooze"))
         right_label.set_padding(6, 0)
+        self.right_button.add(right_label)
         self.left_button.connect('clicked', self._on_stop_clicked)
         self.right_button.connect('clicked', self._on_snooze_clicked)
 
diff --git a/gnomeclocks/stopwatch.py b/gnomeclocks/stopwatch.py
index be1cc43..215cbd3 100644
--- a/gnomeclocks/stopwatch.py
+++ b/gnomeclocks/stopwatch.py
@@ -25,7 +25,6 @@ from .widgets import Toolbar
 class Stopwatch(Clock):
     LABEL_MARKUP = "<span font_desc=\"64.0\">%02i:%04.1f</span>"
     LABEL_MARKUP_LONG = "<span font_desc=\"64.0\">%i:%02i:%04.1f</span>"
-    BUTTON_MARKUP = "<span font_desc=\"18.0\">%s</span>"
 
     class Page:
         STANDALONE = 0
@@ -67,17 +66,19 @@ class Stopwatch(Clock):
         grid.attach(self.time_label, 0, 0, 2, 1)
 
         self.left_button = Gtk.Button()
+        self.left_button.get_style_context().add_class("clocks-button")
         self.left_button.set_size_request(200, -1)
         self.left_label = Gtk.Label()
-        self.left_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Start")))
+        self.left_label.set_text(_("Start"))
         self.left_button.add(self.left_label)
         self.left_button.get_style_context().add_class("clocks-go")
         grid.attach(self.left_button, 0, 1, 1, 1)
 
         self.right_button = Gtk.Button()
+        self.right_button.get_style_context().add_class("clocks-button")
         self.right_button.set_size_request(200, -1)
         self.right_label = Gtk.Label()
-        self.right_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Reset")))
+        self.right_label.set_text(_("Reset"))
         self.right_button.add(self.right_label)
         self.right_button.set_sensitive(False)
         grid.attach(self.right_button, 1, 1, 1, 1)
@@ -123,18 +124,18 @@ class Stopwatch(Clock):
         if self.state in (Stopwatch.State.RESET, Stopwatch.State.STOPPED):
             self.state = Stopwatch.State.RUNNING
             self.start()
-            self.left_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Stop")))
+            self.left_label.set_text(_("Stop"))
             self.left_button.get_style_context().add_class("clocks-stop")
             self.right_button.set_sensitive(True)
-            self.right_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Lap")))
+            self.right_label.set_text(_("Lap"))
         elif self.state == Stopwatch.State.RUNNING:
             self.state = Stopwatch.State.STOPPED
             self.stop()
-            self.left_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Continue")))
+            self.left_label.set_text(_("Continue"))
             self.left_button.get_style_context().remove_class("clocks-stop")
             self.left_button.get_style_context().add_class("clocks-go")
             self.right_button.set_sensitive(True)
-            self.right_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Reset")))
+            self.right_label.set_text(_("Reset"))
 
     def _on_right_button_clicked(self, widget):
         if self.state == Stopwatch.State.RUNNING:
@@ -155,7 +156,7 @@ class Stopwatch(Clock):
         if self.state == Stopwatch.State.STOPPED:
             self.state = Stopwatch.State.RESET
             self.reset()
-            self.left_label.set_markup(Stopwatch.BUTTON_MARKUP % (_("Start")))
+            self.left_label.set_text(_("Start"))
             self.left_button.get_style_context().add_class("clocks-go")
             self.right_button.set_sensitive(False)
             self.set_time_label(0, 0, 0)
diff --git a/gnomeclocks/timer.py b/gnomeclocks/timer.py
index 20e0c4f..132603f 100644
--- a/gnomeclocks/timer.py
+++ b/gnomeclocks/timer.py
@@ -41,16 +41,18 @@ class TimerScreen(Gtk.Grid):
         self.attach(self.time_label, 0, 0, 2, 1)
 
         self.left_button = Gtk.Button()
+        self.left_button.get_style_context().add_class("clocks-button")
         self.left_button.set_size_request(200, -1)
         self.left_label = Gtk.Label()
-        self.left_label.set_markup(Timer.BUTTON_MARKUP % (_("Pause")))
+        self.left_label.set_text(_("Pause"))
         self.left_button.add(self.left_label)
         self.attach(self.left_button, 0, 1, 1, 1)
 
         self.right_button = Gtk.Button()
+        self.right_button.get_style_context().add_class("clocks-button")
         self.right_button.set_size_request(200, -1)
         self.right_label = Gtk.Label()
-        self.right_label.set_markup(Timer.BUTTON_MARKUP % (_("Reset")))
+        self.right_label.set_text(_("Reset"))
         self.right_button.add(self.right_label)
         self.attach(self.right_button, 1, 1, 1, 1)
 
@@ -61,17 +63,17 @@ class TimerScreen(Gtk.Grid):
         self.time_label.set_markup(Timer.LABEL_MARKUP % (h, m, s))
 
     def _on_right_button_clicked(self, data):
-        self.left_label.set_markup(Timer.BUTTON_MARKUP % (_("Pause")))
+        self.left_label.set_text(_("Pause"))
         self.timer.reset()
 
     def _on_left_button_clicked(self, widget):
         if self.timer.state == Timer.State.RUNNING:
             self.timer.pause()
-            self.left_label.set_markup(Timer.BUTTON_MARKUP % (_("Continue")))
+            self.left_label.set_text(_("Continue"))
             self.left_button.get_style_context().add_class("clocks-go")
         elif self.timer.state == Timer.State.PAUSED:
             self.timer.cont()
-            self.left_label.set_markup(Timer.BUTTON_MARKUP % (_("Pause")))
+            self.left_label.set_text(_("Pause"))
             self.left_button.get_style_context().remove_class("clocks-go")
 
 
@@ -106,11 +108,12 @@ class TimerSetupScreen(Gtk.Grid):
         self.attach(spinner, 0, 0, 1, 1)
 
         self.start_button = Gtk.Button()
+        self.start_button.get_style_context().add_class("clocks-button")
         self.start_button.set_size_request(200, -1)
         label = Gtk.Label()
-        label.set_markup(Timer.BUTTON_MARKUP % (_("Start")))
-        self.start_button.set_sensitive(False)
+        label.set_text(_("Start"))
         self.start_button.add(label)
+        self.start_button.set_sensitive(False)
         self.attach(self.start_button, 0, 1, 1, 1)
 
         self.start_button.connect('clicked', self._on_start_clicked)
@@ -145,7 +148,6 @@ class TimerSetupScreen(Gtk.Grid):
 
 class Timer(Clock):
     LABEL_MARKUP = "<span font_desc=\"64.0\">%02i:%02i:%02i</span>"
-    BUTTON_MARKUP = "<span font_desc=\"18.0\">% s</span>"
 
     class State:
         STOPPED = 0



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