ocarina/gui/button.cpp

41 lines
1021 B
C++

#include <ocarina/button.h>
#include <libsaria/audio.h>
#include <libsaria/libsaria.h>
#define reg_on_click(func) \
static void on_click_##func(GtkWidget *button, GdkEvent *event, gpointer data)\
{ \
func(); \
}
#define on_click(func) \
on_click_##func
GtkWidget *make_button(const gchar *stockid, GtkIconSize size)
{
GtkWidget *button = gtk_button_new();
GtkWidget *box = gtk_hbox_new(FALSE, 0);
GtkWidget *image = gtk_image_new_from_stock(stockid, size);
box_pack_start(box, image, FALSE, FALSE, 0);
container_add(button, box);
gtk_widget_show_all(button);
return button;
}
reg_on_click(gst_play);
GtkWidget *make_play_button(GtkIconSize size)
{
GtkWidget *button = make_button(GTK_STOCK_MEDIA_PLAY, size);
GTK_CONNECT(button, "clicked", on_click(gst_play), NULL);
return button;
}
reg_on_click(gst_pause);
GtkWidget *make_pause_button(GtkIconSize size)
{
GtkWidget *button = make_button(GTK_STOCK_MEDIA_PAUSE, size);
GTK_CONNECT(button, "clicked", on_click(gst_pause), NULL);
return button;
}