func gtk_entry_new() *C.GtkWidget { e := C.gtk_entry_new() // allows the GtkEntry to be resized with the window smaller than what it thinks the size should be // thanks to Company in irc.gimp.net/#gtk+ C.gtk_entry_set_width_chars(togtkentry(e), 0) return e }
//Create and return new entry Structure func NewEntry() *Entry { e := &Entry{} o := C.gtk_entry_new() e.Container = NewContainer(unsafe.Pointer(o)) e.object = C.to_GtkEntry(unsafe.Pointer(o)) return e }
func newArea(ab *areabase) Area { widget := C.gtk_drawing_area_new() // the Area's size will be set later // we need to explicitly subscribe to mouse events with GtkDrawingArea C.gtk_widget_add_events(widget, C.GDK_BUTTON_PRESS_MASK|C.GDK_BUTTON_RELEASE_MASK|C.GDK_POINTER_MOTION_MASK|C.GDK_BUTTON_MOTION_MASK|C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK) // and we need to allow focusing on a GtkDrawingArea to enable keyboard events C.gtk_widget_set_can_focus(widget, C.TRUE) textfieldw := C.gtk_entry_new() a := &area{ areabase: ab, _widget: widget, drawingarea: (*C.GtkDrawingArea)(unsafe.Pointer(widget)), scroller: newScroller(widget, false, false, true), // not natively scrollable; no border; have an overlay for OpenTextFieldAt() clickCounter: new(clickCounter), textfieldw: textfieldw, textfield: (*C.GtkEntry)(unsafe.Pointer(textfieldw)), textfielddone: newEvent(), } for _, c := range areaCallbacks { g_signal_connect( C.gpointer(unsafe.Pointer(a.drawingarea)), c.name, c.callback, C.gpointer(unsafe.Pointer(a))) } a.SetSize(a.width, a.height) C.gtk_overlay_add_overlay(a.scroller.overlay, a.textfieldw) g_signal_connect( C.gpointer(unsafe.Pointer(a.scroller.overlay)), "get-child-position", area_get_child_position_callback, C.gpointer(unsafe.Pointer(a))) // this part is important // entering the context menu is considered focusing out // so we connect to populate-popup to mark that we're entering the context menu (thanks slaf in irc.gimp.net/#gtk+) // and we have to connect_after to focus-out-event so that it runs after the populate-popup g_signal_connect( C.gpointer(unsafe.Pointer(a.textfield)), "populate-popup", area_textfield_populate_popup_callback, C.gpointer(unsafe.Pointer(a))) g_signal_connect_after( C.gpointer(unsafe.Pointer(a.textfield)), "focus-out-event", area_textfield_focus_out_event_callback, C.gpointer(unsafe.Pointer(a))) // the widget shows up initially C.gtk_widget_set_no_show_all(a.textfieldw, C.TRUE) return a }
func startNewTextField() *textfield { widget := C.gtk_entry_new() t := &textfield{ _widget: widget, entry: (*C.GtkEntry)(unsafe.Pointer(widget)), changed: newEvent(), } g_signal_connect( C.gpointer(unsafe.Pointer(t._widget)), "changed", C.GCallback(C.textfieldChanged), C.gpointer(unsafe.Pointer(t))) return t }
func startNewTextField() *textfield { widget := C.gtk_entry_new() t := &textfield{ controlSingleWidget: newControlSingleWidget(widget), editable: (*C.GtkEditable)(unsafe.Pointer(widget)), entry: (*C.GtkEntry)(unsafe.Pointer(widget)), changed: newEvent(), } g_signal_connect( C.gpointer(unsafe.Pointer(t.widget)), "changed", C.GCallback(C.textfieldChanged), C.gpointer(unsafe.Pointer(t))) return t }
func NewEntry() *Entry { e := new(Entry) e.SetPtr(glib.Pointer(C.gtk_entry_new())) return e }