Commit ed824102 authored by Beniamino Galvani's avatar Beniamino Galvani

cli: fix completion of connection types

Return only main settings and the special slave types.
parent 07cba180
......@@ -1137,8 +1137,13 @@ _rl_compentry_func_wrap_fcn (const char *text, int state)
{
g_return_val_if_fail (_rl_compentry_func_wrap.initialized, NULL);
if ( !_rl_compentry_func_wrap.values
|| !_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]) {
while ( _rl_compentry_func_wrap.values
&& _rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]
&& !g_str_has_prefix (_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx], text))
_rl_compentry_func_wrap.idx++;
if ( !_rl_compentry_func_wrap.values
|| !_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]) {
g_strfreev (_rl_compentry_func_wrap.values);
_rl_compentry_func_wrap.values = NULL;
_rl_compentry_func_wrap.initialized = FALSE;
......
......@@ -4979,10 +4979,29 @@ gen_cmd_save (const char *text, int state)
static rl_compentry_func_t *
gen_connection_types (const char *text)
{
gs_strfreev char **values = NULL;
gs_free char **values = NULL;
const NMMetaSettingInfoEditor *editor;
GPtrArray *array;
int i;
array = g_ptr_array_new ();
for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) {
editor = &nm_meta_setting_infos_editor[i];
if (!editor->valid_parts)
continue;
g_ptr_array_add (array, (gpointer) nm_meta_setting_infos[i].setting_name);
if (editor->alias)
g_ptr_array_add (array, (gpointer) editor->alias);
}
g_ptr_array_add (array, "bond-slave");
g_ptr_array_add (array, "bridge-slave");
g_ptr_array_add (array, "team-slave");
g_ptr_array_add (array, NULL);
values = (char **) g_ptr_array_free (array, FALSE);
values = _meta_abstract_complete ((const NMMetaAbstractInfo *) nm_meta_property_info_connection_type,
text);
return nmc_rl_compentry_func_wrap ((const char *const*) values);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment