mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Go back to sidebar when collapsed
This commit is contained in:
parent
6d66317687
commit
c8a473b9bb
5 changed files with 20 additions and 6 deletions
|
|
@ -40,6 +40,10 @@ impl RecordingSelector {
|
|||
let navigator = Navigator::new(&empty_screen);
|
||||
leaflet.add(&navigator.widget);
|
||||
|
||||
navigator.set_back_cb(clone!(@strong leaflet, @strong sidebar_box => move || {
|
||||
leaflet.set_visible_child(&sidebar_box);
|
||||
}));
|
||||
|
||||
let result = Rc::new(Self {
|
||||
backend: backend,
|
||||
window: window,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ pub struct Navigator {
|
|||
pub widget: gtk::Stack,
|
||||
screens: RefCell<Vec<Rc<dyn NavigatorScreen>>>,
|
||||
old_screens: RefCell<Vec<Rc<dyn NavigatorScreen>>>,
|
||||
back_cb: RefCell<Option<Box<dyn Fn() -> ()>>>,
|
||||
}
|
||||
|
||||
impl Navigator {
|
||||
|
|
@ -30,6 +31,7 @@ impl Navigator {
|
|||
widget,
|
||||
screens: RefCell::new(Vec::new()),
|
||||
old_screens: RefCell::new(Vec::new()),
|
||||
back_cb: RefCell::new(None),
|
||||
});
|
||||
|
||||
unsafe {
|
||||
|
|
@ -46,6 +48,10 @@ impl Navigator {
|
|||
result
|
||||
}
|
||||
|
||||
pub fn set_back_cb<F>(&self, cb: F) where F: Fn() -> () + 'static {
|
||||
self.back_cb.replace(Some(Box::new(cb)));
|
||||
}
|
||||
|
||||
pub fn push<S>(self: Rc<Self>, screen: Rc<S>)
|
||||
where
|
||||
S: NavigatorScreen + 'static,
|
||||
|
|
@ -80,6 +86,9 @@ impl Navigator {
|
|||
screen.attach_navigator(self.clone());
|
||||
} else {
|
||||
self.widget.set_visible_child_name("empty_screen");
|
||||
if let Some(cb) = &*self.back_cb.borrow() {
|
||||
cb()
|
||||
}
|
||||
}
|
||||
|
||||
if !self.widget.get_transition_running() {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ impl Window {
|
|||
|
||||
let poe_list = PoeList::new(backend.clone());
|
||||
let navigator = Navigator::new(&empty_screen);
|
||||
navigator.set_back_cb(clone!(@strong leaflet, @strong sidebar_box => move || {
|
||||
leaflet.set_visible_child(&sidebar_box);
|
||||
}));
|
||||
|
||||
let result = Rc::new(Self {
|
||||
backend,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue