74ad7b95a4
* src/ReportBase/_ReportUtils.py: Use name_displayer. * src/ReportBase/_CommandLineReport.py: Use name_displayer. * src/ReportBase/_BareReportDialog.py: Use name_displayer. * src/PluginUtils/_Tool.py: Use name_displayer. * src/plugins/TimeLine.py: Use name_displayer. * src/plugins/RelCalc.py: Use name_displayer. * src/plugins/ReadGrdb.py: Use name_displayer. * src/plugins/NarrativeWeb.py: Use name_displayer. * src/plugins/IndivComplete.py: Use name_displayer. * src/plugins/GraphViz.py: Use name_displayer. * src/plugins/FindDupes.py: Use name_displayer. * src/plugins/FamilyGroup.py: Use name_displayer. * src/plugins/DetDescendantReport.py: Use name_displayer. * src/plugins/DetAncestralReport.py: Use name_displayer. * src/plugins/DesGraph.py: Use name_displayer. * src/plugins/DescendReport.py: Use name_displayer. * src/plugins/DescendChart.py: Use name_displayer. * src/plugins/Check.py: Use name_displayer. * src/plugins/Ancestors.py: Use name_displayer. * src/plugins/AncestorReport.py: Use name_displayer. * src/plugins/AncestorChart2.py: Use name_displayer. * src/ObjectSelector/_PersonTreeFrame.py: Use name_displayer. * src/ObjectSelector/_PersonFrame.py: Use name_displayer. * src/Merge/_MergePerson.py: Use name_displayer. * src/GrampsDbUtils/_WriteGedcom.py: Use name_displayer. * src/GrampsDbUtils/_ReadXML.py: Use name_displayer. * src/GrampsDbUtils/_GedcomParse.py: Use name_displayer. * src/FilterEditor/_ShowResults.py: Use name_displayer. * src/FilterEditor/_EditRule.py: Use name_displayer. * src/Editors/_EditPrimary.py: Use name_displayer. * src/Editors/_EditPersonRef.py: Use name_displayer. * src/Editors/_EditPerson.py: Use name_displayer. * src/Editors/_EditName.py: Use name_displayer. * src/Editors/_EditLdsOrd.py: Use name_displayer. * src/Editors/_EditFamily.py: Use name_displayer. * src/DisplayTabs/_PersonRefModel.py: Use name_displayer. * src/DisplayTabs/_NameModel.py: Use name_displayer. * src/DisplayTabs/_ChildModel.py: Use name_displayer. * src/DisplayTabs/_BackRefModel.py: Use name_displayer. * src/DisplayModels/_PeopleModel.py: Use name_displayer. * src/DisplayModels/_FamilyModel.py: Use name_displayer. * src/DataViews/_PersonView.py: Use name_displayer. * src/DataViews/_RelationView.py: Use name_displayer. * src/DataViews/_PedigreeView.py: Use name_displayer. * src/Utils.py: Use name_displayer. * src/SubstKeywords.py: Use name_displayer. * src/Sort.py: Use name_displayer. * src/Reorder.py: Use name_displayer. * src/PageView.py (BookMarkView.add_bookmark): Use name_displayer. * src/Navigation.py: Use name_displayer. * src/DisplayState.py: Use name_displayer. * src/GrampsCfg.py: Use name_displayer. * src/Bookmarks.py (Bookmarks.make_label): Use name_displayer. * src/GrampsDb/Makefile.am (pkgdata_PYTHON): Ship new files. * src/Makefile.am (gdir_PYTHON): Ship ProgressDialog.py svn: r8680
168 lines
5.0 KiB
Python
168 lines
5.0 KiB
Python
#
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
#
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
|
|
# $Id$
|
|
|
|
from gettext import gettext as _
|
|
|
|
import ManagedWindow
|
|
import DateHandler
|
|
from BasicUtils import name_displayer
|
|
import Config
|
|
import GrampsDisplay
|
|
from QuestionDialog import SaveDialog
|
|
|
|
class EditPrimary(ManagedWindow.ManagedWindow):
|
|
|
|
def __init__(self, state, uistate, track, obj, get_from_handle, callback=None):
|
|
"""Creates an edit window. Associates a person with the window."""
|
|
|
|
self.dp = DateHandler.parser
|
|
self.dd = DateHandler.displayer
|
|
self.nd = name_displayer
|
|
self.obj = obj
|
|
self.dbstate = state
|
|
self.uistate = uistate
|
|
self.db = state.db
|
|
self.callback = callback
|
|
self.signal_keys = []
|
|
self.ok_button = None
|
|
self.get_from_handle = get_from_handle
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, obj)
|
|
|
|
self._local_init()
|
|
|
|
self._create_tabbed_pages()
|
|
self._setup_fields()
|
|
self._connect_signals()
|
|
self.show()
|
|
self._post_init()
|
|
|
|
def _local_init(self):
|
|
"""
|
|
Derived class should do any pre-window initalization in this task.
|
|
"""
|
|
pass
|
|
|
|
def _post_init(self):
|
|
"""
|
|
Derived class should do any post-window initalization in this task.
|
|
"""
|
|
pass
|
|
|
|
def _add_db_signal(self, name, callback):
|
|
self.signal_keys.append(self.db.connect(name,callback))
|
|
|
|
def _connect_signals(self):
|
|
pass
|
|
|
|
def _setup_fields(self):
|
|
pass
|
|
|
|
def _create_tabbed_pages(self):
|
|
pass
|
|
|
|
def build_window_key(self,obj):
|
|
if obj and obj.get_handle():
|
|
return obj.get_handle()
|
|
else:
|
|
return id(self)
|
|
|
|
def _setup_notebook_tabs(self, notebook):
|
|
for child in notebook.get_children():
|
|
label = notebook.get_tab_label(child)
|
|
page_no = notebook.page_num(child)
|
|
label.drag_dest_set(0, [], 0)
|
|
label.connect('drag_motion',
|
|
self._switch_page_on_dnd,
|
|
notebook,
|
|
page_no)
|
|
|
|
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
|
|
if notebook.get_current_page() != page_no:
|
|
notebook.set_current_page(page_no)
|
|
|
|
def _add_tab(self,notebook,page):
|
|
notebook.insert_page(page, page.get_tab_widget())
|
|
return page
|
|
|
|
def _cleanup_on_exit(self):
|
|
pass
|
|
|
|
def object_is_empty(self):
|
|
return cmp(self.obj.serialize()[1:],
|
|
self.empty_object().serialize()[1:]) == 0
|
|
|
|
def define_ok_button(self, button, function):
|
|
self.ok_button = button
|
|
button.connect('clicked', function)
|
|
button.set_sensitive(not self.db.readonly)
|
|
|
|
def define_cancel_button(self,button):
|
|
button.connect('clicked',self.close)
|
|
|
|
def define_help_button(self,button,tag):
|
|
button.connect('clicked', lambda x: GrampsDisplay.help(tag))
|
|
|
|
def _do_close(self,*obj):
|
|
for key in self.signal_keys:
|
|
self.db.disconnect(key)
|
|
self._cleanup_on_exit()
|
|
ManagedWindow.ManagedWindow.close(self)
|
|
|
|
def close(self,*obj):
|
|
"""If the data has changed, give the user a chance to cancel
|
|
the close window"""
|
|
if not Config.get(Config.DONT_ASK) and self.data_has_changed():
|
|
SaveDialog(
|
|
_('Save Changes?'),
|
|
_('If you close without saving, the changes you '
|
|
'have made will be lost'),
|
|
self._do_close,
|
|
self.save)
|
|
return True
|
|
else:
|
|
self._do_close()
|
|
return False
|
|
|
|
def empty_object(self):
|
|
return None
|
|
|
|
def data_has_changed(self):
|
|
|
|
if self.db.readonly:
|
|
return False
|
|
elif self.obj.handle:
|
|
orig = self.get_from_handle(self.obj.handle)
|
|
if orig:
|
|
cmp_obj = orig
|
|
else:
|
|
cmp_obj = self.empty_object()
|
|
return cmp(cmp_obj.serialize()[1:],
|
|
self.obj.serialize()[1:]) != 0
|
|
else:
|
|
cmp_obj = self.empty_object()
|
|
return cmp(cmp_obj.serialize()[1:],
|
|
self.obj.serialize()[1:]) != 0
|
|
|
|
def save(self,*obj):
|
|
pass
|