Better default directory choices for import/export

Use recent-export-dir as default for Export View
instead of the console default directory, which can be where
program resides (on Windows), or other inappropriate place.

Use USER_HOME for default directory on 'Export' (recent-export-dir)
if first run (default settings) rather than default directory, which
can be where program resides (on Windows), or other inappropriate
place.

Use USER_HOME for default directory on 'Import' (recent-import-dir)
if first run (default settings) rather than recent file which is
generally set to the grampsdb path.

Fixes #10802
This commit is contained in:
prculley 2018-10-19 16:33:16 -05:00 committed by Nick Hall
parent f4966ca793
commit c110d9bc23
4 changed files with 8 additions and 36 deletions

View File

@ -221,9 +221,9 @@ register('interface.view', True)
register('interface.surname-box-height', 150)
register('interface.treemodel-cache-size', 1000)
register('paths.recent-export-dir', '')
register('paths.recent-export-dir', USER_HOME)
register('paths.recent-file', '')
register('paths.recent-import-dir', '')
register('paths.recent-import-dir', USER_HOME)
register('paths.report-directory', USER_HOME)
register('paths.website-directory', USER_HOME)
register('paths.website-cms-uri', '')

View File

@ -303,27 +303,6 @@ class DbLoader(CLIDbLoader):
self._end_progress()
return True
#-------------------------------------------------------------------------
#
# default dir selection
#
#-------------------------------------------------------------------------
def get_default_dir():
# Suggested folder: try last open file, last import, last export,
# then home.
default_dir = os.path.dirname(config.get('paths.recent-file'))
if default_dir:
default_dir += os.path.sep
if len(default_dir)<=1:
default_dir = config.get('paths.recent-import-dir')
if len(default_dir)<=1:
default_dir = config.get('paths.recent-export-dir')
if len(default_dir)<=1:
default_dir = '~/'
else:
default_dir = "~/"
return default_dir
#-------------------------------------------------------------------------
#
# FileChooser filters: what to show in the file chooser
@ -474,13 +453,7 @@ class GrampsImportFileDialog(ManagedWindow):
(box, type_selector) = format_maker()
import_dialog.set_extra_widget(box)
# Suggested folder: try last open file, import, then last export,
# then home.
default_dir = config.get('paths.recent-import-dir')
if len(default_dir)<=1:
default_dir = get_default_dir()
import_dialog.set_current_folder(default_dir)
import_dialog.set_current_folder(config.get('paths.recent-import-dir'))
while True:
# the import_dialog.run() makes it modal, so any change to that
# line would require the ManagedWindow.__init__ to be changed also

View File

@ -55,7 +55,7 @@ from gi.repository import GdkPixbuf
#
#-------------------------------------------------------------------------
from gramps.gen.const import USER_HOME, ICON, SPLASH, GRAMPS_LOCALE as glocale
from gramps.gen.const import ICON, SPLASH, GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.config import config
from ...pluginmanager import GuiPluginManager
@ -558,12 +558,7 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant):
ix = self.get_selected_format_index()
ext = self.map_exporters[ix].get_extension()
# Suggested folder: try last export, then last import, then home.
default_dir = config.get('paths.recent-export-dir')
if len(default_dir)<=1:
default_dir = config.get('paths.recent-import-dir')
if len(default_dir)<=1:
default_dir = USER_HOME
if ext == 'gramps':
new_filename = os.path.join(default_dir,'data.gramps')

View File

@ -30,6 +30,7 @@ Provide the base classes for GRAMPS' DataView classes
#
#----------------------------------------------------------------
from abc import abstractmethod
import os
import pickle
import time
import logging
@ -1071,6 +1072,8 @@ class ListView(NavigationView):
combobox.set_active(0)
box.show_all()
chooser.set_extra_widget(box)
default_dir = config.get('paths.recent-export-dir')
chooser.set_current_folder(default_dir)
while True:
value = chooser.run()
@ -1083,6 +1086,7 @@ class ListView(NavigationView):
else:
chooser.destroy()
return
config.set('paths.recent-export-dir', os.path.split(fn)[0])
self.write_tabbed_file(fn, fl)
def write_tabbed_file(self, name, type):