diff --git a/build.rs b/build.rs index 0bb8c79..7ff2fa1 100644 --- a/build.rs +++ b/build.rs @@ -4,4 +4,9 @@ fn main() { "src/resources/resources.gresource.xml", "src.templates.gresource", ); -} \ No newline at end of file + glib_build_tools::compile_resources( + &["src/resources/icons"], + "src/resources/icons/resources.gresource.xml", + "src.icons.gresource", + ); +} diff --git a/src/components/audio/audioBox.rs b/src/components/audio/audioBox.rs index 36db69d..65abd48 100644 --- a/src/components/audio/audioBox.rs +++ b/src/components/audio/audioBox.rs @@ -5,7 +5,7 @@ use crate::components::audio::AudioSourceEntry; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetAudio.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetAudio.ui")] pub struct AudioBox { #[template_child] pub resetOutputDevice: TemplateChild, diff --git a/src/components/audio/audioSource.rs b/src/components/audio/audioSource.rs index d0ef8e0..f91f31f 100644 --- a/src/components/audio/audioSource.rs +++ b/src/components/audio/audioSource.rs @@ -3,7 +3,7 @@ use gtk::subclass::prelude::*; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetAudioSourceEntry.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetAudioSourceEntry.ui")] pub struct AudioSourceEntry { #[template_child] pub resetSourceIcon: TemplateChild, @@ -38,4 +38,4 @@ impl BoxImpl for AudioSourceEntry {} impl ObjectImpl for AudioSourceEntry {} -impl WidgetImpl for AudioSourceEntry {} \ No newline at end of file +impl WidgetImpl for AudioSourceEntry {} diff --git a/src/components/bluetooth/bluetoothBox.rs b/src/components/bluetooth/bluetoothBox.rs index 2268381..a62d69e 100644 --- a/src/components/bluetooth/bluetoothBox.rs +++ b/src/components/bluetooth/bluetoothBox.rs @@ -5,7 +5,7 @@ use crate::components::bluetooth::BluetoothEntry; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetBluetooth.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")] pub struct BluetoothBox { #[template_child] pub resetBluetoothSwitch: TemplateChild, diff --git a/src/components/bluetooth/bluetoothEntry.rs b/src/components/bluetooth/bluetoothEntry.rs index 75da27f..42ad9c4 100644 --- a/src/components/bluetooth/bluetoothEntry.rs +++ b/src/components/bluetooth/bluetoothEntry.rs @@ -3,7 +3,7 @@ use gtk::subclass::prelude::*; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetBluetoothEntry.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetBluetoothEntry.ui")] pub struct BluetoothEntry { #[template_child] pub resetBluetoothDeviceType: TemplateChild, diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index 6c33181..32daa68 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -6,7 +6,7 @@ use crate::components::wifi::WifiEntry; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetWiFi.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetWiFi.ui")] pub struct WifiBox { #[template_child] pub resetWifiList: TemplateChild, diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index 155102a..cc51f15 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -3,7 +3,7 @@ use gtk::subclass::prelude::*; #[allow(non_snake_case)] #[derive(Default, CompositeTemplate)] -#[template(resource = "/org/xetibo/reset/resetWifiEntry.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")] pub struct WifiEntry { #[template_child] pub resetWifiStrength: TemplateChild, diff --git a/src/components/window/handleSidebarClick.rs b/src/components/window/handleSidebarClick.rs index 9a06acc..d0cd3c6 100644 --- a/src/components/window/handleSidebarClick.rs +++ b/src/components/window/handleSidebarClick.rs @@ -1,18 +1,37 @@ -use gtk::FlowBox; +use gtk::{Align, FlowBox, FlowBoxChild}; +use gtk::prelude::{FlowBoxChildExt, WidgetExt}; 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(); + let bluetoothBox = BluetoothBox::new(); + let child1 = FlowBoxChild::new(); + let child2 = FlowBoxChild::new(); + + wifibox.set_halign(Align::Start); + bluetoothBox.set_halign(Align::Start); + + child1.set_halign(Align::Fill); + child2.set_halign(Align::Fill); + + child1.set_child(Some(&wifibox)); + child2.set_child(Some(&bluetoothBox)); + resetMain.remove_all(); - resetMain.insert(&wifibox, -1); + resetMain.insert(&child1, -1); + resetMain.insert(&child2, -1); + + // todo center flowbox children }; pub const HANDLE_WIFI_CLICK: fn(FlowBox) = |resetMain: FlowBox| { let wifibox = WifiBox::new(); resetMain.remove_all(); - resetMain.insert(&wifibox, -1); + let child = FlowBoxChild::new(); + child.set_child(Some(&wifibox)); + resetMain.insert(&child, -1); }; pub const HANDLE_BLUETOOTH_CLICK: fn(FlowBox) = |resetMain: FlowBox| { diff --git a/src/components/window/mod.rs b/src/components/window/mod.rs index cd95fe7..723e9ea 100644 --- a/src/components/window/mod.rs +++ b/src/components/window/mod.rs @@ -7,7 +7,6 @@ use glib::Object; use gtk::{Application, FlowBox, gio, glib}; use gtk::prelude::*; -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, @@ -42,32 +41,33 @@ impl Window { selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| { window.filterList(); - })); + })); selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| { window.toggleSidebar(); - })); + })); - selfImp.resetSidebarList - .connect_row_activated(clone!(@ weak selfImp as flowbox => move |_, y| { + selfImp.resetSidebarList.connect_row_activated( + clone!(@ weak selfImp as flowbox => move |_, y| { let result = y.downcast_ref::().unwrap(); let clickEvent = result.imp().onClickEvent.borrow().onClickEvent; (clickEvent)(flowbox.resetMain.get()); - })); + }), + ); selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| { - window.close(); - })); + window.close(); + })); - selfImp.resetMenu.connect_clicked(|_| { - WifiBox::donotdisturb(); - }); + // selfImp.resetMenu.connect_clicked(|_| { + // WifiBox::donotdisturb(); + // + // }); } fn handleDynamicSidebar(&self) { let selfImp = self.imp(); - selfImp.resetSidebarBreakpoint - .set_condition(BreakpointCondition::parse("max-width: 500sp").as_ref().ok()); + selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 500sp").as_ref().ok()); selfImp.resetSidebarBreakpoint.add_setter( &Object::from(selfImp.resetOverlaySplitView.get()), "collapsed", @@ -188,6 +188,31 @@ impl Window { } } } + + fn setupPopoverButtons(&self) { + let selfImp = self.imp(); + selfImp + .resetAboutButton + .connect_clicked(clone!(@ weak self as window => move |_| { + let dialog = adw::AboutWindow::builder() + .application_name("ReSet") + .application_icon("ReSet") + .developer_name("Xetibo") + .license("GPL-3.0") + .license_type(gtk::License::Gpl30) + .website("https://github.com/Xetibo/ReSet") + .issue_url("https://github.com/Xetibo/ReSet/issues") + .version("0.0.1") + .transient_for(&window) + .modal(true) + .copyright("© 2022-2023 Xetibo") + .developers(vec!["DashieTM".to_string(), "Takatori".to_string()]) + .designers(vec!["DashieTM".to_string(), "Takatori".to_string()]) + .build(); + + dialog.present(); + })); + } } impl SidebarEntry { @@ -223,4 +248,3 @@ impl SidebarEntry { } } } - diff --git a/src/components/window/sidebarEntry.rs b/src/components/window/sidebarEntry.rs index 3877cf4..448a2e8 100644 --- a/src/components/window/sidebarEntry.rs +++ b/src/components/window/sidebarEntry.rs @@ -16,7 +16,7 @@ pub enum Categories { #[allow(non_snake_case)] #[derive(CompositeTemplate, Default)] -#[template(resource = "/org/xetibo/reset/resetSidebarEntry.ui")] +#[template(resource = "/org/Xetibo/ReSet/resetSidebarEntry.ui")] pub struct SidebarEntry { #[template_child] pub resetSidebarLabel: TemplateChild