More unix/button.c fixups. I think this will do...
This commit is contained in:
parent
b91fe0c2ac
commit
908755e6b7
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
struct button {
|
struct button {
|
||||||
uiButton b;
|
uiButton b;
|
||||||
|
GtkWidget *widget;
|
||||||
|
GtkButton *button;
|
||||||
void (*onClicked)(uiButton *, void *);
|
void (*onClicked)(uiButton *, void *);
|
||||||
void *onClickedData;
|
void *onClickedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void clicked(GtkButton *button, gpointer data)
|
static void onClicked(GtkButton *button, gpointer data)
|
||||||
{
|
{
|
||||||
struct button *b = (struct button *) data;
|
struct button *b = (struct button *) data;
|
||||||
|
|
||||||
|
@ -19,23 +21,25 @@ static void defaultOnClicked(uiButton *b, void *data)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(GtkWidget *widget, gpointer data)
|
static void onDestroy(GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
struct button *b = (struct button *) data;
|
struct button *b = (struct button *) data;
|
||||||
|
|
||||||
uiFree(b);
|
uiFree(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUTTON(b) GTK_BUTTON(widget(b))
|
|
||||||
|
|
||||||
static char *buttonText(uiButton *bb)
|
static char *buttonText(uiButton *bb)
|
||||||
{
|
{
|
||||||
return g_strdup(gtk_button_get_label(BUTTON(bb)));
|
struct button *b = (struct button *) bb;
|
||||||
|
|
||||||
|
return g_strdup(gtk_button_get_label(b->button));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buttonSetText(uiButton *bb, const char *text)
|
static void buttonSetText(uiButton *bb, const char *text)
|
||||||
{
|
{
|
||||||
gtk_button_set_label(BUTTON(bb), text);
|
struct button *b = (struct button *) bb;
|
||||||
|
|
||||||
|
gtk_button_set_label(b->button, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data)
|
static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data)
|
||||||
|
@ -49,7 +53,6 @@ static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *d
|
||||||
uiButton *uiNewButton(const char *text)
|
uiButton *uiNewButton(const char *text)
|
||||||
{
|
{
|
||||||
struct button *b;
|
struct button *b;
|
||||||
GtkWidget *widget;
|
|
||||||
|
|
||||||
b = uiNew(struct button);
|
b = uiNew(struct button);
|
||||||
|
|
||||||
|
@ -58,9 +61,11 @@ uiButton *uiNewButton(const char *text)
|
||||||
"label", text,
|
"label", text,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
widget = WIDGET(b);
|
b->widget = WIDGET(b);
|
||||||
g_signal_connect(widget, "clicked", G_CALLBACK(clicked), b);
|
b->button = GTK_BUTTON(b->widget);
|
||||||
g_signal_connect(widget, "destroy", G_CALLBACK(destroy), b);
|
|
||||||
|
g_signal_connect(b->widget, "clicked", G_CALLBACK(onClicked), b);
|
||||||
|
g_signal_connect(b->widget, "destroy", G_CALLBACK(onDestroy), b);
|
||||||
b->onClicked = defaultOnClicked;
|
b->onClicked = defaultOnClicked;
|
||||||
|
|
||||||
uiButton(b)->Text = buttonText;
|
uiButton(b)->Text = buttonText;
|
||||||
|
|
Loading…
Reference in New Issue