Pass media tracks and subs file to Celluloid, improve modal spacing
This commit is contained in:
parent
92ab9bb9d8
commit
a758dd113c
4 changed files with 65 additions and 23 deletions
|
@ -14,6 +14,3 @@
|
|||
.media-modal {
|
||||
padding : 100px ;
|
||||
}
|
||||
.media-modal .top-padding {
|
||||
padding-top : 40px ;
|
||||
}
|
||||
|
|
|
@ -64,11 +64,10 @@ impl DataManager {
|
|||
films . runtime_minutes ,
|
||||
films . poster_file_path ,
|
||||
films . source ,
|
||||
sources . video_file_path ,
|
||||
sources . video_track ,
|
||||
sources . audio_file_path ,
|
||||
sources . audio_track ,
|
||||
sources . file_path ,
|
||||
sources . subtitle_file_path ,
|
||||
sources . video_track ,
|
||||
sources . audio_track ,
|
||||
sources . subtitle_track
|
||||
from films left join sources
|
||||
on films . source = sources . uuid
|
||||
|
@ -170,7 +169,7 @@ fn row_to_series_overview ( row : & Row ) -> rusqlite :: Result <SeriesOverview>
|
|||
|
||||
|
||||
|
||||
pub struct FilmDetails {
|
||||
# [ derive (Clone) ] pub struct FilmDetails {
|
||||
pub uuid : String ,
|
||||
pub name : String ,
|
||||
pub original_name : Option <String> ,
|
||||
|
@ -179,12 +178,11 @@ pub struct FilmDetails {
|
|||
pub poster_file_path : Option <PathBuf> ,
|
||||
pub source : Option <SourceDetails> ,
|
||||
}
|
||||
pub struct SourceDetails {
|
||||
pub video_file_path : PathBuf ,
|
||||
pub video_track : Option <u32> ,
|
||||
pub audio_file_path : PathBuf ,
|
||||
pub audio_track : Option <u32> ,
|
||||
# [ derive (Clone) ] pub struct SourceDetails {
|
||||
pub file_path : PathBuf ,
|
||||
pub subtitle_file_path : Option <PathBuf> ,
|
||||
pub video_track : Option <u32> ,
|
||||
pub audio_track : Option <u32> ,
|
||||
pub subtitle_track : Option <u32> ,
|
||||
}
|
||||
|
||||
|
@ -199,19 +197,17 @@ fn row_to_film_details ( row : & Row ) -> rusqlite :: Result <FilmDetails> {
|
|||
let source_uuid = row . get :: < _ , Option <String> > (6) ? ;
|
||||
let source = match source_uuid {
|
||||
Some (_) => {
|
||||
let video_file_path = PathBuf :: from ( row . get :: < _ , String > (7) ? ) ;
|
||||
let video_track = row . get (8) ? ;
|
||||
let audio_file_path = PathBuf :: from ( row . get :: < _ , String > (9) ? ) ;
|
||||
let file_path = PathBuf :: from ( row . get :: < _ , String > (7) ? ) ;
|
||||
let subtitle_file_path = row . get :: < _ , Option <String> > (8) ? . map ( PathBuf :: from ) ;
|
||||
let video_track = row . get (9) ? ;
|
||||
let audio_track = row . get (10) ? ;
|
||||
let subtitle_file_path = row . get :: < _ , Option <String> > (11) ? . map ( PathBuf :: from ) ;
|
||||
let subtitle_track = row . get (12) ? ;
|
||||
let subtitle_track = row . get (11) ? ;
|
||||
|
||||
Some ( SourceDetails {
|
||||
video_file_path ,
|
||||
video_track ,
|
||||
audio_file_path ,
|
||||
audio_track ,
|
||||
file_path ,
|
||||
subtitle_file_path ,
|
||||
video_track ,
|
||||
audio_track ,
|
||||
subtitle_track ,
|
||||
} )
|
||||
} ,
|
||||
|
|
|
@ -9,6 +9,7 @@ use gtk4 :: prelude :: * ;
|
|||
use libadwaita :: * ;
|
||||
use libadwaita :: prelude :: * ;
|
||||
use libadwaita :: ViewSwitcherPolicy :: * ;
|
||||
use std :: process :: * ;
|
||||
|
||||
use crate :: data_manager :: * ;
|
||||
use crate :: ui :: collatable_container :: * ;
|
||||
|
@ -38,6 +39,7 @@ impl UI {
|
|||
& g_box ! (
|
||||
@ option_children ;
|
||||
@ orientation : Vertical ;
|
||||
@ spacing : 40 ;
|
||||
@ css_classes : & [ "media-modal" ] ;
|
||||
|
||||
Some ( label ! (
|
||||
|
@ -50,9 +52,37 @@ impl UI {
|
|||
) . as_ref () ,
|
||||
|
||||
Some ( label ! (
|
||||
@ css_classes : & [ "top-padding" ] ;
|
||||
& format ! ( "Release date: {}" , film_details . release_date ) ,
|
||||
) ) . as_ref () ,
|
||||
|
||||
film_details . source . map (
|
||||
|source| button ! (
|
||||
@ css_classes : & [ "suggested-action" , "circular" ] ;
|
||||
@ connect_clicked : move |_| {
|
||||
let source = source . clone () ;
|
||||
|
||||
let arguments = [
|
||||
Some ( source . file_path . as_os_str () . to_owned () ) ,
|
||||
source . subtitle_file_path . map (
|
||||
|subtitle_file_path| concat_os_str ! ( "--mpv-sub-file=" , subtitle_file_path ) ,
|
||||
) ,
|
||||
source . video_track . map (
|
||||
|video_track| concat_os_str ! ( "--mpv-vid=" , to_os_string (video_track) ) ,
|
||||
) ,
|
||||
source . audio_track . map (
|
||||
|audio_track| concat_os_str ! ( "--mpv-aid=" , to_os_string (audio_track) ) ,
|
||||
) ,
|
||||
source . subtitle_track . map (
|
||||
|subtitle_track| concat_os_str ! ( "--mpv-sid=" , to_os_string (subtitle_track) ) ,
|
||||
) ,
|
||||
] . iter () . filter_map ( Option :: clone ) . collect :: < Vec <_> > () ;
|
||||
|
||||
Command :: new ("/usr/bin/celluloid") . args (arguments) . spawn ()
|
||||
. unwrap () ; // TODO: Better error handling for UI callbacks in general
|
||||
} ;
|
||||
& image ! ( @ icon_name : "media-playback-start-symbolic" ; ) ,
|
||||
) ,
|
||||
) . as_ref () ,
|
||||
) ,
|
||||
) . present ( Some ( & window . libadwaita_window ) )
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
use std :: ffi :: * ;
|
||||
use std :: fmt :: * ;
|
||||
|
||||
|
||||
|
||||
macro_rules ! concat_os_str { (
|
||||
$ base : expr ,
|
||||
$ ( $ suffix : expr ) , +
|
||||
) => { {
|
||||
let mut base = std :: ffi :: OsString :: from ( $ base ) ;
|
||||
$ ( base . push ( $ suffix ) ; ) +
|
||||
base
|
||||
} } }
|
||||
|
||||
pub fn leak < 'l , Type > ( inner : Type ) -> & 'l Type {
|
||||
Box :: leak ( Box :: new (inner) )
|
||||
}
|
||||
|
@ -14,6 +28,11 @@ macro_rules ! pinned_async { (
|
|||
} )
|
||||
} }
|
||||
|
||||
pub fn to_os_string ( value : impl Display + Sized ) -> OsString {
|
||||
OsString :: from ( ToString :: to_string ( & value ) )
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub (crate) use concat_os_str ;
|
||||
pub (crate) use pinned_async ;
|
||||
|
|
Loading…
Add table
Reference in a new issue