* src/Editors/__init__.py: added EditChildRef

* src/Editors/Makefile.am: added EditChildRef
	* src/Editors/_EditChildRef.py: added
	* src/Editors/_EditFamily.py: add child reference editor
	* src/DisplayTabs.py: add optional properties button
	* src/glade/gramps.glade: add child reference editor


svn: r6354
This commit is contained in:
Don Allingham
2006-04-18 20:27:53 +00:00
parent 3c31f1e2ec
commit 6b54577315
8 changed files with 460 additions and 37 deletions

View File

@@ -1,4 +1,10 @@
2006-04-18 Don Allingham <don@gramps-project.org> 2006-04-18 Don Allingham <don@gramps-project.org>
* src/Editors/__init__.py: added EditChildRef
* src/Editors/Makefile.am: added EditChildRef
* src/Editors/_EditChildRef.py: added
* src/Editors/_EditFamily.py: add child reference editor
* src/DisplayTabs.py: add optional properties button
* src/glade/gramps.glade: add child reference editor
* src/plugins/Desbrowser.py: bring up to speed with ManagedWindow * src/plugins/Desbrowser.py: bring up to speed with ManagedWindow
* src/GrampsWidgets.py: fix the type return value * src/GrampsWidgets.py: fix the type return value

View File

@@ -121,6 +121,7 @@ class GrampsTab(gtk.HBox):
# build the interface # build the interface
self.share_btn = None self.share_btn = None
self.prop_btn = None
self.build_interface() self.build_interface()
def get_selected(self): def get_selected(self):
@@ -207,9 +208,11 @@ class ButtonTab(GrampsTab):
'del' : _('Remove'), 'del' : _('Remove'),
'edit' : _('Edit'), 'edit' : _('Edit'),
'share' : _('Share'), 'share' : _('Share'),
'prop' : _('Properties'),
} }
def __init__(self, dbstate, uistate, track, name, share_button=False): def __init__(self, dbstate, uistate, track, name, share_button=False,
prop_button=False):
""" """
Similar to the base class, except after Build Similar to the base class, except after Build
@param dbstate: The database state. Contains a reference to @param dbstate: The database state. Contains a reference to
@@ -228,9 +231,9 @@ class ButtonTab(GrampsTab):
""" """
GrampsTab.__init__(self,dbstate, uistate, track, name) GrampsTab.__init__(self,dbstate, uistate, track, name)
self.tooltips = gtk.Tooltips() self.tooltips = gtk.Tooltips()
self.create_buttons(share_button) self.create_buttons(share_button, prop_button)
def create_buttons(self, share_button=False): def create_buttons(self, share_button=False, prop_button=False):
""" """
Creates a button box consisting of three buttons, one for Add, Creates a button box consisting of three buttons, one for Add,
one for Edit, and one for Delete. This button box is then appended one for Edit, and one for Delete. This button box is then appended
@@ -249,6 +252,13 @@ class ButtonTab(GrampsTab):
self.tooltips.set_tip(self.share_btn, self._MSG['share']) self.tooltips.set_tip(self.share_btn, self._MSG['share'])
else: else:
self.share_btn = None self.share_btn = None
if prop_button:
self.prop_btn = SimpleButton(gtk.STOCK_PROPERTIES,
self.prop_button_clicked)
self.tooltips.set_tip(self.prop_btn, self._MSG['prop'])
else:
self.prop_btn = None
vbox = gtk.VBox() vbox = gtk.VBox()
vbox.set_spacing(6) vbox.set_spacing(6)
@@ -257,6 +267,8 @@ class ButtonTab(GrampsTab):
vbox.pack_start(self.share_btn, False) vbox.pack_start(self.share_btn, False)
vbox.pack_start(self.edit_btn, False) vbox.pack_start(self.edit_btn, False)
vbox.pack_start(self.del_btn, False) vbox.pack_start(self.del_btn, False)
if prop_button:
vbox.pack_start(self.prop_btn, False)
vbox.show_all() vbox.show_all()
self.pack_start(vbox, False) self.pack_start(vbox, False)
@@ -282,6 +294,13 @@ class ButtonTab(GrampsTab):
""" """
print "Uncaught Share clicked" print "Uncaught Share clicked"
def prop_button_clicked(self, obj):
"""
Function called with the Add button is clicked. This function
should be overridden by the derived class.
"""
print "Uncaught Properties clicked"
def del_button_clicked(self, obj): def del_button_clicked(self, obj):
""" """
Function called with the Delete button is clicked. This function Function called with the Delete button is clicked. This function
@@ -306,9 +325,13 @@ class ButtonTab(GrampsTab):
if self.get_selected(): if self.get_selected():
self.edit_btn.set_sensitive(True) self.edit_btn.set_sensitive(True)
self.del_btn.set_sensitive(True) self.del_btn.set_sensitive(True)
if self.prop_btn:
self.prop_btn.set_sensitive(True)
else: else:
self.edit_btn.set_sensitive(False) self.edit_btn.set_sensitive(False)
self.del_btn.set_sensitive(False) self.del_btn.set_sensitive(False)
if self.prop_btn:
self.prop_btn.set_sensitive(False)
class EmbeddedList(ButtonTab): class EmbeddedList(ButtonTab):
""" """
@@ -321,12 +344,15 @@ class EmbeddedList(ButtonTab):
_DND_TYPE = None _DND_TYPE = None
_DND_EXTRA = None _DND_EXTRA = None
def __init__(self, dbstate, uistate, track, name, build_model,share=False): def __init__(self, dbstate, uistate, track, name, build_model,
share=False, properties=False):
""" """
Creates a new list, using the passed build_model to Creates a new list, using the passed build_model to
populate the list. populate the list.
""" """
ButtonTab.__init__(self, dbstate, uistate, track, name, share) ButtonTab.__init__(self, dbstate, uistate, track, name, share,
properties)
self.changed = False self.changed = False
self.build_model = build_model self.build_model = build_model
@@ -369,6 +395,10 @@ class EmbeddedList(ButtonTab):
(True, gtk.STOCK_EDIT, self.edit_button_clicked), (True, gtk.STOCK_EDIT, self.edit_button_clicked),
(True, gtk.STOCK_REMOVE, self.del_button_clicked), (True, gtk.STOCK_REMOVE, self.del_button_clicked),
] ]
if self.prop_btn:
itemlist.append((True, gtk.STOCK_PROPERTIES,
self.prop_button_clicked))
menu = gtk.Menu() menu = gtk.Menu()
for (image, title, func) in itemlist: for (image, title, func) in itemlist:
@@ -1883,7 +1913,7 @@ class ChildModel(gtk.ListStore):
child.get_handle(), child.get_handle(),
NameDisplay.displayer.sort_string(child.primary_name), NameDisplay.displayer.sort_string(child.primary_name),
self.column_birth_sort(child), self.column_birth_sort(child),
self.column_death_sort(child), self.column_death_sort(child),
]) ])
index += 1 index += 1

View File

@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
__init__.py\ __init__.py\
_EditAddress.py \ _EditAddress.py \
_EditAttribute.py \ _EditAttribute.py \
_EditChildRef.py \
_EditEvent.py \ _EditEvent.py \
_EditEventRef.py \ _EditEventRef.py \
_EditFamily.py \ _EditFamily.py \

View File

@@ -0,0 +1,134 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 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: _EditChildRef.py 6282 2006-04-06 22:02:46Z rshura $
"""
The EditChildRef module provides the EditChildRef class. This provides a
mechanism for the user to edit address information.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk.glade
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
import const
from _EditSecondary import EditSecondary
from DisplayTabs import *
from GrampsWidgets import *
#-------------------------------------------------------------------------
#
# EditChildRef class
#
#-------------------------------------------------------------------------
class EditChildRef(EditSecondary):
"""
Displays a dialog that allows the user to edit an address.
"""
def __init__(self, dbstate, uistate, track, childref, callback):
"""
Displays the dialog box.
parent - The class that called the ChildRef editor.
addr - The address that is to be edited
"""
EditSecondary.__init__(self, dbstate, uistate, track,
childref, callback)
def _local_init(self):
self.top = gtk.glade.XML(const.gladeFile, "cref_edit","gramps")
self.define_top_level(self.top.get_widget("cref_edit"),
self.top.get_widget("title"),
_('Child Reference Editor'))
def _setup_fields(self):
self.frel = MonitoredDataType(
self.top.get_widget('frel'),
self.obj.set_father_relation,
self.obj.get_father_relation,
)
self.mrel = MonitoredDataType(
self.top.get_widget('mrel'),
self.obj.set_mother_relation,
self.obj.get_mother_relation,
)
self.priv = PrivacyButton(
self.top.get_widget("private"),
self.obj,
self.db.readonly)
def _connect_signals(self):
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)
def _create_tabbed_pages(self):
"""
Creates the notebook tabs and inserts them into the main
window.
"""
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()))
notebook.show_all()
self.top.get_widget('vbox').pack_start(notebook,True)
def build_menu_names(self,obj):
return (_('ChildRef'),_('ChildRef Editor'))
def save(self,*obj):
"""
Called when the OK button is pressed. Gets data from the
form and updates the ChildRef data structure.
"""
if self.callback:
self.callback(self.obj)
self.close_window(obj)

View File

@@ -109,7 +109,7 @@ class ChildEmbedList(EmbeddedList):
""" """
self.family = family self.family = family
EmbeddedList.__init__(self, dbstate, uistate, track, EmbeddedList.__init__(self, dbstate, uistate, track,
_('Children'), ChildModel, True) _('Children'), ChildModel, True, True)
def find_index(self,obj): def find_index(self,obj):
""" """
@@ -155,20 +155,9 @@ class ChildEmbedList(EmbeddedList):
if not pair[0]: if not pair[0]:
continue continue
name = self._column_names[pair[1]][0] name = self._column_names[pair[1]][0]
if pair[1] == 4: render = gtk.CellRendererText()
render = TypeCellRenderer(RelLib.ChildRefType().get_map()) column = gtk.TreeViewColumn(name, render, text=pair[1])
render.connect('edited',self.frel_edited) column.set_min_width(50)
column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(100)
elif pair[1] == 5:
render = TypeCellRenderer(RelLib.ChildRefType().get_map())
render.connect('edited',self.mrel_edited)
column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(100)
else:
render = gtk.CellRendererText()
column = gtk.TreeViewColumn(name, render, text=pair[1])
column.set_min_width(50)
column.set_resizable(True) column.set_resizable(True)
column.set_sort_column_id(self._column_names[pair[1]][1]) column.set_sort_column_id(self._column_names[pair[1]][1])
@@ -184,20 +173,6 @@ class ChildEmbedList(EmbeddedList):
""" """
return len(self.family.get_child_ref_list()) == 0 return len(self.family.get_child_ref_list()) == 0
def mrel_edited(self, renderer, index, value):
row = int(index)
ref = self.family.get_child_ref_list()[row]
ref.set_mother_relation(RelLib.ChildRefType(value))
node = self.model.get_iter((row,))
self.model.set_value(node, 5, value)
def frel_edited(self, renderer, index, value):
row = int(index)
ref = self.family.get_child_ref_list()[row]
ref.set_father_relation(RelLib.ChildRefType(value))
node = self.model.get_iter((row,))
self.model.set_value(node, 4, value)
def get_data(self): def get_data(self):
""" """
Normally, get_data returns a list. However, we return family Normally, get_data returns a list. However, we return family
@@ -230,6 +205,20 @@ class ChildEmbedList(EmbeddedList):
self.family.add_child_ref(ref) self.family.add_child_ref(ref)
self.rebuild() self.rebuild()
def prop_button_clicked(self,obj):
handle = self.get_selected()
if handle:
from Editors import EditChildRef
for ref in self.family.get_child_ref_list():
if ref.ref == handle:
EditChildRef(self.dbstate, self.uistate, self.track,
ref, self.child_ref_edited)
break
def child_ref_edited(self, person):
self.rebuild()
def share_button_clicked(self,obj): def share_button_clicked(self,obj):
from SelectPerson import SelectPerson from SelectPerson import SelectPerson

View File

@@ -36,4 +36,5 @@ from _EditSource import *
from _EditSourceRef import * from _EditSourceRef import *
from _EditUrl import * from _EditUrl import *
from _EditPersonRef import * from _EditPersonRef import *
from _EditChildRef import *

View File

@@ -37,6 +37,7 @@ import AutoComp
import DateHandler import DateHandler
import DateEdit import DateEdit
import const import const
from RelLib import ChildRefType
_lock_path = os.path.join(const.image_dir, 'stock_lock.png') _lock_path = os.path.join(const.image_dir, 'stock_lock.png')
_lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png') _lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png')
@@ -372,9 +373,9 @@ class MonitoredDataType:
def fix_value(self, value): def fix_value(self, value):
if value[0] == self.get_val().get_custom(): if value[0] == self.get_val().get_custom():
return value return ChildRefType(value)
else: else:
return (value[0],'') return ChildRefType((value[0],''))
def update(self): def update(self):
if self.get_val(): if self.get_val():

View File

@@ -16660,4 +16660,265 @@ You should select parents before adding any new information. If you select paren
</child> </child>
</widget> </widget>
<widget class="GtkDialog" id="cref_edit">
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">600</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<signal name="delete_event" handler="on_addr_edit_delete_event" last_modification_time="Fri, 20 Feb 2004 01:16:24 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox125">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="hbuttonbox45">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_cancel_addr_clicked" object="addr_edit" last_modification_time="Fri, 20 Feb 2004 01:16:51 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Accept changes and close window</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_ok_addr_clicked" last_modification_time="Fri, 20 Feb 2004 01:17:10 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="help">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-11</property>
<signal name="clicked" handler="on_help_addr_clicked" last_modification_time="Tue, 18 Nov 2003 04:04:45 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label651">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">10</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table74">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">7</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<widget class="GtkLabel" id="label652">
<property name="visible">True</property>
<property name="label" translatable="yes">Relationship to _Father:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label653">
<property name="visible">True</property>
<property name="label" translatable="yes">Relationship to _Mother:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkToggleButton" id="private">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<child>
<widget class="GtkImage" id="image2696">
<property name="visible">True</property>
<property name="icon_size">1</property>
<property name="icon_name">gtk-dialog-authentication</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">6</property>
<property name="right_attach">7</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBoxEntry" id="frel">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="has_frame">True</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">6</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkComboBoxEntry" id="mrel">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="has_frame">True</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">6</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>