def get_tasks_tree(self): '''This create a liblarch tree suitable for tasks, including default filters For tags, filter are dynamically created at Tag insertion. ''' tasktree = Tree() f_dic = { 'workview': [self.workview], 'active': [self.active], 'closed': [self.closed, { 'flat': True }], 'notag': [self.notag], 'workable': [self.is_workable], 'started': [self.is_started], 'workdue': [self.workdue], 'workstarted': [self.workstarted], 'worktostart': [self.worktostart], 'worklate': [self.worklate], 'no_disabled_tag': [self.no_disabled_tag], } for f in f_dic: filt = f_dic[f] if len(filt) > 1: param = filt[1] else: param = None tasktree.add_filter(f, filt[0], param) self.tasktree = tasktree return tasktree
def get_tags_tree(self, req): """This create a liblarch tree suitable for tags, including the all_tags_tag and notag_tag. """ tagtree = Tree() # Build the "all tasks tag" alltag = tag.Tag(tag.ALLTASKS_TAG, req=req) alltag.set_attribute("special", "all") alltag.set_attribute("label", "%s" % _("All tasks")) alltag.set_attribute("icon", "emblem-documents-symbolic") alltag.set_attribute("order", 0) tagtree.add_node(alltag) p = {} self.tasktree.add_filter(tag.ALLTASKS_TAG, self.alltag, parameters=p) # Build the "without tag tag" notag_tag = tag.Tag(tag.NOTAG_TAG, req=req) notag_tag.set_attribute("special", "notag") notag_tag.set_attribute("label", "%s" % _("Tasks with no tags")) notag_tag.set_attribute("icon", "task-past-due-symbolic") notag_tag.set_attribute("order", 2) tagtree.add_node(notag_tag) p = {} self.tasktree.add_filter(tag.NOTAG_TAG, self.notag, parameters=p) # Build the search tag search_tag = tag.Tag(tag.SEARCH_TAG, req=req) search_tag.set_attribute("special", "search") search_tag.set_attribute("label", _("Saved searches")) search_tag.set_attribute("icon", "system-search-symbolic") search_tag.set_attribute("order", 1) tagtree.add_node(search_tag) p = {} self.tasktree.add_filter(tag.SEARCH_TAG, search_filter, parameters=p) # Build the separator sep_tag = tag.Tag(tag.SEP_TAG, req=req) sep_tag.set_attribute("special", "sep") sep_tag.set_attribute("order", 3) tagtree.add_node(sep_tag) # Filters tagtree.add_filter('activetag', self.actively_used_tag) tagtree.add_filter('usedtag', self.used_tag) activeview = tagtree.get_viewtree(name='activetags', refresh=False) activeview.apply_filter('activetag') # This view doesn't seem to be used. So it's not useful to build it now # usedview = tagtree.get_viewtree(name='usedtags',refresh=False) # usedview.apply_filter('usedtag') self.tagtree = tagtree self.tagtree_loaded = True return tagtree
def _build_tree_view(self): self.tree = Tree() self.tree.add_filter("even",self.even_filter) self.tree.add_filter("odd",self.odd_filter) self.tree.add_filter("flat",self.flat_filter,{"flat": True}) self.tree.add_filter("leaf",self.leaf_filter) self.view_tree = self.tree.get_viewtree() self.mod_counter = 0 self.view_tree.register_cllbck('node-added-inview',self._update_title) self.view_tree.register_cllbck('node-modified-inview',self._modified_count) self.view_tree.register_cllbck('node-deleted-inview',self._update_title) desc = {} col_name = 'label' col = {} col['title'] = "Title" col['value'] = [str, self.task_label_column] col['expandable'] = True col['resizable'] = True col['sorting'] = 'label' col['order'] = 0 desc[col_name] = col tree_view = TreeView(self.view_tree, desc) # Polish TreeView def on_row_activate(sender,a,b): print( "Selected nodes are: {0!s}".format( tree_view.get_selected_nodes() ) ) tree_view.set_dnd_name('liblarch-demo/liblarch_widget') tree_view.set_multiple_selection(True) tree_view.set_property("enable-tree-lines", True) tree_view.connect('row-activated', on_row_activate) return tree_view
def get_tags_tree(self, req): '''This create a liblarch tree suitable for tags, including the all_tags_tag and notag_tag. ''' tagtree = Tree() ### building the initial tags # Build the "all tasks tag" alltag = Tag(CoreConfig.ALLTASKS_TAG, req=req) alltag.set_attribute("special", "all") alltag.set_attribute("label", "<span weight='bold'>%s</span>" % _("All tasks")) alltag.set_attribute("icon", "gtg-tags-all") alltag.set_attribute("order", 0) tagtree.add_node(alltag) p = {} self.tasktree.add_filter(CoreConfig.ALLTASKS_TAG, self.alltag, parameters=p) # Build the "without tag tag" notag_tag = Tag(CoreConfig.NOTAG_TAG, req=req) notag_tag.set_attribute("special", "notag") notag_tag.set_attribute( "label", "<span weight='bold'>%s</span>" % _("Tasks with no tags")) notag_tag.set_attribute("icon", "gtg-tags-none") notag_tag.set_attribute("order", 2) tagtree.add_node(notag_tag) p = {} self.tasktree.add_filter(CoreConfig.NOTAG_TAG, self.notag, parameters=p) # Build the search tag search_tag = Tag(CoreConfig.SEARCH_TAG, req=req) search_tag.set_attribute("special", "search") search_tag.set_attribute("label", "<span weight='bold'>%s</span>" % _("Search")) search_tag.set_attribute("icon", "search") search_tag.set_attribute("order", 1) tagtree.add_node(search_tag) p = {} self.tasktree.add_filter(CoreConfig.SEARCH_TAG, search_filter, parameters=p) # Build the separator sep_tag = Tag(CoreConfig.SEP_TAG, req=req) sep_tag.set_attribute("special", "sep") sep_tag.set_attribute("order", 3) tagtree.add_node(sep_tag) #### Filters tagtree.add_filter('activetag', self.actively_used_tag) tagtree.add_filter('usedtag', self.used_tag) activeview = tagtree.get_viewtree(name='activetags', refresh=False) activeview.apply_filter('activetag') # This view doesn't seem to be used. So it's not useful to build it now # usedview = tagtree.get_viewtree(name='usedtags',refresh=False) # usedview.apply_filter('usedtag') self.tagtree = tagtree self.tagtree_loaded = True return tagtree
BIG_NUMBER = 2000 STAIRS = 200 from liblarch import Tree from liblarch.tree import TreeNode from liblarch_gtk import TreeView import time, gtk #This is a dummy treenode that only have one properties: a color class DummyNode(TreeNode): def __init__(self,tid): TreeNode.__init__(self, tid) self.colors = [] tree = Tree() view = tree.get_viewtree() #view = tree.get_viewtree(refresh = False) nodes_id = [] ################now testing the GTK treeview ################## #The columns description: desc = {} col = {} col['title'] = "Node name" render_text = gtk.CellRendererText() col['renderer'] = ['markup',render_text] def get_node_name(node): return node.get_id() col['value'] = [str,get_node_name] desc['titles'] = col #treeview = TreeView(view,desc)
def make_contact_list(self): # LIBLARCH TREE CONSTRUCTION # First thing, we create a liblarch tree self.tree = Tree() # Now, we add each contact *and* each team as nodes of that tree. # The team will be the parents of the contact nodes. for contact in CONTACTS: # We create the node and use the XMPP address as the node_id node = NodeContact(contact['xmpp']) # We add the status and the nickname node.set_status(contact['status']) node.set_nick(contact['name']) # The contact node is added to the tree self.tree.add_node(node) # Now, we create the team if it was not done before for team_name in contact['teams']: if not self.tree.has_node(team_name): team_node = NodeTeam(team_name) self.tree.add_node(team_node) # now we put the contact under the team node.add_parent(team_name) # we could also have done # team_node.add_child(contact[0]) # LIBLARCH VIEW and FILTER # Ok, now we have our liblarch tree. What we need is a view. self.view = self.tree.get_viewtree() # We also create a filter that will allow us to hide offline people self.tree.add_filter("online", self.is_node_online) self.offline = False self.tree.add_filter("search", self.search_filter) # And we apply this filter by default self.view.apply_filter("online") # LIBLARCH GTK.TreeView # And, now, we build our Gtk.TreeView # We will build each column of our TreeView columns = {} # The first column contain the XMPP address but will be hidden # But it is still useful for searching col = {} col['value'] = [str, lambda node: node.get_id()] col['visible'] = False col['order'] = 0 columns['XMPP'] = col # The second column is the status col = {} render_tags = CellRendererTags() render_tags.set_property('xalign', 0.0) col['renderer'] = ['status', render_tags] col['value'] = [GObject.TYPE_PYOBJECT, lambda node: node.get_status()] col['expandable'] = False col['resizable'] = False col['order'] = 1 columns['status'] = col # the third column is the nickname col = {} col['value'] = [str, lambda node: node.get_label()] col['visible'] = True col['order'] = 2 columns['nick'] = col return TreeView(self.view, columns)