* src/EditSecondary.py: Base class for standard secondary object
editors (not including reference editors) * src/AddrEdit.py: Base on EditSecondary * src/AttrEdit.py: Base on EditSecondary * src/LocEdit.py: Base on EditSecondary * src/NameEdit.py: Base on EditSecondary * src/UrlEdit.py: Base on EditSecondary svn: r6019
This commit is contained in:
parent
987a35f110
commit
195e0eb9b3
@ -1,4 +1,11 @@
|
|||||||
2006-03-01 Don Allingham <don@gramps-project.org>
|
2006-03-01 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/EditSecondary.py: Base class for standard secondary object
|
||||||
|
editors (not including reference editors)
|
||||||
|
* src/AddrEdit.py: Base on EditSecondary
|
||||||
|
* src/AttrEdit.py: Base on EditSecondary
|
||||||
|
* src/LocEdit.py: Base on EditSecondary
|
||||||
|
* src/NameEdit.py: Base on EditSecondary
|
||||||
|
* src/UrlEdit.py: Base on EditSecondary
|
||||||
* src/EditPerson.py: fix focus_out_event signal handling
|
* src/EditPerson.py: fix focus_out_event signal handling
|
||||||
* src/DisplayTabs.py: provide double click/edit button handling
|
* src/DisplayTabs.py: provide double click/edit button handling
|
||||||
for back references.
|
for back references.
|
||||||
|
118
src/AddrEdit.py
118
src/AddrEdit.py
@ -44,11 +44,8 @@ import gtk.glade
|
|||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import GrampsDisplay
|
|
||||||
import const
|
import const
|
||||||
import Utils
|
import EditSecondary
|
||||||
import RelLib
|
|
||||||
import DisplayState
|
|
||||||
|
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import *
|
||||||
@ -58,7 +55,7 @@ from GrampsWidgets import *
|
|||||||
# AddressEditor class
|
# AddressEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class AddressEditor(DisplayState.ManagedWindow):
|
class AddressEditor(EditSecondary.EditSecondary):
|
||||||
"""
|
"""
|
||||||
Displays a dialog that allows the user to edit an address.
|
Displays a dialog that allows the user to edit an address.
|
||||||
"""
|
"""
|
||||||
@ -69,118 +66,83 @@ class AddressEditor(DisplayState.ManagedWindow):
|
|||||||
parent - The class that called the Address editor.
|
parent - The class that called the Address editor.
|
||||||
addr - The address that is to be edited
|
addr - The address that is to be edited
|
||||||
"""
|
"""
|
||||||
|
EditSecondary.EditSecondary.__init__(self, dbstate, uistate, track, addr)
|
||||||
|
|
||||||
self.db = dbstate.db
|
def _local_init(self):
|
||||||
self.uistate = uistate
|
|
||||||
self.dbstate = dbstate
|
|
||||||
self.callback = callback
|
|
||||||
self.addr = addr
|
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, addr)
|
|
||||||
|
|
||||||
if not self.addr:
|
|
||||||
self.addr = RelLib.Address()
|
|
||||||
|
|
||||||
# Get the important widgets from the glade description
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "addr_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "addr_edit","gramps")
|
||||||
self.window = self.top.get_widget("addr_edit")
|
self.define_top_level(self.top.get_widget("addr_edit"),
|
||||||
|
self.top.get_widget("title"),
|
||||||
title_label = self.top.get_widget("title")
|
_('Address Editor'))
|
||||||
Utils.set_titles(self.window,title_label,_('Address Editor'))
|
|
||||||
|
|
||||||
self._setup_fields()
|
|
||||||
self._create_tabbed_pages()
|
|
||||||
self._connect_signals()
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
self.addr_start = MonitoredDate(
|
self.addr_start = MonitoredDate(
|
||||||
self.top.get_widget("address_start"),
|
self.top.get_widget("address_start"),
|
||||||
self.top.get_widget("date_stat"),
|
self.top.get_widget("date_stat"),
|
||||||
self.addr.get_date_object(),
|
self.obj.get_date_object(),
|
||||||
self.window, self.db.readonly)
|
self.window, self.db.readonly)
|
||||||
|
|
||||||
self.street = MonitoredEntry(
|
self.street = MonitoredEntry(
|
||||||
self.top.get_widget("street"), self.addr.set_street,
|
self.top.get_widget("street"), self.obj.set_street,
|
||||||
self.addr.get_street, self.db.readonly)
|
self.obj.get_street, self.db.readonly)
|
||||||
|
|
||||||
self.city = MonitoredEntry(
|
self.city = MonitoredEntry(
|
||||||
self.top.get_widget("city"), self.addr.set_city,
|
self.top.get_widget("city"), self.obj.set_city,
|
||||||
self.addr.get_city, self.db.readonly)
|
self.obj.get_city, self.db.readonly)
|
||||||
|
|
||||||
self.state = MonitoredEntry(
|
self.state = MonitoredEntry(
|
||||||
self.top.get_widget("state"), self.addr.set_state,
|
self.top.get_widget("state"), self.obj.set_state,
|
||||||
self.addr.get_state, self.db.readonly)
|
self.obj.get_state, self.db.readonly)
|
||||||
|
|
||||||
self.country = MonitoredEntry(
|
self.country = MonitoredEntry(
|
||||||
self.top.get_widget("country"), self.addr.set_country,
|
self.top.get_widget("country"), self.obj.set_country,
|
||||||
self.addr.get_country, self.db.readonly)
|
self.obj.get_country, self.db.readonly)
|
||||||
|
|
||||||
self.postal = MonitoredEntry(
|
self.postal = MonitoredEntry(
|
||||||
self.top.get_widget("postal"), self.addr.set_postal_code,
|
self.top.get_widget("postal"), self.obj.set_postal_code,
|
||||||
self.addr.get_postal_code, self.db.readonly)
|
self.obj.get_postal_code, self.db.readonly)
|
||||||
|
|
||||||
self.phone = MonitoredEntry(
|
self.phone = MonitoredEntry(
|
||||||
self.top.get_widget("phone"), self.addr.set_phone,
|
self.top.get_widget("phone"), self.obj.set_phone,
|
||||||
self.addr.get_phone, self.db.readonly)
|
self.obj.get_phone, self.db.readonly)
|
||||||
|
|
||||||
self.priv = PrivacyButton(self.top.get_widget("private"),
|
self.priv = PrivacyButton(self.top.get_widget("private"),
|
||||||
self.addr, self.db.readonly)
|
self.obj, self.db.readonly)
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.window.connect('delete_event',self.on_delete_event)
|
self.define_help_button(self.top.get_widget('help'),'adv-ad')
|
||||||
self.top.get_widget('cancel').connect('clicked',self.close_window)
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
||||||
self.top.get_widget('help').connect('clicked',self.help_clicked)
|
self.define_ok_button(self.top.get_widget('ok'),self.save)
|
||||||
|
|
||||||
okbtn = self.top.get_widget('ok')
|
|
||||||
okbtn.connect('clicked',self.ok_clicked)
|
|
||||||
okbtn.set_sensitive(not self.db.readonly)
|
|
||||||
|
|
||||||
def _add_page(self,page):
|
|
||||||
self.notebook.insert_page(page)
|
|
||||||
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
||||||
return page
|
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
"""
|
"""
|
||||||
Creates the notebook tabs and inserts them into the main
|
Creates the notebook tabs and inserts them into the main
|
||||||
window.
|
window.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
vbox = self.top.get_widget('vbox')
|
|
||||||
|
|
||||||
self.notebook = gtk.Notebook()
|
notebook = gtk.Notebook()
|
||||||
|
|
||||||
|
self.srcref_list = self._add_tab(
|
||||||
|
notebook,
|
||||||
|
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
||||||
|
self.obj.source_list))
|
||||||
|
|
||||||
|
self.note_tab = self._add_tab(
|
||||||
|
notebook,
|
||||||
|
NoteTab(self.dbstate, self.uistate, self.track,
|
||||||
|
self.obj.get_note_object()))
|
||||||
|
|
||||||
self.srcref_list = self._add_page(SourceEmbedList(
|
notebook.show_all()
|
||||||
self.dbstate,self.uistate, self.track,
|
self.top.get_widget('vbox').pack_start(notebook,True)
|
||||||
self.addr.source_list))
|
|
||||||
self.note_tab = self._add_page(NoteTab(
|
|
||||||
self.dbstate, self.uistate, self.track,
|
|
||||||
self.addr.get_note_object()))
|
|
||||||
|
|
||||||
self.notebook.show_all()
|
|
||||||
vbox.pack_start(self.notebook,True)
|
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def close_window(self,obj):
|
|
||||||
self.window.destroy()
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def build_menu_names(self,obj):
|
def build_menu_names(self,obj):
|
||||||
return (_('Address'),_('Address Editor'))
|
return (_('Address'),_('Address Editor'))
|
||||||
|
|
||||||
def help_clicked(self,obj):
|
def save(self,*obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
|
||||||
GrampsDisplay.help('adv-ad')
|
|
||||||
|
|
||||||
def ok_clicked(self,obj):
|
|
||||||
"""
|
"""
|
||||||
Called when the OK button is pressed. Gets data from the
|
Called when the OK button is pressed. Gets data from the
|
||||||
form and updates the Address data structure.
|
form and updates the Address data structure.
|
||||||
"""
|
"""
|
||||||
self.callback(self.addr)
|
if self.callback:
|
||||||
|
self.callback(self.obj)
|
||||||
self.close_window(obj)
|
self.close_window(obj)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ import const
|
|||||||
import Utils
|
import Utils
|
||||||
import RelLib
|
import RelLib
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import DisplayState
|
import EditSecondary
|
||||||
|
|
||||||
from QuestionDialog import WarningDialog
|
from QuestionDialog import WarningDialog
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
@ -62,7 +62,7 @@ from GrampsWidgets import *
|
|||||||
# AttributeEditor class
|
# AttributeEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class AttributeEditor(DisplayState.ManagedWindow):
|
class AttributeEditor(EditSecondary.EditSecondary):
|
||||||
"""
|
"""
|
||||||
Displays a dialog that allows the user to edit an attribute.
|
Displays a dialog that allows the user to edit an attribute.
|
||||||
"""
|
"""
|
||||||
@ -75,81 +75,51 @@ class AttributeEditor(DisplayState.ManagedWindow):
|
|||||||
title - The title of the dialog box
|
title - The title of the dialog box
|
||||||
list - list of options for the pop down menu
|
list - list of options for the pop down menu
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.db = state.db
|
|
||||||
self.attrib = attrib
|
|
||||||
self.callback = callback
|
|
||||||
self.track = track
|
|
||||||
self.uistate = uistate
|
|
||||||
self.state = state
|
|
||||||
self.alist = data_list
|
self.alist = data_list
|
||||||
|
EditSecondary.EditSecondary.__init__(self, state, uistate, track,
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, attrib)
|
attrib, callback)
|
||||||
|
|
||||||
if not attrib:
|
def _local_init(self):
|
||||||
self.attrib = RelLib.Attribute()
|
|
||||||
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "attr_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "attr_edit","gramps")
|
||||||
self.notebook = self.top.get_widget("notebook")
|
self.define_top_level(self.top.get_widget("attr_edit"),
|
||||||
|
self.top.get_widget('title'),
|
||||||
self.window = self.top.get_widget("attr_edit")
|
_('Attribute Editor'))
|
||||||
title = _("Attribute Editor")
|
|
||||||
l = self.top.get_widget("title")
|
|
||||||
Utils.set_titles(self.window,l,title,_('Attribute Editor'))
|
|
||||||
|
|
||||||
self._create_tabbed_pages()
|
|
||||||
self._setup_fields()
|
|
||||||
self._connect_signals()
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.window.connect('delete_event', self.on_delete_event)
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
||||||
|
self.define_help_button(self.top.get_widget('help'),'adv-at')
|
||||||
self.top.get_widget('cancel').connect('clicked', self.close_window)
|
self.define_ok_button(self.top.get_widget('ok'),self.save)
|
||||||
self.top.get_widget('help').connect('clicked', self.on_help_clicked)
|
|
||||||
|
|
||||||
ok = self.top.get_widget('ok')
|
|
||||||
ok.connect('clicked', self.on_ok_clicked)
|
|
||||||
if self.db.readonly:
|
|
||||||
ok.set_sensitive(False)
|
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
self.value_field = MonitoredEntry(
|
self.value_field = MonitoredEntry(
|
||||||
self.top.get_widget("attr_value"),
|
self.top.get_widget("attr_value"),
|
||||||
self.attrib.set_value, self.attrib.get_value,
|
self.obj.set_value, self.obj.get_value,
|
||||||
self.db.readonly)
|
self.db.readonly)
|
||||||
|
|
||||||
self.priv = PrivacyButton(self.top.get_widget("private"),self.attrib)
|
self.priv = PrivacyButton(
|
||||||
|
self.top.get_widget("private"),
|
||||||
|
self.obj)
|
||||||
|
|
||||||
self.type_selector = MonitoredType(
|
self.type_selector = MonitoredType(
|
||||||
self.top.get_widget("attr_menu"),
|
self.top.get_widget("attr_menu"),
|
||||||
self.attrib.set_type, self.attrib.get_type,
|
self.obj.set_type, self.obj.get_type,
|
||||||
dict(Utils.personal_attributes),
|
dict(Utils.personal_attributes),
|
||||||
RelLib.Attribute.CUSTOM)
|
RelLib.Attribute.CUSTOM)
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
vbox = self.top.get_widget('vbox')
|
notebook = gtk.Notebook()
|
||||||
|
self.srcref_list = self._add_tab(
|
||||||
|
notebook,
|
||||||
|
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
||||||
|
self.obj.source_list))
|
||||||
|
|
||||||
self.notebook = gtk.Notebook()
|
self.note_tab = self._add_tab(
|
||||||
self.srcref_list = self._add_page(SourceEmbedList(
|
notebook,
|
||||||
self.state,self.uistate, self.track,
|
NoteTab(self.dbstate, self.uistate, self.track,
|
||||||
self.attrib.source_list))
|
self.obj.get_note_object()))
|
||||||
self.note_tab = self._add_page(NoteTab(
|
|
||||||
self.state, self.uistate, self.track,
|
notebook.show_all()
|
||||||
self.attrib.get_note_object()))
|
vbox = self.top.get_widget('vbox').pack_start(notebook,True)
|
||||||
self.notebook.show_all()
|
|
||||||
vbox.pack_start(self.notebook,True)
|
|
||||||
|
|
||||||
def _add_page(self,page):
|
|
||||||
self.notebook.insert_page(page)
|
|
||||||
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
||||||
return page
|
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def close_window(self,obj):
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def build_menu_names(self, attrib):
|
def build_menu_names(self, attrib):
|
||||||
if not attrib:
|
if not attrib:
|
||||||
@ -161,17 +131,13 @@ class AttributeEditor(DisplayState.ManagedWindow):
|
|||||||
label = "%s: %s" % (_('Attribute'),label)
|
label = "%s: %s" % (_('Attribute'),label)
|
||||||
return (label, _('Attribute Editor'))
|
return (label, _('Attribute Editor'))
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def save(self,*obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
|
||||||
GrampsDisplay.help('adv-at')
|
|
||||||
|
|
||||||
def on_ok_clicked(self,obj):
|
|
||||||
"""
|
"""
|
||||||
Called when the OK button is pressed. Gets data from the
|
Called when the OK button is pressed. Gets data from the
|
||||||
form and updates the Attribute data structure.
|
form and updates the Attribute data structure.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
attr_data = self.attrib.get_type()
|
attr_data = self.obj.get_type()
|
||||||
if (attr_data[0] == RelLib.Attribute.CUSTOM and
|
if (attr_data[0] == RelLib.Attribute.CUSTOM and
|
||||||
not attr_data[1] in self.alist):
|
not attr_data[1] in self.alist):
|
||||||
WarningDialog(
|
WarningDialog(
|
||||||
@ -181,6 +147,7 @@ class AttributeEditor(DisplayState.ManagedWindow):
|
|||||||
self.alist.append(attr_data[1])
|
self.alist.append(attr_data[1])
|
||||||
self.alist.sort()
|
self.alist.sort()
|
||||||
|
|
||||||
self.callback(self.attrib)
|
if self.callback:
|
||||||
|
self.callback(self.obj)
|
||||||
self.close_window(obj)
|
self.close_window(obj)
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class EditPrimary(DisplayState.ManagedWindow):
|
|||||||
self._setup_fields()
|
self._setup_fields()
|
||||||
self._connect_signals()
|
self._connect_signals()
|
||||||
self.show()
|
self.show()
|
||||||
|
self._post_init()
|
||||||
|
|
||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
"""
|
"""
|
||||||
|
112
src/EditSecondary.py
Normal file
112
src/EditSecondary.py
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000-2005 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 DisplayState
|
||||||
|
import GrampsKeys
|
||||||
|
import GrampsDisplay
|
||||||
|
import Utils
|
||||||
|
|
||||||
|
class EditSecondary(DisplayState.ManagedWindow):
|
||||||
|
|
||||||
|
def __init__(self, state, uistate, track, obj, callback=None):
|
||||||
|
"""Creates an edit window. Associates a person with the window."""
|
||||||
|
|
||||||
|
self.obj = obj
|
||||||
|
self.dbstate = state
|
||||||
|
self.uistate = uistate
|
||||||
|
self.db = state.db
|
||||||
|
self.callback = callback
|
||||||
|
self.signal_keys = []
|
||||||
|
|
||||||
|
DisplayState.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):
|
||||||
|
return id(obj)
|
||||||
|
|
||||||
|
def _add_tab(self,notebook,page):
|
||||||
|
notebook.insert_page(page)
|
||||||
|
notebook.set_tab_label(page,page.get_tab_widget())
|
||||||
|
return page
|
||||||
|
|
||||||
|
def _cleanup_on_exit(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def define_ok_button(self,button,function):
|
||||||
|
button.connect('clicked',function)
|
||||||
|
button.set_sensitive(not self.db.readonly)
|
||||||
|
|
||||||
|
def define_top_level(self,window,title,text):
|
||||||
|
self.window = window
|
||||||
|
self.window.connect('delete-event',self.delete_event)
|
||||||
|
Utils.set_titles(window,title,text)
|
||||||
|
|
||||||
|
def define_cancel_button(self,button):
|
||||||
|
button.connect('clicked',self.delete_event)
|
||||||
|
|
||||||
|
def define_help_button(self,button,tag):
|
||||||
|
button.connect('clicked', lambda x: GrampsDisplay.help(tag))
|
||||||
|
|
||||||
|
def close_window(self,*obj):
|
||||||
|
for key in self.signal_keys:
|
||||||
|
self.db.disconnect(key)
|
||||||
|
self._cleanup_on_exit()
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def delete_event(self,*obj):
|
||||||
|
"""If the data has changed, give the user a chance to cancel
|
||||||
|
the close window"""
|
||||||
|
self.close_window()
|
||||||
|
|
@ -110,15 +110,17 @@ def add_familys_sources(db,family_handle,slist,private):
|
|||||||
if sbase != None and not slist.has_key(sbase):
|
if sbase != None and not slist.has_key(sbase):
|
||||||
slist[sbase] = 1
|
slist[sbase] = 1
|
||||||
|
|
||||||
for event_handle in family.get_event_list():
|
for event_ref in family.get_event_ref_list():
|
||||||
if event_handle:
|
if not event_ref:
|
||||||
event = db.get_event_from_handle(event_handle)
|
continue
|
||||||
if private and event.get_privacy():
|
event_handle = event_ref.ref
|
||||||
continue
|
event = db.get_event_from_handle(event_handle)
|
||||||
for source_ref in event.get_source_references():
|
if private and event.get_privacy():
|
||||||
sbase = source_ref.get_base_handle()
|
continue
|
||||||
if sbase != None and not slist.has_key(sbase):
|
for source_ref in event.get_source_references():
|
||||||
slist[sbase] = 1
|
sbase = source_ref.get_base_handle()
|
||||||
|
if sbase != None and not slist.has_key(sbase):
|
||||||
|
slist[sbase] = 1
|
||||||
|
|
||||||
for attr in family.get_attribute_list():
|
for attr in family.get_attribute_list():
|
||||||
if private and attr.get_privacy():
|
if private and attr.get_privacy():
|
||||||
@ -139,12 +141,10 @@ def add_persons_sources(db,person,slist,private):
|
|||||||
if sbase != None and not slist.has_key(sbase):
|
if sbase != None and not slist.has_key(sbase):
|
||||||
slist[sbase] = 1
|
slist[sbase] = 1
|
||||||
|
|
||||||
elist = person.get_event_list()[:]
|
for event_ref in person.get_event_ref_list() + [person.get_birth_ref(),
|
||||||
|
person.get_death_ref()]:
|
||||||
elist.append(person.get_birth_handle())
|
if event_ref:
|
||||||
elist.append(person.get_death_handle())
|
event_handle = event_ref.ref
|
||||||
for event_handle in elist:
|
|
||||||
if event_handle:
|
|
||||||
event = db.get_event_from_handle(event_handle)
|
event = db.get_event_from_handle(event_handle)
|
||||||
if not event:
|
if not event:
|
||||||
continue
|
continue
|
||||||
@ -709,13 +709,15 @@ class GedcomWriter:
|
|||||||
if not self.restrict or ( not father_alive and not mother_alive ):
|
if not self.restrict or ( not father_alive and not mother_alive ):
|
||||||
self.write_ord("SLGS",family.get_lds_sealing(),1,const.lds_ssealing)
|
self.write_ord("SLGS",family.get_lds_sealing(),1,const.lds_ssealing)
|
||||||
|
|
||||||
for event_handle in family.get_event_list():
|
for event_ref in family.get_event_ref_list():
|
||||||
|
event_handle = event_ref.ref
|
||||||
event = self.db.get_event_from_handle(event_handle)
|
event = self.db.get_event_from_handle(event_handle)
|
||||||
if not event or self.private and event.get_privacy():
|
if not event or self.private and event.get_privacy():
|
||||||
continue
|
continue
|
||||||
name = event.get_name()
|
(index,name) = event.get_type()
|
||||||
|
|
||||||
val = ""
|
val = ""
|
||||||
if Utils.familyConstantEvents.has_key(name):
|
if Utils.familyConstantEvents.has_key(index):
|
||||||
val = Utils.familyConstantEvents[name]
|
val = Utils.familyConstantEvents[name]
|
||||||
if val == "":
|
if val == "":
|
||||||
val = self.target_ged.gramps2tag(name)
|
val = self.target_ged.gramps2tag(name)
|
||||||
@ -837,27 +839,29 @@ class GedcomWriter:
|
|||||||
self.writeln("1 SEX F")
|
self.writeln("1 SEX F")
|
||||||
|
|
||||||
if not restricted:
|
if not restricted:
|
||||||
birth_handle = person.get_birth_handle()
|
birth_ref = person.get_birth_ref()
|
||||||
birth = self.db.get_event_from_handle(birth_handle)
|
if birth_ref:
|
||||||
if birth_handle and birth and not (self.private and birth.get_privacy()):
|
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||||
if not birth.get_date_object().is_empty() or birth.get_place_handle():
|
if not (self.private and birth.get_privacy()):
|
||||||
self.writeln("1 BIRT")
|
if not birth.get_date_object().is_empty() or birth.get_place_handle():
|
||||||
else:
|
self.writeln("1 BIRT")
|
||||||
self.writeln("1 BIRT Y")
|
else:
|
||||||
if birth.get_description() != "":
|
self.writeln("1 BIRT Y")
|
||||||
self.writeln("2 TYPE %s" % birth.get_description())
|
if birth.get_description() != "":
|
||||||
self.dump_event_stats(birth)
|
self.writeln("2 TYPE %s" % birth.get_description())
|
||||||
|
self.dump_event_stats(birth)
|
||||||
|
|
||||||
death_handle = person.get_death_handle()
|
death_ref = person.get_death_ref()
|
||||||
death = self.db.get_event_from_handle(death_handle)
|
if death_ref:
|
||||||
if death_handle and death and not (self.private and death.get_privacy()):
|
death = self.db.get_event_from_handle(death_ref.ref)
|
||||||
if not death.get_date_object().is_empty() or death.get_place_handle():
|
if not (self.private and death.get_privacy()):
|
||||||
self.writeln("1 DEAT")
|
if not death.get_date_object().is_empty() or death.get_place_handle():
|
||||||
else:
|
self.writeln("1 DEAT")
|
||||||
self.writeln("1 DEAT Y")
|
else:
|
||||||
if death.get_description() != "":
|
self.writeln("1 DEAT Y")
|
||||||
self.writeln("2 TYPE %s" % death.get_description())
|
if death.get_description() != "":
|
||||||
self.dump_event_stats(death)
|
self.writeln("2 TYPE %s" % death.get_description())
|
||||||
|
self.dump_event_stats(death)
|
||||||
|
|
||||||
ad = 0
|
ad = 0
|
||||||
|
|
||||||
@ -865,20 +869,16 @@ class GedcomWriter:
|
|||||||
self.write_ord("ENDL",person.get_lds_endowment(),1,const.lds_baptism)
|
self.write_ord("ENDL",person.get_lds_endowment(),1,const.lds_baptism)
|
||||||
self.write_ord("SLGC",person.get_lds_sealing(),1,const.lds_csealing)
|
self.write_ord("SLGC",person.get_lds_sealing(),1,const.lds_csealing)
|
||||||
|
|
||||||
for event_handle in person.get_event_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
if not event_handle:
|
event = self.db.get_event_from_handle(event_ref.ref)
|
||||||
continue
|
|
||||||
event = self.db.get_event_from_handle(event_handle)
|
|
||||||
if not event:
|
|
||||||
continue
|
|
||||||
if self.private and event.get_privacy():
|
if self.private and event.get_privacy():
|
||||||
continue
|
continue
|
||||||
name = event.get_name()
|
(index,name) = event.get_type()
|
||||||
val = ""
|
val = ""
|
||||||
if Utils.personalConstantEvents.has_key(name):
|
if Utils.personalConstantEvents.has_key(index):
|
||||||
val = Utils.personalConstantEvents[name]
|
val = Utils.personalConstantEvents[index]
|
||||||
if val == "":
|
if val == "":
|
||||||
val = self.target_ged.gramps2tag(name)
|
val = self.target_ged.gramps2tag(index)
|
||||||
|
|
||||||
if self.adopt == GedcomInfo.ADOPT_EVENT and val == "ADOP":
|
if self.adopt == GedcomInfo.ADOPT_EVENT and val == "ADOP":
|
||||||
ad = 1
|
ad = 1
|
||||||
|
134
src/LocEdit.py
134
src/LocEdit.py
@ -35,10 +35,9 @@ import gtk.glade
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import const
|
import const
|
||||||
import Utils
|
import Utils
|
||||||
import GrampsDisplay
|
import EditSecondary
|
||||||
import DisplayState
|
|
||||||
|
|
||||||
from WindowUtils import GladeIf
|
from GrampsWidgets import *
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -46,87 +45,68 @@ from gettext import gettext as _
|
|||||||
# LocationEditor class
|
# LocationEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class LocationEditor(DisplayState.ManagedWindow):
|
class LocationEditor(EditSecondary.EditSecondary):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,track,location,callback):
|
def __init__(self,dbstate,uistate,track,location,callback):
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, location)
|
EditSecondary.EditSecondary.__init__(self, dbstate, uistate, track,
|
||||||
|
location, callback)
|
||||||
|
|
||||||
self.location = location
|
def _local_init(self):
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "loc_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "loc_edit","gramps")
|
||||||
self.gladeif = GladeIf(self.top)
|
self.define_top_level(self.top.get_widget("loc_edit"),
|
||||||
|
self.top.get_widget('title'),
|
||||||
|
_('Location Editor'))
|
||||||
|
|
||||||
|
def _setup_fields(self):
|
||||||
|
self.city = MonitoredEntry(
|
||||||
|
self.top.get_widget("city"),
|
||||||
|
self.obj.set_city,
|
||||||
|
self.obj.get_city,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
self.window = self.top.get_widget("loc_edit")
|
self.state = MonitoredEntry(
|
||||||
self.city = self.top.get_widget("city")
|
self.top.get_widget("state"),
|
||||||
self.state = self.top.get_widget("state")
|
self.obj.set_state,
|
||||||
self.postal = self.top.get_widget("postal")
|
self.obj.get_state,
|
||||||
self.phone = self.top.get_widget("phone")
|
self.db.readonly)
|
||||||
self.parish = self.top.get_widget("parish")
|
|
||||||
self.county = self.top.get_widget("county")
|
|
||||||
self.country = self.top.get_widget("country")
|
|
||||||
self.callback = callback
|
|
||||||
|
|
||||||
Utils.set_titles(self.window, self.top.get_widget('title'),
|
|
||||||
_('Location Editor'))
|
|
||||||
|
|
||||||
if location != None:
|
|
||||||
self.city.set_text(location.get_city())
|
|
||||||
self.county.set_text(location.get_county())
|
|
||||||
self.country.set_text(location.get_country())
|
|
||||||
self.state.set_text(location.get_state())
|
|
||||||
self.phone.set_text(location.get_phone())
|
|
||||||
self.postal.set_text(location.get_postal_code())
|
|
||||||
self.parish.set_text(location.get_parish())
|
|
||||||
|
|
||||||
self.gladeif.connect('loc_edit','delete_event',self.on_delete_event)
|
|
||||||
self.gladeif.connect('button119','clicked',self.close_window)
|
|
||||||
self.gladeif.connect('button118','clicked',self.on_ok_clicked)
|
|
||||||
self.gladeif.connect('button128','clicked',self.on_help_clicked)
|
|
||||||
|
|
||||||
self.show()
|
self.postal = MonitoredEntry(
|
||||||
|
self.top.get_widget("postal"),
|
||||||
def on_delete_event(self,obj,b):
|
self.obj.set_postal_code,
|
||||||
self.gladeif.close()
|
self.obj.get_postal_code,
|
||||||
self.close()
|
self.db.readonly)
|
||||||
|
|
||||||
def close_window(self,obj):
|
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
self.phone = MonitoredEntry(
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
self.top.get_widget("phone"),
|
||||||
GrampsDisplay.help('gramps-edit-complete')
|
self.obj.set_phone,
|
||||||
|
self.obj.get_phone,
|
||||||
def on_ok_clicked(self,obj):
|
self.db.readonly)
|
||||||
city = unicode(self.city.get_text())
|
|
||||||
county = unicode(self.county.get_text())
|
|
||||||
country = unicode(self.country.get_text())
|
|
||||||
state = unicode(self.state.get_text())
|
|
||||||
phone = unicode(self.phone.get_text())
|
|
||||||
postal = unicode(self.postal.get_text())
|
|
||||||
parish = unicode(self.parish.get_text())
|
|
||||||
|
|
||||||
self.update_location(city,parish,county,state,phone,postal,country)
|
self.parish = MonitoredEntry(
|
||||||
self.callback(self.location)
|
self.top.get_widget("parish"),
|
||||||
|
self.obj.set_parish,
|
||||||
|
self.obj.get_parish,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.county = MonitoredEntry(
|
||||||
|
self.top.get_widget("county"),
|
||||||
|
self.obj.set_county,
|
||||||
|
self.obj.get_county,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.country = MonitoredEntry(
|
||||||
|
self.top.get_widget("country"),
|
||||||
|
self.obj.set_country,
|
||||||
|
self.obj.get_country,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
def _connect_signals(self):
|
||||||
|
self.define_cancel_button(self.top.get_widget('button119'))
|
||||||
|
self.define_ok_button(self.top.get_widget('button118'),self.save)
|
||||||
|
self.define_help_button(self.top.get_widget('button128'),'gramps-edit-complete')
|
||||||
|
|
||||||
|
def save(self,*obj):
|
||||||
|
if self.callback:
|
||||||
|
self.callback(self.obj)
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
|
|
||||||
def update_location(self,city,parish,county,state,phone,postal,country):
|
|
||||||
if self.location.get_city() != city:
|
|
||||||
self.location.set_city(city)
|
|
||||||
|
|
||||||
if self.location.get_parish() != parish:
|
|
||||||
self.location.set_parish(parish)
|
|
||||||
|
|
||||||
if self.location.get_county() != county:
|
|
||||||
self.location.set_county(county)
|
|
||||||
|
|
||||||
if self.location.get_state() != state:
|
|
||||||
self.location.set_state(state)
|
|
||||||
|
|
||||||
if self.location.get_phone() != phone:
|
|
||||||
self.location.set_phone(phone)
|
|
||||||
|
|
||||||
if self.location.get_postal_code() != postal:
|
|
||||||
self.location.set_postal_code(postal)
|
|
||||||
|
|
||||||
if self.location.get_country() != country:
|
|
||||||
self.location.set_country(country)
|
|
||||||
|
167
src/NameEdit.py
167
src/NameEdit.py
@ -26,8 +26,6 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
import gc
|
|
||||||
from cgi import escape
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -45,8 +43,8 @@ import const
|
|||||||
import Utils
|
import Utils
|
||||||
import RelLib
|
import RelLib
|
||||||
import NameDisplay
|
import NameDisplay
|
||||||
import GrampsDisplay
|
import EditSecondary
|
||||||
import DisplayState
|
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import *
|
||||||
|
|
||||||
@ -55,72 +53,49 @@ from GrampsWidgets import *
|
|||||||
# NameEditor class
|
# NameEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class NameEditor(DisplayState.ManagedWindow):
|
class NameEditor(EditSecondary.EditSecondary):
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, track, name, callback):
|
def __init__(self, dbstate, uistate, track, name, callback):
|
||||||
|
|
||||||
self.db = dbstate.db
|
EditSecondary.EditSecondary.__init__(self, dbstate, uistate,
|
||||||
self.dbstate = dbstate
|
track, name, callback)
|
||||||
self.uistate = uistate
|
|
||||||
self.state = dbstate
|
def _local_init(self):
|
||||||
self.callback = callback
|
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, name)
|
|
||||||
|
|
||||||
self.name = name
|
|
||||||
self.original_group_as = self.name.get_group_as()
|
|
||||||
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "name_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "name_edit","gramps")
|
||||||
self.window = self.top.get_widget("name_edit")
|
self.define_top_level(self.top.get_widget("name_edit"),
|
||||||
|
self.top.get_widget("title"),
|
||||||
|
_("Name Editor"))
|
||||||
|
|
||||||
self.notebook = self.top.get_widget("notebook")
|
self.original_group_as = self.obj.get_group_as()
|
||||||
self.general_label = self.top.get_widget("general_tab")
|
self.general_label = self.top.get_widget("general_tab")
|
||||||
|
|
||||||
self.group_over = self.top.get_widget('group_over')
|
self.group_over = self.top.get_widget('group_over')
|
||||||
self.group_over.connect('toggled',self.on_group_over_toggled)
|
self.group_over.connect('toggled',self.on_group_over_toggled)
|
||||||
self.group_over.set_sensitive(not self.db.readonly)
|
self.group_over.set_sensitive(not self.db.readonly)
|
||||||
|
|
||||||
full_name = NameDisplay.displayer.display_name(name)
|
|
||||||
|
|
||||||
alt_title = self.top.get_widget("title")
|
|
||||||
|
|
||||||
if full_name == "":
|
|
||||||
tmsg = _("Name Editor")
|
|
||||||
else:
|
|
||||||
tmsg = _("Name Editor for %s") % escape(full_name)
|
|
||||||
|
|
||||||
Utils.set_titles(self.window, alt_title, tmsg, _('Name Editor'))
|
|
||||||
|
|
||||||
Utils.bold_label(self.general_label)
|
Utils.bold_label(self.general_label)
|
||||||
|
|
||||||
self._create_tabbed_pages()
|
def _post_init(self):
|
||||||
self._setup_fields()
|
if self.original_group_as and self.original_group_as != self.obj.get_surname():
|
||||||
self._connect_signals()
|
|
||||||
|
|
||||||
if self.original_group_as and self.original_group_as != self.name.get_surname():
|
|
||||||
self.group_over.set_active(True)
|
self.group_over.set_active(True)
|
||||||
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.window.connect('delete_event',self.on_delete_event)
|
self.define_cancel_button(self.top.get_widget('button119'))
|
||||||
self.top.get_widget('button119').connect('clicked',self.close_window)
|
self.define_help_button(self.top.get_widget('button131'),'adv-an')
|
||||||
self.top.get_widget('button131').connect('clicked',self.on_help_clicked)
|
self.define_ok_button(self.top.get_widget('button118'),self.save)
|
||||||
okbtn = self.top.get_widget('button118')
|
|
||||||
okbtn.set_sensitive(not self.db.readonly)
|
|
||||||
okbtn.connect('clicked',self.on_name_edit_ok_clicked)
|
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
self.group_as = MonitoredEntry(
|
self.group_as = MonitoredEntry(
|
||||||
self.top.get_widget("group_as"), self.name.set_group_as,
|
self.top.get_widget("group_as"), self.obj.set_group_as,
|
||||||
self.name.get_group_as, self.db.readonly)
|
self.obj.get_group_as, self.db.readonly)
|
||||||
|
|
||||||
if not self.original_group_as:
|
if not self.original_group_as:
|
||||||
self.group_as.force_value(self.name.get_surname())
|
self.group_as.force_value(self.obj.get_surname())
|
||||||
|
|
||||||
self.sort_as = MonitoredMenu(
|
self.sort_as = MonitoredMenu(
|
||||||
self.top.get_widget('sort_as'),self.name.set_sort_as,
|
self.top.get_widget('sort_as'),self.obj.set_sort_as,
|
||||||
self.name.get_sort_as,
|
self.obj.get_sort_as,
|
||||||
[(_('Default (based on locale'),RelLib.Name.DEF),
|
[(_('Default (based on locale'),RelLib.Name.DEF),
|
||||||
(_('Given name Family name'), RelLib.Name.FNLN),
|
(_('Given name Family name'), RelLib.Name.FNLN),
|
||||||
(_('Family name Given Name'), RelLib.Name.LNFN)],
|
(_('Family name Given Name'), RelLib.Name.LNFN)],
|
||||||
@ -128,55 +103,61 @@ class NameEditor(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
self.display_as = MonitoredMenu(
|
self.display_as = MonitoredMenu(
|
||||||
self.top.get_widget('display_as'),
|
self.top.get_widget('display_as'),
|
||||||
self.name.set_display_as, self.name.get_display_as,
|
self.obj.set_display_as, self.obj.get_display_as,
|
||||||
[(_('Default (based on locale'),RelLib.Name.DEF),
|
[(_('Default (based on locale'),RelLib.Name.DEF),
|
||||||
(_('Given name Family name'), RelLib.Name.FNLN),
|
(_('Given name Family name'), RelLib.Name.FNLN),
|
||||||
(_('Family name Given Name'), RelLib.Name.LNFN)],
|
(_('Family name Given Name'), RelLib.Name.LNFN)],
|
||||||
self.db.readonly)
|
self.db.readonly)
|
||||||
|
|
||||||
self.given_field = MonitoredEntry(
|
self.given_field = MonitoredEntry(
|
||||||
self.top.get_widget("alt_given"), self.name.set_first_name,
|
self.top.get_widget("alt_given"), self.obj.set_first_name,
|
||||||
self.name.get_first_name, self.db.readonly)
|
self.obj.get_first_name, self.db.readonly)
|
||||||
|
|
||||||
self.title_field = MonitoredEntry(
|
self.title_field = MonitoredEntry(
|
||||||
self.top.get_widget("alt_title"), self.name.set_title,
|
self.top.get_widget("alt_title"), self.obj.set_title,
|
||||||
self.name.get_title, self.db.readonly)
|
self.obj.get_title, self.db.readonly)
|
||||||
|
|
||||||
self.suffix_field = MonitoredEntry(
|
self.suffix_field = MonitoredEntry(
|
||||||
self.top.get_widget("alt_suffix"), self.name.set_suffix,
|
self.top.get_widget("alt_suffix"), self.obj.set_suffix,
|
||||||
self.name.get_suffix, self.db.readonly)
|
self.obj.get_suffix, self.db.readonly)
|
||||||
|
|
||||||
self.patronymic_field = MonitoredEntry(
|
self.patronymic_field = MonitoredEntry(
|
||||||
self.top.get_widget("patronymic"), self.name.set_patronymic,
|
self.top.get_widget("patronymic"), self.obj.set_patronymic,
|
||||||
self.name.get_patronymic, self.db.readonly)
|
self.obj.get_patronymic, self.db.readonly)
|
||||||
|
|
||||||
self.surname_field = MonitoredEntry(
|
self.surname_field = MonitoredEntry(
|
||||||
self.top.get_widget("alt_surname"), self.name.set_surname,
|
self.top.get_widget("alt_surname"), self.obj.set_surname,
|
||||||
self.name.get_surname, self.db.readonly,
|
self.obj.get_surname, self.db.readonly,
|
||||||
self.update_group_as)
|
self.update_group_as)
|
||||||
|
|
||||||
self.prefix_field = MonitoredEntry(
|
self.prefix_field = MonitoredEntry(
|
||||||
self.top.get_widget("alt_prefix"), self.name.set_surname_prefix,
|
self.top.get_widget("alt_prefix"), self.obj.set_surname_prefix,
|
||||||
self.name.get_surname_prefix, self.db.readonly)
|
self.obj.get_surname_prefix, self.db.readonly)
|
||||||
|
|
||||||
self.date = MonitoredDate(self.top.get_widget("date"),
|
self.date = MonitoredDate(self.top.get_widget("date"),
|
||||||
self.top.get_widget("date_stat"),
|
self.top.get_widget("date_stat"),
|
||||||
self.name.get_date_object(),self.window)
|
self.obj.get_date_object(),self.window)
|
||||||
|
|
||||||
self.name_combo = MonitoredType(
|
self.obj_combo = MonitoredType(
|
||||||
self.top.get_widget("name_type"), self.name.set_type,
|
self.top.get_widget("name_type"), self.obj.set_type,
|
||||||
self.name.get_type, dict(Utils.name_types), RelLib.Name.CUSTOM)
|
self.obj.get_type, dict(Utils.name_types), RelLib.Name.CUSTOM)
|
||||||
|
|
||||||
self.privacy = PrivacyButton(
|
self.privacy = PrivacyButton(
|
||||||
self.top.get_widget("priv"), self.name)
|
self.top.get_widget("priv"), self.obj)
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
self.srcref_list = self._add_page(SourceEmbedList(
|
|
||||||
self.dbstate,self.uistate, self.track,
|
notebook = self.top.get_widget("notebook")
|
||||||
self.name.source_list))
|
|
||||||
self.note_tab = self._add_page(NoteTab(
|
self.srcref_list = self._add_tab(
|
||||||
self.dbstate, self.uistate, self.track,
|
notebook,
|
||||||
self.name.get_note_object()))
|
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
||||||
|
self.obj.source_list))
|
||||||
|
|
||||||
|
self.note_tab = self._add_tab(
|
||||||
|
notebook,
|
||||||
|
NoteTab(self.dbstate, self.uistate, self.track,
|
||||||
|
self.obj.get_note_object()))
|
||||||
|
|
||||||
def build_menu_names(self,name):
|
def build_menu_names(self,name):
|
||||||
if name:
|
if name:
|
||||||
@ -187,17 +168,12 @@ class NameEditor(DisplayState.ManagedWindow):
|
|||||||
menu_label = _('Name Editor')
|
menu_label = _('Name Editor')
|
||||||
return (menu_label,submenu_label)
|
return (menu_label,submenu_label)
|
||||||
|
|
||||||
def _add_page(self,page):
|
|
||||||
self.notebook.insert_page(page)
|
|
||||||
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
||||||
return page
|
|
||||||
|
|
||||||
def update_group_as(self,obj):
|
def update_group_as(self,obj):
|
||||||
if not self.group_over.get_active():
|
if not self.group_over.get_active():
|
||||||
if self.name.get_group_as() != self.name.get_surname():
|
if self.obj.get_group_as() != self.obj.get_surname():
|
||||||
val = self.name.get_group_as()
|
val = self.obj.get_group_as()
|
||||||
else:
|
else:
|
||||||
name = self.name.get_surname()
|
name = self.obj.get_surname()
|
||||||
val = self.db.get_name_group_mapping(name)
|
val = self.db.get_name_group_mapping(name)
|
||||||
self.group_as.force_value(val)
|
self.group_as.force_value(val)
|
||||||
|
|
||||||
@ -205,31 +181,19 @@ class NameEditor(DisplayState.ManagedWindow):
|
|||||||
self.group_as.enable(obj.get_active())
|
self.group_as.enable(obj.get_active())
|
||||||
|
|
||||||
if not obj.get_active():
|
if not obj.get_active():
|
||||||
field_value = self.name.get_surname()
|
field_value = self.obj.get_surname()
|
||||||
mapping = self.db.get_name_group_mapping(field_value)
|
mapping = self.db.get_name_group_mapping(field_value)
|
||||||
self.group_as.set_text(mapping)
|
self.group_as.set_text(mapping)
|
||||||
|
|
||||||
def on_delete_event(self,*obj):
|
def save(self,*obj):
|
||||||
self.close()
|
|
||||||
|
|
||||||
def close_window(self,*obj):
|
|
||||||
self.close()
|
|
||||||
self.window.destroy()
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def on_help_clicked(self,*obj):
|
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
|
||||||
GrampsDisplay.help('adv-an')
|
|
||||||
|
|
||||||
def on_name_edit_ok_clicked(self,obj):
|
|
||||||
|
|
||||||
if not self.group_over.get_active():
|
if not self.group_over.get_active():
|
||||||
self.name.set_group_as("")
|
self.obj.set_group_as("")
|
||||||
elif self.name.get_group_as() == self.name.get_surname():
|
elif self.obj.get_group_as() == self.obj.get_surname():
|
||||||
self.name.set_group_as("")
|
self.obj.set_group_as("")
|
||||||
elif self.name.get_group_as() != self.original_group_as:
|
elif self.obj.get_group_as() != self.original_group_as:
|
||||||
grp_as = self.name.get_group_as()
|
grp_as = self.obj.get_group_as()
|
||||||
srn = self.name.get_surname()
|
srn = self.obj.get_surname()
|
||||||
if grp_as not in self.db.get_name_group_keys():
|
if grp_as not in self.db.get_name_group_keys():
|
||||||
from QuestionDialog import QuestionDialog2
|
from QuestionDialog import QuestionDialog2
|
||||||
q = QuestionDialog2(
|
q = QuestionDialog2(
|
||||||
@ -242,12 +206,13 @@ class NameEditor(DisplayState.ManagedWindow):
|
|||||||
_("Group this name only"))
|
_("Group this name only"))
|
||||||
val = q.run()
|
val = q.run()
|
||||||
if val:
|
if val:
|
||||||
self.name.set_group_as("")
|
self.obj.set_group_as("")
|
||||||
self.db.set_name_group_mapping(srn,grp_as)
|
self.db.set_name_group_mapping(srn,grp_as)
|
||||||
else:
|
else:
|
||||||
self.name.set_group_as(grp_as)
|
self.obj.set_group_as(grp_as)
|
||||||
|
|
||||||
self.callback(self.name)
|
if self.callback:
|
||||||
|
self.callback(self.obj)
|
||||||
self.close_window(obj)
|
self.close_window(obj)
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,9 +43,8 @@ import gtk.glade
|
|||||||
import const
|
import const
|
||||||
import Utils
|
import Utils
|
||||||
import RelLib
|
import RelLib
|
||||||
import GrampsDisplay
|
import EditSecondary
|
||||||
import DisplayState
|
|
||||||
import AutoComp
|
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import *
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -53,79 +52,46 @@ from GrampsWidgets import *
|
|||||||
# UrlEditor class
|
# UrlEditor class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class UrlEditor(DisplayState.ManagedWindow):
|
class UrlEditor(EditSecondary.EditSecondary):
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, track, name, url, callback):
|
def __init__(self, dbstate, uistate, track, name, url, callback):
|
||||||
|
|
||||||
self.db = dbstate.db
|
EditSecondary.EditSecondary.__init__(self, dbstate, uistate, track,
|
||||||
self.uistate = uistate
|
url, callback)
|
||||||
self.state = dbstate
|
|
||||||
self.callback = callback
|
|
||||||
self.name = name
|
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, url)
|
|
||||||
|
|
||||||
self.url = url
|
def _local_init(self):
|
||||||
self.callback = callback
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps")
|
||||||
|
|
||||||
self.window = self.top.get_widget("url_edit")
|
|
||||||
|
|
||||||
title_label = self.top.get_widget("title")
|
self.define_top_level(self.top.get_widget("url_edit"),
|
||||||
if not name or name == ", ":
|
self.top.get_widget("title"),
|
||||||
etitle =_('Internet Address Editor')
|
_('Internet Address Editor'))
|
||||||
else:
|
|
||||||
etitle =_('Internet Address Editor for %s') % escape(name)
|
|
||||||
|
|
||||||
|
|
||||||
Utils.set_titles(self.window,title_label, etitle,
|
|
||||||
_('Internet Address Editor'))
|
|
||||||
|
|
||||||
self._setup_fields()
|
|
||||||
self._connect_signals()
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.window.connect('delete_event', self.on_delete_event)
|
self.define_cancel_button(self.top.get_widget('button125'))
|
||||||
self.top.get_widget('button125').connect('clicked', self.close_window)
|
self.define_ok_button(self.top.get_widget('button124'),self.save)
|
||||||
self.top.get_widget('button124').connect('clicked', self.ok_clicked)
|
self.define_help_button(self.top.get_widget('button130'),'gramps-edit_complete')
|
||||||
self.top.get_widget('button130').connect('clicked', self.help_clicked)
|
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
self.des = MonitoredEntry(
|
self.des = MonitoredEntry(
|
||||||
self.top.get_widget("url_des"), self.url.set_description,
|
self.top.get_widget("url_des"), self.obj.set_description,
|
||||||
self.url.get_description, self.db.readonly)
|
self.obj.get_description, self.db.readonly)
|
||||||
|
|
||||||
self.addr = MonitoredEntry(
|
self.addr = MonitoredEntry(
|
||||||
self.top.get_widget("url_addr"), self.url.set_path,
|
self.top.get_widget("url_addr"), self.obj.set_path,
|
||||||
self.url.get_path, self.db.readonly)
|
self.obj.get_path, self.db.readonly)
|
||||||
|
|
||||||
self.priv = PrivacyButton(self.top.get_widget("priv"),
|
self.priv = PrivacyButton(self.top.get_widget("priv"),
|
||||||
self.url, self.db.readonly)
|
self.obj, self.db.readonly)
|
||||||
|
|
||||||
self.type_sel = MonitoredType(
|
self.type_sel = MonitoredType(
|
||||||
self.top.get_widget("type"), self.url.set_type,
|
self.top.get_widget("type"), self.obj.set_type,
|
||||||
self.url.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM)
|
self.obj.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM)
|
||||||
|
|
||||||
|
|
||||||
def build_menu_names(self,obj):
|
def build_menu_names(self,obj):
|
||||||
if not self.name or self.name == ", ":
|
etitle =_('Internet Address Editor')
|
||||||
etitle =_('Internet Address Editor')
|
return (etitle, etitle)
|
||||||
else:
|
|
||||||
etitle =_('Internet Address Editor for %s') % escape(self.name)
|
|
||||||
return (etitle, _('Internet Address Editor'))
|
|
||||||
|
|
||||||
def on_delete_event(self,*obj):
|
def save(self,*obj):
|
||||||
self.close()
|
self.callback(self.obj)
|
||||||
|
self.close_window()
|
||||||
def close_window(self,*obj):
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def help_clicked(self,*obj):
|
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
|
||||||
GrampsDisplay.help('gramps-edit-complete')
|
|
||||||
|
|
||||||
def ok_clicked(self,obj):
|
|
||||||
self.callback(self.url)
|
|
||||||
self.close_window(obj)
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user