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:
parent
62b86f5136
commit
95ebff8b6e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue