diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2007-06-05 11:27:58 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2007-06-05 11:27:58 +0000 |
commit | 1e5554a20312775a8773328fc81552c8e1eb0064 (patch) | |
tree | 77040f5efe0d24e2cc05f07fdaed4f3f1877d363 /src/fe-common | |
parent | b228bb30f5c89767db42e5cd27ae11143b456bb6 (diff) | |
download | irssi-1e5554a20312775a8773328fc81552c8e1eb0064.zip |
Remove code duplication.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4539 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/completion.c | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index d4e69798..88e9b029 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -344,7 +344,7 @@ GList *filename_complete(const char *path, const char *default_path) return list; } -static GList *completion_get_settings(const char *key) +static GList *completion_get_settings(const char *key, SettingType type) { GList *complist; GSList *tmp, *sets; @@ -359,29 +359,7 @@ static GList *completion_get_settings(const char *key) for (tmp = sets; tmp != NULL; tmp = tmp->next) { SETTINGS_REC *rec = tmp->data; - if (g_strncasecmp(rec->key, key, len) == 0) - complist = g_list_insert_sorted(complist, g_strdup(rec->key), (GCompareFunc) g_istr_cmp); - } - g_slist_free(sets); - return complist; -} - -static GList *completion_get_bool_settings(const char *key) -{ - GList *complist; - GSList *tmp, *sets; - int len; - - g_return_val_if_fail(key != NULL, NULL); - - sets = settings_get_sorted(); - - len = strlen(key); - complist = NULL; - for (tmp = sets; tmp != NULL; tmp = tmp->next) { - SETTINGS_REC *rec = tmp->data; - - if (rec->type == SETTING_TYPE_BOOLEAN && + if ((type == -1 || rec->type == type) && g_strncasecmp(rec->key, key, len) == 0) complist = g_list_insert_sorted(complist, g_strdup(rec->key), (GCompareFunc) g_istr_cmp); } @@ -701,7 +679,7 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, if (*line != '\0') return; - *list = completion_get_settings(word); + *list = completion_get_settings(word, -1); if (*list != NULL) signal_stop(); } @@ -714,7 +692,7 @@ static void sig_complete_toggle(GList **list, WINDOW_REC *window, if (*line != '\0') return; - *list = completion_get_bool_settings(word); + *list = completion_get_settings(word, SETTING_TYPE_BOOLEAN); if (*list != NULL) signal_stop(); } |