108 lines
2.2 KiB
C++
108 lines
2.2 KiB
C++
|
|
#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);
|
|
}
|
|
|
|
static GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
|
|
void (* func)(GtkWidget *, GdkEvent *, gpointer),
|
|
bool show)
|
|
{
|
|
GtkWidget *button = gtk_button_new();
|
|
GtkWidget *image = gtk_image_new_from_stock(stockid, size);
|
|
gtk_widget_show(image);
|
|
GTK_CONNECT(button, "clicked", func, NULL);
|
|
|
|
container_add(button, image);
|
|
if (show == true)
|
|
gtk_widget_show_all(button);
|
|
return button;
|
|
}
|
|
|
|
static void on_click_play(GtkWidget *b, GdkEvent *e, gpointer d)
|
|
{
|
|
libsaria_get()->play();
|
|
}
|
|
|
|
GtkWidget *make_play_button(GtkIconSize size)
|
|
{
|
|
GtkWidget *b = make_button(GTK_STOCK_MEDIA_PLAY, size, on_click_play, true);
|
|
play_buttons.push_back(b);
|
|
return b;
|
|
}
|
|
|
|
void show_play_buttons()
|
|
{
|
|
show_list(play_buttons);
|
|
}
|
|
|
|
void hide_play_buttons()
|
|
{
|
|
hide_list(play_buttons);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
GtkWidget *make_stop_button(GtkIconSize size)
|
|
{
|
|
return make_button(GTK_STOCK_MEDIA_STOP, size, on_click_stop, true);
|
|
}
|
|
|
|
static void on_click_open_file(GtkWidget *b, GdkEvent *e, gpointer d)
|
|
{
|
|
string file = ocarina_choose_file();
|
|
print("Playing file: " + file);
|
|
libsaria_get()->load(file);
|
|
}
|
|
|
|
GtkWidget *make_open_button(GtkIconSize size)
|
|
{
|
|
return make_button(GTK_STOCK_OPEN, size, on_click_open_file, true);
|
|
}
|