From eeebfe3033e14ce6a2082b7bade7cc3df7d820ab Mon Sep 17 00:00:00 2001 From: takotori Date: Sat, 28 Oct 2023 14:21:22 +0200 Subject: [PATCH] Add Bluetooth UI --- src/bluetooth/bluetoothBox.rs | 46 +++++++++++ src/bluetooth/bluetoothEntry.rs | 43 ++++++++++ src/bluetooth/mod.rs | 30 +++++++ src/main.rs | 1 + src/resources/resetBluetooth.ui | 109 ++++++++++++++++++++++++++ src/resources/resetBluetoothEntry.ui | 33 ++++++++ src/resources/resetUI.cmb | 91 +++++++++++++++++++-- src/resources/resetWiFi.ui | 18 +++++ src/resources/resources.gresource.xml | 2 + src/wifi/mod.rs | 6 +- src/wifi/wifiEntry.rs | 6 +- src/window/handleSidebarClick.rs | 9 ++- 12 files changed, 381 insertions(+), 13 deletions(-) create mode 100644 src/bluetooth/bluetoothBox.rs create mode 100644 src/bluetooth/bluetoothEntry.rs create mode 100644 src/bluetooth/mod.rs create mode 100644 src/resources/resetBluetooth.ui create mode 100644 src/resources/resetBluetoothEntry.ui diff --git a/src/bluetooth/bluetoothBox.rs b/src/bluetooth/bluetoothBox.rs new file mode 100644 index 0000000..fee523b --- /dev/null +++ b/src/bluetooth/bluetoothBox.rs @@ -0,0 +1,46 @@ +use gtk::{CompositeTemplate, glib, ListBox, Switch}; +use gtk::prelude::*; +use gtk::subclass::prelude::*; +use crate::bluetooth::BluetoothEntry; + +#[allow(non_snake_case)] +#[derive(Default, CompositeTemplate)] +#[template(resource = "/org/xetibo/reset/resetBluetooth.ui")] +pub struct BluetoothBox { + #[template_child] + pub resetBluetoothSwitch: TemplateChild, + #[template_child] + pub resetBluetoothAvailableDevices: TemplateChild, + #[template_child] + pub resetBluetoothConnectedDevices: TemplateChild, +} + +#[glib::object_subclass] +impl ObjectSubclass for BluetoothBox { + const NAME: &'static str = "resetBluetooth"; + type Type = super::BluetoothBox; + type ParentType = gtk::Box; + + fn class_init(klass: &mut Self::Class) { + BluetoothEntry::ensure_type(); + klass.bind_template(); + } + + fn instance_init(obj: &glib::subclass::InitializingObject) { + obj.init_template(); + } +} + +impl ObjectImpl for BluetoothBox { + fn constructed(&self) { + self.parent_constructed(); + } +} + +impl BoxImpl for BluetoothBox {} + +impl WidgetImpl for BluetoothBox {} + +impl WindowImpl for BluetoothBox {} + +impl ApplicationWindowImpl for BluetoothBox {} diff --git a/src/bluetooth/bluetoothEntry.rs b/src/bluetooth/bluetoothEntry.rs new file mode 100644 index 0000000..75da27f --- /dev/null +++ b/src/bluetooth/bluetoothEntry.rs @@ -0,0 +1,43 @@ +use gtk::{Button, CompositeTemplate, glib, Image, Label}; +use gtk::subclass::prelude::*; + +#[allow(non_snake_case)] +#[derive(Default, CompositeTemplate)] +#[template(resource = "/org/xetibo/reset/resetBluetoothEntry.ui")] +pub struct BluetoothEntry { + #[template_child] + pub resetBluetoothDeviceType: TemplateChild, + #[template_child] + pub resetBluetoothLabel: TemplateChild