2004-07-09 23:49:47 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-01-10 22:39:40 +05:30
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
2004-07-09 23:49:47 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2005-02-20 00:35:48 +05:30
|
|
|
# Written by Alex Roitman
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-03-05 10:15:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".Exporter")
|
|
|
|
|
2004-07-09 23:49:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2006-03-11 06:42:06 +05:30
|
|
|
from PluginUtils import export_list
|
2004-07-09 23:49:47 +05:30
|
|
|
import QuestionDialog
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
2006-01-10 22:39:40 +05:30
|
|
|
import Assistant
|
2006-06-15 23:54:43 +05:30
|
|
|
import Errors
|
2006-01-11 06:56:17 +05:30
|
|
|
from GrampsDb import gramps_db_writer_factory
|
2004-07-09 23:49:47 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Exporter
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class Exporter:
|
|
|
|
"""
|
|
|
|
This class creates Gnome Druid to guide the user through the various
|
|
|
|
Save as/Export options. The overall goal is to keep things simple by
|
|
|
|
presenting few choice options on each druid page.
|
|
|
|
|
|
|
|
The export formats and options are obtained from the plugins, with the
|
|
|
|
exception of a native save. Native save as just copies file to another
|
|
|
|
name.
|
|
|
|
"""
|
|
|
|
|
2006-03-01 11:46:36 +05:30
|
|
|
def __init__(self,dbstate,uistate):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Set up the window, the druid, and build all the druid's pages.
|
|
|
|
Some page elements are left empty, since their contents depends
|
|
|
|
on the user choices and on the success of the attempted save.
|
|
|
|
"""
|
2006-01-10 22:39:40 +05:30
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
2006-03-01 11:46:36 +05:30
|
|
|
self.callback = self.uistate.pulse_progressbar
|
2006-01-10 22:39:40 +05:30
|
|
|
if self.dbstate.active:
|
2006-04-02 09:45:11 +05:30
|
|
|
self.person = self.dbstate.get_active_person()
|
2004-07-11 05:01:28 +05:30
|
|
|
else:
|
2006-01-30 03:35:20 +05:30
|
|
|
self.person = self.dbstate.db.find_initial_person()
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
self.build_exports()
|
2006-01-11 06:56:17 +05:30
|
|
|
self.format_option = None
|
2004-07-10 04:31:19 +05:30
|
|
|
|
2006-06-15 23:54:43 +05:30
|
|
|
try:
|
|
|
|
self.w = Assistant.Assistant(uistate,self.complete,
|
|
|
|
_("Export Assistant"))
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
return
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.w.add_text_page(_('Saving your data'),self.get_intro_text())
|
2005-12-30 09:27:31 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.format_page = self.w.add_page(_('Choosing the format to save'),
|
|
|
|
self.build_format_page())
|
2006-01-10 22:39:40 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.file_sel_page = self.w.add_page(_('Selecting the file name'),
|
|
|
|
self.build_file_sel_page())
|
2006-01-10 22:39:40 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
self.confirm_page = self.w.add_text_page('','')
|
|
|
|
self.conclusion_page = self.w.add_text_page('','')
|
2006-01-10 22:39:40 +05:30
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
self.w.connect('before-page-next',self.on_before_page_next)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2005-12-30 09:27:31 +05:30
|
|
|
self.w.show()
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
def complete(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_before_page_next(self,obj,page,data=None):
|
|
|
|
if page == self.format_page:
|
|
|
|
self.build_options()
|
|
|
|
self.suggest_filename()
|
|
|
|
elif page == self.file_sel_page:
|
2006-01-12 11:39:14 +05:30
|
|
|
self.build_confirmation()
|
|
|
|
elif page == self.confirm_page:
|
|
|
|
success = self.save()
|
|
|
|
self.build_conclusion(success)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
def help(self,obj):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Help handler.
|
|
|
|
"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('export-data')
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
def get_intro_text(self):
|
|
|
|
return _('Under normal circumstances, GRAMPS does not require you '
|
|
|
|
'to directly save your changes. All changes you make are '
|
|
|
|
'immediately saved to the database.\n\n'
|
|
|
|
'This process will help you save a copy of your data '
|
|
|
|
'in any of the several formats supported by GRAMPS. '
|
|
|
|
'This can be used to make a copy of your data, backup '
|
|
|
|
'your data, or convert it to a format that will allow '
|
|
|
|
'you to transfer it to a different program.\n\n'
|
|
|
|
'If you change your mind during this process, you '
|
|
|
|
'can safely press the Cancel button at any time and your '
|
|
|
|
'present database will still be intact.')
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
def build_confirmation(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Build the text of the confirmation label. This should query
|
|
|
|
the selected options (format, filename) and present the summary
|
|
|
|
of the proposed action.
|
|
|
|
"""
|
2004-07-10 04:31:19 +05:30
|
|
|
filename = self.chooser.get_filename()
|
|
|
|
name = os.path.split(filename)[1]
|
|
|
|
folder = os.path.split(filename)[0]
|
2004-07-11 05:01:28 +05:30
|
|
|
ix = self.get_selected_format_index()
|
|
|
|
format = self.exports[ix][1].replace('_','')
|
2004-07-10 04:31:19 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
confirm_text = _(
|
|
|
|
'The data will be saved as follows:\n\n'
|
2004-07-10 04:31:19 +05:30
|
|
|
'Format:\t%s\nName:\t%s\nFolder:\t%s\n\n'
|
2006-01-11 06:56:17 +05:30
|
|
|
'Press OK to proceed, Cancel to abort, or Back to '
|
2006-01-12 11:39:14 +05:30
|
|
|
'revisit your options.') % (format, name, folder)
|
|
|
|
self.w.remove_page(self.confirm_page)
|
|
|
|
self.confirm_page = self.w.insert_text_page(_('Final confirmation'),
|
|
|
|
confirm_text,
|
|
|
|
self.confirm_page)
|
2004-07-10 04:31:19 +05:30
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
def save(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Perform the actual Save As/Export operation.
|
|
|
|
Depending on the success status, set the text for the final page.
|
|
|
|
"""
|
2004-07-09 23:49:47 +05:30
|
|
|
filename = self.chooser.get_filename()
|
2006-04-25 02:34:01 +05:30
|
|
|
Config.set(Config.RECENT_EXPORT_DIR,os.path.split(filename)[0])
|
2004-07-11 05:01:28 +05:30
|
|
|
ix = self.get_selected_format_index()
|
2006-03-01 11:46:36 +05:30
|
|
|
self.pre_save()
|
2004-07-11 11:33:07 +05:30
|
|
|
if self.exports[ix][3]:
|
2006-01-11 06:56:17 +05:30
|
|
|
success = self.exports[ix][0](self.dbstate.db,
|
|
|
|
filename,self.person,
|
2006-03-01 10:34:22 +05:30
|
|
|
self.option_box_instance,
|
|
|
|
self.callback)
|
2004-07-11 11:33:07 +05:30
|
|
|
else:
|
2006-01-11 06:56:17 +05:30
|
|
|
success = self.exports[ix][0](self.dbstate.db,
|
2006-03-01 10:34:22 +05:30
|
|
|
filename,self.person,
|
|
|
|
self.callback)
|
2006-03-01 11:46:36 +05:30
|
|
|
self.post_save()
|
2006-01-12 11:39:14 +05:30
|
|
|
return success
|
|
|
|
|
2006-03-01 11:46:36 +05:30
|
|
|
def pre_save(self):
|
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
self.w.set_busy_cursor(1)
|
|
|
|
self.uistate.progress.show()
|
|
|
|
|
|
|
|
def post_save(self):
|
|
|
|
self.uistate.set_busy_cursor(0)
|
|
|
|
self.w.set_busy_cursor(0)
|
|
|
|
self.uistate.progress.hide()
|
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
def build_conclusion(self,success):
|
2004-07-09 23:49:47 +05:30
|
|
|
if success:
|
2006-01-11 06:56:17 +05:30
|
|
|
conclusion_title = _('Your data has been saved')
|
|
|
|
conclusion_text = _(
|
|
|
|
'The copy of your data has been '
|
2006-01-12 11:39:14 +05:30
|
|
|
'successfully saved. You may press OK button '
|
2006-01-11 06:56:17 +05:30
|
|
|
'now to continue.\n\n'
|
|
|
|
'Note: the database currently opened in your GRAMPS '
|
|
|
|
'window is NOT the file you have just saved. '
|
|
|
|
'Future editing of the currently opened database will '
|
|
|
|
'not alter the copy you have just made. ')
|
2004-07-09 23:49:47 +05:30
|
|
|
else:
|
2006-01-11 06:56:17 +05:30
|
|
|
conclusion_title = _('Saving failed'),
|
|
|
|
conclusion_text = _(
|
|
|
|
'There was an error while saving your data. '
|
|
|
|
'You may try starting the export again.\n\n'
|
|
|
|
'Note: your currently opened database is safe. '
|
|
|
|
'It was only '
|
|
|
|
'a copy of your data that failed to save.')
|
2006-01-12 11:39:14 +05:30
|
|
|
self.w.remove_page(self.conclusion_page)
|
|
|
|
self.conclusion_page = self.w.insert_text_page(conclusion_title,
|
|
|
|
conclusion_text,
|
|
|
|
self.conclusion_page)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
def build_format_page(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Build a page with the table of format radio buttons and
|
|
|
|
their descriptions.
|
|
|
|
"""
|
2004-07-09 23:49:47 +05:30
|
|
|
self.format_buttons = []
|
|
|
|
|
|
|
|
box = gtk.VBox()
|
|
|
|
box.set_spacing(12)
|
2006-01-10 22:39:40 +05:30
|
|
|
|
2004-07-09 23:49:47 +05:30
|
|
|
table = gtk.Table(2*len(self.exports),2)
|
|
|
|
table.set_row_spacings(6)
|
|
|
|
table.set_col_spacings(6)
|
|
|
|
|
2005-03-17 18:21:14 +05:30
|
|
|
tip = gtk.Tooltips()
|
|
|
|
|
2004-07-09 23:49:47 +05:30
|
|
|
group = None
|
|
|
|
for ix in range(len(self.exports)):
|
|
|
|
title = self.exports[ix][1]
|
|
|
|
description= self.exports[ix][2]
|
|
|
|
|
|
|
|
button = gtk.RadioButton(group,title)
|
|
|
|
if not group:
|
|
|
|
group = button
|
|
|
|
self.format_buttons.append(button)
|
|
|
|
table.attach(button,0,2,2*ix,2*ix+1)
|
2005-03-17 18:21:14 +05:30
|
|
|
tip.set_tip(button,description)
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
box.add(table)
|
2006-01-12 11:39:14 +05:30
|
|
|
return box
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
def build_options(self):
|
2004-07-13 02:59:15 +05:30
|
|
|
"""
|
|
|
|
Build an extra page with the options specific for the chosen format.
|
2006-01-11 06:56:17 +05:30
|
|
|
If there's already an entry for this format in self.extra_pages then
|
|
|
|
do nothing, otherwise add a page.
|
2004-07-13 02:59:15 +05:30
|
|
|
|
|
|
|
If the chosen format does not have options then remove all
|
|
|
|
extra pages that are already there (from previous user passes
|
2006-01-11 06:56:17 +05:30
|
|
|
through the assistant).
|
2004-07-13 02:59:15 +05:30
|
|
|
"""
|
2004-07-11 11:33:07 +05:30
|
|
|
ix = self.get_selected_format_index()
|
|
|
|
if self.exports[ix][3]:
|
2006-01-11 06:56:17 +05:30
|
|
|
if ix == self.format_option:
|
|
|
|
return
|
|
|
|
elif self.format_option:
|
2006-01-12 11:39:14 +05:30
|
|
|
self.w.remove_page(self.option_page)
|
2006-01-11 06:56:17 +05:30
|
|
|
self.format_option = None
|
2004-07-11 11:33:07 +05:30
|
|
|
title = self.exports[ix][3][0]
|
|
|
|
option_box_class = self.exports[ix][3][1]
|
|
|
|
self.option_box_instance = option_box_class(self.person)
|
2006-01-11 06:56:17 +05:30
|
|
|
box = self.option_box_instance.get_option_box()
|
2006-01-12 11:39:14 +05:30
|
|
|
self.option_page = self.w.insert_page(title,box,
|
|
|
|
self.format_page+1)
|
2006-06-15 22:14:17 +05:30
|
|
|
self.file_sel_page += 1
|
2006-01-12 11:39:14 +05:30
|
|
|
self.confirm_page += 1
|
|
|
|
self.conclusion_page += 1
|
2006-01-11 06:56:17 +05:30
|
|
|
self.format_option = ix
|
|
|
|
box.show_all()
|
|
|
|
elif self.format_option:
|
2006-01-12 11:39:14 +05:30
|
|
|
self.w.remove_page(self.option_page)
|
2006-01-11 06:56:17 +05:30
|
|
|
self.format_option = None
|
2004-07-11 11:33:07 +05:30
|
|
|
|
2004-07-09 23:49:47 +05:30
|
|
|
def build_file_sel_page(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Build a druid page embedding the FileChooserWidget.
|
|
|
|
"""
|
2004-07-09 23:49:47 +05:30
|
|
|
|
|
|
|
self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE)
|
2005-02-24 05:55:34 +05:30
|
|
|
self.chooser.set_local_only(False)
|
2006-01-10 22:39:40 +05:30
|
|
|
box = gtk.VBox()
|
|
|
|
box.set_spacing(12)
|
|
|
|
box.add(self.chooser)
|
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
# Dirty hack to enable proper EXPAND/FILL properties of the chooser
|
2006-01-10 22:39:40 +05:30
|
|
|
box.set_child_packing(self.chooser,1,1,0,gtk.PACK_START)
|
2006-01-11 06:56:17 +05:30
|
|
|
|
2006-01-12 11:39:14 +05:30
|
|
|
return box
|
2004-07-09 23:49:47 +05:30
|
|
|
|
2006-01-11 06:56:17 +05:30
|
|
|
def suggest_filename(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
Prepare suggested filename and set it in the file chooser.
|
|
|
|
"""
|
|
|
|
ix = self.get_selected_format_index()
|
|
|
|
ext = self.exports[ix][4]
|
* src/Plugins.py: Add native_format flag to import plugin registration.
* src/ReadXML.py, src/ReadGedcom.py: Register as native formats
to prevent loading twice on File->Open.
* src/data/gramps.schemas: Add keys for last import and export dirs.
* src/GrampsCfg.py (get_last_import_dir, save_last_import_dir,
get_last_export_dir, save_last_export_dir): Add functions.
* src/Exportder.py (suggest_filename): Try last export and last
import folders before falling back to Home; (save): Save export folder.
* src/Utils.py (get_new_filename): Add optional folder argument.
* src/DbPrompter.py (ExistingDbPrompter.chooser): Only add
importers for non-native formats, the rest is already taken care of;
Try last file, last import, last export, then home folders;
(ImportDbPrompter.chooser): Save import folder; Try last import,
last file, last export, then home folders.
(NewNativeDbPrompter): Try last file, last import, last export folders,
then fall back to home.
svn: r3493
2004-08-24 03:35:55 +05:30
|
|
|
|
|
|
|
# Suggested folder: try last export, then last import, then home.
|
2006-04-25 02:34:01 +05:30
|
|
|
default_dir = Config.get(Config.RECENT_EXPORT_DIR)
|
* src/Plugins.py: Add native_format flag to import plugin registration.
* src/ReadXML.py, src/ReadGedcom.py: Register as native formats
to prevent loading twice on File->Open.
* src/data/gramps.schemas: Add keys for last import and export dirs.
* src/GrampsCfg.py (get_last_import_dir, save_last_import_dir,
get_last_export_dir, save_last_export_dir): Add functions.
* src/Exportder.py (suggest_filename): Try last export and last
import folders before falling back to Home; (save): Save export folder.
* src/Utils.py (get_new_filename): Add optional folder argument.
* src/DbPrompter.py (ExistingDbPrompter.chooser): Only add
importers for non-native formats, the rest is already taken care of;
Try last file, last import, last export, then home folders;
(ImportDbPrompter.chooser): Save import folder; Try last import,
last file, last export, then home folders.
(NewNativeDbPrompter): Try last file, last import, last export folders,
then fall back to home.
svn: r3493
2004-08-24 03:35:55 +05:30
|
|
|
if len(default_dir)<=1:
|
2006-04-25 02:34:01 +05:30
|
|
|
default_dir = Config.get(Config.RECENT_IMPORT_DIR)
|
* src/Plugins.py: Add native_format flag to import plugin registration.
* src/ReadXML.py, src/ReadGedcom.py: Register as native formats
to prevent loading twice on File->Open.
* src/data/gramps.schemas: Add keys for last import and export dirs.
* src/GrampsCfg.py (get_last_import_dir, save_last_import_dir,
get_last_export_dir, save_last_export_dir): Add functions.
* src/Exportder.py (suggest_filename): Try last export and last
import folders before falling back to Home; (save): Save export folder.
* src/Utils.py (get_new_filename): Add optional folder argument.
* src/DbPrompter.py (ExistingDbPrompter.chooser): Only add
importers for non-native formats, the rest is already taken care of;
Try last file, last import, last export, then home folders;
(ImportDbPrompter.chooser): Save import folder; Try last import,
last file, last export, then home folders.
(NewNativeDbPrompter): Try last file, last import, last export folders,
then fall back to home.
svn: r3493
2004-08-24 03:35:55 +05:30
|
|
|
if len(default_dir)<=1:
|
2006-03-29 09:54:39 +05:30
|
|
|
default_dir = const.user_home
|
* src/Plugins.py: Add native_format flag to import plugin registration.
* src/ReadXML.py, src/ReadGedcom.py: Register as native formats
to prevent loading twice on File->Open.
* src/data/gramps.schemas: Add keys for last import and export dirs.
* src/GrampsCfg.py (get_last_import_dir, save_last_import_dir,
get_last_export_dir, save_last_export_dir): Add functions.
* src/Exportder.py (suggest_filename): Try last export and last
import folders before falling back to Home; (save): Save export folder.
* src/Utils.py (get_new_filename): Add optional folder argument.
* src/DbPrompter.py (ExistingDbPrompter.chooser): Only add
importers for non-native formats, the rest is already taken care of;
Try last file, last import, last export, then home folders;
(ImportDbPrompter.chooser): Save import folder; Try last import,
last file, last export, then home folders.
(NewNativeDbPrompter): Try last file, last import, last export folders,
then fall back to home.
svn: r3493
2004-08-24 03:35:55 +05:30
|
|
|
|
2004-07-11 05:01:28 +05:30
|
|
|
if ext == 'gramps':
|
2006-03-29 09:54:39 +05:30
|
|
|
new_filename = os.path.join(default_dir,'data.gramps')
|
2005-02-20 04:03:24 +05:30
|
|
|
elif ext == 'burn':
|
2006-01-11 06:56:17 +05:30
|
|
|
new_filename = os.path.basename(self.dbstate.db.get_save_path())
|
2004-07-11 05:01:28 +05:30
|
|
|
else:
|
* src/Plugins.py: Add native_format flag to import plugin registration.
* src/ReadXML.py, src/ReadGedcom.py: Register as native formats
to prevent loading twice on File->Open.
* src/data/gramps.schemas: Add keys for last import and export dirs.
* src/GrampsCfg.py (get_last_import_dir, save_last_import_dir,
get_last_export_dir, save_last_export_dir): Add functions.
* src/Exportder.py (suggest_filename): Try last export and last
import folders before falling back to Home; (save): Save export folder.
* src/Utils.py (get_new_filename): Add optional folder argument.
* src/DbPrompter.py (ExistingDbPrompter.chooser): Only add
importers for non-native formats, the rest is already taken care of;
Try last file, last import, last export, then home folders;
(ImportDbPrompter.chooser): Save import folder; Try last import,
last file, last export, then home folders.
(NewNativeDbPrompter): Try last file, last import, last export folders,
then fall back to home.
svn: r3493
2004-08-24 03:35:55 +05:30
|
|
|
new_filename = Utils.get_new_filename(ext,default_dir)
|
|
|
|
self.chooser.set_current_folder(default_dir)
|
2004-07-11 05:01:28 +05:30
|
|
|
self.chooser.set_current_name(os.path.split(new_filename)[1])
|
|
|
|
|
|
|
|
def get_selected_format_index(self):
|
|
|
|
"""
|
|
|
|
Query the format radiobuttons and return the index number
|
|
|
|
of the selected one.
|
|
|
|
"""
|
|
|
|
for ix in range(len(self.format_buttons)):
|
|
|
|
button = self.format_buttons[ix]
|
|
|
|
if button.get_active():
|
|
|
|
return ix
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
2006-05-10 04:45:38 +05:30
|
|
|
def native_export(self,database,filename,person,callback=None):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
2005-02-23 10:23:11 +05:30
|
|
|
Native database export.
|
|
|
|
|
|
|
|
In the future, filter and other options may be added.
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
2004-07-09 23:49:47 +05:30
|
|
|
try:
|
2006-01-12 11:39:14 +05:30
|
|
|
gramps_db_writer_factory(const.app_gramps)(database,
|
|
|
|
filename,
|
2006-05-10 04:45:38 +05:30
|
|
|
person,
|
|
|
|
callback)
|
2004-07-09 23:49:47 +05:30
|
|
|
return 1
|
|
|
|
except IOError, msg:
|
2006-01-12 11:39:14 +05:30
|
|
|
QuestionDialog.ErrorDialog(
|
|
|
|
_("Could not write file: %s") % filename,
|
|
|
|
_('System message was: %s') % msg )
|
2004-07-09 23:49:47 +05:30
|
|
|
return 0
|
|
|
|
|
|
|
|
def build_exports(self):
|
2004-07-11 05:01:28 +05:30
|
|
|
"""
|
|
|
|
This method builds its own list of available exports.
|
2005-01-08 05:50:42 +05:30
|
|
|
The list is built from the PluginMgr.export_list list
|
2004-07-11 05:01:28 +05:30
|
|
|
and from the locally defined exports (i.e. native export defined here).
|
|
|
|
"""
|
2004-07-09 23:49:47 +05:30
|
|
|
native_title = _('GRAMPS _GRDB database')
|
|
|
|
native_description =_('The GRAMPS GRDB database is a format '
|
|
|
|
'that GRAMPS uses to store information. '
|
|
|
|
'Selecting this option will allow you to '
|
|
|
|
'make a copy of the current database.')
|
|
|
|
native_config = None
|
|
|
|
native_ext = 'grdb'
|
|
|
|
native_export = self.native_export
|
|
|
|
|
2006-01-10 22:39:40 +05:30
|
|
|
self.exports = [(native_export,
|
|
|
|
native_title,
|
|
|
|
native_description,
|
|
|
|
native_config,
|
|
|
|
native_ext)]
|
2006-03-11 06:42:06 +05:30
|
|
|
self.exports = self.exports + [item for item in export_list]
|