* src/Editors/_EditLdsOrd.py (EditLdsOrd): Formatting.

* src/GrampsWidgets.py (MonitoredMenu): Factor out commong code.


svn: r6280
This commit is contained in:
Alex Roitman 2006-04-06 21:28:19 +00:00
parent cc755303cd
commit ab2b973638
3 changed files with 49 additions and 46 deletions

View File

@ -1,3 +1,7 @@
2006-04-06 Alex Roitman <shura@gramps-project.org>
* src/Editors/_EditLdsOrd.py (EditLdsOrd): Formatting.
* src/GrampsWidgets.py (MonitoredMenu): Factor out commong code.
2006-04-06 Don Allingham <don@gramps-project.org> 2006-04-06 Don Allingham <don@gramps-project.org>
* src/RecentFiles.py: check for a files' existence before adding * src/RecentFiles.py: check for a files' existence before adding
to the list. to the list.

View File

@ -70,7 +70,8 @@ class EditLdsOrd(EditSecondary):
""" """
_data_map = { _data_map = {
RelLib.LdsOrd.BAPTISM : [(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), RelLib.LdsOrd.BAPTISM : [
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Child"), RelLib.LdsOrd.STATUS_CHILD), (_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
@ -81,7 +82,8 @@ class EditLdsOrd(EditSecondary):
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
], ],
RelLib.LdsOrd.ENDOWMENT: [(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), RelLib.LdsOrd.ENDOWMENT: [
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Child"), RelLib.LdsOrd.STATUS_CHILD), (_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
@ -92,7 +94,8 @@ class EditLdsOrd(EditSecondary):
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
], ],
RelLib.LdsOrd.SEAL_TO_PARENTS:[(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), RelLib.LdsOrd.SEAL_TO_PARENTS:[
(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("BIC"), RelLib.LdsOrd.STATUS_BIC), (_("BIC"), RelLib.LdsOrd.STATUS_BIC),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),

View File

@ -345,23 +345,15 @@ class MonitoredType:
class MonitoredMenu: class MonitoredMenu:
def __init__(self, obj, set_val, get_val, mapping, readonly=False, changed=None): def __init__(self, obj, set_val, get_val, mapping,
readonly=False, changed=None):
self.set_val = set_val self.set_val = set_val
self.get_val = get_val self.get_val = get_val
self.changed = changed self.changed = changed
self.obj = obj self.obj = obj
self.model = gtk.ListStore(str, int)
self.data = {}
index = 0 self.change_menu(mapping)
for t, v in mapping:
self.model.append(row=[t, v])
self.data[v] = index
index += 1
self.obj.set_model(self.model)
self.obj.set_active(self.data[get_val()])
self.obj.connect('changed', self.on_change) self.obj.connect('changed', self.on_change)
self.obj.set_sensitive(not readonly) self.obj.set_sensitive(not readonly)
@ -369,11 +361,15 @@ class MonitoredMenu:
self.obj.set_active(value) self.obj.set_active(value)
def change_menu(self, mapping): def change_menu(self, mapping):
self.data = {}
self.model = gtk.ListStore(str, int) self.model = gtk.ListStore(str, int)
index = 0
for t, v in mapping: for t, v in mapping:
self.model.append(row=[t, v]) self.model.append(row=[t, v])
self.data[v] = index
index += 1
self.obj.set_model(self.model) self.obj.set_model(self.model)
self.obj.set_active(0) self.obj.set_active(self.data.get(self.get_val(),0))
def on_change(self, obj): def on_change(self, obj):
self.set_val(self.model.get_value(obj.get_active_iter(), 1)) self.set_val(self.model.get_value(obj.get_active_iter(), 1))