mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-01 15:57:46 +02:00
Improve UI
This commit is contained in:
parent
d9d5d2960d
commit
072d516ad1
17 changed files with 258 additions and 331 deletions
|
@ -59,18 +59,6 @@ impl CardEntry {
|
|||
let factory = &SignalListItemFactory::new();
|
||||
factory.connect_setup(|_, item| {
|
||||
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||
|
||||
let value = item.property_value("selected");
|
||||
let value2 = item.property_value("item");
|
||||
|
||||
let result = value.get::<bool>().unwrap();
|
||||
|
||||
dbg!(result);
|
||||
|
||||
for x in item.list_properties() {
|
||||
|
||||
}
|
||||
|
||||
let label = gtk::Label::new(None);
|
||||
label.set_halign(Align::Start);
|
||||
item.property_expression("item")
|
||||
|
@ -79,7 +67,6 @@ impl CardEntry {
|
|||
item.set_child(Some(&label));
|
||||
});
|
||||
entry.set_factory(Some(factory));
|
||||
|
||||
}
|
||||
entry
|
||||
}
|
||||
|
|
|
@ -9,16 +9,18 @@ use dbus::{Error, Path};
|
|||
use glib::subclass::types::ObjectSubclassIsExt;
|
||||
use glib::{clone, PropertySet};
|
||||
use gtk::gio;
|
||||
use gtk::prelude::ListBoxRowExt;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct SavedWifiEntry(ObjectSubclass<savedWifiEntryImpl::SavedWifiEntry>)
|
||||
@extends gtk::Box, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
|
||||
@extends adw::ActionRow, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget, gtk::ListBoxRow;
|
||||
}
|
||||
|
||||
impl SavedWifiEntry {
|
||||
pub fn new(name: &String, path: Path<'static>) -> Self {
|
||||
let entry: SavedWifiEntry = Object::builder().build();
|
||||
entry.set_activatable(false);
|
||||
let entryImp = entry.imp();
|
||||
// TODO handle edit
|
||||
entryImp.resetSavedWifiLabel.set_text(name);
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use std::cell::RefCell;
|
||||
use adw::ActionRow;
|
||||
use adw::subclass::preferences_row::PreferencesRowImpl;
|
||||
use adw::subclass::prelude::ActionRowImpl;
|
||||
|
||||
use dbus::Path;
|
||||
use gtk::subclass::prelude::*;
|
||||
|
@ -26,7 +29,7 @@ unsafe impl Sync for SavedWifiEntry {}
|
|||
impl ObjectSubclass for SavedWifiEntry {
|
||||
const NAME: &'static str = "resetSavedWifiEntry";
|
||||
type Type = savedWifiEntry::SavedWifiEntry;
|
||||
type ParentType = gtk::Box;
|
||||
type ParentType = ActionRow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
|
@ -43,7 +46,11 @@ impl ObjectImpl for SavedWifiEntry {
|
|||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for SavedWifiEntry {}
|
||||
impl PreferencesRowImpl for SavedWifiEntry {}
|
||||
|
||||
impl ListBoxRowImpl for SavedWifiEntry {}
|
||||
|
||||
impl ActionRowImpl for SavedWifiEntry {}
|
||||
|
||||
impl WidgetImpl for SavedWifiEntry {}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::components::base::listEntry::ListEntry;
|
|||
use crate::components::base::utils::Listeners;
|
||||
use adw::glib;
|
||||
use adw::glib::Object;
|
||||
use adw::prelude::ListBoxRowExt;
|
||||
use adw::prelude::{ListBoxRowExt, PreferencesGroupExt};
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use dbus::arg::{AppendAll, ReadAll, RefArg};
|
||||
use dbus::blocking::Connection;
|
||||
|
@ -48,6 +48,7 @@ impl WifiBox {
|
|||
|
||||
pub fn setupCallbacks(&self) {
|
||||
let selfImp = self.imp();
|
||||
selfImp.resetSavedNetworks.set_activatable(true);
|
||||
selfImp
|
||||
.resetSavedNetworks
|
||||
.set_action_name(Some("navigation.push"));
|
||||
|
@ -76,9 +77,9 @@ 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, selfImp)));
|
||||
let entry = WifiEntry::new(accessPoint, selfImp);
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
selfImp.resetWifiList.append(&*entry);
|
||||
selfImp.resetWifiList.add(&*entry);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -124,10 +125,9 @@ pub fn scanForWifi(listeners: Arc<Listeners>, wifiBox: Arc<WifiBox>) {
|
|||
if wifiEntries.get(&ssid).is_some() {
|
||||
return;
|
||||
}
|
||||
let entry =
|
||||
Arc::new(ListEntry::new(&*WifiEntry::new(access_point.0, wifiBoxImpl.imp())));
|
||||
let entry = WifiEntry::new(access_point.0, wifiBoxImpl.imp());
|
||||
wifiEntries.insert(ssid, entry.clone());
|
||||
wifiBoxImpl.imp().resetWifiList.append(&*entry);
|
||||
wifiBoxImpl.imp().resetWifiList.add(&*entry);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -163,9 +163,8 @@ pub fn show_stored_connections(wifiBox: Arc<WifiBox>) {
|
|||
// TODO include button for settings
|
||||
let name =
|
||||
&String::from_utf8(connection.1).unwrap_or_else(|_| String::from(""));
|
||||
let entry = ListEntry::new(&SavedWifiEntry::new(name, connection.0));
|
||||
entry.set_activatable(false);
|
||||
selfImp.resetStoredWifiList.append(&entry);
|
||||
let entry = SavedWifiEntry::new(name, connection.0);
|
||||
selfImp.resetStoredWifiList.add(&entry);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +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 adw::{ActionRow, ComboRow, NavigationView, PreferencesGroup};
|
||||
|
||||
use crate::components::base::listEntry::ListEntry;
|
||||
use crate::components::wifi::wifiEntry::WifiEntry;
|
||||
|
@ -16,18 +16,20 @@ pub struct WifiBox {
|
|||
#[template_child]
|
||||
pub resetWifiNavigation: TemplateChild<NavigationView>,
|
||||
#[template_child]
|
||||
pub resetWifiDetails: TemplateChild<ListBox>,
|
||||
pub resetWifiDetails: TemplateChild<PreferencesGroup>,
|
||||
#[template_child]
|
||||
pub resetSavedNetworks: TemplateChild<ListEntry>,
|
||||
pub resetWiFiDevice: TemplateChild<ComboRow>,
|
||||
#[template_child]
|
||||
pub resetSavedNetworks: TemplateChild<ActionRow>,
|
||||
#[template_child]
|
||||
pub resetWifiSwitch: TemplateChild<Switch>,
|
||||
#[template_child]
|
||||
pub resetWifiList: TemplateChild<ListBox>,
|
||||
pub resetWifiList: TemplateChild<PreferencesGroup>,
|
||||
#[template_child]
|
||||
pub resetStoredWifiList: TemplateChild<ListBox>,
|
||||
pub resetStoredWifiList: TemplateChild<PreferencesGroup>,
|
||||
#[template_child]
|
||||
pub resetAvailableNetworks: TemplateChild<ListEntry>,
|
||||
pub wifiEntries: Arc<Mutex<HashMap<Vec<u8>, Arc<ListEntry>>>>,
|
||||
pub wifiEntries: Arc<Mutex<HashMap<Vec<u8>, Arc<WifiEntry>>>>,
|
||||
pub savedWifiEntries: Arc<Mutex<Vec<ListEntry>>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::time::Duration;
|
|||
|
||||
use adw::glib;
|
||||
use adw::glib::{Object, PropertySet};
|
||||
use adw::prelude::{ButtonExt, EditableExt, PopoverExt};
|
||||
use adw::prelude::{ActionRowExt, ButtonExt, EditableExt, PopoverExt};
|
||||
use adw::subclass::prelude::ObjectSubclassIsExt;
|
||||
use dbus::blocking::Connection;
|
||||
use dbus::{Error, Path};
|
||||
|
@ -22,8 +22,8 @@ use super::savedWifiEntry::SavedWifiEntry;
|
|||
|
||||
glib::wrapper! {
|
||||
pub struct WifiEntry(ObjectSubclass<wifiEntryImpl::WifiEntry>)
|
||||
@extends gtk::Box, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget;
|
||||
@extends adw::ActionRow, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::Actionable, gtk::ConstraintTarget, gtk::ListBoxRow;
|
||||
}
|
||||
|
||||
unsafe impl Send for WifiEntry {}
|
||||
|
@ -66,8 +66,9 @@ impl WifiEntry {
|
|||
*wifiName = String::from(name);
|
||||
}
|
||||
entryImp.accessPoint.set(access_point);
|
||||
let gesture = GestureClick::new();
|
||||
gesture.connect_released(clone!(@weak entryImp => move |_, _, _, _| {
|
||||
|
||||
entry.set_activatable(true);
|
||||
entry.connect_activated(clone!(@weak entryImp => move |_| {
|
||||
let access_point = entryImp.accessPoint.borrow();
|
||||
if access_point.connected {
|
||||
click_disconnect();
|
||||
|
@ -77,7 +78,6 @@ impl WifiEntry {
|
|||
click_new_network(new_entry.clone());
|
||||
}
|
||||
}));
|
||||
entry.add_controller(gesture);
|
||||
entry.setupCallbacks(wifiBox);
|
||||
entry
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ use crate::components::wifi::wifiEntry;
|
|||
use gtk::subclass::prelude::*;
|
||||
use gtk::{glib, Button, CompositeTemplate, Image, Label};
|
||||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
use adw::ActionRow;
|
||||
use adw::subclass::preferences_row::PreferencesRowImpl;
|
||||
use adw::subclass::prelude::ActionRowImpl;
|
||||
use ReSet_Lib::network::network::{AccessPoint, WifiStrength};
|
||||
|
||||
use super::wifiBox::WifiBox;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/Xetibo/ReSet/resetWifiEntry.ui")]
|
||||
|
@ -36,7 +36,7 @@ unsafe impl Sync for WifiEntry {}
|
|||
impl ObjectSubclass for WifiEntry {
|
||||
const NAME: &'static str = "resetWifiEntry";
|
||||
type Type = wifiEntry::WifiEntry;
|
||||
type ParentType = gtk::Box;
|
||||
type ParentType = ActionRow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
|
@ -53,7 +53,11 @@ impl ObjectImpl for WifiEntry {
|
|||
}
|
||||
}
|
||||
|
||||
impl BoxImpl for WifiEntry {}
|
||||
impl PreferencesRowImpl for WifiEntry {}
|
||||
|
||||
impl ListBoxRowImpl for WifiEntry {}
|
||||
|
||||
impl ActionRowImpl for WifiEntry {}
|
||||
|
||||
impl WidgetImpl for WifiEntry {}
|
||||
|
||||
|
|
|
@ -34,12 +34,12 @@ impl WifiOptions {
|
|||
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 });
|
||||
// match conn.device.borrow() {
|
||||
// TypeSettings::WIFI(wifi) => {}
|
||||
// TypeSettings::ETHERNET(ethernet) => {}
|
||||
// TypeSettings::VPN(vpn) => {}
|
||||
// TypeSettings::None => {}
|
||||
// };
|
||||
match &conn.device {
|
||||
TypeSettings::WIFI(wifi) => {}
|
||||
TypeSettings::ETHERNET(ethernet) => {}
|
||||
TypeSettings::VPN(vpn) => {}
|
||||
TypeSettings::None => {}
|
||||
};
|
||||
// IPv4
|
||||
selfImp.resetIP4Method.set_selected(conn.ipv4.dns_method.to_i32() as u32);
|
||||
self.setIP4Visibility(conn.ipv4.dns_method.to_i32() as u32);
|
||||
|
|
|
@ -30,8 +30,6 @@ pub struct Window {
|
|||
#[template_child]
|
||||
pub resetSideBarToggle: TemplateChild<Button>,
|
||||
#[template_child]
|
||||
pub resetPath: TemplateChild<Box>,
|
||||
#[template_child]
|
||||
pub resetPopoverMenu: TemplateChild<PopoverMenu>,
|
||||
#[template_child]
|
||||
pub resetClose: TemplateChild<Button>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue