diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/preferences.c | 39 | ||||
-rw-r--r-- | src/config/preferences.h | 8 |
2 files changed, 38 insertions, 9 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index b709ecd3..6e7ab576 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -52,6 +52,7 @@ #include "preferences.h" #include "tools/autocomplete.h" +// preference groups refer to the sections in .profrc, for example [ui] #define PREF_GROUP_LOGGING "logging" #define PREF_GROUP_CHATSTATES "chatstates" #define PREF_GROUP_UI "ui" @@ -127,6 +128,16 @@ prefs_load(void) g_error_free(err); } + // move pre 0.4.6 titlebar preference + err = NULL; + gchar *old_titlebar = g_key_file_get_string(prefs, PREF_GROUP_UI, "titlebar", &err); + if (err == NULL) { + g_key_file_set_string(prefs, PREF_GROUP_UI, _get_key(PREF_TITLEBAR_SHOW), old_titlebar); + g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar", NULL); + } else { + g_error_free(err); + } + _save_prefs(); boolean_choice_ac = autocomplete_new(); @@ -487,6 +498,9 @@ _get_preferences_file(void) return result; } +// get the preference group for a specific preference +// for example the PREF_BEEP setting ("beep" in .profrc, see _get_key) belongs +// to the [ui] section. static const char * _get_group(preference_t pref) { @@ -496,8 +510,8 @@ _get_group(preference_t pref) case PREF_BEEP: case PREF_THEME: case PREF_VERCHECK: - case PREF_TITLEBAR: - case PREF_EXIT_TITLE: + case PREF_TITLEBAR_SHOW: + case PREF_TITLEBAR_GOODBYE: case PREF_FLASH: case PREF_INTYPE: case PREF_HISTORY: @@ -515,6 +529,8 @@ _get_group(preference_t pref) case PREF_ROSTER_OFFLINE: case PREF_ROSTER_RESOURCE: case PREF_ROSTER_BY: + case PREF_RESOURCE_TITLE: + case PREF_RESOURCE_MESSAGE: return PREF_GROUP_UI; case PREF_STATES: case PREF_OUTTYPE: @@ -551,6 +567,8 @@ _get_group(preference_t pref) } } +// get the key used in .profrc for the preference +// for example the PREF_AUTOAWAY_MODE maps to "autoaway.mode" in .profrc static const char * _get_key(preference_t pref) { @@ -564,8 +582,10 @@ _get_key(preference_t pref) return "theme"; case PREF_VERCHECK: return "vercheck"; - case PREF_TITLEBAR: - return "titlebar"; + case PREF_TITLEBAR_SHOW: + return "titlebar.show"; + case PREF_TITLEBAR_GOODBYE: + return "titlebar.goodbye"; case PREF_FLASH: return "flash"; case PREF_INTYPE: @@ -648,13 +668,17 @@ _get_key(preference_t pref) return "roster.resource"; case PREF_ROSTER_BY: return "roster.by"; - case PREF_EXIT_TITLE: - return "exit.title"; + case PREF_RESOURCE_TITLE: + return "resource.title"; + case PREF_RESOURCE_MESSAGE: + return "resource.message"; default: return NULL; } } +// the default setting for a boolean type preference +// if it is not specified in .profrc static gboolean _get_default_boolean(preference_t pref) { @@ -672,13 +696,14 @@ _get_default_boolean(preference_t pref) case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: case PREF_WRAP: - case PREF_EXIT_TITLE: return TRUE; default: return FALSE; } } +// the default setting for a string type preference +// if it is not specified in .profrc static char * _get_default_string(preference_t pref) { diff --git a/src/config/preferences.h b/src/config/preferences.h index 3302cca5..a0ad2f84 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -47,12 +47,15 @@ #define PREFS_MIN_LOG_SIZE 64 #define PREFS_MAX_LOG_SIZE 1048580 +// represents all settings in .profrc +// each enum value is mapped to a group and key in .profrc (see preferences.c) typedef enum { PREF_SPLASH, PREF_BEEP, PREF_VERCHECK, PREF_THEME, - PREF_TITLEBAR, + PREF_TITLEBAR_SHOW, + PREF_TITLEBAR_GOODBYE, PREF_FLASH, PREF_INTYPE, PREF_HISTORY, @@ -96,7 +99,8 @@ typedef enum { PREF_OTR_LOG, PREF_OTR_WARN, PREF_OTR_POLICY, - PREF_EXIT_TITLE, + PREF_RESOURCE_TITLE, + PREF_RESOURCE_MESSAGE } preference_t; typedef struct prof_alias_t { |