svn: r7368

This commit is contained in:
Don Allingham 2006-10-08 04:17:04 +00:00
parent bec0ca3155
commit 559882d64f
7 changed files with 61 additions and 40 deletions

View File

@ -277,6 +277,8 @@ class EmbeddedList(ButtonTab):
""" """
(model, node) = self.selection.get_selected() (model, node) = self.selection.get_selected()
if node: if node:
obj = self.model.get_value(node, self._HANDLE_COL)
print "Select", obj, obj.ref, obj.get_reference_handle()
return model.get_value(node, self._HANDLE_COL) return model.get_value(node, self._HANDLE_COL)
return None return None

View File

@ -83,17 +83,6 @@ class EventEmbedList(EmbeddedList):
def column_order(self): def column_order(self):
return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)) return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5))
def handle_extra_type(self, objtype, obj):
try:
ref = RelLib.EventRef()
event = self.dbstate.db.get_event_from_handle(obj)
ref.set_role(self.default_role())
self.get_ref_editor()(
self.dbstate, self.uistate, self.track,
event, ref, self.event_added)
except Errors.WindowActiveError:
pass
def default_type(self): def default_type(self):
return RelLib.EventType(RelLib.EventType.MARRIAGE) return RelLib.EventType(RelLib.EventType.MARRIAGE)
@ -108,7 +97,7 @@ class EventEmbedList(EmbeddedList):
event.set_type(self.default_type()) event.set_type(self.default_type())
self.get_ref_editor()( self.get_ref_editor()(
self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track,
event, ref, self.event_added) event, ref, self.object_added)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -124,7 +113,7 @@ class EventEmbedList(EmbeddedList):
ref.set_role(self.default_role()) ref.set_role(self.default_role())
self.get_ref_editor()( self.get_ref_editor()(
self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track,
event, ref, self.event_added) event, ref, self.object_added)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -135,7 +124,7 @@ class EventEmbedList(EmbeddedList):
try: try:
self.get_ref_editor()( self.get_ref_editor()(
self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track,
event, ref, self.event_updated) event, ref, self.object_edited)
except Errors.WindowActiveError: except Errors.WindowActiveError:
from QuestionDialog import WarningDialog from QuestionDialog import WarningDialog
WarningDialog( WarningDialog(
@ -147,13 +136,13 @@ class EventEmbedList(EmbeddedList):
"reference, you need to close the event.") "reference, you need to close the event.")
) )
def event_updated(self, ref, event): def object_added(self, reference, primary):
reference.ref = primary.handle
self.get_data().append(reference)
self.changed = True self.changed = True
self.rebuild() self.rebuild()
def event_added(self, ref, event): def object_edited(self, ref, event):
ref.ref = event.handle
self.get_data().append(ref)
self.changed = True self.changed = True
self.rebuild() self.rebuild()
@ -170,4 +159,16 @@ class EventEmbedList(EmbeddedList):
event = self.dbstate.db.get_event_from_handle(obj.ref) event = self.dbstate.db.get_event_from_handle(obj.ref)
self.get_ref_editor()( self.get_ref_editor()(
self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track,
event, obj, self.event_updated) event, obj, self.object_edited)
def handle_extra_type(self, objtype, obj):
try:
ref = RelLib.EventRef()
event = self.dbstate.db.get_event_from_handle(obj)
ref.set_role(self.default_role())
self.get_ref_editor()(
self.dbstate, self.uistate, self.track,
event, ref, self.object_added)
except Errors.WindowActiveError:
pass

View File

@ -144,7 +144,17 @@ class RepoEmbedList(EmbeddedList):
self.dbstate, self.uistate, self.track, repo, self.dbstate, self.uistate, self.track, repo,
ref, self.edit_callback) ref, self.edit_callback)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass from QuestionDialog import WarningDialog
WarningDialog(
_("Cannot edit this reference"),
_("This repository reference cannot be edited at this "
"time. Either the associated repository is already "
"being edited or another repository reference that is "
"associated with the same repository is being edited."
"\n\nTo edit this repository reference, you need to "
"close the repository.")
)
def edit_callback(self, name): def edit_callback(self, name):
self.changed = True self.changed = True

View File

@ -34,6 +34,7 @@ from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import RelLib import RelLib
import Errors import Errors
import Utils
from DdTargets import DdTargets from DdTargets import DdTargets
from _SourceRefModel import SourceRefModel from _SourceRefModel import SourceRefModel
from _EmbeddedList import EmbeddedList from _EmbeddedList import EmbeddedList
@ -72,25 +73,24 @@ class SourceEmbedList(EmbeddedList):
return 'gramps-source' return 'gramps-source'
def get_data(self): def get_data(self):
return self.obj return self.obj.get_source_references()
def column_order(self): def column_order(self):
return ((1, 0), (1, 1), (1, 2), (1, 3)) return ((1, 0), (1, 1), (1, 2), (1, 3))
def add_button_clicked(self, obj): def add_button_clicked(self, obj):
sref = RelLib.SourceRef()
src = RelLib.Source()
try: try:
from Editors import EditSourceRef from Editors import EditSourceRef
sref = RelLib.SourceRef()
src = RelLib.Source()
EditSourceRef( EditSourceRef(
self.dbstate, self.dbstate,
self.uistate, self.uistate,
self.track, self.track,
src, src,
sref, sref,
self.add_callback) self.object_added)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -99,7 +99,6 @@ class SourceEmbedList(EmbeddedList):
SelectSource = selector_factory('Source') SelectSource = selector_factory('Source')
sel = SelectSource(self.dbstate,self.uistate,self.track) sel = SelectSource(self.dbstate,self.uistate,self.track)
src = sel.run() src = sel.run()
if src: if src:
try: try:
@ -111,30 +110,39 @@ class SourceEmbedList(EmbeddedList):
self.track, self.track,
src, src,
ref, ref,
self.add_callback) self.object_added)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
def add_callback(self, reference, primary):
reference.ref = primary.handle
self.get_data().append(reference)
self.changed = True
self.rebuild()
def edit_button_clicked(self, obj): def edit_button_clicked(self, obj):
sref = self.get_selected() sref = self.get_selected()
if sref: if sref:
src = self.dbstate.db.get_source_from_handle(sref.ref) src = self.dbstate.db.get_source_from_handle(sref.ref)
try: try:
from Editors import EditSourceRef from Editors import EditSourceRef
EditSourceRef(self.dbstate, self.uistate, self.track, EditSourceRef(self.dbstate, self.uistate, self.track,
src, sref, self.edit_callback) src, sref, self.object_edited)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass from QuestionDialog import WarningDialog
WarningDialog(
_("Cannot edit this reference"),
_("This source reference cannot be edited at this time. "
"Either the associated source is already being edited "
"or another source reference that is associated with "
"the same source is being edited.\n\nTo edit this "
"source reference, you need to close the source.")
)
def edit_callback(self, refererence, primary): def object_added(self, reference, primary):
reference.ref = primary.handle
self.get_data().append(reference)
self.changed = True
self.rebuild()
def object_edited(self, refererence, primary):
self.changed = True self.changed = True
self.rebuild() self.rebuild()
@ -145,6 +153,6 @@ class SourceEmbedList(EmbeddedList):
from Editors import EditSourceRef from Editors import EditSourceRef
EditSourceRef(self.dbstate, self.uistate, self.track, EditSourceRef(self.dbstate, self.uistate, self.track,
src, sref, self.add_callback) src, sref, self.object_added)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass

View File

@ -45,6 +45,7 @@ class SourceRefModel(gtk.ListStore):
gtk.ListStore.__init__(self, str, str, str, str, object) gtk.ListStore.__init__(self, str, str, str, str, object)
self.db = db self.db = db
for sref in sref_list: for sref in sref_list:
src = self.db.get_source_from_handle(sref.ref) src = self.db.get_source_from_handle(sref.get_reference_handle())
print "Model", sref, sref.ref, sref.get_reference_handle()
self.append(row=[src.gramps_id, src.title, src.author, self.append(row=[src.gramps_id, src.title, src.author,
sref.page, sref, ]) sref.page, sref, ])

View File

@ -265,7 +265,7 @@ class EditPerson(EditPrimary):
self.srcref_list = self._add_tab( self.srcref_list = self._add_tab(
notebook, notebook,
SourceEmbedList(self.dbstate, self.uistate, SourceEmbedList(self.dbstate, self.uistate,
self.track, self.obj.source_list)) self.track, self.obj))
self.attr_list = self._add_tab( self.attr_list = self._add_tab(
notebook, notebook,

View File

@ -192,7 +192,6 @@ class EditSourceRef(EditReference):
else: else:
self.db.add_source(self.source,trans) self.db.add_source(self.source,trans)
self.db.transaction_commit(trans,_("Add Source")) self.db.transaction_commit(trans,_("Add Source"))
self.source_ref.ref = self.source.handle
if self.update: if self.update:
self.update(self.source_ref,self.source) self.update(self.source_ref,self.source)