From ef7f1ffa65ea4caa91c1ddb33ac6fa3068e326e5 Mon Sep 17 00:00:00 2001 From: Richard Taylor Date: Sun, 21 Jan 2007 21:23:06 +0000 Subject: [PATCH] objectselector work. svn: r7947 --- gramps2/ChangeLog | 6 + .../src/ObjectSelector/_FamilyFilterFrame.py | 109 ++------ .../src/ObjectSelector/_FilterFrameBase.py | 149 ++++++++++- .../ObjectSelector/_ObjectSelectorWindow.py | 65 +++-- .../src/ObjectSelector/_PersonFilterFrame.py | 245 +++--------------- .../src/ObjectSelector/_PersonPreviewFrame.py | 1 + 6 files changed, 236 insertions(+), 339 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3e0325305..2915363c3 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2007-01-21 Richard Taylor + * 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 * src/DisplayModels/_PeopleModel.py: save current filter for rebuild (#838) * src/BaseDoc.py: save/load paragraph description (#850) diff --git a/gramps2/src/ObjectSelector/_FamilyFilterFrame.py b/gramps2/src/ObjectSelector/_FamilyFilterFrame.py index f601f7064..778b5e065 100644 --- a/gramps2/src/ObjectSelector/_FamilyFilterFrame.py +++ b/gramps2/src/ObjectSelector/_FamilyFilterFrame.py @@ -35,107 +35,38 @@ class FamilyFilterFrame(FilterFrameBase): __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) # Gramps ID - id_check = gtk.CheckButton() - id_label = gtk.Label("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())) + self._id_check,self._id_label,self._id_edit = \ + self.make_text_widget("Gramps ID") # Name - name_check = gtk.CheckButton() - name_label = gtk.Label("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())) - + self._name_check,self._name_label,self._name_edit = \ + self.make_text_widget("Name") # Mar - mar_check = gtk.CheckButton() - mar_check.set_alignment(xalign=0,yalign=0) - - 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) - + self._mar_check, self._m_edit, \ + self._m_before, self._m_after, \ + self._m_unknown = self.make_year_widget("Marriage Year") # Filter - filter_check = gtk.CheckButton() - filter_label = gtk.Label("Filter") - filter_label.set_alignment(xalign=0,yalign=0.5) + default_filters = [] - filter_combo = gtk.combo_box_new_text() - filter_combo.append_text("Male") - filter_combo.append_text("Female") - filter_combo.append_text("Unknown") - filter_combo.set_active(2) - filter_combo.set_sensitive(False) - - - filter_check.connect('toggled',lambda b: filter_combo.set_sensitive(filter_check.get_active())) - - # table layout - - - 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) + # don't currently support filters that need an attribute. + filters = [ filter for filter in default_filters if \ + not hasattr(filter,'labels') or len(filter.labels) == 0 ] - current_row +=1 + self._filter_list = gtk.ListStore(str,object) + + for filter in filters: + self._filter_list.append([filter.name,filter]) + + self._filter_check,self._filter_label,self._filter_combo = \ + self.make_combo_widget("Filter",self._filter_list) - 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) + self._reset_widgets() if filter_spec is not None: self._set_filter(filter_spec) diff --git a/gramps2/src/ObjectSelector/_FilterFrameBase.py b/gramps2/src/ObjectSelector/_FilterFrameBase.py index 28533df6c..59f836c7a 100644 --- a/gramps2/src/ObjectSelector/_FilterFrameBase.py +++ b/gramps2/src/ObjectSelector/_FilterFrameBase.py @@ -24,7 +24,6 @@ import gtk import gobject from GrampsWidgets import IntEdit -from Filters import GenericFilter class FilterFrameBase(gtk.Frame): @@ -43,6 +42,12 @@ class FilterFrameBase(gtk.Frame): def __init__(self,filter_spec=None,label="Filter"): gtk.Frame.__init__(self,label) + + + self._checkboxes = [] + self._active_widgets = [] + + self._current_row = 0 self._filter_spec = filter_spec @@ -90,25 +95,141 @@ class FilterFrameBase(gtk.Frame): 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): """Build a GenericFilter object from the settings in the filter controls and emit a 'apply-filter' signal with the GenericFilter object as the parameter.""" 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): gobject.type_register(FilterFrameBase) -if __name__ == "__main__": - - w = gtk.Window() - f = PersonFilterFrame() - w.add(f) - w.show_all() - - gtk.main() diff --git a/gramps2/src/ObjectSelector/_ObjectSelectorWindow.py b/gramps2/src/ObjectSelector/_ObjectSelectorWindow.py index 4c6e9a77b..9129fb6ac 100644 --- a/gramps2/src/ObjectSelector/_ObjectSelectorWindow.py +++ b/gramps2/src/ObjectSelector/_ObjectSelectorWindow.py @@ -155,15 +155,28 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): obj_label.set_padding(self.__class__.__default_border_width, self.__class__.__default_border_width) - - 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")) - self._tool_list = gtk.ListStore(gtk.gdk.Pixbuf, str,int) + try: + 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")) + + self._tool_list = gtk.ListStore(gtk.gdk.Pixbuf, str,int) + + d={ObjectTypes.PERSON: [person_pixbuf,'People',ObjectTypes.PERSON], + ObjectTypes.FAMILY: [flist_pixbuf,'Families',ObjectTypes.FAMILY], + 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 - d={ObjectTypes.PERSON: [person_pixbuf,'People',ObjectTypes.PERSON], - ObjectTypes.FAMILY: [flist_pixbuf,'Families',ObjectTypes.FAMILY], - ObjectTypes.EVENT: [person_pixbuf,'Events',ObjectTypes.EVENT]} for object_type in self._object_list: self._tool_list.append(d[object_type]) @@ -300,9 +313,9 @@ class ObjectSelectorWindow(gtk.Window,ManagedWindow): store = self._tool_list it = store.get_iter_first() while it: - if store.get(it, 2)[0] == selected_object_type: - break - it = store.iter_next(it) + if store.get(it, self._object_type_column)[0] == selected_object_type: + break + it = store.iter_next(it) if it != None: self._tool_combo.set_active_iter(it) @@ -334,7 +347,6 @@ if gtk.pygtk_version < (2,8,0): if __name__ == "__main__": - import GrampsDb import ViewManager import const @@ -369,16 +381,25 @@ if __name__ == "__main__": dbstate.db = db - w = ObjectSelectorWindow(dbstate=dbstate, - uistate=vm.uistate, - default_object_type = ObjectTypes.PERSON, - object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY]) - w.show() - w.connect("destroy", gtk.main_quit) + def prof_fun(): + global dbstate, vm + w = ObjectSelectorWindow(dbstate=dbstate, + uistate=vm.uistate, + track=[], + filter_spec=None, + default_object_type = ObjectTypes.PERSON, + object_list=[ObjectTypes.PERSON,]) + #object_list=[ObjectTypes.PERSON,ObjectTypes.FAMILY]) + w.show() + w.connect("destroy", gtk.main_quit) - def add(w,results): - print str(results) + def add(w,results): + print str(results) - w.connect('add-object',add) - - gtk.main() + w.connect('add-object',add) + + gtk.main() + + prof_fun() + import profile + profile.run("prof_fun()",'profile.dat') diff --git a/gramps2/src/ObjectSelector/_PersonFilterFrame.py b/gramps2/src/ObjectSelector/_PersonFilterFrame.py index 4bfae3c05..c68291121 100644 --- a/gramps2/src/ObjectSelector/_PersonFilterFrame.py +++ b/gramps2/src/ObjectSelector/_PersonFilterFrame.py @@ -27,7 +27,6 @@ from logging import getLogger log = getLogger(".ObjectSelector") -from GrampsWidgets import IntEdit from _FilterFrameBase import FilterFrameBase from Filters import GenericFilter, Rules import RelLib @@ -39,123 +38,48 @@ class PersonFilterFrame(FilterFrameBase): __gsignals__ = { } + # This is used when the widgets are packed into the ObjectSelector + # frames. __default_border_width = 5 def __init__(self,filter_spec=None,label="Filter"): FilterFrameBase.__init__(self,filter_spec,label) - self._checkboxes = [] - + # Build the filter widgets, the make_* methods are + # in the FilterFrameBase base class. + # Gramps ID - self._id_check = gtk.CheckButton() - self._checkboxes.append(self._id_check) - 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())) + self._id_check,self._id_label,self._id_edit = \ + self.make_text_widget("Gramps ID") # Name - self._name_check = gtk.CheckButton() - self._checkboxes.append(self._name_check) - - 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())) + self._name_check,self._name_label,self._name_edit = \ + self.make_text_widget("Name") # 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], [_("Female"),RelLib.Person.FEMALE], [_("Unknown"),RelLib.Person.UNKNOWN]] - - for gender in genders: - self._gender_list.append(gender) - - self._gender_combo = gtk.ComboBox(self._gender_list) - - label_cell = gtk.CellRendererText() - - 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())) + self._gender_list = gtk.ListStore(str,int) + + for entry in genders: + self._gender_list.append(entry) + + self._gender_check,self._gender_label, self._gender_combo = \ + self.make_combo_widget("Gender",self._gender_list) # Birth - self._birth_check = gtk.CheckButton() - self._birth_check.set_alignment(xalign=0,yalign=0) - self._checkboxes.append(self._birth_check) + self._birth_check, self._b_edit, \ + self._b_before, self._b_after, \ + 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 - - self._death_check = gtk.CheckButton() - self._checkboxes.append(self._death_check) - - - 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) + self._death_check, self._d_edit, \ + self._d_before, self._d_after, \ + self._d_unknown = self.make_year_widget("Death Year") # 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 = [ Rules.Person.Everyone, Rules.Person.IsFemale, @@ -182,125 +106,23 @@ class PersonFilterFrame(FilterFrameBase): Rules.Person.IsFemale, ] - self._filter_list = gtk.ListStore(object,str) + # don't currently support filters that need an attribute. + filters = [ filter for filter in default_filters if \ + not hasattr(filter,'labels') or len(filter.labels) == 0 ] - for filter in default_filters: - if not hasattr(filter,'labels') or len(filter.labels) == 0: - # don't currently support filters that need an attribute. - self._filter_list.append([filter,filter.name]) - - self._filter_combo = gtk.ComboBox(self._filter_list) - - label_cell = gtk.CellRendererText() - - self._filter_combo.pack_start(label_cell, True) - self._filter_combo.add_attribute(label_cell, 'text', 1) - self._filter_combo.set_active(0) + self._filter_list = gtk.ListStore(str,object) - self._filter_check.connect('toggled',lambda b: self._filter_combo.set_sensitive(self._filter_check.get_active())) + for filter in filters: + self._filter_list.append([filter.name,filter]) - 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._filter_check,self._filter_label,self._filter_combo = \ + self.make_combo_widget("Filter",self._filter_list) self._reset_widgets() if filter_spec is not None: 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): if filter_spec.include_gramps_id(): self._id_check.set_active(True) @@ -357,10 +179,6 @@ class PersonFilterFrame(FilterFrameBase): self._death_check.set_active(False) self._d_edit.set_text("") - def on_clear(self,button=None): - self._reset_widgets() - self.emit('clear-filter') - def on_apply(self,button=None): filter = GenericFilter() @@ -403,8 +221,7 @@ class PersonFilterFrame(FilterFrameBase): 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) diff --git a/gramps2/src/ObjectSelector/_PersonPreviewFrame.py b/gramps2/src/ObjectSelector/_PersonPreviewFrame.py index 8073c1b4b..443a0ac4e 100644 --- a/gramps2/src/ObjectSelector/_PersonPreviewFrame.py +++ b/gramps2/src/ObjectSelector/_PersonPreviewFrame.py @@ -23,6 +23,7 @@ import os.path from xml.sax.saxutils import escape +from gettext import gettext as _ import gtk import gobject