From 723f2af8c621525848a234d88d98b5107cf0d683 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 9 Apr 2015 02:56:51 -0400 Subject: [PATCH] Implemented the text routines on the GTK+ backend. They work! --- new/button_unix.c | 10 +++++++++- new/entry_unix.c | 10 ++++++++++ new/util_unix.c | 7 +++++++ new/window_unix.c | 10 +++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 new/util_unix.c diff --git a/new/button_unix.c b/new/button_unix.c index a39bdf5..c458e68 100644 --- a/new/button_unix.c +++ b/new/button_unix.c @@ -47,7 +47,15 @@ uiControl *uiNewButton(const char *text) return b->c; } -// TODO text +char *uiButtonText(uiControl *c) +{ + return g_strdup(gtk_button_get_label(GTK_BUTTON(uiControlHandle(c)))); +} + +void uiButtonSetText(uiControl *c, const char *text) +{ + gtk_button_set_label(GTK_BUTTON(uiControlHandle(c)), text); +} void uiButtonOnClicked(uiControl *c, void (*f)(uiControl *, void *), void *data) { diff --git a/new/entry_unix.c b/new/entry_unix.c index 2316618..04005d3 100644 --- a/new/entry_unix.c +++ b/new/entry_unix.c @@ -30,3 +30,13 @@ uiControl *uiNewEntry(void) return e->c; } + +char *uiEntryText(uiControl *c) +{ + return g_strdup(gtk_entry_get_text(GTK_ENTRY(uiControlHandle(c)))); +} + +void uiEntrySetText(uiControl *c, const char *text) +{ + gtk_entry_set_text(GTK_ENTRY(uiControlHandle(c)), text); +} diff --git a/new/util_unix.c b/new/util_unix.c new file mode 100644 index 0000000..72b71df --- /dev/null +++ b/new/util_unix.c @@ -0,0 +1,7 @@ +// 9 april 2015 +#include "uipriv_unix.h" + +void uiFreeText(char *t) +{ + g_free(t); +} diff --git a/new/window_unix.c b/new/window_unix.c index 293fa51..dca52e3 100644 --- a/new/window_unix.c +++ b/new/window_unix.c @@ -39,7 +39,15 @@ uintptr_t uiWindowHandle(uiWindow *w) return (uintptr_t) (w->widget); } -// TODO titles +char *uiWindowTitle(uiWindow *w) +{ + return g_strdup(gtk_window_get_title(GTK_WINDOW(w->widget))); +} + +void uiWindowSetTitle(uiWindow *w, const char *title) +{ + gtk_window_set_title(GTK_WINDOW(w->widget), title); +} void uiWindowShow(uiWindow *w) {