fix(wired): display known connections when unplugged
This commit is contained in:
parent
ccb0449d1c
commit
eb1d5457d4
2 changed files with 11 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1646,7 +1646,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-settings-subscriptions"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/cosmic-settings-subscriptions#90df5c4b22c47f0e0213dcf2025519b0312437df"
|
||||
source = "git+https://github.com/pop-os/cosmic-settings-subscriptions#ece1b2475c9eb90e0f2042b743577670e799a010"
|
||||
dependencies = [
|
||||
"cosmic-dbus-networkmanager",
|
||||
"futures",
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ use cosmic::{
|
|||
widget::{self, icon},
|
||||
Apply, Command, Element,
|
||||
};
|
||||
use cosmic_dbus_networkmanager::interface::enums::DeviceState;
|
||||
use cosmic_settings_page::{self as page, section, Section};
|
||||
use cosmic_settings_subscriptions::network_manager::{
|
||||
self, current_networks::ActiveConnectionInfo, devices::DeviceState, NetworkManagerState,
|
||||
self, current_networks::ActiveConnectionInfo, NetworkManagerState,
|
||||
};
|
||||
|
||||
pub type ConnectionId = Arc<str>;
|
||||
|
|
@ -446,13 +447,14 @@ impl Page {
|
|||
remove_txt: &'a str,
|
||||
settings_txt: &'a str,
|
||||
wired_conns_txt: &'a str,
|
||||
unplugged_txt: &'a str,
|
||||
device: &'a network_manager::devices::DeviceInfo,
|
||||
) -> Element<'a, Message> {
|
||||
let has_multiple_connection_profiles = device.available_connections.len() > 1;
|
||||
let has_multiple_connection_profiles = device.known_connections.len() > 1;
|
||||
let header_txt = format!("{}", wired_conns_txt);
|
||||
|
||||
device
|
||||
.available_connections
|
||||
.known_connections
|
||||
.iter()
|
||||
.fold(
|
||||
widget::settings::section().title(header_txt),
|
||||
|
|
@ -467,6 +469,8 @@ impl Page {
|
|||
|
||||
let (connect_txt, connect_msg) = if is_connected {
|
||||
(connected_txt, None)
|
||||
} else if device.state == DeviceState::Unavailable {
|
||||
(unplugged_txt, None)
|
||||
} else {
|
||||
(
|
||||
connect_txt,
|
||||
|
|
@ -552,6 +556,7 @@ fn devices_view() -> Section<crate::pages::Message> {
|
|||
connected_txt = fl!("connected");
|
||||
settings_txt = fl!("settings");
|
||||
disconnect_txt = fl!("disconnect");
|
||||
unplugged_txt = fl!("network-device-state", "unplugged");
|
||||
});
|
||||
|
||||
Section::default()
|
||||
|
|
@ -570,8 +575,7 @@ fn devices_view() -> Section<crate::pages::Message> {
|
|||
let active_device = page
|
||||
.active_device
|
||||
.as_ref()
|
||||
.or_else(|| (nm_state.devices.len() == 1).then(|| nm_state.devices.get(0))?)
|
||||
.filter(|device| !matches!(device.state, DeviceState::Unavailable));
|
||||
.or_else(|| (nm_state.devices.len() == 1).then(|| nm_state.devices.get(0))?);
|
||||
|
||||
view = match active_device {
|
||||
Some(device) => view.push(page.device_view(
|
||||
|
|
@ -583,6 +587,7 @@ fn devices_view() -> Section<crate::pages::Message> {
|
|||
§ion.descriptions[remove_txt],
|
||||
§ion.descriptions[settings_txt],
|
||||
§ion.descriptions[wired_conns_txt],
|
||||
§ion.descriptions[unplugged_txt],
|
||||
device,
|
||||
)),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue