diff --git a/gui/button.cpp b/gui/button.cpp index aadf777f..dcdd6808 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -3,46 +3,47 @@ #include #include -#define ls_on_click(func) \ -static void on_click_##func(GtkWidget *button, GdkEvent *event, gpointer data)\ -{ \ - libsaria_get()->func(); \ +static void on_click_play(GtkWidget *b, GdkEvent *e, gpointer d) +{ + libsaria_get()->play(); } -#define on_click(func) \ - on_click_##func +static void on_click_pause(GtkWidget *b, GdkEvent *e, gpointer d) +{ + libsaria_get()->pause(); +} -GtkWidget *make_button(const gchar *stockid, GtkIconSize size) +static void on_click_stop(GtkWidget *b, GdkEvent *e, gpointer d) +{ + libsaria_get()->stop(); +} + +static GtkWidget *make_button(const gchar *stockid, GtkIconSize size, + void (* func)(GtkWidget *, GdkEvent *, gpointer)) { GtkWidget *button = gtk_button_new(); GtkWidget *box = gtk_hbox_new(FALSE, 0); GtkWidget *image = gtk_image_new_from_stock(stockid, size); + + GTK_CONNECT(button, "clicked", func, NULL); + box_pack_start(box, image, FALSE, FALSE, 0); container_add(button, box); gtk_widget_show_all(button); return button; } -ls_on_click(play); GtkWidget *make_play_button(GtkIconSize size) { - GtkWidget *button = make_button(GTK_STOCK_MEDIA_PLAY, size); - GTK_CONNECT(button, "clicked", on_click(play), NULL); - return button; + return make_button(GTK_STOCK_MEDIA_PLAY, size, on_click_play); } -ls_on_click(pause); GtkWidget *make_pause_button(GtkIconSize size) { - GtkWidget *button = make_button(GTK_STOCK_MEDIA_PAUSE, size); - GTK_CONNECT(button, "clicked", on_click(pause), NULL); - return button; + return make_button(GTK_STOCK_MEDIA_PAUSE, size, on_click_pause); } -ls_on_click(stop); GtkWidget *make_stop_button(GtkIconSize size) { - GtkWidget *button = make_button(GTK_STOCK_MEDIA_STOP, size); - GTK_CONNECT(button, "clicked", on_click(stop), NULL); - return button; + return make_button(GTK_STOCK_MEDIA_STOP, size, on_click_stop); } diff --git a/include/ocarina/button.h b/include/ocarina/button.h index 5c77fa3c..e96866d2 100644 --- a/include/ocarina/button.h +++ b/include/ocarina/button.h @@ -6,7 +6,6 @@ using namespace std; #include -GtkWidget *make_button(const gchar *, GtkIconSize); GtkWidget *make_play_button(GtkIconSize); GtkWidget *make_pause_button(GtkIconSize); GtkWidget *make_stop_button(GtkIconSize);