[epiphany/wip/tingping/profile-migration: 103/105] Store web extension settings in config dir
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/tingping/profile-migration: 103/105] Store web extension settings in config dir
- Date: Thu, 31 Jan 2019 22:31:14 +0000 (UTC)
commit 4a16af4650f45b7906c3ab0da63c85d90440c008
Author: Patrick Griffis <pgriffis igalia com>
Date: Mon Dec 24 09:38:17 2018 -0500
Store web extension settings in config dir
lib/ephy-file-helpers.c | 37 +++++++++++++++++++++++++++++++++++++
lib/ephy-file-helpers.h | 2 ++
lib/ephy-settings.c | 2 +-
3 files changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 184e963b2..024a5a686 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -70,6 +70,7 @@ static GHashTable *mime_table;
static gboolean keep_directory;
static char *profile_dir_global;
static char *cache_dir;
+static char *config_dir;
static char *tmp_dir;
static EphyProfileDirType profile_dir_type;
@@ -231,6 +232,20 @@ ephy_profile_dir (void)
return profile_dir_global;
}
+/**
+ * ephy_config_dir:
+ *
+ * Gets Epiphany's configuration directory, usually .config/epiphany
+ * under user's homedir.
+ *
+ * Returns: the full path to Epiphany's configuration directory
+ **/
+const char *
+ephy_config_dir (void)
+{
+ return config_dir;
+}
+
/**
* ephy_cache_dir:
*
@@ -303,6 +318,21 @@ ephy_default_cache_dir (void)
g_build_filename (g_get_user_cache_dir (), "epiphany", NULL);
}
+/**
+ * ephy_default_config_dir:
+ *
+ * Get the path to the default config directory found in ~/.config
+ *
+ * Returns: a new allocated string, free with g_free() when done.
+ */
+char *
+ephy_default_config_dir (void)
+{
+ return profile_dir_type == EPHY_PROFILE_DIR_TEST ?
+ g_build_filename (ephy_profile_dir (), "config", NULL) :
+ g_build_filename (g_get_user_config_dir (), "epiphany", NULL);
+}
+
/**
* ephy_file_helpers_init:
* @profile_dir: directory to use as Epiphany's profile
@@ -347,6 +377,7 @@ ephy_file_helpers_init (const char *profile_dir,
if (g_file_test (app_file, G_FILE_TEST_EXISTS)) {
const char *app_name = ephy_web_application_get_program_name_from_profile_directory
(profile_dir_global);
cache_dir = g_build_filename (g_get_user_cache_dir (), app_name, NULL);
+ config_dir = g_build_filename (g_get_user_config_dir (), app_name, NULL);
profile_dir_type = EPHY_PROFILE_DIR_WEB_APP;
}
} else if (private_profile) {
@@ -363,6 +394,7 @@ ephy_file_helpers_init (const char *profile_dir,
"epiphany",
NULL);
cache_dir = g_build_filename (profile_dir_global, "cache", NULL);
+ config_dir = g_build_filename (profile_dir_global, "config", NULL);
if (flags & EPHY_FILE_HELPERS_TESTING_MODE)
profile_dir_type = EPHY_PROFILE_DIR_TEST;
}
@@ -375,9 +407,13 @@ ephy_file_helpers_init (const char *profile_dir,
if (cache_dir == NULL)
cache_dir = ephy_default_cache_dir ();
+ if (config_dir == NULL)
+ config_dir = ephy_default_config_dir ();
+
if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS) {
ret = ephy_ensure_dir_exists (ephy_profile_dir (), error);
ephy_ensure_dir_exists (ephy_cache_dir (), NULL);
+ ephy_ensure_dir_exists (ephy_config_dir (), NULL);
}
if (steal_data_from_profile && profile_dir) {
@@ -435,6 +471,7 @@ ephy_file_helpers_shutdown (void)
g_clear_pointer (&profile_dir_global, g_free);
g_clear_pointer (&cache_dir, g_free);
+ g_clear_pointer (&config_dir, g_free);
if (tmp_dir != NULL) {
if (!keep_directory) {
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index f5373a6d5..7b1e2413f 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -60,8 +60,10 @@ const char * ephy_profile_dir (void);
gboolean ephy_profile_dir_is_default (void);
gboolean ephy_profile_dir_is_web_application (void);
const char * ephy_cache_dir (void);
+const char * ephy_config_dir (void);
char * ephy_default_profile_dir (void);
char * ephy_default_cache_dir (void);
+char * ephy_default_config_dir (void);
void ephy_file_helpers_shutdown (void);
char * ephy_file_get_downloads_dir (void);
char * ephy_file_desktop_dir (void);
diff --git a/lib/ephy-settings.c b/lib/ephy-settings.c
index 16f5d72bc..97e6a631a 100644
--- a/lib/ephy-settings.c
+++ b/lib/ephy-settings.c
@@ -195,7 +195,7 @@ ephy_settings_get_for_web_extension (const char *schema)
return gsettings;
}
- g_autofree char *keyfile_path = g_build_filename (ephy_profile_dir (), "web-extension-settings.ini",
NULL);
+ g_autofree char *keyfile_path = g_build_filename (ephy_config_dir (), "web-extension-settings.ini",
NULL);
backend = g_keyfile_settings_backend_new (keyfile_path, "/", "/");
GSettings *web_gsettings;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]