From ad39f6be256fe0f1d9eeae712f92650676e7357d Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Wed, 6 Apr 2005 20:26:15 +0000 Subject: [PATCH] * src/gramps.glade: People View: Add label for filter text input field. * src/GenericFilter.py (ProbablyAlive): Add check for input parameter, (HasSourceOf): get handle only once, removed unused code. * src/gramps_main.py: Show label for filter input field. svn: r4313 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/GenericFilter.py | 33 +++++++++++---------------------- gramps2/src/gramps.glade | 21 +++++++++++++++++++++ gramps2/src/gramps_main.py | 6 +++++- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 48ae37512..837904946 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-04-06 Martin Hawlisch + * src/gramps.glade: People View: Add label for filter text input field. + * src/GenericFilter.py (ProbablyAlive): Add check for input parameter, + (HasSourceOf): get handle only once, removed unused code. + * src/gramps_main.py: Show label for filter input field. + 2005-04-06 Richard Taylor * src/GenericFilter.py: added a current year parameter to probably alive rule. * src/Utils.py: added a current year parameter to probably alive function. diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index 7bfa77c98..7092a7932 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -1724,7 +1724,14 @@ class FamilyWithIncompleteEvent(Rule): class ProbablyAlive(Rule): """People probably alive""" - labels = ["On year"] + labels = [_("On year:")] + + def prepare(self,db): + try: + self.current_year = int(self.list[0]) + except: + self.current_year = None + print self.current_year def name(self): return 'People probably alive' @@ -1737,12 +1744,8 @@ class ProbablyAlive(Rule): def apply(self,db,p_id): - if len(self.list) == 0: - current_year = None - else: - current_year = int(self.list[0]) p = db.get_person_from_handle(p_id) - return probably_alive(p,db,current_year) + return probably_alive(p,db,self.current_year) #------------------------------------------------------------------------- # "People marked private" @@ -1988,7 +1991,7 @@ class HasSourceOf(Rule): labels = [ _('Source ID:') ] def prepare(self,db): - self.db = db + self.source_handle = db.get_source_from_gramps_id(self.list[0]).get_handle() def name(self): return 'Has source of' @@ -2000,23 +2003,9 @@ class HasSourceOf(Rule): return _('Matches people who have a particular source') def apply(self,db,p_id): - if not self.list[0]: - return False - p = self.db.get_person_from_handle(p_id) - return p.has_source_reference( - self.db.get_source_from_gramps_id(self.list[0]).get_handle()) - -## if len(p.get_source_references()) > 0: -## for src in p.get_source_references(): - -## if self.list[0] == \ -## self.db.get_source_from_handle( -## src.get_base_handle()).get_gramps_id(): -## return True - -## return False + return p.has_source_reference( self.source_handle) #------------------------------------------------------------------------- diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 637bb3cca..af7e7d30f 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1351,6 +1351,27 @@ + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + True diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 3730348a0..10795b8b2 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -289,6 +289,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.toolbar = self.gtop.get_widget("toolbar1") 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.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") @@ -953,7 +954,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): all.add_rule(GenericFilter.FamilyWithIncompleteEvent([])) filter_list.append(all) - all = GenericFilter.GenericFilter() + all = GenericFilter.ParamFilter() all.set_name(_("People probably alive")) all.add_rule(GenericFilter.ProbablyAlive([])) filter_list.append(all) @@ -1604,9 +1605,12 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): if qual: self.filter_text.show() self.filter_text.set_sensitive(1) + self.filter_label.show() + self.filter_label.set_text(mime_filter.get_rules()[0].labels[0]) else: self.filter_text.hide() self.filter_text.set_sensitive(0) + self.filter_label.hide() def new_after_edit(self,epo,val): self.change_active_person(epo.person)