diff options
author | Brijesh Singh <brijesh.ksingh@gmail.com> | 2015-06-04 06:51:14 -0500 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-06-11 14:32:25 +0200 |
commit | 2a2c10ac2562ec8ab30c2c5d48972c05b1eb69c6 (patch) | |
tree | 8d4e7bc71a85685e31b4c53a79af86ddcbf3da88 /playback | |
parent | 80eefca0d123cb610f9595bdf1cfd5051fbe9386 (diff) |
playback/player: gtk-play: use volume-changed signal from player to update the volume slider.
Diffstat (limited to 'playback')
-rw-r--r-- | playback/player/gtk/gtk-play.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/playback/player/gtk/gtk-play.c b/playback/player/gtk/gtk-play.c index bd6b7f5..895ed99 100644 --- a/playback/player/gtk/gtk-play.c +++ b/playback/player/gtk/gtk-play.c @@ -20,6 +20,7 @@ */ #include <string.h> +#include <math.h> #include <gst/gst.h> #include <gst/tag/tag.h> @@ -1530,6 +1531,25 @@ media_info_updated_cb (GstPlayer * player, GstPlayerMediaInfo * media_info, } } +static void +player_volume_changed_cb (GstPlayer * player, GtkPlay * play) +{ + gdouble new_val, cur_val; + + cur_val = gtk_scale_button_get_value + (GTK_SCALE_BUTTON (play->volume_button)); + new_val = gst_player_get_volume (play->player); + + if (fabs (cur_val - new_val) > 0.001) { + g_signal_handlers_block_by_func (play->volume_button, + volume_changed_cb, play); + gtk_scale_button_set_value (GTK_SCALE_BUTTON (play->volume_button), + new_val); + g_signal_handlers_unblock_by_func (play->volume_button, + volume_changed_cb, play); + } +} + int main (gint argc, gchar ** argv) { @@ -1612,6 +1632,8 @@ main (gint argc, gchar ** argv) g_signal_connect (play.player, "end-of-stream", G_CALLBACK (eos_cb), &play); g_signal_connect (play.player, "media-info-updated", G_CALLBACK (media_info_updated_cb), &play); + g_signal_connect (play.player, "volume-changed", + G_CALLBACK (player_volume_changed_cb), &play); play.playing = TRUE; play_current_uri (&play, g_list_first (play.uris), NULL); |