ui/gtk/button.c

changeset 4
39b9b86ec452
parent 3
c1a75454b444
child 5
19d37cb9c96c
--- a/ui/gtk/button.c	Sat Mar 22 10:37:12 2014 +0100
+++ b/ui/gtk/button.c	Sat Mar 22 15:34:20 2014 +0100
@@ -30,7 +30,32 @@
 #include <stdlib.h>
 
 #include "button.h"
+#include "container.h"
+#include "../../ucx/mempool.h"
+#include "../common/context.h"
 
+UIWIDGET ui_button(UiObject *obj, char *label, ui_callback f, void *data) {
+    GtkWidget *button = gtk_button_new_with_label(label);
+    
+    if(f) {
+        UiEventData *event = ucx_mempool_malloc(
+                obj->ctx->mempool,
+                sizeof(UiEventData));
+        event->obj = obj;
+        event->user_data = data;
+        event->callback = f;
+
+        g_signal_connect(
+                button,
+                "clicked",
+                G_CALLBACK(ui_button_clicked),
+                event);
+    }
+    
+    obj->container->add(obj->container, button);
+    
+    return button;
+}
 
 
 void ui_button_clicked(GtkWidget *widget, UiEventData *event) {

mercurial