diff --git a/ChangeLog b/ChangeLog index 7b29e4d2b..6fe1b9a85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-02-19 Douglas S. Blank + * 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 * src/ReportBase/_WebReportDialog.py: * src/ReportBase/_ReportDialog.py: @@ -35,6 +40,7 @@ Remove the "person" option from reports, report options, and report dialogs. Person is selected by the user for all reports. + 2008-02-19 Douglas S. Blank * src/plugins/DefaultGramplets.py: News renders text with styles * src/DataViews/GrampletView.py (GuiGramplet.render_text): diff --git a/src/DbLoader.py b/src/DbLoader.py index 72cb4c200..c7dd6774f 100644 --- a/src/DbLoader.py +++ b/src/DbLoader.py @@ -141,46 +141,51 @@ class DbLoader: default_dir = get_default_dir() choose_db_dialog.set_current_folder(default_dir) - response = choose_db_dialog.run() - if response == gtk.RESPONSE_OK: - filename = Utils.get_unicode_path(choose_db_dialog.get_filename()) - if self.check_errors(filename): - return False + while True: + response = choose_db_dialog.run() + if response == gtk.RESPONSE_CANCEL: + break + 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 - if filename == self.dbstate.db.full_name: - return False - - 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 + # Do not allow importing from the currently open file + if filename == self.dbstate.db.full_name: + ErrorDialog(_("Cannot import from current file")) + continue - # Then we try all the known plugins - (the_path, the_file) = os.path.split(filename) - Config.set(Config.RECENT_IMPORT_DIR, the_path) - for (importData, mime_filter, mime_type, native_format, - format_name) in import_list: - if filetype == mime_type or the_file == mime_type: - self.do_import(choose_db_dialog, importData, filename) + 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)) + 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 - # 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) + # Then we try all the known plugins + (the_path, the_file) = os.path.split(filename) + Config.set(Config.RECENT_IMPORT_DIR, the_path) + for (importData, mime_filter, mime_type, native_format, + format_name) in import_list: + 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() return False