Exemplo n.º 1
0
    def get_clock_string(self):
        date_value = ""
        time_value = ""

        now = GLib.DateTime.new_now_local()

        if not settings.get_use_custom_format():
            if settings.get_clock_should_show_date():
                date_value = now.format(_("%A, %B %e"))
            else:
                date_value = ""

            if settings.get_clock_should_use_24h():
                time_value = now.format("%H:%M").lstrip()
            else:
                time_value = now.format("%l:%M %p").lstrip()
        else:
            date_value = now.format(settings.get_custom_date_format())
            time_value = now.format(settings.get_custom_time_format())

        clock_string = ('<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>\n' +\
                       '<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>')\
                        % (settings.get_time_font(), time_value, settings.get_date_font(), date_value)

        return clock_string
Exemplo n.º 2
0
    def set_clock_format(self):
        date_format = ""
        time_format = ""

        if settings.get_use_custom_format():
            date_format = settings.get_custom_date_format()
            time_format = settings.get_custom_time_format()
        else:
            date_format = self.clock.get_default_date_format()
            time_format = self.clock.get_default_time_format()

            # %l is 12-hr hours, but it adds a space to 0-9, which looks bad here.
            # The '-' modifier tells the GDateTime formatter not to pad the value.
            time_format = time_format.replace('%l', '%-l')

        time_font = Pango.FontDescription.from_string(settings.get_time_font())
        date_font = Pango.FontDescription.from_string(settings.get_date_font())

        if self.low_res:
            time_size = time_font.get_size() * .66
            date_size = date_font.get_size() * .66
            time_font.set_size(int(time_size))
            date_font.set_size(int(date_size))

        time_format = ('<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>\n' +             \
                       '<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>')                \
            % (time_font.to_string(), time_format, date_font.to_string(), date_format)

        self.clock.set_format_string(time_format)
    def get_clock_string(self):
        date_value = ""
        time_value = ""

        now = GLib.DateTime.new_now_local()

        if not settings.get_use_custom_format():
            if settings.get_clock_should_show_date():
                date_value = now.format(_("%A, %B %e"))
            else:
                date_value = ""

            if settings.get_clock_should_use_24h():
                time_value = now.format("%H:%M").lstrip()
            else:
                time_value = now.format("%l:%M %p").lstrip()
        else:
            date_value = now.format(settings.get_custom_date_format())
            time_value = now.format(settings.get_custom_time_format())

        clock_string = ('<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>\n' +\
                       '<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>')\
                        % (settings.get_time_font(), time_value, settings.get_date_font(), date_value)

        return clock_string
Exemplo n.º 4
0
    def set_clock_format(self):
        date_format = ""
        time_format = ""

        if settings.get_use_custom_format():
            date_format = settings.get_custom_date_format()
            time_format = settings.get_custom_time_format()
        else:
            date_format = self.clock.get_default_date_format()
            time_format = self.clock.get_default_time_format()

            # %l is 12-hr hours, but it adds a space to 0-9, which looks bad here.
            # The '-' modifier tells the GDateTime formatter not to pad the value.
            time_format = time_format.replace('%l', '%-l')

        time_font = Pango.FontDescription.from_string(settings.get_time_font())
        date_font = Pango.FontDescription.from_string(settings.get_date_font())

        if self.low_res:
            time_size = time_font.get_size() * .66
            date_size = date_font.get_size() * .66
            time_font.set_size(int(time_size))
            date_font.set_size(int(date_size))

        time_format = ('<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>\n' +             \
                       '<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>')                \
            % (time_font.to_string(), time_format, date_font.to_string(), date_format)

        self.clock.set_format_string(time_format)
Exemplo n.º 5
0
    def set_clock_format(self):
        date_format = ""
        time_format = ""

        if settings.get_use_custom_format():
            date_format = settings.get_custom_date_format()
            time_format = settings.get_custom_time_format()
        else:
            date_format = self.clock.get_default_date_format()
            time_format = self.clock.get_default_time_format()

            # %l is 12-hr hours, but it adds a space to 0-9, which looks bad here.
            # The '-' modifier tells the GDateTime formatter not to pad the value.
            time_format = time_format.replace('%l', '%-l')

        time_format = ('<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>\n' +             \
                       '<b><span font_desc=\"%s\" foreground=\"#FFFFFF\">%s</span></b>')                \
            % (settings.get_time_font(), time_format, settings.get_date_font(), date_format)

        self.clock.set_format_string(time_format)