mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-08 22:52:01 +02:00
Merge pull request #63 from Xetibo/dashie
feat: Wifi event handling improvements
This commit is contained in:
commit
02e63f5984
|
@ -5,8 +5,8 @@ edition = "2021"
|
|||
description = "A wip universal Linux settings application."
|
||||
|
||||
[dependencies]
|
||||
reset_daemon = "0.2.3"
|
||||
ReSet-Lib = "0.4.0"
|
||||
reset_daemon = "0.2.5"
|
||||
ReSet-Lib = "0.4.6"
|
||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||
dbus = "0.9.7"
|
||||
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
||||
|
|
|
@ -5,7 +5,7 @@ use adw::glib::Object;
|
|||
use adw::prelude::{ComboRowExt, PreferencesRowExt};
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::Error;
|
||||
use glib::{Cast, clone, ObjectExt, ToValue};
|
||||
use glib::{Cast, clone, ObjectExt};
|
||||
use glib::subclass::types::ObjectSubclassIsExt;
|
||||
use gtk::{Align, gio, SignalListItemFactory, StringList, StringObject};
|
||||
use gtk::prelude::{GObjectPropertyExpressionExt, ListItemExt, WidgetExt};
|
||||
|
|
|
@ -21,6 +21,7 @@ pub struct CardEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for CardEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetCardEntry";
|
||||
type Type = cardEntry::CardEntry;
|
||||
type ParentType = ComboRow;
|
||||
|
|
|
@ -9,6 +9,7 @@ pub struct ListEntry {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for ListEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetListBoxRow";
|
||||
type Type = listEntry::ListEntry;
|
||||
type ParentType = gtk::ListBoxRow;
|
||||
|
|
|
@ -24,6 +24,7 @@ unsafe impl Sync for Popup {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Popup {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetPopup";
|
||||
type Type = popup::Popup;
|
||||
type ParentType = Popover;
|
||||
|
|
|
@ -9,6 +9,7 @@ pub struct SettingBox {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SettingBox {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSettingBox";
|
||||
type Type = settingBox::SettingBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -137,7 +137,7 @@ impl dbus::message::SignalArgs for SinkRemoved {
|
|||
|
||||
impl GetVal<(u32,)> for SinkRemoved {
|
||||
fn get_value(&self) -> (u32,) {
|
||||
(self.index.clone(),)
|
||||
(self.index,)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ impl dbus::message::SignalArgs for InputStreamRemoved {
|
|||
|
||||
impl GetVal<(u32,)> for InputStreamRemoved {
|
||||
fn get_value(&self) -> (u32,) {
|
||||
(self.index.clone(),)
|
||||
(self.index,)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ impl dbus::message::SignalArgs for SourceRemoved {
|
|||
|
||||
impl GetVal<(u32,)> for SourceRemoved {
|
||||
fn get_value(&self) -> (u32,) {
|
||||
(self.index.clone(),)
|
||||
(self.index,)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ impl dbus::message::SignalArgs for OutputStreamRemoved {
|
|||
|
||||
impl GetVal<(u32,)> for OutputStreamRemoved {
|
||||
fn get_value(&self) -> (u32,) {
|
||||
(self.index.clone(),)
|
||||
(self.index,)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ pub fn start_audio_listener(
|
|||
source_box: Option<Arc<SourceBox>>,
|
||||
) {
|
||||
gio::spawn_blocking(move || {
|
||||
let mut conn = Connection::new_session().unwrap();
|
||||
let conn = Connection::new_session().unwrap();
|
||||
if listeners.pulse_listener.load(Ordering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
|
@ -402,6 +402,7 @@ pub fn start_audio_listener(
|
|||
}
|
||||
|
||||
listeners.pulse_listener.store(true, Ordering::SeqCst);
|
||||
|
||||
println!("starting audio listener");
|
||||
loop {
|
||||
let _ = conn.process(Duration::from_millis(1000));
|
||||
|
|
|
@ -166,7 +166,7 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
|||
}
|
||||
|
||||
listeners.bluetooth_listener.store(true, Ordering::SeqCst);
|
||||
let time = SystemTime::now();
|
||||
let _time = SystemTime::now();
|
||||
|
||||
loop {
|
||||
let _ = conn.process(Duration::from_millis(1000));
|
||||
|
|
|
@ -31,6 +31,7 @@ pub struct BluetoothBox {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for BluetoothBox {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetBluetooth";
|
||||
type Type = bluetoothBox::BluetoothBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -31,6 +31,7 @@ pub struct BluetoothEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for BluetoothEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetBluetoothEntry";
|
||||
type Type = bluetoothEntry::BluetoothEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -32,7 +32,7 @@ impl OutputStreamEntry {
|
|||
let imp = obj.imp();
|
||||
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
||||
imp.resetSourceName.set_text(name.as_str());
|
||||
let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -30,6 +30,7 @@ pub struct OutputStreamEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for OutputStreamEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetOutputStreamEntry";
|
||||
type Type = outputStreamEntry::OutputStreamEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn populate_sources(input_box: Arc<SourceBox>) {
|
|||
let default_sink = output_box_imp.resetDefaultSource.clone();
|
||||
let source = default_sink.borrow();
|
||||
|
||||
let volume = source.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = source.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
output_box_imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
@ -441,7 +441,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
|||
let output_box = source_box.clone();
|
||||
let output_box_imp = output_box.imp();
|
||||
let is_default = ir.source.name == default_source.name;
|
||||
let volume = ir.source.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = ir.source.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
let list = output_box_imp.resetSourceList.read().unwrap();
|
||||
|
@ -531,7 +531,7 @@ pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) ->
|
|||
}
|
||||
let name = ir.stream.application_name.clone() + ": " + ir.stream.name.as_str();
|
||||
imp.resetSourceName.set_text(name.as_str());
|
||||
let volume = ir.stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = ir.stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -7,7 +7,7 @@ use adw::{ActionRow, ComboRow, PreferencesGroup};
|
|||
use crate::components::base::listEntry::ListEntry;
|
||||
use crate::components::input::sourceBox;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, CheckButton, CompositeTemplate, DropDown, StringList, TemplateChild};
|
||||
use gtk::{glib, CheckButton, CompositeTemplate, StringList, TemplateChild};
|
||||
use gtk::{prelude::*, Button, Label, ProgressBar, Scale};
|
||||
use ReSet_Lib::audio::audio::Source;
|
||||
|
||||
|
@ -56,6 +56,7 @@ pub struct SourceBox {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SourceBox {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetAudioInput";
|
||||
type Type = sourceBox::SourceBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -30,7 +30,7 @@ impl SourceEntry {
|
|||
let imp = obj.imp();
|
||||
imp.resetSourceName.set_text(stream.alias.clone().as_str());
|
||||
let name = Arc::new(stream.name.clone());
|
||||
let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -30,6 +30,7 @@ pub struct SourceEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SourceEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSourceEntry";
|
||||
type Type = sourceEntry::SourceEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -37,7 +37,7 @@ impl InputStreamEntry {
|
|||
}
|
||||
let name = stream.application_name.clone() + ": " + stream.name.as_str();
|
||||
imp.resetSinkName.set_text(name.as_str());
|
||||
let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -31,6 +31,7 @@ pub struct InputStreamEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for InputStreamEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetInputStreamEntry";
|
||||
type Type = inputStreamEntry::InputStreamEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -445,7 +445,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
|||
let output_box = sink_box.clone();
|
||||
let output_box_imp = output_box.imp();
|
||||
let is_default = ir.sink.name == default_sink.name;
|
||||
let volume = ir.sink.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = ir.sink.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
|
||||
|
@ -532,7 +532,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
|||
}
|
||||
let name = ir.stream.application_name.clone() + ": " + ir.stream.name.as_str();
|
||||
imp.resetSinkName.set_text(name.as_str());
|
||||
let volume = ir.stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = ir.stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::components::base::listEntry::ListEntry;
|
|||
use crate::components::output::inputStreamEntry::InputStreamEntry;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{
|
||||
glib, Box, Button, CheckButton, CompositeTemplate, DropDown, Label, StringList, TemplateChild,
|
||||
glib, Box, Button, CheckButton, CompositeTemplate, Label, StringList, TemplateChild,
|
||||
};
|
||||
use gtk::{prelude::*, ProgressBar, Scale};
|
||||
use ReSet_Lib::audio::audio::Sink;
|
||||
|
@ -59,6 +59,7 @@ pub struct SinkBox {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SinkBox {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetAudioOutput";
|
||||
type Type = sinkBox::SinkBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -28,7 +28,7 @@ impl SinkEntry {
|
|||
let imp = obj.imp();
|
||||
imp.resetSinkName.set_text(stream.alias.clone().as_str());
|
||||
let name = Arc::new(stream.name.clone());
|
||||
let volume = stream.volume.first().unwrap_or_else(|| &(0 as u32));
|
||||
let volume = stream.volume.first().unwrap_or(&0_u32);
|
||||
let fraction = (*volume as f64 / 655.36).round();
|
||||
let percentage = (fraction).to_string() + "%";
|
||||
imp.resetVolumePercentage.set_text(&percentage);
|
||||
|
|
|
@ -29,6 +29,7 @@ pub struct SinkEntry {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SinkEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSinkEntry";
|
||||
type Type = sinkEntry::SinkEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -27,6 +27,7 @@ unsafe impl Sync for SavedWifiEntry {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SavedWifiEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSavedWifiEntry";
|
||||
type Type = savedWifiEntry::SavedWifiEntry;
|
||||
type ParentType = ActionRow;
|
||||
|
|
|
@ -25,9 +25,9 @@ impl WifiAddressEntry {
|
|||
let addr = getValueFromKey(&map, "address");
|
||||
let prefix = getValueFromKey(&map, "prefix-length");
|
||||
|
||||
entryImp.resetAddressAddress.set_text(&*addr);
|
||||
entryImp.resetAddressNetmask.set_text(&*prefix);
|
||||
entryImp.resetAddressRow.set_title(&*format!("{}, {}", addr, prefix));
|
||||
entryImp.resetAddressAddress.set_text(&addr);
|
||||
entryImp.resetAddressNetmask.set_text(&prefix);
|
||||
entryImp.resetAddressRow.set_title(&format!("{}, {}", addr, prefix));
|
||||
}
|
||||
entry
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ pub struct WifiAddressEntryImpl {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiAddressEntryImpl {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetWifiAddressEntry";
|
||||
type Type = wifiAddressEntry::WifiAddressEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
use std::collections::HashMap;
|
||||
use std::net::Shutdown::Read;
|
||||
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::components::base::listEntry::ListEntry;
|
||||
|
||||
use crate::components::base::utils::Listeners;
|
||||
use adw::glib;
|
||||
use adw::glib::Object;
|
||||
use adw::prelude::{ListBoxRowExt, PreferencesGroupExt};
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use dbus::arg::{AppendAll, ReadAll, RefArg};
|
||||
use dbus::arg::{RefArg};
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::message::SignalArgs;
|
||||
use dbus::Error;
|
||||
use dbus::Path;
|
||||
use glib::ObjectExt;
|
||||
use glib::{ObjectExt, PropertySet};
|
||||
use gtk::gio;
|
||||
use gtk::glib::Variant;
|
||||
use gtk::prelude::ActionableExt;
|
||||
use ReSet_Lib::network::network::AccessPoint;
|
||||
use ReSet_Lib::signals::AccessPointRemoved;
|
||||
use ReSet_Lib::signals::{AccessPointAdded, GetVal};
|
||||
use ReSet_Lib::utils::Events;
|
||||
use gtk::prelude::{ActionableExt, WidgetExt};
|
||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||
use ReSet_Lib::signals::{AccessPointAdded};
|
||||
use ReSet_Lib::signals::{AccessPointChanged, AccessPointRemoved};
|
||||
|
||||
|
||||
use crate::components::wifi::wifiBoxImpl;
|
||||
use crate::components::wifi::wifiEntry::WifiEntry;
|
||||
|
@ -62,93 +63,32 @@ impl WifiBox {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn scanForWifi(listeners: Arc<Listeners>, wifiBox: Arc<WifiBox>) {
|
||||
pub fn scanForWifi(_listeners: Arc<Listeners>, wifiBox: Arc<WifiBox>) {
|
||||
let wifibox_ref = wifiBox.clone();
|
||||
let wifibox_ref_listener = wifiBox.clone();
|
||||
let _wifibox_ref_listener = wifiBox.clone();
|
||||
let wifiEntries = wifiBox.imp().wifiEntries.clone();
|
||||
let wifiEntriesPath = wifiBox.imp().wifiEntriesPath.clone();
|
||||
|
||||
gio::spawn_blocking(move || {
|
||||
let accessPoints = get_access_points();
|
||||
let wifiEntriesListener = wifiEntries.clone();
|
||||
let wifiEntries = wifiEntries.clone();
|
||||
let wifiEntriesPath = wifiEntriesPath.clone();
|
||||
dbus_start_network_events();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let mut wifiEntries = wifiEntries.lock().unwrap();
|
||||
let mut wifiEntriesPath = wifiEntriesPath.lock().unwrap();
|
||||
let selfImp = wifibox_ref.imp();
|
||||
for accessPoint in accessPoints {
|
||||
let ssid = accessPoint.ssid.clone();
|
||||
let path = accessPoint.dbus_path.clone();
|
||||
let entry = WifiEntry::new(accessPoint, selfImp);
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
wifiEntriesPath.insert(path, entry.clone());
|
||||
selfImp.resetWifiList.add(&*entry);
|
||||
}
|
||||
});
|
||||
});
|
||||
if listeners.network_listener.load(Ordering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
listeners.network_listener.store(true, Ordering::SeqCst);
|
||||
dbus_start_network_events();
|
||||
let (sender, receiver): (
|
||||
Sender<Events<(AccessPoint,), (AccessPoint,)>>,
|
||||
Receiver<Events<(AccessPoint,), (AccessPoint,)>>,
|
||||
) = channel();
|
||||
let sender_ref = Arc::new(sender);
|
||||
let res = start_event_listener::<
|
||||
(AccessPoint,),
|
||||
(AccessPoint,),
|
||||
AccessPointAdded,
|
||||
AccessPointRemoved,
|
||||
>(listeners.clone(), sender_ref);
|
||||
if res.is_err() {
|
||||
println!("Could not connect listener");
|
||||
}
|
||||
loop {
|
||||
let wifiEntriesListener = wifiEntriesListener.clone();
|
||||
if listeners
|
||||
.network_listener
|
||||
.load(std::sync::atomic::Ordering::SeqCst)
|
||||
== false
|
||||
{
|
||||
break;
|
||||
}
|
||||
let res = receiver.recv();
|
||||
if res.is_ok() {
|
||||
let access_point = res.unwrap();
|
||||
match access_point {
|
||||
Events::AddedEvent(access_point) => {
|
||||
let wifiEntriesListener = wifiEntriesListener.clone();
|
||||
let wifiBoxImpl = wifibox_ref_listener.clone();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let mut wifiEntries = wifiEntriesListener.lock().unwrap();
|
||||
let ssid = access_point.0.ssid.clone();
|
||||
if wifiEntries.get(&ssid).is_some() {
|
||||
return;
|
||||
}
|
||||
let entry = WifiEntry::new(access_point.0, wifiBoxImpl.imp());
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
wifiBoxImpl.imp().resetWifiList.add(&*entry);
|
||||
});
|
||||
});
|
||||
}
|
||||
Events::RemovedEvent(access_point) => {
|
||||
let wifiBoxImpl = wifibox_ref_listener.clone();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let mut wifiEntries = wifiEntriesListener.lock().unwrap();
|
||||
let entry = wifiEntries.remove(&access_point.0.ssid);
|
||||
if entry.is_none() {
|
||||
return;
|
||||
}
|
||||
wifiBoxImpl.imp().resetWifiList.remove(&*entry.unwrap());
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
} else {
|
||||
println!("no message there :)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -236,75 +176,144 @@ pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection {
|
|||
res.unwrap()
|
||||
}
|
||||
|
||||
// temporary, testing this with lib is pain
|
||||
//
|
||||
pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
||||
gio::spawn_blocking(move || {
|
||||
if listeners.network_listener.load(Ordering::SeqCst) {
|
||||
return;
|
||||
}
|
||||
listeners.network_listener.store(true, Ordering::SeqCst);
|
||||
|
||||
pub fn start_event_listener<
|
||||
AddedType: ReadAll + AppendAll + Send + Sync + 'static,
|
||||
RemovedType: ReadAll + AppendAll + Send + Sync + 'static,
|
||||
AddedEvent: ReadAll + AppendAll + dbus::message::SignalArgs + GetVal<AddedType>,
|
||||
RemovedEvent: ReadAll + AppendAll + dbus::message::SignalArgs + GetVal<RemovedType>,
|
||||
>(
|
||||
listeners: Arc<Listeners>,
|
||||
sender: Arc<Sender<Events<AddedType, RemovedType>>>,
|
||||
) -> Result<(), dbus::Error> {
|
||||
thread::spawn(move || {
|
||||
let added_sender = sender.clone();
|
||||
let removed_sender = sender.clone();
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let mr = AddedEvent::match_rule(
|
||||
let added_ref = wifi_box.clone();
|
||||
let removed_ref = wifi_box.clone();
|
||||
let changed_ref = wifi_box.clone(); // TODO implement changed
|
||||
let access_point_added = AccessPointAdded::match_rule(
|
||||
Some(&"org.xetibo.ReSet".into()),
|
||||
Some(&Path::from("/org/xetibo/ReSet")),
|
||||
)
|
||||
.static_clone();
|
||||
let mrb = RemovedEvent::match_rule(
|
||||
let access_point_removed = AccessPointRemoved::match_rule(
|
||||
Some(&"org.xetibo.ReSet".into()),
|
||||
Some(&Path::from("/org/xetibo/ReSet")),
|
||||
)
|
||||
.static_clone();
|
||||
let res = conn.add_match(mr, move |ir: AddedEvent, _, _| {
|
||||
let access_point_changed = AccessPointChanged::match_rule(
|
||||
Some(&"org.xetibo.ReSet".into()),
|
||||
Some(&Path::from("/org/xetibo/ReSet")),
|
||||
)
|
||||
.static_clone();
|
||||
let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| {
|
||||
println!("received added event");
|
||||
let res = added_sender.send(Events::AddedEvent(ir.get_value()));
|
||||
if res.is_err() {
|
||||
println!("fail on sending added");
|
||||
return false;
|
||||
}
|
||||
let wifi_box = added_ref.clone();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let imp = wifi_box.imp();
|
||||
let mut wifiEntries = imp.wifiEntries.lock().unwrap();
|
||||
let mut wifiEntriesPath = imp.wifiEntriesPath.lock().unwrap();
|
||||
let ssid = ir.access_point.ssid.clone();
|
||||
let path = ir.access_point.dbus_path.clone();
|
||||
if wifiEntries.get(&ssid).is_some() {
|
||||
return;
|
||||
}
|
||||
let entry = WifiEntry::new(ir.access_point, imp);
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
wifiEntriesPath.insert(path, entry.clone());
|
||||
imp.resetWifiList.add(&*entry);
|
||||
});
|
||||
});
|
||||
true
|
||||
});
|
||||
if res.is_err() {
|
||||
println!("fail on add");
|
||||
return Err(dbus::Error::new_custom(
|
||||
"SignalMatchFailed",
|
||||
"Failed to match signal on ReSet.",
|
||||
));
|
||||
return;
|
||||
}
|
||||
let res = conn.add_match(mrb, move |ir: RemovedEvent, _, _| {
|
||||
let res = conn.add_match(access_point_removed, move |ir: AccessPointRemoved, _, _| {
|
||||
println!("received removed event");
|
||||
let res = removed_sender.send(Events::RemovedEvent(ir.get_value()));
|
||||
if res.is_err() {
|
||||
println!("fail on sending removed");
|
||||
return false;
|
||||
}
|
||||
let wifi_box = removed_ref.clone();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let imp = wifi_box.imp();
|
||||
let mut wifiEntries = imp.wifiEntries.lock().unwrap();
|
||||
let mut wifiEntriesPath = imp.wifiEntriesPath.lock().unwrap();
|
||||
let entry = wifiEntriesPath.remove(&ir.access_point);
|
||||
if entry.is_none() {
|
||||
return;
|
||||
}
|
||||
let entry = entry.unwrap();
|
||||
let ssid = entry.imp().accessPoint.borrow().ssid.clone();
|
||||
wifiEntries.remove(&ssid);
|
||||
imp.resetWifiList.remove(&*entry);
|
||||
});
|
||||
});
|
||||
true
|
||||
});
|
||||
if res.is_err() {
|
||||
println!("fail on remove");
|
||||
return Err(dbus::Error::new_custom(
|
||||
"SignalMatchFailed",
|
||||
"Failed to match signal on ReSet.",
|
||||
));
|
||||
return;
|
||||
}
|
||||
let res = conn.add_match(access_point_changed, move |ir: AccessPointChanged, _, _| {
|
||||
println!("received changed event");
|
||||
dbg!(ir.access_point.clone());
|
||||
let wifi_box = changed_ref.clone();
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_local_once(move || {
|
||||
let imp = wifi_box.imp();
|
||||
let wifiEntries = imp.wifiEntries.lock().unwrap();
|
||||
let entry = wifiEntries.get(&ir.access_point.ssid);
|
||||
if entry.is_none() {
|
||||
return;
|
||||
}
|
||||
let entry = entry.unwrap();
|
||||
let entryImp = entry.imp();
|
||||
let strength = WifiStrength::from_u8(ir.access_point.strength);
|
||||
let ssid = ir.access_point.ssid.clone();
|
||||
let name_opt = String::from_utf8(ssid).unwrap_or_else(|_| String::from(""));
|
||||
let name = name_opt.as_str();
|
||||
entryImp.wifiStrength.set(strength);
|
||||
entryImp.resetWifiLabel.get().set_text(name);
|
||||
entryImp.resetWifiEncrypted.set_visible(false);
|
||||
// TODO handle encryption thing
|
||||
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"),
|
||||
});
|
||||
if !ir.access_point.stored {
|
||||
entryImp.resetWifiEditButton.set_sensitive(false);
|
||||
}
|
||||
if ir.access_point.connected {
|
||||
entryImp
|
||||
.resetWifiConnected
|
||||
.get()
|
||||
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
|
||||
} else {
|
||||
entryImp.resetWifiConnected.get().set_from_icon_name(None);
|
||||
}
|
||||
{
|
||||
let mut wifiName = entryImp.wifiName.borrow_mut();
|
||||
*wifiName = String::from(name);
|
||||
}
|
||||
});
|
||||
});
|
||||
true
|
||||
});
|
||||
if res.is_err() {
|
||||
println!("fail on change");
|
||||
return;
|
||||
}
|
||||
listeners.network_listener.store(true, Ordering::SeqCst);
|
||||
println!("starting thread listener");
|
||||
loop {
|
||||
let _ = conn.process(Duration::from_millis(1000))?;
|
||||
let _ = conn.process(Duration::from_millis(1000));
|
||||
if !listeners.network_listener.load(Ordering::SeqCst) {
|
||||
println!("stopping thread listener");
|
||||
break;
|
||||
}
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::components::wifi::wifiBox;
|
||||
use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup};
|
||||
use dbus::Path;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, CompositeTemplate, ListBox, Switch};
|
||||
use gtk::{glib, CompositeTemplate, Switch};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup};
|
||||
|
||||
use crate::components::base::listEntry::ListEntry;
|
||||
use crate::components::wifi::wifiEntry::WifiEntry;
|
||||
|
@ -30,6 +31,7 @@ pub struct WifiBox {
|
|||
#[template_child]
|
||||
pub resetAvailableNetworks: TemplateChild<ListEntry>,
|
||||
pub wifiEntries: Arc<Mutex<HashMap<Vec<u8>, Arc<WifiEntry>>>>,
|
||||
pub wifiEntriesPath: Arc<Mutex<HashMap<Path<'static>, Arc<WifiEntry>>>>,
|
||||
pub savedWifiEntries: Arc<Mutex<Vec<ListEntry>>>,
|
||||
}
|
||||
|
||||
|
@ -38,6 +40,7 @@ unsafe impl Sync for WifiBox {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiBox {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetWifi";
|
||||
type Type = wifiBox::WifiBox;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -7,19 +7,17 @@ use adw::glib::{Object, PropertySet};
|
|||
use adw::prelude::{ActionRowExt, ButtonExt, EditableExt, PopoverExt};
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::{Error, Path};
|
||||
use glib::{clone, Cast};
|
||||
use dbus::Error;
|
||||
use glib::clone;
|
||||
use gtk::gio;
|
||||
use gtk::prelude::{ListBoxRowExt, WidgetExt};
|
||||
use gtk::{gio, AlertDialog, GestureClick};
|
||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||
|
||||
use crate::components::wifi::{wifiEntryImpl};
|
||||
use crate::components::wifi::wifiBox::getConnectionSettings;
|
||||
use crate::components::wifi::wifiBoxImpl::WifiBox;
|
||||
use crate::components::wifi::wifiEntryImpl;
|
||||
use crate::components::wifi::wifiOptions::WifiOptions;
|
||||
|
||||
use super::savedWifiEntry::SavedWifiEntry;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct WifiEntry(ObjectSubclass<wifiEntryImpl::WifiEntry>)
|
||||
@extends adw::ActionRow, gtk::Widget,
|
||||
|
@ -71,7 +69,7 @@ impl WifiEntry {
|
|||
entry.connect_activated(clone!(@weak entryImp => move |_| {
|
||||
let access_point = entryImp.accessPoint.borrow();
|
||||
if access_point.connected {
|
||||
click_disconnect();
|
||||
click_disconnect(stored_entry.clone());
|
||||
} else if access_point.stored {
|
||||
click_stored_network(stored_entry.clone());
|
||||
} else {
|
||||
|
@ -91,8 +89,9 @@ impl WifiEntry {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn click_disconnect() {
|
||||
pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
||||
println!("called disconnect");
|
||||
let entry_ref = entry.clone();
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
|
@ -106,7 +105,10 @@ pub fn click_disconnect() {
|
|||
println!("res of disconnect was error bro");
|
||||
return;
|
||||
}
|
||||
println!("disconnect worked");
|
||||
let imp = entry_ref.imp();
|
||||
imp.resetWifiConnected.get().set_from_icon_name(None);
|
||||
imp.accessPoint.borrow_mut().connected = false;
|
||||
println!("disconnect worked");
|
||||
});
|
||||
}
|
||||
pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
||||
|
@ -114,11 +116,6 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
|||
let entryImp = entry.imp();
|
||||
let access_point = entryImp.accessPoint.borrow().clone();
|
||||
let entry_ref = entry.clone();
|
||||
let popup = entry.imp().resetWifiPopup.imp();
|
||||
popup.resetPopupLabel.set_text("Connecting...");
|
||||
popup.resetPopupLabel.set_visible(true);
|
||||
popup.resetPopupEntry.set_sensitive(false);
|
||||
popup.resetPopupButton.set_sensitive(false);
|
||||
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
|
@ -134,21 +131,23 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
|||
);
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
let imp = entry_ref.imp();
|
||||
let popup = imp.resetWifiPopup.imp();
|
||||
let _imp = entry_ref.imp();
|
||||
if res.is_err() {
|
||||
popup.resetPopupLabel.set_text("Could not connect to dbus.");
|
||||
println!("wat bro?");
|
||||
result.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
if res.unwrap() == (false,) {
|
||||
popup
|
||||
.resetPopupLabel
|
||||
.set_text("Could not connect to access point.");
|
||||
println!("error bro?");
|
||||
result.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
entry_ref.imp().resetWifiPopup.popdown();
|
||||
let imp = entry_ref.imp();
|
||||
println!("wateroni");
|
||||
imp.resetWifiConnected
|
||||
.get()
|
||||
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
|
||||
imp.accessPoint.borrow_mut().connected = true;
|
||||
result.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
});
|
||||
});
|
||||
|
@ -205,7 +204,12 @@ pub fn click_new_network(entry: Arc<WifiEntry>) {
|
|||
return;
|
||||
}
|
||||
println!("worked?");
|
||||
entry_ref.imp().resetWifiPopup.popdown();
|
||||
let imp = entry_ref.imp();
|
||||
imp.resetWifiPopup.popdown();
|
||||
imp.resetWifiEditButton.set_sensitive(true);
|
||||
imp.resetWifiConnected
|
||||
.get()
|
||||
.set_from_icon_name(Some("network-wireless-connected-symbolic"));
|
||||
result.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,6 +34,7 @@ unsafe impl Sync for WifiEntry {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetWifiEntry";
|
||||
type Type = wifiEntry::WifiEntry;
|
||||
type ParentType = ActionRow;
|
||||
|
|
|
@ -5,7 +5,7 @@ use adw::glib::Object;
|
|||
use adw::prelude::{ActionRowExt, ComboRowExt, PreferencesGroupExt};
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use dbus::arg::PropMap;
|
||||
use glib::{PropertySet, Cast, ObjectExt, clone};
|
||||
use glib::{PropertySet, ObjectExt};
|
||||
use gtk::prelude::{EditableExt, WidgetExt};
|
||||
use ReSet_Lib::network::connection::{Connection, Enum, TypeSettings};
|
||||
|
||||
|
@ -31,13 +31,13 @@ impl WifiOptions {
|
|||
let selfImp = self.imp();
|
||||
let conn = selfImp.connection.borrow();
|
||||
// General
|
||||
selfImp.resetWifiName.set_subtitle(&*conn.settings.name);
|
||||
selfImp.resetWifiName.set_subtitle(&conn.settings.name);
|
||||
selfImp.resetWifiAutoConnect.set_active(conn.settings.autoconnect);
|
||||
selfImp.resetWifiMetered.set_active(if conn.settings.metered != -1 { true } else { false });
|
||||
selfImp.resetWifiMetered.set_active(conn.settings.metered != -1);
|
||||
match &conn.device {
|
||||
TypeSettings::WIFI(wifi) => {}
|
||||
TypeSettings::ETHERNET(ethernet) => {}
|
||||
TypeSettings::VPN(vpn) => {}
|
||||
TypeSettings::WIFI(_wifi) => {}
|
||||
TypeSettings::ETHERNET(_ethernet) => {}
|
||||
TypeSettings::VPN(_vpn) => {}
|
||||
TypeSettings::None => {}
|
||||
};
|
||||
// IPv4
|
||||
|
@ -52,8 +52,8 @@ impl WifiOptions {
|
|||
.join(".")
|
||||
})
|
||||
.collect();
|
||||
selfImp.resetIP4DNS.set_text(&*ipv4Dns.join(", "));
|
||||
selfImp.resetIP4Gateway.set_text(&*conn.ipv4.gateway);
|
||||
selfImp.resetIP4DNS.set_text(&ipv4Dns.join(", "));
|
||||
selfImp.resetIP4Gateway.set_text(&conn.ipv4.gateway);
|
||||
|
||||
if conn.ipv4.address_data.is_empty() {
|
||||
selfImp.resetIP4AddressGroup.add(&WifiAddressEntry::new(None))
|
||||
|
@ -82,8 +82,8 @@ impl WifiOptions {
|
|||
.join(":")
|
||||
})
|
||||
.collect();
|
||||
selfImp.resetIP6DNS.set_text(&*ipv6Dns.join(", "));
|
||||
selfImp.resetIP6Gateway.set_text(&*conn.ipv6.gateway);
|
||||
selfImp.resetIP6DNS.set_text(&ipv6Dns.join(", "));
|
||||
selfImp.resetIP6Gateway.set_text(&conn.ipv6.gateway);
|
||||
|
||||
if conn.ipv6.address_data.is_empty() {
|
||||
selfImp.resetIP6AddressGroup.add(&WifiAddressEntry::new(None))
|
||||
|
|
|
@ -59,6 +59,7 @@ pub struct WifiOptions {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiOptions {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetWifiOptions";
|
||||
type Type = wifiOptions::WifiOptions;
|
||||
type ParentType = NavigationPage;
|
||||
|
|
|
@ -26,11 +26,11 @@ impl WifiRouteEntry {
|
|||
let gateway = getValueFromKey(&map, "gateway");
|
||||
let metric = getValueFromKey(&map, "metric");
|
||||
|
||||
entryImp.resetRouteAddress.set_text(&*addr);
|
||||
entryImp.resetRouteNetmask.set_text(&*prefix);
|
||||
entryImp.resetRouteGateway.set_text(&*gateway);
|
||||
entryImp.resetRouteMetric.set_text(&*metric);
|
||||
entryImp.resetRouteRow.set_title(&*format!("{}, {}, {}, {}", addr, prefix, gateway, metric));
|
||||
entryImp.resetRouteAddress.set_text(&addr);
|
||||
entryImp.resetRouteNetmask.set_text(&prefix);
|
||||
entryImp.resetRouteGateway.set_text(&gateway);
|
||||
entryImp.resetRouteMetric.set_text(&metric);
|
||||
entryImp.resetRouteRow.set_title(&format!("{}, {}, {}, {}", addr, prefix, gateway, metric));
|
||||
}
|
||||
entry
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ pub struct WifiRouteEntryImpl {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiRouteEntryImpl {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetWifiRouteEntry";
|
||||
type Type = wifiRouteEntry::WifiRouteEntry;
|
||||
type ParentType = gtk::Box;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
use gtk::prelude::FrameExt;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::components::base::settingBox::SettingBox;
|
||||
use crate::components::base::utils::{start_audio_listener, Listeners};
|
||||
use crate::components::bluetooth::bluetoothBox::{start_bluetooth_listener, BluetoothBox};
|
||||
use crate::components::input::sourceBox::{populate_sources, SourceBox};
|
||||
use crate::components::output::sinkBox::{populate_sinks, SinkBox};
|
||||
use crate::components::wifi::wifiBox::{scanForWifi, show_stored_connections, WifiBox};
|
||||
use crate::components::wifi::wifiBox::{
|
||||
scanForWifi, show_stored_connections, start_event_listener, WifiBox,
|
||||
};
|
||||
use gtk::prelude::WidgetExt;
|
||||
use gtk::{FlowBox, Frame, Label};
|
||||
|
||||
|
@ -15,6 +17,7 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc<Listeners>, FlowBox) =
|
|||
|listeners: Arc<Listeners>, resetMain: FlowBox| {
|
||||
listeners.stop_audio_listener();
|
||||
let wifiBox = Arc::new(WifiBox::new());
|
||||
start_event_listener(listeners.clone(), wifiBox.clone());
|
||||
show_stored_connections(wifiBox.clone());
|
||||
scanForWifi(listeners.clone(), wifiBox.clone());
|
||||
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
||||
|
@ -32,6 +35,7 @@ pub const HANDLE_WIFI_CLICK: fn(Arc<Listeners>, FlowBox) =
|
|||
listeners.stop_audio_listener();
|
||||
listeners.stop_bluetooth_listener();
|
||||
let wifiBox = Arc::new(WifiBox::new());
|
||||
start_event_listener(listeners.clone(), wifiBox.clone());
|
||||
show_stored_connections(wifiBox.clone());
|
||||
scanForWifi(listeners.clone(), wifiBox.clone());
|
||||
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
|
||||
|
@ -90,7 +94,7 @@ pub const HANDLE_VOLUME_CLICK: fn(Arc<Listeners>, FlowBox) =
|
|||
listeners.stop_bluetooth_listener();
|
||||
let audioOutput = Arc::new(SinkBox::new());
|
||||
start_audio_listener(listeners.clone(), Some(audioOutput.clone()), None);
|
||||
while !listeners.pulse_listener.load(Ordering::SeqCst) {}
|
||||
while !listeners.pulse_listener.load(Ordering::SeqCst) { std::hint::spin_loop() }
|
||||
populate_sinks(audioOutput.clone());
|
||||
let audioFrame = wrapInFrame(SettingBox::new(&*audioOutput));
|
||||
resetMain.remove_all();
|
||||
|
|
|
@ -47,6 +47,7 @@ impl Default for SidebarAction {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SidebarEntry {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetSidebarEntry";
|
||||
type Type = sidebarEntry::SidebarEntry;
|
||||
type ParentType = ListBoxRow;
|
||||
|
|
|
@ -81,7 +81,7 @@ impl Window {
|
|||
pub fn filterList(&self) {
|
||||
let text = self.imp().resetSearchEntry.text().to_string();
|
||||
for (mainEntry, subEntries) in self.imp().sidebarEntries.borrow().iter() {
|
||||
if text == "" {
|
||||
if text.is_empty() {
|
||||
mainEntry.set_visible(true);
|
||||
for subEntry in subEntries {
|
||||
subEntry.set_visible(true);
|
||||
|
|
|
@ -6,7 +6,7 @@ use adw::subclass::prelude::AdwApplicationWindowImpl;
|
|||
use adw::{Breakpoint, OverlaySplitView};
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, Box, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, SearchEntry};
|
||||
use gtk::{glib, Button, CompositeTemplate, FlowBox, ListBox, PopoverMenu, SearchEntry};
|
||||
|
||||
use crate::components::base::utils::Listeners;
|
||||
use crate::components::wifi::wifiBox::WifiBox;
|
||||
|
@ -48,6 +48,7 @@ unsafe impl Sync for Window {}
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Window {
|
||||
const ABSTRACT: bool = false;
|
||||
const NAME: &'static str = "resetUI";
|
||||
type Type = window::Window;
|
||||
type ParentType = adw::ApplicationWindow;
|
||||
|
|
Loading…
Reference in a new issue