Restructure Reset

This commit is contained in:
takotori 2023-10-28 17:55:25 +02:00
parent 721e7d3f4e
commit b3f1bfd59b
16 changed files with 54 additions and 30 deletions

View file

@ -7,6 +7,7 @@ description = "A wip universal Linux settings application."
[dependencies]
ReSet-Lib = "*"
adw = { version = "*", package = "libadwaita", features = ["v1_4"]}
dbus = "0.9.7"
gtk = { version = "*", package = "gtk4", features = ["v4_12"]}
[build-dependencies]

View file

@ -1,7 +1,7 @@
use gtk::{Button, CompositeTemplate, DropDown, TemplateChild, glib};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::audio::AudioSourceEntry;
use crate::components::audio::AudioSourceEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]

View file

@ -1,7 +1,7 @@
use gtk::{CompositeTemplate, glib, ListBox, Switch};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::bluetooth::BluetoothEntry;
use crate::components::bluetooth::BluetoothEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]

4
src/components/mod.rs Normal file
View file

@ -0,0 +1,4 @@
pub mod window;
pub mod wifi;
pub mod bluetooth;
pub mod audio;

View file

@ -1,9 +1,15 @@
#![allow(non_snake_case)]
mod wifiBox;
mod wifiEntry;
use std::thread;
use std::time::Duration;
use adw::glib::Object;
use gtk::{glib};
use dbus::blocking::Connection;
use dbus::Error;
use gtk::glib;
mod wifiBox;
mod wifiEntry;
glib::wrapper! {
pub struct WifiBox(ObjectSubclass<wifiBox::WifiBox>)
@ -21,6 +27,18 @@ 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 {

View file

@ -2,7 +2,7 @@ use gtk::{CompositeTemplate, glib, ListBox};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::wifi::WifiEntry;
use crate::components::wifi::WifiEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]

View file

@ -1,7 +1,7 @@
use gtk::FlowBox;
use crate::audio::AudioBox;
use crate::bluetooth::BluetoothBox;
use crate::wifi::WifiBox;
use crate::components::audio::AudioBox;
use crate::components::bluetooth::BluetoothBox;
use crate::components::wifi::WifiBox;
pub const HANDLE_CONNECTIVITY_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
let wifibox = WifiBox::new();

View file

@ -1,17 +1,18 @@
#![allow(non_snake_case)]
use adw::BreakpointCondition;
use adw::glib::clone;
use adw::subclass::prelude::ObjectSubclassIsExt;
use adw::BreakpointCondition;
use glib::Object;
use gtk::{Application, FlowBox, gio, glib};
use gtk::prelude::*;
use gtk::{gio, glib, Application, FlowBox};
use crate::window::handleSidebarClick::{
use crate::components::wifi::WifiBox;
use crate::components::window::handleSidebarClick::{
HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK,
HANDLE_VOLUME_CLICK, HANDLE_VPN_CLICK, HANDLE_WIFI_CLICK,
};
use crate::window::sidebarEntry::{Categories, SidebarAction};
use crate::components::window::sidebarEntry::{Categories, SidebarAction};
mod handleSidebarClick;
mod sidebarEntry;
@ -39,14 +40,12 @@ impl Window {
fn setupCallback(&self) {
let selfImp = self.imp();
selfImp
.resetSearchEntry
selfImp.resetSearchEntry
.connect_search_changed(clone!(@ weak self as window => move |_| {
window.filterList();
}));
selfImp
.resetSideBarToggle
selfImp.resetSideBarToggle
.connect_clicked(clone!(@ weak self as window => move |_| {
window.toggleSidebar();
}));
@ -59,11 +58,13 @@ impl Window {
}),
);
selfImp
.resetClose
.connect_clicked(clone!(@ weak self as window => move |_| {
window.close();
}));
selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| {
window.close();
}));
selfImp.resetMenu.connect_clicked(|_| {
WifiBox::donotdisturb();
});
}
fn handleDynamicSidebar(&self) {

View file

@ -4,7 +4,7 @@ use glib::subclass::InitializingObject;
use gtk::{CompositeTemplate, FlowBox, glib, Image, Label, ListBoxRow};
use gtk::subclass::prelude::*;
use crate::window::handleSidebarClick::HANDLE_HOME;
use crate::components::window::handleSidebarClick::HANDLE_HOME;
#[derive(Default)]
pub enum Categories {

View file

@ -6,8 +6,8 @@ use gtk::subclass::prelude::*;
use gtk::{glib, Box, Button, CompositeTemplate, FlowBox, ListBox, SearchEntry};
use std::cell::RefCell;
use crate::wifi::WifiBox;
use crate::window::SidebarEntry;
use crate::components::wifi::WifiBox;
use crate::components::window::SidebarEntry;
#[allow(non_snake_case)]
#[derive(CompositeTemplate, Default)]
@ -28,6 +28,8 @@ pub struct Window {
#[template_child]
pub resetPath: TemplateChild<Box>,
#[template_child]
pub resetMenu: TemplateChild<Button>,
#[template_child]
pub resetClose: TemplateChild<Button>,
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
}

View file

@ -1,11 +1,9 @@
mod audio;
mod bluetooth;
mod wifi;
mod window;
mod components;
use gtk::prelude::*;
use gtk::{gio, Application};
use window::Window;
use components::window::Window;
const APP_ID: &str = "org.Xetibo.ReSet";