2023-09-20 13:49:02 +02:00
|
|
|
use crate::{welcome_page::MusicusWelcomePage, home_page::MusicusHomePage};
|
2023-09-13 14:58:31 +02:00
|
|
|
|
2023-06-18 14:02:21 +02:00
|
|
|
use adw::subclass::prelude::*;
|
2023-09-15 10:12:36 +02:00
|
|
|
use gtk::{gio, glib, prelude::*};
|
2023-06-18 14:02:21 +02:00
|
|
|
|
|
|
|
|
mod imp {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
|
|
|
|
#[template(resource = "/de/johrpan/musicus/window.ui")]
|
|
|
|
|
pub struct MusicusWindow {
|
|
|
|
|
#[template_child]
|
2023-09-13 14:58:31 +02:00
|
|
|
pub navigation_view: TemplateChild<adw::NavigationView>,
|
2023-09-21 17:19:31 +02:00
|
|
|
#[template_child]
|
|
|
|
|
pub player_bar_revealer: TemplateChild<gtk::Revealer>,
|
2023-06-18 14:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[glib::object_subclass]
|
|
|
|
|
impl ObjectSubclass for MusicusWindow {
|
|
|
|
|
const NAME: &'static str = "MusicusWindow";
|
|
|
|
|
type Type = super::MusicusWindow;
|
|
|
|
|
type ParentType = adw::ApplicationWindow;
|
|
|
|
|
|
|
|
|
|
fn class_init(klass: &mut Self::Class) {
|
2023-09-20 13:49:02 +02:00
|
|
|
MusicusHomePage::static_type();
|
2023-09-15 10:12:36 +02:00
|
|
|
MusicusWelcomePage::static_type();
|
2023-06-18 14:02:21 +02:00
|
|
|
klass.bind_template();
|
2023-09-15 10:12:36 +02:00
|
|
|
klass.bind_template_instance_callbacks();
|
2023-06-18 14:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
|
|
|
|
obj.init_template();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 14:58:31 +02:00
|
|
|
impl ObjectImpl for MusicusWindow {
|
|
|
|
|
fn constructed(&self) {
|
|
|
|
|
self.parent_constructed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-18 14:02:21 +02:00
|
|
|
impl WidgetImpl for MusicusWindow {}
|
|
|
|
|
impl WindowImpl for MusicusWindow {}
|
|
|
|
|
impl ApplicationWindowImpl for MusicusWindow {}
|
|
|
|
|
impl AdwApplicationWindowImpl for MusicusWindow {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glib::wrapper! {
|
|
|
|
|
pub struct MusicusWindow(ObjectSubclass<imp::MusicusWindow>)
|
2023-09-13 14:58:31 +02:00
|
|
|
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow,
|
|
|
|
|
@implements gio::ActionGroup, gio::ActionMap;
|
2023-06-18 14:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-15 10:12:36 +02:00
|
|
|
#[gtk::template_callbacks]
|
2023-06-18 14:02:21 +02:00
|
|
|
impl MusicusWindow {
|
|
|
|
|
pub fn new<P: glib::IsA<gtk::Application>>(application: &P) -> Self {
|
|
|
|
|
glib::Object::builder()
|
|
|
|
|
.property("application", application)
|
|
|
|
|
.build()
|
|
|
|
|
}
|
2023-09-15 10:12:36 +02:00
|
|
|
|
|
|
|
|
#[template_callback]
|
|
|
|
|
async fn set_library_folder(&self, folder: &gio::File) {
|
|
|
|
|
let path = folder.path();
|
|
|
|
|
log::info!("{path:?}");
|
2023-09-20 13:49:02 +02:00
|
|
|
self.imp().navigation_view.replace_with_tags(&["home"]);
|
2023-09-15 10:12:36 +02:00
|
|
|
}
|
2023-06-18 14:02:21 +02:00
|
|
|
}
|