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

@ -2,12 +2,13 @@ use std::thread;
use std::time::Duration;
use adw::glib;
use adw::glib::clone;
use adw::glib::Object;
use adw::subclass::prelude::ObjectSubclassIsExt;
use dbus::blocking::Connection;
use dbus::Error;
use gtk::prelude::ButtonExt;
use gtk::glib::Variant;
use gtk::prelude::ActionableExt;
use crate::components::temp::listEntry::ListEntry;
use crate::components::wifi::wifiBoxImpl;
use crate::components::wifi::wifiEntry::WifiEntry;
@ -27,18 +28,17 @@ impl WifiBox {
pub fn setupCallbacks(&self) {
let selfImp = self.imp();
selfImp.resetWifiDetails.connect_row_activated(clone!(@ weak selfImp as window => move |_, _y| {
// let result = y.downcast_ref()::<WifiEntry>().unwrap(); no worky smh
}));
selfImp.resetSavedNetworks.set_action_name(Some("navigation.push"));
selfImp.resetSavedNetworks.set_action_target_value(Some(&Variant::from("saved")));
}
pub fn scanForWifi(&self) {
let selfImp = self.imp();
let mut wifiEntries = selfImp.wifiEntries.borrow_mut();
wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "ina internet", true));
wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "watch ina", true));
wifiEntries.push(WifiEntry::new(WifiStrength::Ok, "INANET", true));
wifiEntries.push(WifiEntry::new(WifiStrength::Weak, "ina best waifu", false));
wifiEntries.push(ListEntry::new(&WifiEntry::new(WifiStrength::Excellent, "ina internet", true)));
wifiEntries.push(ListEntry::new(&WifiEntry::new(WifiStrength::Excellent, "watch ina", true)));
wifiEntries.push(ListEntry::new(&WifiEntry::new(WifiStrength::Ok, "INANET", true)));
wifiEntries.push(ListEntry::new(&WifiEntry::new(WifiStrength::Weak, "ina best waifu", false)));
for wifiEntry in wifiEntries.iter() {
selfImp.resetWifiList.append(wifiEntry);

View file

@ -1,10 +1,11 @@
use std::cell::RefCell;
use gtk::{Button, CompositeTemplate, glib, ListBox, ListBoxRow, Revealer, Switch};
use gtk::{Button, CompositeTemplate, glib, ListBox, Switch};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::components::wifi::wifiBox;
use crate::components::wifi::wifiEntry::WifiEntry;
use crate::components::temp::listEntry::ListEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
@ -13,14 +14,16 @@ pub struct WifiBox {
#[template_child]
pub resetWifiDetails: TemplateChild<ListBox>,
#[template_child]
pub resetWifiSwitchRow: TemplateChild<ListBoxRow>,
pub resetWifiSwitchRow: TemplateChild<ListEntry>,
#[template_child]
pub resetSavedNetworks: TemplateChild<ListEntry>,
#[template_child]
pub resetWifiSwitch: TemplateChild<Switch>,
#[template_child]
pub resetWifiList: TemplateChild<ListBox>,
#[template_child]
pub resetWifiAdvanced: TemplateChild<Button>,
pub wifiEntries: RefCell<Vec<WifiEntry>>,
pub wifiEntries: RefCell<Vec<ListEntry>>,
}
#[glib::object_subclass]
@ -31,6 +34,7 @@ impl ObjectSubclass for WifiBox {
fn class_init(klass: &mut Self::Class) {
WifiEntry::ensure_type();
ListEntry::ensure_type();
klass.bind_template();
}

View file

@ -7,7 +7,7 @@ use crate::components::wifi::wifiEntryImpl::WifiStrength;
glib::wrapper! {
pub struct WifiEntry(ObjectSubclass<wifiEntryImpl::WifiEntry>)
@extends gtk::ListBoxRow, gtk::Widget,
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
}

View file

@ -1,6 +1,7 @@
use std::cell::RefCell;
use gtk::{Button, CompositeTemplate, glib, Image, Label};
use gtk::subclass::prelude::*;
use crate::components::temp::listEntry::ListEntry;
use crate::components::wifi::wifiEntry;
#[derive(Default, Copy, Clone)]
@ -32,7 +33,7 @@ pub struct WifiEntry {
impl ObjectSubclass for WifiEntry {
const NAME: &'static str = "resetWifiEntry";
type Type = wifiEntry::WifiEntry;
type ParentType = gtk::ListBoxRow;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
@ -49,7 +50,7 @@ impl ObjectImpl for WifiEntry {
}
}
impl ListBoxRowImpl for WifiEntry {}
impl BoxImpl for WifiEntry {}
impl WidgetImpl for WifiEntry {}