mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-17 10:18:32 +02:00
fix remove saved wifi entry
This commit is contained in:
parent
b9ed39f85b
commit
aba894f3a8
|
@ -1,10 +1,11 @@
|
||||||
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::components::wifi::saved_wifi_entry_impl;
|
use crate::components::wifi::saved_wifi_entry_impl;
|
||||||
use crate::components::wifi::wifi_box_impl::WifiBox;
|
use crate::components::wifi::wifi_box_impl::WifiBox;
|
||||||
use adw::glib;
|
use adw::glib;
|
||||||
use adw::glib::Object;
|
use adw::glib::Object;
|
||||||
use adw::prelude::{ActionRowExt, ButtonExt, PreferencesRowExt, WidgetExt};
|
use adw::prelude::{ActionRowExt, ButtonExt, PreferencesRowExt, PreferencesGroupExt};
|
||||||
use dbus::blocking::Connection;
|
use dbus::blocking::Connection;
|
||||||
use dbus::{Error, Path};
|
use dbus::{Error, Path};
|
||||||
use glib::subclass::types::ObjectSubclassIsExt;
|
use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
|
@ -21,8 +22,8 @@ glib::wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SavedWifiEntry {
|
impl SavedWifiEntry {
|
||||||
pub fn new(name: &str, path: Path<'static>, wifi_box: &WifiBox) -> Self {
|
pub fn new(name: &str, path: Path<'static>, wifi_box: &WifiBox) -> Rc<Self> {
|
||||||
let entry: SavedWifiEntry = Object::builder().build();
|
let entry: Rc<SavedWifiEntry> = Rc::new(Object::builder().build());
|
||||||
entry.set_activatable(false);
|
entry.set_activatable(false);
|
||||||
let entry_imp = entry.imp();
|
let entry_imp = entry.imp();
|
||||||
|
|
||||||
|
@ -50,15 +51,13 @@ impl SavedWifiEntry {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
delete_button.connect_clicked(
|
let entry_ref = entry.clone();
|
||||||
clone!(@weak entry as entry => move |_| {
|
delete_button.connect_clicked(clone!(@weak wifi_box => move |_| {
|
||||||
delete_connection(entry.imp().reset_connection_path.take());
|
delete_connection(entry_ref.imp().reset_connection_path.take());
|
||||||
// TODO handle error
|
// TODO handle error
|
||||||
let parent = entry.parent().unwrap();
|
wifi_box.reset_stored_wifi_list.remove(&*entry_ref);
|
||||||
parent.set_visible(false);
|
|
||||||
parent.unparent();
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
entry
|
entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ pub fn show_stored_connections(wifi_box: Arc<WifiBox>) {
|
||||||
let name =
|
let name =
|
||||||
&String::from_utf8(connection.1).unwrap_or_else(|_| String::from(""));
|
&String::from_utf8(connection.1).unwrap_or_else(|_| String::from(""));
|
||||||
let entry = SavedWifiEntry::new(name, connection.0, self_imp);
|
let entry = SavedWifiEntry::new(name, connection.0, self_imp);
|
||||||
self_imp.reset_stored_wifi_list.add(&entry);
|
self_imp.reset_stored_wifi_list.add(&*entry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue