Use XDG pictures directory as the default media path
If the "Base path for relative media paths" is left empty then use the XDG pictures directory as the default rather than the home directory. This is a better default for our Flatpak distribution. Fixes #12217.
This commit is contained in:
parent
9ad4b2d8ac
commit
626a96580a
@ -125,6 +125,10 @@ else:
|
|||||||
USER_CONFIG = os.path.join(GLib.get_user_config_dir(), 'gramps')
|
USER_CONFIG = os.path.join(GLib.get_user_config_dir(), 'gramps')
|
||||||
USER_CACHE = os.path.join(GLib.get_user_cache_dir(), 'gramps')
|
USER_CACHE = os.path.join(GLib.get_user_cache_dir(), 'gramps')
|
||||||
|
|
||||||
|
USER_PICTURES = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)
|
||||||
|
if not USER_PICTURES:
|
||||||
|
USER_PICTURES = HOME_DIR
|
||||||
|
|
||||||
VERSION_DIR_NAME = "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])
|
VERSION_DIR_NAME = "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])
|
||||||
VERSION_DIR = os.path.join(USER_CONFIG, VERSION_DIR_NAME)
|
VERSION_DIR = os.path.join(USER_CONFIG, VERSION_DIR_NAME)
|
||||||
USER_DATA_VERSION = os.path.join(USER_DATA, VERSION_DIR_NAME)
|
USER_DATA_VERSION = os.path.join(USER_DATA, VERSION_DIR_NAME)
|
||||||
|
@ -43,7 +43,7 @@ LOG = logging.getLogger(".gen.utils.file")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ..constfunc import win, mac, get_env_var
|
from ..constfunc import win, mac, get_env_var
|
||||||
from ..const import USER_HOME, ENV, GRAMPS_LOCALE as glocale
|
from ..const import USER_HOME, USER_PICTURES, ENV, GRAMPS_LOCALE as glocale
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -182,9 +182,9 @@ def expand_media_path(mpath, db):
|
|||||||
- Convert to absolute path
|
- Convert to absolute path
|
||||||
- Convert slashes and case (on Windows)
|
- Convert slashes and case (on Windows)
|
||||||
"""
|
"""
|
||||||
# Use home dir if no media_path specified
|
# Use XDG pictures diectory if no media_path specified
|
||||||
if mpath is None:
|
if mpath is None:
|
||||||
mpath = os.path.abspath(USER_HOME)
|
mpath = os.path.abspath(USER_PICTURES)
|
||||||
# Expand environment variables
|
# Expand environment variables
|
||||||
mpath = expand_path(mpath, False)
|
mpath = expand_path(mpath, False)
|
||||||
# Relative mediapath are considered as relative to the database
|
# Relative mediapath are considered as relative to the database
|
||||||
|
@ -39,7 +39,7 @@ import unittest
|
|||||||
# Gramps modules
|
# Gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ...const import USER_HOME, USER_PLUGINS, VERSION
|
from ...const import USER_HOME, USER_PICTURES, USER_PLUGINS, VERSION
|
||||||
from ...utils.file import media_path
|
from ...utils.file import media_path
|
||||||
from ...db.utils import make_database
|
from ...db.utils import make_database
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class FileTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Test without db.mediapath set
|
# Test without db.mediapath set
|
||||||
self.assertEqual(media_path(db), os.path.normcase(os.path.normpath(
|
self.assertEqual(media_path(db), os.path.normcase(os.path.normpath(
|
||||||
os.path.abspath(USER_HOME))))
|
os.path.abspath(USER_PICTURES))))
|
||||||
self.assertTrue(os.path.exists(media_path(db)))
|
self.assertTrue(os.path.exists(media_path(db)))
|
||||||
|
|
||||||
# Test with absolute db.mediapath
|
# Test with absolute db.mediapath
|
||||||
|
Loading…
Reference in New Issue
Block a user