2007-08-25 10:33:23 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2008-01-17 03:12:05 +05:30
|
|
|
# Copyright (C) 2007-2008 Donald N. Allingham
|
2008-07-21 00:03:04 +05:30
|
|
|
# Copyright (C) 2008 Gary Burton
|
2008-09-04 17:16:43 +05:30
|
|
|
# Copyright (C) 2008 Robert Cheramy <robert@cheramy.net>
|
2007-08-25 10:33:23 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2008-01-17 03:12:05 +05:30
|
|
|
"""Provide the common export options for Exporters."""
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-08-25 10:33:23 +05:30
|
|
|
import gtk
|
|
|
|
from gettext import gettext as _
|
2008-01-22 03:33:43 +05:30
|
|
|
import gobject
|
2007-08-25 10:33:23 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-08-25 21:04:13 +05:30
|
|
|
import Config
|
|
|
|
|
2007-08-25 10:33:23 +05:30
|
|
|
from BasicUtils import name_displayer
|
2007-08-31 08:48:38 +05:30
|
|
|
from Filters import GenericFilter, Rules
|
2007-08-25 10:33:23 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2007-09-09 10:54:15 +05:30
|
|
|
# WriterOptionBox
|
2007-08-25 10:33:23 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class WriterOptionBox(object):
|
2007-08-25 10:33:23 +05:30
|
|
|
"""
|
|
|
|
Create a VBox with the option widgets and define methods to retrieve
|
2008-01-17 03:12:05 +05:30
|
|
|
the options.
|
|
|
|
|
2007-08-25 10:33:23 +05:30
|
|
|
"""
|
|
|
|
def __init__(self, person):
|
|
|
|
self.person = person
|
2007-09-09 10:54:15 +05:30
|
|
|
self.private = 0
|
|
|
|
self.restrict = 0
|
2008-09-04 17:16:43 +05:30
|
|
|
self.unlinked = 0
|
2007-09-09 10:54:15 +05:30
|
|
|
self.cfilter = None
|
2008-09-04 17:16:43 +05:30
|
|
|
self.nfilter = None
|
2007-09-09 10:54:15 +05:30
|
|
|
self.restrict_check = None
|
|
|
|
self.private_check = None
|
2008-07-21 00:03:04 +05:30
|
|
|
self.unlinked_check = None
|
2007-09-09 10:54:15 +05:30
|
|
|
self.filter_obj = None
|
2008-09-04 17:16:43 +05:30
|
|
|
self.filter_note = None
|
2007-08-25 10:33:23 +05:30
|
|
|
|
|
|
|
def get_option_box(self):
|
2008-01-17 03:12:05 +05:30
|
|
|
"""Build up a gtk.Table that contains the standard options."""
|
2008-09-04 17:16:43 +05:30
|
|
|
table = gtk.Table(5, 2)
|
2008-02-04 03:03:41 +05:30
|
|
|
|
2007-08-25 21:04:13 +05:30
|
|
|
self.filter_obj = gtk.ComboBox()
|
2008-09-04 17:16:43 +05:30
|
|
|
label = gtk.Label(_('_Person Filter'))
|
2008-02-04 03:03:41 +05:30
|
|
|
label.set_use_underline(True)
|
|
|
|
label.set_mnemonic_widget(self.filter_obj)
|
2008-09-04 17:16:43 +05:30
|
|
|
|
|
|
|
# Objects for choosing a Note filter
|
|
|
|
self.filter_note = gtk.ComboBox()
|
|
|
|
label_note = gtk.Label(_('_Note Filter'))
|
|
|
|
label_note.set_use_underline(True)
|
|
|
|
label_note.set_mnemonic_widget(self.filter_note)
|
2008-02-04 03:03:41 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
self.private_check = gtk.CheckButton(
|
2008-01-17 03:12:05 +05:30
|
|
|
_('_Do not include records marked private'))
|
2007-09-09 10:54:15 +05:30
|
|
|
self.restrict_check = gtk.CheckButton(
|
2008-01-17 03:12:05 +05:30
|
|
|
_('_Restrict data on living people'))
|
2008-07-21 00:03:04 +05:30
|
|
|
self.unlinked_check = gtk.CheckButton(
|
|
|
|
_('_Do not include unlinked records'))
|
2007-08-25 10:33:23 +05:30
|
|
|
|
2007-08-25 21:04:13 +05:30
|
|
|
self.private_check.set_active(Config.get(Config.EXPORT_NO_PRIVATE))
|
|
|
|
self.restrict_check.set_active(Config.get(Config.EXPORT_RESTRICT))
|
2008-07-21 00:03:04 +05:30
|
|
|
self.unlinked_check.set_active(Config.get(Config.EXPORT_NO_UNLINKED))
|
2007-08-25 21:04:13 +05:30
|
|
|
|
2007-08-25 10:33:23 +05:30
|
|
|
table.set_border_width(12)
|
|
|
|
table.set_row_spacings(6)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
table.attach(label, 0, 1, 0, 1, xoptions=0, yoptions=0)
|
|
|
|
table.attach(self.filter_obj, 1, 2, 0, 1, yoptions=0)
|
2008-09-04 17:16:43 +05:30
|
|
|
table.attach(label_note, 0, 1, 1, 2, xoptions =0, yoptions=0)
|
|
|
|
table.attach(self.filter_note, 1, 2, 1, 2, yoptions=0)
|
|
|
|
table.attach(self.private_check, 1, 2, 2, 3, yoptions=0)
|
|
|
|
table.attach(self.restrict_check, 1, 2, 3, 4, yoptions=0)
|
|
|
|
table.attach(self.unlinked_check, 1, 2, 4, 5, yoptions=0)
|
2007-08-25 10:33:23 +05:30
|
|
|
|
2008-09-04 17:16:43 +05:30
|
|
|
# Populate the Person Filter
|
2007-09-09 10:54:15 +05:30
|
|
|
entire_db = GenericFilter()
|
|
|
|
entire_db.set_name(_("Entire Database"))
|
|
|
|
the_filters = [entire_db]
|
2007-08-25 10:33:23 +05:30
|
|
|
|
|
|
|
if self.person:
|
2007-09-09 10:54:15 +05:30
|
|
|
the_filters += self.__define_person_filters()
|
2007-08-25 10:33:23 +05:30
|
|
|
|
|
|
|
from Filters import CustomFilters
|
|
|
|
the_filters.extend(CustomFilters.get_filters('Person'))
|
2007-08-25 21:04:13 +05:30
|
|
|
|
2008-01-22 03:33:43 +05:30
|
|
|
model = gtk.ListStore(gobject.TYPE_STRING, object)
|
2007-09-09 10:54:15 +05:30
|
|
|
for item in the_filters:
|
|
|
|
model.append(row=[item.get_name(), item])
|
2007-08-25 21:04:13 +05:30
|
|
|
|
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
self.filter_obj.pack_start(cell, True)
|
|
|
|
self.filter_obj.add_attribute(cell, 'text', 0)
|
|
|
|
self.filter_obj.set_model(model)
|
|
|
|
self.filter_obj.set_active(0)
|
2008-09-04 17:16:43 +05:30
|
|
|
|
|
|
|
# Populate the Notes Filter
|
|
|
|
notes_filters = [entire_db]
|
|
|
|
|
|
|
|
notes_filters.extend(CustomFilters.get_filters('Note'))
|
|
|
|
notes_model = gtk.ListStore(gobject.TYPE_STRING, object)
|
|
|
|
for item in notes_filters:
|
|
|
|
notes_model.append(row=[item.get_name(), item])
|
|
|
|
notes_cell = gtk.CellRendererText()
|
|
|
|
self.filter_note.pack_start(notes_cell, True)
|
|
|
|
self.filter_note.add_attribute(notes_cell, 'text', 0)
|
|
|
|
self.filter_note.set_model(notes_model)
|
|
|
|
self.filter_note.set_active(0)
|
2007-08-25 10:33:23 +05:30
|
|
|
|
|
|
|
table.show()
|
|
|
|
return table
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
def __define_person_filters(self):
|
2008-01-17 03:12:05 +05:30
|
|
|
"""Add person filters if the active person is defined."""
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2008-12-18 03:09:37 +05:30
|
|
|
name = name_displayer.display(self.person)
|
|
|
|
gramps_id = self.person.get_gramps_id()
|
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
des = GenericFilter()
|
2008-12-18 03:09:37 +05:30
|
|
|
des.set_name(_("Descendants of %s") % name)
|
|
|
|
des.add_rule(Rules.Person.IsDescendantOf([gramps_id, 1]))
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2008-10-07 22:05:51 +05:30
|
|
|
df = GenericFilter()
|
2008-12-18 03:09:37 +05:30
|
|
|
df.set_name(_("Descendant Families of %s") % name)
|
|
|
|
df.add_rule(Rules.Person.IsDescendantFamilyOf([gramps_id, 1]))
|
2008-10-07 22:05:51 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
ans = GenericFilter()
|
2008-12-18 03:09:37 +05:30
|
|
|
ans.set_name(_("Ancestors of %s") % name)
|
|
|
|
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id, 1]))
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
com = GenericFilter()
|
2008-12-18 03:09:37 +05:30
|
|
|
com.set_name(_("People with common ancestor with %s") % name)
|
|
|
|
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
|
|
|
|
|
2008-10-07 22:05:51 +05:30
|
|
|
return [des, df, ans, com]
|
2007-09-09 10:54:15 +05:30
|
|
|
|
2007-08-25 10:33:23 +05:30
|
|
|
def parse_options(self):
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
2008-01-17 03:12:05 +05:30
|
|
|
Extract the common values from the GTK widgets.
|
|
|
|
|
|
|
|
After this function is called, the following variables are defined:
|
2007-09-09 10:54:15 +05:30
|
|
|
|
|
|
|
private = privacy requested
|
|
|
|
restrict = restrict information on living peoplel
|
|
|
|
cfitler = return the GenericFilter selected
|
2008-09-04 17:16:43 +05:30
|
|
|
nfilter = return the NoteFilter selected
|
|
|
|
unlinked = restrict unlinked records
|
2007-08-25 10:33:23 +05:30
|
|
|
|
2007-09-09 10:54:15 +05:30
|
|
|
"""
|
2007-08-25 10:33:23 +05:30
|
|
|
self.restrict = self.restrict_check.get_active()
|
|
|
|
self.private = self.private_check.get_active()
|
2008-07-21 00:03:04 +05:30
|
|
|
self.unlinked = self.unlinked_check.get_active()
|
2007-08-25 21:04:13 +05:30
|
|
|
|
|
|
|
Config.set(Config.EXPORT_NO_PRIVATE, self.private)
|
|
|
|
Config.set(Config.EXPORT_RESTRICT, self.restrict)
|
2008-07-21 00:03:04 +05:30
|
|
|
Config.set(Config.EXPORT_NO_UNLINKED, self.unlinked)
|
2007-08-25 21:04:13 +05:30
|
|
|
Config.sync()
|
|
|
|
|
|
|
|
model = self.filter_obj.get_model()
|
|
|
|
node = self.filter_obj.get_active_iter()
|
|
|
|
self.cfilter = model[node][1]
|
2008-09-04 17:16:43 +05:30
|
|
|
|
|
|
|
model = self.filter_note.get_model()
|
|
|
|
node = self.filter_note.get_active_iter()
|
|
|
|
self.nfilter = model[node][1]
|
|
|
|
|
2007-08-25 10:33:23 +05:30
|
|
|
|