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 build_tag_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_row_separator_func(self.is_tag_separator_filter) treeview.set_headers_visible(False) treeview.set_dnd_name('gtg/tag-iter-str') treeview.set_dnd_external('gtg/task-iter-str', self.ontag_task_dnd) # Updating the unactive color (same for everyone) color = treeview.get_style_context().get_color( Gtk.StateFlags.INSENSITIVE) # Convert color into #RRRGGGBBB self.unactive_color = color.to_color().to_string() treeview.set_sort_column('tag_id') self.tags_view = treeview return treeview
def build_task_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Now that the treeview is done, we can polish treeview.set_main_search_column('label') treeview.set_expander_column('label') treeview.set_dnd_name('gtg/task-iter-str') # Background colors treeview.set_bg_color(self.task_bg_color, 'bg_color') # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_multiple_selection(True) # Updating the unactive color (same for everyone) color = treeview.get_style_context().get_color( Gtk.StateFlags.INSENSITIVE) # Convert color into #RRRGGGBBB self.unactive_color = color.to_color().to_string() return treeview
def build_tag_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_row_separator_func(self.is_tag_separator_filter) treeview.set_headers_visible(False) treeview.set_dnd_name('gtg/tag-iter-str') treeview.set_dnd_external('gtg/task-iter-str', self.on_tag_task_dnd) # Updating the unactive color (same for everyone) color = treeview.get_style_context().get_color(Gtk.StateFlags.INSENSITIVE) # Convert color into #RRRGGGBBB self.unactive_color = color.to_color().to_string() treeview.set_sort_column('tag_id') self.tags_view = treeview return treeview
def build_task_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Now that the treeview is done, we can polish treeview.set_main_search_column('label') treeview.set_expander_column('label') treeview.set_dnd_name('gtg/task-iter-str') # Background colors treeview.set_bg_color(self.get_task_bg_color, 'bg_color') # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_multiple_selection(True) # Updating the unactive color (same for everyone) color = treeview.get_style_context().get_color(Gtk.StateFlags.INSENSITIVE) # Convert color into #RRRGGGBBB self.unactive_color = color.to_color().to_string() return treeview
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)
def build_tag_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_row_separator_func(self.is_tag_separator_filter) treeview.set_headers_visible(False) treeview.set_dnd_name('gtg/tag-iter-str') treeview.set_dnd_external('gtg/task-iter-str', self.ontag_task_dnd) # Updating the unactive color (same for everyone) self.unactive_color = \ treeview.style.text[gtk.STATE_INSENSITIVE].to_string() treeview.set_sort_column('tag_id') self.tags_view = treeview return treeview
def build_task_treeview(self, tree, desc): treeview = TreeView(tree, desc) # Now that the treeview is done, we can polish treeview.set_main_search_column('label') treeview.set_expander_column('label') treeview.set_dnd_name('gtg/task-iter-str') # Background colors treeview.set_bg_color(self.task_bg_color, 'bg_color') # Global treeview properties treeview.set_property("enable-tree-lines", False) treeview.set_rules_hint(False) treeview.set_multiple_selection(True) # Updating the unactive color (same for everyone) self.unactive_color = \ treeview.style.text[gtk.STATE_INSENSITIVE].to_string() return treeview