2
# Gramps - a GTK+/GNOME based genealogy program
4
# Copyright (C) 2000-2006 Donald N. Allingham
6
# Copyright (C) 2011 Tim G L Lyons
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
# $Id: editattribute.py 18548 2011-12-04 17:09:17Z kulath $
26
The EditAttribute module provides the AttributeEditor class. This provides a
27
mechanism for the user to edit attribute information.
30
#-------------------------------------------------------------------------
34
#-------------------------------------------------------------------------
35
from gen.ggettext import gettext as _
37
#-------------------------------------------------------------------------
41
#-------------------------------------------------------------------------
44
#-------------------------------------------------------------------------
48
#-------------------------------------------------------------------------
49
from editsecondary import EditSecondary
50
from gen.lib import NoteType
51
from glade import Glade
52
from displaytabs import CitationEmbedList, NoteTab
53
from gui.widgets import MonitoredEntry, PrivacyButton, MonitoredDataType
55
#-------------------------------------------------------------------------
59
#-------------------------------------------------------------------------
60
class EditAttribute(EditSecondary):
62
Displays a dialog that allows the user to edit an attribute.
65
def __init__(self, state, uistate, track, attrib, title, data_list, callback):
67
Displays the dialog box.
69
parent - The class that called the Address editor.
70
attrib - The attribute that is to be edited
71
title - The title of the dialog box
72
list - list of options for the pop down menu
74
self.alist = data_list
75
EditSecondary.__init__(self, state, uistate, track, attrib, callback)
77
def _local_init(self):
78
self.width_key = 'interface.attribute-width'
79
self.height_key = 'interface.attribute-height'
82
self.set_window(self.top.toplevel,
83
self.top.get_object('title'),
84
_('Attribute Editor'))
86
def _connect_signals(self):
87
self.define_cancel_button(self.top.get_object('cancel'))
88
self.define_help_button(self.top.get_object('help'))
89
self.define_ok_button(self.top.get_object('ok'),self.save)
91
def _setup_fields(self):
92
self.value_field = MonitoredEntry(
93
self.top.get_object("attr_value"),
94
self.obj.set_value, self.obj.get_value,
97
self.priv = PrivacyButton(
98
self.top.get_object("private"),
99
self.obj, self.db.readonly)
101
self.type_selector = MonitoredDataType(
102
self.top.get_object("attr_menu"),
106
custom_values=self.alist
109
def _create_tabbed_pages(self):
110
notebook = gtk.Notebook()
111
self.srcref_list = CitationEmbedList(self.dbstate,
114
self.obj.get_citation_list())
115
self._add_tab(notebook, self.srcref_list)
116
self.track_ref_for_deletion("srcref_list")
118
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
119
self.obj.get_note_list(),
120
notetype = NoteType.ATTRIBUTE)
121
self._add_tab(notebook, self.note_tab)
122
self.track_ref_for_deletion("note_tab")
124
self._setup_notebook_tabs( notebook)
126
self.top.get_object('vbox').pack_start(notebook,True)
128
def build_menu_names(self, attrib):
130
label = _("New Attribute")
132
label = str(attrib.get_type())
133
if not label.strip():
134
label = _("New Attribute")
135
label = "%s: %s" % (_('Attribute'),label)
136
return (label, _('Attribute Editor'))
140
Called when the OK button is pressed. Gets data from the
141
form and updates the Attribute data structure.
143
t = self.obj.get_type()
145
if t.is_custom() and str(t) == '':
146
from QuestionDialog import ErrorDialog
148
_("Cannot save attribute"),
149
_("The attribute type cannot be empty"))
152
self.callback(self.obj)
155
#-------------------------------------------------------------------------
157
# EditAttribute class
159
#-------------------------------------------------------------------------
160
class EditFamilyAttribute(EditAttribute):
162
Displays a dialog that allows the user to edit an attribute.
164
def __init__(self, state, uistate, track, attrib, title, data_list, callback):
166
Displays the dialog box.
168
parent - The class that called the Address editor.
169
attrib - The attribute that is to be edited
170
title - The title of the dialog box
171
list - list of options for the pop down menu
173
EditAttribute.__init__(self, state, uistate, track, attrib, title,