def __init__(self, gfile, icon_size): ''' Initialize DirItem class. ''' # Init. gobject.GObject.__init__(self) self.gfile = gfile self.name = get_gfile_name(self.gfile) self.directory_path = gfile.get_path() self.icon_size = icon_size self.pixbuf = get_file_icon_pixbuf(self.directory_path, self.icon_size) self.is_button_press = False;
def __init__(self, gfile, icon_size): ''' Initialize DirItem class. ''' # Init. gobject.GObject.__init__(self) self.gfile = gfile self.name = get_gfile_name(self.gfile) self.directory_path = gfile.get_path() self.icon_size = icon_size self.pixbuf = get_file_icon_pixbuf(self.directory_path, self.icon_size) self.is_button_press = False
def __init__(self, gfile, column_index=0): ''' Initialize FileItem class. ''' TreeItem.__init__(self) self.gfile = gfile self.type = get_gfile_type(self.gfile) self.name = get_gfile_name(self.gfile) self.modification_time = get_gfile_modification_time(self.gfile) self.content_type = get_gfile_content_type(self.gfile) self.size = get_gfile_size(self.gfile) self.size_name = format_file_size(self.size) self.file_path = gfile.get_path() self.pixbuf = get_file_icon_pixbuf(self.file_path, ICON_SIZE) self.column_index = column_index self.name_width = get_name_width(self.column_index, self.name) self.modification_time_width = get_modification_time_width(self.modification_time) self.content_type_width = get_type_width(self.content_type) self.size_width = get_size_width(self.size_name)
def render_name(self, cr, rect): ''' Render icon and name of DirItem. ''' if self.pixbuf == None: self.pixbuf = get_file_icon_pixbuf(self.directory_path, ICON_SIZE) # Draw select background. if self.is_select or self.is_highlight: draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height, ui_theme.get_shadow_color("listview_select").get_color_info()) # Draw directory arrow icon. if self.is_expand: expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down.png").get_pixbuf() else: expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png").get_pixbuf() draw_pixbuf(cr, expand_indicator_pixbuf, rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT, rect.y + (rect.height - expand_indicator_pixbuf.get_height()) / 2, ) # Draw directory icon. draw_pixbuf(cr, self.pixbuf, rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT, rect.y + (rect.height - ICON_SIZE) / 2, ) # Draw directory name. draw_text(cr, self.name, rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT, rect.y, rect.width, rect.height) # Draw drag line. if self.drag_line: with cairo_disable_antialias(cr): cr.set_line_width(1) if self.drag_line_at_bottom: cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1) else: cr.rectangle(rect.x, rect.y, rect.width, 1) cr.fill()
def __init__(self, gfile, column_index=0): ''' Initialize DirItem class. ''' # Init. TreeItem.__init__(self) self.gfile = gfile self.type = get_gfile_type(self.gfile) self.name = get_gfile_name(self.gfile) self.modification_time = get_gfile_modification_time(self.gfile) self.content_type = get_gfile_content_type(self.gfile) self.size = get_gfile_size(self.gfile) self.size_name = "%s 项" % (self.size) self.directory_path = gfile.get_path() self.pixbuf = get_file_icon_pixbuf(self.directory_path, ICON_SIZE) self.column_index = column_index self.is_expand = False self.load_status = self.LOADING_INIT self.name_width = get_name_width(self.column_index, self.name) self.modification_time_width = get_modification_time_width(self.modification_time) self.content_type_width = get_type_width(self.content_type) self.size_width = get_size_width(self.size_name)