def update(self, secs=None): clock_format = SystemSettings.get_clock_format() location_time = self.get_location_time(secs) if clock_format == '12h': t = location_time.strftime("%I:%M %p") else: t = location_time.strftime("%H:%M") if t.startswith("0"): t = t[1:] if not t == self._last_time \ or not self.sunrise == self._last_sunrise \ or not self.sunset == self._last_sunset: is_light = self.get_is_light(location_time) if is_light: img = os.path.join(Dirs.get_image_dir(), "cities", "day.png") else: img = os.path.join(Dirs.get_image_dir(), "cities", "night.png") day = self.get_day(secs) if day == "Today": self.drawing.render(t, img, is_light) else: self.drawing.render(t, img, is_light, day) if self.path and self.list_store: self.list_store[self.path][1] = self.drawing.pixbuf if self.standalone: self.standalone.update(img, t, self.sunrise, self.sunset) self._last_time = t
def __init__(self, view, alarm, alert): self.view = view self.alarm = alarm self.alert = alert timestr = alarm.get_time_as_string() repeat = alarm.get_alarm_repeat_string() self.drawing = DigitalClockDrawing() is_light = self.get_is_light(int(timestr[:2])) if is_light: img = os.path.join(Dirs.get_image_dir(), "cities", "day.png") else: img = os.path.join(Dirs.get_image_dir(), "cities", "night.png") self.drawing.render(timestr, img, is_light, repeat) self.standalone = None
def __init__(self, app): Gtk.ApplicationWindow.__init__(self, title=_("Clocks"), application=app, hide_titlebar_when_maximized=True) action = Gio.SimpleAction.new("new", None) action.connect("activate", self._on_new_activated) self.add_action(action) app.add_accelerator("<Primary>n", "win.new", None) action = Gio.SimpleAction.new("about", None) action.connect("activate", self._on_about_activated) self.add_action(action) css_provider = Gtk.CssProvider() css_provider.load_from_path(os.path.join(Dirs.get_data_dir(), "gtk-style.css")) context = Gtk.StyleContext() context.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.set_size_request(640, 480) self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.embed = Embed(self.vbox) self.add(self.embed) self.notebook = Gtk.Notebook() self.notebook.set_show_tabs(False) self.notebook.set_show_border(False) self.world = World() self.alarm = Alarm() self.stopwatch = Stopwatch() self.timer = Timer() self.views = (self.world, self.alarm, self.stopwatch, self.timer) self.toolbar = ClocksToolbar(self.views, self.embed) self.vbox.pack_start(self.toolbar, False, False, 0) self.single_evbox = Gtk.EventBox() self.vbox.pack_end(self.notebook, True, True, 0) for view in self.views: self.notebook.append_page(view, None) self.notebook.append_page(self.single_evbox, None) self.world.connect("show-standalone", self._on_show_standalone) self.alarm.connect("show-standalone", self._on_show_standalone) self.toolbar.connect("view-clock", self._on_view_clock) self.vbox.show_all() self.show_all() self.toolbar.show_overview_toolbar()
def __init__(self): self.filename = os.path.join(Dirs.get_user_data_dir(), "alarms.json")