mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-01 15:57:46 +02:00
Add wifiOptions (ui only)
This commit is contained in:
parent
1080a03b8b
commit
5311bb8c4c
12 changed files with 847 additions and 50 deletions
|
@ -122,7 +122,7 @@ pub fn populate_sinks(output_box: Arc<SinkBox>) {
|
|||
sink,
|
||||
));
|
||||
let sink_clone = sink_entry.clone();
|
||||
let entry = Arc::new(ListEntry::new(&*sink_entry));
|
||||
let entry = Arc::new(ListEntry::new(&*sink_entry, ));
|
||||
entry.set_activatable(false);
|
||||
list.insert(index, (entry.clone(), sink_clone, alias));
|
||||
output_box_imp.resetSinks.append(&*entry);
|
||||
|
@ -217,7 +217,7 @@ pub fn populate_inputstreams(output_box: Arc<SinkBox>) {
|
|||
for stream in streams {
|
||||
let index = stream.index;
|
||||
let input_stream = Arc::new(InputStreamEntry::new(output_box.clone(), stream));
|
||||
let entry = Arc::new(ListEntry::new(&*input_stream));
|
||||
let entry = Arc::new(ListEntry::new(&*input_stream, ));
|
||||
entry.set_activatable(false);
|
||||
list.insert(index, (entry.clone(), input_stream.clone()));
|
||||
output_box_imp.resetInputStreams.append(&*entry);
|
||||
|
@ -359,7 +359,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
|||
ir.sink,
|
||||
));
|
||||
let sink_clone = sink_entry.clone();
|
||||
let entry = Arc::new(ListEntry::new(&*sink_entry));
|
||||
let entry = Arc::new(ListEntry::new(&*sink_entry, ));
|
||||
entry.set_activatable(false);
|
||||
list.insert(sink_index, (entry.clone(), sink_clone, alias.clone()));
|
||||
output_box_imp.resetSinks.append(&*entry);
|
||||
|
@ -462,7 +462,7 @@ pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Co
|
|||
let mut list = output_box_imp.resetInputStreamList.write().unwrap();
|
||||
let index = ir.stream.index;
|
||||
let input_stream = Arc::new(InputStreamEntry::new(output_box.clone(), ir.stream));
|
||||
let entry = Arc::new(ListEntry::new(&*input_stream));
|
||||
let entry = Arc::new(ListEntry::new(&*input_stream, ));
|
||||
entry.set_activatable(false);
|
||||
list.insert(index, (entry.clone(), input_stream.clone()));
|
||||
output_box_imp.resetInputStreams.append(&*entry);
|
||||
|
|
|
@ -5,3 +5,5 @@ pub mod wifiBox;
|
|||
pub mod wifiBoxImpl;
|
||||
pub mod wifiEntry;
|
||||
pub mod wifiEntryImpl;
|
||||
pub mod wifiOptions;
|
||||
pub mod wifiOptionsImpl;
|
||||
|
|
|
@ -15,6 +15,7 @@ use dbus::arg::{AppendAll, ReadAll, RefArg};
|
|||
use dbus::blocking::Connection;
|
||||
use dbus::Error;
|
||||
use dbus::Path;
|
||||
use glib::ObjectExt;
|
||||
use gtk::gio;
|
||||
use gtk::glib::Variant;
|
||||
use gtk::prelude::ActionableExt;
|
||||
|
@ -74,7 +75,7 @@ pub fn scanForWifi(listeners: Arc<Listeners>, wifiBox: Arc<WifiBox>) {
|
|||
let selfImp = wifibox_ref.imp();
|
||||
for accessPoint in accessPoints {
|
||||
let ssid = accessPoint.ssid.clone();
|
||||
let entry = Arc::new(ListEntry::new(&*WifiEntry::new(accessPoint)));
|
||||
let entry = Arc::new(ListEntry::new(&*WifiEntry::new(accessPoint, selfImp)));
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
selfImp.resetWifiList.append(&*entry);
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ pub fn scanForWifi(listeners: Arc<Listeners>, wifiBox: Arc<WifiBox>) {
|
|||
return;
|
||||
}
|
||||
let entry =
|
||||
Arc::new(ListEntry::new(&*WifiEntry::new(access_point.0)));
|
||||
Arc::new(ListEntry::new(&*WifiEntry::new(access_point.0, wifiBoxImpl.imp())));
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
wifiBoxImpl.imp().resetWifiList.append(&*entry);
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ use gtk::subclass::prelude::*;
|
|||
use gtk::{glib, CompositeTemplate, ListBox, Switch};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use adw::NavigationView;
|
||||
|
||||
use crate::components::base::listEntry::ListEntry;
|
||||
use crate::components::wifi::wifiEntry::WifiEntry;
|
||||
|
@ -12,6 +13,8 @@ use crate::components::wifi::wifiEntry::WifiEntry;
|
|||
#[derive(Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/Xetibo/ReSet/resetWiFi.ui")]
|
||||
pub struct WifiBox {
|
||||
#[template_child]
|
||||
pub resetWifiNavigation: TemplateChild<NavigationView>,
|
||||
#[template_child]
|
||||
pub resetWifiDetails: TemplateChild<ListBox>,
|
||||
#[template_child]
|
||||
|
|
|
@ -13,9 +13,10 @@ use gtk::prelude::{ListBoxRowExt, WidgetExt};
|
|||
use gtk::{gio, AlertDialog, GestureClick};
|
||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||
|
||||
use crate::components::base::listEntry::ListEntry;
|
||||
use crate::components::wifi::{wifiEntryImpl};
|
||||
use crate::components::wifi::wifiBox::getConnectionSettings;
|
||||
use crate::components::wifi::wifiEntryImpl;
|
||||
use crate::components::wifi::wifiBoxImpl::WifiBox;
|
||||
use crate::components::wifi::wifiOptions::WifiOptions;
|
||||
|
||||
use super::savedWifiEntry::SavedWifiEntry;
|
||||
|
||||
|
@ -29,7 +30,7 @@ unsafe impl Send for WifiEntry {}
|
|||
unsafe impl Sync for WifiEntry {}
|
||||
|
||||
impl WifiEntry {
|
||||
pub fn new(access_point: AccessPoint) -> Arc<Self> {
|
||||
pub fn new(access_point: AccessPoint, wifiBox: &WifiBox) -> Arc<Self> {
|
||||
let entry: Arc<WifiEntry> = Arc::new(Object::builder().build());
|
||||
let stored_entry = entry.clone();
|
||||
let new_entry = entry.clone();
|
||||
|
@ -77,14 +78,15 @@ impl WifiEntry {
|
|||
}
|
||||
}));
|
||||
entry.add_controller(gesture);
|
||||
entry.setupCallbacks(wifiBox);
|
||||
entry
|
||||
}
|
||||
|
||||
pub fn setupCallbacks(&self) {
|
||||
pub fn setupCallbacks(&self, wifiBox: &WifiBox) {
|
||||
let selfImp = self.imp();
|
||||
selfImp.resetWifiEditButton.connect_clicked(clone!(@ weak selfImp => move |_| {
|
||||
// TODO open navigationpage
|
||||
selfImp.resetWifiEditButton.connect_clicked(clone!(@ weak selfImp, @ weak wifiBox => move |_| {
|
||||
let _option = getConnectionSettings(selfImp.accessPoint.borrow().associated_connection.clone());
|
||||
wifiBox.resetWifiNavigation.push(&WifiOptions::new(_option));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,9 +50,6 @@ impl ObjectSubclass for WifiEntry {
|
|||
impl ObjectImpl for WifiEntry {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
let obj = self.obj();
|
||||
obj.setupCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
src/components/wifi/wifiOptions.rs
Normal file
21
src/components/wifi/wifiOptions.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use adw::glib;
|
||||
use adw::glib::Object;
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use glib::PropertySet;
|
||||
use ReSet_Lib::network::connection::Connection;
|
||||
use crate::components::wifi::{wifiOptionsImpl};
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct WifiOptions(ObjectSubclass<wifiOptionsImpl::WifiOptions>)
|
||||
@extends adw::NavigationPage, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl WifiOptions {
|
||||
pub fn new(option: Option<Connection>) -> Self {
|
||||
let wifiOption: WifiOptions = Object::builder().build();
|
||||
wifiOption.imp().options.set(option);
|
||||
wifiOption
|
||||
}
|
||||
|
||||
}
|
45
src/components/wifi/wifiOptionsImpl.rs
Normal file
45
src/components/wifi/wifiOptionsImpl.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
use std::cell::RefCell;
|
||||
use adw::NavigationPage;
|
||||
use adw::subclass::prelude::NavigationPageImpl;
|
||||
use crate::components::wifi::{wifiOptions};
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, CompositeTemplate};
|
||||
use ReSet_Lib::network::connection::Connection;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/Xetibo/ReSet/resetWifiOptions.ui")]
|
||||
pub struct WifiOptions {
|
||||
pub options: RefCell<Option<Connection>> // Option<Rc<RefCell<Connection>>>
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for WifiOptions {
|
||||
const NAME: &'static str = "resetWifiOptions";
|
||||
type Type = wifiOptions::WifiOptions;
|
||||
type ParentType = NavigationPage;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl NavigationPageImpl for WifiOptions {}
|
||||
|
||||
impl ObjectImpl for WifiOptions {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for WifiOptions {}
|
||||
|
||||
impl WidgetImpl for WifiOptions {}
|
||||
|
||||
impl WindowImpl for WifiOptions {}
|
||||
|
||||
impl ApplicationWindowImpl for WifiOptions {}
|
Loading…
Add table
Add a link
Reference in a new issue