From 1d24bc8f13b6954875ba1f6b777213daae66c136 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 6 Apr 2006 21:28:19 +0000 Subject: [PATCH] * src/Editors/_EditLdsOrd.py (EditLdsOrd): Formatting. * src/GrampsWidgets.py (MonitoredMenu): Factor out commong code. svn: r6280 --- ChangeLog | 4 +++ src/Editors/_EditLdsOrd.py | 71 ++++++++++++++++++++------------------ src/GrampsWidgets.py | 20 +++++------ 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 06624f1b1..6dde3cb05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-04-06 Alex Roitman + * src/Editors/_EditLdsOrd.py (EditLdsOrd): Formatting. + * src/GrampsWidgets.py (MonitoredMenu): Factor out commong code. + 2006-04-06 Don Allingham * src/RecentFiles.py: check for a files' existence before adding to the list. diff --git a/src/Editors/_EditLdsOrd.py b/src/Editors/_EditLdsOrd.py index 199b841fa..f04ecbbec 100644 --- a/src/Editors/_EditLdsOrd.py +++ b/src/Editors/_EditLdsOrd.py @@ -70,41 +70,44 @@ class EditLdsOrd(EditSecondary): """ _data_map = { - RelLib.LdsOrd.BAPTISM : [(_(""), RelLib.LdsOrd.STATUS_NONE), - (_("Child"), RelLib.LdsOrd.STATUS_CHILD), - (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), - (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), - (_("Infant"), RelLib.LdsOrd.STATUS_INFANT), - (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), - (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), - (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), - (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), - (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), - ], - RelLib.LdsOrd.ENDOWMENT: [(_(""), RelLib.LdsOrd.STATUS_NONE), - (_("Child"), RelLib.LdsOrd.STATUS_CHILD), - (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), - (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), - (_("Infant"), RelLib.LdsOrd.STATUS_INFANT), - (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), - (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), - (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), - (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), - (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), - ], - RelLib.LdsOrd.SEAL_TO_PARENTS:[(_(""), RelLib.LdsOrd.STATUS_NONE), - (_("BIC"), RelLib.LdsOrd.STATUS_BIC), - (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), - (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), - (_("DNS"), RelLib.LdsOrd.STATUS_DNS), - (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), - (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), - (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), - (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), - (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), - ], + RelLib.LdsOrd.BAPTISM : [ + (_(""), RelLib.LdsOrd.STATUS_NONE), + (_("Child"), RelLib.LdsOrd.STATUS_CHILD), + (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), + (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), + (_("Infant"), RelLib.LdsOrd.STATUS_INFANT), + (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), + (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), + (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), + (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), + (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), + ], + RelLib.LdsOrd.ENDOWMENT: [ + (_(""), RelLib.LdsOrd.STATUS_NONE), + (_("Child"), RelLib.LdsOrd.STATUS_CHILD), + (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), + (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), + (_("Infant"), RelLib.LdsOrd.STATUS_INFANT), + (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), + (_("Qualified"), RelLib.LdsOrd.STATUS_QUALIFIED), + (_("Stillborn"), RelLib.LdsOrd.STATUS_STILLBORN), + (_("Submitted"), RelLib.LdsOrd.STATUS_SUBMITTED), + (_("Uncleared"), RelLib.LdsOrd.STATUS_UNCLEARED), + ], + RelLib.LdsOrd.SEAL_TO_PARENTS:[ + (_(""), RelLib.LdsOrd.STATUS_NONE), + (_("BIC"), RelLib.LdsOrd.STATUS_BIC), + (_("Cleared"), RelLib.LdsOrd.STATUS_CLEARED), + (_("Completed"), RelLib.LdsOrd.STATUS_COMPLETED), + (_("DNS"), RelLib.LdsOrd.STATUS_DNS), + (_("Pre-1970"), RelLib.LdsOrd.STATUS_PRE_1970), + (_("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): """ Displays the dialog box. diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index 4feeaac5b..ddd78726d 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -345,23 +345,15 @@ class MonitoredType: 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.get_val = get_val self.changed = changed self.obj = obj - self.model = gtk.ListStore(str, int) - self.data = {} - index = 0 - 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.change_menu(mapping) self.obj.connect('changed', self.on_change) self.obj.set_sensitive(not readonly) @@ -369,11 +361,15 @@ class MonitoredMenu: self.obj.set_active(value) def change_menu(self, mapping): + self.data = {} self.model = gtk.ListStore(str, int) + index = 0 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(0) + self.obj.set_active(self.data.get(self.get_val(),0)) def on_change(self, obj): self.set_val(self.model.get_value(obj.get_active_iter(), 1))