Changeset 68
- Timestamp:
- 11/06/07 19:02:26
- Files:
-
- action_groups/trunk/action_tree.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
action_groups/trunk/action_tree.py
r67 r68 275 275 t = time() - t 276 276 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 278 284 def _appendChild(self, parent_iter, acc): 279 285 iter = self.append(parent_iter, … … 281 287 282 288 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) 286 290 287 291 #remove previous dummy as now have other children … … 315 319 self.append_column(tvc) 316 320 321 self.next_children = False; 317 322 #self.set_property('fixed-height-mode', True) # speed display 318 323 … … 322 327 323 328 def _onExpanded(self, treeview, iter, path): 324 self._expandLevel(iter)325 326 def _expandLevel(self, iter):327 329 # don't repopulate if it has been filled before 330 # print 'expanding %s' % path 328 331 if self.get_model()[iter][ProgressiveTreeModel.COL_FILLED]: 329 332 return 330 333 # populate this level 331 334 model = self.get_model() 332 # self.set_model(None) # no display updates333 335 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): 337 339 selection = selection or self.get_selection() 338 340 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 341 350 342 351 def get_acc_from_path(self, path): … … 344 353 345 354 def set_top_acc(self, acc): 346 self.set_model(None) # no display updates347 355 model = ProgressiveTreeModel(acc) 348 356 model.popLevel(None) # top 349 357 self.set_model(model) 358 359 def select(self, iter): 360 selection = self.get_selection() 361 selection.select_iter(iter) 350 362 351 363 def next(self): … … 353 365 model, iter = selection.get_selected() 354 366 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; 356 371 else: 357 372 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) 361 380 362 381 def do_action(self): 363 acc = self.get_selected_acc()382 model, iter, acc = self._getSelection() 364 383 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: 366 388 try: 367 389 action_if = acc.queryAction() 368 390 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) 369 398 except: 370 399 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) 378 406 379 407 class Blinker(object):
