From 02fb6e145a36c5c77b0e25cf1b2cb164d76a4186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:45:44 +0200 Subject: [PATCH] cargo fmt --- cosmic-applet-network/src/app.rs | 35 ++++++----- .../src/network_manager/available_vpns.rs | 5 +- .../src/network_manager/mod.rs | 59 +++++++++++++++---- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index 22925fef..a89932fd 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -138,9 +138,8 @@ fn vpn_section<'a>( "go-down-symbolic" }; - vpn_col = vpn_col.push( - padded_control(divider::horizontal::default()).padding([space_xxs, space_s]) - ); + vpn_col = vpn_col + .push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s])); let vpn_toggle_btn = menu_button(row![ text::body(fl!("vpn-connections")) @@ -166,17 +165,11 @@ fn vpn_section<'a>( .size(24) .symbolic(true) .into(), - text::body(&vpn.name) - .width(Length::Fill) - .into(), + text::body(&vpn.name).width(Length::Fill).into(), ]; if is_active { - btn_content.push( - text::body(fl!("connected")) - .align_x(Alignment::End) - .into(), - ); + btn_content.push(text::body(fl!("connected")).align_x(Alignment::End).into()); } let mut btn = menu_button( @@ -323,9 +316,9 @@ pub(crate) enum Message { OpenHwDevice(Option), TogglePasswordVisibility, Surface(surface::Action), - ActivateVpn(String), // UUID of VPN to activate - DeactivateVpn(String), // Name of VPN to deactivate - ToggleVpnList, // Show/hide available VPNs + ActivateVpn(String), // UUID of VPN to activate + DeactivateVpn(String), // Name of VPN to deactivate + ToggleVpnList, // Show/hide available VPNs } impl cosmic::Application for CosmicNetworkApplet { @@ -1086,7 +1079,12 @@ impl cosmic::Application for CosmicNetworkApplet { if !self.show_visible_networks { if !self.nm_state.available_vpns.is_empty() { - content = content.push(vpn_section(&self.nm_state, self.show_available_vpns, space_xxs, space_s)); + content = content.push(vpn_section( + &self.nm_state, + self.show_available_vpns, + space_xxs, + space_s, + )); } return self.view_window_return(content); } @@ -1234,7 +1232,12 @@ impl cosmic::Application for CosmicNetworkApplet { // Add VPN connections section after wireless networks when they are expanded if !self.nm_state.available_vpns.is_empty() { - content = content.push(vpn_section(&self.nm_state, self.show_available_vpns, space_xxs, space_s)); + content = content.push(vpn_section( + &self.nm_state, + self.show_available_vpns, + space_xxs, + space_s, + )); } self.view_window_return(content) diff --git a/cosmic-applet-network/src/network_manager/available_vpns.rs b/cosmic-applet-network/src/network_manager/available_vpns.rs index 2df3d75b..ae9a467e 100644 --- a/cosmic-applet-network/src/network_manager/available_vpns.rs +++ b/cosmic-applet-network/src/network_manager/available_vpns.rs @@ -29,7 +29,10 @@ pub async fn load_vpn_connections(conn: &Connection) -> anyhow::Result { - tracing::info!("Successfully activated VPN: {}", uuid); + tracing::info!( + "Successfully activated VPN: {}", + uuid + ); success = true; } Err(e) => { - tracing::error!("Failed to activate VPN {}: {:?}", uuid, e); + tracing::error!( + "Failed to activate VPN {}: {:?}", + uuid, + e + ); } } break; @@ -337,7 +354,10 @@ async fn start_listening( } if !success { - tracing::warn!("VPN connection with UUID {} not found or failed to activate", uuid); + tracing::warn!( + "VPN connection with UUID {} not found or failed to activate", + uuid + ); } let state = NetworkManagerState::new(&conn).await.unwrap_or_default(); @@ -359,7 +379,9 @@ async fn start_listening( .send(NetworkManagerEvent::RequestResponse { req: NetworkManagerRequest::DeactivateVpn(name), success: false, - state: NetworkManagerState::new(&conn).await.unwrap_or_default(), + state: NetworkManagerState::new(&conn) + .await + .unwrap_or_default(), }) .await; return State::Waiting(conn, rx); @@ -373,14 +395,22 @@ async fn start_listening( for active_conn in active_connections { if let Ok(conn_id) = active_conn.id().await { if conn_id == name && active_conn.vpn().await.unwrap_or(false) { - match network_manager.deactivate_connection(&active_conn).await { + match network_manager.deactivate_connection(&active_conn).await + { Ok(_) => { - tracing::info!("Successfully deactivated VPN: {}", name); + tracing::info!( + "Successfully deactivated VPN: {}", + name + ); success = true; break; } Err(e) => { - tracing::error!("Failed to deactivate VPN {}: {:?}", name, e); + tracing::error!( + "Failed to deactivate VPN {}: {:?}", + name, + e + ); } } } @@ -389,7 +419,10 @@ async fn start_listening( } if !success { - tracing::warn!("Active VPN connection '{}' not found or failed to deactivate", name); + tracing::warn!( + "Active VPN connection '{}' not found or failed to deactivate", + name + ); } let state = NetworkManagerState::new(&conn).await.unwrap_or_default(); @@ -479,8 +512,8 @@ pub enum NetworkManagerRequest { }, Forget(String, HwAddress), Reload, - ActivateVpn(String), // UUID of VPN connection to activate - DeactivateVpn(String), // Name of active VPN connection to deactivate + ActivateVpn(String), // UUID of VPN connection to activate + DeactivateVpn(String), // Name of active VPN connection to deactivate } #[derive(Debug, Clone)]