ocarina: Make generic button-building functions

I want to have buttons with text in addition to images.  To help with
this, I created some functions that should help with that.
This commit is contained in:
Bryan Schumaker 2011-09-10 10:07:48 -04:00
parent 62b86f5136
commit 95ebff8b6e
1 changed files with 19 additions and 7 deletions

View File

@ -5,19 +5,31 @@
#include <libsaria/print.h>
#include <libsaria/controls.h>
static GtkWidget *get_button(void (* func)(GtkWidget *, GdkEvent *, gpointer),
bool show)
{
GtkWidget *button = gtk_button_new();
GTK_CONNECT(button, "clicked", func, NULL);
if (show == true)
gtk_widget_show(button);
return button;
}
static GtkWidget *get_image(const gchar *stockid)
{
GtkWidget *img = gtk_image_new_from_stock(stockid, GTK_ICON_SIZE_MENU);
gtk_widget_show(img);
return img;
}
GtkWidget *make_button(const gchar *stockid,
void (* func)(GtkWidget *, GdkEvent *, gpointer),
bool show)
{
GtkWidget *button = gtk_button_new();
GtkWidget *image = gtk_image_new_from_stock(stockid,
GTK_ICON_SIZE_MENU);
gtk_widget_show(image);
GTK_CONNECT(button, "clicked", func, NULL);
GtkWidget *button = get_button(func, show);
GtkWidget *image = get_image(stockid);
container_add(button, image);
if (show == true)
gtk_widget_show_all(button);
return button;
}