From 6cda31bfe85473fb1cfc8564325e8070131a6290 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 8 Oct 2006 04:17:04 +0000 Subject: [PATCH] svn: r7368 --- gramps2/src/DisplayTabs/_EmbeddedList.py | 2 + gramps2/src/DisplayTabs/_EventEmbedList.py | 39 +++++++++---------- gramps2/src/DisplayTabs/_RepoEmbedList.py | 12 +++++- gramps2/src/DisplayTabs/_SourceEmbedList.py | 42 ++++++++++++--------- gramps2/src/DisplayTabs/_SourceRefModel.py | 3 +- gramps2/src/Editors/_EditPerson.py | 2 +- gramps2/src/Editors/_EditSourceRef.py | 1 - 7 files changed, 61 insertions(+), 40 deletions(-) diff --git a/gramps2/src/DisplayTabs/_EmbeddedList.py b/gramps2/src/DisplayTabs/_EmbeddedList.py index 792740d2b..ed62f33dc 100644 --- a/gramps2/src/DisplayTabs/_EmbeddedList.py +++ b/gramps2/src/DisplayTabs/_EmbeddedList.py @@ -277,6 +277,8 @@ class EmbeddedList(ButtonTab): """ (model, node) = self.selection.get_selected() 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 None diff --git a/gramps2/src/DisplayTabs/_EventEmbedList.py b/gramps2/src/DisplayTabs/_EventEmbedList.py index c44c4c86c..c5da10b63 100644 --- a/gramps2/src/DisplayTabs/_EventEmbedList.py +++ b/gramps2/src/DisplayTabs/_EventEmbedList.py @@ -83,17 +83,6 @@ class EventEmbedList(EmbeddedList): def column_order(self): 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): return RelLib.EventType(RelLib.EventType.MARRIAGE) @@ -108,7 +97,7 @@ class EventEmbedList(EmbeddedList): event.set_type(self.default_type()) self.get_ref_editor()( self.dbstate, self.uistate, self.track, - event, ref, self.event_added) + event, ref, self.object_added) except Errors.WindowActiveError: pass @@ -124,7 +113,7 @@ class EventEmbedList(EmbeddedList): ref.set_role(self.default_role()) self.get_ref_editor()( self.dbstate, self.uistate, self.track, - event, ref, self.event_added) + event, ref, self.object_added) except Errors.WindowActiveError: pass @@ -135,7 +124,7 @@ class EventEmbedList(EmbeddedList): try: self.get_ref_editor()( self.dbstate, self.uistate, self.track, - event, ref, self.event_updated) + event, ref, self.object_edited) except Errors.WindowActiveError: from QuestionDialog import WarningDialog WarningDialog( @@ -147,13 +136,13 @@ class EventEmbedList(EmbeddedList): "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.rebuild() - def event_added(self, ref, event): - ref.ref = event.handle - self.get_data().append(ref) + def object_edited(self, ref, event): self.changed = True self.rebuild() @@ -170,4 +159,16 @@ class EventEmbedList(EmbeddedList): event = self.dbstate.db.get_event_from_handle(obj.ref) self.get_ref_editor()( 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 + diff --git a/gramps2/src/DisplayTabs/_RepoEmbedList.py b/gramps2/src/DisplayTabs/_RepoEmbedList.py index af4577dac..1d99a4702 100644 --- a/gramps2/src/DisplayTabs/_RepoEmbedList.py +++ b/gramps2/src/DisplayTabs/_RepoEmbedList.py @@ -144,7 +144,17 @@ class RepoEmbedList(EmbeddedList): self.dbstate, self.uistate, self.track, repo, ref, self.edit_callback) 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): self.changed = True diff --git a/gramps2/src/DisplayTabs/_SourceEmbedList.py b/gramps2/src/DisplayTabs/_SourceEmbedList.py index 8743d24c4..546dad476 100644 --- a/gramps2/src/DisplayTabs/_SourceEmbedList.py +++ b/gramps2/src/DisplayTabs/_SourceEmbedList.py @@ -34,6 +34,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- import RelLib import Errors +import Utils from DdTargets import DdTargets from _SourceRefModel import SourceRefModel from _EmbeddedList import EmbeddedList @@ -72,25 +73,24 @@ class SourceEmbedList(EmbeddedList): return 'gramps-source' def get_data(self): - return self.obj + return self.obj.get_source_references() def column_order(self): return ((1, 0), (1, 1), (1, 2), (1, 3)) def add_button_clicked(self, obj): - sref = RelLib.SourceRef() - src = RelLib.Source() try: from Editors import EditSourceRef + sref = RelLib.SourceRef() + src = RelLib.Source() EditSourceRef( self.dbstate, self.uistate, self.track, src, sref, - self.add_callback) - + self.object_added) except Errors.WindowActiveError: pass @@ -99,7 +99,6 @@ class SourceEmbedList(EmbeddedList): SelectSource = selector_factory('Source') sel = SelectSource(self.dbstate,self.uistate,self.track) - src = sel.run() if src: try: @@ -111,30 +110,39 @@ class SourceEmbedList(EmbeddedList): self.track, src, ref, - self.add_callback) + self.object_added) except Errors.WindowActiveError: 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): sref = self.get_selected() if sref: src = self.dbstate.db.get_source_from_handle(sref.ref) + try: from Editors import EditSourceRef EditSourceRef(self.dbstate, self.uistate, self.track, - src, sref, self.edit_callback) + src, sref, self.object_edited) 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.rebuild() @@ -145,6 +153,6 @@ class SourceEmbedList(EmbeddedList): from Editors import EditSourceRef EditSourceRef(self.dbstate, self.uistate, self.track, - src, sref, self.add_callback) + src, sref, self.object_added) except Errors.WindowActiveError: pass diff --git a/gramps2/src/DisplayTabs/_SourceRefModel.py b/gramps2/src/DisplayTabs/_SourceRefModel.py index 93cd9ca0d..f61798761 100644 --- a/gramps2/src/DisplayTabs/_SourceRefModel.py +++ b/gramps2/src/DisplayTabs/_SourceRefModel.py @@ -45,6 +45,7 @@ class SourceRefModel(gtk.ListStore): gtk.ListStore.__init__(self, str, str, str, str, object) self.db = db 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, sref.page, sref, ]) diff --git a/gramps2/src/Editors/_EditPerson.py b/gramps2/src/Editors/_EditPerson.py index 55c5648ed..962bb895c 100644 --- a/gramps2/src/Editors/_EditPerson.py +++ b/gramps2/src/Editors/_EditPerson.py @@ -265,7 +265,7 @@ class EditPerson(EditPrimary): self.srcref_list = self._add_tab( notebook, SourceEmbedList(self.dbstate, self.uistate, - self.track, self.obj.source_list)) + self.track, self.obj)) self.attr_list = self._add_tab( notebook, diff --git a/gramps2/src/Editors/_EditSourceRef.py b/gramps2/src/Editors/_EditSourceRef.py index 4e231f2c7..3fd33214e 100644 --- a/gramps2/src/Editors/_EditSourceRef.py +++ b/gramps2/src/Editors/_EditSourceRef.py @@ -192,7 +192,6 @@ class EditSourceRef(EditReference): else: self.db.add_source(self.source,trans) self.db.transaction_commit(trans,_("Add Source")) - self.source_ref.ref = self.source.handle if self.update: self.update(self.source_ref,self.source)