summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtkcalls_unix.go12
-rw-r--r--gtkcasts_unix.go6
-rw-r--r--listbox_unix.go4
3 files changed, 11 insertions, 11 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index f49263a..d9bee56 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -47,7 +47,7 @@ func gtk_window_set_title(window *C.GtkWidget, title string) {
}
func gtk_window_get_title(window *C.GtkWidget) string {
- return C.GoString(fromgchar(C.gtk_window_get_title(togtkwindow(window))))
+ return fromgchar(C.gtk_window_get_title(togtkwindow(window)))
}
func gtk_window_resize(window *C.GtkWidget, width int, height int) {
@@ -77,7 +77,7 @@ func makeTransparent(layout *C.GtkWidget) {
added := C.gtk_css_provider_load_from_data(provider,
(*C.gchar)(unsafe.Pointer(&gtkLayoutCSS[0])), C.gssize(len(gtkLayoutCSS)), &err)
if added == C.FALSE {
- message := C.GoString(fromgchar(err.message))
+ message := fromgchar(err.message)
panic(fmt.Errorf("error loading transparent background CSS for GtkLayout: %s", message))
}
C.gtk_style_context_add_provider(C.gtk_widget_get_style_context(layout),
@@ -128,7 +128,7 @@ func gtk_button_set_label(button *C.GtkWidget, label string) {
}
func gtk_button_get_label(button *C.GtkWidget) string {
- return C.GoString(fromgchar(C.gtk_button_get_label(togtkbutton(button))))
+ return fromgchar(C.gtk_button_get_label(togtkbutton(button)))
}
func gtk_check_button_new() *C.GtkWidget {
@@ -148,7 +148,7 @@ func gtk_combo_box_text_new_with_entry() *C.GtkWidget {
}
func gtk_combo_box_text_get_active_text(widget *C.GtkWidget) string {
- return C.GoString(fromgchar(C.gtk_combo_box_text_get_active_text(togtkcombobox(widget))))
+ return fromgchar(C.gtk_combo_box_text_get_active_text(togtkcombobox(widget)))
}
func gtk_combo_box_text_append_text(widget *C.GtkWidget, text string) {
@@ -196,7 +196,7 @@ func gtk_entry_set_text(widget *C.GtkWidget, text string) {
}
func gtk_entry_get_text(widget *C.GtkWidget) string {
- return C.GoString(fromgchar(C.gtk_entry_get_text(togtkentry(widget))))
+ return fromgchar(C.gtk_entry_get_text(togtkentry(widget)))
}
var _emptystring = [1]C.gchar{0}
@@ -218,7 +218,7 @@ func gtk_label_set_text(widget *C.GtkWidget, text string) {
}
func gtk_label_get_text(widget *C.GtkWidget) string {
- return C.GoString(fromgchar(C.gtk_label_get_text(togtklabel(widget))))
+ return fromgchar(C.gtk_label_get_text(togtklabel(widget)))
}
func gtk_widget_get_preferred_size(widget *C.GtkWidget) (minWidth int, minHeight int, natWidth int, natHeight int) {
diff --git a/gtkcasts_unix.go b/gtkcasts_unix.go
index 133f596..287ed58 100644
--- a/gtkcasts_unix.go
+++ b/gtkcasts_unix.go
@@ -28,9 +28,9 @@ func togbool(b bool) C.gboolean {
return C.FALSE
}
-// TODO wrap in C.GoString()?
-func fromgchar(what *C.gchar) *C.char {
- return (*C.char)(unsafe.Pointer(what))
+func fromgchar(what *C.gchar) string {
+ cstr := (*C.char)(unsafe.Pointer(what))
+ return C.GoString(cstr)
}
func togchar(what *C.char) *C.gchar {
diff --git a/listbox_unix.go b/listbox_unix.go
index f8fc5fe..9687a54 100644
--- a/listbox_unix.go
+++ b/listbox_unix.go
@@ -113,7 +113,7 @@ func gListboxText(widget *C.GtkWidget) string {
return ""
}
C.gtkTreeModelGet(model, &iter, &gs)
- return C.GoString(fromgchar(gs))
+ return fromgchar(gs)
}
func gListboxAppend(widget *C.GtkWidget, what string) {
@@ -181,7 +181,7 @@ func gListboxSelMultiTexts(widget *C.GtkWidget) (texts []string) {
return
}
C.gtkTreeModelGet(model, &iter, &gs)
- texts[i] = C.GoString(fromgchar(gs))
+ texts[i] = fromgchar(gs)
rows = rows.next
}
return texts