From b61c84e88bede42252990620f5289838508e376c Mon Sep 17 00:00:00 2001 From: flavio Date: Tue, 01 Oct 2013 22:15:32 +0000 Subject: Anular TimeWriter --- (limited to 'clock.py') diff --git a/clock.py b/clock.py index 195efb2..ea09e0f 100755 --- a/clock.py +++ b/clock.py @@ -121,7 +121,7 @@ class ClockActivity(activity.Activity): super(ClockActivity, self).__init__(handle) # TRANS: Title of the activity - self.set_title(_('What Time Is It?')) + self.set_title(_('Qué hora es?')) # TRANS: The format used when writing the time in full # letters. You must take care to use a font size large enough @@ -130,7 +130,7 @@ class ClockActivity(activity.Activity): # screen is rotated. Pango markup: # http://www.pygtk.org/docs/pygtk/pango-markup-language.html self._TIME_LETTERS_FORMAT = _('\ -%s') +%s') # TRANS: The format used to display the weekday and date # (example: Tuesday 10/21/2008) We recommend to use the same @@ -138,7 +138,7 @@ class ClockActivity(activity.Activity): # http://docs.python.org/lib/module-time.html for available # strftime formats. xgettext:no-python-format self._DATE_SHORT_FORMAT = _('\ -\ +\ %A, \ %m/\ %d/\ @@ -406,13 +406,15 @@ class ClockActivity(activity.Activity): thread.start() def _do_write_time(self): - """Translate the time to full letters. """ + Translate the time to full letters. + """ + if self._time_writer is None: self._time_writer = TimeWriter() hour = self._clock.get_time().hour minute = self._clock.get_time().minute - self._time_in_letters = self._time_writer.write_time(hour, minute) + self._time_in_letters = "Son las %s con %s minutos" % (hour, minute) #self._time_writer.write_time(hour, minute) self._time_letters.set_markup(self._TIME_LETTERS_FORMAT % self._time_in_letters) def _do_speak_time(self): @@ -428,7 +430,7 @@ class ClockActivity(activity.Activity): pipeline = 'espeak text="%(text)s" voice="%(voice)s" pitch="%(pitch)s" \ rate="%(rate)s" gap="%(gap)s" ! autoaudiosink' % { - 'text':self._untag(self._time_in_letters), + 'text': self._time_in_letters, #self._untag(self._time_in_letters), 'voice':self._time_speaker.VOICE, 'pitch':self._time_speaker.PITCH, 'rate':self._time_speaker.SPEED, @@ -440,7 +442,7 @@ class ClockActivity(activity.Activity): bus.connect('message', gstmessage_cb, pipe) pipe.set_state(Gst.State.PLAYING) except: - self._time_speaker.speak(self._untag(self._time_in_letters)) + self._time_speaker.speak(self._time_in_letters)#(self._untag(self._time_in_letters)) def _untag(self, text): """Remove all the tags (pango markup) from a text. @@ -534,30 +536,34 @@ class ClockFace(Gtk.DrawingArea): of the clock, radius). """ - # Store the measures of the clock face widget - self._center_x = int(allocation.width / 2.0) - self._center_y = int(allocation.height / 2.0) - self._radius = max(min(int(allocation.width / 2.0), \ - int(allocation.height / 2.0)) - 20, 0) - self._width = allocation.width - self._height = allocation.height - self._line_width = int(self._radius / 150) - - # Reload the svg handle - self._svg_handle = Rsvg.Handle.new_from_file("clock.svg") - cr = self.get_property('window').cairo_create() - self._nice_background_cache = cr.get_target().create_similar( - cairo.CONTENT_COLOR_ALPHA, self._radius * 2, - self._radius * 2) - cache_ctx = cairo.Context(self._nice_background_cache) - scale_x = self._radius * 2.0 / self._svg_handle.props.width - scale_y = self._radius * 2.0 / self._svg_handle.props.height - matrix = cairo.Matrix(xx=scale_x, yy=scale_y) - cache_ctx.transform(matrix) - self._svg_handle.render_cairo(cache_ctx) - - self.initialized = True - + try: + # Store the measures of the clock face widget + self._center_x = int(allocation.width / 2.0) + self._center_y = int(allocation.height / 2.0) + self._radius = max(min(int(allocation.width / 2.0), \ + int(allocation.height / 2.0)) - 20, 0) + self._width = allocation.width + self._height = allocation.height + self._line_width = int(self._radius / 150) + + # Reload the svg handle + self._svg_handle = Rsvg.Handle.new_from_file("clock.svg") + cr = self.get_property('window').cairo_create() + self._nice_background_cache = cr.get_target().create_similar( + cairo.CONTENT_COLOR_ALPHA, self._radius * 2, + self._radius * 2) + cache_ctx = cairo.Context(self._nice_background_cache) + scale_x = self._radius * 2.0 / self._svg_handle.props.width + scale_y = self._radius * 2.0 / self._svg_handle.props.height + matrix = cairo.Matrix(xx=scale_x, yy=scale_y) + cache_ctx.transform(matrix) + self._svg_handle.render_cairo(cache_ctx) + + self.initialized = True + + except: + pass + def _expose_cb(self, widget, event): """The widget is exposed and must draw itself on the graphic context. -- cgit v0.9.1