mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Remove code duplication.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4539 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
b228bb30f5
commit
1e5554a203
@ -344,7 +344,7 @@ GList *filename_complete(const char *path, const char *default_path)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *completion_get_settings(const char *key)
|
static GList *completion_get_settings(const char *key, SettingType type)
|
||||||
{
|
{
|
||||||
GList *complist;
|
GList *complist;
|
||||||
GSList *tmp, *sets;
|
GSList *tmp, *sets;
|
||||||
@ -359,29 +359,7 @@ static GList *completion_get_settings(const char *key)
|
|||||||
for (tmp = sets; tmp != NULL; tmp = tmp->next) {
|
for (tmp = sets; tmp != NULL; tmp = tmp->next) {
|
||||||
SETTINGS_REC *rec = tmp->data;
|
SETTINGS_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (g_strncasecmp(rec->key, key, len) == 0)
|
if ((type == -1 || rec->type == type) &&
|
||||||
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 &&
|
|
||||||
g_strncasecmp(rec->key, key, len) == 0)
|
g_strncasecmp(rec->key, key, len) == 0)
|
||||||
complist = g_list_insert_sorted(complist, g_strdup(rec->key), (GCompareFunc) g_istr_cmp);
|
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;
|
if (*line != '\0') return;
|
||||||
|
|
||||||
*list = completion_get_settings(word);
|
*list = completion_get_settings(word, -1);
|
||||||
if (*list != NULL) signal_stop();
|
if (*list != NULL) signal_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,7 +692,7 @@ static void sig_complete_toggle(GList **list, WINDOW_REC *window,
|
|||||||
|
|
||||||
if (*line != '\0') return;
|
if (*line != '\0') return;
|
||||||
|
|
||||||
*list = completion_get_bool_settings(word);
|
*list = completion_get_settings(word, SETTING_TYPE_BOOLEAN);
|
||||||
if (*list != NULL) signal_stop();
|
if (*list != NULL) signal_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user