mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-12-15 10:01:39 +01:00
reorganize wifi (wip)
This commit is contained in:
parent
f4a6f29343
commit
c4c95df8d3
5 changed files with 182 additions and 188 deletions
|
|
@ -1,57 +1,29 @@
|
|||
use std::cell::RefCell;
|
||||
use gtk::{Button, CompositeTemplate, glib, Image, Label};
|
||||
use gtk::subclass::prelude::*;
|
||||
use adw::glib;
|
||||
use crate::components::wifi::wifiEntryImpl::WifiStrength;
|
||||
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub enum WifiStrength {
|
||||
Excellent,
|
||||
Ok,
|
||||
Weak,
|
||||
#[default]
|
||||
None,
|
||||
glib::wrapper! {
|
||||
pub struct WifiEntry(ObjectSubclass<wifiEntryImpl::WifiEntry>)
|
||||
@extends gtk::ListBoxRow, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")]
|
||||
pub struct WifiEntry {
|
||||
#[template_child]
|
||||
pub resetWifiStrength: TemplateChild<Image>,
|
||||
#[template_child]
|
||||
pub resetWifiEncrypted: TemplateChild<Image>,
|
||||
#[template_child]
|
||||
pub resetWifiLabel: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub resetWifiButton: TemplateChild<Button>,
|
||||
pub wifiName: RefCell<String>,
|
||||
pub wifiStrength: RefCell<WifiStrength>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiEntry {
|
||||
const NAME: &'static str = "resetWifiEntry";
|
||||
type Type = super::WifiEntry;
|
||||
type ParentType = gtk::ListBoxRow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
impl WifiEntry {
|
||||
pub fn new(strength: WifiStrength, name: &str, isEncrypted: bool) -> Self {
|
||||
let entry: WifiEntry = Object::builder().build();
|
||||
let entryImp = entry.imp();
|
||||
entryImp.wifiStrength.set(strength);
|
||||
entryImp.resetWifiLabel.get().set_text(name);
|
||||
entryImp.resetWifiEncrypted.set_visible(isEncrypted);
|
||||
entryImp.resetWifiStrength.get().set_from_icon_name(match strength {
|
||||
WifiStrength::Excellent => Some("network-wireless-signal-excellent-symbolic"),
|
||||
WifiStrength::Ok => Some("network-wireless-signal-ok-symbolic"),
|
||||
WifiStrength::Weak => Some("network-wireless-signal-weak-symbolic"),
|
||||
WifiStrength::None => Some("network-wireless-signal-none-symbolic"),
|
||||
});
|
||||
{
|
||||
let mut wifiName = entryImp.wifiName.borrow_mut();
|
||||
*wifiName = String::from(name);
|
||||
}
|
||||
entry
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for WifiEntry {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
}
|
||||
}
|
||||
|
||||
impl ListBoxRowImpl for WifiEntry {}
|
||||
|
||||
impl WidgetImpl for WifiEntry {}
|
||||
|
||||
impl WindowImpl for WifiEntry {}
|
||||
|
||||
impl ApplicationWindowImpl for WifiEntry {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue