summaryrefslogtreecommitdiff
path: root/new/button_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'new/button_unix.c')
-rw-r--r--new/button_unix.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/new/button_unix.c b/new/button_unix.c
index c458e68..da09082 100644
--- a/new/button_unix.c
+++ b/new/button_unix.c
@@ -2,16 +2,16 @@
#include "uipriv_unix.h"
struct button {
- uiControl *c;
void (*onClicked)(uiControl *, void *);
void *onClickedData;
};
-#define B(x) ((struct button *) (x))
-
-static void onClicked(GtkButton *b, gpointer data)
+static void onClicked(GtkButton *button, gpointer data)
{
- (*(B(data)->onClicked))(B(data)->c, B(data)->onClickedData);
+ uiControl *c = (uiControl *) data;
+ struct button *b = (struct button *) (c->data);
+
+ (*(b->onClicked))(c, b->onClickedData);
}
static void defaultOnClicked(uiControl *c, void *data)
@@ -28,23 +28,24 @@ static void onDestroy(GtkWidget *widget, gpointer data)
uiControl *uiNewButton(const char *text)
{
+ uiControl *c;
struct button *b;
GtkWidget *widget;
- b = uiNew(struct button);
-
- b->c = uiUnixNewControl(GTK_TYPE_BUTTON,
- FALSE, FALSE, b,
+ c = uiUnixNewControl(GTK_TYPE_BUTTON,
+ FALSE, FALSE,
"label", text,
NULL);
- widget = GTK_WIDGET(uiControlHandle(b->c));
- g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), b);
- g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b);
+ widget = GTK_WIDGET(uiControlHandle(c));
+ g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), c);
+ b = uiNew(struct button);
+ g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), b);
b->onClicked = defaultOnClicked;
+ c->data = b;
- return b->c;
+ return c;
}
char *uiButtonText(uiControl *c)
@@ -59,9 +60,8 @@ void uiButtonSetText(uiControl *c, const char *text)
void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
{
- struct button *b;
+ struct button *b = (struct button *) (c->data);
- b = (struct button *) uiUnixControlData(c);
b->onClicked = f;
b->onClickedData = data;
}