* src/DateEdit.py: Use new Date's set() method. Enable help.

svn: r3563
This commit is contained in:
Alex Roitman 2004-09-21 01:19:55 +00:00
parent 8fffcbc87e
commit 79e34708b1
2 changed files with 32 additions and 27 deletions

View File

@ -17,6 +17,8 @@
* src/DateEdit.py: Use DateHandler instead of low-level DateDisplay; * src/DateEdit.py: Use DateHandler instead of low-level DateDisplay;
(check): Display yellow LED for anything other than regular dates. (check): Display yellow LED for anything other than regular dates.
* src/DateEdit.py: Use new Date's set() method. Enable help.
2004-09-19 Alex Roitman <shura@alex.neuro.umn.edu> 2004-09-19 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Date.py (is_equal): Add method -- needed to compare dates * src/Date.py (is_equal): Add method -- needed to compare dates
for being identical, since __cmp__ only compares the sorting value for being identical, since __cmp__ only compares the sorting value

View File

@ -52,6 +52,7 @@ import gtk
import gtk.gdk import gtk.gdk
import gtk.glade import gtk.glade
import gobject import gobject
import gnome
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -62,6 +63,7 @@ import Date
import DateHandler import DateHandler
import const import const
import Utils import Utils
import QuestionDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -83,6 +85,7 @@ QUAL_TEXT = (
(Date.QUAL_CALCULATED, _('Calculated')) ) (Date.QUAL_CALCULATED, _('Calculated')) )
dd = DateHandler.create_display() dd = DateHandler.create_display()
dp = DateHandler.create_parser()
CAL_TO_MONTHS_NAMES = { CAL_TO_MONTHS_NAMES = {
Date.CAL_GREGORIAN : dd._MONS, Date.CAL_GREGORIAN : dd._MONS,
@ -113,8 +116,6 @@ class DateEdit:
button_obj is pressed. button_obj is pressed.
""" """
self.dp = DateHandler.create_parser()
self.dd = DateHandler.create_display()
self.date_obj = date_obj self.date_obj = date_obj
self.text_obj = text_obj self.text_obj = text_obj
self.button_obj = button_obj self.button_obj = button_obj
@ -147,7 +148,7 @@ class DateEdit:
text = unicode(self.text_obj.get_text()) text = unicode(self.text_obj.get_text())
if text != self.text: if text != self.text:
self.text = text self.text = text
self.date_obj.copy(self.dp.parse(text)) self.date_obj.copy(dp.parse(text))
self.check() self.check()
def invoke_date_editor(self,obj): def invoke_date_editor(self,obj):
@ -160,11 +161,8 @@ class DateEdit:
the_date = date_dialog.return_date the_date = date_dialog.return_date
if the_date: if the_date:
self.date_obj.copy(the_date) self.date_obj.copy(the_date)
self.text_obj.set_text(self.dd.display(self.date_obj)) self.text_obj.set_text(dd.display(self.date_obj))
self.check() self.check()
print "The date was built as follows:", self.date_obj
else:
print "Cancel was pressed, date not changed."
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -245,28 +243,33 @@ class DateEditorDialog:
self.text_entry = self.top.get_widget('date_text_entry') self.text_entry = self.top.get_widget('date_text_entry')
self.text_entry.set_text(self.date.get_text()) self.text_entry.set_text(self.date.get_text())
# The dialog is modal -- since dates don't have name, we don't # The dialog is modal -- since dates don't have names, we don't
# want to have several open dialogs, since then the user will # want to have several open dialogs, since then the user will
# loose track of which is which. # loose track of which is which. Much like opening files.
if parent_window: if parent_window:
self.top_window.set_transient_for(parent_window) self.top_window.set_transient_for(parent_window)
response = self.top_window.run()
self.return_date = None self.return_date = None
while 1:
if response == gtk.RESPONSE_HELP: response = self.top_window.run()
# Here be help :-) if response == gtk.RESPONSE_HELP:
print "Help is not hooked up yet, sorry. Exiting now." try:
elif response == gtk.RESPONSE_OK: gnome.help_display('gramps-manual','index')
(the_quality,the_modifier,the_calendar,the_value,the_text) = \ except gobject.GError, msg:
QuestionDialog.ErrorDialog(_("Could not open help"),str(msg))
elif response == gtk.RESPONSE_OK:
(the_quality,the_modifier,the_calendar,the_value,the_text) = \
self.build_date_from_ui() self.build_date_from_ui()
self.return_date = Date.Date(self.date) self.return_date = Date.Date(self.date)
self.return_date.set( self.return_date.set(
quality=the_quality, quality=the_quality,
modifier=the_modifier, modifier=the_modifier,
calendar=the_calendar, calendar=the_calendar,
value=the_value) value=the_value,
self.return_date.set_text_value(the_text) text=the_text)
break
else:
break
self.top_window.destroy() self.top_window.destroy()
def build_date_from_ui(self): def build_date_from_ui(self):
@ -337,7 +340,7 @@ class DateEditorDialog:
def switch_calendar(self,obj): def switch_calendar(self,obj):
""" """
Change month names and convert the date on the calendar Change month names and convert the date based on the calendar
selected via the menu. selected via the menu.
""" """
@ -350,8 +353,8 @@ class DateEditorDialog:
quality=the_quality, quality=the_quality,
modifier=the_modifier, modifier=the_modifier,
calendar=old_cal, calendar=old_cal,
value=the_value) value=the_value,
self.date.set_text_value(the_text) text=the_text)
self.date.convert_calendar(new_cal) self.date.convert_calendar(new_cal)