def on_expose_event(self, widget, event): if not self.prompt_pixbuf: return cr = widget.window.cairo_create() rect = widget.allocation pixbuf_y = rect.y + (rect.height - self.prompt_pixbuf.get_height()) / 2 draw_pixbuf(cr, self.bg_left, rect.x, rect.y) bg_left_w = self.bg_left.get_width() self.cache_bg_pixbuf.scale(self.bg_middle, rect.width - bg_left_w * 2, self.bg_middle.get_height()) draw_pixbuf(cr, self.cache_bg_pixbuf.get_cache(), rect.x + bg_left_w, rect.y) draw_pixbuf(cr, self.bg_right, rect.x + rect.width - bg_left_w, rect.y) draw_pixbuf(cr, self.prompt_pixbuf, rect.x + self.padding_x, pixbuf_y) # draw text. text_rect = gtk.gdk.Rectangle( rect.x + self.prompt_pixbuf.get_width() + self.padding_x * 2, rect.y, rect.width - self.prompt_pixbuf.get_width() - self.padding_x * 3, rect.height) render_text(cr, self.prompt_text, text_rect, app_theme.get_color("labelText").get_color(), 8) return True
def render(self, cr, rect): ''' Render item. This is IconView interface, you should implement it. ''' # Draw cover. if self.pixbuf is None: self.create_cover_pixbuf() pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2 cr.save() cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, rect.y + self.pixbuf.get_height() / 2, self.pixbuf.get_width() / 2, 0, 2 * math.pi) cr.clip() draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y) cr.restore() if self.pixbuf_rect is None: self.pixbuf_rect = gtk.gdk.Rectangle( (rect.width - self.pixbuf.get_width()) / 2, 0, self.pixbuf.get_width(), self.pixbuf.get_height()) if self.mask_flag: if self.mask_pixbuf is None: self.create_mask_pixbuf() cr.save() cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, rect.y + self.pixbuf.get_height() / 2, self.pixbuf.get_width() / 2, 0, 2 * math.pi) cr.clip() draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y) cr.restore() title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x, rect.y + self.pixbuf.get_height() + 5, rect.width - self.padding_x * 2, 11) total_rect = gtk.gdk.Rectangle(title_rect.x, title_rect.y + 16, title_rect.width, 9) render_text( cr, utils.xmlescape(self.title), title_rect, # app_theme.get_color("labelText").get_color(), "#444444", 10) render_text(cr, utils.xmlescape(self.description), total_rect, app_theme.get_color("labelText").get_color(), 8)
def render(self, cr, rect): ''' Render item. This is IconView interface, you should implement it. ''' # Draw cover. if self.pixbuf is None: self.create_cover_pixbuf() pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2 cr.save() cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, rect.y + self.pixbuf.get_height() / 2, self.pixbuf.get_width() / 2, 0, 2 * math.pi) cr.clip() draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y) cr.restore() if self.pixbuf_rect is None: self.pixbuf_rect = gtk.gdk.Rectangle((rect.width - self.pixbuf.get_width()) / 2, 0, self.pixbuf.get_width(), self.pixbuf.get_height()) if self.mask_flag: if self.mask_pixbuf is None: self.create_mask_pixbuf() cr.save() cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, rect.y + self.pixbuf.get_height() / 2, self.pixbuf.get_width() / 2, 0, 2 * math.pi) cr.clip() draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y) cr.restore() title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x, rect.y + self.pixbuf.get_height() + 5, rect.width - self.padding_x * 2, 11) total_rect = gtk.gdk.Rectangle(title_rect.x, title_rect.y + 16, title_rect.width, 9) render_text(cr, utils.xmlescape(self.title), title_rect, # app_theme.get_color("labelText").get_color(), "#444444", 10) render_text(cr, utils.xmlescape(self.description), total_rect, app_theme.get_color("labelText").get_color(), 8)
def render(self, cr, rect): ''' Render item. This is IconView interface, you should implement it. ''' if self.pixbuf is None: self.create_pixbuf() pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2 # cr.save() # cr.arc(pixbuf_x + self.pixbuf.get_width() / 2 + 1, # rect.y + self.pixbuf.get_height() / 2 + 1, # self.pixbuf.get_width() / 2, # 0, 2 * math.pi) # cr.clip() draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y) # cr.restore() if self.pixbuf_rect is None: self.pixbuf_rect = gtk.gdk.Rectangle((rect.width - self.pixbuf.get_width()) / 2, 0, self.pixbuf.get_width(), self.pixbuf.get_height()) if self.mask_flag: if self.mask_pixbuf is None: self.create_mask_pixbuf() # cr.save() # cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, # rect.y + self.pixbuf.get_height() / 2, # self.pixbuf.get_width() / 2, # 0, 2 * math.pi) # cr.clip() draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y) # cr.restore() title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x, rect.y + self.pixbuf.get_height() + 5, rect.width - self.padding_x * 2, 11) render_text(cr, _("More"), title_rect, app_theme.get_color("labelText").get_color(), 10)
def render(self, cr, rect): ''' Render item. This is IconView interface, you should implement it. ''' if self.pixbuf is None: self.create_pixbuf() pixbuf_x = rect.x + (rect.width - self.pixbuf.get_width()) / 2 # cr.save() # cr.arc(pixbuf_x + self.pixbuf.get_width() / 2 + 1, # rect.y + self.pixbuf.get_height() / 2 + 1, # self.pixbuf.get_width() / 2, # 0, 2 * math.pi) # cr.clip() draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y) # cr.restore() if self.pixbuf_rect is None: self.pixbuf_rect = gtk.gdk.Rectangle( (rect.width - self.pixbuf.get_width()) / 2, 0, self.pixbuf.get_width(), self.pixbuf.get_height()) if self.mask_flag: if self.mask_pixbuf is None: self.create_mask_pixbuf() # cr.save() # cr.arc(pixbuf_x + self.pixbuf.get_width() / 2, # rect.y + self.pixbuf.get_height() / 2, # self.pixbuf.get_width() / 2, # 0, 2 * math.pi) # cr.clip() draw_pixbuf(cr, self.mask_pixbuf, pixbuf_x, rect.y) # cr.restore() title_rect = gtk.gdk.Rectangle(rect.x + self.padding_x, rect.y + self.pixbuf.get_height() + 5, rect.width - self.padding_x * 2, 11) render_text(cr, _("More"), title_rect, app_theme.get_color("labelText").get_color(), 10)
def render(self, cr, rect): # Draw cover. draw_pixbuf(cr, self.pixbuf, rect.x + self.padding_x, rect.y + self.padding_y) if self.hover_flag or self.highlight_flag: side_pixbuf = app_theme.get_pixbuf("filter/side_hover.png").get_pixbuf() draw_pixbuf(cr, side_pixbuf, rect.x, rect.y ) else: if self.draw_side_flag: side_pixbuf = self.__normal_side_pixbuf draw_pixbuf(cr, side_pixbuf, rect.x, rect.y ) if self.hover_flag: if self.__draw_play_hover_flag: play_pixbuf = app_theme.get_pixbuf("filter/play_hover.png").get_pixbuf() elif self.__draw_play_press_flag: play_pixbuf = app_theme.get_pixbuf("filter/play_press.png").get_pixbuf() else: play_pixbuf = self.__normal_play_pixbuf draw_pixbuf(cr, play_pixbuf, rect.x + self.play_rect.x, rect.y + self.play_rect.y) # Draw text. name_rect = gtk.gdk.Rectangle(rect.x + self.padding_x , rect.y + self.__normal_side_pixbuf.get_height() + 5, self.cell_width, 11) num_rect = gtk.gdk.Rectangle(name_rect.x, name_rect.y + 16, name_rect.width, 9) render_text(cr, self.name_label, name_rect, app_theme.get_color("labelText").get_color(), 10) render_text(cr, self.labels, num_rect, app_theme.get_color("labelText").get_color(), 8)
def render(self, cr, rect): # Create pixbuf resource if self.pixbuf is None. self.create_pixbuf() if not self.pixbuf: self.pixbuf = self.cover_dpixbuf.get_pixbuf() pixbuf_x = rect.x + (rect.width - self.__normal_side_pixbuf.get_width()) / 2 # Draw cover. if self.tag == "folder": draw_pixbuf(cr, self.pixbuf, pixbuf_x, rect.y) else: pixbuf_rect = gtk.gdk.Rectangle( pixbuf_x + self.pixbuf_offset_x, rect.y + self.pixbuf_offset_y, self.pixbuf.get_width(), self.pixbuf.get_height()) draw_pixbuf(cr, self.pixbuf, pixbuf_x + self.pixbuf_offset_x, rect.y + self.pixbuf_offset_y) if self.hover_flag or self.highlight_flag: if self.tag == "folder": hover_side_pixbuf = app_theme.get_pixbuf("local/side_hover.png").get_pixbuf() else: hover_side_pixbuf = app_theme.get_pixbuf("filter/side_hover.png").get_pixbuf() draw_pixbuf(cr, hover_side_pixbuf, pixbuf_x, rect.y ) else: if self.draw_side_flag: draw_pixbuf(cr, self.__normal_side_pixbuf, pixbuf_x, rect.y ) if self.hover_flag: # if self.tag != "folder" and self.draw_side_flag: # cr.set_source_rgba(0, 0, 0, 0.3) # cr.rectangle(*pixbuf_rect) # cr.fill() if self.__draw_play_hover_flag: play_pixbuf = app_theme.get_pixbuf("filter/play_hover.png").get_pixbuf() elif self.__draw_play_press_flag: play_pixbuf = app_theme.get_pixbuf("filter/play_press.png").get_pixbuf() else: play_pixbuf = self.__normal_play_pixbuf draw_pixbuf(cr, play_pixbuf, pixbuf_x + self.play_rect.x, rect.y + self.play_rect.y) # Draw text. name_rect = gtk.gdk.Rectangle(rect.x + self.padding_x , rect.y + self.__normal_side_pixbuf.get_height() + 5, self.cell_width, 11) num_rect = gtk.gdk.Rectangle(name_rect.x, name_rect.y + 16, name_rect.width, 9) render_text(cr, self.name_label, name_rect, app_theme.get_color("labelText").get_color(), 10) render_text(cr, self.labels, num_rect, app_theme.get_color("labelText").get_color(), 8)