Compare commits
No commits in common. "f07641622e3c6eff87a6e5e42982063efee16728" and "0dab31137cfaae3abd20f53f6ba42fd99daf0be8" have entirely different histories.
f07641622e
...
0dab31137c
8 changed files with 109 additions and 53 deletions
|
@ -82,7 +82,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
|||
upper: bind template.playbin as <$AudreyPlaybin>.duration;
|
||||
};
|
||||
|
||||
change-value => $on_play_position_seek () swapped;
|
||||
change-value => $on_play_position_seek (template);
|
||||
}
|
||||
|
||||
[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 () swapped;
|
||||
clicked => $on_skip_backward_clicked (template);
|
||||
}
|
||||
|
||||
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 () swapped;
|
||||
clicked => $seek_backward (template);
|
||||
}
|
||||
|
||||
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 () swapped;
|
||||
clicked => $on_play_pause_clicked (template);
|
||||
}
|
||||
|
||||
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 () swapped;
|
||||
clicked => $seek_forward (template);
|
||||
}
|
||||
|
||||
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 () swapped;
|
||||
clicked => $on_skip_forward_clicked (template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 () swapped;
|
||||
clicked => $on_mute_toggle (template);
|
||||
}
|
||||
|
||||
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',
|
||||
]
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
[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,6 +3,3 @@ 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, GString};
|
||||
use glib::{gformat, gstr, GString};
|
||||
use gtk::{gdk, glib};
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
|
|
100
src/ui/playbar.vapi
Normal file
100
src/ui/playbar.vapi
Normal file
|
@ -0,0 +1,100 @@
|
|||
// [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");
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
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