2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
# Copyright (C) 2002-2006 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2004-09-19 20:47:57 +05:30
|
|
|
Date editing module for GRAMPS.
|
2004-09-19 05:09:40 +05:30
|
|
|
|
2004-09-21 06:28:39 +05:30
|
|
|
The DateEdit.DateEdit provides visual feedback to the user via a pixamp
|
2002-10-20 19:55:16 +05:30
|
|
|
to indicate if the assocated GtkEntry box contains a valid date. Green
|
2004-09-21 06:28:39 +05:30
|
|
|
means complete and regular date. Yellow means a valid, but not a regular date.
|
2002-10-20 19:55:16 +05:30
|
|
|
Red means that the date is not valid, and will be viewed as a text string
|
|
|
|
instead of a date.
|
2004-09-19 05:09:40 +05:30
|
|
|
|
|
|
|
The DateEdit.DateEditor provides a dialog in which the date can be
|
|
|
|
unambiguously built using UI controls such as menus and spin buttons.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Donald N. Allingham"
|
|
|
|
__version__ = "$Revision$"
|
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2004-09-18 09:28:30 +05:30
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".DateEdit")
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-02-04 03:33:53 +05:30
|
|
|
from RelLib import Date
|
2004-09-19 20:47:57 +05:30
|
|
|
import DateHandler
|
2002-10-20 19:55:16 +05:30
|
|
|
import const
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
2006-05-06 08:44:13 +05:30
|
|
|
import ManagedWindow
|
2007-01-07 04:05:29 +05:30
|
|
|
from Errors import MaskError, ValidationError
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
MOD_TEXT = (
|
2004-09-19 05:09:40 +05:30
|
|
|
(Date.MOD_NONE , _('Regular')),
|
|
|
|
(Date.MOD_BEFORE , _('Before')),
|
|
|
|
(Date.MOD_AFTER , _('After')),
|
|
|
|
(Date.MOD_ABOUT , _('About')),
|
|
|
|
(Date.MOD_RANGE , _('Range')),
|
|
|
|
(Date.MOD_SPAN , _('Span')),
|
|
|
|
(Date.MOD_TEXTONLY , _('Text only')) )
|
|
|
|
|
|
|
|
QUAL_TEXT = (
|
2005-12-06 12:08:09 +05:30
|
|
|
(Date.QUAL_NONE, _('Regular')),
|
|
|
|
(Date.QUAL_ESTIMATED, _('Estimated')),
|
2004-09-19 05:09:40 +05:30
|
|
|
(Date.QUAL_CALCULATED, _('Calculated')) )
|
|
|
|
|
|
|
|
CAL_TO_MONTHS_NAMES = {
|
2004-12-29 10:36:10 +05:30
|
|
|
Date.CAL_GREGORIAN : DateHandler.displayer._MONS,
|
|
|
|
Date.CAL_JULIAN : DateHandler.displayer._MONS,
|
|
|
|
Date.CAL_HEBREW : DateHandler.displayer._hebrew,
|
|
|
|
Date.CAL_FRENCH : DateHandler.displayer._french,
|
|
|
|
Date.CAL_PERSIAN : DateHandler.displayer._persian,
|
|
|
|
Date.CAL_ISLAMIC : DateHandler.displayer._islamic }
|
2004-09-18 09:28:30 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DateEdit
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateEdit:
|
|
|
|
"""Class that associates a pixmap with a text widget, providing visual
|
|
|
|
feedback that indicates if the text widget contains a valid date"""
|
|
|
|
|
2006-05-06 08:44:13 +05:30
|
|
|
def __init__(self, date_obj, text_obj, button_obj, uistate, track):
|
2004-09-19 20:47:57 +05:30
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
2006-05-06 08:44:13 +05:30
|
|
|
self.uistate = uistate
|
|
|
|
self.track = track
|
2004-09-19 20:47:57 +05:30
|
|
|
self.date_obj = date_obj
|
2002-10-20 19:55:16 +05:30
|
|
|
self.text_obj = text_obj
|
2004-09-19 05:09:40 +05:30
|
|
|
self.button_obj = button_obj
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2007-01-07 04:33:55 +05:30
|
|
|
image = gtk.Image()
|
2007-01-07 04:45:58 +05:30
|
|
|
image.set_from_stock('gramps-date', gtk.ICON_SIZE_BUTTON)
|
2007-01-07 04:33:55 +05:30
|
|
|
self.button_obj.set_image(image)
|
2007-01-07 04:45:58 +05:30
|
|
|
self.button_obj.set_relief(gtk.RELIEF_NORMAL)
|
2004-09-19 05:09:40 +05:30
|
|
|
self.pixmap_obj = button_obj.get_child()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-01-07 04:05:29 +05:30
|
|
|
self.text_obj.connect('validate',self.validate)
|
2007-01-11 10:28:31 +05:30
|
|
|
self.text_obj.connect('empty',self.validate)
|
2004-09-19 05:09:40 +05:30
|
|
|
self.button_obj.connect('clicked',self.invoke_date_editor)
|
2003-01-02 10:01:52 +05:30
|
|
|
|
2004-09-19 20:47:57 +05:30
|
|
|
self.text = unicode(self.text_obj.get_text())
|
|
|
|
self.check()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-19 20:47:57 +05:30
|
|
|
def check(self):
|
|
|
|
"""
|
|
|
|
Check current date object and display LED indicating the validity.
|
|
|
|
"""
|
|
|
|
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
2007-01-07 04:05:29 +05:30
|
|
|
self.text_obj.set_invalid()
|
|
|
|
return False
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2007-01-07 04:05:29 +05:30
|
|
|
self.text_obj.set_valid()
|
|
|
|
return True
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
def parse_and_check(self,*obj):
|
2004-09-19 20:47:57 +05:30
|
|
|
"""
|
|
|
|
Called with the text box loses focus. Parses the text and calls
|
|
|
|
the check() method ONLY if the text has changed.
|
|
|
|
"""
|
|
|
|
text = unicode(self.text_obj.get_text())
|
|
|
|
if text != self.text:
|
|
|
|
self.text = text
|
2004-12-29 10:36:10 +05:30
|
|
|
self.date_obj.copy(DateHandler.parser.parse(text))
|
2005-05-24 18:38:06 +05:30
|
|
|
self.text_obj.set_text(DateHandler.displayer.display(self.date_obj))
|
2007-01-07 04:05:29 +05:30
|
|
|
if self.check():
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return ValidationError('Bad Date')
|
|
|
|
|
|
|
|
def validate(self, widget, data):
|
|
|
|
"""
|
|
|
|
Called with the text box loses focus. Parses the text and calls
|
|
|
|
the check() method ONLY if the text has changed.
|
|
|
|
"""
|
|
|
|
self.date_obj.copy(DateHandler.parser.parse(unicode(data)))
|
|
|
|
if self.check():
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return ValidationError('Bad Date')
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
def invoke_date_editor(self,obj):
|
2004-09-19 20:47:57 +05:30
|
|
|
"""
|
|
|
|
Invokes Date Editor dialog when the user clicks the LED button.
|
|
|
|
If date was in fact built, sets the date_obj to the newly built
|
|
|
|
date.
|
|
|
|
"""
|
2006-05-06 08:44:13 +05:30
|
|
|
date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)
|
2004-09-19 20:47:57 +05:30
|
|
|
the_date = date_dialog.return_date
|
2005-03-14 03:40:40 +05:30
|
|
|
self.update_after_editor(the_date)
|
|
|
|
|
|
|
|
def update_after_editor(self,date_obj):
|
|
|
|
"""
|
|
|
|
Update text field and LED button to reflect the given date instance.
|
|
|
|
"""
|
|
|
|
if date_obj:
|
|
|
|
self.date_obj.copy(date_obj)
|
2004-12-29 10:36:10 +05:30
|
|
|
self.text_obj.set_text(DateHandler.displayer.display(self.date_obj))
|
2004-09-20 23:26:26 +05:30
|
|
|
self.check()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DateEditorDialog
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-06 08:44:13 +05:30
|
|
|
class DateEditorDialog(ManagedWindow.ManagedWindow):
|
2004-09-18 09:28:30 +05:30
|
|
|
"""
|
2004-09-19 05:09:40 +05:30
|
|
|
Dialog allowing to build the date precisely, to correct possible
|
|
|
|
limitations of parsing and/or underlying structure of Date.
|
2004-09-18 09:28:30 +05:30
|
|
|
"""
|
|
|
|
|
2006-05-06 08:44:13 +05:30
|
|
|
def __init__(self, date, uistate, track):
|
2004-09-18 09:28:30 +05:30
|
|
|
"""
|
|
|
|
Initiate and display the dialog.
|
|
|
|
"""
|
|
|
|
|
2006-05-06 08:44:13 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
# Create self.date as a copy of the given Date object.
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date = Date(date)
|
2004-09-18 09:28:30 +05:30
|
|
|
|
2006-01-17 10:33:30 +05:30
|
|
|
self.top = gtk.glade.XML(const.gladeFile, "date_edit","gramps" )
|
2004-09-18 09:28:30 +05:30
|
|
|
|
2006-05-06 08:44:13 +05:30
|
|
|
self.set_window(
|
|
|
|
self.top.get_widget('date_edit'),
|
|
|
|
self.top.get_widget('title'),
|
|
|
|
_('Date selection'))
|
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
self.calendar_box = self.top.get_widget('calendar_box')
|
2006-02-04 03:33:53 +05:30
|
|
|
for name in Date.ui_calendar_names:
|
2004-09-18 09:28:30 +05:30
|
|
|
self.calendar_box.append_text(name)
|
2006-05-06 08:44:13 +05:30
|
|
|
|
2004-09-18 09:28:30 +05:30
|
|
|
self.calendar_box.set_active(self.date.get_calendar())
|
2004-09-19 05:09:40 +05:30
|
|
|
self.calendar_box.connect('changed',self.switch_calendar)
|
2004-09-18 09:28:30 +05:30
|
|
|
|
|
|
|
self.quality_box = self.top.get_widget('quality_box')
|
2004-09-19 05:09:40 +05:30
|
|
|
for item_number in range(len(QUAL_TEXT)):
|
|
|
|
self.quality_box.append_text(QUAL_TEXT[item_number][1])
|
|
|
|
if self.date.get_quality() == QUAL_TEXT[item_number][0]:
|
|
|
|
self.quality_box.set_active(item_number)
|
2004-09-18 09:28:30 +05:30
|
|
|
|
|
|
|
self.type_box = self.top.get_widget('type_box')
|
2004-09-19 05:09:40 +05:30
|
|
|
for item_number in range(len(MOD_TEXT)):
|
|
|
|
self.type_box.append_text(MOD_TEXT[item_number][1])
|
|
|
|
if self.date.get_modifier() == MOD_TEXT[item_number][0]:
|
|
|
|
self.type_box.set_active(item_number)
|
2004-09-18 09:28:30 +05:30
|
|
|
self.type_box.connect('changed',self.switch_type)
|
|
|
|
|
|
|
|
self.start_month_box = self.top.get_widget('start_month_box')
|
|
|
|
self.stop_month_box = self.top.get_widget('stop_month_box')
|
2004-09-19 05:09:40 +05:30
|
|
|
month_names = CAL_TO_MONTHS_NAMES[self.date.get_calendar()]
|
|
|
|
for name in month_names:
|
2004-09-18 09:28:30 +05:30
|
|
|
self.start_month_box.append_text(name)
|
|
|
|
self.stop_month_box.append_text(name)
|
|
|
|
self.start_month_box.set_active(self.date.get_month())
|
|
|
|
self.stop_month_box.set_active(self.date.get_stop_month())
|
|
|
|
|
|
|
|
self.start_day = self.top.get_widget('start_day')
|
|
|
|
self.start_day.set_value(self.date.get_day())
|
|
|
|
self.start_year = self.top.get_widget('start_year')
|
|
|
|
self.start_year.set_value(self.date.get_year())
|
|
|
|
|
|
|
|
self.stop_day = self.top.get_widget('stop_day')
|
|
|
|
self.stop_day.set_value(self.date.get_stop_day())
|
|
|
|
self.stop_year = self.top.get_widget('stop_year')
|
|
|
|
self.stop_year.set_value(self.date.get_stop_year())
|
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
# Disable second date controls if not compound date
|
2004-09-18 09:28:30 +05:30
|
|
|
if not self.date.is_compound():
|
|
|
|
self.stop_day.set_sensitive(0)
|
|
|
|
self.stop_month_box.set_sensitive(0)
|
|
|
|
self.stop_year.set_sensitive(0)
|
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
# Disable the rest of controls if a text-only date
|
2004-09-18 09:28:30 +05:30
|
|
|
if self.date.get_modifier() == Date.MOD_TEXTONLY:
|
|
|
|
self.start_day.set_sensitive(0)
|
|
|
|
self.start_month_box.set_sensitive(0)
|
|
|
|
self.start_year.set_sensitive(0)
|
|
|
|
self.calendar_box.set_sensitive(0)
|
|
|
|
self.quality_box.set_sensitive(0)
|
|
|
|
|
|
|
|
self.text_entry = self.top.get_widget('date_text_entry')
|
|
|
|
self.text_entry.set_text(self.date.get_text())
|
2004-09-19 05:09:40 +05:30
|
|
|
|
2004-09-21 06:49:55 +05:30
|
|
|
# The dialog is modal -- since dates don't have names, we don't
|
2004-09-19 05:09:40 +05:30
|
|
|
# want to have several open dialogs, since then the user will
|
2004-09-21 06:49:55 +05:30
|
|
|
# loose track of which is which. Much like opening files.
|
|
|
|
|
2004-09-19 20:47:57 +05:30
|
|
|
self.return_date = None
|
2006-05-06 08:44:13 +05:30
|
|
|
|
|
|
|
self.show()
|
2006-06-22 00:48:54 +05:30
|
|
|
|
2006-05-06 08:44:13 +05:30
|
|
|
while True:
|
|
|
|
response = self.window.run()
|
2004-09-21 06:49:55 +05:30
|
|
|
if response == gtk.RESPONSE_HELP:
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('adv-dates')
|
2006-06-22 00:48:54 +05:30
|
|
|
elif response == gtk.RESPONSE_DELETE_EVENT:
|
|
|
|
return
|
2004-09-21 06:49:55 +05:30
|
|
|
else:
|
2006-06-22 00:48:54 +05:30
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
(the_quality,the_modifier,the_calendar,
|
|
|
|
the_value,the_text) = self.build_date_from_ui()
|
|
|
|
self.return_date = Date(self.date)
|
|
|
|
self.return_date.set(
|
|
|
|
quality=the_quality,
|
|
|
|
modifier=the_modifier,
|
|
|
|
calendar=the_calendar,
|
|
|
|
value=the_value,
|
|
|
|
text=the_text)
|
|
|
|
self.close()
|
|
|
|
return
|
2006-05-06 08:44:13 +05:30
|
|
|
|
|
|
|
def build_menu_names(self, obj):
|
|
|
|
return (_("Date selection"), None)
|
2004-09-18 09:28:30 +05:30
|
|
|
|
|
|
|
def build_date_from_ui(self):
|
2004-09-19 05:09:40 +05:30
|
|
|
"""
|
|
|
|
Collect information from the UI controls and return
|
|
|
|
5-tuple of (quality,modifier,calendar,value,text)
|
|
|
|
"""
|
|
|
|
# It is important to not set date based on these controls.
|
|
|
|
# For example, changing the caledar makes the date inconsistent
|
|
|
|
# until the callback of the calendar menu is finished.
|
|
|
|
# We need to be able to use this function from that callback,
|
|
|
|
# so here we just report on the state of all widgets, without
|
|
|
|
# actually modifying the date yet.
|
|
|
|
|
|
|
|
modifier = MOD_TEXT[self.type_box.get_active()][0]
|
|
|
|
text = self.text_entry.get_text()
|
2004-09-18 09:28:30 +05:30
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
if modifier == Date.MOD_TEXTONLY:
|
|
|
|
return (Date.QUAL_NONE,Date.MOD_TEXTONLY,Date.CAL_GREGORIAN,
|
2006-02-04 03:33:53 +05:30
|
|
|
Date.EMPTY,text)
|
2004-09-19 05:09:40 +05:30
|
|
|
|
|
|
|
quality = QUAL_TEXT[self.quality_box.get_active()][0]
|
|
|
|
|
|
|
|
if modifier in (Date.MOD_RANGE,Date.MOD_SPAN):
|
|
|
|
value = (
|
2004-09-18 09:28:30 +05:30
|
|
|
self.start_day.get_value_as_int(),
|
|
|
|
self.start_month_box.get_active(),
|
|
|
|
self.start_year.get_value_as_int(),
|
|
|
|
False,
|
|
|
|
self.stop_day.get_value_as_int(),
|
|
|
|
self.stop_month_box.get_active(),
|
|
|
|
self.stop_year.get_value_as_int(),
|
|
|
|
False)
|
|
|
|
else:
|
2004-09-19 05:09:40 +05:30
|
|
|
value = (
|
2004-09-18 09:28:30 +05:30
|
|
|
self.start_day.get_value_as_int(),
|
|
|
|
self.start_month_box.get_active(),
|
|
|
|
self.start_year.get_value_as_int(),
|
|
|
|
False)
|
2004-09-19 05:09:40 +05:30
|
|
|
calendar = self.calendar_box.get_active()
|
|
|
|
return (quality,modifier,calendar,value,text)
|
2004-09-18 09:28:30 +05:30
|
|
|
|
|
|
|
def switch_type(self,obj):
|
|
|
|
"""
|
|
|
|
Disable/enable various date controls depending on the date
|
|
|
|
type selected via the menu.
|
|
|
|
"""
|
2004-09-19 05:09:40 +05:30
|
|
|
|
|
|
|
the_modifier = MOD_TEXT[self.type_box.get_active()][0]
|
|
|
|
|
|
|
|
# Disable/enable second date controls based on whether
|
|
|
|
# the type allows compound dates
|
|
|
|
if the_modifier in (Date.MOD_RANGE,Date.MOD_SPAN):
|
2004-09-18 09:28:30 +05:30
|
|
|
stop_date_sensitivity = 1
|
|
|
|
else:
|
|
|
|
stop_date_sensitivity = 0
|
|
|
|
self.stop_day.set_sensitive(stop_date_sensitivity)
|
|
|
|
self.stop_month_box.set_sensitive(stop_date_sensitivity)
|
|
|
|
self.stop_year.set_sensitive(stop_date_sensitivity)
|
|
|
|
|
2004-09-19 05:09:40 +05:30
|
|
|
# Disable/enable the rest of the controls if the type is text-only.
|
|
|
|
date_sensitivity = not the_modifier == Date.MOD_TEXTONLY
|
2004-09-18 09:28:30 +05:30
|
|
|
self.start_day.set_sensitive(date_sensitivity)
|
|
|
|
self.start_month_box.set_sensitive(date_sensitivity)
|
|
|
|
self.start_year.set_sensitive(date_sensitivity)
|
|
|
|
self.calendar_box.set_sensitive(date_sensitivity)
|
|
|
|
self.quality_box.set_sensitive(date_sensitivity)
|
2004-09-19 05:09:40 +05:30
|
|
|
|
|
|
|
def switch_calendar(self,obj):
|
|
|
|
"""
|
2004-09-21 06:49:55 +05:30
|
|
|
Change month names and convert the date based on the calendar
|
2004-09-19 05:09:40 +05:30
|
|
|
selected via the menu.
|
|
|
|
"""
|
|
|
|
|
|
|
|
old_cal = self.date.get_calendar()
|
|
|
|
new_cal = self.calendar_box.get_active()
|
|
|
|
|
|
|
|
(the_quality,the_modifier,the_calendar,the_value,the_text) = \
|
|
|
|
self.build_date_from_ui()
|
|
|
|
self.date.set(
|
|
|
|
quality=the_quality,
|
|
|
|
modifier=the_modifier,
|
|
|
|
calendar=old_cal,
|
2004-09-21 06:49:55 +05:30
|
|
|
value=the_value,
|
|
|
|
text=the_text)
|
2004-09-19 05:09:40 +05:30
|
|
|
|
|
|
|
self.date.convert_calendar(new_cal)
|
|
|
|
|
|
|
|
self.start_month_box.get_model().clear()
|
|
|
|
self.stop_month_box.get_model().clear()
|
|
|
|
month_names = CAL_TO_MONTHS_NAMES[new_cal]
|
|
|
|
for name in month_names:
|
|
|
|
self.start_month_box.append_text(name)
|
|
|
|
self.stop_month_box.append_text(name)
|
|
|
|
|
|
|
|
self.start_day.set_value(self.date.get_day())
|
|
|
|
self.start_month_box.set_active(self.date.get_month())
|
|
|
|
self.start_year.set_value(self.date.get_year())
|
|
|
|
self.stop_day.set_value(self.date.get_stop_day())
|
|
|
|
self.stop_month_box.set_active(self.date.get_stop_month())
|
|
|
|
self.stop_year.set_value(self.date.get_stop_year())
|