diff --git a/ChangeLog b/ChangeLog index 6489a021f..8402f7b7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ 2006-05-05 Don Allingham + * src/DateEdit.py: ManagedWindow + * src/Editors/_EditAddress.py: new DateEdit interface + * src/Editors/_EditLdsOrd.py: new DateEdit interface + * src/Editors/_EditSourceRef.py: new DateEdit interface + * src/Editors/_EditEventRef.py: new DateEdit interface + * src/Editors/_EditMedia.py: new DateEdit interface + * src/Editors/_EditName.py: new DateEdit interface + * src/Editors/_EditEvent.py: new DateEdit interface + * src/GrampsWidgets.py: new DateEdit interface * src/Editors/_EditFamily.py: import ChildModel 2006-05-05 Alex Roitman diff --git a/src/DateEdit.py b/src/DateEdit.py index 84f20e8c2..73805608b 100644 --- a/src/DateEdit.py +++ b/src/DateEdit.py @@ -42,7 +42,6 @@ __version__ = "$Revision$" # #------------------------------------------------------------------------- from gettext import gettext as _ -import gc #------------------------------------------------------------------------- # @@ -71,6 +70,7 @@ import DateHandler import const import Utils import GrampsDisplay +import ManagedWindow #------------------------------------------------------------------------- # @@ -108,18 +108,18 @@ class DateEdit: """Class that associates a pixmap with a text widget, providing visual feedback that indicates if the text widget contains a valid date""" - def __init__(self,date_obj,text_obj,button_obj,parent_window=None): + def __init__(self, date_obj, text_obj, button_obj, uistate, track): """ Creates a connection between the date_obj, text_obj and the pixmap_obj. Assigns callbacks to parse and change date when the text in text_obj is changed, and to invoke Date Editor when the LED button_obj is pressed. """ - + self.uistate = uistate + self.track = track self.date_obj = date_obj self.text_obj = text_obj self.button_obj = button_obj - self.parent_window = parent_window self.pixmap_obj = button_obj.get_child() @@ -164,7 +164,7 @@ class DateEdit: If date was in fact built, sets the date_obj to the newly built date. """ - date_dialog = DateEditorDialog(self.date_obj,self.parent_window) + date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track) the_date = date_dialog.return_date self.update_after_editor(the_date) @@ -182,29 +182,33 @@ class DateEdit: # DateEditorDialog # #------------------------------------------------------------------------- -class DateEditorDialog: +class DateEditorDialog(ManagedWindow.ManagedWindow): """ Dialog allowing to build the date precisely, to correct possible limitations of parsing and/or underlying structure of Date. """ - def __init__(self,date,parent_window=None): + def __init__(self, date, uistate, track): """ Initiate and display the dialog. """ + ManagedWindow.ManagedWindow.__init__(self, uistate, track, self) + # Create self.date as a copy of the given Date object. self.date = Date(date) self.top = gtk.glade.XML(const.gladeFile, "date_edit","gramps" ) - self.top_window = self.top.get_widget('date_edit') - self.top_window.hide() - title = self.top.get_widget('title') - Utils.set_titles(self.top_window,title,_('Date selection')) + self.set_window( + self.top.get_widget('date_edit'), + self.top.get_widget('title'), + _('Date selection')) + self.calendar_box = self.top.get_widget('calendar_box') for name in Date.ui_calendar_names: self.calendar_box.append_text(name) + self.calendar_box.set_active(self.date.get_calendar()) self.calendar_box.connect('changed',self.switch_calendar) @@ -260,12 +264,13 @@ class DateEditorDialog: # The dialog is modal -- since dates don't have names, we don't # want to have several open dialogs, since then the user will # loose track of which is which. Much like opening files. - if parent_window: - self.top_window.set_transient_for(parent_window) self.return_date = None - while 1: - response = self.top_window.run() + + self.show() + + while True: + response = self.window.run() if response == gtk.RESPONSE_HELP: GrampsDisplay.help('adv-dates') @@ -282,8 +287,10 @@ class DateEditorDialog: break else: break - self.top_window.destroy() - gc.collect() + self.window.destroy() + + def build_menu_names(self, obj): + return (_("Date selection"), None) def build_date_from_ui(self): """ diff --git a/src/Editors/_EditAddress.py b/src/Editors/_EditAddress.py index 8e3741411..a4cb360a7 100644 --- a/src/Editors/_EditAddress.py +++ b/src/Editors/_EditAddress.py @@ -79,7 +79,9 @@ class EditAddress(EditSecondary): self.top.get_widget("address_start"), self.top.get_widget("date_stat"), self.obj.get_date_object(), - self.window, self.db.readonly) + self.uistate, + self.track, + self.db.readonly) self.street = MonitoredEntry( self.top.get_widget("street"), self.obj.set_street, diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index 1414439d0..4e5194d89 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -142,7 +142,9 @@ class EditEvent(EditPrimary): self.top.get_widget("eventDate"), self.top.get_widget("date_stat"), self.obj.get_date_object(), - self.window, self.db.readonly) + self.uistate, + self.track, + self.db.readonly) def _create_tabbed_pages(self): """ diff --git a/src/Editors/_EditEventRef.py b/src/Editors/_EditEventRef.py index f6bc2bf55..629f793ac 100644 --- a/src/Editors/_EditEventRef.py +++ b/src/Editors/_EditEventRef.py @@ -140,7 +140,8 @@ class EditEventRef(EditReference): self.top.get_widget("eer_date"), self.top.get_widget("eer_date_stat"), self.source.get_date_object(), - self.window, + self.uistate, + self.track, self.db.readonly) def _create_tabbed_pages(self): diff --git a/src/Editors/_EditLdsOrd.py b/src/Editors/_EditLdsOrd.py index 3f7432caa..27c409acb 100644 --- a/src/Editors/_EditLdsOrd.py +++ b/src/Editors/_EditLdsOrd.py @@ -145,7 +145,9 @@ class EditLdsOrd(EditSecondary): self.top.get_widget("date"), self.top.get_widget("date_stat"), self.obj.get_date_object(), - self.window, self.db.readonly) + self.uistate, + self.track, + self.db.readonly) self.place_field = PlaceEntry( self.top.get_widget("place"), @@ -325,7 +327,9 @@ class EditFamilyLdsOrd(EditSecondary): self.top.get_widget("date"), self.top.get_widget("date_stat"), self.obj.get_date_object(), - self.window, self.db.readonly) + self.uistate, + self.track, + self.db.readonly) self.place_field = PlaceEntry( self.top.get_widget("place"), diff --git a/src/Editors/_EditMedia.py b/src/Editors/_EditMedia.py index 99175f48c..5c1f90159 100644 --- a/src/Editors/_EditMedia.py +++ b/src/Editors/_EditMedia.py @@ -86,7 +86,8 @@ class EditMedia(EditPrimary): self.glade.get_widget('date'), self.glade.get_widget("date_edit"), self.obj.get_date_object(), - self.window, + self.uistate, + self.track, self.db.readonly) self.descr_window = MonitoredEntry( diff --git a/src/Editors/_EditName.py b/src/Editors/_EditName.py index 52b8ed044..fbf84aff8 100644 --- a/src/Editors/_EditName.py +++ b/src/Editors/_EditName.py @@ -160,7 +160,9 @@ class EditName(EditSecondary): self.top.get_widget("date"), self.top.get_widget("date_stat"), self.obj.get_date_object(), - self.window) + self.uistate, + self.track, + self.db.readonly) self.obj_combo = MonitoredDataType( self.top.get_widget("name_type"), diff --git a/src/Editors/_EditSourceRef.py b/src/Editors/_EditSourceRef.py index 642e6d469..aa0dd3afb 100644 --- a/src/Editors/_EditSourceRef.py +++ b/src/Editors/_EditSourceRef.py @@ -112,7 +112,8 @@ class EditSourceRef(EditReference): self.source_ref.get_text,False) self.type_mon = MonitoredMenu( - self.top.get_widget('confidence'), self.source_ref.set_confidence_level, + self.top.get_widget('confidence'), + self.source_ref.set_confidence_level, self.source_ref.get_confidence_level, [ (_('Very Low'), RelLib.SourceRef.CONF_VERY_LOW), (_('Low'), RelLib.SourceRef.CONF_LOW), @@ -124,7 +125,10 @@ class EditSourceRef(EditReference): self.date = MonitoredDate( self.top.get_widget("date"), self.top.get_widget("date_stat"), - self.source_ref.get_date_object(),self.window) + self.source_ref.get_date_object(), + self.uistate, + self.track, + self.db.readonly) def _create_tabbed_pages(self): """ diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index 66c4283d0..57a5d71d6 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -465,10 +465,10 @@ class MonitoredStrMenu: class MonitoredDate: - def __init__(self, field, button, value, window, readonly=False): + def __init__(self, field, button, value, uistate, track, readonly=False): self.date = value self.date_check = DateEdit.DateEdit( - self.date, field, button, window) + self.date, field, button, uistate, track) field.set_editable(not readonly) button.set_sensitive(not readonly)