Changeset 68

Show
Ignore:
Timestamp:
11/06/07 19:02:26
Author:
slee
Message:

added scanning and enus

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • action_groups/trunk/action_tree.py

    r67 r68  
    275275    t = time() - t 
    276276    print 'Populated level in', t 
    277    
     277 
     278  def makeExpandable(self, iter): 
     279    # add dummy child is expandable 
     280    # and  not self.iter_has_child(iter): 
     281    if iter: 
     282      self.append(iter, ['', '', None, True, False]) 
     283 
    278284  def _appendChild(self, parent_iter, acc): 
    279285    iter = self.append(parent_iter,  
     
    281287 
    282288    if not acc.isInteractive(): 
    283       # and  not self.iter_has_child(iter): 
    284       # is a group so add dummy grandchild so child is expandable 
    285       self.append(iter, ['', '', None, True, False]) 
     289      self.makeExpandable(iter) 
    286290 
    287291    #remove previous dummy as now have other children  
     
    315319    self.append_column(tvc) 
    316320 
     321    self.next_children = False; 
    317322    #self.set_property('fixed-height-mode', True) # speed display 
    318323 
     
    322327 
    323328  def _onExpanded(self, treeview, iter, path): 
    324     self._expandLevel(iter) 
    325  
    326   def _expandLevel(self, iter): 
    327329    # don't repopulate if it has been filled before 
     330 #   print 'expanding %s' % path 
    328331    if self.get_model()[iter][ProgressiveTreeModel.COL_FILLED]: 
    329332      return 
    330333    # populate this level 
    331334    model = self.get_model() 
    332 #    self.set_model(None) # no display updates 
    333335    model.popLevel(iter) 
    334 #    self.set_model(model) 
    335    
    336   def get_selected_acc(self, selection=None): 
     336    self.next_children = True; 
     337   
     338  def _getSelection(self, selection=None): 
    337339    selection = selection or self.get_selection() 
    338340    model, iter = selection.get_selected() 
    339     if not iter: return None 
    340     return model[iter][ProgressiveTreeModel.COL_ACC] 
     341    if iter: 
     342      acc = model[iter][ProgressiveTreeModel.COL_ACC] 
     343    else: 
     344      acc = None 
     345    return (model, iter, acc) 
     346   
     347  def get_selected_acc(self, selection=None): 
     348    model, iter, acc = self._getSelection() 
     349    return acc 
    341350   
    342351  def get_acc_from_path(self, path): 
     
    344353 
    345354  def set_top_acc(self, acc): 
    346     self.set_model(None) # no display updates 
    347355    model = ProgressiveTreeModel(acc) 
    348356    model.popLevel(None) # top 
    349357    self.set_model(model) 
     358 
     359  def select(self, iter): 
     360    selection = self.get_selection() 
     361    selection.select_iter(iter) 
    350362 
    351363  def next(self): 
     
    353365    model, iter = selection.get_selected() 
    354366    if not iter:  
    355       nextiter = model.get_iter(0) 
     367      nextiter = model.get_iter_root() 
     368    elif self.next_children: 
     369      nextiter = model.iter_children(iter) 
     370      self.next_children = False; 
    356371    else: 
    357372      nextiter = model.iter_next(iter) 
    358     if not nextiter: 
    359       nextiter = model.get_iter_first() 
    360     selection.select_iter(nextiter) 
     373      if not nextiter: 
     374        nextiter = model.iter_parent(iter) 
     375        if not nextiter: 
     376          nextiter = model.get_iter_root() 
     377        else: 
     378          self.next_children = True; 
     379    self.select(nextiter) 
    361380      
    362381  def do_action(self): 
    363     acc = self.get_selected_acc() 
     382    model, iter, acc = self._getSelection() 
    364383    if not acc: return 
    365     if acc.isInteractive(): 
     384    path = model.get_path(iter) 
     385    print 'path', path 
     386    is_interactive = acc.isInteractive() 
     387    if is_interactive: 
    366388      try: 
    367389        action_if = acc.queryAction() 
    368390        action_if.doAction(0) 
     391        # assume menu for now 
     392        if self.row_expanded(path): 
     393          self.collapse_row(path) 
     394        else: 
     395          model.makeExpandable(iter) 
     396          model.popLevel(model.get_iter(path)) 
     397          self.expand_row(path, False) 
    369398      except: 
    370399        pass 
    371     else: 
    372       selection = self.get_selection() 
    373       model, iter = selection.get_selected() 
    374       path = model.get_path(iter) 
    375       is_expanded = self.row_expanded(path) 
    376       op = (self.colapse_row if is_expanded else self.expand_row) 
    377       op(path, False) 
     400       
     401    else:   
     402      if self.row_expanded(path): 
     403        self.collapse_row(path) 
     404      elif model.iter_has_child(iter): 
     405        self.expand_row(path, False) 
    378406 
    379407class Blinker(object):