diff --git a/ChangeLog b/ChangeLog index f9c4fe79c..53edd2b30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ 2006-04-18 Don Allingham + * 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/GrampsWidgets.py: fix the type return value diff --git a/src/DisplayTabs.py b/src/DisplayTabs.py index 27272f018..58aa0d7a9 100644 --- a/src/DisplayTabs.py +++ b/src/DisplayTabs.py @@ -121,6 +121,7 @@ class GrampsTab(gtk.HBox): # build the interface self.share_btn = None + self.prop_btn = None self.build_interface() def get_selected(self): @@ -207,9 +208,11 @@ class ButtonTab(GrampsTab): 'del' : _('Remove'), 'edit' : _('Edit'), '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 @param dbstate: The database state. Contains a reference to @@ -228,9 +231,9 @@ class ButtonTab(GrampsTab): """ GrampsTab.__init__(self,dbstate, uistate, track, name) 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, 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']) else: 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.set_spacing(6) @@ -257,6 +267,8 @@ class ButtonTab(GrampsTab): vbox.pack_start(self.share_btn, False) vbox.pack_start(self.edit_btn, False) vbox.pack_start(self.del_btn, False) + if prop_button: + vbox.pack_start(self.prop_btn, False) vbox.show_all() self.pack_start(vbox, False) @@ -282,6 +294,13 @@ class ButtonTab(GrampsTab): """ 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): """ Function called with the Delete button is clicked. This function @@ -306,9 +325,13 @@ class ButtonTab(GrampsTab): if self.get_selected(): self.edit_btn.set_sensitive(True) self.del_btn.set_sensitive(True) + if self.prop_btn: + self.prop_btn.set_sensitive(True) else: self.edit_btn.set_sensitive(False) self.del_btn.set_sensitive(False) + if self.prop_btn: + self.prop_btn.set_sensitive(False) class EmbeddedList(ButtonTab): """ @@ -321,12 +344,15 @@ class EmbeddedList(ButtonTab): _DND_TYPE = 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 populate the list. """ - ButtonTab.__init__(self, dbstate, uistate, track, name, share) + ButtonTab.__init__(self, dbstate, uistate, track, name, share, + properties) + self.changed = False self.build_model = build_model @@ -369,6 +395,10 @@ class EmbeddedList(ButtonTab): (True, gtk.STOCK_EDIT, self.edit_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() for (image, title, func) in itemlist: @@ -1883,7 +1913,7 @@ class ChildModel(gtk.ListStore): child.get_handle(), NameDisplay.displayer.sort_string(child.primary_name), self.column_birth_sort(child), - self.column_death_sort(child), + self.column_death_sort(child), ]) index += 1 diff --git a/src/Editors/Makefile.am b/src/Editors/Makefile.am index c700466d7..a9968edcb 100644 --- a/src/Editors/Makefile.am +++ b/src/Editors/Makefile.am @@ -9,6 +9,7 @@ pkgdata_PYTHON = \ __init__.py\ _EditAddress.py \ _EditAttribute.py \ + _EditChildRef.py \ _EditEvent.py \ _EditEventRef.py \ _EditFamily.py \ diff --git a/src/Editors/_EditChildRef.py b/src/Editors/_EditChildRef.py new file mode 100644 index 000000000..1092d43be --- /dev/null +++ b/src/Editors/_EditChildRef.py @@ -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) + diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index b4bb84c7f..e25a2e9a1 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -109,7 +109,7 @@ class ChildEmbedList(EmbeddedList): """ self.family = family EmbeddedList.__init__(self, dbstate, uistate, track, - _('Children'), ChildModel, True) + _('Children'), ChildModel, True, True) def find_index(self,obj): """ @@ -155,20 +155,9 @@ class ChildEmbedList(EmbeddedList): if not pair[0]: continue name = self._column_names[pair[1]][0] - if pair[1] == 4: - render = TypeCellRenderer(RelLib.ChildRefType().get_map()) - render.connect('edited',self.frel_edited) - 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) + render = gtk.CellRendererText() + column = gtk.TreeViewColumn(name, render, text=pair[1]) + column.set_min_width(50) column.set_resizable(True) 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 - 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): """ Normally, get_data returns a list. However, we return family @@ -230,6 +205,20 @@ class ChildEmbedList(EmbeddedList): self.family.add_child_ref(ref) 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): from SelectPerson import SelectPerson diff --git a/src/Editors/__init__.py b/src/Editors/__init__.py index 832dfab70..9f344fd96 100644 --- a/src/Editors/__init__.py +++ b/src/Editors/__init__.py @@ -36,4 +36,5 @@ from _EditSource import * from _EditSourceRef import * from _EditUrl import * from _EditPersonRef import * +from _EditChildRef import * diff --git a/src/GrampsWidgets.py b/src/GrampsWidgets.py index ecdd61ff9..95a467835 100644 --- a/src/GrampsWidgets.py +++ b/src/GrampsWidgets.py @@ -37,6 +37,7 @@ import AutoComp import DateHandler import DateEdit import const +from RelLib import ChildRefType _lock_path = os.path.join(const.image_dir, 'stock_lock.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): if value[0] == self.get_val().get_custom(): - return value + return ChildRefType(value) else: - return (value[0],'') + return ChildRefType((value[0],'')) def update(self): if self.get_val(): diff --git a/src/glade/gramps.glade b/src/glade/gramps.glade index 31a9c8672..cd0743e2f 100644 --- a/src/glade/gramps.glade +++ b/src/glade/gramps.glade @@ -16660,4 +16660,265 @@ You should select parents before adding any new information. If you select paren + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 600 + 400 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + False + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + + True + Accept changes and close window + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + + False + True + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 10 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 12 + True + 2 + 7 + False + 6 + 12 + + + + True + Relationship to _Father: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Relationship to _Mother: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + GTK_RELIEF_NONE + True + False + False + + + + True + 1 + gtk-dialog-authentication + 0.5 + 0.5 + 0 + 0 + + + + + 6 + 7 + 1 + 2 + + + + + + + + True + False + True + True + + + 1 + 6 + 0 + 1 + fill + + + + + + True + False + True + True + + + 1 + 6 + 1 + 2 + fill + fill + + + + + 0 + False + True + + + + + 0 + True + True + + + + + +