ocarina: Create a make_toggle_button_data() function

Used to pass extra data to the toggle function.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-05-18 11:24:38 -04:00
parent 01e63da4f7
commit f6cdcae79c
2 changed files with 20 additions and 6 deletions

View File

@ -26,6 +26,11 @@ GtkWidget *make_text_button(const gchar *stockid,
void (* func)(GtkWidget *, gpointer),
bool show);
GtkWidget *make_toggle_button_data(const gchar *stockid,
void (*func)(GtkWidget *, gpointer),
gpointer data,
bool show);
GtkWidget *make_toggle_button(const gchar *stockid,
void (* func)(GtkWidget *, gpointer),
bool show);

View File

@ -1,21 +1,30 @@
// Copyright (c) 2011 Bryan Schumaker
#include <ocarina/button.h>
static GtkWidget *get_toggle_button(void (* func)(GtkWidget *, gpointer), bool show)
static GtkWidget *get_toggle_button(void (* func)(GtkWidget *, gpointer),
gpointer data, bool show)
{
GtkWidget *button = gtk_toggle_button_new();
g_signal_connect(button, "toggled", G_CALLBACK(func), NULL);
g_signal_connect(button, "toggled", G_CALLBACK(func), data);
if (show == true)
gtk_widget_show(button);
return button;
}
GtkWidget *make_toggle_button_data(const gchar *stockid,
void (* func)(GtkWidget *, gpointer),
gpointer data,
bool show)
{
GtkWidget *button = get_toggle_button(func, data, show);
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU);
container_add(button, image);
return button;
}
GtkWidget *make_toggle_button(const gchar *stockid,
void (* func)(GtkWidget *, gpointer),
bool show)
{
GtkWidget *button = get_toggle_button(func, show);
GtkWidget *image = get_image(stockid, GTK_ICON_SIZE_MENU);
container_add(button, image);
return button;
return make_toggle_button_data(stockid, func, NULL, show);
}