Compare commits
4 commits
0dab31137c
...
f07641622e
Author | SHA1 | Date | |
---|---|---|---|
f07641622e | |||
d49c348781 | |||
e5871e0bfc | |||
74b0183e1c |
8 changed files with 53 additions and 109 deletions
|
@ -82,7 +82,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
upper: bind template.playbin as <$AudreyPlaybin>.duration;
|
||||
};
|
||||
|
||||
change-value => $on_play_position_seek (template);
|
||||
change-value => $on_play_position_seek () swapped;
|
||||
}
|
||||
|
||||
[end]
|
||||
|
@ -105,7 +105,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
valign: center;
|
||||
sensitive: bind $playbin_active (template.playbin as <$AudreyPlaybin>.state as <$AudreyPlaybinState>) as <bool>;
|
||||
|
||||
clicked => $on_skip_backward_clicked (template);
|
||||
clicked => $on_skip_backward_clicked () swapped;
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -113,7 +113,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
valign: center;
|
||||
sensitive: bind $playbin_active (template.playbin as <$AudreyPlaybin>.state as <$AudreyPlaybinState>) as <bool>;
|
||||
|
||||
clicked => $seek_backward (template);
|
||||
clicked => $seek_backward () swapped;
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -121,7 +121,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
valign: center;
|
||||
sensitive: bind $can_press_play (template.playbin as <$AudreyPlaybin>.state as <$AudreyPlaybinState>, template.playbin as <$AudreyPlaybin>.play-queue-length) as <bool>;
|
||||
|
||||
clicked => $on_play_pause_clicked (template);
|
||||
clicked => $on_play_pause_clicked () swapped;
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -129,7 +129,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
valign: center;
|
||||
sensitive: bind $playbin_active (template.playbin as <$AudreyPlaybin>.state as <$AudreyPlaybinState>) as <bool>;
|
||||
|
||||
clicked => $seek_forward (template);
|
||||
clicked => $seek_forward () swapped;
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -137,7 +137,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
valign: center;
|
||||
sensitive: bind $playbin_active (template.playbin as <$AudreyPlaybin>.state as <$AudreyPlaybinState>) as <bool>;
|
||||
|
||||
clicked => $on_skip_forward_clicked (template);
|
||||
clicked => $on_skip_forward_clicked () swapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
icon-name: bind $mute_button_icon_name (template.playbin as <$AudreyPlaybin>.mute) as <string>;
|
||||
valign: center;
|
||||
|
||||
clicked => $on_mute_toggle (template);
|
||||
clicked => $on_mute_toggle () swapped;
|
||||
}
|
||||
|
||||
Scale {
|
||||
|
|
|
@ -3,9 +3,9 @@ audrey_sources = [
|
|||
'globalconf.vala',
|
||||
'mpris.vala',
|
||||
'playbin.vala',
|
||||
'rust.vapi',
|
||||
'subsonic.vala',
|
||||
'ui/play_queue.vala',
|
||||
'ui/playbar.vapi',
|
||||
'ui/setup.vala',
|
||||
'ui/window.vala',
|
||||
]
|
||||
|
|
12
src/rust.vapi
Normal file
12
src/rust.vapi
Normal file
|
@ -0,0 +1,12 @@
|
|||
[CCode (cheader_filename = "rust.h")]
|
||||
namespace Audrey {
|
||||
|
||||
public class Ui.Playbar : Adw.Bin {
|
||||
public PlaybinSong? song { get; set; }
|
||||
public Gdk.Paintable? playing_cover_art { get; set; }
|
||||
public weak Playbin playbin { get; set; }
|
||||
public bool show_cover_art { get; set; /*default = true;*/ }
|
||||
public int volume { get; set; }
|
||||
}
|
||||
|
||||
}
|
|
@ -3,3 +3,6 @@ pub use window::Window;
|
|||
|
||||
mod playbar;
|
||||
pub use playbar::Playbar;
|
||||
|
||||
mod setup;
|
||||
pub use setup::Setup;
|
||||
|
|
|
@ -2,7 +2,7 @@ mod imp {
|
|||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::subclass::InitializingObject;
|
||||
use glib::{gformat, gstr, GString};
|
||||
use glib::{gformat, GString};
|
||||
use gtk::{gdk, glib};
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
// [GtkTemplate (ui = "/eu/callcc/audrey/playbar.ui")]
|
||||
[CCode (cheader_filename = "ui/playbar.h")]
|
||||
public class Audrey.Ui.Playbar : Adw.Bin {
|
||||
public PlaybinSong? song {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Gdk.Paintable? playing_cover_art { get; set; }
|
||||
public weak Playbin playbin { get; set; }
|
||||
public bool show_cover_art { get; set; /*default = true;*/ }
|
||||
|
||||
public int volume { get; set; }
|
||||
/*{
|
||||
get { return playbin == null ? 100 : playbin.volume; }
|
||||
set { playbin.volume = value; }
|
||||
}*/
|
||||
|
||||
/*
|
||||
[GtkCallback] private string format_timestamp (double s) {
|
||||
return "%02d:%02d".printf (((int) s)/60, ((int) s)%60);
|
||||
}
|
||||
|
||||
[GtkCallback] private bool on_play_position_seek (Gtk.Range range, Gtk.ScrollType scroll_type, double value) {
|
||||
if (range.adjustment.lower < range.adjustment.upper) {
|
||||
this.playbin.seek ((int64) value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[GtkCallback] private void on_play_pause_clicked () {
|
||||
if (this.playbin.state == PlaybinState.PLAYING) {
|
||||
this.playbin.pause();
|
||||
} else {
|
||||
this.playbin.play();
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback] private string play_pause_icon_name (PlaybinState state) {
|
||||
if (state == PlaybinState.PLAYING) {
|
||||
return "media-playback-pause";
|
||||
} else {
|
||||
return "media-playback-start";
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback] private bool playbin_active (PlaybinState state) {
|
||||
return state != PlaybinState.STOPPED;
|
||||
}
|
||||
|
||||
[GtkCallback] private bool can_press_play (PlaybinState state, uint n_items) {
|
||||
return !(state == PlaybinState.STOPPED && n_items == 0);
|
||||
}
|
||||
|
||||
[GtkCallback] private string mute_button_icon_name (bool mute) {
|
||||
return mute ? "audio-volume-muted" : "audio-volume-high";
|
||||
}
|
||||
|
||||
[GtkCallback] private void on_mute_toggle () {
|
||||
this.playbin.mute = !this.playbin.mute;
|
||||
}
|
||||
|
||||
[GtkCallback] private void on_skip_forward_clicked () {
|
||||
this.playbin.go_to_next_track ();
|
||||
}
|
||||
|
||||
[GtkCallback] private void on_skip_backward_clicked () {
|
||||
this.playbin.go_to_prev_track ();
|
||||
}
|
||||
|
||||
[GtkCallback] private void seek_backward () {
|
||||
// 10 seconds
|
||||
double new_position = playbin.position - 10.0;
|
||||
if (new_position < 0.0) new_position = 0.0;
|
||||
this.playbin.seek (new_position);
|
||||
}
|
||||
|
||||
[GtkCallback] private void seek_forward () {
|
||||
// 10 seconds
|
||||
double new_position = playbin.position + 10.0;
|
||||
if (new_position > this.playbin.duration) new_position = this.playbin.duration;
|
||||
this.playbin.seek (new_position);
|
||||
}
|
||||
|
||||
[GtkCallback] private string song_title (PlaybinSong? song) {
|
||||
return song == null ? "" : song.title;
|
||||
}
|
||||
|
||||
[GtkCallback] private string song_artist (PlaybinSong? song) {
|
||||
return song == null ? "" : song.artist;
|
||||
}
|
||||
|
||||
[GtkCallback] private string song_album (PlaybinSong? song) {
|
||||
return song == null ? "" : song.album;
|
||||
}
|
||||
|
||||
~Playbar () {
|
||||
debug ("destroying playbar widget");
|
||||
}
|
||||
*/
|
||||
}
|
29
src/ui/setup.rs
Normal file
29
src/ui/setup.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
mod ffi {
|
||||
use gtk::glib;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct AudreyUiSetup {
|
||||
parent_instance: adw::ffi::AdwPreferencesDialog,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct AudreyUiSetupClass {
|
||||
parent_class: adw::ffi::AdwPreferencesDialogClass,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn audrey_ui_setup_get_type() -> glib::ffi::GType;
|
||||
}
|
||||
}
|
||||
|
||||
use gtk::glib;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Setup(Object<ffi::AudreyUiSetup, ffi::AudreyUiSetupClass>)
|
||||
@extends adw::PreferencesDialog, adw::Dialog, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
|
||||
|
||||
match fn {
|
||||
type_ => || ffi::audrey_ui_setup_get_type(),
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue