diff --git a/applets/cosmic-applet-network/src/main.rs b/applets/cosmic-applet-network/src/main.rs
index bb608f9e..17c44462 100644
--- a/applets/cosmic-applet-network/src/main.rs
+++ b/applets/cosmic-applet-network/src/main.rs
@@ -5,6 +5,7 @@ extern crate relm4_macros;
pub mod task;
pub mod ui;
+pub mod widgets;
use gtk4::{gio::ApplicationFlags, prelude::*, Orientation};
use once_cell::sync::Lazy;
diff --git a/applets/cosmic-applet-network/src/ui/toggles.rs b/applets/cosmic-applet-network/src/ui/toggles.rs
index 2f84118d..d68bf0cf 100644
--- a/applets/cosmic-applet-network/src/ui/toggles.rs
+++ b/applets/cosmic-applet-network/src/ui/toggles.rs
@@ -1,27 +1,22 @@
-use gtk4::{prelude::*, Align, Label, Orientation, Separator, Switch};
+use crate::widgets::SettingsEntry;
+use gtk4::{prelude::*, Orientation, Separator, Switch};
pub fn add_toggles(target: >k4::Box) {
view! {
- airplane_mode_box = gtk4::Box {
- append: airplane_mode_label = &Label {
- set_markup: "Airplane Mode",
- set_halign: Align::Start
- },
- append: airplane_mode_switch = &Switch {}
+ airplane_mode = SettingsEntry {
+ set_title_markup: "Airplane Mode",
+ set_child: airplane_mode_switch = &Switch {}
}
}
view! {
- wifi_box = gtk4::Box {
- append: wifi_label = &Label {
- set_markup: "WiFi",
- set_halign: Align::Start
- },
- append: wifi_switch = &Switch {}
+ wifi = SettingsEntry {
+ set_title_markup: "WiFi",
+ set_child: wifi_switch = &Switch {}
}
}
- target.append(&airplane_mode_box);
+ target.append(&airplane_mode);
target.append(&Separator::new(Orientation::Horizontal));
- target.append(&wifi_box);
+ target.append(&wifi);
target.append(&Separator::new(Orientation::Horizontal));
}
diff --git a/applets/cosmic-applet-network/src/widgets.rs b/applets/cosmic-applet-network/src/widgets.rs
new file mode 100644
index 00000000..a92fff62
--- /dev/null
+++ b/applets/cosmic-applet-network/src/widgets.rs
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+mod settings_entry;
+
+pub use settings_entry::SettingsEntry;
diff --git a/applets/cosmic-applet-network/src/widgets/settings_entry.rs b/applets/cosmic-applet-network/src/widgets/settings_entry.rs
new file mode 100644
index 00000000..f1793637
--- /dev/null
+++ b/applets/cosmic-applet-network/src/widgets/settings_entry.rs
@@ -0,0 +1,214 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+use gtk4::{
+ glib::{self, Object},
+ prelude::*,
+ subclass::prelude::*,
+ Label,
+};
+use std::cell::RefCell;
+
+glib::wrapper! {
+ pub struct SettingsEntry(ObjectSubclass)
+ @extends gtk4::Widget,
+ @implements gtk4::Accessible;
+}
+
+impl SettingsEntry {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ pub fn set_child<'a, Widget, IntoWidget>(&self, child: IntoWidget)
+ where
+ Widget: IsA,
+ IntoWidget: Into