2008-02-19 Douglas S. Blank <dblank@cs.brynmawr.edu>

* src/DbLoader.py (DbLoader.import_file): 
	Importer will stay on dialog until cancel or success. Errors
	will remain in dialog until fixed, or cancel.




svn: r10075
This commit is contained in:
Doug Blank 2008-02-20 04:59:52 +00:00
parent cc6654ddab
commit c76b017d64
2 changed files with 47 additions and 36 deletions

View File

@ -1,3 +1,8 @@
2008-02-19 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/DbLoader.py (DbLoader.import_file):
Importer will stay on dialog until cancel or success. Errors
will remain in dialog until fixed, or cancel.
2008-02-19 Brian Matherly <brian@gramps-project.org> 2008-02-19 Brian Matherly <brian@gramps-project.org>
* src/ReportBase/_WebReportDialog.py: * src/ReportBase/_WebReportDialog.py:
* src/ReportBase/_ReportDialog.py: * src/ReportBase/_ReportDialog.py:
@ -35,6 +40,7 @@
Remove the "person" option from reports, report options, and report dialogs. Remove the "person" option from reports, report options, and report dialogs.
Person is selected by the user for all reports. Person is selected by the user for all reports.
2008-02-19 Douglas S. Blank <dblank@cs.brynmawr.edu> 2008-02-19 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/DefaultGramplets.py: News renders text with styles * src/plugins/DefaultGramplets.py: News renders text with styles
* src/DataViews/GrampletView.py (GuiGramplet.render_text): * src/DataViews/GrampletView.py (GuiGramplet.render_text):

View File

@ -141,46 +141,51 @@ class DbLoader:
default_dir = get_default_dir() default_dir = get_default_dir()
choose_db_dialog.set_current_folder(default_dir) choose_db_dialog.set_current_folder(default_dir)
response = choose_db_dialog.run() while True:
if response == gtk.RESPONSE_OK: response = choose_db_dialog.run()
filename = Utils.get_unicode_path(choose_db_dialog.get_filename()) if response == gtk.RESPONSE_CANCEL:
if self.check_errors(filename): break
return False elif response == gtk.RESPONSE_OK:
filename = Utils.get_unicode_path(choose_db_dialog.get_filename())
if self.check_errors(filename):
# displays errors if any
continue
# Do not allow importing from the currently open file # Do not allow importing from the currently open file
if filename == self.dbstate.db.full_name: if filename == self.dbstate.db.full_name:
return False ErrorDialog(_("Cannot import from current file"))
continue
filetype = type_selector.get_value()
if filetype == 'auto':
try:
filetype = Mime.get_type(filename)
except RuntimeError, msg:
ErrorDialog(_("Could not open file: %s") % filename,
str(msg))
return False
# First we try our best formats
if filetype in OPEN_FORMATS:
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
self.do_import(choose_db_dialog, importer, filename)
return True
# Then we try all the known plugins filetype = type_selector.get_value()
(the_path, the_file) = os.path.split(filename) if filetype == 'auto':
Config.set(Config.RECENT_IMPORT_DIR, the_path) try:
for (importData, mime_filter, mime_type, native_format, filetype = Mime.get_type(filename)
format_name) in import_list: except RuntimeError, msg:
if filetype == mime_type or the_file == mime_type: ErrorDialog(_("Could not open file: %s") % filename,
self.do_import(choose_db_dialog, importData, filename) str(msg))
continue
# First we try our best formats
if filetype in OPEN_FORMATS:
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
self.do_import(choose_db_dialog, importer, filename)
return True return True
# Finally, we give up and declare this an unknown format # Then we try all the known plugins
ErrorDialog( (the_path, the_file) = os.path.split(filename)
_("Could not open file: %s") % filename, Config.set(Config.RECENT_IMPORT_DIR, the_path)
_('File type "%s" is unknown to GRAMPS.\n\n' for (importData, mime_filter, mime_type, native_format,
'Valid types are: GRAMPS database, GRAMPS XML, ' format_name) in import_list:
'GRAMPS package, and GEDCOM.') % filetype) if filetype == mime_type or the_file == mime_type:
self.do_import(choose_db_dialog, importData, filename)
return True
# Finally, we give up and declare this an unknown format
ErrorDialog(
_("Could not open file: %s") % filename,
_('File type "%s" is unknown to GRAMPS.\n\n'
'Valid types are: GRAMPS database, GRAMPS XML, '
'GRAMPS package, and GEDCOM.') % filetype)
choose_db_dialog.destroy() choose_db_dialog.destroy()
return False return False