libsaria: Notifications for play and pause events
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
9f7d861b77
commit
00111fc87b
|
@ -7,6 +7,8 @@ enum notify_t {
|
|||
PATH_ADDED, // libsaria::library::Path *
|
||||
PATH_DELETED, // libsaria::library::Path *
|
||||
PATH_UPDATED, // libsaria::library::Path *
|
||||
PLAYING, // NULL
|
||||
PAUSED, // NULL
|
||||
NOTIFY_SIZE,
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ bool update_idle_bar(int);
|
|||
void update_length_label(string &);
|
||||
void update_status();
|
||||
void update_labels(libsaria::Track *);
|
||||
void update_buttons(notify_t);
|
||||
void init_status();
|
||||
|
||||
namespace ocarina
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker.
|
||||
#include <libsaria/notify.h>
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/print.h>
|
||||
#include <libsaria/path.h>
|
||||
|
@ -6,6 +7,14 @@
|
|||
|
||||
static GstState cur_state = GST_STATE_READY;
|
||||
|
||||
static void notify_state_change(GstState state)
|
||||
{
|
||||
if (state == GST_STATE_PLAYING)
|
||||
libsaria::notify(PLAYING, NULL);
|
||||
else if (state == GST_STATE_PAUSED)
|
||||
libsaria::notify(PAUSED, NULL);
|
||||
}
|
||||
|
||||
static bool change_state(GstState new_state)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
|
@ -15,6 +24,7 @@ static bool change_state(GstState new_state)
|
|||
case GST_STATE_CHANGE_SUCCESS:
|
||||
case GST_STATE_CHANGE_ASYNC:
|
||||
cur_state = new_state;
|
||||
notify_state_change(cur_state);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -11,6 +11,10 @@ void on_notify(notify_t event, void *data)
|
|||
case PATH_DELETED:
|
||||
case PATH_UPDATED:
|
||||
notify_library(event, (libsaria::library::Path *)data);
|
||||
break;
|
||||
case PLAYING:
|
||||
case PAUSED:
|
||||
update_buttons(event);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include <libsaria/deck.h>
|
||||
#include <libsaria/idle.h>
|
||||
|
||||
static GstState cur_state;
|
||||
|
||||
static void set_label(const string &name, const string &text, const string &size)
|
||||
{
|
||||
GtkWidget *label = get_widget(name);
|
||||
|
@ -33,20 +31,14 @@ void update_labels(libsaria::Track *track)
|
|||
track->get_banned());
|
||||
}
|
||||
|
||||
static void update_buttons()
|
||||
void update_buttons(notify_t event)
|
||||
{
|
||||
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) {
|
||||
if (event == PLAYING) {
|
||||
gtk_widget_show(pause);
|
||||
gtk_widget_hide(play);
|
||||
} else {
|
||||
|
@ -152,7 +144,6 @@ void update_length_label(string &text)
|
|||
|
||||
void update_status()
|
||||
{
|
||||
update_buttons();
|
||||
update_progress();
|
||||
update_autopause();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue