diff --git a/applets/cosmic-applet-power/src/main.rs b/applets/cosmic-applet-power/src/main.rs index e65378ee..91dd5b4e 100644 --- a/applets/cosmic-applet-power/src/main.rs +++ b/applets/cosmic-applet-power/src/main.rs @@ -28,6 +28,7 @@ fn build_ui(application: >k4::Application) { .default_height(300) .build(); + let session_section = ui::session::build(); let system_section = ui::system::build(); view! { main_box = gtk4::Box { @@ -38,6 +39,7 @@ fn build_ui(application: >k4::Application) { set_margin_start: 24, set_margin_end: 24, append: first_separator = &Separator {}, + append: &session_section, append: second_separator = &Separator {}, append: &system_section } diff --git a/applets/cosmic-applet-power/src/ui/session.rs b/applets/cosmic-applet-power/src/ui/session.rs index 40f1a64e..daa78997 100644 --- a/applets/cosmic-applet-power/src/ui/session.rs +++ b/applets/cosmic-applet-power/src/ui/session.rs @@ -1 +1,49 @@ // SPDX-License-Identifier: LGPL-3.0-or-later + +use gtk4::{prelude::*, Align, Button, Image, Label, Orientation}; + +pub fn build() -> gtk4::Box { + view! { + inner_box = gtk4::Box { + set_orientation: Orientation::Vertical, + set_spacing: 5, + append: lock_screen_button = &Button { + set_child: lock_screen_box = Some(>k4::Box) { + set_orientation: Orientation::Horizontal, + set_spacing: 10, + append: lock_screen_icon = &Image { + set_icon_name: Some("system-lock-screen-symbolic"), + }, + append: lock_screen_label = &Label { + set_label: "Lock Screen", + set_halign: Align::Start, + set_hexpand: true + }, + append: lock_screen_hotkey_label = &Label { + set_label: "Super + Escape", + set_halign: Align::End + } + } + }, + append: log_out_button = &Button { + set_child: log_out_box = Some(>k4::Box) { + set_orientation: Orientation::Horizontal, + set_spacing: 10, + append: log_out_icon = &Image { + set_icon_name: Some("system-log-out-symbolic"), + }, + append: log_out_label = &Label { + set_label: "Log Out", + set_halign: Align::Start, + set_hexpand: true + }, + append: log_out_hotkey_label = &Label { + set_label: "Ctrl + Alt + Delete", + set_halign: Align::End + } + } + } + } + } + inner_box +} diff --git a/applets/cosmic-applet-power/src/ui/system.rs b/applets/cosmic-applet-power/src/ui/system.rs index 89aa4a76..d0a3c7a4 100644 --- a/applets/cosmic-applet-power/src/ui/system.rs +++ b/applets/cosmic-applet-power/src/ui/system.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later use crate::RT; -use gtk4::{prelude::*, Align, Button, IconSize, Image, Label, Orientation}; +use gtk4::{prelude::*, Button, IconSize, Image, Label, Orientation}; use logind_zbus::manager::ManagerProxy; use zbus::Connection;