diff options
author | James Booth <boothj5@gmail.com> | 2012-05-10 22:44:23 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-05-10 22:44:23 +0100 |
commit | 5e3962a129c32e5c7f4304124a22987158f75d0b (patch) | |
tree | f7ecfcc985249338cbee1b1fa9d3e97dd156bd47 | |
parent | 4e23031c7444d64fb93c1f044f71e0df331e0ecd (diff) | |
download | profani-tty-5e3962a129c32e5c7f4304124a22987158f75d0b.tar.gz |
Create GSList of jids on preferences load
-rw-r--r-- | preferences.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/preferences.c b/preferences.c index 2b16e000..ebf9b274 100644 --- a/preferences.c +++ b/preferences.c @@ -28,7 +28,13 @@ static GString *prefs_loc; static GKeyFile *prefs; +// search logins list +static GSList *logins = NULL; +//static GSList *last_found = NULL; +//static gchar *search_str = NULL; + static void _save_prefs(void); +static gint _compare_jids(gconstpointer a, gconstpointer b); void prefs_load(void) { @@ -37,6 +43,24 @@ void prefs_load(void) prefs = g_key_file_new(); g_key_file_load_from_file(prefs, prefs_loc->str, G_KEY_FILE_NONE, NULL); + + // create the logins searchable list for autocompletion + gsize njids; + gchar **jids = + g_key_file_get_string_list(prefs, "connections", "logins", &njids, NULL); + + gsize i; + for (i = 0; i < njids; i++) { + logins = g_slist_insert_sorted(logins, jids[0], _compare_jids); + } +} + +static gint _compare_jids(gconstpointer a, gconstpointer b) +{ + const gchar *str_a = (const gchar *) a; + const gchar *str_b = (const gchar *) b; + + return g_strcmp0(str_a, str_b); } gboolean prefs_get_beep(void) |