def update_color(self): dialog = self.get_toplevel() if self.settings['use_custom']: bg_color = Color.from_string('#' + self.settings['custom_back']) dialog.set_property('dialog-bg', bg_color) border_color = Color.from_string('#' + self.settings['custom_border']) dialog.set_property('border', border_color) elif self.was_custom: bg_color = self.awn_client.get_value('theme', 'dialog_bg') dialog.set_property('dialog-bg', bg_color) border_color = self.awn_client.get_value('theme', 'border') dialog.set_property('border', border_color) color = dialog.get_property('dialog-bg') self.bg_red = color.get_red() / 65535.0 self.bg_green = color.get_green() / 65535.0 self.bg_blue = color.get_blue() / 65535.0 self.bg_alpha = color.get_alpha() / 65535.0 self.was_custom = self.settings['use_custom']
def draw_outlined_number(self, applet): size = sqrt(self.settings['width']**2 + self.settings['height']**2) self.cr.save() props = applet.overlay.props try: if props.font_mode == 0: main_color = props.text_color.get_cairo_color() outline_color = [0.0] * 4 elif props.font_mode == 1: main_color = props.text_color.get_cairo_color() outline_color = props.text_outline_color.get_cairo_color() elif props.font_mode == 2: main_color = props.text_outline_color.get_cairo_color() outline_color = props.text_color.get_cairo_color() except: #Use the gtk colors style = applet.get_style() main_color = Color(style.fg[gtk.STATE_NORMAL], 65535).get_cairo_color() outline_color = Color(style.bg[gtk.STATE_NORMAL], 65535).get_cairo_color() #Get where the number should go x, y = self.settings['width'] / 2, self.settings['height'] / 2 font_size = 25.0 * (size / 200.0) six, eight = (6, 8) #Set up the text layout with pango layout = self.cr.create_layout() self.font_description.set_absolute_size(font_size * pango.SCALE) layout.set_font_description(self.font_description) layout.set_text(str(self.number)) w, h = layout.get_pixel_size() #Draw the text self.cr.move_to(self.settings['width'] / 2 - w / 2, self.settings['height'] / 2 - h / 2) self.cr.set_line_width(props.text_outline_width * self.settings['height'] / 120.0) self.cr.set_source_rgba(*outline_color) self.cr.set_line_join(cairo.LINE_JOIN_ROUND) self.cr.layout_path(layout) self.cr.stroke_preserve() self.cr.set_source_rgba(*main_color) self.cr.fill() self.cr.restore()
def make_button(self, key): button = ColorButton.with_color(Color.from_string('#' + self.applet.settings[key])) button.key = key button.use_alpha = True button.connect('color-set', self.color_set) return button
def make_button(self, key): button = ColorButton.with_color( Color.from_string('#' + self.applet.settings[key])) button.key = key button.use_alpha = True button.connect('color-set', self.color_set) return button
def draw(self, widget, event): w = self.allocation.width h = self.allocation.height gdk_color = self.get_style().text[gtk.STATE_NORMAL].to_string() color = Color.from_string(gdk_color + 'ffff') cr = self.window.cairo_create() cr.set_source_rgba(*color.get_cairo_color()) cr.set_dash((1, 0, 0, 1)) cr.rectangle(0.0, 0.0, w, h) cr.stroke()
def convert(self, s): color = Color.from_string('#' + s) return color.get_cairo_color()