2006-10-31 Don Allingham <don@gramps-project.org>

* src/Reorder.py: Allow for reordering of relationships
	* src/DataViews/_RelationView.py: add reorder support
	* src/glade/gramps.glade: reorder dialog
	* src/Makefile.am: install Reorder.py



svn: r7525
This commit is contained in:
Don Allingham 2006-10-31 17:36:38 +00:00
parent 2df2d25b5a
commit 9ce6369d09
5 changed files with 559 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2006-10-31 Don Allingham <don@gramps-project.org>
* src/Reorder.py: Allow for reordering of relationships
* src/DataViews/_RelationView.py: add reorder support
* src/glade/gramps.glade: reorder dialog
* src/Makefile.am: install Reorder.py
2006-10-31 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_WriteGedcom.py (write_families): Properly write
custom attr type.

View File

@ -1,3 +1,24 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-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$
#-------------------------------------------------------------------------
#
# Python modules
@ -206,6 +227,7 @@ class RelationshipView(PageView.PersonNavView):
</placeholder>
</menu>
<menu action="EditMenu">
<menuitem action="ChangeOrder"/>
<menuitem action="FilterEdit"/>
</menu>
<menu action="BookMenu">
@ -225,6 +247,9 @@ class RelationshipView(PageView.PersonNavView):
<toolitem action="Forward"/>
<toolitem action="HomePerson"/>
</placeholder>
<placeholder name="CommonEdit">
<toolitem action="ChangeOrder"/>
</placeholder>
</toolbar>
<popup name="Popup">
<menuitem action="Back"/>
@ -237,6 +262,10 @@ class RelationshipView(PageView.PersonNavView):
def define_actions(self):
PageView.PersonNavView.define_actions(self)
self.add_action('ChangeOrder', gtk.STOCK_SORT_ASCENDING, _("_Reorder"),
tip=_("Reorder the relationships"),
callback=self.reorder)
self.add_toggle_action('Details', None, _('Show details'),
None, None, self.details_toggle,
self.show_details)
@ -878,3 +907,13 @@ class RelationshipView(PageView.PersonNavView):
def change_to(self, obj, handle):
self.dbstate.change_active_handle(handle)
def reorder(self,obj):
if self.dbstate.active:
try:
import Reorder
Reorder.Reorder(self.dbstate, self.uistate, [],
self.dbstate.active.handle)
except Errors.WindowActiveError:
pass

View File

@ -61,6 +61,7 @@ gdir_PYTHON = \
QuestionDialog.py\
RecentFiles.py\
Relationship.py\
Reorder.py\
ScratchPad.py\
Sort.py\
soundex.py\

167
src/Reorder.py Normal file
View File

@ -0,0 +1,167 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-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: _SourceView.py 7138 2006-08-06 06:26:10Z rshura $
import const
import gtk
import NameDisplay
import ListModel
import ManagedWindow
_parent_titles = [(_('Father'),-1,200),(_('Mother'),-1,200),('',-1,0)]
_family_titles = [(_('Spouse'),-1,200),(_('Relationship'),-1,200),('',-1,0)]
class Reorder(ManagedWindow.ManagedWindow):
def __init__(self, state, uistate, track, handle):
xml = gtk.glade.XML(const.gladeFile, "reorder", "gramps")
top = xml.get_widget('reorder')
self.dbstate = state
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
self.person = self.dbstate.db.get_person_from_handle(handle)
self.set_window(top, None, _("Reorder Relationships"))
self.ptree = xml.get_widget('ptree')
self.pmodel = ListModel.ListModel(self.ptree,_parent_titles)
self.ftree = xml.get_widget('ftree')
self.fmodel = ListModel.ListModel(self.ftree,_family_titles)
xml.get_widget('ok').connect('clicked', self.ok_clicked)
xml.get_widget('cancel').connect('clicked', self.cancel_clicked)
xml.get_widget('fup').connect('clicked', self.fup_clicked)
xml.get_widget('fdown').connect('clicked', self.fdown_clicked)
xml.get_widget('pup').connect('clicked', self.pup_clicked)
xml.get_widget('pdown').connect('clicked', self.pdown_clicked)
self.parent_list = self.person.get_parent_family_handle_list()
self.family_list = self.person.get_family_handle_list()
self.fill_data()
self.show()
def fill_data(self):
self.fill_parents()
self.fill_family()
def fill_parents(self):
for handle in self.parent_list:
family = self.dbstate.db.get_family_from_handle(handle)
fhandle = family.get_father_handle()
mhandle = family.get_mother_handle()
fname = ""
if fhandle:
father = self.dbstate.db.get_person_from_handle(fhandle)
if father:
fname = NameDisplay.displayer.display(father)
mname = ""
if mhandle:
mother = self.dbstate.db.get_person_from_handle(mhandle)
if mother:
mname = NameDisplay.displayer.display(mother)
self.pmodel.add([fname, mname, handle])
def fill_family(self):
for handle in self.family_list:
family = self.dbstate.db.get_family_from_handle(handle)
fhandle = family.get_father_handle()
mhandle = family.get_mother_handle()
name = ""
if fhandle and fhandle != self.person.handle:
spouse = self.dbstate.db.get_person_from_handle(fhandle)
if spouse:
name = NameDisplay.displayer.display(spouse)
elif mhandle:
spouse = self.dbstate.db.get_person_from_handle(mhandle)
if spouse:
name = NameDisplay.displayer.display(spouse)
reltype = str(family.get_relationship())
self.fmodel.add([name, reltype, handle])
def cancel_clicked(self, obj):
self.close()
def ok_clicked(self, obj):
trans = self.dbstate.db.transaction_begin()
self.dbstate.db.commit_person(self.person, trans)
name = NameDisplay.displayer.display(self.person)
msg = _("Reorder Relationships: %s") % name
self.dbstate.db.transaction_commit(trans, msg)
self.close()
def pup_clicked(self,obj):
"""Moves the current selection up one row"""
row = self.pmodel.get_selected_row()
if not row or row == -1:
return
store,the_iter = self.pmodel.get_selected()
data = self.pmodel.get_data(the_iter,xrange(3))
self.pmodel.remove(the_iter)
self.pmodel.insert(row-1,data,None,1)
handle = self.parent_list.pop(row)
self.parent_list.insert(row-1,handle)
def pdown_clicked(self, obj):
row = self.pmodel.get_selected_row()
if row + 1 >= self.pmodel.count or row == -1:
return
store,the_iter = self.pmodel.get_selected()
data = self.pmodel.get_data(the_iter,xrange(3))
self.pmodel.remove(the_iter)
self.pmodel.insert(row+1,data,None,1)
handle = self.parent_list.pop(row)
self.parent_list.insert(row+1,handle)
def fup_clicked(self, obj):
row = self.fmodel.get_selected_row()
if not row or row == -1:
return
store,the_iter = self.fmodel.get_selected()
data = self.fmodel.get_data(the_iter,xrange(3))
self.fmodel.remove(the_iter)
self.fmodel.insert(row-1,data,None,1)
handle = self.family_list.pop(row)
self.family_list.insert(row-1,handle)
def fdown_clicked(self, obj):
row = self.fmodel.get_selected_row()
if row + 1 >= self.fmodel.count or row == -1:
return
store,the_iter = self.fmodel.get_selected()
data = self.fmodel.get_data(the_iter,xrange(3))
self.fmodel.remove(the_iter)
self.fmodel.insert(row+1,data,None,1)
handle = self.family_list.pop(row)
self.family_list.insert(row+1,handle)

View File

@ -15313,4 +15313,350 @@ Very High</property>
</child>
</widget>
<widget class="GtkDialog" id="reorder">
<property name="border_width">12</property>
<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">500</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">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox24">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area24">
<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>
</widget>
</child>
<child>
<widget class="GtkButton" id="ok">
<property name="visible">True</property>
<property name="can_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>
</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="GtkTable" id="table78">
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="label665">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Parent relationships&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</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">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox129">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="pup">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2714">
<property name="visible">True</property>
<property name="stock">gtk-go-up</property>
<property name="icon_size">4</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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="pdown">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2715">
<property name="visible">True</property>
<property name="stock">gtk-go-down</property>
<property name="icon_size">4</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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</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>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow86">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="ptree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label666">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Family relationships&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</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">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow87">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="ftree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox130">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="fup">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2716">
<property name="visible">True</property>
<property name="stock">gtk-go-up</property>
<property name="icon_size">4</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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="fdown">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2717">
<property name="visible">True</property>
<property name="stock">gtk-go-down</property>
<property name="icon_size">4</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="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</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">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>