v0.2.1 c0399be

gtkeditable.go RawHistoryFolder

1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/gobject"
12	"github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type EditableInterface struct {
16	_ structs.HostLayout
17
18	BaseIface uintptr
19
20	xInsertText uintptr
21
22	xDeleteText uintptr
23
24	xChanged uintptr
25
26	xGetText uintptr
27
28	xDoInsertText uintptr
29
30	xDoDeleteText uintptr
31
32	xGetSelectionBounds uintptr
33
34	xSetSelectionBounds uintptr
35
36	xGetDelegate uintptr
37}
38
39func (x *EditableInterface) GoPointer() uintptr {
40	return uintptr(unsafe.Pointer(x))
41}
42
43// OverrideInsertText sets the "insert_text" callback function.
44func (x *EditableInterface) OverrideInsertText(cb func(Editable, string, int, int)) {
45	if cb == nil {
46		x.xInsertText = 0
47	} else {
48		x.xInsertText = purego.NewCallback(func(EditableVarp uintptr, TextVarp string, LengthVarp int, PositionVarp int) {
49			cb(&EditableBase{Ptr: EditableVarp}, TextVarp, LengthVarp, PositionVarp)
50		})
51	}
52}
53
54// GetInsertText gets the "insert_text" callback function.
55func (x *EditableInterface) GetInsertText() func(Editable, string, int, int) {
56	if x.xInsertText == 0 {
57		return nil
58	}
59	var rawCallback func(EditableVarp uintptr, TextVarp string, LengthVarp int, PositionVarp int)
60	purego.RegisterFunc(&rawCallback, x.xInsertText)
61	return func(EditableVar Editable, TextVar string, LengthVar int, PositionVar int) {
62		rawCallback(EditableVar.GoPointer(), TextVar, LengthVar, PositionVar)
63	}
64}
65
66// OverrideDeleteText sets the "delete_text" callback function.
67func (x *EditableInterface) OverrideDeleteText(cb func(Editable, int, int)) {
68	if cb == nil {
69		x.xDeleteText = 0
70	} else {
71		x.xDeleteText = purego.NewCallback(func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int) {
72			cb(&EditableBase{Ptr: EditableVarp}, StartPosVarp, EndPosVarp)
73		})
74	}
75}
76
77// GetDeleteText gets the "delete_text" callback function.
78func (x *EditableInterface) GetDeleteText() func(Editable, int, int) {
79	if x.xDeleteText == 0 {
80		return nil
81	}
82	var rawCallback func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int)
83	purego.RegisterFunc(&rawCallback, x.xDeleteText)
84	return func(EditableVar Editable, StartPosVar int, EndPosVar int) {
85		rawCallback(EditableVar.GoPointer(), StartPosVar, EndPosVar)
86	}
87}
88
89// OverrideChanged sets the "changed" callback function.
90func (x *EditableInterface) OverrideChanged(cb func(Editable)) {
91	if cb == nil {
92		x.xChanged = 0
93	} else {
94		x.xChanged = purego.NewCallback(func(EditableVarp uintptr) {
95			cb(&EditableBase{Ptr: EditableVarp})
96		})
97	}
98}
99
100// GetChanged gets the "changed" callback function.
101func (x *EditableInterface) GetChanged() func(Editable) {
102	if x.xChanged == 0 {
103		return nil
104	}
105	var rawCallback func(EditableVarp uintptr)
106	purego.RegisterFunc(&rawCallback, x.xChanged)
107	return func(EditableVar Editable) {
108		rawCallback(EditableVar.GoPointer())
109	}
110}
111
112// OverrideGetText sets the "get_text" callback function.
113func (x *EditableInterface) OverrideGetText(cb func(Editable) string) {
114	if cb == nil {
115		x.xGetText = 0
116	} else {
117		x.xGetText = purego.NewCallback(func(EditableVarp uintptr) string {
118			return cb(&EditableBase{Ptr: EditableVarp})
119		})
120	}
121}
122
123// GetGetText gets the "get_text" callback function.
124func (x *EditableInterface) GetGetText() func(Editable) string {
125	if x.xGetText == 0 {
126		return nil
127	}
128	var rawCallback func(EditableVarp uintptr) string
129	purego.RegisterFunc(&rawCallback, x.xGetText)
130	return func(EditableVar Editable) string {
131		return rawCallback(EditableVar.GoPointer())
132	}
133}
134
135// OverrideDoInsertText sets the "do_insert_text" callback function.
136func (x *EditableInterface) OverrideDoInsertText(cb func(Editable, string, int, int)) {
137	if cb == nil {
138		x.xDoInsertText = 0
139	} else {
140		x.xDoInsertText = purego.NewCallback(func(EditableVarp uintptr, TextVarp string, LengthVarp int, PositionVarp int) {
141			cb(&EditableBase{Ptr: EditableVarp}, TextVarp, LengthVarp, PositionVarp)
142		})
143	}
144}
145
146// GetDoInsertText gets the "do_insert_text" callback function.
147func (x *EditableInterface) GetDoInsertText() func(Editable, string, int, int) {
148	if x.xDoInsertText == 0 {
149		return nil
150	}
151	var rawCallback func(EditableVarp uintptr, TextVarp string, LengthVarp int, PositionVarp int)
152	purego.RegisterFunc(&rawCallback, x.xDoInsertText)
153	return func(EditableVar Editable, TextVar string, LengthVar int, PositionVar int) {
154		rawCallback(EditableVar.GoPointer(), TextVar, LengthVar, PositionVar)
155	}
156}
157
158// OverrideDoDeleteText sets the "do_delete_text" callback function.
159func (x *EditableInterface) OverrideDoDeleteText(cb func(Editable, int, int)) {
160	if cb == nil {
161		x.xDoDeleteText = 0
162	} else {
163		x.xDoDeleteText = purego.NewCallback(func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int) {
164			cb(&EditableBase{Ptr: EditableVarp}, StartPosVarp, EndPosVarp)
165		})
166	}
167}
168
169// GetDoDeleteText gets the "do_delete_text" callback function.
170func (x *EditableInterface) GetDoDeleteText() func(Editable, int, int) {
171	if x.xDoDeleteText == 0 {
172		return nil
173	}
174	var rawCallback func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int)
175	purego.RegisterFunc(&rawCallback, x.xDoDeleteText)
176	return func(EditableVar Editable, StartPosVar int, EndPosVar int) {
177		rawCallback(EditableVar.GoPointer(), StartPosVar, EndPosVar)
178	}
179}
180
181// OverrideGetSelectionBounds sets the "get_selection_bounds" callback function.
182func (x *EditableInterface) OverrideGetSelectionBounds(cb func(Editable, *int, *int) bool) {
183	if cb == nil {
184		x.xGetSelectionBounds = 0
185	} else {
186		x.xGetSelectionBounds = purego.NewCallback(func(EditableVarp uintptr, StartPosVarp *int, EndPosVarp *int) bool {
187			return cb(&EditableBase{Ptr: EditableVarp}, StartPosVarp, EndPosVarp)
188		})
189	}
190}
191
192// GetGetSelectionBounds gets the "get_selection_bounds" callback function.
193func (x *EditableInterface) GetGetSelectionBounds() func(Editable, *int, *int) bool {
194	if x.xGetSelectionBounds == 0 {
195		return nil
196	}
197	var rawCallback func(EditableVarp uintptr, StartPosVarp *int, EndPosVarp *int) bool
198	purego.RegisterFunc(&rawCallback, x.xGetSelectionBounds)
199	return func(EditableVar Editable, StartPosVar *int, EndPosVar *int) bool {
200		return rawCallback(EditableVar.GoPointer(), StartPosVar, EndPosVar)
201	}
202}
203
204// OverrideSetSelectionBounds sets the "set_selection_bounds" callback function.
205func (x *EditableInterface) OverrideSetSelectionBounds(cb func(Editable, int, int)) {
206	if cb == nil {
207		x.xSetSelectionBounds = 0
208	} else {
209		x.xSetSelectionBounds = purego.NewCallback(func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int) {
210			cb(&EditableBase{Ptr: EditableVarp}, StartPosVarp, EndPosVarp)
211		})
212	}
213}
214
215// GetSetSelectionBounds gets the "set_selection_bounds" callback function.
216func (x *EditableInterface) GetSetSelectionBounds() func(Editable, int, int) {
217	if x.xSetSelectionBounds == 0 {
218		return nil
219	}
220	var rawCallback func(EditableVarp uintptr, StartPosVarp int, EndPosVarp int)
221	purego.RegisterFunc(&rawCallback, x.xSetSelectionBounds)
222	return func(EditableVar Editable, StartPosVar int, EndPosVar int) {
223		rawCallback(EditableVar.GoPointer(), StartPosVar, EndPosVar)
224	}
225}
226
227// OverrideGetDelegate sets the "get_delegate" callback function.
228func (x *EditableInterface) OverrideGetDelegate(cb func(Editable) *EditableBase) {
229	if cb == nil {
230		x.xGetDelegate = 0
231	} else {
232		x.xGetDelegate = purego.NewCallback(func(EditableVarp uintptr) uintptr {
233			ret := cb(&EditableBase{Ptr: EditableVarp})
234			if ret == nil {
235				return 0
236			}
237			return ret.GoPointer()
238		})
239	}
240}
241
242// GetGetDelegate gets the "get_delegate" callback function.
243func (x *EditableInterface) GetGetDelegate() func(Editable) *EditableBase {
244	if x.xGetDelegate == 0 {
245		return nil
246	}
247	var rawCallback func(EditableVarp uintptr) uintptr
248	purego.RegisterFunc(&rawCallback, x.xGetDelegate)
249	return func(EditableVar Editable) *EditableBase {
250		rawRet := rawCallback(EditableVar.GoPointer())
251		if rawRet == 0 {
252			return nil
253		}
254		ret := &EditableBase{}
255		ret.Ptr = rawRet
256		return ret
257	}
258}
259
260// Interface for single-line text editing widgets.
261//
262// Typical examples of editable widgets are [class@Gtk.Entry] and
263// [class@Gtk.SpinButton]. It contains functions for generically manipulating
264// an editable widget, a large number of action signals used for key bindings,
265// and several signals that an application can connect to modify the behavior
266// of a widget.
267//
268// As an example of the latter usage, by connecting the following handler to
269// [signal@Gtk.Editable::insert-text], an application can convert all entry
270// into a widget into uppercase.
271//
272// ## Forcing entry to uppercase.
273//
274// ```c
275// #include <ctype.h>
276//
277// void
278// insert_text_handler (GtkEditable *editable,
279//
280//	const char  *text,
281//	int          length,
282//	int         *position,
283//	gpointer     data)
284//
285//	{
286//	  char *result = g_utf8_strup (text, length);
287//
288//	  g_signal_handlers_block_by_func (editable,
289//	                               (gpointer) insert_text_handler, data);
290//	  gtk_editable_insert_text (editable, result, length, position);
291//	  g_signal_handlers_unblock_by_func (editable,
292//	                                     (gpointer) insert_text_handler, data);
293//
294//	  g_signal_stop_emission_by_name (editable, "insert_text");
295//
296//	  g_free (result);
297//	}
298//
299// ```
300//
301// ## Implementing GtkEditable
302//
303// The most likely scenario for implementing `GtkEditable` on your own widget
304// is that you will embed a `GtkText` inside a complex widget, and want to
305// delegate the editable functionality to that text widget. `GtkEditable`
306// provides some utility functions to make this easy.
307//
308// In your class_init function, call [func@Gtk.Editable.install_properties],
309// passing the first available property ID:
310//
311// ```c
312// static void
313// my_class_init (MyClass *class)
314//
315//	{
316//	  ...
317//	  g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
318//	  gtk_editable_install_properties (object_clas, NUM_PROPERTIES);
319//	  ...
320//	}
321//
322// ```
323//
324// In your interface_init function for the `GtkEditable` interface, provide
325// an implementation for the get_delegate vfunc that returns your text widget:
326//
327// ```c
328// GtkEditable *
329// get_editable_delegate (GtkEditable *editable)
330//
331//	{
332//	  return GTK_EDITABLE (MY_WIDGET (editable)->text_widget);
333//	}
334//
335// static void
336// my_editable_init (GtkEditableInterface *iface)
337//
338//	{
339//	  iface->get_delegate = get_editable_delegate;
340//	}
341//
342// ```
343//
344// You don't need to provide any other vfuncs. The default implementations
345// work by forwarding to the delegate that the GtkEditableInterface.get_delegate()
346// vfunc returns.
347//
348// In your instance_init function, create your text widget, and then call
349// [method@Gtk.Editable.init_delegate]:
350//
351// ```c
352// static void
353// my_widget_init (MyWidget *self)
354//
355//	{
356//	  ...
357//	  self->text_widget = gtk_text_new ();
358//	  gtk_editable_init_delegate (GTK_EDITABLE (self));
359//	  ...
360//	}
361//
362// ```
363//
364// In your dispose function, call [method@Gtk.Editable.finish_delegate] before
365// destroying your text widget:
366//
367// ```c
368// static void
369// my_widget_dispose (GObject *object)
370//
371//	{
372//	  ...
373//	  gtk_editable_finish_delegate (GTK_EDITABLE (self));
374//	  g_clear_pointer (&self->text_widget, gtk_widget_unparent);
375//	  ...
376//	}
377//
378// ```
379//
380// Finally, use [func@Gtk.Editable.delegate_set_property] in your `set_property`
381// function (and similar for `get_property`), to set the editable properties:
382//
383// ```c
384//
385//	...
386//	if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
387//	  return;
388//
389//	switch (prop_id)
390//	...
391//
392// ```
393//
394// It is important to note that if you create a `GtkEditable` that uses
395// a delegate, the low level [signal@Gtk.Editable::insert-text] and
396// [signal@Gtk.Editable::delete-text] signals will be propagated from the
397// "wrapper" editable to the delegate, but they will not be propagated from
398// the delegate to the "wrapper" editable, as they would cause an infinite
399// recursion. If you wish to connect to the [signal@Gtk.Editable::insert-text]
400// and [signal@Gtk.Editable::delete-text] signals, you will need to connect
401// to them on the delegate obtained via [method@Gtk.Editable.get_delegate].
402type Editable interface {
403	GoPointer() uintptr
404	SetGoPointer(uintptr)
405	DelegateGetAccessiblePlatformState(StateVar AccessiblePlatformState) bool
406	DeleteSelection()
407	DeleteText(StartPosVar int, EndPosVar int)
408	FinishDelegate()
409	GetAlignment() float32
410	GetChars(StartPosVar int, EndPosVar int) string
411	GetDelegate() *EditableBase
412	GetEditable() bool
413	GetEnableUndo() bool
414	GetMaxWidthChars() int
415	GetPosition() int
416	GetSelectionBounds(StartPosVar *int, EndPosVar *int) bool
417	GetText() string
418	GetWidthChars() int
419	InitDelegate()
420	InsertText(TextVar string, LengthVar int, PositionVar int)
421	SelectRegion(StartPosVar int, EndPosVar int)
422	SetAlignment(XalignVar float32)
423	SetEditable(IsEditableVar bool)
424	SetEnableUndo(EnableUndoVar bool)
425	SetMaxWidthChars(NCharsVar int)
426	SetPosition(PositionVar int)
427	SetText(TextVar string)
428	SetWidthChars(NCharsVar int)
429}
430
431var xEditableGLibType func() types.GType
432
433func EditableGLibType() types.GType {
434	return xEditableGLibType()
435}
436
437type EditableBase struct {
438	Ptr uintptr
439}
440
441func (x *EditableBase) GoPointer() uintptr {
442	if x == nil {
443		return 0
444	}
445	return x.Ptr
446}
447
448func (x *EditableBase) SetGoPointer(ptr uintptr) {
449	x.Ptr = ptr
450}
451
452// Retrieves the accessible platform state from the editable delegate.
453//
454// This is an helper function to retrieve the accessible state for
455// `GtkEditable` interface implementations using a delegate pattern.
456//
457// You should call this function in your editable widget implementation
458// of the [vfunc@Gtk.Accessible.get_platform_state] virtual function, for
459// instance:
460//
461// ```c
462// static void
463// accessible_interface_init (GtkAccessibleInterface *iface)
464//
465//	{
466//	  iface->get_platform_state = your_editable_get_accessible_platform_state;
467//	}
468//
469// static gboolean
470// your_editable_get_accessible_platform_state (GtkAccessible *accessible,
471//
472//	GtkAccessiblePlatformState state)
473//
474//	{
475//	  return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state);
476//	}
477//
478// ```
479//
480// Note that the widget which is the delegate *must* be a direct child of
481// this widget, otherwise your implementation of [vfunc@Gtk.Accessible.get_platform_state]
482// might not even be called, as the platform change will originate from
483// the parent of the delegate, and, as a result, will not work properly.
484//
485// So, if you can't ensure the direct child condition, you should give the
486// delegate the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role, or you can
487// change your tree to allow this function to work.
488func (x *EditableBase) DelegateGetAccessiblePlatformState(StateVar AccessiblePlatformState) bool {
489
490	cret := XGtkEditableDelegateGetAccessiblePlatformState(x.GoPointer(), StateVar)
491	return cret
492}
493
494// Deletes the currently selected text of the editable.
495//
496// This call doesn’t do anything if there is no selected text.
497func (x *EditableBase) DeleteSelection() {
498
499	XGtkEditableDeleteSelection(x.GoPointer())
500
501}
502
503// Deletes a sequence of characters.
504//
505// The characters that are deleted are those characters at positions
506// from @start_pos up to, but not including @end_pos. If @end_pos is
507// negative, then the characters deleted are those from @start_pos to
508// the end of the text.
509//
510// Note that the positions are specified in characters, not bytes.
511func (x *EditableBase) DeleteText(StartPosVar int, EndPosVar int) {
512
513	XGtkEditableDeleteText(x.GoPointer(), StartPosVar, EndPosVar)
514
515}
516
517// Undoes the setup done by [method@Gtk.Editable.init_delegate].
518//
519// This is a helper function that should be called from dispose,
520// before removing the delegate object.
521func (x *EditableBase) FinishDelegate() {
522
523	XGtkEditableFinishDelegate(x.GoPointer())
524
525}
526
527// Gets the alignment of the editable.
528func (x *EditableBase) GetAlignment() float32 {
529
530	cret := XGtkEditableGetAlignment(x.GoPointer())
531	return cret
532}
533
534// Retrieves a sequence of characters.
535//
536// The characters that are retrieved are those characters at positions
537// from @start_pos up to, but not including @end_pos. If @end_pos is negative,
538// then the characters retrieved are those characters from @start_pos to
539// the end of the text.
540//
541// Note that positions are specified in characters, not bytes.
542func (x *EditableBase) GetChars(StartPosVar int, EndPosVar int) string {
543
544	cret := XGtkEditableGetChars(x.GoPointer(), StartPosVar, EndPosVar)
545	return cret
546}
547
548// Gets the `GtkEditable` that @editable is delegating its
549// implementation to.
550//
551// Typically, the delegate is a [class@Gtk.Text] widget.
552func (x *EditableBase) GetDelegate() *EditableBase {
553	var cls *EditableBase
554
555	cret := XGtkEditableGetDelegate(x.GoPointer())
556
557	if cret == 0 {
558		return nil
559	}
560	gobject.IncreaseRef(cret)
561	cls = &EditableBase{}
562	cls.Ptr = cret
563	return cls
564}
565
566// Retrieves whether @editable is editable.
567func (x *EditableBase) GetEditable() bool {
568
569	cret := XGtkEditableGetEditable(x.GoPointer())
570	return cret
571}
572
573// Gets if undo/redo actions are enabled for @editable
574func (x *EditableBase) GetEnableUndo() bool {
575
576	cret := XGtkEditableGetEnableUndo(x.GoPointer())
577	return cret
578}
579
580// Retrieves the desired maximum width of @editable, in characters.
581func (x *EditableBase) GetMaxWidthChars() int {
582
583	cret := XGtkEditableGetMaxWidthChars(x.GoPointer())
584	return cret
585}
586
587// Retrieves the current position of the cursor relative
588// to the start of the content of the editable.
589//
590// Note that this position is in characters, not in bytes.
591func (x *EditableBase) GetPosition() int {
592
593	cret := XGtkEditableGetPosition(x.GoPointer())
594	return cret
595}
596
597// Retrieves the selection bound of the editable.
598//
599// @start_pos will be filled with the start of the selection and
600// @end_pos with end. If no text was selected both will be identical
601// and %FALSE will be returned.
602//
603// Note that positions are specified in characters, not bytes.
604func (x *EditableBase) GetSelectionBounds(StartPosVar *int, EndPosVar *int) bool {
605
606	cret := XGtkEditableGetSelectionBounds(x.GoPointer(), StartPosVar, EndPosVar)
607	return cret
608}
609
610// Retrieves the contents of @editable.
611//
612// The returned string is owned by GTK and must not be modified or freed.
613func (x *EditableBase) GetText() string {
614
615	cret := XGtkEditableGetText(x.GoPointer())
616	return cret
617}
618
619// Gets the number of characters of space reserved
620// for the contents of the editable.
621func (x *EditableBase) GetWidthChars() int {
622
623	cret := XGtkEditableGetWidthChars(x.GoPointer())
624	return cret
625}
626
627// Sets up a delegate for `GtkEditable`.
628//
629// This is assuming that the get_delegate vfunc in the `GtkEditable`
630// interface has been set up for the @editable's type.
631//
632// This is a helper function that should be called in instance init,
633// after creating the delegate object.
634func (x *EditableBase) InitDelegate() {
635
636	XGtkEditableInitDelegate(x.GoPointer())
637
638}
639
640// Inserts @length bytes of @text into the contents of the
641// widget, at position @position.
642//
643// Note that the position is in characters, not in bytes.
644// The function updates @position to point after the newly
645// inserted text.
646func (x *EditableBase) InsertText(TextVar string, LengthVar int, PositionVar int) {
647
648	XGtkEditableInsertText(x.GoPointer(), TextVar, LengthVar, PositionVar)
649
650}
651
652// Selects a region of text.
653//
654// The characters that are selected are those characters at positions
655// from @start_pos up to, but not including @end_pos. If @end_pos is
656// negative, then the characters selected are those characters from
657// @start_pos to  the end of the text.
658//
659// Note that positions are specified in characters, not bytes.
660func (x *EditableBase) SelectRegion(StartPosVar int, EndPosVar int) {
661
662	XGtkEditableSelectRegion(x.GoPointer(), StartPosVar, EndPosVar)
663
664}
665
666// Sets the alignment for the contents of the editable.
667//
668// This controls the horizontal positioning of the contents when
669// the displayed text is shorter than the width of the editable.
670func (x *EditableBase) SetAlignment(XalignVar float32) {
671
672	XGtkEditableSetAlignment(x.GoPointer(), XalignVar)
673
674}
675
676// Determines if the user can edit the text in the editable widget.
677func (x *EditableBase) SetEditable(IsEditableVar bool) {
678
679	XGtkEditableSetEditable(x.GoPointer(), IsEditableVar)
680
681}
682
683// If enabled, changes to @editable will be saved for undo/redo
684// actions.
685//
686// This results in an additional copy of text changes and are not
687// stored in secure memory. As such, undo is forcefully disabled
688// when [property@Gtk.Text:visibility] is set to %FALSE.
689func (x *EditableBase) SetEnableUndo(EnableUndoVar bool) {
690
691	XGtkEditableSetEnableUndo(x.GoPointer(), EnableUndoVar)
692
693}
694
695// Sets the desired maximum width in characters of @editable.
696func (x *EditableBase) SetMaxWidthChars(NCharsVar int) {
697
698	XGtkEditableSetMaxWidthChars(x.GoPointer(), NCharsVar)
699
700}
701
702// Sets the cursor position in the editable to the given value.
703//
704// The cursor is displayed before the character with the given (base 0)
705// index in the contents of the editable. The value must be less than
706// or equal to the number of characters in the editable. A value of -1
707// indicates that the position should be set after the last character
708// of the editable. Note that @position is in characters, not in bytes.
709func (x *EditableBase) SetPosition(PositionVar int) {
710
711	XGtkEditableSetPosition(x.GoPointer(), PositionVar)
712
713}
714
715// Sets the text in the editable to the given value.
716//
717// This is replacing the current contents.
718func (x *EditableBase) SetText(TextVar string) {
719
720	XGtkEditableSetText(x.GoPointer(), TextVar)
721
722}
723
724// Changes the size request of the editable to be about the
725// right size for @n_chars characters.
726//
727// Note that it changes the size request, the size can still
728// be affected by how you pack the widget into containers.
729// If @n_chars is -1, the size reverts to the default size.
730func (x *EditableBase) SetWidthChars(NCharsVar int) {
731
732	XGtkEditableSetWidthChars(x.GoPointer(), NCharsVar)
733
734}
735
736// GetPropertyCursorPosition gets the "cursor-position" property.
737// The current position of the insertion cursor in chars.
738func (x *EditableBase) GetPropertyCursorPosition() int {
739	obj := gobject.Object{}
740	obj.Ptr = x.GoPointer()
741	var v gobject.Value
742	obj.GetProperty("cursor-position", &v)
743	return v.GetInt()
744}
745
746// SetPropertyEditable sets the "editable" property.
747// Whether the entry contents can be edited.
748func (x *EditableBase) SetPropertyEditable(value bool) {
749	obj := gobject.Object{}
750	obj.Ptr = x.GoPointer()
751	var v gobject.Value
752	v.Init(gobject.TypeBooleanVal)
753	v.SetBoolean(value)
754	obj.SetProperty("editable", &v)
755}
756
757// GetPropertyEditable gets the "editable" property.
758// Whether the entry contents can be edited.
759func (x *EditableBase) GetPropertyEditable() bool {
760	obj := gobject.Object{}
761	obj.Ptr = x.GoPointer()
762	var v gobject.Value
763	obj.GetProperty("editable", &v)
764	return v.GetBoolean()
765}
766
767// SetPropertyEnableUndo sets the "enable-undo" property.
768// If undo/redo should be enabled for the editable.
769func (x *EditableBase) SetPropertyEnableUndo(value bool) {
770	obj := gobject.Object{}
771	obj.Ptr = x.GoPointer()
772	var v gobject.Value
773	v.Init(gobject.TypeBooleanVal)
774	v.SetBoolean(value)
775	obj.SetProperty("enable-undo", &v)
776}
777
778// GetPropertyEnableUndo gets the "enable-undo" property.
779// If undo/redo should be enabled for the editable.
780func (x *EditableBase) GetPropertyEnableUndo() bool {
781	obj := gobject.Object{}
782	obj.Ptr = x.GoPointer()
783	var v gobject.Value
784	obj.GetProperty("enable-undo", &v)
785	return v.GetBoolean()
786}
787
788// SetPropertyMaxWidthChars sets the "max-width-chars" property.
789// The desired maximum width of the entry, in characters.
790func (x *EditableBase) SetPropertyMaxWidthChars(value int) {
791	obj := gobject.Object{}
792	obj.Ptr = x.GoPointer()
793	var v gobject.Value
794	v.Init(gobject.TypeIntVal)
795	v.SetInt(value)
796	obj.SetProperty("max-width-chars", &v)
797}
798
799// GetPropertyMaxWidthChars gets the "max-width-chars" property.
800// The desired maximum width of the entry, in characters.
801func (x *EditableBase) GetPropertyMaxWidthChars() int {
802	obj := gobject.Object{}
803	obj.Ptr = x.GoPointer()
804	var v gobject.Value
805	obj.GetProperty("max-width-chars", &v)
806	return v.GetInt()
807}
808
809// GetPropertySelectionBound gets the "selection-bound" property.
810// The position of the opposite end of the selection from the cursor in chars.
811func (x *EditableBase) GetPropertySelectionBound() int {
812	obj := gobject.Object{}
813	obj.Ptr = x.GoPointer()
814	var v gobject.Value
815	obj.GetProperty("selection-bound", &v)
816	return v.GetInt()
817}
818
819// SetPropertyText sets the "text" property.
820// The contents of the entry.
821func (x *EditableBase) SetPropertyText(value string) {
822	obj := gobject.Object{}
823	obj.Ptr = x.GoPointer()
824	var v gobject.Value
825	v.Init(gobject.TypeStringVal)
826	v.SetString(&value)
827	obj.SetProperty("text", &v)
828}
829
830// GetPropertyText gets the "text" property.
831// The contents of the entry.
832func (x *EditableBase) GetPropertyText() string {
833	obj := gobject.Object{}
834	obj.Ptr = x.GoPointer()
835	var v gobject.Value
836	obj.GetProperty("text", &v)
837	return v.GetString()
838}
839
840// SetPropertyWidthChars sets the "width-chars" property.
841// Number of characters to leave space for in the entry.
842func (x *EditableBase) SetPropertyWidthChars(value int) {
843	obj := gobject.Object{}
844	obj.Ptr = x.GoPointer()
845	var v gobject.Value
846	v.Init(gobject.TypeIntVal)
847	v.SetInt(value)
848	obj.SetProperty("width-chars", &v)
849}
850
851// GetPropertyWidthChars gets the "width-chars" property.
852// Number of characters to leave space for in the entry.
853func (x *EditableBase) GetPropertyWidthChars() int {
854	obj := gobject.Object{}
855	obj.Ptr = x.GoPointer()
856	var v gobject.Value
857	obj.GetProperty("width-chars", &v)
858	return v.GetInt()
859}
860
861// SetPropertyXalign sets the "xalign" property.
862// The horizontal alignment, from 0 (left) to 1 (right).
863//
864// Reversed for RTL layouts.
865func (x *EditableBase) SetPropertyXalign(value float32) {
866	obj := gobject.Object{}
867	obj.Ptr = x.GoPointer()
868	var v gobject.Value
869	v.Init(gobject.TypeFloatVal)
870	v.SetFloat(value)
871	obj.SetProperty("xalign", &v)
872}
873
874// GetPropertyXalign gets the "xalign" property.
875// The horizontal alignment, from 0 (left) to 1 (right).
876//
877// Reversed for RTL layouts.
878func (x *EditableBase) GetPropertyXalign() float32 {
879	obj := gobject.Object{}
880	obj.Ptr = x.GoPointer()
881	var v gobject.Value
882	obj.GetProperty("xalign", &v)
883	return v.GetFloat()
884}
885
886var XGtkEditableDelegateGetAccessiblePlatformState func(uintptr, AccessiblePlatformState) bool
887var XGtkEditableDeleteSelection func(uintptr)
888var XGtkEditableDeleteText func(uintptr, int, int)
889var XGtkEditableFinishDelegate func(uintptr)
890var XGtkEditableGetAlignment func(uintptr) float32
891var XGtkEditableGetChars func(uintptr, int, int) string
892var XGtkEditableGetDelegate func(uintptr) uintptr
893var XGtkEditableGetEditable func(uintptr) bool
894var XGtkEditableGetEnableUndo func(uintptr) bool
895var XGtkEditableGetMaxWidthChars func(uintptr) int
896var XGtkEditableGetPosition func(uintptr) int
897var XGtkEditableGetSelectionBounds func(uintptr, *int, *int) bool
898var XGtkEditableGetText func(uintptr) string
899var XGtkEditableGetWidthChars func(uintptr) int
900var XGtkEditableInitDelegate func(uintptr)
901var XGtkEditableInsertText func(uintptr, string, int, int)
902var XGtkEditableSelectRegion func(uintptr, int, int)
903var XGtkEditableSetAlignment func(uintptr, float32)
904var XGtkEditableSetEditable func(uintptr, bool)
905var XGtkEditableSetEnableUndo func(uintptr, bool)
906var XGtkEditableSetMaxWidthChars func(uintptr, int)
907var XGtkEditableSetPosition func(uintptr, int)
908var XGtkEditableSetText func(uintptr, string)
909var XGtkEditableSetWidthChars func(uintptr, int)
910
911// The identifiers for [iface@Gtk.Editable] properties.
912//
913// See [func@Gtk.Editable.install_properties] for details on how to
914// implement the `GtkEditable` interface.
915type EditableProperties int
916
917var xEditablePropertiesGLibType func() types.GType
918
919func EditablePropertiesGLibType() types.GType {
920	return xEditablePropertiesGLibType()
921}
922
923const (
924
925	// the property id for [property@Gtk.Editable:text]
926	EditablePropTextValue EditableProperties = 0
927	// the property id for [property@Gtk.Editable:cursor-position]
928	EditablePropCursorPositionValue EditableProperties = 1
929	// the property id for [property@Gtk.Editable:selection-bound]
930	EditablePropSelectionBoundValue EditableProperties = 2
931	// the property id for [property@Gtk.Editable:editable]
932	EditablePropEditableValue EditableProperties = 3
933	// the property id for [property@Gtk.Editable:width-chars]
934	EditablePropWidthCharsValue EditableProperties = 4
935	// the property id for [property@Gtk.Editable:max-width-chars]
936	EditablePropMaxWidthCharsValue EditableProperties = 5
937	// the property id for [property@Gtk.Editable:xalign]
938	EditablePropXalignValue EditableProperties = 6
939	// the property id for [property@Gtk.Editable:enable-undo]
940	EditablePropEnableUndoValue EditableProperties = 7
941	// the number of properties
942	EditableNumPropertiesValue EditableProperties = 8
943)
944
945var xEditableDelegateGetProperty func(uintptr, uint, *gobject.Value, uintptr) bool
946
947// Gets a property of the `GtkEditable` delegate for @object.
948//
949// This is helper function that should be called in the `get_property`
950// function of your `GtkEditable` implementation, before handling your
951// own properties.
952func EditableDelegateGetProperty(ObjectVar *gobject.Object, PropIdVar uint, ValueVar *gobject.Value, PspecVar *gobject.ParamSpec) bool {
953
954	cret := xEditableDelegateGetProperty(ObjectVar.GoPointer(), PropIdVar, ValueVar, PspecVar.GoPointer())
955	return cret
956}
957
958var xEditableDelegateSetProperty func(uintptr, uint, *gobject.Value, uintptr) bool
959
960// Sets a property on the `GtkEditable` delegate for @object.
961//
962// This is a helper function that should be called in the `set_property`
963// function of your `GtkEditable` implementation, before handling your
964// own properties.
965func EditableDelegateSetProperty(ObjectVar *gobject.Object, PropIdVar uint, ValueVar *gobject.Value, PspecVar *gobject.ParamSpec) bool {
966
967	cret := xEditableDelegateSetProperty(ObjectVar.GoPointer(), PropIdVar, ValueVar, PspecVar.GoPointer())
968	return cret
969}
970
971var xEditableInstallProperties func(*gobject.ObjectClass, uint) uint
972
973// Overrides the `GtkEditable` properties for @class.
974//
975// This is a helper function that should be called in class_init,
976// after installing your own properties.
977//
978// Note that your class must have "text", "cursor-position",
979// "selection-bound", "editable", "width-chars", "max-width-chars",
980// "xalign" and "enable-undo" properties for this function to work.
981//
982// To handle the properties in your set_property and get_property
983// functions, you can either use [func@Gtk.Editable.delegate_set_property]
984// and [func@Gtk.Editable.delegate_get_property] (if you are using
985// a delegate), or remember the @first_prop offset and add it to the
986// values in the [enum@Gtk.EditableProperties] enumeration to get the
987// property IDs for these properties.
988func EditableInstallProperties(ObjectClassVar *gobject.ObjectClass, FirstPropVar uint) uint {
989
990	cret := xEditableInstallProperties(ObjectClassVar, FirstPropVar)
991	return cret
992}
993
994func init() {
995	core.SetPackageName("GTK", "gtk4")
996	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
997	var libs []uintptr
998	for _, libPath := range core.GetPaths("GTK") {
999		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1000		if err != nil {
1001			panic(err)
1002		}
1003		libs = append(libs, lib)
1004	}
1005
1006	core.PuregoSafeRegister(&xEditablePropertiesGLibType, libs, "gtk_editable_properties_get_type")
1007
1008	core.PuregoSafeRegister(&xEditableDelegateGetProperty, libs, "gtk_editable_delegate_get_property")
1009	core.PuregoSafeRegister(&xEditableDelegateSetProperty, libs, "gtk_editable_delegate_set_property")
1010	core.PuregoSafeRegister(&xEditableInstallProperties, libs, "gtk_editable_install_properties")
1011
1012	core.PuregoSafeRegister(&xEditableGLibType, libs, "gtk_editable_get_type")
1013
1014	core.PuregoSafeRegister(&XGtkEditableDelegateGetAccessiblePlatformState, libs, "gtk_editable_delegate_get_accessible_platform_state")
1015	core.PuregoSafeRegister(&XGtkEditableDeleteSelection, libs, "gtk_editable_delete_selection")
1016	core.PuregoSafeRegister(&XGtkEditableDeleteText, libs, "gtk_editable_delete_text")
1017	core.PuregoSafeRegister(&XGtkEditableFinishDelegate, libs, "gtk_editable_finish_delegate")
1018	core.PuregoSafeRegister(&XGtkEditableGetAlignment, libs, "gtk_editable_get_alignment")
1019	core.PuregoSafeRegister(&XGtkEditableGetChars, libs, "gtk_editable_get_chars")
1020	core.PuregoSafeRegister(&XGtkEditableGetDelegate, libs, "gtk_editable_get_delegate")
1021	core.PuregoSafeRegister(&XGtkEditableGetEditable, libs, "gtk_editable_get_editable")
1022	core.PuregoSafeRegister(&XGtkEditableGetEnableUndo, libs, "gtk_editable_get_enable_undo")
1023	core.PuregoSafeRegister(&XGtkEditableGetMaxWidthChars, libs, "gtk_editable_get_max_width_chars")
1024	core.PuregoSafeRegister(&XGtkEditableGetPosition, libs, "gtk_editable_get_position")
1025	core.PuregoSafeRegister(&XGtkEditableGetSelectionBounds, libs, "gtk_editable_get_selection_bounds")
1026	core.PuregoSafeRegister(&XGtkEditableGetText, libs, "gtk_editable_get_text")
1027	core.PuregoSafeRegister(&XGtkEditableGetWidthChars, libs, "gtk_editable_get_width_chars")
1028	core.PuregoSafeRegister(&XGtkEditableInitDelegate, libs, "gtk_editable_init_delegate")
1029	core.PuregoSafeRegister(&XGtkEditableInsertText, libs, "gtk_editable_insert_text")
1030	core.PuregoSafeRegister(&XGtkEditableSelectRegion, libs, "gtk_editable_select_region")
1031	core.PuregoSafeRegister(&XGtkEditableSetAlignment, libs, "gtk_editable_set_alignment")
1032	core.PuregoSafeRegister(&XGtkEditableSetEditable, libs, "gtk_editable_set_editable")
1033	core.PuregoSafeRegister(&XGtkEditableSetEnableUndo, libs, "gtk_editable_set_enable_undo")
1034	core.PuregoSafeRegister(&XGtkEditableSetMaxWidthChars, libs, "gtk_editable_set_max_width_chars")
1035	core.PuregoSafeRegister(&XGtkEditableSetPosition, libs, "gtk_editable_set_position")
1036	core.PuregoSafeRegister(&XGtkEditableSetText, libs, "gtk_editable_set_text")
1037	core.PuregoSafeRegister(&XGtkEditableSetWidthChars, libs, "gtk_editable_set_width_chars")
1038
1039}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close