summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-05 13:04:34 -0400
committerPietro Gagliardi <[email protected]>2014-06-05 13:04:34 -0400
commit86cf1fbcbafde190905b48588192832448e147da (patch)
treecb5f7c4c3db6d89475f8c132643f6a2f685d8f57
parente1c4e7d655a9402401f7a4c72d1a1d48ac6604c7 (diff)
Fixed resizing of editable comboboxes in the GTK+ backend. Uneditable comboboxes are still an issue, and there's experimental code to try to fix them, but it doesn't work...
-rw-r--r--gtkcalls_unix.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index 819f5d8..99fff8e 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -11,6 +11,18 @@ import (
)
// #include "gtk_unix.h"
+// static inline void gtkSetComboBoxArbitrarilyResizeable(GtkWidget *w)
+// {
+// // we can safely assume that the cell renderers of a GtkComboBoxText are a single GtkCellRendererText by default
+// // thanks mclasen and tristan in irc.gimp.net/#gtk+
+// GtkCellLayout *cbox = (GtkCellLayout *) w;
+// GList *renderer;
+//
+// renderer = gtk_cell_layout_get_cells(cbox);
+// g_object_set(renderer->data, "width-chars", 0, NULL);
+// g_list_free(renderer);
+// gtk_combo_box_set_popup_fixed_width(cbox, FALSE);
+// }
import "C"
var gtkStyles = []byte(
@@ -146,11 +158,23 @@ func gtk_toggle_button_get_active(widget *C.GtkWidget) bool {
}
func gtk_combo_box_text_new() *C.GtkWidget {
- return C.gtk_combo_box_text_new()
+ w := C.gtk_combo_box_text_new()
+ C.gtkSetComboBoxArbitrarilyResizeable(w)
+c:=C.gtk_bin_get_child((*C.GtkBin)(unsafe.Pointer(w)))
+x:=(*C.GTypeInstance)(unsafe.Pointer(c))
+t:=x.g_class.g_type
+fmt.Printf("%p %s\n", c, fromgstr(C.g_type_name(t)))
+ return w
}
func gtk_combo_box_text_new_with_entry() *C.GtkWidget {
- return C.gtk_combo_box_text_new_with_entry()
+ w := C.gtk_combo_box_text_new_with_entry()
+ C.gtkSetComboBoxArbitrarilyResizeable(w)
+ // we need to set the entry's width-chars to achieve the arbitrary sizing we want
+ // thanks to tristan in irc.gimp.net/#gtk+
+ entry := togtkentry(C.gtk_bin_get_child((*C.GtkBin)(unsafe.Pointer(w))))
+ C.gtk_entry_set_width_chars(entry, 0)
+ return w
}
func gtk_combo_box_text_get_active_text(widget *C.GtkWidget) string {