Compare commits
No commits in common. "118b2d6f7e5c17f143dc3595ffedad30785d5c45" and "b53b3d8362804253bcb01e1faa7fea678b9ff7fb" have entirely different histories.
118b2d6f7e
...
b53b3d8362
4 changed files with 13 additions and 43 deletions
|
@ -1,11 +1,10 @@
|
||||||
pub mod window;
|
mod window;
|
||||||
pub use window::Window;
|
pub use window::Window;
|
||||||
|
|
||||||
pub mod playbar;
|
mod playbar;
|
||||||
pub use playbar::Playbar;
|
pub use playbar::Playbar;
|
||||||
|
|
||||||
pub mod setup;
|
mod setup;
|
||||||
pub use setup::Setup;
|
pub use setup::Setup;
|
||||||
|
|
||||||
pub mod play_queue;
|
pub mod play_queue;
|
||||||
pub use play_queue::PlayQueue;
|
|
||||||
|
|
|
@ -1,32 +1,2 @@
|
||||||
pub mod song;
|
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,4 +1,3 @@
|
||||||
/*
|
|
||||||
[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::{RefCell, Cell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
|
||||||
#[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: WeakRef<crate::Playbin>,
|
pub(super) playbin: RefCell<Option<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,14 +175,16 @@ 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.set(Some(playbin));
|
song.imp().playbin.replace(Some(playbin.downgrade()));
|
||||||
song
|
song
|
||||||
}
|
}
|
||||||
|
|
||||||
fn playbin(&self) -> crate::Playbin {
|
fn playbin(&self) -> crate::Playbin {
|
||||||
self.imp().playbin.upgrade().unwrap()
|
let playbin = self.imp().playbin.borrow();
|
||||||
|
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) {
|
||||||
|
@ -228,7 +230,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