mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-18 18:48:33 +02:00
feat: Add inbuilt daemon and create preference/shorcut window shell
This commit is contained in:
parent
2228c11c3c
commit
d00c76fa9e
14
Cargo.toml
14
Cargo.toml
|
@ -5,11 +5,21 @@ edition = "2021"
|
||||||
description = "A wip universal Linux settings application."
|
description = "A wip universal Linux settings application."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
reset_daemon = "0.1.0"
|
||||||
ReSet-Lib = "0.2.3"
|
ReSet-Lib = "0.2.3"
|
||||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"]}
|
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||||
dbus = "0.9.7"
|
dbus = "0.9.7"
|
||||||
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"]}
|
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
||||||
glib = "0.18.3"
|
glib = "0.18.3"
|
||||||
|
tokio = { version = "1.33.0", features = [
|
||||||
|
"rt",
|
||||||
|
"time",
|
||||||
|
"net",
|
||||||
|
"macros",
|
||||||
|
"rt-multi-thread",
|
||||||
|
"sync",
|
||||||
|
] }
|
||||||
|
fork = "0.1.22"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
glib-build-tools = "0.18.0"
|
glib-build-tools = "0.18.0"
|
||||||
|
|
|
@ -262,5 +262,17 @@ impl Window {
|
||||||
|
|
||||||
dialog.present();
|
dialog.present();
|
||||||
}));
|
}));
|
||||||
|
selfImp
|
||||||
|
.resetPreferenceButton
|
||||||
|
.connect_clicked(clone!(@weak self as window => move |_| {
|
||||||
|
let preferences = adw::PreferencesWindow::builder().build();
|
||||||
|
preferences.present();
|
||||||
|
}));
|
||||||
|
selfImp
|
||||||
|
.resetShortcutsButton
|
||||||
|
.connect_clicked(clone!(@weak self as window => move |_| {
|
||||||
|
let shortcuts = gtk::ShortcutsWindow::builder().build();
|
||||||
|
shortcuts.present();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use adw::{Breakpoint, OverlaySplitView};
|
|
||||||
use adw::glib::StaticTypeExt;
|
use adw::glib::StaticTypeExt;
|
||||||
use adw::subclass::prelude::AdwApplicationWindowImpl;
|
use adw::subclass::prelude::AdwApplicationWindowImpl;
|
||||||
|
use adw::{Breakpoint, OverlaySplitView};
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use gtk::{Box, Button, CompositeTemplate, FlowBox, glib, ListBox, PopoverMenu, SearchEntry};
|
|
||||||
use gtk::subclass::prelude::*;
|
use gtk::subclass::prelude::*;
|
||||||
|
use gtk::{glib, Box, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, SearchEntry};
|
||||||
|
|
||||||
use crate::components::wifi::wifiBox::WifiBox;
|
use crate::components::wifi::wifiBox::WifiBox;
|
||||||
use crate::components::window::window;
|
|
||||||
use crate::components::window::sidebarEntry::SidebarEntry;
|
use crate::components::window::sidebarEntry::SidebarEntry;
|
||||||
|
use crate::components::window::window;
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(CompositeTemplate, Default)]
|
#[derive(CompositeTemplate, Default)]
|
||||||
|
@ -35,6 +35,10 @@ pub struct Window {
|
||||||
pub resetClose: TemplateChild<Button>,
|
pub resetClose: TemplateChild<Button>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub resetAboutButton: TemplateChild<Button>,
|
pub resetAboutButton: TemplateChild<Button>,
|
||||||
|
#[template_child]
|
||||||
|
pub resetPreferenceButton: TemplateChild<Button>,
|
||||||
|
#[template_child]
|
||||||
|
pub resetShortcutsButton: TemplateChild<Button>,
|
||||||
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
|
pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
src/main.rs
33
src/main.rs
|
@ -1,8 +1,14 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use gtk::{Application, CssProvider, gio};
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use dbus::blocking::Connection;
|
||||||
|
use dbus::Error;
|
||||||
use gtk::gdk::Display;
|
use gtk::gdk::Display;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use gtk::{gio, Application, CssProvider};
|
||||||
|
use reset_daemon::run_daemon;
|
||||||
|
|
||||||
use crate::components::window::window::Window;
|
use crate::components::window::window::Window;
|
||||||
|
|
||||||
|
@ -10,13 +16,26 @@ mod components;
|
||||||
|
|
||||||
const APP_ID: &str = "org.Xetibo.ReSet";
|
const APP_ID: &str = "org.Xetibo.ReSet";
|
||||||
|
|
||||||
fn main() {
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// TODO is this the best way to handle this??
|
||||||
|
let conn = Connection::new_session().unwrap();
|
||||||
|
let proxy = conn.with_proxy(
|
||||||
|
"org.xetibo.ReSet",
|
||||||
|
"/org/xetibo/ReSet",
|
||||||
|
Duration::from_millis(100),
|
||||||
|
);
|
||||||
|
let res: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "Check", ());
|
||||||
|
if res.is_err() {
|
||||||
|
println!("Daemon was not running");
|
||||||
|
tokio::task::spawn(run_daemon());
|
||||||
|
} else {
|
||||||
|
println!("Daemon was running");
|
||||||
|
}
|
||||||
gio::resources_register_include!("src.templates.gresource")
|
gio::resources_register_include!("src.templates.gresource")
|
||||||
.expect("Failed to register resources.");
|
.expect("Failed to register resources.");
|
||||||
gio::resources_register_include!("src.icons.gresource")
|
gio::resources_register_include!("src.icons.gresource").expect("Failed to register resources.");
|
||||||
.expect("Failed to register resources.");
|
gio::resources_register_include!("src.style.gresource").expect("Failed to register resources.");
|
||||||
gio::resources_register_include!("src.style.gresource")
|
|
||||||
.expect("Failed to register resources.");
|
|
||||||
|
|
||||||
let app = Application::builder().application_id(APP_ID).build();
|
let app = Application::builder().application_id(APP_ID).build();
|
||||||
|
|
||||||
|
@ -38,7 +57,6 @@ fn loadCss() {
|
||||||
&provider,
|
&provider,
|
||||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
@ -46,4 +64,3 @@ fn buildUI(app: &Application) {
|
||||||
let window = Window::new(app);
|
let window = Window::new(app);
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue