Add player mockup

This commit is contained in:
Elias Projahn 2023-09-29 21:18:28 +02:00
parent ba5958d549
commit 00bd7027a6
5 changed files with 105 additions and 9 deletions

52
src/player.rs Normal file
View file

@ -0,0 +1,52 @@
use gtk::{glib, glib::Properties, prelude::*, subclass::prelude::*};
use std::cell::Cell;
mod imp {
use super::*;
#[derive(Properties, Debug, Default)]
#[properties(wrapper_type = super::MusicusPlayer)]
pub struct MusicusPlayer {
#[property(get, set)]
pub active: Cell<bool>,
#[property(get, set)]
pub playing: Cell<bool>,
}
#[glib::object_subclass]
impl ObjectSubclass for MusicusPlayer {
const NAME: &'static str = "MusicusPlayer";
type Type = super::MusicusPlayer;
}
#[glib::derived_properties]
impl ObjectImpl for MusicusPlayer {}
}
glib::wrapper! {
pub struct MusicusPlayer(ObjectSubclass<imp::MusicusPlayer>);
}
impl MusicusPlayer {
pub fn new() -> Self {
glib::Object::new()
}
pub fn play(&self) {
if !self.imp().active.get() {
self.set_property("active", true);
}
self.set_property("playing", true);
}
pub fn pause(&self) {
self.set_property("playing", false);
}
}
impl Default for MusicusPlayer {
fn default() -> Self {
Self::new()
}
}