diff options
author | William Wennerström <william@wstrm.dev> | 2020-12-03 16:43:07 +0100 |
---|---|---|
committer | William Wennerström <william@wstrm.dev> | 2020-12-03 16:54:06 +0100 |
commit | 3a6597ee2967f91f49a1b4e17cf0595f37064587 (patch) | |
tree | 82d021e0c76b6980d908952edd4402272f14dcab /src/config | |
parent | 1bb6cecee69d5167220a18cc4c125c215784de66 (diff) | |
download | profani-tty-3a6597ee2967f91f49a1b4e17cf0595f37064587.tar.gz |
Refactor for threaded external executable for built-in download methods
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/files.h | 19 | ||||
-rw-r--r-- | src/config/preferences.c | 49 | ||||
-rw-r--r-- | src/config/preferences.h | 1 |
3 files changed, 14 insertions, 55 deletions
diff --git a/src/config/files.h b/src/config/files.h index d5c96b0f..42499663 100644 --- a/src/config/files.h +++ b/src/config/files.h @@ -48,15 +48,16 @@ #define FILE_PROFANITY_IDENTIFIER "profident" #define FILE_BOOKMARK_AUTOJOIN_IGNORE "bookmark_ignore" -#define DIR_THEMES "themes" -#define DIR_ICONS "icons" -#define DIR_SCRIPTS "scripts" -#define DIR_CHATLOGS "chatlogs" -#define DIR_OTR "otr" -#define DIR_PGP "pgp" -#define DIR_OMEMO "omemo" -#define DIR_PLUGINS "plugins" -#define DIR_DATABASE "database" +#define DIR_THEMES "themes" +#define DIR_ICONS "icons" +#define DIR_SCRIPTS "scripts" +#define DIR_CHATLOGS "chatlogs" +#define DIR_OTR "otr" +#define DIR_PGP "pgp" +#define DIR_OMEMO "omemo" +#define DIR_PLUGINS "plugins" +#define DIR_DATABASE "database" +#define DIR_DOWNLOADS "downloads" void files_create_directories(void); diff --git a/src/config/preferences.c b/src/config/preferences.c index c7a74429..4b524fcf 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -81,7 +81,6 @@ static const char* _get_group(preference_t pref); static const char* _get_key(preference_t pref); static gboolean _get_default_boolean(preference_t pref); static char* _get_default_string(preference_t pref); -static char** _get_default_string_list(preference_t pref); static void _prefs_load(void) @@ -544,33 +543,6 @@ prefs_get_string_with_option(preference_t pref, gchar* option) return result; } -gchar** -prefs_get_string_list_with_option(preference_t pref, gchar* option) -{ - const char* group = _get_group(pref); - const char* key = _get_key(pref); - char** def = _get_default_string_list(pref); - - gchar** result = g_key_file_get_locale_string_list(prefs, group, key, option, NULL, NULL); - if (result) { - g_strfreev(def); - return result; - } - - result = g_key_file_get_string_list(prefs, group, key, NULL, NULL); - if (result) { - g_strfreev(def); - return result; - } - - if (def) { - return def; - } else { - g_strfreev(def); - return NULL; - } -} - void prefs_set_string(preference_t pref, char* value) { @@ -1893,6 +1865,7 @@ _get_group(preference_t pref) return PREF_GROUP_LOGGING; case PREF_AVATAR_CMD: case PREF_URL_OPEN_CMD: + return PREF_GROUP_EXECUTABLES; case PREF_URL_SAVE_CMD: return PREF_GROUP_EXECUTABLES; case PREF_AUTOAWAY_CHECK: @@ -2318,24 +2291,10 @@ _get_default_string(preference_t pref) return "false"; case PREF_AVATAR_CMD: return "xdg-open"; - default: - return NULL; - } -} - -// the default setting for a string list type preference -// if it is not specified in .profrc -static char** -_get_default_string_list(preference_t pref) -{ - char** str_array = NULL; - - switch (pref) { case PREF_URL_OPEN_CMD: - str_array = g_malloc0(3); - str_array[0] = g_strdup("false"); - str_array[1] = g_strdup("xdg-open %u"); - return str_array; + return "xdg-open %u"; + case PREF_URL_SAVE_CMD: + return NULL; // Default to built-in method. default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 141d8fce..bfad7d6b 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -320,7 +320,6 @@ gboolean prefs_get_boolean(preference_t pref); void prefs_set_boolean(preference_t pref, gboolean value); char* prefs_get_string(preference_t pref); char* prefs_get_string_with_option(preference_t pref, gchar* option); -gchar** prefs_get_string_list_with_option(preference_t pref, gchar* option); void prefs_set_string(preference_t pref, char* value); void prefs_set_string_with_option(preference_t pref, char* option, char* value); void prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values); |