mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Add new experimental navigator and use it for login
This commit is contained in:
parent
29e89580d8
commit
80f5047369
8 changed files with 332 additions and 105 deletions
41
src/widgets/new_navigator_window.rs
Normal file
41
src/widgets/new_navigator_window.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use crate::backend::Backend;
|
||||
use super::new_navigator::{Navigator, Screen};
|
||||
use glib::clone;
|
||||
use gtk::prelude::*;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// A window hosting a navigator.
|
||||
pub struct NavigatorWindow {
|
||||
pub navigator: Rc<Navigator>,
|
||||
window: libadwaita::Window,
|
||||
}
|
||||
|
||||
impl NavigatorWindow {
|
||||
/// Create a new navigator window.
|
||||
pub fn new(backend: Rc<Backend>) -> Rc<Self> {
|
||||
let window = libadwaita::Window::new();
|
||||
window.set_default_size(600, 424);
|
||||
let placeholder = gtk::Label::new(None);
|
||||
let navigator = Navigator::new(backend, &window, &placeholder);
|
||||
libadwaita::WindowExt::set_child(&window, Some(&navigator.widget));
|
||||
|
||||
let this = Rc::new(Self { navigator, window });
|
||||
|
||||
this.navigator.set_back_cb(clone!(@strong this => move || {
|
||||
this.window.close();
|
||||
}));
|
||||
|
||||
this
|
||||
}
|
||||
|
||||
/// Make the wrapped window transient. This will make the window modal.
|
||||
pub fn set_transient_for<W: IsA<gtk::Window>>(&self, window: &W) {
|
||||
self.window.set_modal(true);
|
||||
self.window.set_transient_for(Some(window));
|
||||
}
|
||||
|
||||
/// Show the navigator window.
|
||||
pub fn show(&self) {
|
||||
self.window.show();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue