From 0d92c1b7d592ceadb69210136cd08364d2ba84bb Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 16 Jan 2007 05:54:40 +0000 Subject: [PATCH] 2007-01-15 Don Allingham * src/DataViews/_PersonView.py: use watch cursor on node expand * src/GrampsDb/_ReadGedcom.py: handle empty repo instances * src/plugins/TestCaseGenerator.py: fix typo * src/DisplayState.py: manage watch cursors better (don't set twice) * src/DisplayModels/_PeopleModel.py: maintain backref hash table for quick access to iter to node mappings at the top level. svn: r7914 --- gramps2/ChangeLog | 8 ++++++++ gramps2/src/DataViews/_PersonView.py | 14 ++++++++++++++ gramps2/src/DisplayModels/_PeopleModel.py | 12 ++++++++---- gramps2/src/DisplayState.py | 7 ++++++- gramps2/src/GrampsDb/_ReadGedcom.py | 2 +- gramps2/src/plugins/TestcaseGenerator.py | 10 +++++----- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 706e751d9..773b403cb 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,11 @@ +2007-01-15 Don Allingham + * src/DataViews/_PersonView.py: use watch cursor on node expand + * src/GrampsDb/_ReadGedcom.py: handle empty repo instances + * src/plugins/TestCaseGenerator.py: fix typo + * src/DisplayState.py: manage watch cursors better (don't set twice) + * src/DisplayModels/_PeopleModel.py: maintain backref hash table for quick access + to iter to node mappings at the top level. + 2007-01-15 Martin Hawlisch * src/ViewManager.py: Switch pages during DnD; Set active sidebar button properly diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index d1afddf4a..d53d913c0 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -254,6 +254,12 @@ class PersonView(PageView.PersonNavView): """ return 'gramps-person' + def start_expand(self, *obj): + self.uistate.set_busy_cursor(True) + + def expanded(self, *obj): + self.uistate.set_busy_cursor(False) + def build_widget(self): """ Builds the interface and returns a gtk.Container type that @@ -274,6 +280,8 @@ class PersonView(PageView.PersonNavView): self.tree.set_headers_visible(True) self.tree.set_fixed_height_mode(True) self.tree.connect('key-press-event', self.key_press) + self.tree.connect('row-expanded', self.expanded) + self.tree.connect('test-expand-row', self.start_expand) scrollwindow = gtk.ScrolledWindow() scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) @@ -561,8 +569,14 @@ class PersonView(PageView.PersonNavView): pass def open_all_nodes(self, obj): + self.uistate.status_text(_("Updating display...")) + self.uistate.set_busy_cursor(True) + self.tree.expand_all() + self.uistate.set_busy_cursor(False) + self.uistate.modify_statusbar(self.dbstate) + def close_all_nodes(self, obj): self.tree.collapse_all() diff --git a/gramps2/src/DisplayModels/_PeopleModel.py b/gramps2/src/DisplayModels/_PeopleModel.py index dd1f50c08..2331a6bed 100644 --- a/gramps2/src/DisplayModels/_PeopleModel.py +++ b/gramps2/src/DisplayModels/_PeopleModel.py @@ -248,7 +248,6 @@ class PeopleModel(gtk.GenericTreeModel): """ Calculates the new path to node values for the model. """ - self.lru_data = LRU(_CACHE_SIZE) self.lru_name = LRU(_CACHE_SIZE) self.lru_bdate = LRU(_CACHE_SIZE) @@ -292,6 +291,11 @@ class PeopleModel(gtk.GenericTreeModel): self.iter2path = self.temp_iter2path self.path2iter = self.temp_path2iter self.sname_sub = self.temp_sname_sub + self.top_iter2path = {} + i = 0 + for item in self.top_path2iter: + self.top_iter2path[item] = i + i+=1 def on_get_flags(self): '''returns the GtkTreeModelFlags for this particular type of model''' @@ -304,10 +308,10 @@ class PeopleModel(gtk.GenericTreeModel): '''returns the tree path (a tuple of indices at the various levels) for a particular node.''' try: - return (self.top_path2iter.index(node), ) + return (self.top_iter2path[node], ) except: (surname, index) = self.iter2path[node] - return (self.top_path2iter.index(surname), index) + return (self.top_iter2path[surname], index) def is_visable(self, handle): return self.iter2path.has_key(handle) @@ -355,7 +359,7 @@ class PeopleModel(gtk.GenericTreeModel): def on_iter_next(self, node): '''returns the next node at this level of the tree''' try: - path = self.top_path2iter.index(node) + path = self.top_iter2path[node] if path+1 == len(self.top_path2iter): return None return self.top_path2iter[path+1] diff --git a/gramps2/src/DisplayState.py b/gramps2/src/DisplayState.py index cd84b07c0..e9e53c07e 100644 --- a/gramps2/src/DisplayState.py +++ b/gramps2/src/DisplayState.py @@ -258,7 +258,8 @@ class DisplayState(GrampsDb.GrampsDBCallback): } def __init__(self, window, status, progress, warnbtn, uimanager): - + + self.busy = False self.uimanager = uimanager self.window = window GrampsDb.GrampsDBCallback.__init__(self) @@ -306,6 +307,10 @@ class DisplayState(GrampsDb.GrampsDBCallback): self.phistory.clear() def set_busy_cursor(self,value): + if value == self.busy: + return + else: + self.busy = value if value: self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) else: diff --git a/gramps2/src/GrampsDb/_ReadGedcom.py b/gramps2/src/GrampsDb/_ReadGedcom.py index 7064f1270..3faf0f719 100644 --- a/gramps2/src/GrampsDb/_ReadGedcom.py +++ b/gramps2/src/GrampsDb/_ReadGedcom.py @@ -957,7 +957,7 @@ class GedcomParser(UpdateCallback): self.ignore_sub_junk(level+1) def func_source_repo(self, matches, source, level): - if matches[2][0] == '@': + if matches[2] and matches[2][0] == '@': gid = matches[2][1:-1] repo = self.find_or_create_repository(gid) else: diff --git a/gramps2/src/plugins/TestcaseGenerator.py b/gramps2/src/plugins/TestcaseGenerator.py index a5249afe8..bbc82bb64 100644 --- a/gramps2/src/plugins/TestcaseGenerator.py +++ b/gramps2/src/plugins/TestcaseGenerator.py @@ -722,27 +722,27 @@ class TestcaseGenerator(Tool.Tool): if not ndate: ndate = RelLib.Date() ndate.set_as_text("DateParser None") - person.set_marker(RelLib.MarkerType.TODO) + person.set_marker(RelLib.MarkerType.TODO_TYPE) else: person.set_marker(RelLib.MarkerType.COMPLETE) except: ndate = RelLib.Date() ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),)) - person.set_marker(RelLib.MarkerType.TODO) + person.set_marker(RelLib.MarkerType.TODO_TYPE) except: ndate = RelLib.Date() ndate.set_as_text("DateDisplay Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),)) - person.set_marker(RelLib.MarkerType.TODO) + person.set_marker(RelLib.MarkerType.TODO_TYPE) if dateval.get_modifier() != RelLib.Date.MOD_TEXTONLY \ and ndate.get_modifier() == RelLib.Date.MOD_TEXTONLY: # parser was unable to correctly parse the string ndate.set_as_text( "TEXTONLY: "+ndate.get_text()) - person.set_marker(RelLib.MarkerType.TODO) + person.set_marker(RelLib.MarkerType.TODO_TYPE) if dateval.get_modifier() == RelLib.Date.MOD_TEXTONLY \ and dateval.get_text().count("Traceback") \ and person.get_marker() == RelLib.MarkerType.COMPLETE: - person.set_marker(RelLib.MarkerType.TODO) + person.set_marker(RelLib.MarkerType.TODO_TYPE) devent = RelLib.Event() devent.set_type(RelLib.EventType.DEATH)