ocarina: Move play button to new file

I moved all the button code into a new subdirectory.  From there, I
moved the play button code into a file named controls.cpp.  This should
help clean up button code.
This commit is contained in:
Bryan Schumaker 2011-08-30 08:26:23 -04:00
parent 7e9b2f9380
commit 8234e4072b
3 changed files with 53 additions and 23 deletions

View File

@ -25,7 +25,7 @@ static void hide_list(list<GtkWidget *> &l)
gtk_widget_hide(*it);
}
static GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
void (* func)(GtkWidget *, GdkEvent *, gpointer),
bool show)
{
@ -40,28 +40,6 @@ static GtkWidget *make_button(const gchar *stockid, GtkIconSize size,
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();

47
gui/buttons/controls.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <list>
using namespace std;
#include <ocarina/button.h>
#include <libsaria/libsaria.h>
static list<GtkWidget *> play_buttons;
static void show_list(list<GtkWidget *> &buttons)
{
list<GtkWidget *>::iterator it;
for(it = buttons.begin(); it != buttons.end(); it++)
gtk_widget_show(*it);
}
static void hide_list(list<GtkWidget *> &buttons)
{
list<GtkWidget *>::iterator it;
for(it = buttons.begin(); it != buttons.end(); it++)
gtk_widget_hide(*it);
}
static void on_click_play(GtkWidget *b, GdkEvent *e, gpointer d)
{
libsaria_get()->play();
}
void show_play_buttons()
{
show_list(play_buttons);
}
void hide_play_buttons()
{
hide_list(play_buttons);
}
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;
}

View File

@ -6,6 +6,11 @@ using namespace std;
#include <ocarina/gtk.h>
GtkWidget *make_button(const gchar *stockid,
GtkIconSize size,
void (* func)(GtkWidget *, GdkEvent *, gpointer),
bool show);
GtkWidget *make_play_button(GtkIconSize);
GtkWidget *make_pause_button(GtkIconSize);
GtkWidget *make_stop_button(GtkIconSize);