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:
parent
f4966ca793
commit
c110d9bc23
@ -221,9 +221,9 @@ register('interface.view', True)
|
|||||||
register('interface.surname-box-height', 150)
|
register('interface.surname-box-height', 150)
|
||||||
register('interface.treemodel-cache-size', 1000)
|
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-file', '')
|
||||||
register('paths.recent-import-dir', '')
|
register('paths.recent-import-dir', USER_HOME)
|
||||||
register('paths.report-directory', USER_HOME)
|
register('paths.report-directory', USER_HOME)
|
||||||
register('paths.website-directory', USER_HOME)
|
register('paths.website-directory', USER_HOME)
|
||||||
register('paths.website-cms-uri', '')
|
register('paths.website-cms-uri', '')
|
||||||
|
@ -303,27 +303,6 @@ class DbLoader(CLIDbLoader):
|
|||||||
self._end_progress()
|
self._end_progress()
|
||||||
return True
|
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
|
# FileChooser filters: what to show in the file chooser
|
||||||
@ -474,13 +453,7 @@ class GrampsImportFileDialog(ManagedWindow):
|
|||||||
(box, type_selector) = format_maker()
|
(box, type_selector) = format_maker()
|
||||||
import_dialog.set_extra_widget(box)
|
import_dialog.set_extra_widget(box)
|
||||||
|
|
||||||
# Suggested folder: try last open file, import, then last export,
|
import_dialog.set_current_folder(config.get('paths.recent-import-dir'))
|
||||||
# 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)
|
|
||||||
while True:
|
while True:
|
||||||
# the import_dialog.run() makes it modal, so any change to that
|
# the import_dialog.run() makes it modal, so any change to that
|
||||||
# line would require the ManagedWindow.__init__ to be changed also
|
# line would require the ManagedWindow.__init__ to be changed also
|
||||||
|
@ -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
|
_ = glocale.translation.gettext
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
from ...pluginmanager import GuiPluginManager
|
from ...pluginmanager import GuiPluginManager
|
||||||
@ -558,12 +558,7 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant):
|
|||||||
ix = self.get_selected_format_index()
|
ix = self.get_selected_format_index()
|
||||||
ext = self.map_exporters[ix].get_extension()
|
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')
|
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':
|
if ext == 'gramps':
|
||||||
new_filename = os.path.join(default_dir,'data.gramps')
|
new_filename = os.path.join(default_dir,'data.gramps')
|
||||||
|
@ -30,6 +30,7 @@ Provide the base classes for GRAMPS' DataView classes
|
|||||||
#
|
#
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
@ -1071,6 +1072,8 @@ class ListView(NavigationView):
|
|||||||
combobox.set_active(0)
|
combobox.set_active(0)
|
||||||
box.show_all()
|
box.show_all()
|
||||||
chooser.set_extra_widget(box)
|
chooser.set_extra_widget(box)
|
||||||
|
default_dir = config.get('paths.recent-export-dir')
|
||||||
|
chooser.set_current_folder(default_dir)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
value = chooser.run()
|
value = chooser.run()
|
||||||
@ -1083,6 +1086,7 @@ class ListView(NavigationView):
|
|||||||
else:
|
else:
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
return
|
return
|
||||||
|
config.set('paths.recent-export-dir', os.path.split(fn)[0])
|
||||||
self.write_tabbed_file(fn, fl)
|
self.write_tabbed_file(fn, fl)
|
||||||
|
|
||||||
def write_tabbed_file(self, name, type):
|
def write_tabbed_file(self, name, type):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user