From 571ff74418b4a807c9af01ac36e23757f72fd59c Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Fri, 8 Apr 2005 10:49:26 +0000 Subject: [PATCH] * src/gramps_main.py: Added "Invert" checkbox for person filter; Fix "active-changed" signals to not cause Tracebacks. * src/gramps.glade: Added "Invert" checkbox for person filter * src/PeopleView.py (build_tree): Pass Invert state for Filter to PeopleModel * src/PeopleModel.py: Enable invertation of filter result svn: r4323 --- gramps2/ChangeLog | 8 +++++++- gramps2/src/PeopleModel.py | 5 ++++- gramps2/src/PeopleView.py | 3 ++- gramps2/src/gramps.glade | 19 +++++++++++++++++++ gramps2/src/gramps_main.py | 5 +++-- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index bc1f3c74e..38a4acb30 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,6 +1,12 @@ -2005-04-08 Richard Taylor +2005-04-08 Martin Hawlisch * src/Utils.py (probably_alive): Added two more checks for birth and death year + * src/gramps_main.py: Added "Invert" checkbox for person filter; + Fix "active-changed" signals to not cause Tracebacks. + * src/gramps.glade: Added "Invert" checkbox for person filter + * src/PeopleView.py (build_tree): Pass Invert state for Filter to PeopleModel + * src/PeopleModel.py: Enable invertation of filter result + 2005-04-08 Richard Taylor * src/Utils.py (probably_alive): fix some bugs and added checking of ancestors. diff --git a/gramps2/src/PeopleModel.py b/gramps2/src/PeopleModel.py index 130a52cbf..5122cfed0 100644 --- a/gramps2/src/PeopleModel.py +++ b/gramps2/src/PeopleModel.py @@ -69,12 +69,13 @@ _CHANGE_COL= 21 #------------------------------------------------------------------------- class PeopleModel(gtk.GenericTreeModel): - def __init__(self,db,data_filter=None): + def __init__(self,db,data_filter=None,invert_result=False): gtk.GenericTreeModel.__init__(self) self.db = db self.visible = {} self.top_visible = {} + self.invert_result = invert_result self.rebuild_data(data_filter) def rebuild_data(self,data_filter=None,skip=None): @@ -96,6 +97,8 @@ class PeopleModel(gtk.GenericTreeModel): if data_filter: handle_list = self.db.get_person_handles(sort_handles=False) keys = data_filter.apply(self.db,handle_list) + if self.invert_result: + keys = [k for k in handle_list if k not in keys] del handle_list else: keys = self.db.get_person_handles(sort_handles=False) diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index efe84a795..26f32fd5c 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -169,7 +169,8 @@ class PeopleView: def build_tree(self): self.person_model = PeopleModel.PeopleModel(self.parent.db, - self.DataFilter) + self.DataFilter, + self.parent.filter_invert.get_active()) self.person_tree.set_model(self.person_model) def blist(self, store, path, node, id_list): diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index af7e7d30f..8f814943c 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1391,6 +1391,25 @@ + + + True + True + Invert + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + True diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index c62bbcb28..84dd8fce4 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -110,7 +110,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): __signals__ = { 'database-changed' : (GrampsDbBase.GrampsDbBase,), - 'active-changed' : (unicode,), + 'active-changed' : (str,), } def __init__(self,args): @@ -291,6 +291,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.toolbardock = self.gtop.get_widget("dockitem2") self.filter_text = self.gtop.get_widget('filter') self.filter_label= self.gtop.get_widget('filter_label') + self.filter_invert= self.gtop.get_widget('filter_invert') self.qual_label = self.gtop.get_widget("qual") self.child_type = self.gtop.get_widget("childtype") self.spouse_tab = self.gtop.get_widget("lab_or_list") @@ -1452,7 +1453,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.set_buttons(0) self.active_person = None self.modify_statusbar() - self.emit('active-changed',(None,)) + self.emit('active-changed',('',)) elif (self.active_person == None or person.get_handle() != self.active_person.get_handle()): self.active_person = self.db.get_person_from_handle(person.get_handle())