Пример #1
0
    def __init__(self, applet):
        self.__applet = applet

        self.__city_boxes = {}
        self.cache_surface = {}

        # Initialize the base clock so that the clocks can be drawn immediately when exposed
        self.__previous_state = (None, None, applet.applet.settings["theme"])
        self.base_clock = AnalogClock(
            AnalogClockThemeProvider(self.__previous_state[2]), clock_size)

        self.__cities_vbox = gtk.VBox(spacing=6)

        if "cities-timezones" not in applet.applet.settings:
            applet.applet.settings["cities-timezones"] = list()
        self.__cities_timezones = applet.applet.settings["cities-timezones"]

        applet.applet.timing.register(self.draw_clock_cb, draw_clock_interval)
Пример #2
0
    def draw_clock_cb(self):
        local_time = time.localtime()

        new_state = (local_time[3], local_time[4],
                     self.__applet.applet.settings["theme"],
                     self.__applet.applet.settings["time-24-format"])
        if self.__previous_state == new_state:
            return

        if self.__previous_state[2] != new_state[2]:
            self.base_clock = AnalogClock(
                AnalogClockThemeProvider(new_state[2]), clock_size)

        self.__previous_state = new_state

        # Clear cache because theme might have changed and to avoid memory leaks
        self.cache_surface.clear()

        # Update all clock images and timezone labels
        local_datetime = datetime.now(tz.tzlocal())

        for box in self.__city_boxes.itervalues():
            box.update_clock_image()
            box.update_timezone_label(local_datetime)