def __init__(self, theme): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.theme = theme self.name = self.theme.get_name() self.hover_flag = False self.highlight_flag = False self.pixbufs = [] self.wallpaper_offset_x = 50 self.wallpaper_offset_y = 21 self.wallpaper_width = 100 self.wallpaper_height = 75 self.wallpaper_render_offset = 15 self.wallpaper_frame_size = 4 self.window_frame_padding_x = 40 self.window_frame_padding_y = 80 self.window_frame_width = 48 self.window_frame_height = 48 self.reflection_height = 23 self.title_padding_y = 10 self.title_size = CONTENT_FONT_SIZE self.hover_offset = 5 self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_fill_dcolor = app_theme.get_color("globalHoverFill") self.highlight_fill_color = "#7db7f2" self.highlight_stroke_color = "#396497" self.hover_response_rect = gtk.gdk.Rectangle( self.hover_offset, self.hover_offset, self.ITEM_WIDTH - self.hover_offset * 2, self.ITEM_HEIGHT - self.hover_offset * 2)
def render_item(self, cr, rect): if self.is_head: rect.y += self.head_height rect.height -= self.head_height if self.is_hover: text_color = "#000000" bg_color = app_theme.get_color("globalItemHover").get_color() if self.is_select: #text_color = "#FFFFFF" text_color = app_theme.get_color("globalTitleForeground").get_color() bg_color = app_theme.get_color("globalItemSelect").get_color() if not self.is_hover and not self.is_select: text_color = "#000000" bg_color = MODULE_BG_COLOR #cr.set_source_rgb(*color_hex_to_cairo(bg_color)) #cr.rectangle(rect.x, rect.y+self.title_height, rect.width-4, rect.height-2*self.title_height-1) #cr.fill() # draw account type text if self.is_myowner: text_color2 = app_theme.get_color("globalTitleForeground").get_color() x1 = rect.x y1 = rect.y draw_text(cr, _("My Account"), x1, y1, self.title_width, self.title_height, text_size=TITLE_FONT_SIZE, text_color=text_color2) x2 = rect.x y2 = rect.y + self.height + self.title_height + BETWEEN_SPACING - self.padding_y draw_text(cr, _("Other Accounts"), x2, y2, self.title_width, self.title_height, text_size=TITLE_FONT_SIZE, text_color=text_color2) self.render_icon(cr, gtk.gdk.Rectangle(rect.x+1, rect.y, 58, rect.height)) self.render_content(cr, gtk.gdk.Rectangle(rect.x+58, rect.y, rect.width-58, rect.height), text_color)
def render_background(self, cr, rect): if self.is_select: background_color = app_theme.get_color("globalItemSelect") else: if self.is_hover: background_color = app_theme.get_color("globalItemHover") else: background_color = app_theme.get_color("tooltipText") cr.set_source_rgb(*color_hex_to_cairo(background_color.get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.fill()
def render_background(self, cr, rect): if self.is_select: background_color = app_theme.get_color("globalItemSelect") else: if self.is_hover: background_color = app_theme.get_color("globalItemHover") else: background_color = app_theme.get_color("tooltipText") cr.set_source_rgb(*color_hex_to_cairo(background_color.get_color())) cr.rectangle(rect.x, rect.y, rect.width, rect.height) cr.fill()
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.status_box = StatusBox() self.scroll = ScrolledWindow() self.scroll.set_size_request(800, 432) self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.label_padding_x = 10 self.label_padding_y = 10 self.theme_box = gtk.VBox() self.user_theme_label = Label( _("My Themes"), text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground")) self.user_theme_view = UserThemeView(status_box=self.status_box) self.user_theme_scrolledwindow = self.user_theme_view.get_scrolled_window( ) self.system_theme_label = Label( _("System Themes"), text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground")) self.system_theme_view = SystemThemeView(status_box=self.status_box) self.system_theme_scrolledwindow = self.system_theme_view.get_scrolled_window( ) self.theme_box.pack_start(self.user_theme_label, False, False) self.theme_box.pack_start(get_separator(), False, False) self.theme_box.pack_start(self.user_theme_scrolledwindow, False, False) self.theme_box.pack_start(self.system_theme_label, False, False) self.theme_box.pack_start(get_separator(), False, False) self.theme_box.pack_start(self.system_theme_scrolledwindow, True, True) main_align = gtk.Alignment() main_align.set_padding(15, 0, 20, 20) main_align.set(1, 1, 1, 1) main_align.add(self.theme_box) self.scroll.add_child(main_align) main_align.connect("expose-event", self.expose_label_align) self.pack_start(self.scroll, False, False) self.pack_start(self.status_box)
def __init__(self, account_setting): super(IconEditPage, self).__init__(False) self.account_setting = account_setting self.error_label = Label("", label_width=350, enable_select=False, enable_double_click=False) left_align = gtk.Alignment() right_align = gtk.Alignment() left_align.set_padding(0, 0, 0, 60) #right_align.set_padding(0, 0, 0, 60) left_vbox = gtk.VBox(False) right_vbox = gtk.VBox(False) left_vbox.set_spacing(BETWEEN_SPACING) right_vbox.set_spacing(BETWEEN_SPACING) left_align.add(left_vbox) right_align.add(right_vbox) self.draw_area = IconEditArea() hseparator = HSeparator(app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) hseparator.set_size_request(-1, 10) left_vbox.pack_start(tools.make_align(Label(_("Clip"), app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, enable_select=False, enable_double_click=False)), False, False) left_vbox.pack_start(hseparator, False, False) left_vbox.pack_start(tools.make_align(self.draw_area, yalign=0.0, width=300, height=300)) self.thumbnail_large = gtk.Image() self.thumbnail_mid = gtk.Image() self.thumbnail_small = gtk.Image() self.thumbnail_large.set_size_request(150, 150) self.thumbnail_mid.set_size_request(48, 48) self.thumbnail_small.set_size_request(24, 24) hseparator = HSeparator(app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) hseparator.set_size_request(-1, 10) right_vbox.pack_start(tools.make_align(Label(_("Preview"), app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, enable_select=False, enable_double_click=False)), False, False) right_vbox.pack_start(hseparator, False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_large), False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_mid), False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_small), False, False) right_vbox.pack_start(tools.make_align(self.error_label, yalign=0.0)) self.pack_start(left_align, False, False) self.pack_start(right_align, False, False) self.connect("expose-event", self.draw_frame_border, left_align, right_align) self.draw_area.connect("pixbuf-changed", self.__on_pixbuf_changed_cb)
def render_text(self, cr, rect): if self.is_hover and not self.is_select: text_color = "#000000" bg_color = app_theme.get_color("globalItemHover").get_color() elif self.is_select: text_color = "#FFFFFF" bg_color = app_theme.get_color("globalItemSelect").get_color() else: text_color = "#000000" bg_color = MODULE_BG_COLOR cr.set_source_rgb(*color_hex_to_cairo(bg_color)) cr.rectangle(rect.x+1, rect.y, rect.width-2, rect.height-1) cr.paint() draw_text(cr, self.text, rect.x+50+self.padding_x, rect.y, rect.width, rect.height, text_color=text_color)
def text_view_changed(self, buf, button): '''text_view changed callback''' count = buf.get_char_count() if count <= self.MAX_CHAR: #self.input_tip_label.set_text(_("left")) self.input_num_label.set_text("%d" % (self.MAX_CHAR - count)) self.input_num_label.text_color = app_theme.get_color("left_char_num") if not button.is_sensitive(): button.set_sensitive(True) else: #self.input_tip_label.set_text(_("exceeds")) self.input_num_label.set_text("-%d" % (count - self.MAX_CHAR)) self.input_num_label.text_color = app_theme.get_color("left_char_num1") if button.is_sensitive(): button.set_sensitive(False)
def text_view_changed(self, buf, button): '''text_view changed callback''' count = buf.get_char_count() if count <= self.MAX_CHAR: #self.input_tip_label.set_text(_("left")) self.input_num_label.set_text("%d" % (self.MAX_CHAR - count)) self.input_num_label.text_color = app_theme.get_color("left_char_num") if not button.is_sensitive(): button.set_sensitive(True) else: #self.input_tip_label.set_text(_("exceeds")) self.input_num_label.set_text("-%d" % (count - self.MAX_CHAR)) self.input_num_label.text_color = app_theme.get_color("left_char_num1") if button.is_sensitive(): button.set_sensitive(False)
def expose_button(self, widget, event, font_size, label_dcolor): # Init. rect = widget.allocation image = self.pixbuf_normal.get_pixbuf() # Get pixbuf along with button's sate. if widget.state == gtk.STATE_NORMAL: image = self.pixbuf_normal.get_pixbuf() label_dcolor = app_theme.get_color('button_text_fg_normal') bg_dcolor = app_theme.get_alpha_color('button_bg_normal') elif widget.state == gtk.STATE_PRELIGHT: image = self.pixbuf_hover.get_pixbuf() label_dcolor = app_theme.get_color('button_text_fg_hover') bg_dcolor = app_theme.get_alpha_color('button_bg_hover') elif widget.state == gtk.STATE_ACTIVE: image = self.pixbuf_press.get_pixbuf() label_dcolor = app_theme.get_color('button_text_fg_press') bg_dcolor = app_theme.get_alpha_color('button_bg_press') # Draw button. cr = widget.window.cairo_create() draw_pixbuf(cr, image, rect.x + self.padding_edge, rect.y) # Draw font. if widget.state == gtk.STATE_INSENSITIVE: label_color = ui_theme.get_color("disable_text").get_color() else: label_color = label_dcolor.get_color() if self.button_label: draw_text(cr, self.button_label, rect.x + image.get_width() + self.padding_edge + self.padding_middle, rect.y, rect.width - image.get_width() - self.padding_middle - self.padding_edge*2, rect.height, font_size, label_color, alignment=pango.ALIGN_LEFT ) if self.draw_background: cr.set_source_rgba(*alpha_color_hex_to_cairo(bg_dcolor.get_color_info())) draw_round_rectangle(cr, rect.x, rect.y, rect.width, rect.height, rect.height/2) cr.fill() # Propagate expose to children. propagate_expose(widget, event) return True
def __init__(self, path, theme): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.image_path = path self.theme = theme self.pixbuf = None self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle( ITEM_PADDING_X, ITEM_PADDING_Y , self.wallpaper_width, self.wallpaper_height ) self.cross_normal_dpixbuf = app_theme.get_pixbuf("individuation/cross_normal.png") self.cross_gray_dpixbuf = app_theme.get_pixbuf("individuation/cross_gray.png") self.is_tick = False self.tick_area = None
def __init__(self, path, theme): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.image_path = path self.theme = theme self.pixbuf = None self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height) self.cross_normal_dpixbuf = app_theme.get_pixbuf( "individuation/cross_normal.png") self.cross_gray_dpixbuf = app_theme.get_pixbuf( "individuation/cross_gray.png") self.is_tick = False self.tick_area = None
def render_item_text(cr, content, rect, in_select, in_highlight, align=pango.ALIGN_LEFT, font_size=9, error=False): if in_highlight: color = app_theme.get_color("simpleSelectItem").get_color() else: # color = app_theme.get_color("labelText").get_color() color = "#707070" if error: color = "#ff0000" content = utils.xmlescape(content) draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.status_box = StatusBox() self.scroll = ScrolledWindow() self.scroll.set_size_request(800, 432) self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.label_padding_x = 10 self.label_padding_y = 10 self.theme_box = gtk.VBox() self.user_theme_label = Label(_("My Themes"), text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground")) self.user_theme_view = UserThemeView(status_box = self.status_box) self.user_theme_scrolledwindow = self.user_theme_view.get_scrolled_window() self.system_theme_label = Label(_("System Themes"), text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground")) self.system_theme_view = SystemThemeView(status_box = self.status_box) self.system_theme_scrolledwindow = self.system_theme_view.get_scrolled_window() self.theme_box.pack_start(self.user_theme_label, False, False) self.theme_box.pack_start(get_separator(), False, False) self.theme_box.pack_start(self.user_theme_scrolledwindow, False, False) self.theme_box.pack_start(self.system_theme_label, False, False) self.theme_box.pack_start(get_separator(), False, False) self.theme_box.pack_start(self.system_theme_scrolledwindow, True, True) main_align = gtk.Alignment() main_align.set_padding(15, 0, 20, 20) main_align.set(1, 1, 1, 1) main_align.add(self.theme_box) self.scroll.add_child(main_align) main_align.connect("expose-event", self.expose_label_align) self.pack_start(self.scroll, False, False) self.pack_start(self.status_box)
def draw_single_mask(cr, x, y, width, height, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) cr.set_source_rgb(*cairo_color) cr.rectangle(x, y, width, height) cr.fill()
def draw_single_mask(cr, x, y, width, height, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) cr.set_source_rgb(*cairo_color) cr.rectangle(x, y, width, height) cr.fill()
def __init__(self, module_info, start_callback): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.start_callback = start_callback self.module_info = module_info self.icon_padding_y = int(_("10")) self.name_padding_y = 8 self.hover_flag = False self.highlight_flag = False self.hover_offset = 1 self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_fill_dcolor = app_theme.get_color("globalHoverFill") self.hover_response_rect = gtk.gdk.Rectangle( self.hover_offset, self.hover_offset, ICON_SIZE - self.hover_offset * 2, ICON_SIZE - self.hover_offset * 2)
def draw_range(cr, x, y, width, height, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) with cairo_disable_antialias(cr): cr.set_line_width(1) cr.set_source_rgb(*cairo_color) cr.rectangle(x, y, width, height) cr.stroke()
def draw_range(cr, x, y, width, height, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) with cairo_disable_antialias(cr): cr.set_line_width(1) cr.set_source_rgb(*cairo_color) cr.rectangle(x, y, width, height) cr.stroke()
def render_text(self, cr, rect): if self.is_hover and not self.is_select: text_color = "#000000" bg_color = app_theme.get_color("globalItemHover").get_color() elif self.is_select: text_color = "#FFFFFF" bg_color = app_theme.get_color("globalItemSelect").get_color() else: text_color = "#000000" bg_color = MODULE_BG_COLOR cr.set_source_rgb(*color_hex_to_cairo(bg_color)) cr.rectangle(rect.x + 1, rect.y, rect.width - 2, rect.height - 1) cr.paint() draw_text(cr, self.text, rect.x + 50 + self.padding_x, rect.y, rect.width, rect.height, text_color=text_color)
def __init__(self, module_info, start_callback): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.start_callback = start_callback self.module_info = module_info self.icon_padding_y = int(_("10")) self.name_padding_y = 8 self.hover_flag = False self.highlight_flag = False self.hover_offset = 1 self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_fill_dcolor = app_theme.get_color("globalHoverFill") self.hover_response_rect = gtk.gdk.Rectangle( self.hover_offset, self.hover_offset, ICON_SIZE - self.hover_offset * 2, ICON_SIZE - self.hover_offset * 2)
def render_item_text(cr, content, rect, in_select, in_highlight, align=pango.ALIGN_LEFT, font_size=9, error=False): if in_highlight: color = app_theme.get_color("simpleSelectItem").get_color() else: # color = app_theme.get_color("labelText").get_color() color = "#707070" if error: color = "#ff0000" content = utils.xmlescape(content) draw_text(cr, content, rect.x, rect.y, rect.width, rect.height, font_size, color, alignment=align)
def draw_line(cr, start, end, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) with cairo_disable_antialias(cr): cr.set_line_width(1) cr.set_source_rgb(*cairo_color) cr.move_to(*start) cr.line_to(*end) cr.stroke()
def draw_line(cr, start, end, color_name): if color_name.startswith("#"): color = color_name else: color = app_theme.get_color(color_name).get_color() cairo_color = color_hex_to_cairo(color) with cairo_disable_antialias(cr): cr.set_line_width(1) cr.set_source_rgb(*cairo_color) cr.move_to(*start) cr.rel_line_to(*end) cr.stroke()
def __setup_title_label(self, text="", text_color=app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, text_x_align=ALIGN_START, label_width=180): return Label(text = text, text_color = text_color, text_size = text_size, text_x_align = text_x_align, label_width = label_width, enable_select = False, enable_double_click = False)
def __setup_title_label(self, text="", text_color=app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, text_x_align=ALIGN_START, label_width=180): return Label(text = text, text_color = text_color, text_size = text_size, text_x_align = text_x_align, label_width = label_width, enable_select = False, enable_double_click = False)
def __init__(self, path, readonly, theme, background_settings=None): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.background_settings = background_settings self.image_path = path self.readonly = readonly self.theme = theme self.pixbuf = None self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height) self.tick_normal_dpixbuf = app_theme.get_pixbuf( "individuation/tick_normal.png") self.tick_gray_dpixbuf = app_theme.get_pixbuf( "individuation/tick_gray.png") self.cross_normal_dpixbuf = app_theme.get_pixbuf( "individuation/cross_normal.png") self.cross_gray_dpixbuf = app_theme.get_pixbuf( "individuation/cross_gray.png") if readonly: self.is_tick = self.theme.get_system_wallpaper_status(path) else: if self.theme == None: self.is_tick = False else: self.is_tick = self.theme.get_user_wallpaper_status(path) self.tick_area = None self.__is_double_click = False
def __init__(self, image_object, download_dir=None): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) MissionThread.__init__(self) self.image_path = None self.is_loaded = False self.is_downloaded = False self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.padding_x = 8 self.width = self.wallpaper_width + self.padding_x * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.image_object = image_object self.download_dir = download_dir self.pixbuf = None self.create_cache_pixbuf() self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle(self.padding_x, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height) self.tick_normal_dpixbuf = app_theme.get_pixbuf( "individuation/tick_normal.png") self.tick_gray_dpixbuf = app_theme.get_pixbuf( "individuation/tick_gray.png") self.is_tick = False self.loop_dpixbuf = app_theme.get_pixbuf("individuation/loop.png") self.is_loop = False event_manager.add_callback("download-start", self.__on_download_start) event_manager.add_callback("download-finish", self.__on_download_finish) event_manager.add_callback("delete-downloaded-wallpaper", self.__on_delete_downloaded_wallpaper)
def __init__(self, path, readonly, theme, background_settings=None): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.background_settings = background_settings self.image_path = path self.readonly = readonly self.theme = theme self.pixbuf = None self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle( ITEM_PADDING_X, ITEM_PADDING_Y , self.wallpaper_width, self.wallpaper_height ) self.tick_normal_dpixbuf = app_theme.get_pixbuf("individuation/tick_normal.png") self.tick_gray_dpixbuf = app_theme.get_pixbuf("individuation/tick_gray.png") self.cross_normal_dpixbuf = app_theme.get_pixbuf("individuation/cross_normal.png") self.cross_gray_dpixbuf = app_theme.get_pixbuf("individuation/cross_gray.png") if readonly: self.is_tick = self.theme.get_system_wallpaper_status(path) else: if self.theme == None: self.is_tick = False else: self.is_tick = self.theme.get_user_wallpaper_status(path) self.tick_area = None self.__is_double_click = False
def __init__(self, pixbuf_normal, pixbuf_hover, pixbuf_press, button_label=None, label_color=None, padding_middle=0, padding_edge=0, font_size=DEFAULT_FONT_SIZE, draw_background=False, ): gtk.Button.__init__(self) self.pixbuf_normal = pixbuf_normal self.pixbuf_hover = pixbuf_hover self.pixbuf_press = pixbuf_press self.font_size = font_size self.padding_edge = padding_edge self.padding_middle = padding_middle self.button_label = button_label self.draw_background = draw_background if not label_color: label_dcolor = app_theme.get_color("button_text_fg_normal") self.button_press_flag = False # Init request size. label_width = 0 button_width = pixbuf_normal.get_pixbuf().get_width() button_height = pixbuf_normal.get_pixbuf().get_height() if button_label: label_width = get_content_size(button_label, self.font_size)[0] self.set_size_request(button_width + label_width + padding_edge * 2 + padding_middle, button_height) self.connect("button-press-event", self.press_button) self.connect("button-release-event", self.release_button) # Expose button. self.connect("expose-event", lambda w, e : self.expose_button( w, e, self.font_size, label_dcolor))
def __init__(self, image_path): super(WallpaperItem, self).__init__() self.image_path = image_path self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.pixbuf = None self.is_hover = False self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height)
def __init__(self, image_path): super(WallpaperItem, self).__init__() self.image_path = image_path self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.pixbuf = None self.is_hover = False self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle( ITEM_PADDING_X, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height )
def __init__(self, image_object, download_dir=None): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) MissionThread.__init__(self) self.image_path = None self.is_loaded = False self.is_downloaded = False self.hover_flag = False self.highlight_flag = False self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.padding_x = 8 self.width = self.wallpaper_width + self.padding_x * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.image_object = image_object self.download_dir = download_dir self.pixbuf = None self.create_cache_pixbuf() self.is_hover = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle( self.padding_x, ITEM_PADDING_Y , self.wallpaper_width, self.wallpaper_height ) self.tick_normal_dpixbuf = app_theme.get_pixbuf("individuation/tick_normal.png") self.tick_gray_dpixbuf = app_theme.get_pixbuf("individuation/tick_gray.png") self.is_tick = False self.loop_dpixbuf = app_theme.get_pixbuf("individuation/loop.png") self.is_loop = False event_manager.add_callback("download-start", self.__on_download_start) event_manager.add_callback("download-finish", self.__on_download_finish) event_manager.add_callback("delete-downloaded-wallpaper", self.__on_delete_downloaded_wallpaper)
def __init__(self): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.hover_flag = False self.highlight_flag = False self.image_path = "invalid" self.is_add = True self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.is_tick = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X, ITEM_PADDING_Y, self.wallpaper_width, self.wallpaper_height) self.theme = None
def __init__(self): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' gobject.GObject.__init__(self) self.hover_flag = False self.highlight_flag = False self.image_path = "invalid" self.is_add = True self.wallpaper_width = SMALL_SIZE["x"] self.wallpaper_height = SMALL_SIZE["y"] self.width = self.wallpaper_width + ITEM_PADDING_X * 2 self.height = self.wallpaper_height + ITEM_PADDING_Y * 2 self.is_hover = False self.is_tick = False self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke") self.hover_response_rect = gtk.gdk.Rectangle( ITEM_PADDING_X, ITEM_PADDING_Y , self.wallpaper_width, self.wallpaper_height ) self.theme = None
def __init__(self, account_setting): super(IconEditPage, self).__init__(False) self.account_setting = account_setting self.error_label = Label("", label_width=350, enable_select=False, enable_double_click=False) left_align = gtk.Alignment() right_align = gtk.Alignment() left_align.set_padding(0, 0, 0, 60) #right_align.set_padding(0, 0, 0, 60) left_vbox = gtk.VBox(False) right_vbox = gtk.VBox(False) left_vbox.set_spacing(BETWEEN_SPACING) right_vbox.set_spacing(BETWEEN_SPACING) left_align.add(left_vbox) right_align.add(right_vbox) self.draw_area = IconEditArea() hseparator = HSeparator( app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) hseparator.set_size_request(-1, 10) left_vbox.pack_start( tools.make_align( Label(_("Clip"), app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, enable_select=False, enable_double_click=False)), False, False) left_vbox.pack_start(hseparator, False, False) left_vbox.pack_start( tools.make_align(self.draw_area, yalign=0.0, width=300, height=300)) self.thumbnail_large = gtk.Image() self.thumbnail_mid = gtk.Image() self.thumbnail_small = gtk.Image() self.thumbnail_large.set_size_request(150, 150) self.thumbnail_mid.set_size_request(48, 48) self.thumbnail_small.set_size_request(24, 24) hseparator = HSeparator( app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) hseparator.set_size_request(-1, 10) right_vbox.pack_start( tools.make_align( Label(_("Preview"), app_theme.get_color("globalTitleForeground"), text_size=TITLE_FONT_SIZE, enable_select=False, enable_double_click=False)), False, False) right_vbox.pack_start(hseparator, False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_large), False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_mid), False, False) right_vbox.pack_start(tools.make_align(self.thumbnail_small), False, False) right_vbox.pack_start(tools.make_align(self.error_label, yalign=0.0)) self.pack_start(left_align, False, False) self.pack_start(right_align, False, False) self.connect("expose-event", self.draw_frame_border, left_align, right_align) self.draw_area.connect("pixbuf-changed", self.__on_pixbuf_changed_cb)
def get_user_info(self, weibo): '''get weibo user info''' info = weibo.get_user_name() gtk.gdk.threads_enter() #self.get_user_error_text = "" weibo_hbox = weibo.get_box() hbox = gtk.HBox(False) vbox = gtk.VBox(False) weibo_hbox.pack_start(vbox, False, False) vbox.pack_start(hbox) #print weibo.t_type, info if info: self.is_get_user_info[weibo] = 1 label = Label(text=info, label_width=70, enable_select=False) check = CheckButton() #check = gtk.CheckButton() check.connect("toggled", self.weibo_check_toggle, weibo) check.set_active(True) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to switch user")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) hbox.pack_start(label, False, False) else: self.is_get_user_info[weibo] = 0 check = CheckButton() #check = gtk.CheckButton() check.set_sensitive(False) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to login")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) # curl time out info_error = weibo.get_curl_error() if info_error: #self.get_user_error_text += "%s:%s." % (weibo.t_type, _(info_error)) hbox.pack_start( Label(text="(%s)" % _(info_error), label_width=70, enable_select=False, text_color=app_theme.get_color("left_char_num1")), False, False) button.connect("clicked", self.weibo_login, weibo) self.__weibo_check_button_list.append(check) self.__weibo_image_button_list.append(button) gtk.gdk.threads_leave() return weibo_hbox
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_szie = CONTENT_FONT_SIZE self.label_widgets["speaker"] = Label(_("Speaker"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["microphone"] = Label(_("Microphone"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["left"] = Label(_("Left"), enable_select=False, enable_double_click=False) self.label_widgets["right"] = Label(_("Right"), enable_select=False, enable_double_click=False) self.label_widgets["speaker_port"] = Label(_("Output Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_volume"] = Label(_("Output Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_balance"] = Label(_("Balance"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_port"] = Label(_("Input Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_volume"] = Label(_("Input Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) ##################################### # image init self.image_widgets["balance"] = ImageBox(app_theme.get_pixbuf("%s/balance.png" % MODULE_NAME)) self.image_widgets["speaker"] = ImageBox(app_theme.get_pixbuf("%s/speaker-3.png" % MODULE_NAME)) self.image_widgets["microphone"] = ImageBox(app_theme.get_pixbuf("%s/microphone.png" % MODULE_NAME)) self.image_widgets["device"] = app_theme.get_pixbuf("%s/device.png" % MODULE_NAME) # button init self.button_widgets["balance"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["speaker"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["microphone"] = SwitchButton( inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png")) self.button_widgets["advanced"] = Button(_("Advanced")) self.button_widgets["speaker_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) self.button_widgets["microphone_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["slider"] = HSlider() self.container_widgets["swin"] = ScrolledWindow() self.container_widgets["advance_set_tab_box"] = TabBox() self.container_widgets["advance_set_tab_box"].draw_title_background = self.draw_tab_title_background self.container_widgets["main_hbox"] = gtk.HBox(False) self.container_widgets["left_vbox"] = gtk.VBox(False) self.container_widgets["right_vbox"] = gtk.VBox(False) self.container_widgets["balance_hbox"] = gtk.HBox(False) self.container_widgets["speaker_main_vbox"] = gtk.VBox(False) # speaker self.container_widgets["speaker_label_hbox"] = gtk.HBox(False) self.container_widgets["speaker_table"] = gtk.Table(4, 2) self.container_widgets["microphone_main_vbox"] = gtk.VBox(False) # microphone self.container_widgets["microphone_label_hbox"] = gtk.HBox(False) self.container_widgets["microphone_table"] = gtk.Table(4, 2) # alignment init self.alignment_widgets["slider"] = gtk.Alignment() self.alignment_widgets["main_hbox"] = gtk.Alignment() self.alignment_widgets["advance_set_tab_box"] = gtk.Alignment() self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["speaker_label"] = gtk.Alignment() # speaker self.alignment_widgets["speaker_set"] = gtk.Alignment() self.alignment_widgets["microphone_label"] = gtk.Alignment() # microphone self.alignment_widgets["microphone_set"] = gtk.Alignment() # adjust init volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE self.adjust_widgets["balance"] = gtk.Adjustment(0, -1.0, 1.0, 0.1, 0.2) self.adjust_widgets["speaker"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) self.adjust_widgets["microphone"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) # scale init self.scale_widgets["balance"] = HScalebar(value_min=-1, value_max=1, gray_progress=True) self.scale_widgets["balance"].set_magnetic_values([(0, 0.1), (1, 0.1), (2, 0.1)]) self.scale_widgets["speaker"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["speaker"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) self.scale_widgets["microphone"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["microphone"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) ################################### # advance set self.container_widgets["advance_input_box"] = gtk.VBox(False) self.container_widgets["advance_output_box"] = gtk.VBox(False) self.container_widgets["advance_hardware_box"] = gtk.VBox(False) self.alignment_widgets["advance_input_box"] = gtk.Alignment() self.alignment_widgets["advance_output_box"] = gtk.Alignment() self.alignment_widgets["advance_hardware_box"] = gtk.Alignment() # self.label_widgets["ad_output"] = Label(_("Choose a device for sound output:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_input"] = Label(_("Choose a device for sound input:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_hardware"] = Label(_("Choose a device to configure:"), enable_select=False, enable_double_click=False) # self.container_widgets["ad_output"] = gtk.VBox(False) self.container_widgets["ad_input"] = gtk.VBox(False) self.container_widgets["ad_hardware"] = gtk.VBox(False) # self.view_widgets["ad_output"] = TreeView() self.view_widgets["ad_input"] = TreeView() self.view_widgets["ad_hardware"] = TreeView()
def __init__(self, inactive_normal_dpixbuf, active_normal_dpixbuf, inactive_hover_dpixbuf=None, active_hover_dpixbuf=None, inactive_press_dpixbuf=None, active_press_dpixbuf=None, inactive_disable_dpixbuf=None, active_disable_dpixbuf=None, active_button_label=None, inactive_button_label=None, label_color=None, padding_middle=0, padding_edge=0, more_width=0, font_size=DEFAULT_FONT_SIZE, draw_background=False, ): gtk.ToggleButton.__init__(self) self.font_size = font_size if not label_color: label_dcolor = app_theme.get_color("button_text_fg_normal") self.button_press_flag = False self.draw_background = draw_background self.inactive_pixbuf_group = (inactive_normal_dpixbuf, inactive_hover_dpixbuf, inactive_press_dpixbuf, inactive_disable_dpixbuf) self.active_pixbuf_group = (active_normal_dpixbuf, active_hover_dpixbuf, active_press_dpixbuf, active_disable_dpixbuf) # Init request size. label_width = 0 self.padding_middle = padding_middle self.padding_edge = padding_edge self.more_width = more_width self.active_button_label = active_button_label self.inactive_button_label = inactive_button_label if active_button_label and not inactive_button_label: self.inactive_button_label = self.active_button_label self.button_width = inactive_normal_dpixbuf.get_pixbuf().get_width() self.button_height = inactive_normal_dpixbuf.get_pixbuf().get_height() if self.active_button_label: label_width = get_content_size(self.active_button_label, self.font_size)[0] self.set_size_request(self.button_width + label_width + self.padding_middle + self.padding_edge*2 + more_width, self.button_height) self.connect("button-press-event", self.press_toggle_button) self.connect("button-release-event", self.release_toggle_button) # Expose button. self.connect("expose-event", lambda w, e : self.expose_toggle_button( w, e, self.font_size, label_dcolor))
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_size = CONTENT_FONT_SIZE # image init self.image_widgets["custom"] = ImageBox(app_theme.get_pixbuf( "%s/pad_l%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["speed"] = ImageBox(app_theme.get_pixbuf( "%s/pointer%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double"] = ImageBox(app_theme.get_pixbuf( "%s/double-click%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["drag"] = ImageBox(app_theme.get_pixbuf( "%s/drag%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double_test_1"] = app_theme.get_pixbuf( "%s/smiley00%s.png" % (MODULE_NAME, self.has_touchpad_icon)) self.image_widgets["double_test_2"] = app_theme.get_pixbuf( "%s/smiley01.png" % (MODULE_NAME)) # label init self.label_widgets["custom"] = Label(_("Custom"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["pointer_speed"] = Label(_("Pointer Speed"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["acceleration"] = Label(_("Acceleration"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["sensitivity"] = Label(_("Sensitivity"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_click"] = Label(_("Double-click"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["click_rate"] = Label(_("Frequency"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_test"] = Label(_("Double-click on the smiley face to test your settings."), label_width=HSCALEBAR_WIDTH, wrap_width=HSCALEBAR_WIDTH, enable_select=False, enable_double_click=False) self.label_widgets["drag_drop"] = Label(_("Drag and Drop"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["drag_threshold"] = Label(_("Drag threshold"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["relevant"] = Label(_("Relevant Settings"), text_size=title_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) # button init self.button_widgets["right_hand_radio"] = RadioButton( _("Right-handed"), padding_x=10) self.button_widgets["left_hand_radio"] = RadioButton(_("Left-handed"), padding_x=10) self.button_widgets["double_test"] = gtk.EventBox() # relevant settings button self.button_widgets["keyboard_setting"] = Label("<u>%s</u>" % _("Keyboard Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["mouse_setting"] = Label("<u>%s</u>" % _("Mouse Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["set_to_default"] = Button(_("Reset")) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["main_swindow"] = ScrolledWindow() self.container_widgets["main_hbox"] = gtk.HBox(False) self.container_widgets["left_vbox"] = gtk.VBox(False) self.container_widgets["right_vbox"] = gtk.VBox(False) self.container_widgets["custom_main_vbox"] = gtk.VBox(False) # custom self.container_widgets["custom_label_hbox"] = gtk.HBox(False) self.container_widgets["custom_button_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_main_vbox"] = gtk.VBox(False) # pointer speed self.container_widgets["pointer_speed_label_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_table"] = gtk.Table(2, 4, False) self.container_widgets["double_click_main_vbox"] = gtk.VBox(False) # double click self.container_widgets["double_click_label_hbox"] = gtk.HBox(False) self.container_widgets["double_click_table"] = gtk.Table(2, 4, False) self.container_widgets["drag_threshold_main_vbox"] = gtk.VBox(False) # mouse wheel self.container_widgets["drag_threshold_label_hbox"] = gtk.HBox(False) self.container_widgets["drag_threshold_table"] = gtk.Table(1, 4, False) # alignment init self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["custom_label"] = gtk.Alignment() # custom self.alignment_widgets["custom_button"] = gtk.Alignment() self.alignment_widgets["pointer_speed_label"] = gtk.Alignment() # pointer speed self.alignment_widgets["pointer_speed_table"] = gtk.Alignment() self.alignment_widgets["double_click_label"] = gtk.Alignment() # double click self.alignment_widgets["double_click_table"] = gtk.Alignment() self.alignment_widgets["drag_threshold_label"] = gtk.Alignment() # mouse wheel self.alignment_widgets["drag_threshold_table"] = gtk.Alignment() self.alignment_widgets["keyboard_setting"] = gtk.Alignment() self.alignment_widgets["mouse_setting"] = gtk.Alignment() # adjust init self.adjust_widgets["pointer_speed_accel"] = gtk.Adjustment(1.0, 1.0, 10.0, 1, 2) self.adjust_widgets["pointer_speed_sensitiv"] = gtk.Adjustment(1, 1, 10, 1, 2) self.adjust_widgets["double_click_rate"] = gtk.Adjustment(100, 100, 1000, 100, 200) self.adjust_widgets["drag_threshold_time"] = gtk.Adjustment(1, 1, 10, 1, 2) # scale init self.scale_widgets["pointer_speed_accel"] = HScalebar(value_min=1.0, value_max=10.0) self.scale_widgets["pointer_speed_sensitiv"] = HScalebar(value_min=1, value_max=10) self.scale_widgets["double_click_rate"] = HScalebar(value_min=100, value_max=1000) self.scale_widgets["drag_threshold_time"] = HScalebar(value_min=1, value_max=10)
def init_share_box(self): '''get weibo info, and create button''' self.to_share_weibo = {} self.to_share_weibo_res = {} self.deepin_info = {} self.is_get_user_info = {} self.__weibo_check_button_list = [] self.__weibo_image_button_list = [] # create Thumbnail if exists(self.upload_image): pixbuf = gtk.gdk.pixbuf_new_from_file(self.upload_image) pix_w = pixbuf.get_width() pix_h = pixbuf.get_height() if pix_w > pix_h: pix_s_w = self.thumb_width pix_s_h = int(pix_h / (float(pix_w) / self.thumb_width)) else: pix_s_h = self.thumb_height pix_s_w = int(pix_w / (float(pix_h) / self.thumb_height)) pixbuf = pixbuf.scale_simple(pix_s_w, pix_s_h, gtk.gdk.INTERP_TILES) thumb = gtk.image_new_from_pixbuf(pixbuf) else: thumb = gtk.Image() thumb.set_size_request(self.thumb_width, self.thumb_height) # weibo context input text_box = gtk.HBox(False, 2) text_vbox = gtk.VBox(False, 2) text_bg_vbox = gtk.VBox(False) text_bg_align = gtk.Alignment() text_bg_align.set(0.5, 0.5, 0, 0) text_bg_align.set_padding(5, 5, 16, 5) text_bg_align.connect("expose-event", self.text_view_bg_expose) text_scrolled_win = ScrolledWindow() text_scrolled_win.set_size_request(340, 157) text_view = gtk.TextView() text_view.set_left_margin(10) text_view.set_right_margin(10) text_view.set_pixels_above_lines(5) text_view.set_pixels_below_lines(5) text_view.set_wrap_mode(gtk.WRAP_WORD | gtk.WRAP_CHAR) text_view.connect("expose-event", self.text_view_expose) buf = text_view.get_buffer() text_scrolled_win.add(text_view) text_bg_vbox.pack_start(text_scrolled_win) text_bg_align.add(text_bg_vbox) text_align = gtk.Alignment() text_align.set(0.5, 0.5, 0, 0) text_align.set_padding(25, 30, 10, 10) text_box.pack_start(thumb, False, False, 10) text_box.pack_start(text_bg_align) text_vbox.pack_start(text_box, False, False, 10) text_align.add(text_vbox) #tmp_align = gtk.Alignment() #tmp_align.set(0.5, 0, 0, 1) #self.share_box.pack_start(tmp_align, False, False) self.share_box.pack_start(text_align, False, False) # dialog button box left_box = self.window.left_button_box right_box = self.window.right_button_box # input tip label self.input_num_label = Label("%d" % self.MAX_CHAR, text_size=16, text_x_align=pango.ALIGN_CENTER, label_width=50, enable_select=False) self.input_num_label.text_color = app_theme.get_color("left_char_num") # login box #weibo_box = gtk.HBox(False, 1) #weibo_box.set_size_request(-1, 50) weibo_box_list = [] self.loading_label = Label("%s..." % _("Loading"), text_size=12, label_width=70, enable_select=False) weibo_box_list.append(self.loading_label) for weibo in self.__weibo_list: box = gtk.HBox(False, 2) weibo.set_box(box) weibo_box_list.append(box) left_box.set_buttons(weibo_box_list) # share button button = Button(_("Share")) #button.set_size_request(75, 25) button.connect("clicked", self.share_button_clicked, text_view) buf.connect("changed", self.text_view_changed, button) # check char num tmp_vbox = gtk.VBox(False) tmp_align = gtk.Alignment() tmp_align.set(0.5, 0.5, 0, 0) tmp_vbox.pack_start(button, False, False) #tmp_vbox.pack_start(tmp_align) tmp_align.add(tmp_vbox) right_box.set_buttons([self.input_num_label, tmp_align]) # at first, set widget insensitive button.set_sensitive(False) text_view.set_editable(False) t = threading.Thread(target=self.init_user_info_thread, args=(button, text_view)) t.setDaemon(True) t.start()
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.wait_duration_items = [("1 %s" % _("Minute"), 60), ("5 %s" % _("Minutes"), 300), ("10 %s" % _("Minutes"), 600), ("15 %s" % _("Minutes"), 900), ("30 %s" % _("Minutes"), 1800), ("1 %s" % _("Hour"), 3600), (_("Never"), 0)] self.power_manager = PowerManager() self.power_manager.power_settings.connect( "changed", self.__power_settings_changed) self.power_manage_items = [ (_("Do nothing"), self.power_manager.nothing), (_("Suspend"), self.power_manager.suspend), (_("Shut down"), self.power_manager.shutdown) ] self.power_plan_items = [(_("Balanced"), self.power_manager.balance), (_("Power saver"), self.power_manager.saving), (_("High performance"), self.power_manager.high_performance), (_("Custom"), self.power_manager.customized)] ''' button power config ''' self.button_power_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/button_power.png"), _("Power Button Settings"), TEXT_WINDOW_TOP_PADDING, TEXT_WINDOW_LEFT_PADDING) ''' press button power ''' self.press_button_power_align = self.__setup_align() self.press_button_power_box = gtk.HBox(spacing=WIDGET_SPACING) self.press_button_power_label = self.__setup_label( _("When I press the power button")) self.press_button_power_combo = self.__setup_combo( self.power_manage_items) self.press_button_power_combo.set_select_index( self.power_manager.get_press_button_power(self.power_manage_items)) self.press_button_power_combo.connect("item-selected", self.__combo_item_selected, "press_button_power") self.__widget_pack_start( self.press_button_power_box, [self.press_button_power_label, self.press_button_power_combo]) self.press_button_power_align.add(self.press_button_power_box) ''' close notebook cover ''' self.close_notebook_cover_align = self.__setup_align() self.close_notebook_cover_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_notebook_cover_label = self.__setup_label( _("When I close the lid")) self.close_notebook_cover_combo = self.__setup_combo( self.power_manage_items) self.close_notebook_cover_combo.set_select_index( self.power_manager.get_close_notebook_cover( self.power_manage_items)) self.close_notebook_cover_combo.connect("item-selected", self.__combo_item_selected, "close_notebook_cover") self.__widget_pack_start( self.close_notebook_cover_box, [self.close_notebook_cover_label, self.close_notebook_cover_combo]) self.close_notebook_cover_align.add(self.close_notebook_cover_box) self.close_notebook_cover_align.set_child_visible(is_laptop()) ''' power save config ''' self.power_save_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/power_save.png"), _("Power Saving Settings")) ''' power plan ''' self.power_plan_align = self.__setup_align() self.power_plan_box = gtk.HBox(spacing=WIDGET_SPACING) self.power_plan_label = self.__setup_label(_("Power Plan")) self.power_plan_combo = self.__setup_combo(self.power_plan_items) self.power_plan_combo.set_select_index( self.power_manager.get_current_plan()) self.power_plan_combo.connect("item-selected", self.__combo_item_selected, "power_plan") self.__widget_pack_start( self.power_plan_box, [self.power_plan_label, self.power_plan_combo]) self.power_plan_align.add(self.power_plan_box) ''' close monitor ''' self.close_monitor_align = self.__setup_align() self.close_monitor_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_monitor_label = self.__setup_label(_("Turn off monitor")) self.close_monitor_combo = self.__setup_combo(self.wait_duration_items) self.close_monitor_combo.set_select_index(0) self.close_monitor_combo.connect("item-selected", self.__combo_item_selected, "close_monitor") self.__widget_pack_start( self.close_monitor_box, [self.close_monitor_label, self.close_monitor_combo]) self.close_monitor_align.add(self.close_monitor_box) ''' suspend ''' self.suspend_align = self.__setup_align() self.suspend_box = gtk.HBox(spacing=WIDGET_SPACING) self.suspend_label = self.__setup_label(_("Suspend")) self.suspend_combo = self.__setup_combo(self.wait_duration_items) self.suspend_combo.set_select_index(0) self.suspend_combo.connect("item-selected", self.__combo_item_selected, "suspend") self.__widget_pack_start(self.suspend_box, [self.suspend_label, self.suspend_combo]) self.suspend_align.add(self.suspend_box) self.__on_power_plan_customized() ''' percentage ''' self.percentage_align = self.__setup_align() self.percentage_box = gtk.HBox(spacing=WIDGET_SPACING) self.percentage_label = self.__setup_label( _("Battery power remaining")) self.percentage_progressbar_align = self.__setup_align(padding_left=0, padding_top=0) self.percentage_progressbar = self.__setup_progressbar( self.power_manager.power_settings.get_double("percentage")) self.percentage_progressbar_align.add(self.percentage_progressbar) self.__widget_pack_start( self.percentage_box, [self.percentage_label, self.percentage_progressbar_align]) self.percentage_align.add(self.percentage_box) self.percentage_align.set_child_visible(is_laptop()) ''' wakeup password ''' self.wakeup_password_align = self.__setup_align( padding_top=BETWEEN_SPACING, padding_left=TEXT_WINDOW_LEFT_PADDING) self.wakeup_password_box = gtk.HBox(spacing=WIDGET_SPACING) self.wakeup_password_image = ImageBox( app_theme.get_pixbuf("lock/lock.png")) self.wakeup_password_label = self.__setup_label( _("Require password when computer wakes"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.wakeup_password_label.set_sensitive(self.power_manager.get_wakeup_password()) self.wakeup_password_toggle_align = self.__setup_align(padding_top=2, padding_left=88) self.wakeup_password_toggle = self.__setup_toggle() self.wakeup_password_toggle.set_active( self.power_manager.get_wakeup_password()) self.wakeup_password_toggle.connect("toggled", self.__toggled, "wakeup_password") self.wakeup_password_toggle_align.add(self.wakeup_password_toggle) self.__widget_pack_start(self.wakeup_password_box, [ self.wakeup_password_image, self.wakeup_password_label, self.wakeup_password_toggle_align ]) self.wakeup_password_align.add(self.wakeup_password_box) ''' tray battery status ''' self.tray_battery_status_align = self.__setup_align( padding_top=BETWEEN_SPACING, padding_left=TEXT_WINDOW_LEFT_PADDING) self.tray_battery_status_box = gtk.HBox(spacing=WIDGET_SPACING) self.tray_battery_image = ImageBox( app_theme.get_pixbuf("power/tray_battery.png")) self.tray_battery_status_label = self.__setup_label( _("Always show icon in the tray"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.tray_battery_status_label.set_sensitive(self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle_align = self.__setup_align( padding_top=2, padding_left=88) self.tray_battery_status_toggle = self.__setup_toggle() self.tray_battery_status_toggle.set_active( self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle.connect("toggled", self.__toggled, "tray_battery_status") self.tray_battery_status_toggle_align.add( self.tray_battery_status_toggle) self.__widget_pack_start(self.tray_battery_status_box, [ self.tray_battery_image, self.tray_battery_status_label, self.tray_battery_status_toggle_align ]) self.tray_battery_status_align.add(self.tray_battery_status_box) self.tray_battery_status_align.set_child_visible(is_laptop()) ''' this->gtk.VBox pack_start ''' self.__widget_pack_start(self, [ self.button_power_config_align, self.press_button_power_align, self.close_notebook_cover_align, self.power_save_config_align, self.power_plan_align, self.close_monitor_align, self.suspend_align, self.percentage_align, self.wakeup_password_align, self.tray_battery_status_align, ]) self.connect("expose-event", self.__expose) self.__send_message("status", ("power", "")) self.__send_message("status", ("power", "show_reset"))
def get_user_info(self, weibo): '''get weibo user info''' info = weibo.get_user_name() gtk.gdk.threads_enter() #self.get_user_error_text = "" weibo_hbox = weibo.get_box() hbox = gtk.HBox(False) vbox = gtk.VBox(False) weibo_hbox.pack_start(vbox, False, False) vbox.pack_start(hbox) #print weibo.t_type, info if info: self.is_get_user_info[weibo] = 1 label = Label(text=info, label_width=70, enable_select=False) check = CheckButton() #check = gtk.CheckButton() check.connect("toggled", self.weibo_check_toggle, weibo) check.set_active(True) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png"), app_theme.get_pixbuf("share/" + weibo.t_type + ".png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to switch user")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) hbox.pack_start(label, False, False) else: self.is_get_user_info[weibo] = 0 check = CheckButton() #check = gtk.CheckButton() check.set_sensitive(False) check_vbox = gtk.VBox(False) check_align = gtk.Alignment(0.5, 0.5, 0, 0) check_align.add(check_vbox) check_vbox.pack_start(check, False, False) button = ImageButton( app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png"), app_theme.get_pixbuf("share/" + weibo.t_type + "_no.png")) utils.set_clickable_cursor(button) button.connect("enter-notify-event", self.show_tooltip, _("Click to login")) hbox.pack_start(check_align, False, False) hbox.pack_start(button, False, False, 5) # curl time out info_error = weibo.get_curl_error() if info_error: #self.get_user_error_text += "%s:%s." % (weibo.t_type, _(info_error)) hbox.pack_start( Label(text="(%s)" % _(info_error), label_width=70,enable_select=False, text_color = app_theme.get_color("left_char_num1")), False, False) button.connect("clicked", self.weibo_login, weibo) self.__weibo_check_button_list.append(check) self.__weibo_image_button_list.append(button) gtk.gdk.threads_leave() return weibo_hbox
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_size = CONTENT_FONT_SIZE # image init self.image_widgets["custom"] = ImageBox( app_theme.get_pixbuf("%s/pad_l%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["speed"] = ImageBox( app_theme.get_pixbuf("%s/pointer%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double"] = ImageBox( app_theme.get_pixbuf("%s/double-click%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["drag"] = ImageBox( app_theme.get_pixbuf("%s/drag%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double_test_1"] = app_theme.get_pixbuf( "%s/smiley00%s.png" % (MODULE_NAME, self.has_touchpad_icon)) self.image_widgets["double_test_2"] = app_theme.get_pixbuf( "%s/smiley01.png" % (MODULE_NAME)) # label init self.label_widgets["custom"] = Label( _("Custom"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["pointer_speed"] = Label( _("Pointer Speed"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["acceleration"] = Label( _("Acceleration"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["sensitivity"] = Label( _("Sensitivity"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_click"] = Label( _("Double-click"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["click_rate"] = Label( _("Frequency"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_test"] = Label( _("Double-click on the smiley face to test your settings."), label_width=HSCALEBAR_WIDTH, wrap_width=HSCALEBAR_WIDTH, enable_select=False, enable_double_click=False) self.label_widgets["drag_drop"] = Label( _("Drag and Drop"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["drag_threshold"] = Label( _("Drag threshold"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["relevant"] = Label(_("Relevant Settings"), text_size=title_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) # button init self.button_widgets["right_hand_radio"] = RadioButton( _("Right-handed"), padding_x=10) self.button_widgets["left_hand_radio"] = RadioButton(_("Left-handed"), padding_x=10) self.button_widgets["double_test"] = gtk.EventBox() # relevant settings button self.button_widgets["keyboard_setting"] = Label( "<u>%s</u>" % _("Keyboard Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["mouse_setting"] = Label( "<u>%s</u>" % _("Mouse Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["set_to_default"] = Button(_("Reset")) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["main_swindow"] = ScrolledWindow() self.container_widgets["main_hbox"] = gtk.HBox(False) self.container_widgets["left_vbox"] = gtk.VBox(False) self.container_widgets["right_vbox"] = gtk.VBox(False) self.container_widgets["custom_main_vbox"] = gtk.VBox(False) # custom self.container_widgets["custom_label_hbox"] = gtk.HBox(False) self.container_widgets["custom_button_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_main_vbox"] = gtk.VBox( False) # pointer speed self.container_widgets["pointer_speed_label_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_table"] = gtk.Table(2, 4, False) self.container_widgets["double_click_main_vbox"] = gtk.VBox( False) # double click self.container_widgets["double_click_label_hbox"] = gtk.HBox(False) self.container_widgets["double_click_table"] = gtk.Table(2, 4, False) self.container_widgets["drag_threshold_main_vbox"] = gtk.VBox( False) # mouse wheel self.container_widgets["drag_threshold_label_hbox"] = gtk.HBox(False) self.container_widgets["drag_threshold_table"] = gtk.Table(1, 4, False) # alignment init self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["custom_label"] = gtk.Alignment() # custom self.alignment_widgets["custom_button"] = gtk.Alignment() self.alignment_widgets["pointer_speed_label"] = gtk.Alignment( ) # pointer speed self.alignment_widgets["pointer_speed_table"] = gtk.Alignment() self.alignment_widgets["double_click_label"] = gtk.Alignment( ) # double click self.alignment_widgets["double_click_table"] = gtk.Alignment() self.alignment_widgets["drag_threshold_label"] = gtk.Alignment( ) # mouse wheel self.alignment_widgets["drag_threshold_table"] = gtk.Alignment() self.alignment_widgets["keyboard_setting"] = gtk.Alignment() self.alignment_widgets["mouse_setting"] = gtk.Alignment() # adjust init self.adjust_widgets["pointer_speed_accel"] = gtk.Adjustment( 1.0, 1.0, 10.0, 1, 2) self.adjust_widgets["pointer_speed_sensitiv"] = gtk.Adjustment( 1, 1, 10, 1, 2) self.adjust_widgets["double_click_rate"] = gtk.Adjustment( 100, 100, 1000, 100, 200) self.adjust_widgets["drag_threshold_time"] = gtk.Adjustment( 1, 1, 10, 1, 2) # scale init self.scale_widgets["pointer_speed_accel"] = HScalebar(value_min=1.0, value_max=10.0) self.scale_widgets["pointer_speed_sensitiv"] = HScalebar(value_min=1, value_max=10) self.scale_widgets["double_click_rate"] = HScalebar(value_min=100, value_max=1000) self.scale_widgets["drag_threshold_time"] = HScalebar(value_min=1, value_max=10)
def expose_toggle_button(self, widget, event, font_size, label_dcolor): ''' Callback for `expose-event` signal. @param widget: ToggleButton widget. @param event: Expose event. @param button_label: Button label string. @param padding_x: horticultural padding value. @param font_size: Font size. @param label_dcolor: Label DynamicColor. ''' # Init. inactive_normal_dpixbuf, inactive_hover_dpixbuf, inactive_press_dpixbuf, inactive_disable_dpixbuf = self.inactive_pixbuf_group active_normal_dpixbuf, active_hover_dpixbuf, active_press_dpixbuf, active_disable_dpixbuf = self.active_pixbuf_group rect = widget.allocation image = inactive_normal_dpixbuf.get_pixbuf() if not widget.get_active(): button_label = self.active_button_label else: button_label = self.inactive_button_label # Get pixbuf along with button's sate. if widget.state == gtk.STATE_INSENSITIVE: if widget.get_active(): image = active_disable_dpixbuf.get_pixbuf() else: image = inactive_disable_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_NORMAL: label_dcolor = app_theme.get_color('button_text_fg_normal') bg_dcolor = app_theme.get_alpha_color('button_bg_normal') image = inactive_normal_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_PRELIGHT: label_dcolor = app_theme.get_color('button_text_fg_hover') bg_dcolor = app_theme.get_alpha_color('button_bg_hover') if not inactive_hover_dpixbuf and not active_hover_dpixbuf: if widget.get_active(): image = active_normal_dpixbuf.get_pixbuf() else: image = inactive_normal_dpixbuf.get_pixbuf() else: if inactive_hover_dpixbuf and active_hover_dpixbuf: if widget.get_active(): image = active_hover_dpixbuf.get_pixbuf() else: image = inactive_hover_dpixbuf.get_pixbuf() elif inactive_hover_dpixbuf: image = inactive_hover_dpixbuf.get_pixbuf() elif active_hover_dpixbuf: image = active_hover_dpixbuf.get_pixbuf() elif widget.state == gtk.STATE_ACTIVE: if inactive_press_dpixbuf and active_press_dpixbuf: if self.button_press_flag: label_dcolor = app_theme.get_color('button_text_fg_press') bg_dcolor = app_theme.get_alpha_color('button_bg_press') if widget.get_active(): image = active_press_dpixbuf.get_pixbuf() else: image = inactive_press_dpixbuf.get_pixbuf() else: label_dcolor = app_theme.get_color('button_text_fg_normal') bg_dcolor = app_theme.get_alpha_color('button_bg_normal') image = active_normal_dpixbuf.get_pixbuf() else: image = active_normal_dpixbuf.get_pixbuf() # Draw button. cr = widget.window.cairo_create() draw_pixbuf(cr, image, rect.x + self.padding_edge, rect.y) # Draw font. if widget.state == gtk.STATE_INSENSITIVE: label_color = ui_theme.get_color("disable_text").get_color() else: label_color = label_dcolor.get_color() if button_label: draw_text(cr, button_label, rect.x + image.get_width() + self.padding_edge + self.padding_middle, rect.y, rect.width - image.get_width() - self.padding_edge * 2 - self.padding_middle + self.more_width, rect.height, font_size, label_color, alignment=pango.ALIGN_LEFT ) if self.draw_background: cr.set_source_rgba(*alpha_color_hex_to_cairo(bg_dcolor.get_color_info())) draw_round_rectangle(cr, rect.x, rect.y, rect.width, rect.height, rect.height/2) cr.fill() # Propagate expose to children. propagate_expose(widget, event) return True
def init_share_box(self): '''get weibo info, and create button''' self.to_share_weibo = {} self.to_share_weibo_res = {} self.deepin_info = {} self.is_get_user_info = {} self.__weibo_check_button_list = [] self.__weibo_image_button_list = [] # create Thumbnail if exists(self.upload_image): pixbuf = gtk.gdk.pixbuf_new_from_file(self.upload_image) pix_w = pixbuf.get_width() pix_h = pixbuf.get_height() if pix_w > pix_h: pix_s_w = self.thumb_width pix_s_h = int(pix_h / (float(pix_w) / self.thumb_width)) else: pix_s_h = self.thumb_height pix_s_w = int(pix_w / (float(pix_h) / self.thumb_height)) pixbuf = pixbuf.scale_simple(pix_s_w, pix_s_h, gtk.gdk.INTERP_TILES) thumb = gtk.image_new_from_pixbuf(pixbuf) else: thumb = gtk.Image() thumb.set_size_request(self.thumb_width, self.thumb_height) # weibo context input text_box = gtk.HBox(False, 2) text_vbox = gtk.VBox(False, 2) text_bg_vbox = gtk.VBox(False) text_bg_align = gtk.Alignment() text_bg_align.set(0.5, 0.5, 0, 0) text_bg_align.set_padding(5, 5, 16, 5) text_bg_align.connect("expose-event", self.text_view_bg_expose) text_scrolled_win = ScrolledWindow() text_scrolled_win.set_size_request(340, 157) text_view = gtk.TextView() text_view.set_left_margin(10) text_view.set_right_margin(10) text_view.set_pixels_above_lines(5) text_view.set_pixels_below_lines(5) text_view.set_wrap_mode(gtk.WRAP_WORD| gtk.WRAP_CHAR) text_view.connect("expose-event", self.text_view_expose) buf = text_view.get_buffer() text_scrolled_win.add(text_view) text_bg_vbox.pack_start(text_scrolled_win) text_bg_align.add(text_bg_vbox) text_align = gtk.Alignment() text_align.set(0.5, 0.5, 0, 0) text_align.set_padding(25, 30, 10, 10) text_box.pack_start(thumb, False, False, 10) text_box.pack_start(text_bg_align) text_vbox.pack_start(text_box, False, False, 10) text_align.add(text_vbox) #tmp_align = gtk.Alignment() #tmp_align.set(0.5, 0, 0, 1) #self.share_box.pack_start(tmp_align, False, False) self.share_box.pack_start(text_align, False, False) # dialog button box left_box = self.window.left_button_box right_box = self.window.right_button_box # input tip label self.input_num_label = Label("%d" % self.MAX_CHAR, text_size=16, text_x_align=pango.ALIGN_CENTER, label_width=50, enable_select=False) self.input_num_label.text_color = app_theme.get_color("left_char_num") # login box #weibo_box = gtk.HBox(False, 1) #weibo_box.set_size_request(-1, 50) weibo_box_list = [] self.loading_label = Label("%s..." % _("Loading"), text_size=12, label_width=70, enable_select=False) weibo_box_list.append(self.loading_label) for weibo in self.__weibo_list: box = gtk.HBox(False, 2) weibo.set_box(box) weibo_box_list.append(box) left_box.set_buttons(weibo_box_list) # share button button = Button(_("Share")) #button.set_size_request(75, 25) button.connect("clicked", self.share_button_clicked, text_view) buf.connect("changed", self.text_view_changed, button) # check char num tmp_vbox = gtk.VBox(False) tmp_align = gtk.Alignment() tmp_align.set(0.5, 0.5, 0, 0) tmp_vbox.pack_start(button, False, False) #tmp_vbox.pack_start(tmp_align) tmp_align.add(tmp_vbox) right_box.set_buttons([self.input_num_label, tmp_align]) # at first, set widget insensitive button.set_sensitive(False) text_view.set_editable(False) t = threading.Thread(target=self.init_user_info_thread, args=(button, text_view)) t.setDaemon(True) t.start()
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.wait_duration_items = [("1 %s" % _("Minute"), 60), ("5 %s" % _("Minutes"), 300), ("10 %s" % _("Minutes"), 600), ("15 %s" % _("Minutes"), 900), ("30 %s" % _("Minutes"), 1800), ("1 %s" % _("Hour"), 3600), (_("Never"), 0) ] self.power_manager = PowerManager() self.power_manager.power_settings.connect("changed", self.__power_settings_changed) self.power_manage_items = [(_("Do nothing"), self.power_manager.nothing), (_("Suspend"), self.power_manager.suspend), (_("Shut down"), self.power_manager.shutdown) ] self.power_plan_items = [(_("Balanced"), self.power_manager.balance), (_("Power saver"), self.power_manager.saving), (_("High performance"), self.power_manager.high_performance), (_("Custom"), self.power_manager.customized) ] ''' button power config ''' self.button_power_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/button_power.png"), _("Power Button Settings"), TEXT_WINDOW_TOP_PADDING, TEXT_WINDOW_LEFT_PADDING) ''' press button power ''' self.press_button_power_align = self.__setup_align() self.press_button_power_box = gtk.HBox(spacing=WIDGET_SPACING) self.press_button_power_label = self.__setup_label(_("When I press the power button")) self.press_button_power_combo = self.__setup_combo(self.power_manage_items) self.press_button_power_combo.set_select_index(self.power_manager.get_press_button_power(self.power_manage_items)) self.press_button_power_combo.connect("item-selected", self.__combo_item_selected, "press_button_power") self.__widget_pack_start(self.press_button_power_box, [self.press_button_power_label, self.press_button_power_combo]) self.press_button_power_align.add(self.press_button_power_box) ''' close notebook cover ''' self.close_notebook_cover_align = self.__setup_align() self.close_notebook_cover_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_notebook_cover_label = self.__setup_label(_("When I close the lid")) self.close_notebook_cover_combo = self.__setup_combo(self.power_manage_items) self.close_notebook_cover_combo.set_select_index(self.power_manager.get_close_notebook_cover(self.power_manage_items)) self.close_notebook_cover_combo.connect("item-selected", self.__combo_item_selected, "close_notebook_cover") self.__widget_pack_start(self.close_notebook_cover_box, [self.close_notebook_cover_label, self.close_notebook_cover_combo]) self.close_notebook_cover_align.add(self.close_notebook_cover_box) self.close_notebook_cover_align.set_child_visible(is_laptop()) ''' power save config ''' self.power_save_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/power_save.png"), _("Power Saving Settings")) ''' power plan ''' self.power_plan_align = self.__setup_align() self.power_plan_box = gtk.HBox(spacing = WIDGET_SPACING) self.power_plan_label = self.__setup_label(_("Power Plan")) self.power_plan_combo = self.__setup_combo(self.power_plan_items) self.power_plan_combo.set_select_index(self.power_manager.get_current_plan()) self.power_plan_combo.connect("item-selected", self.__combo_item_selected, "power_plan") self.__widget_pack_start(self.power_plan_box, [self.power_plan_label, self.power_plan_combo]) self.power_plan_align.add(self.power_plan_box) ''' close monitor ''' self.close_monitor_align = self.__setup_align() self.close_monitor_box = gtk.HBox(spacing = WIDGET_SPACING) self.close_monitor_label = self.__setup_label(_("Turn off monitor")) self.close_monitor_combo = self.__setup_combo(self.wait_duration_items) self.close_monitor_combo.set_select_index(0) self.close_monitor_combo.connect("item-selected", self.__combo_item_selected, "close_monitor") self.__widget_pack_start(self.close_monitor_box, [self.close_monitor_label, self.close_monitor_combo]) self.close_monitor_align.add(self.close_monitor_box) ''' suspend ''' self.suspend_align = self.__setup_align() self.suspend_box = gtk.HBox(spacing = WIDGET_SPACING) self.suspend_label = self.__setup_label(_("Suspend")) self.suspend_combo = self.__setup_combo(self.wait_duration_items) self.suspend_combo.set_select_index(0) self.suspend_combo.connect("item-selected", self.__combo_item_selected, "suspend") self.__widget_pack_start(self.suspend_box, [self.suspend_label, self.suspend_combo]) self.suspend_align.add(self.suspend_box) self.__on_power_plan_customized() ''' percentage ''' self.percentage_align = self.__setup_align() self.percentage_box = gtk.HBox(spacing = WIDGET_SPACING) self.percentage_label = self.__setup_label(_("Battery power remaining")) self.percentage_progressbar_align = self.__setup_align(padding_left = 0, padding_top = 0) self.percentage_progressbar = self.__setup_progressbar( self.power_manager.power_settings.get_double("percentage")) self.percentage_progressbar_align.add(self.percentage_progressbar) self.__widget_pack_start(self.percentage_box, [self.percentage_label, self.percentage_progressbar_align]) self.percentage_align.add(self.percentage_box) self.percentage_align.set_child_visible(is_laptop()) ''' wakeup password ''' self.wakeup_password_align = self.__setup_align(padding_top = BETWEEN_SPACING, padding_left = TEXT_WINDOW_LEFT_PADDING) self.wakeup_password_box = gtk.HBox(spacing=WIDGET_SPACING) self.wakeup_password_image = ImageBox(app_theme.get_pixbuf("lock/lock.png")) self.wakeup_password_label = self.__setup_label(_("Require password when computer wakes"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.wakeup_password_label.set_sensitive(self.power_manager.get_wakeup_password()) self.wakeup_password_toggle_align = self.__setup_align(padding_top = 2, padding_left = 88) self.wakeup_password_toggle = self.__setup_toggle() self.wakeup_password_toggle.set_active(self.power_manager.get_wakeup_password()) self.wakeup_password_toggle.connect("toggled", self.__toggled, "wakeup_password") self.wakeup_password_toggle_align.add(self.wakeup_password_toggle) self.__widget_pack_start(self.wakeup_password_box, [self.wakeup_password_image, self.wakeup_password_label, self.wakeup_password_toggle_align]) self.wakeup_password_align.add(self.wakeup_password_box) ''' tray battery status ''' self.tray_battery_status_align = self.__setup_align(padding_top = BETWEEN_SPACING, padding_left = TEXT_WINDOW_LEFT_PADDING) self.tray_battery_status_box = gtk.HBox(spacing=WIDGET_SPACING) self.tray_battery_image = ImageBox(app_theme.get_pixbuf("power/tray_battery.png")) self.tray_battery_status_label = self.__setup_label(_("Always show icon in the tray"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.tray_battery_status_label.set_sensitive(self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle_align = self.__setup_align(padding_top = 2, padding_left = 88) self.tray_battery_status_toggle = self.__setup_toggle() self.tray_battery_status_toggle.set_active(self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle.connect("toggled", self.__toggled, "tray_battery_status") self.tray_battery_status_toggle_align.add(self.tray_battery_status_toggle) self.__widget_pack_start(self.tray_battery_status_box, [self.tray_battery_image, self.tray_battery_status_label, self.tray_battery_status_toggle_align]) self.tray_battery_status_align.add(self.tray_battery_status_box) self.tray_battery_status_align.set_child_visible(is_laptop()) ''' this->gtk.VBox pack_start ''' self.__widget_pack_start(self, [self.button_power_config_align, self.press_button_power_align, self.close_notebook_cover_align, self.power_save_config_align, self.power_plan_align, self.close_monitor_align, self.suspend_align, self.percentage_align, self.wakeup_password_align, self.tray_battery_status_align, ]) self.connect("expose-event", self.__expose) self.__send_message("status", ("power", "")) self.__send_message("status", ("power", "show_reset"))
def share_to_weibo_result(self): '''result of share to weibo''' font_color = app_theme.get_color("share_result_text") res_hbox = gtk.HBox(False) res_hbox.set_size_request(-1, 240) res_left_box = DialogLeftButtonBox() res_right_box = DialogRightButtonBox() res_left_box.button_align.set(0.5, 0.0, 0, 1) res_right_box.button_align.set(0.5, 0.0, 0, 1) res_left_box.button_align.set_padding(5, 9, 19, 0) res_right_box.button_align.set_padding(30, 0, 0, 0) res_left_box.set_size_request(405, -1) res_right_box.set_size_request(195, -1) res_hbox.pack_start(res_left_box) res_hbox.pack_start( VSeparator(app_theme.get_shadow_color("VSeparator").get_color_info(), 0, 0)) res_hbox.pack_start(res_right_box) res_vbox = gtk.VBox(False) follow_vbox = gtk.VBox(False) tmp_img = gtk.Image() # only use as a placeholder tmp_img.set_size_request(-1, 50) res_vbox.pack_start(tmp_img, False, False) follow_tip_hbox = gtk.HBox(False) img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/deepin_logo.png")) follow_tip_hbox.pack_start(img, False, False, 5) follow_tip_hbox.pack_start( Label("%s %s" % (_("Follow"), "Linux Deepin"), text_color=app_theme_get_dynamic_color("#5f5f5f"), text_size=12, enable_select=False), False, False) follow_vbox.pack_start(follow_tip_hbox, False, False, 13) for weibo in self.to_share_weibo_res: vbox = gtk.VBox(False, 1) tip_box = gtk.HBox() error_box = gtk.HBox() vbox.pack_start(tip_box, False, False) vbox.pack_start(error_box, False, False) if self.to_share_weibo_res[weibo][0]: # upload succeed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_succeed.png")) #link = LinkButton(_(weibo.t_type), text_size=13, self.to_share_weibo_res[weibo][1]) link = Label(_(weibo.t_type), text_size=12, text_color=app_theme.get_color("link_text")) #, enable_gaussian=True, gaussian_radious=1, border_radious=0) link.add_events(gtk.gdk.BUTTON_PRESS_MASK) link.connect("enter-notify-event", lambda w, e: self.__draw_under_line(w)) link.connect("leave-notify-event", lambda w, e: w.queue_draw()) link.connect("button-press-event", self.goto_weibo_button_clicked, weibo) link_box = gtk.HBox(False) link_box.pack_start(link, False, False) utils.set_clickable_cursor(link) text = _("Share to") label = Label(text, text_size=12, text_color=font_color, enable_select=False) text = _("Successful") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label, False, False, 3) tip_box.pack_start(link_box, False, False, 3) tip_box.pack_start(label1, False, False) # only use as a placeholder img = gtk.Image() img.set_size_request(20, 1) error_box.pack_start(img, False, False, 16) tmp = Label(" ", text_size=9, label_width=200) tmp.set_size_request(200, 1) error_box.pack_start(tmp, False, False) #print text else: # upload failed img = gtk.image_new_from_file(app_theme.get_theme_file_path("image/share/share_failed.png")) #text = "% %s %s." % (_(weibo.t_type), _("upload failed")) text = _("Share to") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) label2 = Label(_(weibo.t_type), text_size=12, text_color=font_color, enable_select=False) text = _("Failed") label3 = Label(text, text_size=12, text_color=font_color, enable_select=False) if weibo.curl.error: error = "(%s)" % _(weibo.curl.error) elif weibo.get_error_msg(): error = "(%s)" % _(weibo.get_error_msg()) else: error = "(%s)" % _("Unknown reason") #print "%s: %s" % (weibo.t_type, error) #print "%s: %s" % (weibo.t_type, weibo.get_error_msg()) label = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label1, False, False, 3) tip_box.pack_start(label2, False, False, 3) tip_box.pack_start(label3, False, False) img = gtk.Image() # only use as a placeholder img.set_size_request(20, 20) error_box.pack_start(img, False, False, 16) error_box.pack_start(Label(error, text_size=9, label_width=200, text_color=font_color, enable_select=False), False, False) #print text res_vbox.pack_start(vbox, False, False, 10) for weibo in self.deepin_info: box = gtk.HBox(False, 15) # followed img = gtk.image_new_from_pixbuf(app_theme.get_pixbuf("share/"+weibo.t_type+".png").get_pixbuf()) box.pack_start(img, False, False) if self.deepin_info[weibo] is not None and self.deepin_info[weibo][3]: if not default_locale.startswith("zh_"): button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed_en.png").get_pixbuf()) else: button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/followed.png").get_pixbuf()) else: # to follow if not default_locale.startswith("zh_"): button = ImageButton( app_theme.get_pixbuf("share/follow_normal_en.png"), app_theme.get_pixbuf("share/follow_hover_en.png"), app_theme.get_pixbuf("share/follow_press_en.png")) else: button = ImageButton( app_theme.get_pixbuf("share/follow_normal.png"), app_theme.get_pixbuf("share/follow_hover.png"), app_theme.get_pixbuf("share/follow_press.png")) button.connect("clicked", self.friendships_add_button_clicked, weibo, box) box.pack_start(button, False, False) align = gtk.Alignment() align.set(0.0, 0.5, 0, 0) align.set_padding(0, 0, 30, 0) align.add(box) follow_vbox.pack_start(align, False, False, 8) res_left_box.set_buttons([res_vbox]) res_right_box.set_buttons([follow_vbox]) self.result_box.pack_start(res_hbox, False, False) self.result_box.show_all() self.set_slide_index(2)
def share_to_weibo_result(self): '''result of share to weibo''' font_color = app_theme.get_color("share_result_text") res_hbox = gtk.HBox(False) res_hbox.set_size_request(-1, 240) res_left_box = DialogLeftButtonBox() res_right_box = DialogRightButtonBox() res_left_box.button_align.set(0.5, 0.0, 0, 1) res_right_box.button_align.set(0.5, 0.0, 0, 1) res_left_box.button_align.set_padding(5, 9, 19, 0) res_right_box.button_align.set_padding(30, 0, 0, 0) res_left_box.set_size_request(405, -1) res_right_box.set_size_request(195, -1) res_hbox.pack_start(res_left_box) res_hbox.pack_start( VSeparator( app_theme.get_shadow_color("VSeparator").get_color_info(), 0, 0)) res_hbox.pack_start(res_right_box) res_vbox = gtk.VBox(False) follow_vbox = gtk.VBox(False) tmp_img = gtk.Image() # only use as a placeholder tmp_img.set_size_request(-1, 50) res_vbox.pack_start(tmp_img, False, False) follow_tip_hbox = gtk.HBox(False) img = gtk.image_new_from_file( app_theme.get_theme_file_path("image/share/deepin_logo.png")) follow_tip_hbox.pack_start(img, False, False, 5) follow_tip_hbox.pack_start( Label("%s %s" % (_("Follow"), "Linux Deepin"), text_color=app_theme_get_dynamic_color("#5f5f5f"), text_size=12, enable_select=False), False, False) follow_vbox.pack_start(follow_tip_hbox, False, False, 13) for weibo in self.to_share_weibo_res: vbox = gtk.VBox(False, 1) tip_box = gtk.HBox() error_box = gtk.HBox() vbox.pack_start(tip_box, False, False) vbox.pack_start(error_box, False, False) if self.to_share_weibo_res[weibo][0]: # upload succeed img = gtk.image_new_from_file( app_theme.get_theme_file_path( "image/share/share_succeed.png")) #link = LinkButton(_(weibo.t_type), text_size=13, self.to_share_weibo_res[weibo][1]) link = Label(_(weibo.t_type), text_size=12, text_color=app_theme.get_color("link_text")) #, enable_gaussian=True, gaussian_radious=1, border_radious=0) link.add_events(gtk.gdk.BUTTON_PRESS_MASK) link.connect("enter-notify-event", lambda w, e: self.__draw_under_line(w)) link.connect("leave-notify-event", lambda w, e: w.queue_draw()) link.connect("button-press-event", self.goto_weibo_button_clicked, weibo) link_box = gtk.HBox(False) link_box.pack_start(link, False, False) utils.set_clickable_cursor(link) text = _("Share to") label = Label(text, text_size=12, text_color=font_color, enable_select=False) text = _("Successful") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label, False, False, 3) tip_box.pack_start(link_box, False, False, 3) tip_box.pack_start(label1, False, False) # only use as a placeholder img = gtk.Image() img.set_size_request(20, 1) error_box.pack_start(img, False, False, 16) tmp = Label(" ", text_size=9, label_width=200) tmp.set_size_request(200, 1) error_box.pack_start(tmp, False, False) #print text else: # upload failed img = gtk.image_new_from_file( app_theme.get_theme_file_path( "image/share/share_failed.png")) #text = "% %s %s." % (_(weibo.t_type), _("upload failed")) text = _("Share to") label1 = Label(text, text_size=12, text_color=font_color, enable_select=False) label2 = Label(_(weibo.t_type), text_size=12, text_color=font_color, enable_select=False) text = _("Failed") label3 = Label(text, text_size=12, text_color=font_color, enable_select=False) if weibo.curl.error: error = "(%s)" % _(weibo.curl.error) elif weibo.get_error_msg(): error = "(%s)" % _(weibo.get_error_msg()) else: error = "(%s)" % _("Unknown reason") #print "%s: %s" % (weibo.t_type, error) #print "%s: %s" % (weibo.t_type, weibo.get_error_msg()) label = Label(text, text_size=12, text_color=font_color, enable_select=False) tip_box.pack_start(img, False, False, 15) tip_box.pack_start(label1, False, False, 3) tip_box.pack_start(label2, False, False, 3) tip_box.pack_start(label3, False, False) img = gtk.Image() # only use as a placeholder img.set_size_request(20, 20) error_box.pack_start(img, False, False, 16) error_box.pack_start( Label(error, text_size=9, label_width=200, text_color=font_color, enable_select=False), False, False) #print text res_vbox.pack_start(vbox, False, False, 10) for weibo in self.deepin_info: box = gtk.HBox(False, 15) # followed img = gtk.image_new_from_pixbuf( app_theme.get_pixbuf("share/" + weibo.t_type + ".png").get_pixbuf()) box.pack_start(img, False, False) if self.deepin_info[weibo] is not None and self.deepin_info[weibo][ 3]: if not default_locale.startswith("zh_"): button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf( "share/followed_en.png").get_pixbuf()) else: button = gtk.image_new_from_pixbuf( app_theme.get_pixbuf( "share/followed.png").get_pixbuf()) else: # to follow if not default_locale.startswith("zh_"): button = ImageButton( app_theme.get_pixbuf("share/follow_normal_en.png"), app_theme.get_pixbuf("share/follow_hover_en.png"), app_theme.get_pixbuf("share/follow_press_en.png")) else: button = ImageButton( app_theme.get_pixbuf("share/follow_normal.png"), app_theme.get_pixbuf("share/follow_hover.png"), app_theme.get_pixbuf("share/follow_press.png")) button.connect("clicked", self.friendships_add_button_clicked, weibo, box) box.pack_start(button, False, False) align = gtk.Alignment() align.set(0.0, 0.5, 0, 0) align.set_padding(0, 0, 30, 0) align.add(box) follow_vbox.pack_start(align, False, False, 8) res_left_box.set_buttons([res_vbox]) res_right_box.set_buttons([follow_vbox]) self.result_box.pack_start(res_hbox, False, False) self.result_box.show_all() self.set_slide_index(2)