2006-05-17 Don Allingham <don@gramps-project.org>
* 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 svn: r6695
This commit is contained in:
parent
25860314ed
commit
9b03472a0a
@ -1,3 +1,9 @@
|
||||
2006-05-17 Don Allingham <don@gramps-project.org>
|
||||
* 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 <shura@gramps-project.org>
|
||||
* src/GrampsWidgets.py (LinkLabel.__init__): Set cursor to HAND1.
|
||||
|
||||
|
@ -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"))
|
||||
|
||||
|
@ -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"),
|
||||
|
@ -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()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
@ -13613,27 +13613,6 @@ Text Beside Icons</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="eer_place">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="eer_cause">
|
||||
<property name="visible">True</property>
|
||||
@ -13735,6 +13714,65 @@ Text Beside Icons</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox132">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="eer_place">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="share_place">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image2702">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="gid">
|
||||
<property name="visible">True</property>
|
||||
@ -13755,6 +13793,33 @@ Text Beside Icons</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="add_del_place">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image2701">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
|
Loading…
Reference in New Issue
Block a user