mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 07:50:17 +01:00
nmtui: correctly check that connection list is non-empty
Previously, the "edit" or "delete" buttons were clickable even
if there were no available connections, which was not expected
and caused an assertion to fail when clicked. This is because
the connections list could contain connections that were later
filtered out and not displayed in the final list, but the check
did not take this into account.
Make it so that the buttons are clickable only if we *actually*
have any available connections to edit or delete.
Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1991
This commit is contained in:
parent
abbaa9b629
commit
c9fefcd095
1 changed files with 12 additions and 5 deletions
|
|
@ -154,7 +154,7 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list)
|
|||
NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE(list);
|
||||
const GPtrArray *connections;
|
||||
GSList *iter;
|
||||
gboolean did_header = FALSE, did_vpn = FALSE;
|
||||
gboolean did_header = FALSE, did_vpn = FALSE, did_any = FALSE;
|
||||
NMEditorConnectionTypeData **types;
|
||||
NMConnection *conn, *selected_conn;
|
||||
int i, row, selected_row;
|
||||
|
|
@ -181,9 +181,6 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list)
|
|||
g_object_notify(G_OBJECT(list), "connections");
|
||||
g_object_notify(G_OBJECT(list), "num-connections");
|
||||
|
||||
nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->edit), priv->connections != NULL);
|
||||
nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->delete), priv->connections != NULL);
|
||||
|
||||
nmt_newt_listbox_clear(priv->listbox);
|
||||
|
||||
if (!priv->grouped) {
|
||||
|
|
@ -198,7 +195,9 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list)
|
|||
selected_row = row - 1;
|
||||
nmt_newt_listbox_set_active(priv->listbox, selected_row);
|
||||
|
||||
return;
|
||||
did_any = !!priv->connections;
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
types = nm_editor_utils_get_connection_type_list();
|
||||
|
|
@ -230,6 +229,10 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list)
|
|||
did_header = TRUE;
|
||||
}
|
||||
|
||||
if (!did_any) {
|
||||
did_any = TRUE;
|
||||
}
|
||||
|
||||
indented = g_strdup_printf(" %s", nm_connection_get_id(conn));
|
||||
nmt_newt_listbox_append(priv->listbox, indented, conn);
|
||||
g_free(indented);
|
||||
|
|
@ -243,6 +246,10 @@ nmt_edit_connection_list_rebuild(NmtEditConnectionList *list)
|
|||
if (selected_row >= row)
|
||||
selected_row = row - 1;
|
||||
nmt_newt_listbox_set_active(priv->listbox, selected_row);
|
||||
|
||||
done:
|
||||
nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->edit), did_any);
|
||||
nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->delete), did_any);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue