From 80779a35fa03c41c617604ea6d43b753bbcc7aa0 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 15 May 2017 17:02:06 +0100 Subject: [PATCH] Revert bugs #8785 and #9700 Expanding tree selectors by default caused performance issues. The expanded person selector also made it more difficult to select a specific person in some circumstances. GEPS 041 has been created to discuss a better selector design. --- .../editors/displaytabs/citationembedlist.py | 2 +- gramps/gui/selectors/baseselector.py | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gramps/gui/editors/displaytabs/citationembedlist.py b/gramps/gui/editors/displaytabs/citationembedlist.py index 8380a878f..10a8c31a2 100644 --- a/gramps/gui/editors/displaytabs/citationembedlist.py +++ b/gramps/gui/editors/displaytabs/citationembedlist.py @@ -154,7 +154,7 @@ class CitationEmbedList(EmbeddedList, DbGUIElement): def share_button_clicked(self, obj): SelectCitation = SelectorFactory('Citation') - sel = SelectCitation(self.dbstate, self.uistate, self.track, expand=False) + sel = SelectCitation(self.dbstate, self.uistate, self.track) object = sel.run() LOG.debug("selected object: %s" % object) # the object returned should either be a Source or a Citation diff --git a/gramps/gui/selectors/baseselector.py b/gramps/gui/selectors/baseselector.py index 726fca841..8e154a679 100644 --- a/gramps/gui/selectors/baseselector.py +++ b/gramps/gui/selectors/baseselector.py @@ -53,14 +53,13 @@ class BaseSelector(ManagedWindow): IMAGE = 2 def __init__(self, dbstate, uistate, track=[], filter=None, skip=set(), - show_search_bar = True, default=None, expand=True): + show_search_bar = True, default=None): """Set up the dialog with the dbstate and uistate, track of parent windows for ManagedWindow, initial filter for the model, skip with set of handles to skip in the view, and search_bar to show the SearchBar at the top or not. """ self.filter = (2, filter, False) - self.expand = expand # Set window title, some selectors may set self.title in their __init__ if not hasattr(self, 'title'): @@ -133,6 +132,18 @@ class BaseSelector(ManagedWindow): """ iter_ = self.model.get_iter_from_handle(handle) if iter_: + if not (self.model.get_flags() & Gtk.TreeModelFlags.LIST_ONLY): + # Expand tree + parent_iter = self.model.iter_parent(iter_) + if parent_iter: + parent_path = self.model.get_path(parent_iter) + if parent_path: + parent_path_list = parent_path.get_indices() + 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) + # Select active object path = self.model.get_path(iter_) self.selection.unselect_all() @@ -287,11 +298,7 @@ class BaseSelector(ManagedWindow): self.tree.set_search_column(search_col) self.setupcols = False - - if self.expand: - if not (self.model.get_flags() & Gtk.TreeModelFlags.LIST_ONLY): - self.tree.expand_all() - + def column_clicked(self, obj, data): if self.sort_col != data: self.sortorder = Gtk.SortType.ASCENDING