diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/preferences.c | 63 | ||||
-rw-r--r-- | src/config/preferences.h | 6 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index a3d9276a..2051e66b 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -65,6 +65,8 @@ static GKeyFile *prefs; gint log_maxsize = 0; static Autocomplete boolean_choice_ac; +static Autocomplete message_trigger_ac; +static Autocomplete room_trigger_ac; static void _save_prefs(void); static gchar* _get_preferences_file(void); @@ -133,12 +135,33 @@ prefs_load(void) boolean_choice_ac = autocomplete_new(); autocomplete_add(boolean_choice_ac, "on"); autocomplete_add(boolean_choice_ac, "off"); + + message_trigger_ac = autocomplete_new(); + gsize len = 0; + gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL); + + int i; + for (i = 0; i < len; i++) { + autocomplete_add(message_trigger_ac, triggers[i]); + } + g_strfreev(triggers); + + room_trigger_ac = autocomplete_new(); + len = 0; + triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL); + + for (i = 0; i < len; i++) { + autocomplete_add(room_trigger_ac, triggers[i]); + } + g_strfreev(triggers); } void prefs_close(void) { autocomplete_free(boolean_choice_ac); + autocomplete_free(message_trigger_ac); + autocomplete_free(room_trigger_ac); g_key_file_free(prefs); prefs = NULL; } @@ -155,6 +178,30 @@ prefs_reset_boolean_choice(void) autocomplete_reset(boolean_choice_ac); } +char* +prefs_autocomplete_message_trigger(const char *const prefix) +{ + return autocomplete_complete(message_trigger_ac, prefix, TRUE); +} + +void +prefs_reset_message_trigger_ac(void) +{ + autocomplete_reset(message_trigger_ac); +} + +char* +prefs_autocomplete_room_trigger(const char *const prefix) +{ + return autocomplete_complete(room_trigger_ac, prefix, TRUE); +} + +void +prefs_reset_room_trigger_ac(void) +{ + autocomplete_reset(room_trigger_ac); +} + gboolean prefs_get_boolean(preference_t pref) { @@ -613,6 +660,10 @@ prefs_add_msg_notify_trigger(const char * const text) gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text); _save_prefs(); + if (res) { + autocomplete_add(message_trigger_ac, text); + } + return res; } @@ -622,6 +673,10 @@ prefs_remove_msg_notify_trigger(const char * const text) gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text); _save_prefs(); + if (res) { + autocomplete_remove(message_trigger_ac, text); + } + return res; } @@ -648,6 +703,10 @@ prefs_add_room_notify_trigger(const char * const text) gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text); _save_prefs(); + if (res) { + autocomplete_add(room_trigger_ac, text); + } + return res; } @@ -657,6 +716,10 @@ prefs_remove_room_notify_trigger(const char * const text) gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text); _save_prefs(); + if (res) { + autocomplete_remove(room_trigger_ac, text); + } + return res; } diff --git a/src/config/preferences.h b/src/config/preferences.h index acf62ddb..9038591d 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -135,9 +135,15 @@ void prefs_close(void); char* prefs_find_login(char *prefix); void prefs_reset_login_search(void); + char* prefs_autocomplete_boolean_choice(const char *const prefix); void prefs_reset_boolean_choice(void); +char* prefs_autocomplete_message_trigger(const char *const prefix); +void prefs_reset_message_trigger_ac(void); +char* prefs_autocomplete_room_trigger(const char *const prefix); +void prefs_reset_room_trigger_ac(void); + gint prefs_get_gone(void); void prefs_set_gone(gint value); |