ocarina: Move pause button code
I moved it from the generic button.cpp file to the controls.cpp file to keep everything together. I also changed the button list to use the new show / hide functions.
This commit is contained in:
parent
bd907ecfe0
commit
f6ac48219e
|
@ -1,30 +1,9 @@
|
|||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/chooser.h>
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/libsaria.h>
|
||||
|
||||
static list<GtkWidget *> play_buttons;
|
||||
static list<GtkWidget *> pause_buttons;
|
||||
|
||||
static void show_list(list<GtkWidget *> &l)
|
||||
{
|
||||
list<GtkWidget *>::iterator it;
|
||||
for(it = l.begin(); it != l.end(); it++)
|
||||
gtk_widget_show(*it);
|
||||
}
|
||||
|
||||
static void hide_list(list<GtkWidget *> &l)
|
||||
{
|
||||
list<GtkWidget *>::iterator it;
|
||||
for(it = l.begin(); it != l.end(); it++)
|
||||
gtk_widget_hide(*it);
|
||||
}
|
||||
|
||||
GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
|
||||
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
||||
bool show)
|
||||
|
@ -40,28 +19,6 @@ GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
|
|||
return button;
|
||||
}
|
||||
|
||||
static void on_click_pause(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
libsaria_get()->pause();
|
||||
}
|
||||
|
||||
GtkWidget *make_pause_button(GtkIconSize size)
|
||||
{
|
||||
GtkWidget *b = make_button(GTK_STOCK_MEDIA_PAUSE, size, on_click_pause, false);
|
||||
pause_buttons.push_back(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
void show_pause_buttons()
|
||||
{
|
||||
show_list(pause_buttons);
|
||||
}
|
||||
|
||||
void hide_pause_buttons()
|
||||
{
|
||||
hide_list(pause_buttons);
|
||||
}
|
||||
|
||||
static void on_click_stop(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
libsaria_get()->stop();
|
||||
|
|
|
@ -6,10 +6,16 @@ using namespace std;
|
|||
#include <libsaria/libsaria.h>
|
||||
|
||||
static list<GtkWidget *> play_buttons;
|
||||
static list<GtkWidget *> pause_buttons;
|
||||
|
||||
static list<GtkWidget *> *get_buttons(button_list_t bttn_list)
|
||||
{
|
||||
return &play_buttons;
|
||||
switch(bttn_list) {
|
||||
case PLAY_BUTTON_LIST:
|
||||
return &play_buttons;
|
||||
default:
|
||||
return &pause_buttons;
|
||||
}
|
||||
}
|
||||
|
||||
void show_button_list(button_list_t bttn_list)
|
||||
|
@ -28,7 +34,6 @@ void hide_button_list(button_list_t bttn_list)
|
|||
gtk_widget_hide(*it);
|
||||
}
|
||||
|
||||
|
||||
static void on_click_play(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
libsaria_get()->play();
|
||||
|
@ -43,3 +48,20 @@ GtkWidget *make_play_button(GtkIconSize size)
|
|||
play_buttons.push_back(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
static void on_click_pause(GtkWidget *b, GdkEvent *e, gpointer d)
|
||||
{
|
||||
libsaria_get()->pause();
|
||||
}
|
||||
|
||||
GtkWidget *make_pause_button(GtkIconSize size)
|
||||
{
|
||||
GtkWidget *b = make_button(GTK_STOCK_MEDIA_PAUSE,
|
||||
size,
|
||||
on_click_pause,
|
||||
false);
|
||||
pause_buttons.push_back(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ void cb_play()
|
|||
{
|
||||
print("Ocarina PLAY callback!");
|
||||
hide_button_list(PLAY_BUTTON_LIST);
|
||||
show_pause_buttons();
|
||||
show_button_list(PAUSE_BUTTON_LIST);
|
||||
}
|
||||
|
||||
void cb_pause()
|
||||
{
|
||||
print("Ocarina PAUSE callback!");
|
||||
hide_pause_buttons();
|
||||
hide_button_list(PAUSE_BUTTON_LIST);
|
||||
show_button_list(PLAY_BUTTON_LIST);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,4 @@ enum button_list_t {
|
|||
void show_button_list(button_list_t);
|
||||
void hide_button_list(button_list_t);
|
||||
|
||||
void show_pause_buttons();
|
||||
void hide_pause_buttons();
|
||||
|
||||
#endif /* OCARINA_BUTTON_H */
|
||||
|
|
Loading…
Reference in New Issue