diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index fad8e5b05..e87c807ee 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,10 @@ 2005-01-06 Don Allingham + * src/EditPerson.py: switch to ComboBox from OptionMenu + * src/GenericFilter.py: switch to ComboBox from OptionMenu + * src/Marriage.py: switch to ComboBox from OptionMenu + * src/PeopleView.py: switch to ComboBox from OptionMenu + * src/gramps.glade:switch to ComboBox from OptionMenu + * src/gramps_main.py: switch to ComboBox from OptionMenu * src/const.py.in: add support for overriding gconf usage * src/GrampsIniKeys.py: provide support for the default schema * src/GrampsKeys.py: select appropriate backend diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 4a938de5b..bf27fbe40 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -642,20 +642,23 @@ class EditPerson: else: self.ldsfam = None - myMenu = gtk.Menu() - item = gtk.MenuItem(_("None")) - item.set_data("f",None) - item.connect("activate",self.menu_changed) - item.show() - myMenu.append(item) + cell = gtk.CellRendererText() + self.ldsseal_fam.pack_start(cell,True) + self.ldsseal_fam.add_attribute(cell,'text',0) + + store = gtk.ListStore(str) + store.append(row=[_("None")]) index = 0 hist = 0 + self.lds_fam_list = [None] flist = [self.person.get_main_parents_family_handle()] for (fam,mrel,frel) in self.person.get_parent_family_handle_list(): if fam not in flist: flist.append(fam) + for fam_id in flist: + index += 1 fam = self.db.get_family_from_handle(fam_id) if fam == None: continue @@ -673,16 +676,13 @@ class EditPerson: name = self.name_display.display(m) else: name = _("unknown") - item = gtk.MenuItem(name) - item.set_data("f",fam) - item.connect("activate",self.menu_changed) - item.show() - myMenu.append(item) - index = index + 1 - if fam == self.ldsfam: + store.append(row=[name]) + self.lds_fam_list.append(fam_id) + if fam_id == self.ldsfam: hist = index - self.ldsseal_fam.set_menu(myMenu) - self.ldsseal_fam.set_history(hist) + self.ldsseal_fam.set_model(store) + self.ldsseal_fam.set_active(hist) + self.ldsseal_fam.connect("changed",self.menu_changed) self.build_bap_menu() self.build_seal_menu() @@ -704,17 +704,16 @@ class EditPerson: self.is_female.set_active(True) def build_menu(self,list,task,opt_menu,type): - menu = gtk.Menu() - index = 0 + cell = gtk.CellRendererText() + opt_menu.pack_start(cell,True) + opt_menu.add_attribute(cell,'text',0) + + store = gtk.ListStore(str) for val in list: - menuitem = gtk.MenuItem(val) - menuitem.set_data("val",index) - menuitem.connect('activate',task) - menuitem.show() - menu.append(menuitem) - index = index + 1 - opt_menu.set_menu(menu) - opt_menu.set_history(type) + store.append(row=[val]) + opt_menu.set_model(store) + opt_menu.connect('changed',task) + opt_menu.set_active(type) def build_bap_menu(self): self.build_menu(const.lds_baptism,self.set_lds_bap,self.ldsbapstat, @@ -729,13 +728,13 @@ class EditPerson: self.seal_stat) def set_lds_bap(self,obj): - self.lds_baptism.set_status(obj.get_data("val")) + self.lds_baptism.set_status(obj.get_active()) def set_lds_endow(self,obj): - self.lds_endowment.set_status(obj.get_data("val")) + self.lds_endowment.set_status(obj.get_active()) def set_lds_seal(self,obj): - self.lds_sealing.set_status(obj.get_data("val")) + self.lds_sealing.set_status(obj.get_active()) def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time): row = self.etree.get_row_at(x,y) @@ -883,7 +882,7 @@ class EditPerson: return def menu_changed(self,obj): - self.ldsfam = obj.get_data("f") + self.ldsfam = self.lds_fam_list[obj.get_active()] def get_widget(self,str): """returns the widget related to the passed string""" diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index af314bee3..f3e92516e 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -1348,7 +1348,7 @@ class MatchesFilter(Rule): return 'Matches the filter named' def apply(self,db,p_id): - for filt in SystemFilters.get_filters(): + for filt in SystemFilters.get_filter(): if filt.get_name() == self.list[0]: return filt.check(p_id) for filt in CustomFilters.get_filters(): @@ -1771,6 +1771,37 @@ class GrampsFilterComboBox(gtk.ComboBox): return self.map[key] +class FilterStore(gtk.ListStore): + + def __init__(self,local_filters=[], default=""): + gtk.ListStore.__init__(self,str) + self.list_map = [] + self.def_index = 0 + + cnt = 0 + for filt in local_filters: + name = filt.get_name() + self.append(row=[name]) + self.list_map.append(filt) + if default != "" and default == name: + self.def_index = cnt + cnt += 1 + + for filt in SystemFilters.get_filters() + CustomFilters.get_filters(): + name = _(filt.get_name()) + self.append(row=[name]) + self.list_map.append(filt) + if default != "" and default == name: + self.def_index = cnt + cnt += 1 + + def default_index(self): + return self.def_index + + def get_filter(self,index): + return self.list_map[index] + + def build_filter_menu(local_filters = [], default=""): menu = gtk.Menu() diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py index bce07727b..25c70b082 100644 --- a/gramps2/src/Marriage.py +++ b/gramps2/src/Marriage.py @@ -331,20 +331,19 @@ class Marriage: return def build_seal_menu(self): - menu = gtk.Menu() - index = 0 + cell = gtk.CellRendererText() + self.lds_status.pack_start(cell,True) + self.lds_status.add_attribute(cell,'text',0) + + store = gtk.ListStore(str) for val in const.lds_ssealing: - menuitem = gtk.MenuItem(val) - menuitem.set_data("val",index) - menuitem.connect('activate',self.set_lds_seal) - menuitem.show() - menu.append(menuitem) - index = index + 1 - self.lds_status.set_menu(menu) - self.lds_status.set_history(self.seal_stat) + store.append(row=[val]) + self.lds_status.set_model(store) + self.lds_status.connect('changed',self.set_lds_seal) + self.lds_status.set_active(self.seal_stat) def set_lds_seal(self,obj): - self.seal_stat = obj.get_data("val") + self.seal_stat = obj.get_active() def lds_src_clicked(self,obj): lds_ord = self.family.get_lds_sealing() diff --git a/gramps2/src/PeopleView.py b/gramps2/src/PeopleView.py index c89645eb8..9cd060904 100644 --- a/gramps2/src/PeopleView.py +++ b/gramps2/src/PeopleView.py @@ -170,8 +170,8 @@ class PeopleView: self.parent.mhistory.remove(del_id) def apply_filter_clicked(self): - mi = self.parent.filter_list.get_menu().get_active() - self.DataFilter = mi.get_data("filter") + index = self.parent.filter_list.get_active() + self.DataFilter = self.parent.filter_model.get_filter(index) if self.DataFilter.need_param: qual = unicode(self.parent.filter_text.get_text()) self.DataFilter.set_parameter(qual) diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index 7902d526d..ede488f03 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1278,17 +1278,8 @@ 6 - - 200 + True - True - -1 - - - - True - - 0 @@ -12540,29 +12531,6 @@ Other - - - 100 - True - True - -1 - - - - True - - - - - 3 - 4 - 1 - 2 - fill - - - - True @@ -12875,28 +12843,6 @@ Other - - - True - True - -1 - - - - True - - - - - 3 - 4 - 6 - 7 - fill - - - - True @@ -12986,28 +12932,6 @@ Other - - - True - True - -1 - - - - True - - - - - 3 - 4 - 11 - 12 - fill - - - - True @@ -13135,9 +13059,6 @@ Other 0 0 sealparents - - - 1 @@ -13149,28 +13070,6 @@ Other - - - True - True - -1 - - - - True - - - - - 2 - 3 - 14 - 15 - fill - - - - True @@ -13236,6 +13135,62 @@ Other fill + + + + True + + + 3 + 4 + 1 + 2 + fill + fill + + + + + + True + + + 3 + 4 + 6 + 7 + fill + fill + + + + + + True + + + 3 + 4 + 11 + 12 + fill + fill + + + + + + True + + + 2 + 3 + 14 + 15 + fill + fill + + False @@ -15214,28 +15169,6 @@ Other - - - True - True - -1 - - - - True - - - - - 3 - 4 - 1 - 2 - fill - - - - True @@ -15303,6 +15236,20 @@ Other fill + + + + True + + + 3 + 4 + 1 + 2 + fill + fill + + 0 diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 0b2531e2d..7c5200dfe 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -838,6 +838,10 @@ class Gramps: def init_filters(self): + cell = gtk.CellRendererText() + self.filter_list.pack_start(cell,True) + self.filter_list.add_attribute(cell,'text',0) + filter_list = [] all = GenericFilter.GenericFilter() @@ -867,8 +871,9 @@ class Gramps: menu = GenericFilter.build_filter_menu(filter_list) - self.filter_list.set_menu(menu) - self.filter_list.set_history(0) + self.filter_model = GenericFilter.FilterStore(filter_list) + self.filter_list.set_model(self.filter_model) + self.filter_list.set_active(self.filter_model.default_index()) self.filter_list.connect('changed',self.on_filter_name_changed) self.filter_text.set_sensitive(0) @@ -1485,7 +1490,8 @@ class Gramps: self.people_view.apply_filter_clicked() def on_filter_name_changed(self,obj): - mime_filter = obj.get_menu().get_active().get_data('filter') + index = self.filter_list.get_active() + mime_filter = self.filter_model.get_filter(index) qual = mime_filter.need_param if qual: self.filter_text.show()