mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
cli: sort external connections later in nmcli connection|device
EXTERNAL connections are special. Sort them later. This affects output of `nmcli connection` and `nmcli device`.
This commit is contained in:
parent
8ccd1f7bfe
commit
a5f9f2fbfc
1 changed files with 10 additions and 4 deletions
|
|
@ -300,21 +300,27 @@ active_connection_get_state_ord(NMActiveConnection *active)
|
||||||
};
|
};
|
||||||
NMActiveConnectionState state;
|
NMActiveConnectionState state;
|
||||||
int i;
|
int i;
|
||||||
|
gboolean is_external;
|
||||||
|
|
||||||
/* returns an integer related to @active's state, that can be used for sorting
|
/* returns an integer related to @active's state, that can be used for sorting
|
||||||
* active connections based on their activation state. */
|
* active connections based on their activation state. */
|
||||||
|
|
||||||
if (!active)
|
if (!active)
|
||||||
return -2;
|
return -10;
|
||||||
|
|
||||||
state = nm_active_connection_get_state(active);
|
state = nm_active_connection_get_state(active);
|
||||||
|
is_external = NM_FLAGS_HAS(nm_active_connection_get_state_flags(active),
|
||||||
|
NM_ACTIVATION_STATE_FLAG_EXTERNAL);
|
||||||
|
|
||||||
for (i = 0; i < (int) G_N_ELEMENTS(ordered_states); i++) {
|
for (i = 0; i < (int) G_N_ELEMENTS(ordered_states); i++) {
|
||||||
if (state == ordered_states[i])
|
if (state == ordered_states[i]) {
|
||||||
|
if (!is_external)
|
||||||
|
i += G_N_ELEMENTS(ordered_states);
|
||||||
return i;
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return is_external ? -2 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue