Added GTK+ Labels.

This commit is contained in:
Pietro Gagliardi 2014-02-16 22:03:14 -05:00
parent d7f9d3807d
commit 919e89ca7e
2 changed files with 22 additions and 0 deletions

View File

@ -181,3 +181,22 @@ func gtk_entry_set_text(widget *gtkWidget, text string) {
func gtk_entry_get_text(widget *gtkWidget) string {
return C.GoString((*C.char)(unsafe.Pointer(C.gtk_entry_get_text((*C.GtkEntry)(unsafe.Pointer(widget))))))
}
var _emptystring = [1]C.gchar{0}
var emptystring = &_emptystring[0]
func gtk_label_new() *gtkWidget {
return (*gtkWidget)(unsafe.Pointer(C.gtk_label_new(emptystring)))
// TODO left-justify?
}
func gtk_label_set_text(widget *gtkWidget, text string) {
ctext := C.CString(text)
defer C.free(unsafe.Pointer(ctext))
C.gtk_label_set_text((*C.GtkLabel)(unsafe.Pointer(widget)),
(*C.gchar)(unsafe.Pointer(ctext)))
}
func gtk_label_get_text(widget *gtkWidget) string {
return C.GoString((*C.char)(unsafe.Pointer(C.gtk_label_get_text((*C.GtkLabel)(unsafe.Pointer(widget))))))
}

View File

@ -93,6 +93,9 @@ var classTypes = [nctypes]*classData{
text: gtk_entry_get_text,
},
c_label: &classData{
make: gtk_label_new,
setText: gtk_label_set_text,
text: gtk_label_get_text,
},
c_listbox: &classData{
},