summaryrefslogtreecommitdiff
path: root/new/unix/label.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-15 18:49:45 -0400
committerPietro Gagliardi <[email protected]>2015-04-15 18:49:45 -0400
commit518a5ddbf15d50a254c732a80d5907ef8878abe0 (patch)
tree48cf259f98994e4570e65c389fcd9824272884ad /new/unix/label.c
parent50ae3ca045e7f5f5744043df0a4506e2f6930bb1 (diff)
Split all OS backends into their own folders.
Diffstat (limited to 'new/unix/label.c')
-rw-r--r--new/unix/label.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/new/unix/label.c b/new/unix/label.c
new file mode 100644
index 0000000..1f950d3
--- /dev/null
+++ b/new/unix/label.c
@@ -0,0 +1,45 @@
+// 11 april 2015
+#include "uipriv_unix.h"
+
+struct label {
+};
+
+static void onDestroy(GtkWidget *widget, gpointer data)
+{
+ struct label *l = (struct label *) data;
+
+ uiFree(l);
+}
+
+uiControl *uiNewLabel(const char *text)
+{
+ uiControl *c;
+ struct label *l;
+ GtkWidget *widget;
+
+ c = uiUnixNewControl(GTK_TYPE_LABEL,
+ FALSE, FALSE,
+ "label", text,
+ "xalign", 0.0, // note: must be a float constant, otherwise the ... will turn it into an int and we get segfaults on some platforms (thanks ebassi in irc.gimp.net/#gtk+)
+ // TODO yalign 0?
+ NULL);
+
+ widget = GTK_WIDGET(uiControlHandle(c));
+
+ l = uiNew(struct label);
+ g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), l);
+ c->data = l;
+
+ return c;
+}
+
+char *uiLabelText(uiControl *c)
+{
+ // TODO change g_strdup() to a wrapper function for export in ui_unix.h
+ return g_strdup(gtk_label_get_text(GTK_LABEL(uiControlHandle(c))));
+}
+
+void uiLabelSetText(uiControl *c, const char *text)
+{
+ gtk_label_set_text(GTK_LABEL(uiControlHandle(c)), text);
+}