Commit 27fa3f72 authored by Bruce Cowan's avatar Bruce Cowan

Remove custom font setting

parent f1d50085
.countdown-label
{
font: 36pt sans-serif;
}
.clock-label
{
font: 48pt sans-serif;
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/uk/me/bcowan/countdown">
<file preprocess="xml-stripblanks">gtk/menu.ui</file>
<file compressed="true">countdown.css</file>
</gresource>
</gresources>
......@@ -26,16 +26,13 @@ class CountdownApplicationWindow(Gtk.ApplicationWindow):
grid.add(self._count)
def _on_preferences(self, btn):
dialogue = PreferenceDialog(self._count.target, self._clock.font)
dialogue = PreferenceDialog(self._count.target)
dialogue.set_transient_for(self)
dialogue.show_all()
dialogue.connect('response', self._on_preferences_response)
def _on_preferences_response(self, dialogue, resp_id):
if resp_id == Gtk.ResponseType.ACCEPT:
self._clock.props.font = dialogue.font
self._count.props.font = dialogue.font
self._count.target = dialogue.datetime
dialogue.destroy()
\ No newline at end of file
......@@ -10,10 +10,10 @@ class CountdownLabel(Gtk.Label):
Gtk.Label.__init__(self)
# Properties
self._fd = Pango.FontDescription.from_string("Sans 36")
self._target = GLib.DateTime.new_now_local()
self.override_font(self._fd)
ctx = self.get_style_context()
ctx.add_class('countdown-label')
self._update_clock()
GLib.timeout_add_seconds(1, self._update_clock)
......@@ -26,7 +26,7 @@ class CountdownLabel(Gtk.Label):
return True
def _format_difference(self, diff):
diff = abs(diff) / GLib.TIME_SPAN_SECOND
diff = (abs(diff) / GLib.TIME_SPAN_SECOND) + 1
seconds = int(diff % 60)
diff /= 60
minutes = int(diff % 60)
......@@ -37,16 +37,6 @@ class CountdownLabel(Gtk.Label):
return "{:3d} days\n{:3d} hours\n{:3d} minutes\n{:3d} seconds".format(days, hours, minutes, seconds)
@GObject.Property(type=Pango.FontDescription)
def font(self):
return self._fd
@font.setter
def font(self, fd):
self._fd = fd
self.override_font(fd)
self._update_clock()
@GObject.Property(type=GLib.DateTime)
def target(self):
return self._target
......@@ -55,4 +45,3 @@ class CountdownLabel(Gtk.Label):
def target(self, target):
self._target = target
self._update_clock()
\ No newline at end of file
......@@ -7,29 +7,14 @@ class DigitalClock(Gtk.Label):
def __init__(self):
Gtk.Label.__init__(self)
self._fd = Pango.FontDescription.from_string("Sans 48")
self.override_font(self._fd)
self._update_clock()
GLib.timeout_add_seconds(1, self._update_clock)
ctx = self.get_style_context()
ctx.add_class('clock-label')
def _update_clock(self):
now = GLib.DateTime.new_now_local()
text = now.format("%d/%m/%y %H∶%M∶%S")
self.set_label(text)
return True
@GObject.Property(type=Pango.FontDescription)
def font(self):
return self._fd
@font.setter
def font(self, font):
self._fd = font
# Make the primary bit 4/3 the size
size = font.get_size()
size += (font.get_size() / 3)
font.set_size(size)
self.override_font(font)
self._update_clock()
......@@ -3,7 +3,7 @@ import sys
from gi import require_version
require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk, Pango
from gi.repository import Gdk, Gio, Gtk, Pango
from .aboutdialog import AboutDialog
from .countdownapplicationwindow import CountdownApplicationWindow
......@@ -29,6 +29,13 @@ class CountdownApplication(Gtk.Application):
quit_action.connect("activate", self._on_quit)
self.add_action(quit_action)
provider = Gtk.CssProvider()
provider.load_from_resource('/uk/me/bcowan/countdown/countdown.css')
screen = Gdk.Screen.get_default()
ctx = Gtk.StyleContext()
ctx.add_provider_for_screen(screen, provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
# Turn this into a lambda if possible
def _on_about_response(self, dialogue, resp_id):
dialogue.destroy();
......
......@@ -5,7 +5,7 @@ class PreferenceDialog(Gtk.Dialog):
"""A dialogue for choosing preferences"""
__gtype_name__ = 'PreferenceDialog'
def __init__(self, target, fd):
def __init__(self, target):
Gtk.Dialog.__init__(self, title="Preferences", flags=Gtk.DialogFlags.MODAL, resizable=False, use_header_bar=True)
self.add_button("_Cancel", Gtk.ResponseType.CANCEL)
......@@ -43,10 +43,6 @@ class PreferenceDialog(Gtk.Dialog):
self._calendar.select_month(target.get_month() - 1, target.get_year())
grid.attach_next_to(self._calendar, self._hour, Gtk.PositionType.TOP, 5, 1)
# Font chooser
self._font_choose = Gtk.FontChooserWidget(font_desc=fd)
grid.attach_next_to(self._font_choose, self._calendar, Gtk.PositionType.RIGHT, 1, 2)
def _on_spin_output(self, spin):
value = int(spin.props.value)
text = "{:02d}".format(value)
......@@ -62,7 +58,3 @@ class PreferenceDialog(Gtk.Dialog):
second = int(self._second.props.value)
return GLib.DateTime.new_local(year, month, day, hour, minute, second)
@GObject.Property(type=Pango.FontDescription)
def font(self):
return self._font_choose.get_font_desc()
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