Fix default selection in selectors
This commit is contained in:
parent
407588d338
commit
f15649a0f1
@ -130,30 +130,26 @@ class BaseSelector(ManagedWindow):
|
|||||||
"""
|
"""
|
||||||
Goto the correct row.
|
Goto the correct row.
|
||||||
"""
|
"""
|
||||||
try: # tree:
|
iter_ = self.model.get_iter_from_handle(handle)
|
||||||
path = None
|
if iter_:
|
||||||
node = self.model.get_node(handle)
|
if not (self.model.get_flags() & Gtk.TreeModelFlags.LIST_ONLY):
|
||||||
if node:
|
# Expand tree
|
||||||
parent_node = self.model.on_iter_parent(node)
|
parent_iter = self.model.iter_parent(iter_)
|
||||||
if parent_node:
|
if parent_iter:
|
||||||
parent_path = self.model.on_get_path(parent_node)
|
parent_path = self.model.get_path(parent_iter)
|
||||||
if parent_path:
|
if parent_path:
|
||||||
for i in range(len(parent_path)):
|
parent_path_list = parent_path.get_indices()
|
||||||
expand_path = tuple([x for x in parent_path[:i+1]])
|
for i in range(len(parent_path_list)):
|
||||||
|
expand_path = Gtk.TreePath(
|
||||||
|
tuple([x for x in parent_path_list[:i+1]]))
|
||||||
self.tree.expand_row(expand_path, False)
|
self.tree.expand_row(expand_path, False)
|
||||||
path = self.model.on_get_path(node)
|
|
||||||
except: # flat:
|
|
||||||
try:
|
|
||||||
path = self.model.on_get_path(handle)
|
|
||||||
except:
|
|
||||||
path = None
|
|
||||||
|
|
||||||
if path is not None:
|
# Select active object
|
||||||
|
path = self.model.get_path(iter_)
|
||||||
self.selection.unselect_all()
|
self.selection.unselect_all()
|
||||||
self.selection.select_path(path)
|
self.selection.select_path(path)
|
||||||
self.tree.scroll_to_cell(path, None, 1, 0.5, 0)
|
self.tree.scroll_to_cell(path, None, 1, 0.5, 0)
|
||||||
else:
|
else:
|
||||||
# not in list
|
|
||||||
self.selection.unselect_all()
|
self.selection.unselect_all()
|
||||||
|
|
||||||
def add_columns(self,tree):
|
def add_columns(self,tree):
|
||||||
|
Loading…
Reference in New Issue
Block a user