From c98290d4f0cfdc979db3024ec53832662662eed8 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Wed, 30 Oct 2024 10:06:10 +0100 Subject: [PATCH] wrap some classes and a struct --- src/main.rs | 8 ++++++++ src/mpris.rs | 30 ++++++++++++++++++++++++++++++ src/mpris/player.rs | 27 +++++++++++++++++++++++++++ src/playbin.rs | 30 ++++++++++++++++++++++++++++++ src/playbin/song.rs | 27 +++++++++++++++++++++++++++ src/subsonic.rs | 5 +++++ src/subsonic/client.rs | 27 +++++++++++++++++++++++++++ src/subsonic/song.rs | 38 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 192 insertions(+) create mode 100644 src/mpris.rs create mode 100644 src/mpris/player.rs create mode 100644 src/playbin.rs create mode 100644 src/playbin/song.rs create mode 100644 src/subsonic.rs create mode 100644 src/subsonic/client.rs create mode 100644 src/subsonic/song.rs diff --git a/src/main.rs b/src/main.rs index b7427e7..bc8a2d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,14 @@ pub use application::Application; mod meson_config; pub mod ui; +pub mod mpris; +pub use mpris::Mpris; + +pub mod playbin; +pub use playbin::Playbin; + +pub mod subsonic; + use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory}; use gtk::prelude::*; use gtk::{gio, glib}; diff --git a/src/mpris.rs b/src/mpris.rs new file mode 100644 index 0000000..e8ad8ad --- /dev/null +++ b/src/mpris.rs @@ -0,0 +1,30 @@ +mod player; +pub use player::Player; + +mod ffi { + use gtk::glib; + + #[repr(C)] + pub struct AudreyMpris { + parent_instance: glib::gobject_ffi::GObject, + } + + #[repr(C)] + pub struct AudreyMprisClass { + parent_class: glib::gobject_ffi::GObjectClass, + } + + extern "C" { + pub fn audrey_mpris_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Mpris(Object); + + match fn { + type_ => || ffi::audrey_mpris_get_type(), + } +} diff --git a/src/mpris/player.rs b/src/mpris/player.rs new file mode 100644 index 0000000..7282e96 --- /dev/null +++ b/src/mpris/player.rs @@ -0,0 +1,27 @@ +mod ffi { + use gtk::glib; + + #[repr(C)] + pub struct AudreyMprisPlayer { + parent_instance: glib::gobject_ffi::GObject, + } + + #[repr(C)] + pub struct AudreyMprisClassPlayer { + parent_class: glib::gobject_ffi::GObjectClass, + } + + extern "C" { + pub fn audrey_mpris_player_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Player(Object); + + match fn { + type_ => || ffi::audrey_mpris_player_get_type(), + } +} diff --git a/src/playbin.rs b/src/playbin.rs new file mode 100644 index 0000000..8130af9 --- /dev/null +++ b/src/playbin.rs @@ -0,0 +1,30 @@ +mod song; +pub use song::Song; + +mod ffi { + use gtk::glib; + + #[repr(C)] + pub struct AudreyPlaybin { + parent_instance: glib::gobject_ffi::GObject, + } + + #[repr(C)] + pub struct AudreyPlaybinClass { + parent_class: glib::gobject_ffi::GObjectClass, + } + + extern "C" { + pub fn audrey_playbin_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Playbin(Object); + + match fn { + type_ => || ffi::audrey_playbin_get_type(), + } +} diff --git a/src/playbin/song.rs b/src/playbin/song.rs new file mode 100644 index 0000000..adfbba2 --- /dev/null +++ b/src/playbin/song.rs @@ -0,0 +1,27 @@ +mod ffi { + use gtk::glib; + + #[repr(C)] + pub struct AudreyPlaybinSong { + parent_instance: glib::gobject_ffi::GObject, + } + + #[repr(C)] + pub struct AudreyPlaybinSongClass { + parent_class: glib::gobject_ffi::GObjectClass, + } + + extern "C" { + pub fn audrey_playbin_song_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Song(Object); + + match fn { + type_ => || ffi::audrey_playbin_song_get_type(), + } +} diff --git a/src/subsonic.rs b/src/subsonic.rs new file mode 100644 index 0000000..b00ba5f --- /dev/null +++ b/src/subsonic.rs @@ -0,0 +1,5 @@ +mod client; +pub use client::Client; + +mod song; +pub use song::Song; diff --git a/src/subsonic/client.rs b/src/subsonic/client.rs new file mode 100644 index 0000000..95e1853 --- /dev/null +++ b/src/subsonic/client.rs @@ -0,0 +1,27 @@ +mod ffi { + use gtk::glib; + + #[repr(C)] + pub struct AudreySubsonicClient { + parent_instance: glib::gobject_ffi::GObject, + } + + #[repr(C)] + pub struct AudreySubsonicClientClass { + parent_class: glib::gobject_ffi::GObjectClass, + } + + extern "C" { + pub fn audrey_subsonic_client_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Client(Object); + + match fn { + type_ => || ffi::audrey_subsonic_client_get_type(), + } +} diff --git a/src/subsonic/song.rs b/src/subsonic/song.rs new file mode 100644 index 0000000..0294681 --- /dev/null +++ b/src/subsonic/song.rs @@ -0,0 +1,38 @@ +mod ffi { + use std::ffi::*; + use gtk::glib; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct AudreySubsonicSong { + pub id: *mut c_char, + pub title: *mut c_char, + pub album: *mut c_char, + pub artist: *mut c_char, + pub track: i64, + pub year: i64, + pub starred: *mut glib::ffi::GDateTime, + pub duration: i64, + pub play_count: i64, + pub genre: *mut c_char, + pub cover_art: *mut c_char, + } + + extern "C" { + pub fn audrey_subsonic_song_copy(ptr: *const AudreySubsonicSong) -> *mut AudreySubsonicSong; + pub fn audrey_subsonic_song_free(ptr: *mut AudreySubsonicSong); + pub fn audrey_subsonic_song_get_type() -> glib::ffi::GType; + } +} + +use gtk::glib; + +glib::wrapper! { + pub struct Song(BoxedInline); + + match fn { + copy => |ptr| ffi::audrey_subsonic_song_copy(ptr), + free => |ptr| ffi::audrey_subsonic_song_free(ptr), + type_ => || ffi::audrey_subsonic_song_get_type(), + } +}