mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Add mechanism to show playlist page
This commit is contained in:
parent
5fd958644e
commit
d0cf77888c
8 changed files with 135 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
mod application;
|
||||
mod config;
|
||||
mod home_page;
|
||||
mod playlist_page;
|
||||
mod tile;
|
||||
mod welcome_page;
|
||||
mod window;
|
||||
|
|
|
|||
56
src/playlist_page.rs
Normal file
56
src/playlist_page.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
use adw::subclass::prelude::*;
|
||||
use gtk::{glib, glib::subclass::Signal, prelude::*};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
||||
#[template(resource = "/de/johrpan/musicus/playlist_page.ui")]
|
||||
pub struct MusicusPlaylistPage {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for MusicusPlaylistPage {
|
||||
const NAME: &'static str = "MusicusPlaylistPage";
|
||||
type Type = super::MusicusPlaylistPage;
|
||||
type ParentType = adw::Bin;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
klass.bind_template_instance_callbacks();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for MusicusPlaylistPage {
|
||||
fn signals() -> &'static [Signal] {
|
||||
static SIGNALS: Lazy<Vec<Signal>> =
|
||||
Lazy::new(|| vec![Signal::builder("close").build()]);
|
||||
|
||||
SIGNALS.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for MusicusPlaylistPage {}
|
||||
impl BinImpl for MusicusPlaylistPage {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct MusicusPlaylistPage(ObjectSubclass<imp::MusicusPlaylistPage>)
|
||||
@extends gtk::Widget, adw::Bin;
|
||||
}
|
||||
|
||||
#[gtk::template_callbacks]
|
||||
impl MusicusPlaylistPage {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn close(&self, _: >k::Button) {
|
||||
self.emit_by_name::<()>("close", &[]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
use crate::{home_page::MusicusHomePage, welcome_page::MusicusWelcomePage};
|
||||
use crate::{
|
||||
home_page::MusicusHomePage, playlist_page::MusicusPlaylistPage,
|
||||
welcome_page::MusicusWelcomePage,
|
||||
};
|
||||
|
||||
use adw::subclass::prelude::*;
|
||||
use gtk::{gio, glib, prelude::*};
|
||||
|
|
@ -9,10 +12,14 @@ mod imp {
|
|||
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
||||
#[template(resource = "/de/johrpan/musicus/window.ui")]
|
||||
pub struct MusicusWindow {
|
||||
#[template_child]
|
||||
pub stack: TemplateChild<gtk::Stack>,
|
||||
#[template_child]
|
||||
pub navigation_view: TemplateChild<adw::NavigationView>,
|
||||
#[template_child]
|
||||
pub player_bar_revealer: TemplateChild<gtk::Revealer>,
|
||||
#[template_child]
|
||||
pub playlist_button: TemplateChild<gtk::ToggleButton>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
@ -23,6 +30,7 @@ mod imp {
|
|||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
MusicusHomePage::static_type();
|
||||
MusicusPlaylistPage::static_type();
|
||||
MusicusWelcomePage::static_type();
|
||||
klass.bind_template();
|
||||
klass.bind_template_instance_callbacks();
|
||||
|
|
@ -93,4 +101,20 @@ impl MusicusWindow {
|
|||
log::info!("{path:?}");
|
||||
self.imp().navigation_view.replace_with_tags(&["home"]);
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn show_playlist(&self, button: >k::ToggleButton) {
|
||||
self.imp()
|
||||
.stack
|
||||
.set_visible_child_name(if button.is_active() {
|
||||
"playlist"
|
||||
} else {
|
||||
"navigation"
|
||||
});
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn hide_playlist(&self, _: &MusicusPlaylistPage) {
|
||||
self.imp().playlist_button.set_active(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue