Compare commits
2 commits
b53b3d8362
...
118b2d6f7e
Author | SHA1 | Date | |
---|---|---|---|
118b2d6f7e | |||
96067675d4 |
4 changed files with 43 additions and 13 deletions
|
@ -1,10 +1,11 @@
|
||||||
mod window;
|
pub mod window;
|
||||||
pub use window::Window;
|
pub use window::Window;
|
||||||
|
|
||||||
mod playbar;
|
pub mod playbar;
|
||||||
pub use playbar::Playbar;
|
pub use playbar::Playbar;
|
||||||
|
|
||||||
mod setup;
|
pub mod setup;
|
||||||
pub use setup::Setup;
|
pub use setup::Setup;
|
||||||
|
|
||||||
pub mod play_queue;
|
pub mod play_queue;
|
||||||
|
pub use play_queue::PlayQueue;
|
||||||
|
|
|
@ -1,2 +1,32 @@
|
||||||
mod song;
|
pub mod song;
|
||||||
pub use song::Song;
|
pub use song::Song;
|
||||||
|
|
||||||
|
mod ffi {
|
||||||
|
use gtk::glib;
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct AudreyUiPlayQueue {
|
||||||
|
_data: [u8; 0],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct AudreyUiPlayQueueClass {
|
||||||
|
_data: [u8; 0],
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
pub fn audrey_ui_play_queue_get_type() -> glib::ffi::GType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use gtk::glib;
|
||||||
|
|
||||||
|
glib::wrapper! {
|
||||||
|
pub struct PlayQueue(Object<ffi::AudreyUiPlayQueue, ffi::AudreyUiPlayQueueClass>)
|
||||||
|
@extends adw::Bin, gtk::Widget,
|
||||||
|
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
|
||||||
|
|
||||||
|
match fn {
|
||||||
|
type_ => || ffi::audrey_ui_play_queue_get_type(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
[GtkTemplate (ui = "/eu/callcc/audrey/play_queue.ui")]
|
[GtkTemplate (ui = "/eu/callcc/audrey/play_queue.ui")]
|
||||||
public class Audrey.Ui.PlayQueue : Adw.Bin {
|
public class Audrey.Ui.PlayQueue : Adw.Bin {
|
||||||
private weak Playbin _playbin;
|
private weak Playbin _playbin;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
mod imp {
|
mod imp {
|
||||||
use glib::{subclass::InitializingObject, WeakRef};
|
use glib::{subclass::InitializingObject, WeakRef};
|
||||||
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
|
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{RefCell, Cell};
|
||||||
|
|
||||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||||
#[template(resource = "/eu/callcc/audrey/play_queue_song.ui")]
|
#[template(resource = "/eu/callcc/audrey/play_queue_song.ui")]
|
||||||
#[properties(wrapper_type = super::Song)]
|
#[properties(wrapper_type = super::Song)]
|
||||||
pub struct Song {
|
pub struct Song {
|
||||||
pub(super) playbin: RefCell<Option<WeakRef<crate::Playbin>>>,
|
pub(super) playbin: WeakRef<crate::Playbin>,
|
||||||
|
|
||||||
#[property(set, get)]
|
#[property(set, get)]
|
||||||
draggable: Cell<bool>,
|
draggable: Cell<bool>,
|
||||||
|
@ -121,7 +121,7 @@ mod imp {
|
||||||
fn on_drag_begin(&self, drag: &gdk::Drag) {
|
fn on_drag_begin(&self, drag: &gdk::Drag) {
|
||||||
let drag_widget = gtk::ListBox::new();
|
let drag_widget = gtk::ListBox::new();
|
||||||
|
|
||||||
let drag_row = super::Song::new(self.obj().playbin());
|
let drag_row = super::Song::new(&self.obj().playbin());
|
||||||
drag_row.set_draggable(false);
|
drag_row.set_draggable(false);
|
||||||
drag_row.set_show_position(self.obj().show_position());
|
drag_row.set_show_position(self.obj().show_position());
|
||||||
drag_row.set_show_artist(self.obj().show_artist());
|
drag_row.set_show_artist(self.obj().show_artist());
|
||||||
|
@ -175,16 +175,14 @@ glib::wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Song {
|
impl Song {
|
||||||
pub fn new(playbin: crate::Playbin) -> Self {
|
pub fn new(playbin: &crate::Playbin) -> Self {
|
||||||
let song: Self = Object::new();
|
let song: Self = Object::new();
|
||||||
song.imp().playbin.replace(Some(playbin.downgrade()));
|
song.imp().playbin.set(Some(playbin));
|
||||||
song
|
song
|
||||||
}
|
}
|
||||||
|
|
||||||
fn playbin(&self) -> crate::Playbin {
|
fn playbin(&self) -> crate::Playbin {
|
||||||
let playbin = self.imp().playbin.borrow();
|
self.imp().playbin.upgrade().unwrap()
|
||||||
let playbin = playbin.as_ref().unwrap(); // weak
|
|
||||||
playbin.upgrade().unwrap().clone() // strong
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind(&self, position: u32, song: &crate::playbin::Song) {
|
pub fn bind(&self, position: u32, song: &crate::playbin::Song) {
|
||||||
|
@ -230,7 +228,7 @@ pub mod ffi {
|
||||||
extern "C" fn audrey_ui_play_queue_song_new(
|
extern "C" fn audrey_ui_play_queue_song_new(
|
||||||
playbin: *mut crate::playbin::ffi::AudreyPlaybin,
|
playbin: *mut crate::playbin::ffi::AudreyPlaybin,
|
||||||
) -> *mut AudreyUiPlayQueueSong {
|
) -> *mut AudreyUiPlayQueueSong {
|
||||||
unsafe { super::Song::new(from_glib_none(playbin)).into_glib_ptr() }
|
unsafe { super::Song::new(&from_glib_none(playbin)).into_glib_ptr() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Reference in a new issue