Beispiel #1
0
 def read_db_node_n_children(self, db, node_row, tree_father, discard_ids, node_sequence):
     """Read a node and his children from DB"""
     if not discard_ids:
         unique_id = node_row['node_id']
     else: unique_id = self.dad.node_id_get()
     node_tags = node_row['tags']
     if node_tags: self.dad.tags_add_from_node(node_tags)
     # is_ro (bitfield)
     readonly_n_custom_icon_id = node_row['is_ro']
     readonly = readonly_n_custom_icon_id & 0x01
     custom_icon_id = readonly_n_custom_icon_id >> 1
     # is_richtxt (bitfield)
     richtxt_bold_foreground = node_row['is_richtxt']
     is_bold = (richtxt_bold_foreground >> 1) & 0x01
     fg_override = (richtxt_bold_foreground >> 2) & 0x01
     if fg_override:
         foreground = exports.rgb_str_from_int24bit((richtxt_bold_foreground >> 3) & 0xffffff)
     else:
         foreground = None
     syntax_highlighting = node_row['syntax']
     if syntax_highlighting not in [cons.RICH_TEXT_ID, cons.PLAIN_TEXT_ID]\
     and syntax_highlighting not in self.dad.available_languages:
         syntax_highlighting = syntax_highlighting.lower().replace("C++", "cpp")
         if syntax_highlighting not in self.dad.available_languages:
             syntax_highlighting = cons.RICH_TEXT_ID
     node_level = self.dad.treestore.iter_depth(tree_father)+1 if tree_father else 0
     cherry = self.dad.get_node_icon(node_level, syntax_highlighting, custom_icon_id)
     #print "added node with unique_id", unique_id
     # insert the node containing the buffer into the tree
     tree_iter = self.dad.treestore.append(tree_father, [cherry,
                                                         node_row['name'],
                                                         None, # no buffer for now
                                                         unique_id,
                                                         syntax_highlighting,
                                                         node_sequence,
                                                         node_tags,
                                                         readonly,
                                                         None,
                                                         custom_icon_id,
                                                         support.get_pango_weight(is_bold),
                                                         foreground])
     self.dad.nodes_names_dict[self.dad.treestore[tree_iter][3]] = self.dad.treestore[tree_iter][1]
     if discard_ids:
         # we are importing (=> adding) a node
         self.pending_new_db_node(unique_id)
         self.read_db_node_content(tree_iter, db, original_id=node_row['node_id'])
     # loop for child nodes
     child_sequence = 0
     children_rows = self.get_children_rows_from_father_id(db, node_row['node_id'])
     for child_row in children_rows:
         child_node_row = self.get_node_row_partial_from_id(db, child_row['node_id'])
         if child_node_row:
             child_sequence += 1
             self.read_db_node_n_children(db,
                                          child_node_row,
                                          tree_iter,
                                          discard_ids,
                                          child_sequence)
Beispiel #2
0
 def read_db_node_n_children(self, db, original_id, node_row, tree_father, discard_ids, node_sequence):
     """Read a node and his children from DB"""
     if discard_ids is None:
         unique_id = original_id
     else:
         unique_id = self.dad.node_id_get(original_id, discard_ids)
     node_tags = node_row['tags']
     if node_tags: self.dad.tags_add_from_node(node_tags)
     # is_ro (bitfield)
     readonly_n_custom_icon_id = node_row['is_ro']
     readonly = readonly_n_custom_icon_id & 0x01
     custom_icon_id = readonly_n_custom_icon_id >> 1
     # is_richtxt (bitfield)
     richtxt_bold_foreground = node_row['is_richtxt']
     is_bold = (richtxt_bold_foreground >> 1) & 0x01
     fg_override = (richtxt_bold_foreground >> 2) & 0x01
     if fg_override:
         foreground = exports.rgb_str_from_int24bit((richtxt_bold_foreground >> 3) & 0xffffff)
     else:
         foreground = None
     syntax_highlighting = node_row['syntax']
     if syntax_highlighting not in [cons.RICH_TEXT_ID, cons.PLAIN_TEXT_ID]\
     and syntax_highlighting not in self.dad.available_languages:
         syntax_highlighting = syntax_highlighting.lower().replace("C++", "cpp")
         if syntax_highlighting not in self.dad.available_languages:
             syntax_highlighting = cons.RICH_TEXT_ID
     node_level = self.dad.treestore.iter_depth(tree_father)+1 if tree_father else 0
     cherry = self.dad.get_node_icon(node_level, syntax_highlighting, custom_icon_id)
     try:
         ts_creation = node_row['ts_creation']
         ts_lastsave = node_row['ts_lastsave']
     except IndexError:
         ts_creation = None
         ts_lastsave = None
     if not ts_creation: ts_creation = 0
     if not ts_lastsave: ts_lastsave = 0
     #print "added node with unique_id", unique_id
     # insert the node containing the buffer into the tree
     tree_iter = self.dad.treestore.append(tree_father, [cherry,
                                                         node_row['name'],
                                                         None, # no buffer for now
                                                         unique_id,
                                                         syntax_highlighting,
                                                         node_sequence,
                                                         node_tags,
                                                         readonly,
                                                         None,
                                                         custom_icon_id,
                                                         support.get_pango_weight(is_bold),
                                                         foreground,
                                                         ts_creation,
                                                         ts_lastsave])
     self.dad.update_node_aux_icon(tree_iter)
     self.dad.nodes_names_dict[self.dad.treestore[tree_iter][3]] = self.dad.treestore[tree_iter][1]
     if discard_ids is not None:
         # we are importing (=> adding) a node
         self.pending_new_db_node(unique_id)
         self.read_db_node_content(tree_iter, db, original_id, discard_ids)
     # loop for child nodes
     child_sequence = 0
     children_node_ids = self.get_children_node_ids_from_father_id(db, original_id)
     for child_node_id in children_node_ids:
         child_node_row = self.get_node_row_partial_from_id(db, child_node_id)
         if child_node_row:
             child_sequence += 1
             self.read_db_node_n_children(db,
                                          child_node_id,
                                          child_node_row,
                                          tree_iter,
                                          discard_ids,
                                          child_sequence)