diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-15 22:17:02 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-15 22:17:02 -0400 |
| commit | 922360f1120daa1581c8db9feb365929bce416eb (patch) | |
| tree | 49c15b2c0a3cb3c11161e1ee4becc2826ad3b9c8 /new/unix/label.c | |
| parent | f6ef5212331229cfa17bb05a61d4ca566273ddff (diff) | |
Converted unix/entry.c and unix/label.c.
Diffstat (limited to 'new/unix/label.c')
| -rw-r--r-- | new/unix/label.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/new/unix/label.c b/new/unix/label.c index 1f950d3..caf7d55 100644 --- a/new/unix/label.c +++ b/new/unix/label.c @@ -2,6 +2,7 @@ #include "uipriv_unix.h" struct label { + uiLabel l; }; static void onDestroy(GtkWidget *widget, gpointer data) @@ -11,35 +12,38 @@ static void onDestroy(GtkWidget *widget, gpointer data) uiFree(l); } +#define LABEL(l) GTK_LABEL(uiControlHandle(uiControl(l))) + +static char *getText(uiLabel *l) +{ + // TODO change g_strdup() to a wrapper function for export in ui_unix.h + return g_strdup(gtk_label_get_text(LABEL(l))); +} + +static void setText(uiLabel *l, const char *text) +{ + gtk_label_set_text(LABEL(l), text); +} + uiControl *uiNewLabel(const char *text) { - uiControl *c; struct label *l; GtkWidget *widget; - c = uiUnixNewControl(GTK_TYPE_LABEL, + l = uiNew(struct label); + + uiUnixNewControl(uiControl(l), 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); + widget = GTK_WIDGET(LABEL(l)); g_signal_connect(widget, "destroy", G_CALLBACK(onDestroy), l); - c->data = l; - return c; -} + uiLabel(l)->Text = getText; + uiLabel(l)->SetText = setText; -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); + return uiLabel(l); } |
