2023-09-20 13:49:02 +02:00
|
|
|
use adw::subclass::{navigation_page::NavigationPageImpl, prelude::*};
|
2023-09-21 17:19:31 +02:00
|
|
|
use gtk::{glib, prelude::*};
|
2023-09-20 13:49:02 +02:00
|
|
|
|
|
|
|
|
mod imp {
|
|
|
|
|
use crate::tile::MusicusTile;
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
|
|
|
|
#[template(resource = "/de/johrpan/musicus/home_page.ui")]
|
|
|
|
|
pub struct MusicusHomePage {
|
|
|
|
|
#[template_child]
|
|
|
|
|
pub search_entry: TemplateChild<gtk::SearchEntry>,
|
|
|
|
|
#[template_child]
|
|
|
|
|
pub persons_flow_box: TemplateChild<gtk::FlowBox>,
|
|
|
|
|
#[template_child]
|
|
|
|
|
pub works_flow_box: TemplateChild<gtk::FlowBox>,
|
|
|
|
|
#[template_child]
|
|
|
|
|
pub recordings_flow_box: TemplateChild<gtk::FlowBox>,
|
2023-09-21 17:19:31 +02:00
|
|
|
#[template_child]
|
|
|
|
|
pub play_button: TemplateChild<gtk::Button>,
|
2023-09-20 13:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[glib::object_subclass]
|
|
|
|
|
impl ObjectSubclass for MusicusHomePage {
|
|
|
|
|
const NAME: &'static str = "MusicusHomePage";
|
|
|
|
|
type Type = super::MusicusHomePage;
|
|
|
|
|
type ParentType = adw::NavigationPage;
|
|
|
|
|
|
|
|
|
|
fn class_init(klass: &mut Self::Class) {
|
|
|
|
|
klass.bind_template();
|
2023-09-21 17:19:31 +02:00
|
|
|
klass.bind_template_instance_callbacks();
|
2023-09-20 13:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
|
|
|
|
obj.init_template();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ObjectImpl for MusicusHomePage {
|
|
|
|
|
fn constructed(&self) {
|
|
|
|
|
self.parent_constructed();
|
|
|
|
|
self.search_entry
|
|
|
|
|
.set_key_capture_widget(Some(self.obj().as_ref()));
|
|
|
|
|
|
|
|
|
|
for _ in 0..9 {
|
|
|
|
|
self.persons_flow_box.append(&MusicusTile::new());
|
|
|
|
|
self.works_flow_box.append(&MusicusTile::new());
|
|
|
|
|
self.recordings_flow_box.append(&MusicusTile::new());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl WidgetImpl for MusicusHomePage {}
|
|
|
|
|
impl NavigationPageImpl for MusicusHomePage {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glib::wrapper! {
|
|
|
|
|
pub struct MusicusHomePage(ObjectSubclass<imp::MusicusHomePage>)
|
|
|
|
|
@extends gtk::Widget, adw::NavigationPage;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-21 17:19:31 +02:00
|
|
|
#[gtk::template_callbacks]
|
2023-09-20 13:49:02 +02:00
|
|
|
impl MusicusHomePage {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
glib::Object::new()
|
|
|
|
|
}
|
2023-09-21 17:19:31 +02:00
|
|
|
|
|
|
|
|
#[template_callback]
|
|
|
|
|
fn play(&self, _: >k::Button) {
|
|
|
|
|
log::info!("Play button clicked");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[template_callback]
|
|
|
|
|
fn search(&self, entry: >k::SearchEntry) {
|
|
|
|
|
log::info!("Search changed: \"{}\"", entry.text());
|
|
|
|
|
}
|
2023-09-20 13:49:02 +02:00
|
|
|
}
|