diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c index efd6573605..1ed551fe88 100644 --- a/gnucash/gnome-utils/gnc-gnome-utils.c +++ b/gnucash/gnome-utils/gnc-gnome-utils.c @@ -219,11 +219,11 @@ gnc_add_css_file (void) #endif gtk_css_provider_load_from_resource (provider_fallback, "/org/gnucash/gnucash-fallback-310.css"); - var = g_get_home_dir (); + var = gnc_userconfig_dir (); if (var) { gchar *str; - str = g_build_filename (var, ".gtk-3.0-gnucash.css", (char *)NULL); + str = g_build_filename (var, "gtk-3.0.css", (char *)NULL); gtk_css_provider_load_from_path (provider_user, str, &error); g_free (str); } diff --git a/libgnucash/core-utils/gnc-filepath-utils.cpp b/libgnucash/core-utils/gnc-filepath-utils.cpp index 8b45780b8a..a8857d41c6 100644 --- a/libgnucash/core-utils/gnc-filepath-utils.cpp +++ b/libgnucash/core-utils/gnc-filepath-utils.cpp @@ -543,6 +543,33 @@ get_userdata_home(void) return userdata_home; } +static bfs::path +get_userconfig_home(void) +{ + gchar *config_dir = NULL; + auto userconfig_home = bfs::path(); + +#ifdef G_OS_WIN32 + config_dir = win32_get_userdata_home (); +#elif defined MAC_INTEGRATION + config_dir = quarz_get_userdata_home (); +#endif + + /* On Windows and Macs the data directory is used, for Linux + $HOME/.config is used */ + if (config_dir) + { + userconfig_home = config_dir; + g_free(config_dir); + } + else + userconfig_home = g_get_user_config_dir(); + + userconfig_home = userconfig_home / PACKAGE; + + return userconfig_home; +} + gboolean gnc_filepath_init (void) { @@ -684,6 +711,24 @@ gnc_userdata_dir (void) return gnc_userdata_home.string().c_str(); } +/** @fn const gchar * gnc_userconfig_dir () + * @brief Return the config directory + * + * Note that the default path depends on the platform. + * - Windows: CSIDL_APPDATA/Gnucash + * - OS X: $HOME/Application Support/Gnucash + * - Linux: $XDG_CONFIG_HOME/Gnucash (or the default $HOME/.config/Gnucash) + * + * @return An absolute path to the configuration directory. This string is + * owned by the gnc_filepath_utils code and should not be freed by the user. + */ +const gchar * +gnc_userconfig_dir (void) +{ + auto path_string = get_userconfig_home(); + return g_strdup(path_string.string().c_str()); +} + static const bfs::path& gnc_userdata_dir_as_path (void) { diff --git a/libgnucash/core-utils/gnc-filepath-utils.h b/libgnucash/core-utils/gnc-filepath-utils.h index 465d404b78..f327446bcf 100644 --- a/libgnucash/core-utils/gnc-filepath-utils.h +++ b/libgnucash/core-utils/gnc-filepath-utils.h @@ -103,6 +103,8 @@ gchar *gnc_build_data_path (const gchar *filename); gchar *gnc_build_report_path (const gchar *filename); gchar *gnc_build_stdreports_path (const gchar *filename); +const gchar *gnc_userconfig_dir (void); + /** Given a pixmap/pixbuf file name, find the file in the pixmap * directory associated with this application. This routine will * display an error message if it can't find the file.