From 3a80310d163af8fcd672fa3c3a7f4d48d107c032 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 4 Apr 2006 22:42:38 +0000 Subject: [PATCH] widget connections svn: r6265 --- gramps2/src/Editors/_EditLdsOrd.py | 7 ++++++ gramps2/src/GrampsWidgets.py | 36 +++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/gramps2/src/Editors/_EditLdsOrd.py b/gramps2/src/Editors/_EditLdsOrd.py index e771744a9..bc4064f94 100644 --- a/gramps2/src/Editors/_EditLdsOrd.py +++ b/gramps2/src/Editors/_EditLdsOrd.py @@ -122,6 +122,13 @@ class EditLdsOrd(EditSecondary): for val in lds.temple_codes.keys(): temple_list.append((lds.temple_codes[val],val)) + self.type_menu = MonitoredStrMenu( + self.top.get_widget('temple'), + self.obj.set_temple, + self.obj.get_temple, + temple_list, + self.db.readonly) + def _create_tabbed_pages(self): notebook = gtk.Notebook() self.srcref_list = self._add_tab( diff --git a/gramps2/src/GrampsWidgets.py b/gramps2/src/GrampsWidgets.py index ddc6b01fe..a734d15bf 100644 --- a/gramps2/src/GrampsWidgets.py +++ b/gramps2/src/GrampsWidgets.py @@ -362,15 +362,41 @@ class MonitoredMenu: self.obj.set_active(value) def on_change(self, obj): + print obj + print obj.get_active_iter() + print self.model.get_value(obj.get_active_iter(),1) self.set_val(self.model.get_value(obj.get_active_iter(),1)) - def force(self,value): - self.obj.set_active(self.data.index(value)) +class MonitoredStrMenu: + + def __init__(self,obj,set_val,get_val,mapping,readonly=False): + self.set_val = set_val + self.get_val = get_val + + self.obj = obj + self.model = gtk.ListStore(str,int) + self.model.append(row=['',0]) + index = 0 + self.data = [''] + + default = get_val() + active = 0 + + for t,v in mapping: + self.model.append(row=[t,index]) + self.data.append(v) + if v == default: + active = index + index += 1 + + self.obj.set_model(self.model) + self.obj.set_active(index) + self.obj.connect('changed',self.on_change) + self.obj.set_sensitive(not readonly) def on_change(self, obj): - value = self.data[self.model.get_value(obj.get_active_iter(),1)] - self.set_val(value) - + self.set_val(self.data[obj.get_active()]) + class MonitoredDate: def __init__(self,field,button,value,window, readonly=False):