mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move the user CSS settings file
Move the CSS settings file to a location based on XDG_CONFIG_HOME which is OS dependant but with slight changes for Windows and OS X. - Windows: CSIDL_APPDATA/Gnucash - OS X: $HOME/Application Support/Gnucash - Linux: $XDG_CONFIG_HOME/gnucash (or the default $HOME/.config/gnucash)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user