def on_get_value(self, iter, column): #~ print '>> on_get_value', iter, column if column == NAME_COL: return iter.row['name'].split(':')[-1] elif column == TIP_COL: basename = iter.row['name'].split(':')[-1] return encode_markup_text(basename) elif column == PATH_COL: return PageIndexRecord(iter.row) elif column == EMPTY_COL: return iter.row['is_link_placeholder'] elif column == STYLE_COL: if iter.row['is_link_placeholder']: return pango.STYLE_ITALIC else: return pango.STYLE_NORMAL elif column == FGCOLOR_COL: if iter.row['is_link_placeholder']: return self.EMPTY_COLOR else: return self.NORMAL_COLOR elif column == WEIGHT_COL: if self.current_page and iter.row['name'] == self.current_page.name: return pango.WEIGHT_BOLD else: return pango.WEIGHT_NORMAL elif column == N_CHILD_COL: return iter.n_children or ''
def get_indexpath(self, treeiter): '''Get an L{PageIndexRecord} for a C{gtk.TreeIter} @param treeiter: a C{gtk.TreeIter} @returns: an L{PageIndexRecord} object ''' myiter = self.get_user_data(treeiter) return PageIndexRecord(myiter.row)
def get_indexpath(self, treeiter): '''Get an L{PageIndexRecord} for a C{Gtk.TreeIter} @param treeiter: a C{Gtk.TreeIter} @returns: an L{PageIndexRecord} object ''' mytreeiter = self.get_user_data(treeiter) if mytreeiter.hint == IS_PAGE: return PageIndexRecord(mytreeiter.row) elif mytreeiter.hint == IS_TAG: return IndexTag(mytreeiter.row['name'], mytreeiter.row['id']) else: raise ValueError
def on_get_value(self, iter, column): if column == NAME_COL: return iter.row['name'].split(':')[-1] elif column == TIP_COL: basename = iter.row['name'].split(':')[-1] return encode_markup_text(basename) elif column == PATH_COL: return PageIndexRecord(iter.row) elif column == EXISTS_COL: return not iter.row['is_link_placeholder'] elif column == STYLE_COL: if iter.row['is_link_placeholder']: return Pango.Style.ITALIC else: return Pango.Style.NORMAL elif column == WEIGHT_COL: if self.current_page and iter.row['name'] == self.current_page.name: return Pango.Weight.BOLD else: return Pango.Weight.NORMAL elif column == N_CHILD_COL: return str(iter.n_children) if iter.n_children > 0 else ''
def on_get_value(self, iter, column): ''' Modify to return new pagenames, tooltips and icons. Columns 'NAME_COL', 'TIP_COL' and 'ICON_COL' use cache, other columns works with default methods. ''' if (column == NAME_COL) or (column == TIP_COL): try: return self._pagenames_cache[iter.row['name']][column] except KeyError: pass elif column == ICON_COL: try: return render_icon( self._pagenames_cache[iter.row['name']][column]) except KeyError: pass else: return PageTreeStore.on_get_value(self, iter, column) # Value is not in cache. # Find tags, icons and put values to cache. page = PageIndexRecord(iter.row) tags = [ a.name for a in TagsView.new_from_index(self.index).list_tags(page) ] icon = None if self.iconindex: icon = self.iconindex.get_icon(iter.row['name']) if icon: icon = ICONS.get(icon, ICONS[NO_IMAGE]) elif tags: # Check icons for tags. _icons = [ self.icons_for_tags[a] for a in tags if a in self.icons_for_tags ] if _icons: # Check whether all icons are the same. if len(set(_icons)) > 1: icon = ICONS[SEVERAL_ICONS] else: icon = ICONS[_icons[0]] elif page.haschildren: icon = ICONS[FOLDER_TAGS_ICON] else: icon = ICONS[FILE_TAGS_ICON] else: if page.haschildren: icon = ICONS[FOLDER_ICON] else: icon = ICONS[FILE_ICON] if tags and self.show_tags: # show tags after page name name = '{} ({})'.format(page.basename, ', '.join(tags)) else: name = page.basename self._pagenames_cache[iter.row['name']] = { NAME_COL: name, TIP_COL: encode_markup_text(name), ICON_COL: icon } # Launch function to clear cache. if not self._clear_cache_scheduled: self._clear_pagenames_cache() return self.on_get_value(iter, column)