mirror of
				https://github.com/Xetibo/ReSet.git
				synced 2025-11-04 01:35:20 +01:00 
			
		
		
		
	
						commit
						2eed25fe7d
					
				
					 22 changed files with 811 additions and 774 deletions
				
			
		| 
						 | 
					@ -1,43 +1,15 @@
 | 
				
			||||||
use gtk::{Button, CompositeTemplate, DropDown, TemplateChild, glib};
 | 
					use adw::glib;
 | 
				
			||||||
use gtk::prelude::*;
 | 
					use adw::glib::Object;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use crate::components::audio::audioBoxImpl;
 | 
				
			||||||
use crate::components::audio::AudioSourceEntry;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					glib::wrapper! {
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					    pub struct AudioBox(ObjectSubclass<audioBoxImpl::AudioBox>)
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetAudio.ui")]
 | 
					    @extends gtk::Box, gtk::Widget,
 | 
				
			||||||
pub struct AudioBox {
 | 
					    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetOutputDevice: TemplateChild<DropDown>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetAllOutputDevices: TemplateChild<Button>,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl AudioBox {
 | 
				
			||||||
#[glib::object_subclass]
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
impl ObjectSubclass for AudioBox {
 | 
					        Object::builder().build()
 | 
				
			||||||
    const NAME: &'static str = "resetAudio";
 | 
					 | 
				
			||||||
    type Type = super::AudioBox;
 | 
					 | 
				
			||||||
    type ParentType = gtk::Box;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn class_init(klass: &mut Self::Class) {
 | 
					 | 
				
			||||||
        AudioSourceEntry::ensure_type();
 | 
					 | 
				
			||||||
        klass.bind_template();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
					 | 
				
			||||||
        obj.init_template();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BoxImpl for AudioBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ObjectImpl for AudioBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ListBoxRowImpl for AudioBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for AudioBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WindowImpl for AudioBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ApplicationWindowImpl for AudioBox {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										44
									
								
								src/components/audio/audioBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/components/audio/audioBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					use gtk::{Button, CompositeTemplate, DropDown, TemplateChild, glib};
 | 
				
			||||||
 | 
					use gtk::prelude::*;
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::audio::audioBox;
 | 
				
			||||||
 | 
					use crate::components::audio::audioSource::AudioSourceEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(Default, CompositeTemplate)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetAudio.ui")]
 | 
				
			||||||
 | 
					pub struct AudioBox {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetOutputDevice: TemplateChild<DropDown>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetAllOutputDevices: TemplateChild<Button>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for AudioBox {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetAudio";
 | 
				
			||||||
 | 
					    type Type = audioBox::AudioBox;
 | 
				
			||||||
 | 
					    type ParentType = gtk::Box;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn class_init(klass: &mut Self::Class) {
 | 
				
			||||||
 | 
					        AudioSourceEntry::ensure_type();
 | 
				
			||||||
 | 
					        klass.bind_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
				
			||||||
 | 
					        obj.init_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl BoxImpl for AudioBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ObjectImpl for AudioBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ListBoxRowImpl for AudioBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for AudioBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WindowImpl for AudioBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ApplicationWindowImpl for AudioBox {}
 | 
				
			||||||
| 
						 | 
					@ -1,41 +1,15 @@
 | 
				
			||||||
use gtk::{Button, CompositeTemplate, glib, Image, Label, ProgressBar, Scale};
 | 
					use adw::glib;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use adw::glib::Object;
 | 
				
			||||||
 | 
					use crate::components::audio::audioSourceImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					glib::wrapper! {
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					    pub struct AudioSourceEntry(ObjectSubclass<audioSourceImpl::AudioSourceEntry>)
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetAudioSourceEntry.ui")]
 | 
					    @extends gtk::Box, gtk::Widget,
 | 
				
			||||||
pub struct AudioSourceEntry {
 | 
					    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSourceIcon: TemplateChild<Image>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSourceName: TemplateChild<Label>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSourceMute: TemplateChild<Button>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetVolumeSlider: TemplateChild<Scale>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetVolumePercentage: TemplateChild<Label>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetVolumeMeter: TemplateChild<ProgressBar>,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[glib::object_subclass]
 | 
					impl AudioSourceEntry {
 | 
				
			||||||
impl ObjectSubclass for AudioSourceEntry {
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
    const NAME: &'static str = "resetAudioSourceEntry";
 | 
					        Object::builder().build()
 | 
				
			||||||
    type Type = super::AudioSourceEntry;
 | 
					 | 
				
			||||||
    type ParentType = gtk::Box;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn class_init(klass: &mut Self::Class) {
 | 
					 | 
				
			||||||
        klass.bind_template();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
					 | 
				
			||||||
        obj.init_template();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BoxImpl for AudioSourceEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ObjectImpl for AudioSourceEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for AudioSourceEntry {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										42
									
								
								src/components/audio/audioSourceImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/components/audio/audioSourceImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,42 @@
 | 
				
			||||||
 | 
					use gtk::{Button, CompositeTemplate, glib, Image, Label, ProgressBar, Scale};
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::audio::audioSource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(Default, CompositeTemplate)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetAudioSourceEntry.ui")]
 | 
				
			||||||
 | 
					pub struct AudioSourceEntry {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSourceIcon: TemplateChild<Image>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSourceName: TemplateChild<Label>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSourceMute: TemplateChild<Button>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetVolumeSlider: TemplateChild<Scale>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetVolumePercentage: TemplateChild<Label>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetVolumeMeter: TemplateChild<ProgressBar>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for AudioSourceEntry {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetAudioSourceEntry";
 | 
				
			||||||
 | 
					    type Type = audioSource::AudioSourceEntry;
 | 
				
			||||||
 | 
					    type ParentType = gtk::Box;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn class_init(klass: &mut Self::Class) {
 | 
				
			||||||
 | 
					        klass.bind_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
				
			||||||
 | 
					        obj.init_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl BoxImpl for AudioSourceEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ObjectImpl for AudioSourceEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for AudioSourceEntry {}
 | 
				
			||||||
| 
						 | 
					@ -1,31 +1,5 @@
 | 
				
			||||||
#![allow(non_snake_case)]
 | 
					#![allow(non_snake_case)]
 | 
				
			||||||
 | 
					pub mod audioSource;
 | 
				
			||||||
mod audioSource;
 | 
					pub mod audioBox;
 | 
				
			||||||
mod audioBox;
 | 
					pub mod audioBoxImpl;
 | 
				
			||||||
 | 
					pub mod audioSourceImpl;
 | 
				
			||||||
use adw::glib::Object;
 | 
					 | 
				
			||||||
use gtk::{glib};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct AudioBox(ObjectSubclass<audioBox::AudioBox>)
 | 
					 | 
				
			||||||
    @extends gtk::Box, gtk::Widget,
 | 
					 | 
				
			||||||
    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct AudioSourceEntry(ObjectSubclass<audioSource::AudioSourceEntry>)
 | 
					 | 
				
			||||||
    @extends gtk::Box, gtk::Widget,
 | 
					 | 
				
			||||||
    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl AudioBox {
 | 
					 | 
				
			||||||
    pub fn new() -> Self {
 | 
					 | 
				
			||||||
        Object::builder().build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl AudioSourceEntry {
 | 
					 | 
				
			||||||
    pub fn new() -> Self {
 | 
					 | 
				
			||||||
        Object::builder().build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,46 +1,16 @@
 | 
				
			||||||
use gtk::{CompositeTemplate, glib, ListBox, Switch};
 | 
					use adw::glib;
 | 
				
			||||||
use gtk::prelude::*;
 | 
					use adw::glib::Object;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use crate::components::bluetooth::bluetoothBoxImpl;
 | 
				
			||||||
use crate::components::bluetooth::BluetoothEntry;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					glib::wrapper! {
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					    pub struct BluetoothBox(ObjectSubclass<bluetoothBoxImpl::BluetoothBox>)
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")]
 | 
					    @extends gtk::Box, gtk::Widget,
 | 
				
			||||||
pub struct BluetoothBox {
 | 
					    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothSwitch: TemplateChild<Switch>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothAvailableDevices: TemplateChild<ListBox>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothConnectedDevices: TemplateChild<ListBox>,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[glib::object_subclass]
 | 
					 | 
				
			||||||
impl ObjectSubclass for BluetoothBox {
 | 
					 | 
				
			||||||
    const NAME: &'static str = "resetBluetooth";
 | 
					 | 
				
			||||||
    type Type = super::BluetoothBox;
 | 
					 | 
				
			||||||
    type ParentType = gtk::Box;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn class_init(klass: &mut Self::Class) {
 | 
					impl BluetoothBox {
 | 
				
			||||||
        BluetoothEntry::ensure_type();
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
        klass.bind_template();
 | 
					        Object::builder().build()
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
					 | 
				
			||||||
        obj.init_template();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ObjectImpl for BluetoothBox {
 | 
					 | 
				
			||||||
    fn constructed(&self) {
 | 
					 | 
				
			||||||
        self.parent_constructed();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BoxImpl for BluetoothBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for BluetoothBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WindowImpl for BluetoothBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ApplicationWindowImpl for BluetoothBox {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										48
									
								
								src/components/bluetooth/bluetoothBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/components/bluetooth/bluetoothBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,48 @@
 | 
				
			||||||
 | 
					use gtk::{CompositeTemplate, glib, ListBox, Switch};
 | 
				
			||||||
 | 
					use gtk::prelude::*;
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use crate::components::bluetooth::bluetoothBox;
 | 
				
			||||||
 | 
					use crate::components::bluetooth::bluetoothEntry::BluetoothEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(Default, CompositeTemplate)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")]
 | 
				
			||||||
 | 
					pub struct BluetoothBox {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothSwitch: TemplateChild<Switch>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothAvailableDevices: TemplateChild<ListBox>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothConnectedDevices: TemplateChild<ListBox>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for BluetoothBox {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetBluetooth";
 | 
				
			||||||
 | 
					    type Type = bluetoothBox::BluetoothBox;
 | 
				
			||||||
 | 
					    type ParentType = gtk::Box;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn class_init(klass: &mut Self::Class) {
 | 
				
			||||||
 | 
					        BluetoothEntry::ensure_type();
 | 
				
			||||||
 | 
					        klass.bind_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
 | 
				
			||||||
 | 
					        obj.init_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ObjectImpl for BluetoothBox {
 | 
				
			||||||
 | 
					    fn constructed(&self) {
 | 
				
			||||||
 | 
					        self.parent_constructed();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl BoxImpl for BluetoothBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for BluetoothBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WindowImpl for BluetoothBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ApplicationWindowImpl for BluetoothBox {}
 | 
				
			||||||
| 
						 | 
					@ -1,43 +1,15 @@
 | 
				
			||||||
use gtk::{Button, CompositeTemplate, glib, Image, Label};
 | 
					use adw::glib;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use adw::glib::Object;
 | 
				
			||||||
 | 
					use crate::components::bluetooth::bluetoothEntryImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					glib::wrapper! {
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					    pub struct BluetoothEntry(ObjectSubclass<bluetoothEntryImpl::BluetoothEntry>)
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetBluetoothEntry.ui")]
 | 
					        @extends gtk::Widget,
 | 
				
			||||||
pub struct BluetoothEntry {
 | 
					        @implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothDeviceType: TemplateChild<Image>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothLabel: TemplateChild<Label>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetBluetoothButton: TemplateChild<Button>,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[glib::object_subclass]
 | 
					impl BluetoothEntry {
 | 
				
			||||||
impl ObjectSubclass for BluetoothEntry {
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
    const NAME: &'static str = "resetBluetoothEntry";
 | 
					        Object::builder().build()
 | 
				
			||||||
    type Type = super::BluetoothEntry;
 | 
					 | 
				
			||||||
    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 BluetoothEntry {
 | 
					 | 
				
			||||||
    fn constructed(&self) {
 | 
					 | 
				
			||||||
        self.parent_constructed();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ListBoxRowImpl for BluetoothEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for BluetoothEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WindowImpl for BluetoothEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ApplicationWindowImpl for BluetoothEntry {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										44
									
								
								src/components/bluetooth/bluetoothEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/components/bluetooth/bluetoothEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					use gtk::{Button, CompositeTemplate, glib, Image, Label};
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::bluetooth::bluetoothEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(Default, CompositeTemplate)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetBluetoothEntry.ui")]
 | 
				
			||||||
 | 
					pub struct BluetoothEntry {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothDeviceType: TemplateChild<Image>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothLabel: TemplateChild<Label>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetBluetoothButton: TemplateChild<Button>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for BluetoothEntry {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetBluetoothEntry";
 | 
				
			||||||
 | 
					    type Type = bluetoothEntry::BluetoothEntry;
 | 
				
			||||||
 | 
					    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 BluetoothEntry {
 | 
				
			||||||
 | 
					    fn constructed(&self) {
 | 
				
			||||||
 | 
					        self.parent_constructed();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ListBoxRowImpl for BluetoothEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for BluetoothEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WindowImpl for BluetoothEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ApplicationWindowImpl for BluetoothEntry {}
 | 
				
			||||||
| 
						 | 
					@ -1,30 +1,5 @@
 | 
				
			||||||
#![allow(non_snake_case)]
 | 
					#![allow(non_snake_case)]
 | 
				
			||||||
mod bluetoothBox;
 | 
					pub mod bluetoothBox;
 | 
				
			||||||
mod bluetoothEntry;
 | 
					pub mod bluetoothEntry;
 | 
				
			||||||
 | 
					pub mod bluetoothBoxImpl;
 | 
				
			||||||
use adw::glib::Object;
 | 
					pub mod bluetoothEntryImpl;
 | 
				
			||||||
use gtk::{glib};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct BluetoothBox(ObjectSubclass<bluetoothBox::BluetoothBox>)
 | 
					 | 
				
			||||||
    @extends gtk::Box, gtk::Widget,
 | 
					 | 
				
			||||||
    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct BluetoothEntry(ObjectSubclass<bluetoothEntry::BluetoothEntry>)
 | 
					 | 
				
			||||||
        @extends gtk::Widget,
 | 
					 | 
				
			||||||
        @implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BluetoothBox {
 | 
					 | 
				
			||||||
    pub fn new() -> Self {
 | 
					 | 
				
			||||||
        Object::builder().build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BluetoothEntry {
 | 
					 | 
				
			||||||
    pub fn new() -> Self {
 | 
					 | 
				
			||||||
        Object::builder().build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,89 +1,5 @@
 | 
				
			||||||
#![allow(non_snake_case)]
 | 
					#![allow(non_snake_case)]
 | 
				
			||||||
 | 
					pub mod wifiBox;
 | 
				
			||||||
use std::thread;
 | 
					pub mod wifiBoxImpl;
 | 
				
			||||||
use std::time::Duration;
 | 
					pub mod wifiEntry;
 | 
				
			||||||
 | 
					pub mod wifiEntryImpl;
 | 
				
			||||||
use adw::glib::{Object, PropertySet};
 | 
					 | 
				
			||||||
use adw::glib::clone;
 | 
					 | 
				
			||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
					 | 
				
			||||||
use dbus::blocking::Connection;
 | 
					 | 
				
			||||||
use dbus::Error;
 | 
					 | 
				
			||||||
use gtk::glib;
 | 
					 | 
				
			||||||
use gtk::prelude::WidgetExt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use crate::components::wifi::wifiEntry::WifiStrength;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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::ListBoxRow, gtk::Widget,
 | 
					 | 
				
			||||||
        @implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WifiBox {
 | 
					 | 
				
			||||||
    pub fn new() -> Self {
 | 
					 | 
				
			||||||
        Object::builder().build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn setupCallbacks(&self) {
 | 
					 | 
				
			||||||
        let selfImp = self.imp();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        selfImp.resetWifiDetails.connect_row_activated(clone!(@ weak selfImp as window => move |_, y| {
 | 
					 | 
				
			||||||
            // let result = y.downcast_ref()::<WifiEntry>().unwrap(); no worky smh
 | 
					 | 
				
			||||||
        }));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn scanForWifi(&self) {
 | 
					 | 
				
			||||||
        let selfImp = self.imp();
 | 
					 | 
				
			||||||
        let mut wifiEntries = selfImp.wifiEntries.borrow_mut();
 | 
					 | 
				
			||||||
        wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "ina internet", true));
 | 
					 | 
				
			||||||
        wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "watch ina", true));
 | 
					 | 
				
			||||||
        wifiEntries.push(WifiEntry::new(WifiStrength::Ok, "INANET", true));
 | 
					 | 
				
			||||||
        wifiEntries.push(WifiEntry::new(WifiStrength::Weak, "ina best waifu", false));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for wifiEntry in wifiEntries.iter() {
 | 
					 | 
				
			||||||
            selfImp.resetWifiList.append(wifiEntry);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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(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
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,55 +1,58 @@
 | 
				
			||||||
use std::cell::RefCell;
 | 
					use std::thread;
 | 
				
			||||||
use gtk::{CompositeTemplate, glib, ListBox, ListBoxRow, Switch};
 | 
					use std::time::Duration;
 | 
				
			||||||
use gtk::prelude::*;
 | 
					 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::components::wifi::WifiEntry;
 | 
					use adw::glib;
 | 
				
			||||||
 | 
					use adw::glib::clone;
 | 
				
			||||||
 | 
					use adw::glib::Object;
 | 
				
			||||||
 | 
					use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
				
			||||||
 | 
					use dbus::blocking::Connection;
 | 
				
			||||||
 | 
					use dbus::Error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					use crate::components::wifi::wifiBoxImpl;
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					use crate::components::wifi::wifiEntry::WifiEntry;
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetWiFi.ui")]
 | 
					use crate::components::wifi::wifiEntryImpl::WifiStrength;
 | 
				
			||||||
pub struct WifiBox {
 | 
					
 | 
				
			||||||
    #[template_child]
 | 
					glib::wrapper! {
 | 
				
			||||||
    pub resetWifiDetails: TemplateChild<ListBox>,
 | 
					    pub struct WifiBox(ObjectSubclass<wifiBoxImpl::WifiBox>)
 | 
				
			||||||
    #[template_child]
 | 
					    @extends gtk::Box, gtk::Widget,
 | 
				
			||||||
    pub resetWifiSwitchRow: TemplateChild<ListBoxRow>,
 | 
					    @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetWifiSwitch: TemplateChild<Switch>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetWifiList: TemplateChild<ListBox>,
 | 
					 | 
				
			||||||
    pub wifiEntries: RefCell<Vec<WifiEntry>>,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[glib::object_subclass]
 | 
					impl WifiBox {
 | 
				
			||||||
impl ObjectSubclass for WifiBox {
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
    const NAME: &'static str = "resetWifi";
 | 
					        Object::builder().build()
 | 
				
			||||||
    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>) {
 | 
					    pub fn setupCallbacks(&self) {
 | 
				
			||||||
        obj.init_template();
 | 
					        let selfImp = self.imp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        selfImp.resetWifiDetails.connect_row_activated(clone!(@ weak selfImp as window => move |_, _y| {
 | 
				
			||||||
 | 
					            // let result = y.downcast_ref()::<WifiEntry>().unwrap(); no worky smh
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn scanForWifi(&self) {
 | 
				
			||||||
 | 
					        let selfImp = self.imp();
 | 
				
			||||||
 | 
					        let mut wifiEntries = selfImp.wifiEntries.borrow_mut();
 | 
				
			||||||
 | 
					        wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "ina internet", true));
 | 
				
			||||||
 | 
					        wifiEntries.push(WifiEntry::new(WifiStrength::Excellent, "watch ina", true));
 | 
				
			||||||
 | 
					        wifiEntries.push(WifiEntry::new(WifiStrength::Ok, "INANET", true));
 | 
				
			||||||
 | 
					        wifiEntries.push(WifiEntry::new(WifiStrength::Weak, "ina best waifu", false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for wifiEntry in wifiEntries.iter() {
 | 
				
			||||||
 | 
					            selfImp.resetWifiList.append(wifiEntry);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ObjectImpl for WifiBox {
 | 
					    pub fn donotdisturb() {
 | 
				
			||||||
    fn constructed(&self) {
 | 
					        thread::spawn(|| {
 | 
				
			||||||
        self.parent_constructed();
 | 
					            let conn = Connection::new_session().unwrap();
 | 
				
			||||||
 | 
					            let proxy = conn.with_proxy(
 | 
				
			||||||
        let obj = self.obj();
 | 
					                "org.freedesktop.Notifications",
 | 
				
			||||||
        obj.setupCallbacks();
 | 
					                "/org/freedesktop/Notifications",
 | 
				
			||||||
        obj.scanForWifi();
 | 
					                Duration::from_millis(1000),
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            let _: Result<(), Error> = proxy.method_call("org.freedesktop.Notifications", "DoNotDisturb", ());
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
impl BoxImpl for WifiBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for WifiBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WindowImpl for WifiBox {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ApplicationWindowImpl for WifiBox {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										56
									
								
								src/components/wifi/wifiBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/components/wifi/wifiBoxImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,56 @@
 | 
				
			||||||
 | 
					use std::cell::RefCell;
 | 
				
			||||||
 | 
					use gtk::{CompositeTemplate, glib, ListBox, ListBoxRow, Switch};
 | 
				
			||||||
 | 
					use gtk::prelude::*;
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::wifi::wifiBox;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use crate::components::wifi::wifiEntry::WifiEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(Default, CompositeTemplate)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetWiFi.ui")]
 | 
				
			||||||
 | 
					pub struct WifiBox {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetWifiDetails: TemplateChild<ListBox>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetWifiSwitchRow: TemplateChild<ListBoxRow>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetWifiSwitch: TemplateChild<Switch>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetWifiList: TemplateChild<ListBox>,
 | 
				
			||||||
 | 
					    pub wifiEntries: RefCell<Vec<WifiEntry>>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for WifiBox {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetWifi";
 | 
				
			||||||
 | 
					    type Type = wifiBox::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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let obj = self.obj();
 | 
				
			||||||
 | 
					        obj.setupCallbacks();
 | 
				
			||||||
 | 
					        obj.scanForWifi();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl BoxImpl for WifiBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for WifiBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WindowImpl for WifiBox {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ApplicationWindowImpl for WifiBox {}
 | 
				
			||||||
| 
						 | 
					@ -1,57 +1,33 @@
 | 
				
			||||||
use std::cell::RefCell;
 | 
					use crate::components::wifi::wifiEntryImpl;
 | 
				
			||||||
use gtk::{Button, CompositeTemplate, glib, Image, Label};
 | 
					use adw::glib;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use adw::glib::{Object, PropertySet};
 | 
				
			||||||
 | 
					use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
				
			||||||
 | 
					use gtk::prelude::WidgetExt;
 | 
				
			||||||
 | 
					use crate::components::wifi::wifiEntryImpl::WifiStrength;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Default, Copy, Clone)]
 | 
					glib::wrapper! {
 | 
				
			||||||
pub enum WifiStrength {
 | 
					    pub struct WifiEntry(ObjectSubclass<wifiEntryImpl::WifiEntry>)
 | 
				
			||||||
    Excellent,
 | 
					        @extends gtk::ListBoxRow, gtk::Widget,
 | 
				
			||||||
    Ok,
 | 
					        @implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
 | 
				
			||||||
    Weak,
 | 
					 | 
				
			||||||
    #[default]
 | 
					 | 
				
			||||||
    None,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					impl WifiEntry {
 | 
				
			||||||
#[derive(Default, CompositeTemplate)]
 | 
					    pub fn new(strength: WifiStrength, name: &str, isEncrypted: bool) -> Self {
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")]
 | 
					        let entry: WifiEntry = Object::builder().build();
 | 
				
			||||||
pub struct WifiEntry {
 | 
					        let entryImp = entry.imp();
 | 
				
			||||||
    #[template_child]
 | 
					        entryImp.wifiStrength.set(strength);
 | 
				
			||||||
    pub resetWifiStrength: TemplateChild<Image>,
 | 
					        entryImp.resetWifiLabel.get().set_text(name);
 | 
				
			||||||
    #[template_child]
 | 
					        entryImp.resetWifiEncrypted.set_visible(isEncrypted);
 | 
				
			||||||
    pub resetWifiEncrypted: TemplateChild<Image>,
 | 
					        entryImp.resetWifiStrength.get().set_from_icon_name(match strength {
 | 
				
			||||||
    #[template_child]
 | 
					            WifiStrength::Excellent => Some("network-wireless-signal-excellent-symbolic"),
 | 
				
			||||||
    pub resetWifiLabel: TemplateChild<Label>,
 | 
					            WifiStrength::Ok => Some("network-wireless-signal-ok-symbolic"),
 | 
				
			||||||
    #[template_child]
 | 
					            WifiStrength::Weak => Some("network-wireless-signal-weak-symbolic"),
 | 
				
			||||||
    pub resetWifiButton: TemplateChild<Button>,
 | 
					            WifiStrength::None => Some("network-wireless-signal-none-symbolic"),
 | 
				
			||||||
    pub wifiName: RefCell<String>,
 | 
					        });
 | 
				
			||||||
    pub wifiStrength: RefCell<WifiStrength>,
 | 
					        {
 | 
				
			||||||
 | 
					            let mut wifiName = entryImp.wifiName.borrow_mut();
 | 
				
			||||||
 | 
					            *wifiName = String::from(name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        entry
 | 
				
			||||||
#[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 {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										58
									
								
								src/components/wifi/wifiEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								src/components/wifi/wifiEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,58 @@
 | 
				
			||||||
 | 
					use std::cell::RefCell;
 | 
				
			||||||
 | 
					use gtk::{Button, CompositeTemplate, glib, Image, Label};
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::wifi::wifiEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[derive(Default, Copy, Clone)]
 | 
				
			||||||
 | 
					pub enum WifiStrength {
 | 
				
			||||||
 | 
					    Excellent,
 | 
				
			||||||
 | 
					    Ok,
 | 
				
			||||||
 | 
					    Weak,
 | 
				
			||||||
 | 
					    #[default]
 | 
				
			||||||
 | 
					    None,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[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 = wifiEntry::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 {}
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
use gtk::{Align, FlowBox, FlowBoxChild};
 | 
					use gtk::{Align, FlowBox, FlowBoxChild};
 | 
				
			||||||
use gtk::prelude::{FlowBoxChildExt, WidgetExt};
 | 
					use gtk::prelude::{FlowBoxChildExt, WidgetExt};
 | 
				
			||||||
use crate::components::audio::AudioBox;
 | 
					use crate::components::audio::audioBox::AudioBox;
 | 
				
			||||||
use crate::components::bluetooth::BluetoothBox;
 | 
					use crate::components::bluetooth::bluetoothBox::BluetoothBox;
 | 
				
			||||||
use crate::components::wifi::WifiBox;
 | 
					use crate::components::wifi::wifiBox::WifiBox;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub const HANDLE_CONNECTIVITY_CLICK: fn(FlowBox) =  |resetMain: FlowBox|   {
 | 
					pub const HANDLE_CONNECTIVITY_CLICK: fn(FlowBox) =  |resetMain: FlowBox|   {
 | 
				
			||||||
    let wifibox = WifiBox::new();
 | 
					    let wifibox = WifiBox::new();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,248 +1,6 @@
 | 
				
			||||||
#![allow(non_snake_case)]
 | 
					#![allow(non_snake_case)]
 | 
				
			||||||
 | 
					pub mod window;
 | 
				
			||||||
use adw::BreakpointCondition;
 | 
					pub mod windowImpl;
 | 
				
			||||||
use adw::glib::clone;
 | 
					pub mod sidebarEntry;
 | 
				
			||||||
use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
					pub mod sidebarEntryImpl;
 | 
				
			||||||
use glib::Object;
 | 
					pub mod handleSidebarClick;
 | 
				
			||||||
use gtk::{Application, FlowBox, gio, glib};
 | 
					 | 
				
			||||||
use gtk::prelude::*;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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::components::window::sidebarEntry::{Categories, SidebarAction};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
mod handleSidebarClick;
 | 
					 | 
				
			||||||
mod sidebarEntry;
 | 
					 | 
				
			||||||
mod window;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct Window(ObjectSubclass<window::Window>)
 | 
					 | 
				
			||||||
        @extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
 | 
					 | 
				
			||||||
        @implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
 | 
					 | 
				
			||||||
                    gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
glib::wrapper! {
 | 
					 | 
				
			||||||
    pub struct SidebarEntry(ObjectSubclass<sidebarEntry::SidebarEntry>)
 | 
					 | 
				
			||||||
        @extends gtk::ListBoxRow, gtk::Widget,
 | 
					 | 
				
			||||||
        @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					 | 
				
			||||||
impl Window {
 | 
					 | 
				
			||||||
    pub fn new(app: &Application) -> Self {
 | 
					 | 
				
			||||||
        Object::builder().property("application", app).build()
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn setupCallback(&self) {
 | 
					 | 
				
			||||||
        let selfImp = self.imp();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        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| {
 | 
					 | 
				
			||||||
                let result = y.downcast_ref::<SidebarEntry>().unwrap();
 | 
					 | 
				
			||||||
                let clickEvent = result.imp().onClickEvent.borrow().onClickEvent;
 | 
					 | 
				
			||||||
                (clickEvent)(flowbox.resetMain.get());
 | 
					 | 
				
			||||||
            }),
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| {
 | 
					 | 
				
			||||||
                window.close();
 | 
					 | 
				
			||||||
            }));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // selfImp.resetMenu.connect_clicked(|_| {
 | 
					 | 
				
			||||||
        //     WifiBox::donotdisturb();
 | 
					 | 
				
			||||||
        //
 | 
					 | 
				
			||||||
        // });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn handleDynamicSidebar(&self) {
 | 
					 | 
				
			||||||
        let selfImp = self.imp();
 | 
					 | 
				
			||||||
        selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 600sp").as_ref().ok());
 | 
					 | 
				
			||||||
        selfImp.resetSidebarBreakpoint.add_setter(
 | 
					 | 
				
			||||||
            &Object::from(selfImp.resetOverlaySplitView.get()),
 | 
					 | 
				
			||||||
            "collapsed",
 | 
					 | 
				
			||||||
            &true.to_value(),
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
        selfImp.resetSidebarBreakpoint.add_setter(
 | 
					 | 
				
			||||||
            &Object::from(selfImp.resetSideBarToggle.get()),
 | 
					 | 
				
			||||||
            "visible",
 | 
					 | 
				
			||||||
            &true.to_value(),
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn filterList(&self) {
 | 
					 | 
				
			||||||
        let text = self.imp().resetSearchEntry.text().to_string();
 | 
					 | 
				
			||||||
        for (mainEntry, subEntries) in self.imp().sidebarEntries.borrow().iter() {
 | 
					 | 
				
			||||||
            if text == "" {
 | 
					 | 
				
			||||||
                mainEntry.set_visible(true);
 | 
					 | 
				
			||||||
                for subEntry in subEntries {
 | 
					 | 
				
			||||||
                    subEntry.set_visible(true);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if mainEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
 | 
					 | 
				
			||||||
                mainEntry.set_visible(true);
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                mainEntry.set_visible(false);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            for subEntry in subEntries {
 | 
					 | 
				
			||||||
                if subEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
 | 
					 | 
				
			||||||
                    subEntry.set_visible(true);
 | 
					 | 
				
			||||||
                    mainEntry.set_visible(true);
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    subEntry.set_visible(false);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn toggleSidebar(&self) {
 | 
					 | 
				
			||||||
        if self.imp().resetOverlaySplitView.shows_sidebar() {
 | 
					 | 
				
			||||||
            self.imp().resetOverlaySplitView.set_show_sidebar(false);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            self.imp().resetOverlaySplitView.set_show_sidebar(true);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn setupSidebarEntries(&self) {
 | 
					 | 
				
			||||||
        let selfImp = self.imp();
 | 
					 | 
				
			||||||
        let mut sidebarEntries = selfImp.sidebarEntries.borrow_mut();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let connectivityList = vec![
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "WiFi",
 | 
					 | 
				
			||||||
                "network-wireless-symbolic",
 | 
					 | 
				
			||||||
                Categories::Connectivity,
 | 
					 | 
				
			||||||
                true,
 | 
					 | 
				
			||||||
                HANDLE_WIFI_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "Bluetooth",
 | 
					 | 
				
			||||||
                "bluetooth-symbolic",
 | 
					 | 
				
			||||||
                Categories::Connectivity,
 | 
					 | 
				
			||||||
                true,
 | 
					 | 
				
			||||||
                HANDLE_BLUETOOTH_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "VPN",
 | 
					 | 
				
			||||||
                "network-vpn-symbolic",
 | 
					 | 
				
			||||||
                Categories::Connectivity,
 | 
					 | 
				
			||||||
                true,
 | 
					 | 
				
			||||||
                HANDLE_VPN_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        sidebarEntries.push((
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "Connectivity",
 | 
					 | 
				
			||||||
                "network-wired-symbolic",
 | 
					 | 
				
			||||||
                Categories::Connectivity,
 | 
					 | 
				
			||||||
                false,
 | 
					 | 
				
			||||||
                HANDLE_CONNECTIVITY_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            connectivityList,
 | 
					 | 
				
			||||||
        ));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let audioList = vec![
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "Volume",
 | 
					 | 
				
			||||||
                "audio-volume-high-symbolic",
 | 
					 | 
				
			||||||
                Categories::Audio,
 | 
					 | 
				
			||||||
                true,
 | 
					 | 
				
			||||||
                HANDLE_VOLUME_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "Microphone",
 | 
					 | 
				
			||||||
                "audio-input-microphone-symbolic",
 | 
					 | 
				
			||||||
                Categories::Audio,
 | 
					 | 
				
			||||||
                true,
 | 
					 | 
				
			||||||
                HANDLE_MICROPHONE_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        sidebarEntries.push((
 | 
					 | 
				
			||||||
            SidebarEntry::new(
 | 
					 | 
				
			||||||
                "Audio",
 | 
					 | 
				
			||||||
                "audio-headset-symbolic",
 | 
					 | 
				
			||||||
                Categories::Audio,
 | 
					 | 
				
			||||||
                false,
 | 
					 | 
				
			||||||
                HANDLE_AUDIO_CLICK,
 | 
					 | 
				
			||||||
            ),
 | 
					 | 
				
			||||||
            audioList,
 | 
					 | 
				
			||||||
        ));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (mainEntry, subEntries) in sidebarEntries.iter() {
 | 
					 | 
				
			||||||
            selfImp.resetSidebarList.append(mainEntry);
 | 
					 | 
				
			||||||
            for subEntry in subEntries {
 | 
					 | 
				
			||||||
                selfImp.resetSidebarList.append(subEntry);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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 {
 | 
					 | 
				
			||||||
    pub fn new(
 | 
					 | 
				
			||||||
        entryName: &str,
 | 
					 | 
				
			||||||
        iconName: &str,
 | 
					 | 
				
			||||||
        category: Categories,
 | 
					 | 
				
			||||||
        isSubcategory: bool,
 | 
					 | 
				
			||||||
        clickEvent: fn(FlowBox),
 | 
					 | 
				
			||||||
    ) -> Self {
 | 
					 | 
				
			||||||
        let entry: SidebarEntry = Object::builder().build();
 | 
					 | 
				
			||||||
        let entryImp = entry.imp();
 | 
					 | 
				
			||||||
        entryImp.resetSidebarLabel.get().set_text(entryName);
 | 
					 | 
				
			||||||
        entryImp.resetSidebarImage.set_from_icon_name(Some(iconName));
 | 
					 | 
				
			||||||
        entryImp.category.set(category);
 | 
					 | 
				
			||||||
        entryImp.isSubcategory.set(isSubcategory);
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            let mut name = entryImp.name.borrow_mut();
 | 
					 | 
				
			||||||
            *name = String::from(entryName);
 | 
					 | 
				
			||||||
            let mut action = entryImp.onClickEvent.borrow_mut();
 | 
					 | 
				
			||||||
            *action = SidebarAction {
 | 
					 | 
				
			||||||
                onClickEvent: clickEvent,
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        Self::setMargin(&entry);
 | 
					 | 
				
			||||||
        entry
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn setMargin(entry: &SidebarEntry) {
 | 
					 | 
				
			||||||
        if entry.imp().isSubcategory.get() {
 | 
					 | 
				
			||||||
            let option = entry.child().unwrap();
 | 
					 | 
				
			||||||
            option.set_margin_start(30);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,63 +1,48 @@
 | 
				
			||||||
use std::cell::{Cell, RefCell};
 | 
					use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
				
			||||||
 | 
					use glib::Object;
 | 
				
			||||||
 | 
					use gtk::{FlowBox, glib};
 | 
				
			||||||
 | 
					use gtk::prelude::*;
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntryImpl;
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntryImpl::{Categories, SidebarAction};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use glib::subclass::InitializingObject;
 | 
					glib::wrapper! {
 | 
				
			||||||
use gtk::{CompositeTemplate, FlowBox, glib, Image, Label, ListBoxRow};
 | 
					    pub struct SidebarEntry(ObjectSubclass<sidebarEntryImpl::SidebarEntry>)
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					        @extends gtk::ListBoxRow, gtk::Widget,
 | 
				
			||||||
 | 
					        @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
 | 
				
			||||||
use crate::components::window::handleSidebarClick::HANDLE_HOME;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[derive(Default)]
 | 
					 | 
				
			||||||
pub enum Categories {
 | 
					 | 
				
			||||||
    Connectivity,
 | 
					 | 
				
			||||||
    Audio,
 | 
					 | 
				
			||||||
    #[default]
 | 
					 | 
				
			||||||
    Misc,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					impl SidebarEntry {
 | 
				
			||||||
#[derive(CompositeTemplate, Default)]
 | 
					    pub fn new(
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetSidebarEntry.ui")]
 | 
					        entryName: &str,
 | 
				
			||||||
pub struct SidebarEntry {
 | 
					        iconName: &str,
 | 
				
			||||||
    #[template_child]
 | 
					        category: Categories,
 | 
				
			||||||
    pub resetSidebarLabel: TemplateChild<Label>,
 | 
					        isSubcategory: bool,
 | 
				
			||||||
    #[template_child]
 | 
					        clickEvent: fn(FlowBox),
 | 
				
			||||||
    pub resetSidebarImage: TemplateChild<Image>,
 | 
					    ) -> Self {
 | 
				
			||||||
    pub category: Cell<Categories>,
 | 
					        let entry: SidebarEntry = Object::builder().build();
 | 
				
			||||||
    pub isSubcategory: Cell<bool>,
 | 
					        let entryImp = entry.imp();
 | 
				
			||||||
    pub onClickEvent: RefCell<SidebarAction>,
 | 
					        entryImp.resetSidebarLabel.get().set_text(entryName);
 | 
				
			||||||
    pub name : RefCell<String>,
 | 
					        entryImp
 | 
				
			||||||
 | 
					            .resetSidebarImage
 | 
				
			||||||
 | 
					            .set_from_icon_name(Some(iconName));
 | 
				
			||||||
 | 
					        entryImp.category.set(category);
 | 
				
			||||||
 | 
					        entryImp.isSubcategory.set(isSubcategory);
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            let mut name = entryImp.name.borrow_mut();
 | 
				
			||||||
 | 
					            *name = String::from(entryName);
 | 
				
			||||||
 | 
					            let mut action = entryImp.onClickEvent.borrow_mut();
 | 
				
			||||||
 | 
					            *action = SidebarAction {
 | 
				
			||||||
 | 
					                onClickEvent: clickEvent,
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Self::setMargin(&entry);
 | 
				
			||||||
 | 
					        entry
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					    fn setMargin(entry: &SidebarEntry) {
 | 
				
			||||||
pub struct SidebarAction {
 | 
					        if entry.imp().isSubcategory.get() {
 | 
				
			||||||
    pub onClickEvent: fn(FlowBox),
 | 
					            let option = entry.child().unwrap();
 | 
				
			||||||
}
 | 
					            option.set_margin_start(30);
 | 
				
			||||||
 | 
					 | 
				
			||||||
impl Default for SidebarAction {
 | 
					 | 
				
			||||||
    fn default() -> Self {
 | 
					 | 
				
			||||||
        Self {
 | 
					 | 
				
			||||||
            onClickEvent: HANDLE_HOME
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
#[glib::object_subclass]
 | 
					 | 
				
			||||||
impl ObjectSubclass for SidebarEntry {
 | 
					 | 
				
			||||||
    const NAME: &'static str = "resetSidebarEntry";
 | 
					 | 
				
			||||||
    type Type = super::SidebarEntry;
 | 
					 | 
				
			||||||
    type ParentType = ListBoxRow;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn class_init(klass: &mut Self::Class) {
 | 
					 | 
				
			||||||
        klass.bind_template();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fn instance_init(obj: &InitializingObject<Self>) {
 | 
					 | 
				
			||||||
        obj.init_template();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ObjectImpl for SidebarEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl ListBoxRowImpl for SidebarEntry {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl WidgetImpl for SidebarEntry {}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										64
									
								
								src/components/window/sidebarEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								src/components/window/sidebarEntryImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,64 @@
 | 
				
			||||||
 | 
					use std::cell::{Cell, RefCell};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use glib::subclass::InitializingObject;
 | 
				
			||||||
 | 
					use gtk::{CompositeTemplate, FlowBox, glib, Image, Label, ListBoxRow};
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use crate::components::window::handleSidebarClick::HANDLE_HOME;
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[derive(Default)]
 | 
				
			||||||
 | 
					pub enum Categories {
 | 
				
			||||||
 | 
					    Connectivity,
 | 
				
			||||||
 | 
					    Audio,
 | 
				
			||||||
 | 
					    #[default]
 | 
				
			||||||
 | 
					    Misc,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(CompositeTemplate, Default)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetSidebarEntry.ui")]
 | 
				
			||||||
 | 
					pub struct SidebarEntry {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSidebarLabel: TemplateChild<Label>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSidebarImage: TemplateChild<Image>,
 | 
				
			||||||
 | 
					    pub category: Cell<Categories>,
 | 
				
			||||||
 | 
					    pub isSubcategory: Cell<bool>,
 | 
				
			||||||
 | 
					    pub onClickEvent: RefCell<SidebarAction>,
 | 
				
			||||||
 | 
					    pub name : RefCell<String>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					pub struct SidebarAction {
 | 
				
			||||||
 | 
					    pub onClickEvent: fn(FlowBox),
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl Default for SidebarAction {
 | 
				
			||||||
 | 
					    fn default() -> Self {
 | 
				
			||||||
 | 
					        Self {
 | 
				
			||||||
 | 
					            onClickEvent: HANDLE_HOME
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for SidebarEntry {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetSidebarEntry";
 | 
				
			||||||
 | 
					    type Type = sidebarEntry::SidebarEntry;
 | 
				
			||||||
 | 
					    type ParentType = ListBoxRow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn class_init(klass: &mut Self::Class) {
 | 
				
			||||||
 | 
					        klass.bind_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn instance_init(obj: &InitializingObject<Self>) {
 | 
				
			||||||
 | 
					        obj.init_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ObjectImpl for SidebarEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ListBoxRowImpl for SidebarEntry {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for SidebarEntry {}
 | 
				
			||||||
| 
						 | 
					@ -1,73 +1,204 @@
 | 
				
			||||||
use adw::glib::StaticTypeExt;
 | 
					use adw::BreakpointCondition;
 | 
				
			||||||
use adw::subclass::prelude::AdwApplicationWindowImpl;
 | 
					use adw::glib::clone;
 | 
				
			||||||
use adw::{Breakpoint, OverlaySplitView};
 | 
					use adw::subclass::prelude::ObjectSubclassIsExt;
 | 
				
			||||||
use glib::subclass::InitializingObject;
 | 
					use glib::Object;
 | 
				
			||||||
use gtk::subclass::prelude::*;
 | 
					use gtk::{Application, gio, glib};
 | 
				
			||||||
use gtk::{glib, Box, Button, CompositeTemplate, FlowBox, ListBox, SearchEntry, PopoverMenu};
 | 
					use gtk::prelude::*;
 | 
				
			||||||
use std::cell::RefCell;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::components::wifi::WifiBox;
 | 
					use crate::components::window::handleSidebarClick::{
 | 
				
			||||||
use crate::components::window::SidebarEntry;
 | 
					    HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK,
 | 
				
			||||||
 | 
					    HANDLE_VOLUME_CLICK, HANDLE_VPN_CLICK, HANDLE_WIFI_CLICK,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntry::SidebarEntry;
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntryImpl::Categories;
 | 
				
			||||||
 | 
					use crate::components::window::windowImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					glib::wrapper! {
 | 
				
			||||||
 | 
					    pub struct Window(ObjectSubclass<windowImpl::Window>)
 | 
				
			||||||
 | 
					        @extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
 | 
				
			||||||
 | 
					        @implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
 | 
				
			||||||
 | 
					                    gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[allow(non_snake_case)]
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
#[derive(CompositeTemplate, Default)]
 | 
					impl Window {
 | 
				
			||||||
#[template(resource = "/org/Xetibo/ReSet/resetMainWindow.ui")]
 | 
					    pub fn new(app: &Application) -> Self {
 | 
				
			||||||
pub struct Window {
 | 
					        Object::builder().property("application", app).build()
 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetMain: TemplateChild<FlowBox>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSidebarBreakpoint: TemplateChild<Breakpoint>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetOverlaySplitView: TemplateChild<OverlaySplitView>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSearchEntry: TemplateChild<SearchEntry>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSidebarList: TemplateChild<ListBox>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetSideBarToggle: TemplateChild<Button>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetPath: TemplateChild<Box>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetPopoverMenu: TemplateChild<PopoverMenu>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetClose: TemplateChild<Button>,
 | 
					 | 
				
			||||||
    #[template_child]
 | 
					 | 
				
			||||||
    pub resetAboutButton: TemplateChild<Button>,
 | 
					 | 
				
			||||||
    pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[glib::object_subclass]
 | 
					    pub fn setupCallback(&self) {
 | 
				
			||||||
impl ObjectSubclass for Window {
 | 
					        let selfImp = self.imp();
 | 
				
			||||||
    const NAME: &'static str = "resetUI";
 | 
					 | 
				
			||||||
    type Type = super::Window;
 | 
					 | 
				
			||||||
    type ParentType = adw::ApplicationWindow;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn class_init(klass: &mut Self::Class) {
 | 
					        selfImp.resetSearchEntry.connect_search_changed(clone!(@ weak self as window => move |_| {
 | 
				
			||||||
        WifiBox::ensure_type();
 | 
					            window.filterList();
 | 
				
			||||||
        klass.bind_template();
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        selfImp.resetSideBarToggle.connect_clicked(clone!(@ weak self as window => move |_| {
 | 
				
			||||||
 | 
					            window.toggleSidebar();
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        selfImp.resetSidebarList.connect_row_activated(
 | 
				
			||||||
 | 
					            clone!(@ weak selfImp as flowbox => move |_, y| {
 | 
				
			||||||
 | 
					                let result = y.downcast_ref::<SidebarEntry>().unwrap();
 | 
				
			||||||
 | 
					                let clickEvent = result.imp().onClickEvent.borrow().onClickEvent;
 | 
				
			||||||
 | 
					                (clickEvent)(flowbox.resetMain.get());
 | 
				
			||||||
 | 
					            }),
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        selfImp.resetClose.connect_clicked(clone!(@ weak self as window => move |_| {
 | 
				
			||||||
 | 
					                window.close();
 | 
				
			||||||
 | 
					            }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // selfImp.resetMenu.connect_clicked(|_| {
 | 
				
			||||||
 | 
					        //     WifiBox::donotdisturb();
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					        // });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn instance_init(obj: &InitializingObject<Self>) {
 | 
					    pub fn handleDynamicSidebar(&self) {
 | 
				
			||||||
        obj.init_template();
 | 
					        let selfImp = self.imp();
 | 
				
			||||||
 | 
					        selfImp.resetSidebarBreakpoint.set_condition(BreakpointCondition::parse("max-width: 600sp").as_ref().ok());
 | 
				
			||||||
 | 
					        selfImp.resetSidebarBreakpoint.add_setter(
 | 
				
			||||||
 | 
					            &Object::from(selfImp.resetOverlaySplitView.get()),
 | 
				
			||||||
 | 
					            "collapsed",
 | 
				
			||||||
 | 
					            &true.to_value(),
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        selfImp.resetSidebarBreakpoint.add_setter(
 | 
				
			||||||
 | 
					            &Object::from(selfImp.resetSideBarToggle.get()),
 | 
				
			||||||
 | 
					            "visible",
 | 
				
			||||||
 | 
					            &true.to_value(),
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn filterList(&self) {
 | 
				
			||||||
 | 
					        let text = self.imp().resetSearchEntry.text().to_string();
 | 
				
			||||||
 | 
					        for (mainEntry, subEntries) in self.imp().sidebarEntries.borrow().iter() {
 | 
				
			||||||
 | 
					            if text == "" {
 | 
				
			||||||
 | 
					                mainEntry.set_visible(true);
 | 
				
			||||||
 | 
					                for subEntry in subEntries {
 | 
				
			||||||
 | 
					                    subEntry.set_visible(true);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if mainEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
 | 
				
			||||||
 | 
					                mainEntry.set_visible(true);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                mainEntry.set_visible(false);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            for subEntry in subEntries {
 | 
				
			||||||
 | 
					                if subEntry.imp().name.borrow().to_lowercase().contains(&text.to_lowercase()) {
 | 
				
			||||||
 | 
					                    subEntry.set_visible(true);
 | 
				
			||||||
 | 
					                    mainEntry.set_visible(true);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    subEntry.set_visible(false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ObjectImpl for Window {
 | 
					    pub fn toggleSidebar(&self) {
 | 
				
			||||||
    fn constructed(&self) {
 | 
					        if self.imp().resetOverlaySplitView.shows_sidebar() {
 | 
				
			||||||
        self.parent_constructed();
 | 
					            self.imp().resetOverlaySplitView.set_show_sidebar(false);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
        let object = self.obj();
 | 
					            self.imp().resetOverlaySplitView.set_show_sidebar(true);
 | 
				
			||||||
        object.setupCallback();
 | 
					 | 
				
			||||||
        object.setupPopoverButtons();
 | 
					 | 
				
			||||||
        object.handleDynamicSidebar();
 | 
					 | 
				
			||||||
        object.setupSidebarEntries();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl WidgetImpl for Window {}
 | 
					    pub fn setupSidebarEntries(&self) {
 | 
				
			||||||
 | 
					        let selfImp = self.imp();
 | 
				
			||||||
 | 
					        let mut sidebarEntries = selfImp.sidebarEntries.borrow_mut();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl WindowImpl for Window {}
 | 
					        let connectivityList = vec![
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "WiFi",
 | 
				
			||||||
 | 
					                "network-wireless-symbolic",
 | 
				
			||||||
 | 
					                Categories::Connectivity,
 | 
				
			||||||
 | 
					                true,
 | 
				
			||||||
 | 
					                HANDLE_WIFI_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "Bluetooth",
 | 
				
			||||||
 | 
					                "bluetooth-symbolic",
 | 
				
			||||||
 | 
					                Categories::Connectivity,
 | 
				
			||||||
 | 
					                true,
 | 
				
			||||||
 | 
					                HANDLE_BLUETOOTH_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "VPN",
 | 
				
			||||||
 | 
					                "network-vpn-symbolic",
 | 
				
			||||||
 | 
					                Categories::Connectivity,
 | 
				
			||||||
 | 
					                true,
 | 
				
			||||||
 | 
					                HANDLE_VPN_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ApplicationWindowImpl for Window {}
 | 
					        sidebarEntries.push((
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "Connectivity",
 | 
				
			||||||
 | 
					                "network-wired-symbolic",
 | 
				
			||||||
 | 
					                Categories::Connectivity,
 | 
				
			||||||
 | 
					                false,
 | 
				
			||||||
 | 
					                HANDLE_CONNECTIVITY_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            connectivityList,
 | 
				
			||||||
 | 
					        ));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl AdwApplicationWindowImpl for Window {}
 | 
					        let audioList = vec![
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "Volume",
 | 
				
			||||||
 | 
					                "audio-volume-high-symbolic",
 | 
				
			||||||
 | 
					                Categories::Audio,
 | 
				
			||||||
 | 
					                true,
 | 
				
			||||||
 | 
					                HANDLE_VOLUME_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "Microphone",
 | 
				
			||||||
 | 
					                "audio-input-microphone-symbolic",
 | 
				
			||||||
 | 
					                Categories::Audio,
 | 
				
			||||||
 | 
					                true,
 | 
				
			||||||
 | 
					                HANDLE_MICROPHONE_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sidebarEntries.push((
 | 
				
			||||||
 | 
					            SidebarEntry::new(
 | 
				
			||||||
 | 
					                "Audio",
 | 
				
			||||||
 | 
					                "audio-headset-symbolic",
 | 
				
			||||||
 | 
					                Categories::Audio,
 | 
				
			||||||
 | 
					                false,
 | 
				
			||||||
 | 
					                HANDLE_AUDIO_CLICK,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            audioList,
 | 
				
			||||||
 | 
					        ));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (mainEntry, subEntries) in sidebarEntries.iter() {
 | 
				
			||||||
 | 
					            selfImp.resetSidebarList.append(mainEntry);
 | 
				
			||||||
 | 
					            for subEntry in subEntries {
 | 
				
			||||||
 | 
					                selfImp.resetSidebarList.append(subEntry);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub 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();
 | 
				
			||||||
 | 
					        }));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										75
									
								
								src/components/window/windowImpl.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								src/components/window/windowImpl.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,75 @@
 | 
				
			||||||
 | 
					use std::cell::RefCell;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use adw::{Breakpoint, OverlaySplitView};
 | 
				
			||||||
 | 
					use adw::glib::StaticTypeExt;
 | 
				
			||||||
 | 
					use adw::subclass::prelude::AdwApplicationWindowImpl;
 | 
				
			||||||
 | 
					use glib::subclass::InitializingObject;
 | 
				
			||||||
 | 
					use gtk::{Box, Button, CompositeTemplate, FlowBox, glib, ListBox, PopoverMenu, SearchEntry};
 | 
				
			||||||
 | 
					use gtk::subclass::prelude::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use crate::components::wifi::wifiBox::WifiBox;
 | 
				
			||||||
 | 
					use crate::components::window::window;
 | 
				
			||||||
 | 
					use crate::components::window::sidebarEntry::SidebarEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(non_snake_case)]
 | 
				
			||||||
 | 
					#[derive(CompositeTemplate, Default)]
 | 
				
			||||||
 | 
					#[template(resource = "/org/Xetibo/ReSet/resetMainWindow.ui")]
 | 
				
			||||||
 | 
					pub struct Window {
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetMain: TemplateChild<FlowBox>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSidebarBreakpoint: TemplateChild<Breakpoint>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetOverlaySplitView: TemplateChild<OverlaySplitView>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSearchEntry: TemplateChild<SearchEntry>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSidebarList: TemplateChild<ListBox>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetSideBarToggle: TemplateChild<Button>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetPath: TemplateChild<Box>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetPopoverMenu: TemplateChild<PopoverMenu>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetClose: TemplateChild<Button>,
 | 
				
			||||||
 | 
					    #[template_child]
 | 
				
			||||||
 | 
					    pub resetAboutButton: TemplateChild<Button>,
 | 
				
			||||||
 | 
					    pub sidebarEntries: RefCell<Vec<(SidebarEntry, Vec<SidebarEntry>)>>,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[glib::object_subclass]
 | 
				
			||||||
 | 
					impl ObjectSubclass for Window {
 | 
				
			||||||
 | 
					    const NAME: &'static str = "resetUI";
 | 
				
			||||||
 | 
					    type Type = window::Window;
 | 
				
			||||||
 | 
					    type ParentType = adw::ApplicationWindow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn class_init(klass: &mut Self::Class) {
 | 
				
			||||||
 | 
					        WifiBox::ensure_type();
 | 
				
			||||||
 | 
					        klass.bind_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn instance_init(obj: &InitializingObject<Self>) {
 | 
				
			||||||
 | 
					        obj.init_template();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ObjectImpl for Window {
 | 
				
			||||||
 | 
					    fn constructed(&self) {
 | 
				
			||||||
 | 
					        self.parent_constructed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let obj = self.obj();
 | 
				
			||||||
 | 
					        obj.setupCallback();
 | 
				
			||||||
 | 
					        obj.setupPopoverButtons();
 | 
				
			||||||
 | 
					        obj.handleDynamicSidebar();
 | 
				
			||||||
 | 
					        obj.setupSidebarEntries();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WidgetImpl for Window {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl WindowImpl for Window {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl ApplicationWindowImpl for Window {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl AdwApplicationWindowImpl for Window {}
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@ mod components;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use gtk::prelude::*;
 | 
					use gtk::prelude::*;
 | 
				
			||||||
use gtk::{gio, Application};
 | 
					use gtk::{gio, Application};
 | 
				
			||||||
use components::window::Window;
 | 
					use crate::components::window::window::Window;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_ID: &str = "org.Xetibo.ReSet";
 | 
					const APP_ID: &str = "org.Xetibo.ReSet";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue