objectselector work.

svn: r7947
This commit is contained in:
Richard Taylor 2007-01-21 21:23:06 +00:00
parent e11d71e273
commit ef7f1ffa65
6 changed files with 236 additions and 339 deletions

View File

@ -1,3 +1,9 @@
2007-01-21 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* ObjectSelector/_FilterFrameBase.py, ObjectSelector/_ObjectSelectorWindow.py,
ObjectSelector/_FamilyFilterFrame.py, ObjectSelector/_PersonPreviewFrame.py,
ObjectSelector/_PersonFilterFrame.py: refactoring and simplification of
filter widgets.
2007-01-20 Don Allingham <don@gramps-project.org> 2007-01-20 Don Allingham <don@gramps-project.org>
* src/DisplayModels/_PeopleModel.py: save current filter for rebuild (#838) * src/DisplayModels/_PeopleModel.py: save current filter for rebuild (#838)
* src/BaseDoc.py: save/load paragraph description (#850) * src/BaseDoc.py: save/load paragraph description (#850)

View File

@ -35,107 +35,38 @@ class FamilyFilterFrame(FilterFrameBase):
__default_border_width = 5 __default_border_width = 5
def __init__(self,dbstate,filter_spec=None,label="Filter"): def __init__(self,filter_spec=None,label="Filter"):
FilterFrameBase.__init__(self,filter_spec,label) FilterFrameBase.__init__(self,filter_spec,label)
# Gramps ID # Gramps ID
id_check = gtk.CheckButton() self._id_check,self._id_label,self._id_edit = \
id_label = gtk.Label("Gramps ID") self.make_text_widget("Gramps ID")
id_label.set_alignment(xalign=0,yalign=0.5)
id_edit = gtk.Entry()
id_edit.set_sensitive(False)
id_check.connect('toggled',lambda b: id_edit.set_sensitive(id_check.get_active()))
# Name # Name
name_check = gtk.CheckButton() self._name_check,self._name_label,self._name_edit = \
name_label = gtk.Label("Name") self.make_text_widget("Name")
name_label.set_alignment(xalign=0,yalign=0.5)
name_edit = gtk.Entry()
name_edit.set_sensitive(False)
name_check.connect('toggled',lambda b: name_edit.set_sensitive(name_check.get_active()))
# Mar # Mar
mar_check = gtk.CheckButton() self._mar_check, self._m_edit, \
mar_check.set_alignment(xalign=0,yalign=0) self._m_before, self._m_after, \
self._m_unknown = self.make_year_widget("Marriage Year")
m_label = gtk.Label("Marriage Year")
m_label.set_alignment(xalign=0,yalign=0)
m_edit = IntEdit()
m_edit.set_sensitive(False)
m_before = gtk.RadioButton(group=None,label="Before")
m_before.set_sensitive(False)
m_after = gtk.RadioButton(m_before,"After")
m_after.set_sensitive(False)
m_before.set_active(True)
m_unknown = gtk.CheckButton("Include Unknown")
m_unknown.set_sensitive(False)
m_unknown.set_active(True)
mar_check.connect('toggled',lambda b: m_edit.set_sensitive(mar_check.get_active()))
mar_check.connect('toggled',lambda b: m_before.set_sensitive(mar_check.get_active()))
mar_check.connect('toggled',lambda b: m_after.set_sensitive(mar_check.get_active()))
mar_check.connect('toggled',lambda b: m_unknown.set_sensitive(mar_check.get_active()))
m_inner_box = gtk.HBox()
m_inner_box.pack_start(m_before)
m_inner_box.pack_start(m_after)
# Filter # Filter
filter_check = gtk.CheckButton() default_filters = []
filter_label = gtk.Label("Filter")
filter_label.set_alignment(xalign=0,yalign=0.5)
filter_combo = gtk.combo_box_new_text() # don't currently support filters that need an attribute.
filter_combo.append_text("Male") filters = [ filter for filter in default_filters if \
filter_combo.append_text("Female") not hasattr(filter,'labels') or len(filter.labels) == 0 ]
filter_combo.append_text("Unknown")
filter_combo.set_active(2)
filter_combo.set_sensitive(False)
self._filter_list = gtk.ListStore(str,object)
filter_check.connect('toggled',lambda b: filter_combo.set_sensitive(filter_check.get_active())) for filter in filters:
self._filter_list.append([filter.name,filter])
# table layout self._filter_check,self._filter_label,self._filter_combo = \
self.make_combo_widget("Filter",self._filter_list)
self._reset_widgets()
current_row = 0
self._table.attach(id_check,self._check_col,self._check_col+1,current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(id_label,self._label_col,self._label_col+1,current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(id_edit,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(name_check,self._check_col,self._check_col+1,current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(name_label,self._label_col,self._label_col+1,current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(name_edit,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(mar_check,self._check_col,self._check_col+1,current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(m_label,self._label_col,self._label_col+1,current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(m_edit,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(m_inner_box,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(m_unknown,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(filter_check,self._check_col,self._check_col+1,current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(filter_label,self._label_col,self._label_col+1,current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(filter_combo,self._control_col,self._control_col+1,current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
if filter_spec is not None: if filter_spec is not None:
self._set_filter(filter_spec) self._set_filter(filter_spec)

View File

@ -24,7 +24,6 @@ import gtk
import gobject import gobject
from GrampsWidgets import IntEdit from GrampsWidgets import IntEdit
from Filters import GenericFilter
class FilterFrameBase(gtk.Frame): class FilterFrameBase(gtk.Frame):
@ -44,6 +43,12 @@ class FilterFrameBase(gtk.Frame):
def __init__(self,filter_spec=None,label="Filter"): def __init__(self,filter_spec=None,label="Filter"):
gtk.Frame.__init__(self,label) gtk.Frame.__init__(self,label)
self._checkboxes = []
self._active_widgets = []
self._current_row = 0
self._filter_spec = filter_spec self._filter_spec = filter_spec
align = gtk.Alignment() align = gtk.Alignment()
@ -90,25 +95,141 @@ class FilterFrameBase(gtk.Frame):
self.add(align) self.add(align)
def _reset_widgets(self):
for widget in self._active_widgets:
widget.set_sensitive(False)
for check in self._checkboxes:
check.set_active(False)
def on_clear(self,button=None):
self._reset_widgets()
self.emit('clear-filter')
def make_text_widget(self,widget_label):
"""create a text edit widget with a label and check box."""
check_col=self._check_col
label_col=self._label_col
control_col=self._control_col
check = gtk.CheckButton()
self._checkboxes.append(check)
label = gtk.Label(widget_label)
label.set_alignment(xalign=0,yalign=0.5)
edit = gtk.Entry()
self._active_widgets.append(edit)
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
self._table.attach(check,check_col,check_col+1,
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
self._table.attach(label,label_col,label_col+1,
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(edit,control_col,control_col+1,
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._current_row += 1
return(check,label,edit)
def make_combo_widget(self,widget_label,list_model):
"""create a combo widget with a label and check box."""
check_col=self._check_col
label_col=self._label_col
control_col=self._control_col
check = gtk.CheckButton()
self._checkboxes.append(check)
label = gtk.Label(widget_label)
label.set_alignment(xalign=0,yalign=0.5)
combo = gtk.ComboBox(list_model)
self._active_widgets.append(combo)
label_cell = gtk.CellRendererText()
combo.pack_start(label_cell, True)
combo.add_attribute(label_cell, 'text', 0)
combo.set_active(2)
check.connect('toggled',lambda b: combo.set_sensitive(check.get_active()))
self._table.attach(check,check_col,check_col+1,
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
self._table.attach(label,label_col,label_col+1,
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(combo,control_col,control_col+1,
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._current_row += 1
return (check,label,combo)
def make_year_widget(self,widget_label):
"""Create a widget with a year edit entry, a before and after check box.
Including a check box to enable and disable all the widgets."""
check_col=self._check_col
label_col=self._label_col
control_col=self._control_col
check = gtk.CheckButton()
check.set_alignment(xalign=0,yalign=0)
self._checkboxes.append(check)
label = gtk.Label(widget_label)
label.set_alignment(xalign=0,yalign=0)
edit = IntEdit()
self._active_widgets.append(edit)
before = gtk.RadioButton(group=None,label="Before")
self._active_widgets.append(before)
after = gtk.RadioButton(before,"After")
self._active_widgets.append(after)
before.set_active(True)
unknown = gtk.CheckButton("Include Unknown")
self._active_widgets.append(unknown)
unknown.set_active(False)
check.connect('toggled',lambda b: edit.set_sensitive(check.get_active()))
check.connect('toggled',lambda b: before.set_sensitive(check.get_active()))
check.connect('toggled',lambda b: after.set_sensitive(check.get_active()))
#check.connect('toggled',lambda b: unknown.set_sensitive(check.get_active()))
inner_box = gtk.HBox()
inner_box.pack_start(before)
inner_box.pack_start(after)
self._table.attach(check,check_col,check_col+1,
self._current_row,self._current_row+1,xoptions=False,yoptions=False)
self._table.attach(label,label_col,label_col+1,
self._current_row,self._current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(edit,control_col,control_col+1,
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._current_row +=1
self._table.attach(inner_box,control_col,control_col+1,
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._current_row +=1
self._table.attach(unknown,control_col,control_col+1,
self._current_row,self._current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._current_row +=1
return (check, edit, before, after, unknown)
def on_apply(self,button): def on_apply(self,button):
"""Build a GenericFilter object from the settings in the filter controls and """Build a GenericFilter object from the settings in the filter controls and
emit a 'apply-filter' signal with the GenericFilter object as the parameter.""" emit a 'apply-filter' signal with the GenericFilter object as the parameter."""
raise NotImplementedError("subclass of FilterFrameBase must implement on_apply") raise NotImplementedError("subclass of FilterFrameBase must implement on_apply")
def on_clear(self,button):
"""Clear all the filter widgets and emit a 'clear-filter' signal."""
raise NotImplementedError("subclass of FilterFrameBase must implement on_apply")
if gtk.pygtk_version < (2,8,0): if gtk.pygtk_version < (2,8,0):
gobject.type_register(FilterFrameBase) gobject.type_register(FilterFrameBase)
if __name__ == "__main__":
w = gtk.Window()
f = PersonFilterFrame()
w.add(f)
w.show_all()
gtk.main()

View File

@ -156,6 +156,7 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
self.__class__.__default_border_width) self.__class__.__default_border_width)
try:
person_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.image_dir,"person.svg")) person_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.image_dir,"person.svg"))
flist_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.image_dir,"flist.svg")) flist_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(const.image_dir,"flist.svg"))
@ -165,6 +166,18 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
ObjectTypes.FAMILY: [flist_pixbuf,'Families',ObjectTypes.FAMILY], ObjectTypes.FAMILY: [flist_pixbuf,'Families',ObjectTypes.FAMILY],
ObjectTypes.EVENT: [person_pixbuf,'Events',ObjectTypes.EVENT]} ObjectTypes.EVENT: [person_pixbuf,'Events',ObjectTypes.EVENT]}
self._object_type_column = 2
except gobject.GError:
self._tool_list = gtk.ListStore(str,int)
d={ObjectTypes.PERSON: ['People',ObjectTypes.PERSON],
ObjectTypes.FAMILY: ['Families',ObjectTypes.FAMILY],
ObjectTypes.EVENT: ['Events',ObjectTypes.EVENT]}
self._object_type_column = 1
for object_type in self._object_list: for object_type in self._object_list:
self._tool_list.append(d[object_type]) self._tool_list.append(d[object_type])
@ -300,7 +313,7 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow):
store = self._tool_list store = self._tool_list
it = store.get_iter_first() it = store.get_iter_first()
while it: while it:
if store.get(it, 2)[0] == selected_object_type: if store.get(it, self._object_type_column)[0] == selected_object_type:
break break
it = store.iter_next(it) it = store.iter_next(it)
@ -334,7 +347,6 @@ if gtk.pygtk_version < (2,8,0):
if __name__ == "__main__": if __name__ == "__main__":
import GrampsDb import GrampsDb
import ViewManager import ViewManager
import const import const
@ -369,10 +381,15 @@ if __name__ == "__main__":
dbstate.db = db dbstate.db = db
def prof_fun():
global dbstate, vm
w = ObjectSelectorWindow(dbstate=dbstate, w = ObjectSelectorWindow(dbstate=dbstate,
uistate=vm.uistate, uistate=vm.uistate,
track=[],
filter_spec=None,
default_object_type = ObjectTypes.PERSON, default_object_type = ObjectTypes.PERSON,
object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY]) object_list=[ObjectTypes.PERSON,])
#object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY])
w.show() w.show()
w.connect("destroy", gtk.main_quit) w.connect("destroy", gtk.main_quit)
@ -382,3 +399,7 @@ if __name__ == "__main__":
w.connect('add-object',add) w.connect('add-object',add)
gtk.main() gtk.main()
prof_fun()
import profile
profile.run("prof_fun()",'profile.dat')

View File

@ -27,7 +27,6 @@ from logging import getLogger
log = getLogger(".ObjectSelector") log = getLogger(".ObjectSelector")
from GrampsWidgets import IntEdit
from _FilterFrameBase import FilterFrameBase from _FilterFrameBase import FilterFrameBase
from Filters import GenericFilter, Rules from Filters import GenericFilter, Rules
import RelLib import RelLib
@ -39,123 +38,48 @@ class PersonFilterFrame(FilterFrameBase):
__gsignals__ = { __gsignals__ = {
} }
# This is used when the widgets are packed into the ObjectSelector
# frames.
__default_border_width = 5 __default_border_width = 5
def __init__(self,filter_spec=None,label="Filter"): def __init__(self,filter_spec=None,label="Filter"):
FilterFrameBase.__init__(self,filter_spec,label) FilterFrameBase.__init__(self,filter_spec,label)
self._checkboxes = [] # Build the filter widgets, the make_* methods are
# in the FilterFrameBase base class.
# Gramps ID # Gramps ID
self._id_check = gtk.CheckButton() self._id_check,self._id_label,self._id_edit = \
self._checkboxes.append(self._id_check) self.make_text_widget("Gramps ID")
id_label = gtk.Label("Gramps ID")
id_label.set_alignment(xalign=0,yalign=0.5)
self._id_edit = gtk.Entry()
self._id_check.connect('toggled',lambda b: self._id_edit.set_sensitive(self._id_check.get_active()))
# Name # Name
self._name_check = gtk.CheckButton() self._name_check,self._name_label,self._name_edit = \
self._checkboxes.append(self._name_check) self.make_text_widget("Name")
name_label = gtk.Label("Name")
name_label.set_alignment(xalign=0,yalign=0.5)
self._name_edit = gtk.Entry()
self._name_check.connect('toggled',lambda b: self._name_edit.set_sensitive(self._name_check.get_active()))
# Gender # Gender
self._gender_check = gtk.CheckButton()
self._checkboxes.append(self._gender_check)
gender_label = gtk.Label("Gender")
gender_label.set_alignment(xalign=0,yalign=0.5)
self._gender_list = gtk.ListStore(str,int)
genders=[[_("Male"),RelLib.Person.MALE], genders=[[_("Male"),RelLib.Person.MALE],
[_("Female"),RelLib.Person.FEMALE], [_("Female"),RelLib.Person.FEMALE],
[_("Unknown"),RelLib.Person.UNKNOWN]] [_("Unknown"),RelLib.Person.UNKNOWN]]
for gender in genders: self._gender_list = gtk.ListStore(str,int)
self._gender_list.append(gender)
self._gender_combo = gtk.ComboBox(self._gender_list) for entry in genders:
self._gender_list.append(entry)
label_cell = gtk.CellRendererText() self._gender_check,self._gender_label, self._gender_combo = \
self.make_combo_widget("Gender",self._gender_list)
self._gender_combo.pack_start(label_cell, True)
self._gender_combo.add_attribute(label_cell, 'text', 0)
self._gender_combo.set_active(2)
self._gender_check.connect('toggled',lambda b: self._gender_combo.set_sensitive(self._gender_check.get_active()))
# Birth # Birth
self._birth_check = gtk.CheckButton() self._birth_check, self._b_edit, \
self._birth_check.set_alignment(xalign=0,yalign=0) self._b_before, self._b_after, \
self._checkboxes.append(self._birth_check) self._b_unknown = self.make_year_widget("Birth Year")
b_label = gtk.Label("Birth Year")
b_label.set_alignment(xalign=0,yalign=0)
self._b_edit = IntEdit()
self._b_before = gtk.RadioButton(group=None,label="Before")
self._b_after = gtk.RadioButton(self._b_before,"After")
self._b_before.set_active(True)
self._b_unknown = gtk.CheckButton("Include Unknown")
self._b_unknown.set_active(False)
self._birth_check.connect('toggled',lambda b: self._b_edit.set_sensitive(self._birth_check.get_active()))
self._birth_check.connect('toggled',lambda b: self._b_before.set_sensitive(self._birth_check.get_active()))
self._birth_check.connect('toggled',lambda b: self._b_after.set_sensitive(self._birth_check.get_active()))
#self._birth_check.connect('toggled',lambda b: self._b_unknown.set_sensitive(self._birth_check.get_active()))
self._b_inner_box = gtk.HBox()
self._b_inner_box.pack_start(self._b_before)
self._b_inner_box.pack_start(self._b_after)
# Death # Death
self._death_check, self._d_edit, \
self._death_check = gtk.CheckButton() self._d_before, self._d_after, \
self._checkboxes.append(self._death_check) self._d_unknown = self.make_year_widget("Death Year")
d_label = gtk.Label("Death Year")
d_label.set_alignment(xalign=0,yalign=0)
self._d_edit = IntEdit()
self._d_before = gtk.RadioButton(group=None,label="Before")
self._d_after = gtk.RadioButton(self._d_before,"After")
self._d_before.set_active(True)
self._d_unknown = gtk.CheckButton("Include Unknown")
self._d_unknown.set_active(False)
self._death_check.connect('toggled',lambda b: self._d_edit.set_sensitive(self._death_check.get_active()))
self._death_check.connect('toggled',lambda b: self._d_before.set_sensitive(self._death_check.get_active()))
self._death_check.connect('toggled',lambda b: self._d_after.set_sensitive(self._death_check.get_active()))
#self._death_check.connect('toggled',lambda b: self._d_unknown.set_sensitive(self._death_check.get_active()))
d_inner_box = gtk.HBox()
d_inner_box.pack_start(self._d_before)
d_inner_box.pack_start(self._d_after)
# Filter # Filter
self._filter_check = gtk.CheckButton()
self._checkboxes.append(self._filter_check)
filter_label = gtk.Label("Filter")
filter_label.set_alignment(xalign=0,yalign=0.5)
default_filters = [ default_filters = [
Rules.Person.Everyone, Rules.Person.Everyone,
Rules.Person.IsFemale, Rules.Person.IsFemale,
@ -182,125 +106,23 @@ class PersonFilterFrame(FilterFrameBase):
Rules.Person.IsFemale, Rules.Person.IsFemale,
] ]
self._filter_list = gtk.ListStore(object,str)
for filter in default_filters:
if not hasattr(filter,'labels') or len(filter.labels) == 0:
# don't currently support filters that need an attribute. # don't currently support filters that need an attribute.
self._filter_list.append([filter,filter.name]) filters = [ filter for filter in default_filters if \
not hasattr(filter,'labels') or len(filter.labels) == 0 ]
self._filter_combo = gtk.ComboBox(self._filter_list) self._filter_list = gtk.ListStore(str,object)
label_cell = gtk.CellRendererText() for filter in filters:
self._filter_list.append([filter.name,filter])
self._filter_combo.pack_start(label_cell, True) self._filter_check,self._filter_label,self._filter_combo = \
self._filter_combo.add_attribute(label_cell, 'text', 1) self.make_combo_widget("Filter",self._filter_list)
self._filter_combo.set_active(0)
self._filter_check.connect('toggled',lambda b: self._filter_combo.set_sensitive(self._filter_check.get_active()))
self._filter_entry_label = gtk.Label()
self._filter_entry_edit = gtk.Entry()
# table layout
current_row = 0
self._table.attach(self._id_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(id_label,self._label_col,self._label_col+1,
current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._id_edit,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._name_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(name_label,self._label_col,self._label_col+1,
current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._name_edit,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._gender_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(gender_label,self._label_col,self._label_col+1,
current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._gender_combo,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._birth_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(b_label,self._label_col,self._label_col+1,
current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._b_edit,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._b_inner_box,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._b_unknown,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._death_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(d_label,self._label_col,self._label_col+1,current_row,
current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._d_edit,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(d_inner_box,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._d_unknown,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
current_row +=1
self._table.attach(self._filter_check,self._check_col,self._check_col+1,
current_row,current_row+1,xoptions=False,yoptions=False)
self._table.attach(filter_label,self._label_col,self._label_col+1,
current_row,current_row+1,xoptions=gtk.FILL,yoptions=False)
self._table.attach(self._filter_combo,self._control_col,self._control_col+1,
current_row,current_row+1,xoptions=gtk.EXPAND|gtk.FILL,yoptions=False)
self._reset_widgets() self._reset_widgets()
if filter_spec is not None: if filter_spec is not None:
self._set_filter(filter_spec) self._set_filter(filter_spec)
def _reset_widgets(self):
self._id_edit.set_sensitive(False)
self._name_edit.set_sensitive(False)
self._gender_combo.set_sensitive(False)
self._b_edit.set_sensitive(False)
self._b_before.set_sensitive(False)
self._b_after.set_sensitive(False)
self._b_unknown.set_sensitive(False)
self._d_edit.set_sensitive(False)
self._d_after.set_sensitive(False)
self._d_before.set_sensitive(False)
self._d_unknown.set_sensitive(False)
self._filter_combo.set_sensitive(False)
self._filter_entry_label.set_sensitive(False)
self._filter_entry_edit.set_sensitive(False)
for check in self._checkboxes:
check.set_active(False)
def _set_filter(self,filter_spec): def _set_filter(self,filter_spec):
if filter_spec.include_gramps_id(): if filter_spec.include_gramps_id():
self._id_check.set_active(True) self._id_check.set_active(True)
@ -357,10 +179,6 @@ class PersonFilterFrame(FilterFrameBase):
self._death_check.set_active(False) self._death_check.set_active(False)
self._d_edit.set_text("") self._d_edit.set_text("")
def on_clear(self,button=None):
self._reset_widgets()
self.emit('clear-filter')
def on_apply(self,button=None): def on_apply(self,button=None):
filter = GenericFilter() filter = GenericFilter()
@ -403,8 +221,7 @@ class PersonFilterFrame(FilterFrameBase):
if self._filter_check.get_active(): if self._filter_check.get_active():
filter.add_rule(self._filter_list.get_value(self._filter_combo.get_active_iter(),0)([])) filter.add_rule(self._filter_list.get_value(self._filter_combo.get_active_iter(),1)([]))
self.emit('apply-filter',filter) self.emit('apply-filter',filter)

View File

@ -23,6 +23,7 @@
import os.path import os.path
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from gettext import gettext as _
import gtk import gtk
import gobject import gobject