Add templates for box and listboxrow

kekw
This commit is contained in:
takotori 2023-11-07 15:08:22 +01:00
parent 7e15201c85
commit af7776d62a
24 changed files with 333 additions and 205 deletions

View file

@ -5,6 +5,7 @@ use adw::subclass::prelude::ObjectSubclassIsExt;
use crate::components::bluetooth::bluetoothBoxImpl;
use crate::components::bluetooth::bluetoothEntry::BluetoothEntry;
use crate::components::bluetooth::bluetoothEntryImpl::DeviceTypes;
use crate::components::temp::listEntry::ListEntry;
glib::wrapper! {
pub struct BluetoothBox(ObjectSubclass<bluetoothBoxImpl::BluetoothBox>)
@ -12,7 +13,6 @@ glib::wrapper! {
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
impl BluetoothBox {
pub fn new() -> Self {
Object::builder().build()
@ -21,10 +21,10 @@ impl BluetoothBox {
pub fn scanForDevices(&self) {
let selfImp = self.imp();
let mut wifiEntries = selfImp.availableDevices.borrow_mut();
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Mouse, "ina mouse"));
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Keyboard, "inaboard"));
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Controller, "ina controller"));
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Controller, "ina best waifu"));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Mouse, "ina mouse")));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Keyboard, "inaboard")));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Controller, "ina controller")));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Controller, "ina best waifu")));
for wifiEntry in wifiEntries.iter() {
selfImp.resetBluetoothAvailableDevices.append(wifiEntry);
@ -34,8 +34,8 @@ impl BluetoothBox {
pub fn addConnectedDevices(&self) {
let selfImp = self.imp();
let mut wifiEntries = selfImp.connectedDevices.borrow_mut();
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Mouse, "why are we still here?"));
wifiEntries.push(BluetoothEntry::new(DeviceTypes::Keyboard, "just to suffer?"));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Mouse, "why are we still here?")));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(DeviceTypes::Keyboard, "just to suffer?")));
for wifiEntry in wifiEntries.iter() {
selfImp.resetBluetoothConnectedDevices.append(wifiEntry);

View file

@ -5,6 +5,7 @@ use gtk::subclass::prelude::*;
use crate::components::bluetooth::bluetoothBox;
use crate::components::bluetooth::bluetoothEntry::BluetoothEntry;
use crate::components::temp::listEntry::ListEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
@ -16,8 +17,8 @@ pub struct BluetoothBox {
pub resetBluetoothAvailableDevices: TemplateChild<ListBox>,
#[template_child]
pub resetBluetoothConnectedDevices: TemplateChild<ListBox>,
pub availableDevices: RefCell<Vec<BluetoothEntry>>,
pub connectedDevices: RefCell<Vec<BluetoothEntry>>,
pub availableDevices: RefCell<Vec<ListEntry>>,
pub connectedDevices: RefCell<Vec<ListEntry>>,
}
#[glib::object_subclass]
@ -28,6 +29,7 @@ impl ObjectSubclass for BluetoothBox {
fn class_init(klass: &mut Self::Class) {
BluetoothEntry::ensure_type();
ListEntry::ensure_type();
klass.bind_template();
}

View file

@ -6,7 +6,7 @@ use crate::components::bluetooth::bluetoothEntryImpl::DeviceTypes;
glib::wrapper! {
pub struct BluetoothEntry(ObjectSubclass<bluetoothEntryImpl::BluetoothEntry>)
@extends gtk::Widget,
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
}

View file

@ -29,7 +29,7 @@ pub struct BluetoothEntry {
impl ObjectSubclass for BluetoothEntry {
const NAME: &'static str = "resetBluetoothEntry";
type Type = bluetoothEntry::BluetoothEntry;
type ParentType = gtk::ListBoxRow;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
@ -46,7 +46,7 @@ impl ObjectImpl for BluetoothEntry {
}
}
impl ListBoxRowImpl for BluetoothEntry {}
impl BoxImpl for BluetoothEntry {}
impl WidgetImpl for BluetoothEntry {}