57 lines
1.3 KiB
Rust
57 lines
1.3 KiB
Rust
use crate::PlaybackState;
|
|
use glib::Object;
|
|
use gtk::{prelude::*, subclass::prelude::*};
|
|
|
|
pub struct PlaylistCardPrivate {
|
|
name: gtk::Label,
|
|
playing: gtk::Label,
|
|
}
|
|
|
|
impl Default for PlaylistCardPrivate {
|
|
fn default() -> Self {
|
|
Self {
|
|
name: gtk::Label::new(None),
|
|
playing: gtk::Label::new(Some("Stopped")),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[glib::object_subclass]
|
|
impl ObjectSubclass for PlaylistCardPrivate {
|
|
const NAME: &'static str = "PlaylistCard";
|
|
type Type = PlaylistCard;
|
|
type ParentType = gtk::Box;
|
|
}
|
|
|
|
impl ObjectImpl for PlaylistCardPrivate {}
|
|
impl WidgetImpl for PlaylistCardPrivate {}
|
|
impl BoxImpl for PlaylistCardPrivate {}
|
|
|
|
glib::wrapper! {
|
|
pub struct PlaylistCard(ObjectSubclass<PlaylistCardPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
|
}
|
|
|
|
impl Default for PlaylistCard {
|
|
fn default() -> Self {
|
|
let s: Self = Object::builder().build();
|
|
s.set_orientation(gtk::Orientation::Vertical);
|
|
s.add_css_class("playlist-card");
|
|
s.add_css_class("card");
|
|
|
|
s.append(&s.imp().name);
|
|
s.append(&s.imp().playing);
|
|
|
|
s
|
|
}
|
|
}
|
|
|
|
impl PlaylistCard {
|
|
pub fn set_name(&self, s: &str) {
|
|
self.imp().name.set_text(s);
|
|
}
|
|
|
|
pub fn set_playback(&self, s: PlaybackState) {
|
|
self.imp().playing.set_text(&format!("{}", s))
|
|
}
|
|
}
|