* 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:
Don Allingham 2006-03-02 04:32:37 +00:00
parent d251bbe7c1
commit f545e1d769
9 changed files with 388 additions and 428 deletions

View File

@ -1,4 +1,11 @@
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/DisplayTabs.py: provide double click/edit button handling
for back references.

View File

@ -44,11 +44,8 @@ import gtk.glade
# gramps modules
#
#-------------------------------------------------------------------------
import GrampsDisplay
import const
import Utils
import RelLib
import DisplayState
import EditSecondary
from DisplayTabs import *
from GrampsWidgets import *
@ -58,7 +55,7 @@ from GrampsWidgets import *
# AddressEditor class
#
#-------------------------------------------------------------------------
class AddressEditor(DisplayState.ManagedWindow):
class AddressEditor(EditSecondary.EditSecondary):
"""
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.
addr - The address that is to be edited
"""
EditSecondary.EditSecondary.__init__(self, dbstate, uistate, track, addr)
self.db = dbstate.db
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
def _local_init(self):
self.top = gtk.glade.XML(const.gladeFile, "addr_edit","gramps")
self.window = self.top.get_widget("addr_edit")
title_label = self.top.get_widget("title")
Utils.set_titles(self.window,title_label,_('Address Editor'))
self._setup_fields()
self._create_tabbed_pages()
self._connect_signals()
self.show()
self.define_top_level(self.top.get_widget("addr_edit"),
self.top.get_widget("title"),
_('Address Editor'))
def _setup_fields(self):
self.addr_start = MonitoredDate(
self.top.get_widget("address_start"),
self.top.get_widget("date_stat"),
self.addr.get_date_object(),
self.obj.get_date_object(),
self.window, self.db.readonly)
self.street = MonitoredEntry(
self.top.get_widget("street"), self.addr.set_street,
self.addr.get_street, self.db.readonly)
self.top.get_widget("street"), self.obj.set_street,
self.obj.get_street, self.db.readonly)
self.city = MonitoredEntry(
self.top.get_widget("city"), self.addr.set_city,
self.addr.get_city, self.db.readonly)
self.top.get_widget("city"), self.obj.set_city,
self.obj.get_city, self.db.readonly)
self.state = MonitoredEntry(
self.top.get_widget("state"), self.addr.set_state,
self.addr.get_state, self.db.readonly)
self.top.get_widget("state"), self.obj.set_state,
self.obj.get_state, self.db.readonly)
self.country = MonitoredEntry(
self.top.get_widget("country"), self.addr.set_country,
self.addr.get_country, self.db.readonly)
self.top.get_widget("country"), self.obj.set_country,
self.obj.get_country, self.db.readonly)
self.postal = MonitoredEntry(
self.top.get_widget("postal"), self.addr.set_postal_code,
self.addr.get_postal_code, self.db.readonly)
self.top.get_widget("postal"), self.obj.set_postal_code,
self.obj.get_postal_code, self.db.readonly)
self.phone = MonitoredEntry(
self.top.get_widget("phone"), self.addr.set_phone,
self.addr.get_phone, self.db.readonly)
self.top.get_widget("phone"), self.obj.set_phone,
self.obj.get_phone, self.db.readonly)
self.priv = PrivacyButton(self.top.get_widget("private"),
self.addr, self.db.readonly)
self.obj, self.db.readonly)
def _connect_signals(self):
self.window.connect('delete_event',self.on_delete_event)
self.top.get_widget('cancel').connect('clicked',self.close_window)
self.top.get_widget('help').connect('clicked',self.help_clicked)
self.define_help_button(self.top.get_widget('help'),'adv-ad')
self.define_cancel_button(self.top.get_widget('cancel'))
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):
"""
Creates the notebook tabs and inserts them into the main
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(
self.dbstate,self.uistate, self.track,
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()
notebook.show_all()
self.top.get_widget('vbox').pack_start(notebook,True)
def build_menu_names(self,obj):
return (_('Address'),_('Address Editor'))
def help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('adv-ad')
def ok_clicked(self,obj):
def save(self,*obj):
"""
Called when the OK button is pressed. Gets data from the
form and updates the Address data structure.
"""
self.callback(self.addr)
if self.callback:
self.callback(self.obj)
self.close_window(obj)

View File

@ -51,7 +51,7 @@ import const
import Utils
import RelLib
import GrampsDisplay
import DisplayState
import EditSecondary
from QuestionDialog import WarningDialog
from DisplayTabs import *
@ -62,7 +62,7 @@ from GrampsWidgets import *
# AttributeEditor class
#
#-------------------------------------------------------------------------
class AttributeEditor(DisplayState.ManagedWindow):
class AttributeEditor(EditSecondary.EditSecondary):
"""
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
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
DisplayState.ManagedWindow.__init__(self, uistate, track, attrib)
if not attrib:
self.attrib = RelLib.Attribute()
EditSecondary.EditSecondary.__init__(self, state, uistate, track,
attrib, callback)
def _local_init(self):
self.top = gtk.glade.XML(const.gladeFile, "attr_edit","gramps")
self.notebook = self.top.get_widget("notebook")
self.window = self.top.get_widget("attr_edit")
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()
self.define_top_level(self.top.get_widget("attr_edit"),
self.top.get_widget('title'),
_('Attribute Editor'))
def _connect_signals(self):
self.window.connect('delete_event', self.on_delete_event)
self.top.get_widget('cancel').connect('clicked', self.close_window)
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)
self.define_cancel_button(self.top.get_widget('cancel'))
self.define_help_button(self.top.get_widget('help'),'adv-at')
self.define_ok_button(self.top.get_widget('ok'),self.save)
def _setup_fields(self):
self.value_field = MonitoredEntry(
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.priv = PrivacyButton(self.top.get_widget("private"),self.attrib)
self.priv = PrivacyButton(
self.top.get_widget("private"),
self.obj)
self.type_selector = MonitoredType(
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),
RelLib.Attribute.CUSTOM)
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.srcref_list = self._add_page(SourceEmbedList(
self.state,self.uistate, self.track,
self.attrib.source_list))
self.note_tab = self._add_page(NoteTab(
self.state, self.uistate, self.track,
self.attrib.get_note_object()))
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()
self.note_tab = self._add_tab(
notebook,
NoteTab(self.dbstate, self.uistate, self.track,
self.obj.get_note_object()))
notebook.show_all()
vbox = self.top.get_widget('vbox').pack_start(notebook,True)
def build_menu_names(self, attrib):
if not attrib:
@ -161,17 +131,13 @@ class AttributeEditor(DisplayState.ManagedWindow):
label = "%s: %s" % (_('Attribute'),label)
return (label, _('Attribute Editor'))
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('adv-at')
def on_ok_clicked(self,obj):
def save(self,*obj):
"""
Called when the OK button is pressed. Gets data from the
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
not attr_data[1] in self.alist):
WarningDialog(
@ -181,6 +147,7 @@ class AttributeEditor(DisplayState.ManagedWindow):
self.alist.append(attr_data[1])
self.alist.sort()
self.callback(self.attrib)
if self.callback:
self.callback(self.obj)
self.close_window(obj)

View File

@ -55,6 +55,7 @@ class EditPrimary(DisplayState.ManagedWindow):
self._setup_fields()
self._connect_signals()
self.show()
self._post_init()
def _local_init(self):
"""

View 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()

View File

@ -110,15 +110,17 @@ def add_familys_sources(db,family_handle,slist,private):
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for event_handle in family.get_event_list():
if event_handle:
event = db.get_event_from_handle(event_handle)
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
sbase = source_ref.get_base_handle()
if sbase != None and not slist.has_key(sbase):
slist[sbase] = 1
for event_ref in family.get_event_ref_list():
if not event_ref:
continue
event_handle = event_ref.ref
event = db.get_event_from_handle(event_handle)
if private and event.get_privacy():
continue
for source_ref in event.get_source_references():
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():
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):
slist[sbase] = 1
elist = person.get_event_list()[:]
elist.append(person.get_birth_handle())
elist.append(person.get_death_handle())
for event_handle in elist:
if event_handle:
for event_ref in person.get_event_ref_list() + [person.get_birth_ref(),
person.get_death_ref()]:
if event_ref:
event_handle = event_ref.ref
event = db.get_event_from_handle(event_handle)
if not event:
continue
@ -709,13 +709,15 @@ class GedcomWriter:
if not self.restrict or ( not father_alive and not mother_alive ):
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)
if not event or self.private and event.get_privacy():
continue
name = event.get_name()
(index,name) = event.get_type()
val = ""
if Utils.familyConstantEvents.has_key(name):
if Utils.familyConstantEvents.has_key(index):
val = Utils.familyConstantEvents[name]
if val == "":
val = self.target_ged.gramps2tag(name)
@ -837,27 +839,29 @@ class GedcomWriter:
self.writeln("1 SEX F")
if not restricted:
birth_handle = person.get_birth_handle()
birth = self.db.get_event_from_handle(birth_handle)
if birth_handle and birth and not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_handle():
self.writeln("1 BIRT")
else:
self.writeln("1 BIRT Y")
if birth.get_description() != "":
self.writeln("2 TYPE %s" % birth.get_description())
self.dump_event_stats(birth)
birth_ref = person.get_birth_ref()
if birth_ref:
birth = self.db.get_event_from_handle(birth_ref.ref)
if not (self.private and birth.get_privacy()):
if not birth.get_date_object().is_empty() or birth.get_place_handle():
self.writeln("1 BIRT")
else:
self.writeln("1 BIRT Y")
if birth.get_description() != "":
self.writeln("2 TYPE %s" % birth.get_description())
self.dump_event_stats(birth)
death_handle = person.get_death_handle()
death = self.db.get_event_from_handle(death_handle)
if death_handle and death and not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_handle():
self.writeln("1 DEAT")
else:
self.writeln("1 DEAT Y")
if death.get_description() != "":
self.writeln("2 TYPE %s" % death.get_description())
self.dump_event_stats(death)
death_ref = person.get_death_ref()
if death_ref:
death = self.db.get_event_from_handle(death_ref.ref)
if not (self.private and death.get_privacy()):
if not death.get_date_object().is_empty() or death.get_place_handle():
self.writeln("1 DEAT")
else:
self.writeln("1 DEAT Y")
if death.get_description() != "":
self.writeln("2 TYPE %s" % death.get_description())
self.dump_event_stats(death)
ad = 0
@ -865,20 +869,16 @@ class GedcomWriter:
self.write_ord("ENDL",person.get_lds_endowment(),1,const.lds_baptism)
self.write_ord("SLGC",person.get_lds_sealing(),1,const.lds_csealing)
for event_handle in person.get_event_list():
if not event_handle:
continue
event = self.db.get_event_from_handle(event_handle)
if not event:
continue
for event_ref in person.get_event_ref_list():
event = self.db.get_event_from_handle(event_ref.ref)
if self.private and event.get_privacy():
continue
name = event.get_name()
(index,name) = event.get_type()
val = ""
if Utils.personalConstantEvents.has_key(name):
val = Utils.personalConstantEvents[name]
if Utils.personalConstantEvents.has_key(index):
val = Utils.personalConstantEvents[index]
if val == "":
val = self.target_ged.gramps2tag(name)
val = self.target_ged.gramps2tag(index)
if self.adopt == GedcomInfo.ADOPT_EVENT and val == "ADOP":
ad = 1

View File

@ -35,10 +35,9 @@ import gtk.glade
#-------------------------------------------------------------------------
import const
import Utils
import GrampsDisplay
import DisplayState
import EditSecondary
from WindowUtils import GladeIf
from GrampsWidgets import *
from gettext import gettext as _
#-------------------------------------------------------------------------
@ -46,87 +45,68 @@ from gettext import gettext as _
# LocationEditor class
#
#-------------------------------------------------------------------------
class LocationEditor(DisplayState.ManagedWindow):
class LocationEditor(EditSecondary.EditSecondary):
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.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.city = self.top.get_widget("city")
self.state = self.top.get_widget("state")
self.postal = self.top.get_widget("postal")
self.phone = self.top.get_widget("phone")
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.state = MonitoredEntry(
self.top.get_widget("state"),
self.obj.set_state,
self.obj.get_state,
self.db.readonly)
self.show()
def on_delete_event(self,obj,b):
self.gladeif.close()
self.close()
def close_window(self,obj):
self.gladeif.close()
self.close()
self.postal = MonitoredEntry(
self.top.get_widget("postal"),
self.obj.set_postal_code,
self.obj.get_postal_code,
self.db.readonly)
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('gramps-edit-complete')
def on_ok_clicked(self,obj):
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.phone = MonitoredEntry(
self.top.get_widget("phone"),
self.obj.set_phone,
self.obj.get_phone,
self.db.readonly)
self.update_location(city,parish,county,state,phone,postal,country)
self.callback(self.location)
self.parish = MonitoredEntry(
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)
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)

View File

@ -26,8 +26,6 @@
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import gc
from cgi import escape
#-------------------------------------------------------------------------
#
@ -45,8 +43,8 @@ import const
import Utils
import RelLib
import NameDisplay
import GrampsDisplay
import DisplayState
import EditSecondary
from DisplayTabs import *
from GrampsWidgets import *
@ -55,72 +53,49 @@ from GrampsWidgets import *
# NameEditor class
#
#-------------------------------------------------------------------------
class NameEditor(DisplayState.ManagedWindow):
class NameEditor(EditSecondary.EditSecondary):
def __init__(self, dbstate, uistate, track, name, callback):
self.db = dbstate.db
self.dbstate = dbstate
self.uistate = uistate
self.state = dbstate
self.callback = callback
EditSecondary.EditSecondary.__init__(self, dbstate, uistate,
track, name, callback)
def _local_init(self):
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.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.group_over = self.top.get_widget('group_over')
self.group_over.connect('toggled',self.on_group_over_toggled)
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)
self._create_tabbed_pages()
self._setup_fields()
self._connect_signals()
if self.original_group_as and self.original_group_as != self.name.get_surname():
def _post_init(self):
if self.original_group_as and self.original_group_as != self.obj.get_surname():
self.group_over.set_active(True)
self.show()
def _connect_signals(self):
self.window.connect('delete_event',self.on_delete_event)
self.top.get_widget('button119').connect('clicked',self.close_window)
self.top.get_widget('button131').connect('clicked',self.on_help_clicked)
okbtn = self.top.get_widget('button118')
okbtn.set_sensitive(not self.db.readonly)
okbtn.connect('clicked',self.on_name_edit_ok_clicked)
self.define_cancel_button(self.top.get_widget('button119'))
self.define_help_button(self.top.get_widget('button131'),'adv-an')
self.define_ok_button(self.top.get_widget('button118'),self.save)
def _setup_fields(self):
self.group_as = MonitoredEntry(
self.top.get_widget("group_as"), self.name.set_group_as,
self.name.get_group_as, self.db.readonly)
self.top.get_widget("group_as"), self.obj.set_group_as,
self.obj.get_group_as, self.db.readonly)
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.top.get_widget('sort_as'),self.name.set_sort_as,
self.name.get_sort_as,
self.top.get_widget('sort_as'),self.obj.set_sort_as,
self.obj.get_sort_as,
[(_('Default (based on locale'),RelLib.Name.DEF),
(_('Given name Family name'), RelLib.Name.FNLN),
(_('Family name Given Name'), RelLib.Name.LNFN)],
@ -128,55 +103,61 @@ class NameEditor(DisplayState.ManagedWindow):
self.display_as = MonitoredMenu(
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),
(_('Given name Family name'), RelLib.Name.FNLN),
(_('Family name Given Name'), RelLib.Name.LNFN)],
self.db.readonly)
self.given_field = MonitoredEntry(
self.top.get_widget("alt_given"), self.name.set_first_name,
self.name.get_first_name, self.db.readonly)
self.top.get_widget("alt_given"), self.obj.set_first_name,
self.obj.get_first_name, self.db.readonly)
self.title_field = MonitoredEntry(
self.top.get_widget("alt_title"), self.name.set_title,
self.name.get_title, self.db.readonly)
self.top.get_widget("alt_title"), self.obj.set_title,
self.obj.get_title, self.db.readonly)
self.suffix_field = MonitoredEntry(
self.top.get_widget("alt_suffix"), self.name.set_suffix,
self.name.get_suffix, self.db.readonly)
self.top.get_widget("alt_suffix"), self.obj.set_suffix,
self.obj.get_suffix, self.db.readonly)
self.patronymic_field = MonitoredEntry(
self.top.get_widget("patronymic"), self.name.set_patronymic,
self.name.get_patronymic, self.db.readonly)
self.top.get_widget("patronymic"), self.obj.set_patronymic,
self.obj.get_patronymic, self.db.readonly)
self.surname_field = MonitoredEntry(
self.top.get_widget("alt_surname"), self.name.set_surname,
self.name.get_surname, self.db.readonly,
self.top.get_widget("alt_surname"), self.obj.set_surname,
self.obj.get_surname, self.db.readonly,
self.update_group_as)
self.prefix_field = MonitoredEntry(
self.top.get_widget("alt_prefix"), self.name.set_surname_prefix,
self.name.get_surname_prefix, self.db.readonly)
self.top.get_widget("alt_prefix"), self.obj.set_surname_prefix,
self.obj.get_surname_prefix, self.db.readonly)
self.date = MonitoredDate(self.top.get_widget("date"),
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.top.get_widget("name_type"), self.name.set_type,
self.name.get_type, dict(Utils.name_types), RelLib.Name.CUSTOM)
self.obj_combo = MonitoredType(
self.top.get_widget("name_type"), self.obj.set_type,
self.obj.get_type, dict(Utils.name_types), RelLib.Name.CUSTOM)
self.privacy = PrivacyButton(
self.top.get_widget("priv"), self.name)
self.top.get_widget("priv"), self.obj)
def _create_tabbed_pages(self):
self.srcref_list = self._add_page(SourceEmbedList(
self.dbstate,self.uistate, self.track,
self.name.source_list))
self.note_tab = self._add_page(NoteTab(
self.dbstate, self.uistate, self.track,
self.name.get_note_object()))
notebook = self.top.get_widget("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()))
def build_menu_names(self,name):
if name:
@ -187,17 +168,12 @@ class NameEditor(DisplayState.ManagedWindow):
menu_label = _('Name Editor')
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):
if not self.group_over.get_active():
if self.name.get_group_as() != self.name.get_surname():
val = self.name.get_group_as()
if self.obj.get_group_as() != self.obj.get_surname():
val = self.obj.get_group_as()
else:
name = self.name.get_surname()
name = self.obj.get_surname()
val = self.db.get_name_group_mapping(name)
self.group_as.force_value(val)
@ -205,31 +181,19 @@ class NameEditor(DisplayState.ManagedWindow):
self.group_as.enable(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)
self.group_as.set_text(mapping)
def on_delete_event(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):
def save(self,*obj):
if not self.group_over.get_active():
self.name.set_group_as("")
elif self.name.get_group_as() == self.name.get_surname():
self.name.set_group_as("")
elif self.name.get_group_as() != self.original_group_as:
grp_as = self.name.get_group_as()
srn = self.name.get_surname()
self.obj.set_group_as("")
elif self.obj.get_group_as() == self.obj.get_surname():
self.obj.set_group_as("")
elif self.obj.get_group_as() != self.original_group_as:
grp_as = self.obj.get_group_as()
srn = self.obj.get_surname()
if grp_as not in self.db.get_name_group_keys():
from QuestionDialog import QuestionDialog2
q = QuestionDialog2(
@ -242,12 +206,13 @@ class NameEditor(DisplayState.ManagedWindow):
_("Group this name only"))
val = q.run()
if val:
self.name.set_group_as("")
self.obj.set_group_as("")
self.db.set_name_group_mapping(srn,grp_as)
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)

View File

@ -43,9 +43,8 @@ import gtk.glade
import const
import Utils
import RelLib
import GrampsDisplay
import DisplayState
import AutoComp
import EditSecondary
from GrampsWidgets import *
#-------------------------------------------------------------------------
@ -53,79 +52,46 @@ from GrampsWidgets import *
# UrlEditor class
#
#-------------------------------------------------------------------------
class UrlEditor(DisplayState.ManagedWindow):
class UrlEditor(EditSecondary.EditSecondary):
def __init__(self, dbstate, uistate, track, name, url, callback):
self.db = dbstate.db
self.uistate = uistate
self.state = dbstate
self.callback = callback
self.name = name
DisplayState.ManagedWindow.__init__(self, uistate, track, url)
EditSecondary.EditSecondary.__init__(self, dbstate, uistate, track,
url, callback)
self.url = url
self.callback = callback
def _local_init(self):
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")
if not name or name == ", ":
etitle =_('Internet Address Editor')
else:
etitle =_('Internet Address Editor for %s') % escape(name)
self.define_top_level(self.top.get_widget("url_edit"),
self.top.get_widget("title"),
_('Internet Address Editor'))
Utils.set_titles(self.window,title_label, etitle,
_('Internet Address Editor'))
self._setup_fields()
self._connect_signals()
self.show()
def _connect_signals(self):
self.window.connect('delete_event', self.on_delete_event)
self.top.get_widget('button125').connect('clicked', self.close_window)
self.top.get_widget('button124').connect('clicked', self.ok_clicked)
self.top.get_widget('button130').connect('clicked', self.help_clicked)
self.define_cancel_button(self.top.get_widget('button125'))
self.define_ok_button(self.top.get_widget('button124'),self.save)
self.define_help_button(self.top.get_widget('button130'),'gramps-edit_complete')
def _setup_fields(self):
self.des = MonitoredEntry(
self.top.get_widget("url_des"), self.url.set_description,
self.url.get_description, self.db.readonly)
self.top.get_widget("url_des"), self.obj.set_description,
self.obj.get_description, self.db.readonly)
self.addr = MonitoredEntry(
self.top.get_widget("url_addr"), self.url.set_path,
self.url.get_path, self.db.readonly)
self.top.get_widget("url_addr"), self.obj.set_path,
self.obj.get_path, self.db.readonly)
self.priv = PrivacyButton(self.top.get_widget("priv"),
self.url, self.db.readonly)
self.obj, self.db.readonly)
self.type_sel = MonitoredType(
self.top.get_widget("type"), self.url.set_type,
self.url.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM)
self.top.get_widget("type"), self.obj.set_type,
self.obj.get_type, dict(Utils.web_types), RelLib.Url.CUSTOM)
def build_menu_names(self,obj):
if not self.name or self.name == ", ":
etitle =_('Internet Address Editor')
else:
etitle =_('Internet Address Editor for %s') % escape(self.name)
return (etitle, _('Internet Address Editor'))
etitle =_('Internet Address Editor')
return (etitle, etitle)
def on_delete_event(self,*obj):
self.close()
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)
def save(self,*obj):
self.callback(self.obj)
self.close_window()