GEP 18: Deprecate EditCitation

svn: r22486
This commit is contained in:
Benny Malengier 2013-06-10 20:09:03 +00:00
parent e5f80e521c
commit 973e143b22
12 changed files with 121 additions and 48 deletions

View File

@ -137,8 +137,7 @@ class BackRefList(EmbeddedList):
def edit_button_clicked(self, obj):
from .. import EditEvent, EditPerson, EditFamily, EditSource, \
EditPlace, EditMedia, EditRepository, \
EditCitation
EditPlace, EditMedia, EditRepository
(reftype, ref) = self.find_node()
if reftype == 'Person':
@ -162,7 +161,9 @@ class BackRefList(EmbeddedList):
elif reftype == 'Citation':
try:
citation = self.dbstate.db.get_citation_from_handle(ref)
EditCitation(self.dbstate, self.uistate, [], citation)
EditSource(self.dbstate, self.uistate, [],
self.dbstate.db.get_source_from_handle(
citation.get_reference_handle()), citation)
except WindowActiveError:
"""
Return the text used when citation cannot be edited

View File

@ -128,7 +128,7 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
def add_button_clicked(self, obj):
"""
Create a new Citation instance and call the EditCitation editor with
Create a new Citation instance and call the EditSource editor with
the new citation.
Called when the Add button is clicked.
@ -136,9 +136,9 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
This prevents the dialog from coming up twice on the same object.
"""
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track,
Citation(), Source(),
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
Source(), Citation(),
self.add_callback, self.callertitle)
except WindowActiveError:
pass
@ -164,9 +164,9 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
if object:
if isinstance(object, Source):
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track,
Citation(), object,
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
object, Citation(),
callback=self.add_callback,
callertitle=self.callertitle)
except WindowActiveError:
@ -175,10 +175,12 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
self.__blocked_text())
elif isinstance(object, Citation):
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track,
object, callback=self.add_callback,
callertitle=self.callertitle)
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
self.dbstate.db.get_source_from_handle(
object.get_reference_handle()), object,
callback=self.add_callback,
callertitle=self.callertitle)
except WindowActiveError:
from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
@ -198,7 +200,7 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
def edit_button_clicked(self, obj):
"""
Get the selected Citation instance and call the EditCitation editor
Get the selected Citation instance and call the EditSource editor
with the citation.
Called when the Edit button is clicked.
@ -209,9 +211,11 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
if handle:
citation = self.dbstate.db.get_citation_from_handle(handle)
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track, citation,
callertitle = self.callertitle)
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
self.dbstate.db.get_source_from_handle(
citation.get_reference_handle()), citation,
callertitle = self.callertitle)
except WindowActiveError:
pass
@ -248,10 +252,12 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
object = self.dbstate.db.get_citation_from_handle(handle)
if isinstance(object, Citation):
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track,
object, callback=self.add_callback,
callertitle=self.callertitle)
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
self.dbstate.db.get_source_from_handle(
object.get_reference_handle()),
object, callback=self.add_callback,
callertitle=self.callertitle)
except WindowActiveError:
from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
@ -267,11 +273,11 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
object = self.dbstate.db.get_source_from_handle(handle)
if isinstance(object, Source):
try:
from .. import EditCitation
EditCitation(self.dbstate, self.uistate, self.track,
Citation(), object,
callback=self.add_callback,
callertitle=self.callertitle)
from .. import EditSource
EditSource(self.dbstate, self.uistate, self.track,
object, Citation(),
callback=self.add_callback,
callertitle=self.callertitle)
except WindowActiveError:
from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),

View File

@ -401,7 +401,7 @@ class CitedInTab(GrampsTab):
return
from .. import (EditEvent, EditPerson, EditFamily, EditPlace,
EditMedia, EditRepository, EditCitation)
EditMedia, EditRepository)
if reftype == 'Person':
try:

View File

@ -101,6 +101,12 @@ class SrcTemplateTab(GrampsTab):
self.setup_interface(self.glade.get_object('scrolledtemplates'))
self.show_all()
def make_active(self):
"""
Called by using editor to focus on correct field in the tab
"""
self.temp_tv.grab_focus()
def is_empty(self):
"""
Override base class

View File

@ -58,8 +58,31 @@ from ..glade import Glade
# EditCitationclass
#
#-------------------------------------------------------------------------
class EditCitation(EditPrimary):
"""
Create an Editor for Citation object. This actually opens the source!
This class is called both to edit the Citation Primary object
and to edit references from other objects to citations.
@param callertitle: Text passed by calling object to add to title
@type callertitle: str
"""
def __init__(self, dbstate, uistate, track, citation, callback=None,
callertitle = None):
from .editsource import EditSource
if citation.handle:
EditSource(dbstate, uistate, track, dbstate.db.get_source_from_handle(
citation.get_reference_handle()), citation,
callback, callertitle)
else:
#we don't allow this, caller should be changed to call EditSource
#directly !
raise NotImplementedError("Depracated call")
class EditCitationOld(EditPrimary):
"""
Create an EditCitation window. Associate a citation with the window.

View File

@ -160,7 +160,21 @@ class EditSource(EditPrimary):
self.unload_citation()
self.load_source_image()
self.title.grab_focus()
if not self.obj.handle:
#new source, open on template view, and focus there.
self.notebook_src.set_current_pate(self.template_page_nr)
self.template_tab.make_active()
elif self.citation:
#there is a citation!
if self.citation.handle:
#existing citation!
self.notebook_ref.grab_focus()
else:
#new citation!
self.notebook_ref.grab_focus()
else:
#existing source, no citation
self.title.grab_focus()
def load_source_image(self):
"""
@ -363,7 +377,8 @@ class EditSource(EditPrimary):
self.source_text.get_buffer().set_text(ref_text)
def _create_tabbed_pages(self):
notebook = self.glade.get_object('notebook')
self.notebook_src = self.glade.get_object('notebook')
notebook = self.notebook_src
gridsrc = self.glade.get_object('gridsrc')
#recreate start page as GrampsTab
notebook.remove_page(1)
@ -373,6 +388,7 @@ class EditSource(EditPrimary):
self._add_tab(notebook, self.overviewtab)
#recreate second page as GrampsTab
self.template_page_nr = 1
self.template_tab = SrcTemplateTab(self.dbstate, self.uistate,
self.track, self.obj, self.glade,
self.update_template_data

View File

@ -60,7 +60,7 @@ from gramps.gen.errors import WindowActiveError
from ...widgets.multitreeview import MultiTreeView
from ...ddtargets import DdTargets
from ..quick import run_quick_report_by_name
from ...editors import (EditPerson, EditEvent, EditFamily, EditCitation,
from ...editors import (EditPerson, EditEvent, EditFamily,
EditSource, EditPlace, EditRepository, EditNote,
EditMedia)
@ -216,9 +216,11 @@ class QuickTable(SimpleTable):
elif objclass == 'Citation':
ref = self.access.dbase.get_citation_from_handle(handle)
if ref:
dbstate = self.simpledoc.doc.dbstate
try:
EditCitation(self.simpledoc.doc.dbstate,
self.simpledoc.doc.uistate, [], ref)
EditSource(dbstate, self.simpledoc.doc.uistate, [],
dbstate.db.get_source_from_handle(
ref.get_reference_handle()), ref)
return True # handled event
except WindowActiveError:
pass

View File

@ -304,6 +304,13 @@ class ListView(NavigationView):
NavigationView.set_inactive(self)
self.uistate.viewmanager.tags.tag_disable()
def grab_focus(self):
"""
Inherit this method to indicate where to put focus if there is no
specific handle in focus
"""
self.list.grab_focus()
def __build_tree(self):
profile(self._build_tree)

View File

@ -196,11 +196,21 @@ class NavigationView(PageView):
self.navigation_group())
if active_handle:
self.goto_handle(active_handle)
else:
#make the pageview the object with focus, so moving arrow works
self.grab_focus()
hobj = self.get_history()
self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(not hobj.at_front())
def grab_focus(self):
"""
Inherit this method to indicate where to put focus if there is no
specific handle in focus
"""
pass
def get_active(self):
"""
Return the handle of the active object.

View File

@ -20,7 +20,7 @@
# $Id$
#
from gramps.gui.editors import EditSource, EditCitation
from gramps.gui.editors import EditSource
from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet
from gramps.gui.dbguielement import DbGUIElement
@ -268,7 +268,7 @@ class Citations(Gramplet, DbGUIElement):
citation = self.dbstate.db.get_citation_from_handle(handle)
source_handle = citation.get_reference_handle()
source = self.dbstate.db.get_source_from_handle(source_handle)
EditCitation(self.dbstate, self.uistate, [], citation, source)
EditSource(self.dbstate, self.uistate, [], source, citation)
except WindowActiveError:
pass

View File

@ -54,7 +54,7 @@ from gramps.gui.views.bookmarks import CitationBookmarks
from gramps.gen.errors import WindowActiveError
from gramps.gui.ddtargets import DdTargets
from gramps.gui.dialog import ErrorDialog
from gramps.gui.editors import EditCitation, DeleteCitationQuery
from gramps.gui.editors import EditSource, DeleteCitationQuery
from gramps.gui.filters.sidebar import CitationSidebarFilter
from gramps.gui.merge import MergeCitation
@ -255,7 +255,7 @@ class CitationListView(ListView):
citation to an existing source)
Create a new Source instance and Citation instance and call the
EditCitation editor with the new source and new citation.
EditSource editor with the new source and new citation.
Called when the Add button is clicked.
If the window already exists (WindowActiveError), we ignore it.
@ -266,8 +266,7 @@ class CitationListView(ListView):
window to already exist, so this is just an extra safety measure.
"""
try:
EditCitation(self.dbstate, self.uistate, [], Citation(),
Source())
EditSource(self.dbstate, self.uistate, [], Source(), Citation())
except WindowActiveError:
pass
@ -289,7 +288,9 @@ class CitationListView(ListView):
for handle in self.selected_handles():
citation = self.dbstate.db.get_citation_from_handle(handle)
try:
EditCitation(self.dbstate, self.uistate, [], citation)
EditSource(self.dbstate, self.uistate, [],
self.dbstate.db.get_source_from_handle(
citation.get_reference_handle()), citation)
except WindowActiveError:
pass

View File

@ -56,8 +56,8 @@ from gramps.gui.views.bookmarks import CitationBookmarks
from gramps.gen.errors import WindowActiveError
from gramps.gui.ddtargets import DdTargets
from gramps.gui.dialog import ErrorDialog
from gramps.gui.editors import EditCitation, DeleteCitationQuery, EditSource, \
DeleteSrcQuery
from gramps.gui.editors import (DeleteCitationQuery, EditSource,
DeleteSrcQuery)
from gramps.gui.filters.sidebar import SourceSidebarFilter
from gramps.gui.merge import MergeCitation, MergeSource
@ -400,8 +400,7 @@ class CitationTreeView(ListView):
window to already exist, so this is just an extra safety measure.
"""
try:
EditCitation(self.dbstate, self.uistate, [], Citation(),
Source())
EditSource(self.dbstate, self.uistate, [], Source(), Citation())
except WindowActiveError:
pass
@ -418,8 +417,8 @@ class CitationTreeView(ListView):
raise ValueError("selection must be either source or citation")
if source:
try:
EditCitation(self.dbstate, self.uistate, [],
Citation(), source)
EditSource(self.dbstate, self.uistate, [], source,
Citation())
except WindowActiveError:
from gramps.gui.dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
@ -469,7 +468,9 @@ class CitationTreeView(ListView):
raise ValueError("selection must be either source or citation")
if citation:
try:
EditCitation(self.dbstate, self.uistate, [], citation)
EditSource(self.dbstate, self.uistate, [],
self.dbstate.db.get_source_from_handle(
citation.get_reference_handle()), citation)
except WindowActiveError:
pass
else: # FIXME need try block here