Commit a1d3b2c3 authored by Bruce Cowan's avatar Bruce Cowan

--no commit message

--no commit message
parent f12d8d02
......@@ -12,8 +12,8 @@ class Countdown(Gtk.Label):
self.target = datetime.now()
fd = Pango.FontDescription.from_string("Monospace 36")
self.override_font(fd)
self.fd = Pango.FontDescription.from_string("Monospace 36")
self.override_font(self.fd)
self._update_clock()
GObject.timeout_add_seconds(1, self._update_clock)
......@@ -35,4 +35,14 @@ class Countdown(Gtk.Label):
span /= 24
days = int(span)
return "{:3d} days\n{:3d} hours\n{:3d} minutes\n{:3d} seconds".format(days, hours, minutes, seconds)
\ No newline at end of file
return "{:3d} days\n{:3d} hours\n{:3d} minutes\n{:3d} seconds".format(days, hours, minutes, seconds)
def set_font(self, fd):
# Make it 3/4 the size
size = fd.get_size()
size -= (fd.get_size() / 3)
fd.set_size(size)
self.fd = fd
self.override_font(fd)
self._update_clock()
\ No newline at end of file
......@@ -33,6 +33,10 @@ class CountdownApplication(Gtk.Application):
time_action.connect("activate", self._on_choose_time)
self.add_action(time_action)
font_action = Gio.SimpleAction(name="choose_font")
font_action.connect("activate", self._on_choose_font)
self.add_action(font_action)
about_action = Gio.SimpleAction(name="about")
about_action.connect("activate", self._on_about)
self.add_action(about_action)
......@@ -49,12 +53,12 @@ class CountdownApplication(Gtk.Application):
grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)
self.win.add(grid)
clock = DigitalClock()
grid.add(clock)
self.clock = DigitalClock()
grid.add(self.clock)
self.count = Countdown()
grid.add(self.count)
def _on_choose_response(self, dialogue, resp_id):
def _on_choose_time_response(self, dialogue, resp_id):
self.count.target = dialogue.get_datetime()
dialogue.destroy();
......@@ -62,7 +66,22 @@ class CountdownApplication(Gtk.Application):
dialogue = TimeChooserDialog(self.count.target)
dialogue.set_transient_for(self.win)
dialogue.show_all()
dialogue.connect("response", self._on_choose_response)
dialogue.connect("response", self._on_choose_time_response)
def _on_font_choose_response(self, dialogue, resp_id):
if resp_id == Gtk.ResponseType.OK:
self.clock.set_font(dialogue.get_font_desc())
self.count.set_font(dialogue.get_font_desc())
dialogue.destroy()
def _on_choose_font(self, action, param):
dialogue = Gtk.FontChooserDialog(flags=Gtk.DialogFlags.MODAL)
dialogue.set_transient_for(self.win)
dialogue.set_font_desc(self.clock.fd)
dialogue.show_all()
dialogue.connect("response", self._on_font_choose_response)
# Turn this into a lambda if possible
def _on_about_response(self, dialogue, resp_id):
......
......@@ -9,8 +9,8 @@ class DigitalClock(Gtk.Label):
def __init__(self):
Gtk.Label.__init__(self)
fd = Pango.FontDescription.from_string("Monospace 48")
self.override_font(fd)
self.fd = Pango.FontDescription.from_string("Monospace 48")
self.override_font(self.fd)
self._update_clock()
GObject.timeout_add_seconds(1, self._update_clock)
......@@ -18,4 +18,9 @@ class DigitalClock(Gtk.Label):
time = datetime.now()
text = time.strftime("%d/%m/%y %H:%M:%S")
self.set_label(text)
return True
\ No newline at end of file
return True
def set_font(self, fd):
self.fd = fd
self.override_font(fd)
self._update_clock()
\ No newline at end of file
......@@ -6,6 +6,10 @@
<attribute name="action">app.choose_time</attribute>
<attribute name="label">Choose time</attribute>
</item>
<item>
<attribute name="action">app.choose_font</attribute>
<attribute name="label">Choose font</attribute>
</item>
</section>
<section>
<item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment