diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-09 18:17:04 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-09 18:17:04 -0400 |
| commit | 22db738dd13fc8a7eae6188698ab82a803b9ec76 (patch) | |
| tree | 92dde89ba29b7c2c77eb7d3c27419098ae22e707 /new/button_unix.c | |
| parent | 1a525dea313bc78d707b6678f76c7355445d4a87 (diff) | |
Migrated the GTK+ backend to the new uiControl/uiSizing system.
Diffstat (limited to 'new/button_unix.c')
| -rw-r--r-- | new/button_unix.c | 30 |
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; } |
