diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5175bdfa8..28a577aa5 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-11-30 Martin Hawlisch + * src/Filters/Rules/*: Add new Rule HasMarkerOf + * src/FilterEditor/_EditRule.py: Support MarkerType + * src/Filters/SideBar/_FamilySidebarFilter.py: Add MarkerType + * src/Filters/SideBar/_PersonSidebarFilter.py: Add MarkerType + 2006-11-29 Alex Roitman * src/GrampsWidgets.py (PlaceEntry.set_button): Dynamically set tooltips. diff --git a/gramps2/src/Filters/Rules/Family/_HasMarkerOf.py b/gramps2/src/Filters/Rules/Family/_HasMarkerOf.py new file mode 100644 index 000000000..edb6536db --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_HasMarkerOf.py @@ -0,0 +1,46 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id: _HasEvent.py 7607 2006-11-10 21:27:08Z loshawlos $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from Filters.Rules._HasMarkerBase import HasMarkerBase + +#------------------------------------------------------------------------- +# +# HasEvent +# +#------------------------------------------------------------------------- +class HasMarkerOf(HasMarkerBase): + """Rule that checks for a family with a particular marker""" + + name = _('Families with ') + description = _("Matches Families with a marker of a particular value") diff --git a/gramps2/src/Filters/Rules/Family/__init__.py b/gramps2/src/Filters/Rules/Family/__init__.py index a573366a7..9285aef27 100644 --- a/gramps2/src/Filters/Rules/Family/__init__.py +++ b/gramps2/src/Filters/Rules/Family/__init__.py @@ -39,6 +39,7 @@ from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf from _FamilyPrivate import FamilyPrivate from _HasAttribute import HasAttribute from _HasEvent import HasEvent +from _HasMarkerOf import HasMarkerOf from _MatchesFilter import MatchesFilter from _FatherHasNameOf import FatherHasNameOf from _FatherHasIdOf import FatherHasIdOf @@ -57,6 +58,7 @@ editor_rule_list = [ FamilyPrivate, HasEvent, HasAttribute, + HasMarkerOf, MatchesFilter, FatherHasNameOf, FatherHasIdOf, diff --git a/gramps2/src/Filters/Rules/Person/_HasMarkerOf.py b/gramps2/src/Filters/Rules/Person/_HasMarkerOf.py new file mode 100644 index 000000000..409f46aef --- /dev/null +++ b/gramps2/src/Filters/Rules/Person/_HasMarkerOf.py @@ -0,0 +1,46 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id: _HasEvent.py 7607 2006-11-10 21:27:08Z loshawlos $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from Filters.Rules._HasMarkerBase import HasMarkerBase + +#------------------------------------------------------------------------- +# +# HasEvent +# +#------------------------------------------------------------------------- +class HasMarkerOf(HasMarkerBase): + """Rule that checks for a person with a particular marker""" + + name = _('People with ') + description = _("Matches people with a marker of a particular value") diff --git a/gramps2/src/Filters/Rules/Person/__init__.py b/gramps2/src/Filters/Rules/Person/__init__.py index e56104b91..e37c5a6d9 100644 --- a/gramps2/src/Filters/Rules/Person/__init__.py +++ b/gramps2/src/Filters/Rules/Person/__init__.py @@ -48,6 +48,7 @@ from _HasSourceOf import HasSourceOf from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf from _HasUnknownGender import HasUnknownGender +from _HasMarkerOf import HasMarkerOf from _HaveAltFamilies import HaveAltFamilies from _HaveChildren import HaveChildren from _HavePhotos import HavePhotos @@ -119,6 +120,7 @@ editor_rule_list = [ HasAttribute, HasFamilyAttribute, HasSourceOf, + HasMarkerOf, HaveAltFamilies, HavePhotos, HaveChildren, diff --git a/gramps2/src/Filters/Rules/_HasMarkerBase.py b/gramps2/src/Filters/Rules/_HasMarkerBase.py new file mode 100644 index 000000000..d5d209d4c --- /dev/null +++ b/gramps2/src/Filters/Rules/_HasMarkerBase.py @@ -0,0 +1,55 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id: _HasEvent.py 6635 2006-05-13 03:53:06Z dallingham $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from RelLib import MarkerType +from Filters.Rules._Rule import Rule + +#------------------------------------------------------------------------- +# +# HasEvent +# +#------------------------------------------------------------------------- +class HasMarkerBase(Rule): + """Rule that checks for a person with a particular value""" + + + labels = [ _('Marker type:')] + name = _('Has marker of') + description = _("Matches markers of a partikular type") + category = _('General filters') + + def apply(self,db,obj): + specified_type = MarkerType() + specified_type.set_from_xml_str(self.list[0]) + return obj.get_marker() == specified_type diff --git a/gramps2/src/Filters/SideBar/_FamilySidebarFilter.py b/gramps2/src/Filters/SideBar/_FamilySidebarFilter.py index 2b8a3d80e..ceca1ab99 100644 --- a/gramps2/src/Filters/SideBar/_FamilySidebarFilter.py +++ b/gramps2/src/Filters/SideBar/_FamilySidebarFilter.py @@ -82,14 +82,22 @@ class FamilySidebarFilter(SidebarFilter): self.family_stub.set_relationship, self.family_stub.get_relationship) + self.filter_marker = RelLib.Family() + self.filter_marker.set_marker((RelLib.MarkerType.CUSTOM,'')) + self.mtype = gtk.ComboBoxEntry() + self.marker_menu = GrampsWidgets.MonitoredDataType( + self.mtype, + self.filter_marker.set_marker, + self.filter_marker.get_marker) + self.filter_note = gtk.Entry() self.filter_regex = gtk.CheckButton(_('Use regular expressions')) - self.generic = gtk.ComboBox() - cell = gtk.CellRendererText() - self.generic.pack_start(cell, True) - self.generic.add_attribute(cell, 'text', 0) + self.generic = gtk.ComboBox() + cell = gtk.CellRendererText() + self.generic.pack_start(cell, True) + self.generic.add_attribute(cell, 'text', 0) self.on_filters_changed('Family') self.add_text_entry(_('ID'), self.filter_id) @@ -98,6 +106,7 @@ class FamilySidebarFilter(SidebarFilter): self.add_text_entry(_('Child'), self.filter_child) self.add_entry(_('Relationship'), self.rtype) self.add_entry(_('Family Event'), self.etype) + self.add_entry(_('Marker'), self.mtype) self.add_text_entry(_('Family Note'), self.filter_note) self.add_entry(_('Custom filter'), self.generic) self.add_entry(None, self.filter_regex) @@ -110,6 +119,7 @@ class FamilySidebarFilter(SidebarFilter): self.filter_note.set_text('') self.etype.child.set_text('') self.rtype.child.set_text('') + self.mtype.child.set_text('') self.generic.set_active(0) def clicked(self, obj): @@ -123,10 +133,11 @@ class FamilySidebarFilter(SidebarFilter): note = unicode(self.filter_note.get_text()).strip() etype = self.filter_event.get_type().xml_str() rtype = self.family_stub.get_relationship().xml_str() + mtype = self.filter_marker.get_marker().xml_str() regex = self.filter_regex.get_active() - gen = self.generic.get_active() > 0 + gen = self.generic.get_active() > 0 - empty = not (gid or father or mother or child or note + empty = not (gid or father or mother or child or note or mtype or regex or etype or rtype or gen) if empty: generic_filter = None @@ -159,6 +170,10 @@ class FamilySidebarFilter(SidebarFilter): rule = HasRelType([rtype]) generic_filter.add_rule(rule) + if mtype: + rule = HasMarkerOf([mtype]) + generic_filter.add_rule(rule) + if note: if regex: rule = HasNoteRegexp([note]) @@ -166,12 +181,12 @@ class FamilySidebarFilter(SidebarFilter): rule = HasNoteMatchingSubstringOf([note]) generic_filter.add_rule(rule) - if self.generic.get_active() != 0: - model = self.generic.get_model() - iter = self.generic.get_active_iter() - obj = model.get_value(iter, 0) - rule = MatchesFilter([obj]) - generic_filter.add_rule(rule) + if self.generic.get_active() != 0: + model = self.generic.get_model() + iter = self.generic.get_active_iter() + obj = model.get_value(iter, 0) + rule = MatchesFilter([obj]) + generic_filter.add_rule(rule) return generic_filter diff --git a/gramps2/src/Filters/SideBar/_PersonSidebarFilter.py b/gramps2/src/Filters/SideBar/_PersonSidebarFilter.py index 0b5025580..6dd3e661a 100644 --- a/gramps2/src/Filters/SideBar/_PersonSidebarFilter.py +++ b/gramps2/src/Filters/SideBar/_PersonSidebarFilter.py @@ -65,12 +65,19 @@ class PersonSidebarFilter(SidebarFilter): self.filter_event = RelLib.Event() self.filter_event.set_type((RelLib.EventType.CUSTOM,'')) self.etype = gtk.ComboBoxEntry() - self.event_menu = GrampsWidgets.MonitoredDataType( self.etype, self.filter_event.set_type, self.filter_event.get_type) - + + self.filter_marker = RelLib.Person() + self.filter_marker.set_marker((RelLib.MarkerType.CUSTOM,'')) + self.mtype = gtk.ComboBoxEntry() + self.marker_menu = GrampsWidgets.MonitoredDataType( + self.mtype, + self.filter_marker.set_marker, + self.filter_marker.get_marker) + self.filter_note = gtk.Entry() self.filter_gender = gtk.combo_box_new_text() for i in [ _('any'), _('male'), _('female'), _('unknown') ]: @@ -79,10 +86,10 @@ class PersonSidebarFilter(SidebarFilter): self.filter_regex = gtk.CheckButton(_('Use regular expressions')) - self.generic = gtk.ComboBox() - cell = gtk.CellRendererText() - self.generic.pack_start(cell, True) - self.generic.add_attribute(cell, 'text', 0) + self.generic = gtk.ComboBox() + cell = gtk.CellRendererText() + self.generic.pack_start(cell, True) + self.generic.add_attribute(cell, 'text', 0) self.on_filters_changed('Person') self.add_text_entry(_('Name'), self.filter_name) @@ -91,6 +98,7 @@ class PersonSidebarFilter(SidebarFilter): self.add_text_entry(_('Birth date'), self.filter_birth) self.add_text_entry(_('Death date'), self.filter_death) self.add_entry(_('Event'), self.etype) + self.add_entry(_('Marker'), self.mtype) self.add_text_entry(_('Note'), self.filter_note) self.add_entry(_('Custom filter'), self.generic) self.add_entry(None, self.filter_regex) @@ -103,6 +111,7 @@ class PersonSidebarFilter(SidebarFilter): self.filter_note.set_text('') self.filter_gender.set_active(0) self.etype.child.set_text('') + self.mtype.child.set_text('') self.generic.set_active(0) def clicked(self, obj): @@ -114,12 +123,13 @@ class PersonSidebarFilter(SidebarFilter): birth = unicode(self.filter_birth.get_text()).strip() death = unicode(self.filter_death.get_text()).strip() etype = self.filter_event.get_type().xml_str() + mtype = self.filter_marker.get_marker().xml_str() note = unicode(self.filter_note.get_text()).strip() gender = self.filter_gender.get_active() regex = self.filter_regex.get_active() - gen = self.generic.get_active() > 0 + gen = self.generic.get_active() > 0 - empty = not (name or gid or birth or death or etype + empty = not (name or gid or birth or death or etype or mtype or note or gender or regex or gen) if empty: generic_filter = None @@ -146,6 +156,10 @@ class PersonSidebarFilter(SidebarFilter): else: generic_filter.add_rule(HasUnknownGender([])) + if mtype: + rule = HasMarkerOf([mtype]) + generic_filter.add_rule(rule) + if etype: rule = HasEvent([etype, '', '', '']) generic_filter.add_rule(rule) @@ -163,12 +177,12 @@ class PersonSidebarFilter(SidebarFilter): rule = HasNoteMatchingSubstringOf([note]) generic_filter.add_rule(rule) - if self.generic.get_active() != 0: - model = self.generic.get_model() - iter = self.generic.get_active_iter() - obj = model.get_value(iter, 0) - rule = MatchesFilter([obj]) - generic_filter.add_rule(rule) + if self.generic.get_active() != 0: + model = self.generic.get_model() + iter = self.generic.get_active_iter() + obj = model.get_value(iter, 0) + rule = MatchesFilter([obj]) + generic_filter.add_rule(rule) return generic_filter