ocarina: Connect signals to buttons
And also - Show / hide the play and pause buttons - Remove the scrollbar from the now playing display Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
90355962e4
commit
22e64d64ca
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <version.h>
|
||||
#include <libsaria/libsaria.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/deck.h>
|
||||
#include <libsaria/idle.h>
|
||||
|
||||
#include <ocarina/ocarina.h>
|
||||
|
@ -110,6 +112,13 @@ static void init(int argc, char **argv)
|
|||
init_window();
|
||||
init_playlist();
|
||||
|
||||
/* Connect signals */
|
||||
connect_signal("PlayButton", "clicked", libsaria::audio::play, NULL);
|
||||
connect_signal("PauseButton", "clicked", libsaria::audio::pause, NULL);
|
||||
connect_signal("StopButton", "clicked", libsaria::audio::stop, NULL);
|
||||
connect_signal("PrevButton", "clicked", libsaria::deck::prev, NULL);
|
||||
connect_signal("NextButton", "clicked", libsaria::deck::next, NULL);
|
||||
|
||||
/* Show any widgets that need showing */
|
||||
/* ocarina::window::init();
|
||||
ocarina::body::init();*/
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
static libsaria::Track *current = NULL;
|
||||
static libsaria::Track *cur_track = NULL;
|
||||
static GstState cur_state;
|
||||
|
||||
static void set_label(const string &name, const string &text, const string &size)
|
||||
{
|
||||
|
@ -22,18 +24,46 @@ static void set_label(const string &name, const string &text, const string &size
|
|||
|
||||
static void refresh_widgets()
|
||||
{
|
||||
set_label("TitleLabel", current->get_title(), "xx-large");
|
||||
set_label("ArtistLabel", current->get_artist(), "x-large");
|
||||
set_label("AlbumLabel", current->get_album(), "x-large");
|
||||
set_label("DurLabel", current->get_lenstr(), "");
|
||||
set_label("TitleLabel", cur_track->get_title(), "xx-large");
|
||||
set_label("ArtistLabel", cur_track->get_artist(), "x-large");
|
||||
set_label("AlbumLabel", cur_track->get_album(), "x-large");
|
||||
set_label("DurLabel", cur_track->get_lenstr(), "");
|
||||
}
|
||||
|
||||
static void update_labels()
|
||||
{
|
||||
libsaria::Track *cur = libsaria::current_track();
|
||||
if (cur == cur_track)
|
||||
return;
|
||||
|
||||
cur_track = cur;
|
||||
refresh_widgets();
|
||||
}
|
||||
|
||||
static void update_buttons()
|
||||
{
|
||||
GstState cur;
|
||||
GtkWidget *play, *pause;
|
||||
|
||||
cur = libsaria::audio::get_state();
|
||||
if (cur == cur_state)
|
||||
return;
|
||||
|
||||
cur_state = cur;
|
||||
play = get_widget("PlayButton");
|
||||
pause = get_widget("PauseButton");
|
||||
|
||||
if (cur_state == GST_STATE_PLAYING) {
|
||||
gtk_widget_show(pause);
|
||||
gtk_widget_hide(play);
|
||||
} else {
|
||||
gtk_widget_show(play);
|
||||
gtk_widget_hide(pause);
|
||||
}
|
||||
}
|
||||
|
||||
void update_status()
|
||||
{
|
||||
libsaria::Track *cur = libsaria::current_track();
|
||||
if (cur == current)
|
||||
return;
|
||||
|
||||
current = cur;
|
||||
refresh_widgets();
|
||||
update_labels();
|
||||
update_buttons();
|
||||
}
|
||||
|
|
|
@ -205,6 +205,7 @@
|
|||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">never</property>
|
||||
<child>
|
||||
<object class="GtkViewport" id="viewport1">
|
||||
|
|
Loading…
Reference in New Issue