2005-04-06 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GenericFilter.py: Added HasSourceOf rule * src/plugins/FilterEditor.py: Added MySource combobox for selecting source IDs. svn: r4310
This commit is contained in:
parent
698beec5c1
commit
721af70faf
@ -1,3 +1,7 @@
|
||||
2005-04-06 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/GenericFilter.py: Added HasSourceOf rule
|
||||
* src/plugins/FilterEditor.py: Added MySource combobox for selecting source IDs.
|
||||
|
||||
2005-04-06 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* src/PedView.py: Truncate place names because they tend to be loooong.
|
||||
|
||||
|
@ -1973,6 +1973,48 @@ class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf):
|
||||
self.cache_sources()
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasSourceOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSourceOf(Rule):
|
||||
"""Rule that checks people that have a particular source."""
|
||||
|
||||
labels = [ _('Source ID:') ]
|
||||
|
||||
def prepare(self,db):
|
||||
self.db = db
|
||||
|
||||
def name(self):
|
||||
return 'Has source of'
|
||||
|
||||
def category(self):
|
||||
return _('Event filters')
|
||||
|
||||
def description(self):
|
||||
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
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GenericFilter
|
||||
@ -2144,6 +2186,7 @@ tasks = {
|
||||
unicode(_("Has the family event")) : HasFamilyEvent,
|
||||
unicode(_("Has the personal attribute")) : HasAttribute,
|
||||
unicode(_("Has the family attribute")) : HasFamilyAttribute,
|
||||
unicode(_("Has source of")) : HasSourceOf,
|
||||
unicode(_("Matches the filter named")) : MatchesFilter,
|
||||
unicode(_("Is spouse of filter match")) : IsSpouseOfFilterMatch,
|
||||
unicode(_("Is a sibling of filter match")) : IsSiblingOfFilterMatch,
|
||||
|
@ -133,6 +133,41 @@ class MyFilters(gtk.ComboBox):
|
||||
if val in self.flist:
|
||||
self.set_active(self.flist.index(val))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MySource - Combo box with list of sources with a standard interface
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MySource(gtk.ComboBox):
|
||||
|
||||
def __init__(self,db):
|
||||
gtk.ComboBox.__init__(self)
|
||||
self.db = db
|
||||
store = gtk.ListStore(str)
|
||||
self.set_model(store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
self.add_attribute(cell,'text',0)
|
||||
|
||||
self.slist = []
|
||||
for src_handle in self.db.get_source_handles(sort_handles=True):
|
||||
src = self.db.get_source_from_handle(src_handle)
|
||||
self.slist.append(src.get_gramps_id())
|
||||
store.append(row=[src.get_title()])
|
||||
|
||||
self.set_active(0)
|
||||
self.show()
|
||||
|
||||
def get_text(self):
|
||||
active = self.get_active()
|
||||
if active < 0:
|
||||
return ""
|
||||
return self.slist[active]
|
||||
|
||||
def set_text(self,val):
|
||||
if val in self.slist:
|
||||
self.set_active(self.slist.index(val))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MyPlaces - AutoCombo text entry with list of places attached. Provides
|
||||
@ -641,6 +676,8 @@ class EditRule:
|
||||
t = MyInteger(1,32)
|
||||
elif v == _('ID:'):
|
||||
t = MyID(self.db)
|
||||
elif v == _('Source ID:'):
|
||||
t = MySource(self.db)
|
||||
elif v == _('Filter name:'):
|
||||
t = MyFilters(self.filterdb.get_filters())
|
||||
elif _name2list.has_key(v1):
|
||||
|
Loading…
Reference in New Issue
Block a user