diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 8fe5d7022..80a903f01 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-05-17 Don Allingham + * src/Editors/_EditPlace.py: new SelectPlace interface + * src/Editors/_EditEventRef.py: new SelectPlace interface + * src/Editors/_EditEvent.py: new SelectPlace interface + * src/GrampsWidgets.py: new Place editor interface + 2006-05-17 Alex Roitman * src/GrampsWidgets.py (LinkLabel.__init__): Set cursor to HAND1. diff --git a/gramps2/src/Editors/_EditEvent.py b/gramps2/src/Editors/_EditEvent.py index 9a9b227ae..abdf812c6 100644 --- a/gramps2/src/Editors/_EditEvent.py +++ b/gramps2/src/Editors/_EditEvent.py @@ -114,7 +114,9 @@ class EditEvent(EditPrimary): # place, select_place, add_del_place self.place_field = PlaceEntry( - self.db, + self.dbstate, + self.uistate, + self.track, self.top.get_widget("place"), self.obj.set_place_handle, self.obj.get_place_handle, @@ -207,26 +209,14 @@ class EditEvent(EditPrimary): "enter data or cancel the edit.")) return - (need_new, handle) = self.place_field.get_place_info() - if need_new: - place_obj = RelLib.Place() - place_obj.set_title(handle) - self.obj.set_place_handle(place_obj.get_handle()) - else: - self.obj.set_place_handle(handle) - if self.obj.handle == None: trans = self.db.transaction_begin() - if need_new: - self.db.add_place(place_obj,trans) self.db.add_event(self.obj,trans) self.db.transaction_commit(trans,_("Add Event")) else: orig = self.dbstate.db.get_event_from_handle(self.obj.handle) if cmp(self.obj.serialize(),orig.serialize()): trans = self.db.transaction_begin() - if need_new: - self.db.add_place(place_obj,trans) self.commit_event(self.obj,trans) self.db.transaction_commit(trans,_("Edit Event")) diff --git a/gramps2/src/Editors/_EditEventRef.py b/gramps2/src/Editors/_EditEventRef.py index 629f793ac..ee4eca875 100644 --- a/gramps2/src/Editors/_EditEventRef.py +++ b/gramps2/src/Editors/_EditEventRef.py @@ -78,6 +78,8 @@ class EditEventRef(EditReference): _('Event Reference Editor')) self.define_warn_box(self.top.get_widget("eer_warning")) self.define_expander(self.top.get_widget("eer_expander")) + self.share_btn = self.top.get_widget('share_place') + self.add_del_btn = self.top.get_widget('add_del_place') def _init_event(self): self.commit_event = self.db.commit_personal_event @@ -115,10 +117,14 @@ class EditEventRef(EditReference): self.db.readonly) self.place_field = PlaceEntry( + self.dbstate, + self.uistate, + self.track, self.top.get_widget("eer_place"), - self.source.get_place_handle(), - self.dbstate.get_place_completion(), - self.db.readonly) + self.source.set_place_handle, + self.source.get_place_handle, + self.add_del_btn, + self.share_btn) self.ev_privacy = PrivacyButton( self.top.get_widget("eer_ev_priv"), diff --git a/gramps2/src/Editors/_EditPlace.py b/gramps2/src/Editors/_EditPlace.py index 2634db41c..b4b5cf083 100644 --- a/gramps2/src/Editors/_EditPlace.py +++ b/gramps2/src/Editors/_EditPlace.py @@ -208,6 +208,8 @@ class EditPlace(EditPrimary): self.db.transaction_commit(trans, _("Edit Place (%s)") % self.obj.get_title()) + if self.callback: + self.callback(self.obj) self.close() #------------------------------------------------------------------------- diff --git a/gramps2/src/GrampsWidgets.py b/gramps2/src/GrampsWidgets.py index 2eccee9a2..fc584b2f4 100644 --- a/gramps2/src/GrampsWidgets.py +++ b/gramps2/src/GrampsWidgets.py @@ -474,15 +474,21 @@ class MonitoredDate: field.set_text(DateHandler.displayer.display(self.date)) class PlaceEntry: - - def __init__(self, db, obj, set_val, get_val, add_del, share): + """ + handles the selection of a existing or new Place + """ + def __init__(self, dbstate, uistate, track, obj, set_val, + get_val, add_del, share): self.obj = obj self.add_del = add_del self.share = share - self.db = db + self.dbstate = dbstate + self.db = dbstate.db self.get_val = get_val self.set_val = set_val + self.uistate = uistate + self.track = track if get_val(): self.set_button(True) @@ -492,28 +498,79 @@ class PlaceEntry: name = u"" self.set_button(False) - if db.readonly: + if self.db.readonly: self.add_del.set_sensitive(False) self.share.set_sensitive(False) else: self.add_del.set_sensitive(True) self.share.set_sensitive(True) + + self.add_del.connect('clicked', self.add_del_clicked) + self.share.connect('clicked', self.share_clicked) obj.set_text(name) + def after_edit(self, place): + name = "%s [%s]" % (place.get_title(),place.gramps_id) + self.obj.set_text(name) + + def add_del_clicked(self, obj): + if self.get_val(): + self.set_val(None) + self.obj.set_text(u'') + self.set_button(False) + else: + from RelLib import Place + from Editors import EditPlace + + place = Place() + EditPlace(self.dbstate, self.uistate, self.track, + place, self.place_added) + + def place_added(self, data): + self.set_val(data.handle) + self.obj.set_text("%s [%s]" % (data.get_title(),data.gramps_id)) + self.set_button(True) + + def share_clicked(self, obj): + if self.get_val(): + from Editors import EditPlace + + place = self.db.get_place_from_handle(self.get_val()) + EditPlace(self.dbstate, self.uistate, self.track, place, + self.after_edit) + else: + from Selectors import selector_factory + cls = selector_factory('Place') + select = cls(self.dbstate, self.uistate, self.track) + place = select.run() + if place: + self.place_added(place) + def set_button(self, use_add): for i in self.add_del.get_children(): self.add_del.remove(i) + for i in self.share.get_children(): + self.share.remove(i) - image = gtk.Image() if use_add: + image = gtk.Image() image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON) - self.share.hide() + image.show() + self.add_del.add(image) + image = gtk.Image() + image.set_from_stock(gtk.STOCK_EDIT,gtk.ICON_SIZE_BUTTON) + image.show() + self.share.add(image) else: + image = gtk.Image() image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_BUTTON) - self.share.show() - image.show() - self.add_del.add(image) + image.show() + self.add_del.add(image) + image = gtk.Image() + image.set_from_stock(gtk.STOCK_INDEX,gtk.ICON_SIZE_BUTTON) + image.show() + self.share.add(image) diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index 756593e45..9a43779dd 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -13613,27 +13613,6 @@ Text Beside Icons - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 3 - 4 - - - - True @@ -13735,6 +13714,65 @@ Text Beside Icons + + + True + False + 0 + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + + True + True + GTK_RELIEF_NONE + True + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 1 + 2 + 3 + 4 + fill + fill + + + True @@ -13755,6 +13793,33 @@ Text Beside Icons + + + + True + True + GTK_RELIEF_NONE + True + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 3 + 4 + fill + + + False