From b4ab3048917cf2a7fa657e6a2c57573c3f460334 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sat, 18 Sep 2004 03:58:30 +0000 Subject: [PATCH] * src/gramps.glade: Add date_edit dialog. * src/DateEdit.py (DateEditorDialog): Add class. * src/Date.py (get_quality): Typo. * src/AddrEdit.py: Use date editor callback. * src/EditPerson.py: Use date editor callback. * src/EventEdit.py: Use date editor callback. * src/AddrEdit.py: Add date editor callback * src/EditPerson.py: Add date editor callback * src/EventEdit.py: Add date editor callback svn: r3552 --- ChangeLog | 14 +- src/AddrEdit.py | 10 +- src/Date.py | 2 +- src/DateEdit.py | 160 +++++++++++- src/EditPerson.py | 10 +- src/EventEdit.py | 27 +- src/gramps.glade | 632 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 818 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad74e568f..3d700146f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,19 @@ +2004-09-17 Alex Roitman + * src/gramps.glade: Add date_edit dialog. + * src/DateEdit.py (DateEditorDialog): Add class. + * src/Date.py (get_quality): Typo. + * src/AddrEdit.py: Use date editor callback. + * src/EditPerson.py: Use date editor callback. + * src/EventEdit.py: Use date editor callback. + 2004-09-17 Don Allingham * src/DateDisplay.py: use locale.nl_langinfo to get month names without manual encoding * src/DateParser.py: use locale.nl_langinfo to get month names without manual encoding - * src/AddrEdit.py: Add date editor callback - * src/EditPerson.py: Add date editor callback - * src/EventEdit.py: Add date editor callback + * src/AddrEdit.py: Add date editor callback + * src/EditPerson.py: Add date editor callback + * src/EventEdit.py: Add date editor callback * src/gramps.glade: replace LED indicators with buttons 2004-09-16 Don Allingham diff --git a/src/AddrEdit.py b/src/AddrEdit.py index 4af008b37..1c92e439b 100644 --- a/src/AddrEdit.py +++ b/src/AddrEdit.py @@ -44,7 +44,7 @@ import Date import RelLib import Sources -from DateEdit import DateEdit +import DateEdit from gettext import gettext as _ #------------------------------------------------------------------------- @@ -133,7 +133,7 @@ class AddressEditor: self.top.get_widget('del_src')) date_stat = self.top.get_widget("date_stat") - self.date_check = DateEdit(self.addr_start,date_stat) + self.date_check = DateEdit.DateEdit(self.addr_start,date_stat) self.top.signal_autoconnect({ "on_switch_page" : self.on_switch_page, @@ -150,9 +150,9 @@ class AddressEditor: self.window.show() def on_date_edit_clicked(self,obj): - from QuestionDialog import ErrorDialog - ErrorDialog("Not implemented yet", - "The Date Editor has not been implemented yet") + date_dialog = DateEdit.DateEditorDialog(self.addr_start.checkval) + the_date = date_dialog.get_date() + print "The date was built as follows:", the_date def on_delete_event(self,obj,b): self.close_child_windows() diff --git a/src/Date.py b/src/Date.py index 440e4ccb3..79ccf49f3 100644 --- a/src/Date.py +++ b/src/Date.py @@ -215,7 +215,7 @@ class Date: QUAL_ESTIMATED = estimated QUAL_CALCULATED = calculated """ - return self.modifier + return self.quality def set_quality(self,val): """ diff --git a/src/DateEdit.py b/src/DateEdit.py index 730b7922a..3c7328215 100644 --- a/src/DateEdit.py +++ b/src/DateEdit.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2002 Donald N. Allingham +# Copyright (C) 2002-2004 Donald N. Allingham # # 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 @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + """ The DateEdit interface provides visual feedback to the user via a pixamp to indicate if the assocated GtkEntry box contains a valid date. Green @@ -29,6 +31,13 @@ instead of a date. __author__ = "Donald N. Allingham" __version__ = "$Revision$" +#------------------------------------------------------------------------- +# +# Python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + #------------------------------------------------------------------------- # # GNOME modules @@ -36,6 +45,7 @@ __version__ = "$Revision$" #------------------------------------------------------------------------- import gtk import gtk.gdk +import gtk.glade #------------------------------------------------------------------------- # @@ -44,8 +54,27 @@ import gtk.gdk #------------------------------------------------------------------------- import Date import DateParser +import DateDisplay import const +#------------------------------------------------------------------------- +# +# Constants +# +#------------------------------------------------------------------------- +MOD_TEXT = ( + _('Regular'), _('Before'), _('After'), _('About'), + _('Range'), _('Span'), _('Text only') ) +QUAL_TEXT = ( _('Regular'), _('Estimated'), _('Calculated') ) +MONTHS_NAMES = ( + DateDisplay.DateDisplay._MONS, + DateDisplay.DateDisplay._MONS, + DateDisplay.DateDisplay._hebrew, + DateDisplay.DateDisplay._french, + DateDisplay.DateDisplay._persian, + DateDisplay.DateDisplay._islamic, + ) + #------------------------------------------------------------------------- # # DateEdit @@ -83,5 +112,132 @@ class DateEdit: # self.pixmap_obj.set_from_pixbuf(DateEdit.caution) else: self.pixmap_obj.set_from_pixbuf(DateEdit.good) - +#------------------------------------------------------------------------- +# +# DateEditorDialog +# +#------------------------------------------------------------------------- +class DateEditorDialog: + """ + Dialog allowing to build the date precisely, to correct defficiencies + of parsing. + """ + + def __init__(self,date): + """ + Initiate and display the dialog. + """ + + self.date = date + + self.top = gtk.glade.XML(const.dialogFile, "date_edit","gramps" ) + self.top_window = self.top.get_widget('date_edit') + + self.calendar_box = self.top.get_widget('calendar_box') + for name in Date.Date.calendar_names: + self.calendar_box.append_text(name) + self.calendar_box.set_active(self.date.get_calendar()) + + self.quality_box = self.top.get_widget('quality_box') + for name in QUAL_TEXT: + self.quality_box.append_text(name) + self.quality_box.set_active(self.date.get_quality()) + + self.type_box = self.top.get_widget('type_box') + for name in MOD_TEXT: + self.type_box.append_text(name) + self.type_box.set_active(self.date.get_modifier()) + 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') + for name in MONTHS_NAMES[self.date.get_calendar()]: + 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()) + + 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) + + 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()) + + response = self.top_window.run() + + if response == gtk.RESPONSE_HELP: + print "Help is not hooked up yet, sorry. Exiting now." + elif response == gtk.RESPONSE_OK: + self.build_date_from_ui() + self.top_window.destroy() + + def get_date(self): + return self.date + + def build_date_from_ui(self): + if self.type_box.get_active() == Date.MOD_TEXTONLY: + self.date.set_as_text(self.text_entry.get_text()) + return + + if self.type_box.get_active() in (Date.MOD_RANGE,Date.MOD_SPAN): + date_tuple = ( + 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: + date_tuple = ( + self.start_day.get_value_as_int(), + self.start_month_box.get_active(), + self.start_year.get_value_as_int(), + False) + self.date.set( + quality=self.quality_box.get_active(), + modifier=self.type_box.get_active(), + calendar=self.calendar_box.get_active(), + value=date_tuple) + self.date.set_text_value(self.text_entry.get_text()) + + def switch_type(self,obj): + """ + Disable/enable various date controls depending on the date + type selected via the menu. + """ + if self.type_box.get_active() in (Date.MOD_RANGE,Date.MOD_SPAN): + 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) + + date_sensitivity = not self.type_box.get_active() == Date.MOD_TEXTONLY + 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) diff --git a/src/EditPerson.py b/src/EditPerson.py index 345618c71..1393b5067 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -449,12 +449,14 @@ class EditPerson: self.window.show() def on_edit_date_birth_clicked(self,obj): - ErrorDialog("Not implemented yet", - "The Date Editor has not been implemented yet") + date_dialog = DateEdit.DateEditorDialog(self.bdate_check.checkval) + the_date = date_dialog.get_date() + print "The date was built as follows:", the_date def on_edit_date_death_clicked(self,obj): - ErrorDialog("Not implemented yet", - "The Date Editor has not been implemented yet") + date_dialog = DateEdit.DateEditorDialog(self.ddate_check.checkval) + the_date = date_dialog.get_date() + print "The date was built as follows:", the_date def close_child_windows(self): for child_window in self.child_windows.values(): diff --git a/src/EventEdit.py b/src/EventEdit.py index e0a7ec76d..0b073fa5e 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -48,7 +48,7 @@ import DateParser import DateHandler import ImageSelect -from DateEdit import DateEdit +import DateEdit from gettext import gettext as _ from QuestionDialog import WarningDialog @@ -136,7 +136,6 @@ class EventEditor: self.note_field = self.top.get_widget("eventNote") self.event_menu = self.top.get_widget("personal_events") self.priv = self.top.get_widget("priv") - self.calendar = self.top.get_widget("calendar") self.sources_label = self.top.get_widget("sourcesEvent") self.notes_label = self.top.get_widget("notesEvent") self.flowed = self.top.get_widget("eventflowed") @@ -144,8 +143,6 @@ class EventEditor: self.gallery_label = self.top.get_widget("galleryEvent") self.witnesses_label = self.top.get_widget("witnessesEvent") - self.calendar.show() - if read_only: self.event_menu.set_sensitive(0) self.date_field.grab_focus() @@ -197,7 +194,7 @@ class EventEditor: self.event_menu.child.set_text(def_event) if def_placename: self.place_field.set_text(def_placename) - self.date_check = DateEdit(self.date_field,self.top.get_widget("date_stat")) + self.date_check = DateEdit.DateEdit(self.date_field,self.top.get_widget("date_stat")) if not event: event = RelLib.Event() @@ -219,28 +216,14 @@ class EventEditor: "on_date_edit_clicked" : self.on_date_edit_clicked, }) - menu = gtk.Menu() - index = 0 - for cobj in Date.Date.calendar: - item = gtk.MenuItem(cobj) - item.set_data("d",index) - item.connect("activate",self.on_menu_changed) - item.show() - menu.append(item) - if self.date.get_calendar() == index: - menu.set_active(index) - self.date_check.set_calendar(index) - index += 1 - self.calendar.set_menu(menu) - self.window.set_transient_for(self.parent.window) self.add_itself_to_menu() self.window.show() def on_date_edit_clicked(self,obj): - from QuestionDialog import ErrorDialog - ErrorDialog("Not implemented yet", - "The Date Editor has not been implemented yet") + date_dialog = DateEdit.DateEditorDialog(self.date_check.checkval) + the_date = date_dialog.get_date() + print "The date was built as follows:", the_date def on_delete_event(self,obj,b): self.gallery.close() diff --git a/src/gramps.glade b/src/gramps.glade index 0928295d8..48487e632 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -30727,4 +30727,636 @@ Other + + True + Date selection - GRAMPS + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + <b><big>Date selection</big></b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + Calendar: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 6 + False + True + + + + + + True + + + + 6 + True + True + + + + + 6 + False + True + + + + + + True + 5 + 8 + False + 6 + 6 + + + + True + Year + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 7 + 8 + 3 + 4 + fill + + + + + + + True + Month + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 6 + 7 + 3 + 4 + fill + + + + + + + True + Day + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 5 + 6 + 3 + 4 + fill + + + + + + + True + Year + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 3 + 4 + 3 + 4 + fill + + + + + + + True + Month + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 2 + 3 + 3 + 4 + fill + + + + + + + True + Day + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + <b>Date</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 4 + 2 + 3 + fill + + + + + + + True + <b>Second date</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 4 + 8 + 2 + 3 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 31 1 10 10 + + + 1 + 2 + 4 + 5 + 6 + + + + + + + True + False + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 31 1 10 10 + + + 5 + 6 + 4 + 5 + 6 + + + + + + + True + False + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 2100 1 10 10 + + + 7 + 8 + 4 + 5 + 6 + + + + + + + True + <b>Quality</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 0 + 4 + 0 + 1 + fill + + + + + + + True + <b>Type</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + + + 4 + 8 + 0 + 1 + fill + + + + + + + True + + + + 6 + 7 + 4 + 5 + 6 + fill + + + + + + True + + + + 2 + 3 + 4 + 5 + 6 + fill + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 2100 1 10 10 + + + 3 + 4 + 4 + 5 + 6 + + + + + + + True + + + + 1 + 4 + 1 + 2 + 6 + 6 + fill + fill + + + + + + True + + + + 5 + 8 + 1 + 2 + 6 + 6 + fill + fill + + + + + 6 + True + True + + + + + + True + False + 0 + + + + True + Text comment: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 6 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 6 + True + True + + + + + 6 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + +