diff --git a/ChangeLog b/ChangeLog index a1fe944b6..d8d6dde9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-08-24 Don Allingham + * src/ExportAssistant.py: fix grammar + * src/ExportOptions.py: place for common options, build option dialog for + exporters + * src/GrampsDbUtils/_WriteGedcom.py: handle restrict, private, and new + option dialog + * src/GrampsDbUtils/_PrivateProxyDb.py: add get_researcher() + * src/GrampsDbUtils/exportgedcom.glade: removed + 2007-08-25 Benny Malengier * src/plugins/rel_de.py : nomeata, bug #1183 diff --git a/po/POTFILES.in b/po/POTFILES.in index 549eebf96..61657750f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -20,6 +20,7 @@ src/DdTargets.py src/DisplayState.py src/Errors.py src/ExportAssistant.py +src/ExportOptions.py src/FontScale.py src/GrampsCfg.py src/GrampsDisplay.py diff --git a/src/ExportAssistant.py b/src/ExportAssistant.py index 2d1206534..9c0332ed7 100644 --- a/src/ExportAssistant.py +++ b/src/ExportAssistant.py @@ -199,7 +199,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : self.append_page(page) self.set_page_header_image(page, self.logo) - self.set_page_title(page, _('Choose the format you want to export to')) + self.set_page_title(page, _('Choose the output format')) self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT) diff --git a/src/ExportOptions.py b/src/ExportOptions.py new file mode 100644 index 000000000..c3f9d5c08 --- /dev/null +++ b/src/ExportOptions.py @@ -0,0 +1,123 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007 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 +# +import gtk +from gettext import gettext as _ + +import RelLib +from BasicUtils import name_displayer +from Filters import GenericFilter, Rules, build_filter_menu + +def restrict_living(person): + newperson = RelLib.Person() + name = RelLib.Name() + + # copy name info + source = person.get_primary_name() + name.first_name = _(u'Living') + name.surname = source.surname + name.title = source.title + name.type = source.type + name.prefix = source.prefix + name.patronymic = source.patronymic + name.group_as = source.group_as + name.sort_as = source.sort_as + name.display_as = source.display_as + name.call = "" + newperson.set_primary_name(name) + + newperson.parent_family_list = person.parent_family_list[:] + newperson.family_list = person.family_list[:] + newperson.gender = person.gender + + return newperson + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +class WriterOptionBox: + """ + Create a VBox with the option widgets and define methods to retrieve + the options. + """ + def __init__(self, person): + self.person = person + + def get_option_box(self): + self.restrict = True + + table = gtk.Table(3, 2) + label = gtk.Label('Filter') + self.filter_obj = gtk.OptionMenu() + self.private_check = gtk.CheckButton(_('Do not include records marked private')) + self.restrict_check = gtk.CheckButton(_('Restrict data on living people')) + + 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) + table.attach(self.private_check, 1, 2, 1, 2, yoptions=0) + table.attach(self.restrict_check, 1, 2, 2, 3, yoptions=0) + + #filter_obj = self.topDialog.get_widget("filter") + + all = GenericFilter() + all.set_name(_("Entire Database")) + all.add_rule(Rules.Person.Everyone([])) + + the_filters = [all] + + if self.person: + des = GenericFilter() + des.set_name(_("Descendants of %s") % + name_displayer.display(self.person)) + des.add_rule(Rules.Person.IsDescendantOf( + [self.person.get_gramps_id(), 1])) + + ans = GenericFilter() + ans.set_name(_("Ancestors of %s") + % name_displayer.display(self.person)) + ans.add_rule(Rules.Person.IsAncestorOf( + [self.person.get_gramps_id(), 1])) + + com = GenericFilter() + com.set_name(_("People with common ancestor with %s") % + name_displayer.display(self.person)) + com.add_rule(Rules.Person.HasCommonAncestorWith( + [self.person.get_gramps_id()])) + + the_filters += [des, ans, com] + + from Filters import CustomFilters + the_filters.extend(CustomFilters.get_filters('Person')) + self.filter_menu = build_filter_menu(the_filters) + self.filter_obj.set_menu(self.filter_menu) + + table.show() + return table + + def parse_options(self): + + self.restrict = self.restrict_check.get_active() + self.private = self.private_check.get_active() + self.cfilter = self.filter_menu.get_active().get_data("filter") + diff --git a/src/GrampsDbUtils/Makefile.am b/src/GrampsDbUtils/Makefile.am index d7603590c..42a541111 100644 --- a/src/GrampsDbUtils/Makefile.am +++ b/src/GrampsDbUtils/Makefile.am @@ -26,8 +26,7 @@ pkgpyexecdir = @pkgpyexecdir@/GrampsDbUtils pkgpythondir = @pkgpythondir@/GrampsDbUtils GLADEFILES = \ - gedcomimport.glade\ - gedcomexport.glade + gedcomimport.glade dist_pkgdata_DATA = $(GLADEFILES) diff --git a/src/GrampsDbUtils/_PrivateProxyDb.py b/src/GrampsDbUtils/_PrivateProxyDb.py index d794fff9f..16badce37 100644 --- a/src/GrampsDbUtils/_PrivateProxyDb.py +++ b/src/GrampsDbUtils/_PrivateProxyDb.py @@ -946,7 +946,7 @@ class PrivateProxyDb: def get_researcher(self): """returns the Researcher instance, providing information about the owner of the database""" - raise NotImplementedError + return self.db.get_researcher() def set_default_person_handle(self, handle): """sets the default Person to the passed instance""" @@ -1876,11 +1876,11 @@ def sanitize_repository(db,repository): new_repository.set_type(repository.get_type()) new_repository.set_name(repository.get_name()) new_repository.set_gramps_id(repository.get_gramps_id()) - new_repository.set_handle(repositofy.get_handle()) + new_repository.set_handle(repository.get_handle()) new_repository.set_marker(repository.get_marker()) copy_notes(db,repository,new_repository) copy_addresses(db,repository,new_repository) copy_urls(db,repository,new_repository) - return new_repository \ No newline at end of file + return new_repository diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index ca40f010b..caa6ee2fe 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -36,24 +36,17 @@ import string import logging log = logging.getLogger(".WriteGedcom") -#------------------------------------------------------------------------- -# -# GNOME/GTK modules -# -#------------------------------------------------------------------------- -import gtk - #------------------------------------------------------------------------- # # GRAMPS modules # #------------------------------------------------------------------------- import RelLib -from Filters import GenericFilter, Rules, build_filter_menu import const import _GedcomInfo as GedcomInfo import Errors import Utils +import ExportOptions from QuestionDialog import ErrorDialog, WarningDialog from BasicUtils import UpdateCallback, name_displayer @@ -159,7 +152,7 @@ quay_map = { RelLib.SourceRef.CONF_HIGH : 2, RelLib.SourceRef.CONF_LOW : 1, RelLib.SourceRef.CONF_VERY_LOW : 0, -} + } #------------------------------------------------------------------------- # @@ -244,97 +237,6 @@ def breakup(txt, limit): data.append(txt) return data -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -class GedcomWriterOptionBox: - """ - Create a VBox with the option widgets and define methods to retrieve - the options. - """ - def __init__(self, person): - self.person = person - - def get_option_box(self): - self.restrict = True - - glade_file = "%s/gedcomexport.glade" % os.path.dirname(__file__) - if not os.path.isfile(glade_file): - glade_file = "plugins/gedcomexport.glade" - - self.topDialog = gtk.glade.XML(glade_file, "gedcomExport", "gramps") - self.topDialog.signal_autoconnect({ - "on_restrict_toggled" : self.on_restrict_toggled, - }) - - filter_obj = self.topDialog.get_widget("filter") - - all = GenericFilter() - all.set_name(_("Entire Database")) - all.add_rule(Rules.Person.Everyone([])) - - the_filters = [all] - - if self.person: - des = GenericFilter() - des.set_name(_("Descendants of %s") % - name_displayer.display(self.person)) - des.add_rule(Rules.Person.IsDescendantOf( - [self.person.get_gramps_id(), 1])) - - ans = GenericFilter() - ans.set_name(_("Ancestors of %s") - % name_displayer.display(self.person)) - ans.add_rule(Rules.Person.IsAncestorOf( - [self.person.get_gramps_id(), 1])) - - com = GenericFilter() - com.set_name(_("People with common ancestor with %s") % - name_displayer.display(self.person)) - com.add_rule(Rules.Person.HasCommonAncestorWith( - [self.person.get_gramps_id()])) - - the_filters += [des, ans, com] - - from Filters import CustomFilters - the_filters.extend(CustomFilters.get_filters('Person')) - self.filter_menu = build_filter_menu(the_filters) - filter_obj.set_menu(self.filter_menu) - - the_box = self.topDialog.get_widget('vbox1') - the_parent = self.topDialog.get_widget('dialog-vbox1') - the_parent.remove(the_box) - self.topDialog.get_widget("gedcomExport").destroy() - return the_box - - def on_restrict_toggled(self, restrict): - active = restrict.get_active () - map (lambda x: x.set_sensitive (active), - [self.topDialog.get_widget("living"), - self.topDialog.get_widget("notes"), - self.topDialog.get_widget("sources")]) - - def parse_options(self): - - self.restrict = self.topDialog.get_widget("restrict").get_active() - self.living = (self.restrict and - self.topDialog.get_widget("living").get_active()) - self.exclnotes = (self.restrict and - self.topDialog.get_widget("notes").get_active()) - self.exclsrcs = (self.restrict and - self.topDialog.get_widget("sources").get_active()) - - self.cfilter = self.filter_menu.get_active().get_data("filter") - - self.images = self.topDialog.get_widget ("images").get_active () - if self.images: - images_path = self.topDialog.get_widget ("images_path") - self.images_path = unicode(images_path.get_text ()) - else: - self.images_path = "" - #------------------------------------------------------------------------- # # GedcomWriter class @@ -393,11 +295,11 @@ class GedcomWriter(UpdateCallback): self.option_box.parse_options() self.restrict = self.option_box.restrict - self.living = self.option_box.living - self.exclnotes = self.option_box.exclnotes - self.exclsrcs = self.option_box.exclsrcs - self.images = self.option_box.images - self.images_path = self.option_box.images_path + self.private = self.option_box.private + + if self.private: + import _PrivateProxyDb + self.db = _PrivateProxyDb.PrivateProxyDb(self.db) if self.option_box.cfilter == None: self.plist = set(self.db.get_person_handles(sort_handles=False)) @@ -414,7 +316,7 @@ class GedcomWriter(UpdateCallback): def cli_setup(self): # use default settings self.restrict = 0 - self.images = 0 + self.private = 0 self.plist = set(self.db.get_person_handles(sort_handles=False)) @@ -555,7 +457,11 @@ class GedcomWriter(UpdateCallback): sorted.sort() for data in sorted: - self.__write_person(self.db.get_person_from_handle(data[1])) + person = self.db.get_person_from_handle(data[1]) + if self.restrict: + if Utils.probably_alive(person, self.db): + person = ExportOptions.restrict_living(person) + self.__write_person(person) self.update() def __write_person(self, person): @@ -767,9 +673,8 @@ class GedcomWriter(UpdateCallback): self.__write_source_references(addr.get_source_references(), 2) def __write_photos(self, media_list, level): - if self.images: - for photo in media_list: - self.__write_photo(photo, level) + for photo in media_list: + self.__write_photo(photo, level) def __write_child_families(self, person): hndl_list = [ hndl for hndl in person.get_parent_family_handle_list() \ @@ -1090,10 +995,9 @@ class GedcomWriter(UpdateCallback): self.__write_note_references(event.get_note_list(), 1) self.__write_source_references(event.get_source_references(), 2) - if self.images: - self.__write_photos(event.get_media_list(), 2) - if place: - self.__write_photos(place.get_media_list(), 2) + self.__write_photos(event.get_media_list(), 2) + if place: + self.__write_photos(place.get_media_list(), 2) def write_ord(self, ord, index): self.__writeln(index, lds_ord_name[ord.get_type()]) @@ -1250,31 +1154,14 @@ class GedcomWriter(UpdateCallback): mime = photo_obj.get_mime_type() form = mime2ged.get(mime, mime) path = photo_obj.get_path() - imgdir = os.path.join(self.dirname, self.images_path) + imgdir = path if not os.path.isfile(path): return - try: - if not os.path.isdir(imgdir): - os.makedirs(imgdir) - except: - return - basename = os.path.basename(path) - dest = os.path.join (imgdir, basename) - if dest != path: - try: - shutil.copyfile(path, dest) - shutil.copystat(path, dest) - except (IOError, OSError), msg: - msg2 = _("Could not create %s") % dest - WarningDialog(msg2, str(msg)) - return - self.__writeln(level, 'OBJE') if form: self.__writeln(level+1, 'FORM', form) self.__writeln(level+1, 'TITL', photo_obj.get_description()) - basename = os.path.basename (path) - self.__writeln(level+1, 'FILE', os.path.join(self.images_path, basename)) + self.__writeln(level+1, 'FILE', path) self.__write_note_references(photo_obj.get_note_list(), level+1) @@ -1312,7 +1199,7 @@ def exportData(database, filename, person, option_box, callback=None): _title = _('GE_DCOM') _description = _('GEDCOM is used to transfer data between genealogy programs. ' 'Most genealogy software will accept a GEDCOM file as input. ') -_config = (_('GEDCOM export options'), GedcomWriterOptionBox) +_config = (_('GEDCOM export options'), ExportOptions.WriterOptionBox) _filename = 'ged' from PluginUtils import register_export diff --git a/src/GrampsDbUtils/gedcomexport.glade b/src/GrampsDbUtils/gedcomexport.glade deleted file mode 100644 index 3a326dfdd..000000000 --- a/src/GrampsDbUtils/gedcomexport.glade +++ /dev/null @@ -1,396 +0,0 @@ - - - - - - - True - - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - 400 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - 12 - True - 6 - 3 - False - 6 - 12 - - - - True - <b>Options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - _Filter: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - filter - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - -1 - - - - True - - - - - 2 - 3 - 1 - 2 - fill - - - - - - - 3 - True - True - _Do not include records marked private - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 3 - 2 - 3 - fill - - - - - - - 3 - True - True - _Restrict data on living people - True - GTK_RELIEF_NORMAL - True - True - False - True - - - - 1 - 3 - 3 - 4 - fill - - - - - - - True - 3 - 2 - False - 6 - 12 - - - - True - True - Exclude _notes - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - True - Exclude sour_ces - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - True - Use _Living as first name - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - - - 0 - 1 - 0 - 1 - shrink|fill - fill - - - - - 1 - 3 - 4 - 5 - fill - - - - - - True - False - 0 - - - - True - True - R_eference images from path: - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - True - True - True - True - 0 - media - True - * - False - - - 0 - True - True - - - - - 1 - 3 - 5 - 6 - fill - - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - True - True - - - - - - - diff --git a/src/Makefile.am b/src/Makefile.am index 40d0aa98a..58af3d053 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,6 +49,7 @@ gdir_PYTHON = \ DisplayState.py\ Errors.py\ ExportAssistant.py\ + ExportOptions.py\ FontScale.py\ GrampsCfg.py\ GrampsDisplay.py\