summaryrefslogtreecommitdiff
path: root/new/unix/button.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-15 19:46:24 -0400
committerPietro Gagliardi <[email protected]>2015-04-15 19:46:24 -0400
commita25f49e7e6a15e4c27c51dea65df67ed3bfa7163 (patch)
tree79df47b53cd4336af49d1615e8276cfacec45a15 /new/unix/button.c
parentbb0c52ee4ea98b679dba89e8988bd960d12c737a (diff)
Started doing conversion of the GTK+ backend...
Diffstat (limited to 'new/unix/button.c')
-rw-r--r--new/unix/button.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/new/unix/button.c b/new/unix/button.c
index da09082..150e049 100644
--- a/new/unix/button.c
+++ b/new/unix/button.c
@@ -8,7 +8,7 @@ struct button {
static void onClicked(GtkButton *button, gpointer data)
{
- uiControl *c = (uiControl *) data;
+ uiControl *c = uiControl(data);
struct button *b = (struct button *) (c->data);
(*(b->onClicked))(c, b->onClickedData);
@@ -26,42 +26,48 @@ static void onDestroy(GtkWidget *widget, gpointer data)
uiFree(b);
}
-uiControl *uiNewButton(const char *text)
+static char *getText(uiButton *b)
{
- uiControl *c;
- struct button *b;
- GtkWidget *widget;
-
- c = uiUnixNewControl(GTK_TYPE_BUTTON,
- FALSE, FALSE,
- "label", text,
- NULL);
-
- 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 c;
+ return g_strdup(gtk_button_get_label(GTK_BUTTON(uiControlHandle(b.base))));
}
-char *uiButtonText(uiControl *c)
+static void setText(uiButton *b, const char *text)
{
- return g_strdup(gtk_button_get_label(GTK_BUTTON(uiControlHandle(c))));
+ gtk_button_set_label(GTK_BUTTON(uiControlHandle(b.base)), text);
}
-void uiButtonSetText(uiControl *c, const char *text)
+static void setOnClicked(uiButton *b, void (*f)(uiControl *, void *), void *data)
{
- gtk_button_set_label(GTK_BUTTON(uiControlHandle(c)), text);
+ struct button *b = (struct button *) (b->base.data);
+
+ b->onClicked = f;
+ b->onClickedData = data;
}
-void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data)
+uiControl *uiNewButton(const char *text)
{
- struct button *b = (struct button *) (c->data);
+ uiButton *b;
+ struct button *bb;
+ GtkWidget *widget;
- b->onClicked = f;
- b->onClickedData = data;
+ b = uiNew(uiButton);
+
+ uiUnixNewControl(&(b.base), GTK_TYPE_BUTTON,
+ FALSE, FALSE,
+ "label", text,
+ NULL);
+
+ widget = GTK_WIDGET(uiControlHandle(&(b.base)));
+ g_signal_connect(widget, "clicked", G_CALLBACK(onClicked), b);
+
+ bb = uiNew(struct button);
+ g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), bb);
+ bb->onClicked = defaultOnClicked;
+ b->priv.data = bb;
+
+ b->Text = getText;
+ b->SetText = setText;
+ b->OnClicked = setOnClicked;
+
+ return b;
}