Hide separator if there are no visible networks
This commit is contained in:
parent
f9bea05bbb
commit
131b1e501c
2 changed files with 8 additions and 5 deletions
|
|
@ -43,8 +43,10 @@ fn build_ui(application: >k4::Application) {
|
||||||
ui::toggles::add_toggles(&main_box);
|
ui::toggles::add_toggles(&main_box);
|
||||||
main_box.append(&Separator::new(Orientation::Horizontal));
|
main_box.append(&Separator::new(Orientation::Horizontal));
|
||||||
ui::current_networks::add_current_networks(&main_box);
|
ui::current_networks::add_current_networks(&main_box);
|
||||||
main_box.append(&Separator::new(Orientation::Horizontal));
|
let available_wifi_separator = Separator::new(Orientation::Horizontal);
|
||||||
ui::available_wifi::add_available_wifi(&main_box);
|
main_box.append(&available_wifi_separator);
|
||||||
|
available_wifi_separator.hide();
|
||||||
|
ui::available_wifi::add_available_wifi(&main_box, available_wifi_separator);
|
||||||
window.set_child(Some(&main_box));
|
window.set_child(Some(&main_box));
|
||||||
|
|
||||||
window.show();
|
window.show();
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ use futures_util::StreamExt;
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
glib::{self, clone, source::PRIORITY_DEFAULT, MainContext, Sender},
|
glib::{self, clone, source::PRIORITY_DEFAULT, MainContext, Sender},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
Align, Image,
|
Align, Image, Separator,
|
||||||
};
|
};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
|
|
||||||
pub fn add_available_wifi(target: >k4::Box) {
|
pub fn add_available_wifi(target: >k4::Box, separator: Separator) {
|
||||||
let ap_entries = Rc::<RefCell<Vec<SettingsEntry>>>::default();
|
let ap_entries = Rc::<RefCell<Vec<SettingsEntry>>>::default();
|
||||||
let (tx, rx) = MainContext::channel::<Vec<AccessPoint>>(PRIORITY_DEFAULT);
|
let (tx, rx) = MainContext::channel::<Vec<AccessPoint>>(PRIORITY_DEFAULT);
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
|
|
@ -24,8 +24,9 @@ pub fn add_available_wifi(target: >k4::Box) {
|
||||||
});
|
});
|
||||||
rx.attach(
|
rx.attach(
|
||||||
None,
|
None,
|
||||||
clone!(@strong ap_entries, @weak target => @default-return Continue(true), move |aps| {
|
clone!(@strong ap_entries, @weak target, @weak separator, => @default-return Continue(true), move |aps| {
|
||||||
build_aps_list(ap_entries.clone(), target, dbg!(aps));
|
build_aps_list(ap_entries.clone(), target, dbg!(aps));
|
||||||
|
separator.set_visible(!ap_entries.borrow().is_empty());
|
||||||
Continue(true)
|
Continue(true)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue