mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-07 10:37:46 +02:00
Restructure Reset
This commit is contained in:
parent
721e7d3f4e
commit
b3f1bfd59b
16 changed files with 54 additions and 30 deletions
48
src/components/wifi/mod.rs
Normal file
48
src/components/wifi/mod.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use adw::glib::Object;
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::Error;
|
||||
use gtk::glib;
|
||||
|
||||
mod wifiBox;
|
||||
mod wifiEntry;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct WifiBox(ObjectSubclass<wifiBox::WifiBox>)
|
||||
@extends gtk::Box, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct WifiEntry(ObjectSubclass<wifiEntry::WifiEntry>)
|
||||
@extends gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl WifiBox {
|
||||
pub fn new() -> Self {
|
||||
Object::builder().build()
|
||||
}
|
||||
|
||||
pub fn donotdisturb() {
|
||||
thread::spawn(|| {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
"org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let _ : Result<(), Error> = proxy.method_call("org.freedesktop.Notifications", "DoNotDisturb", ());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl WifiEntry {
|
||||
pub fn new() -> Self {
|
||||
Object::builder().build()
|
||||
}
|
||||
}
|
43
src/components/wifi/wifiBox.rs
Normal file
43
src/components/wifi/wifiBox.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use gtk::{CompositeTemplate, glib, ListBox};
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
||||
use crate::components::wifi::WifiEntry;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/xetibo/reset/resetWiFi.ui")]
|
||||
pub struct WifiBox {
|
||||
#[template_child]
|
||||
pub resetWifiList: TemplateChild<ListBox>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiBox {
|
||||
const NAME: &'static str = "resetWifi";
|
||||
type Type = super::WifiBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
WifiEntry::ensure_type();
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for WifiBox {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for WifiBox {}
|
||||
|
||||
impl WidgetImpl for WifiBox {}
|
||||
|
||||
impl WindowImpl for WifiBox {}
|
||||
|
||||
impl ApplicationWindowImpl for WifiBox {}
|
43
src/components/wifi/wifiEntry.rs
Normal file
43
src/components/wifi/wifiEntry.rs
Normal file
|
@ -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/resetWifiEntry.ui")]
|
||||
pub struct WifiEntry {
|
||||
#[template_child]
|
||||
pub resetWifiStrength: TemplateChild<Image>,
|
||||
#[template_child]
|
||||
pub resetWifiLabel: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub resetWifiButton: TemplateChild<Button>,
|
||||
}
|
||||
|
||||
#[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();
|
||||
}
|
||||
|
||||
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