* 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 bc96c75e39
commit 1d24bc8f13
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,39 +70,42 @@ class EditLdsOrd(EditSecondary):
""" """
_data_map = { _data_map = {
RelLib.LdsOrd.BAPTISM : [(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), RelLib.LdsOrd.BAPTISM : [
(_("Child"), RelLib.LdsOrd.STATUS_CHILD), (_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), (_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Infant"), RelLib.LdsOrd.STATUS_INFANT), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), (_("Infant"), RelLib.LdsOrd.STATUS_INFANT),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
], (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
RelLib.LdsOrd.ENDOWMENT: [(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), ],
(_("Child"), RelLib.LdsOrd.STATUS_CHILD), RelLib.LdsOrd.ENDOWMENT: [
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), (_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("Child"), RelLib.LdsOrd.STATUS_CHILD),
(_("Infant"), RelLib.LdsOrd.STATUS_INFANT), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), (_("Infant"), RelLib.LdsOrd.STATUS_INFANT),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
], (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
RelLib.LdsOrd.SEAL_TO_PARENTS:[(_("<No Status>"), RelLib.LdsOrd.STATUS_NONE), (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
(_("BIC"), RelLib.LdsOrd.STATUS_BIC), ],
(_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), RelLib.LdsOrd.SEAL_TO_PARENTS:[
(_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), (_("<No Status>"), RelLib.LdsOrd.STATUS_NONE),
(_("DNS"), RelLib.LdsOrd.STATUS_DNS), (_("BIC"), RelLib.LdsOrd.STATUS_BIC),
(_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED),
(_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED),
(_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), (_("DNS"), RelLib.LdsOrd.STATUS_DNS),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED),
], (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN),
(_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED),
(_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED),
],
} }
def __init__(self, state, uistate, track, attrib, callback): def __init__(self, state, uistate, track, attrib, callback):

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))