v0.2.1 c0399be

gtkbuilder.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/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type BuilderClass struct {
17	_ structs.HostLayout
18}
19
20func (x *BuilderClass) GoPointer() uintptr {
21	return uintptr(unsafe.Pointer(x))
22}
23
24// Error codes that identify various errors that can occur while using
25// `GtkBuilder`.
26type BuilderError int
27
28var xBuilderErrorGLibType func() types.GType
29
30func BuilderErrorGLibType() types.GType {
31	return xBuilderErrorGLibType()
32}
33
34const (
35
36	// A type-func attribute didn’t name
37	//  a function that returns a `GType`.
38	BuilderErrorInvalidTypeFunctionValue BuilderError = 0
39	// The input contained a tag that `GtkBuilder`
40	//  can’t handle.
41	BuilderErrorUnhandledTagValue BuilderError = 1
42	// An attribute that is required by
43	//  `GtkBuilder` was missing.
44	BuilderErrorMissingAttributeValue BuilderError = 2
45	// `GtkBuilder` found an attribute that
46	//  it doesn’t understand.
47	BuilderErrorInvalidAttributeValue BuilderError = 3
48	// `GtkBuilder` found a tag that
49	//  it doesn’t understand.
50	BuilderErrorInvalidTagValue BuilderError = 4
51	// A required property value was
52	//  missing.
53	BuilderErrorMissingPropertyValueValue BuilderError = 5
54	// `GtkBuilder` couldn’t parse
55	//  some attribute value.
56	BuilderErrorInvalidValueValue BuilderError = 6
57	// The input file requires a newer version
58	//  of GTK.
59	BuilderErrorVersionMismatchValue BuilderError = 7
60	// An object id occurred twice.
61	BuilderErrorDuplicateIdValue BuilderError = 8
62	// A specified object type is of the same type or
63	//  derived from the type of the composite class being extended with builder XML.
64	BuilderErrorObjectTypeRefusedValue BuilderError = 9
65	// The wrong type was specified in a composite class’s template XML
66	BuilderErrorTemplateMismatchValue BuilderError = 10
67	// The specified property is unknown for the object class.
68	BuilderErrorInvalidPropertyValue BuilderError = 11
69	// The specified signal is unknown for the object class.
70	BuilderErrorInvalidSignalValue BuilderError = 12
71	// An object id is unknown.
72	BuilderErrorInvalidIdValue BuilderError = 13
73	// A function could not be found. This often happens
74	//   when symbols are set to be kept private. Compiling code with -rdynamic or using the
75	//   `gmodule-export-2.0` pkgconfig module can fix this problem.
76	BuilderErrorInvalidFunctionValue BuilderError = 14
77)
78
79var xBuilderErrorQuark func() glib.Quark
80
81// Registers an error quark for [class@Gtk.Builder] errors.
82func BuilderErrorQuark() glib.Quark {
83
84	cret := xBuilderErrorQuark()
85	return cret
86}
87
88// Reads XML descriptions of a user interface and instantiates the described objects.
89//
90// To create a `GtkBuilder` from a user interface description, call
91// [ctor@Gtk.Builder.new_from_file], [ctor@Gtk.Builder.new_from_resource]
92// or [ctor@Gtk.Builder.new_from_string].
93//
94// In the (unusual) case that you want to add user interface
95// descriptions from multiple sources to the same `GtkBuilder` you can
96// call [ctor@Gtk.Builder.new] to get an empty builder and populate it by
97// (multiple) calls to [method@Gtk.Builder.add_from_file],
98// [method@Gtk.Builder.add_from_resource] or
99// [method@Gtk.Builder.add_from_string].
100//
101// A `GtkBuilder` holds a reference to all objects that it has constructed
102// and drops these references when it is finalized. This finalization can
103// cause the destruction of non-widget objects or widgets which are not
104// contained in a toplevel window. For toplevel windows constructed by a
105// builder, it is the responsibility of the user to call
106// [method@Gtk.Window.destroy] to get rid of them and all the widgets
107// they contain.
108//
109// The functions [method@Gtk.Builder.get_object] and
110// [method@Gtk.Builder.get_objects] can be used to access the widgets in
111// the interface by the names assigned to them inside the UI description.
112// Toplevel windows returned by these functions will stay around until the
113// user explicitly destroys them with [method@Gtk.Window.destroy]. Other
114// widgets will either be part of a larger hierarchy constructed by the
115// builder (in which case you should not have to worry about their lifecycle),
116// or without a parent, in which case they have to be added to some container
117// to make use of them. Non-widget objects need to be reffed with
118// g_object_ref() to keep them beyond the lifespan of the builder.
119//
120// ## GtkBuilder UI Definitions
121//
122// `GtkBuilder` parses textual descriptions of user interfaces which are
123// specified in XML format. We refer to these descriptions as “GtkBuilder
124// UI definitions” or just “UI definitions” if the context is clear.
125//
126// ### Structure of UI definitions
127//
128// UI definition files are always encoded in UTF-8.
129//
130// The toplevel element is `<interface>`. It optionally takes a “domain”
131// attribute, which will make the builder look for translated strings
132// using `dgettext()` in the domain specified. This can also be done by
133// calling [method@Gtk.Builder.set_translation_domain] on the builder.
134// For example:
135//
136// ```xml
137// <?xml version="1.0" encoding="UTF-8"?>
138// <interface domain="your-app">
139//
140//	...
141//
142// </interface>
143// ```
144//
145// ### Requirements
146//
147// The target toolkit version(s) are described by `<requires>` elements,
148// the “lib” attribute specifies the widget library in question (currently
149// the only supported value is “gtk”) and the “version” attribute specifies
150// the target version in the form “`<major>`.`<minor>`”. `GtkBuilder` will
151// error out if the version requirements are not met. For example:
152//
153// ```xml
154// <?xml version="1.0" encoding="UTF-8"?>
155// <interface domain="your-app">
156//
157//	<requires lib="gtk" version="4.0" />
158//
159// </interface>
160// ```
161//
162// ### Objects
163//
164// Objects are defined as children of the `<interface>` element.
165//
166// Objects are described by `<object>` elements, which can contain
167// `<property>` elements to set properties, `<signal>` elements which
168// connect signals to handlers, and `<child>` elements, which describe
169// child objects.
170//
171// Typically, the specific kind of object represented by an `<object>`
172// element is specified by the “class” attribute. If the type has not
173// been loaded yet, GTK tries to find the `get_type()` function from the
174// class name by applying heuristics. This works in most cases, but if
175// necessary, it is possible to specify the name of the `get_type()`
176// function explicitly with the "type-func" attribute. If your UI definition
177// is referencing internal types, you should make sure to call
178// `g_type_ensure()` for each object type before parsing the UI definition.
179//
180// Objects may be given a name with the “id” attribute, which allows the
181// application to retrieve them from the builder with
182// [method@Gtk.Builder.get_object]. An id is also necessary to use the
183// object as property value in other parts of the UI definition. GTK
184// reserves ids starting and ending with `___` (three consecutive
185// underscores) for its own purposes.
186//
187// ### Properties
188//
189// Setting properties of objects is pretty straightforward with the
190// `<property>` element: the “name” attribute specifies the name of the
191// property, and the content of the element specifies the value:
192//
193// ```xml
194// <object class="GtkButton">
195//
196//	<property name="label">Hello, world</property>
197//
198// </object>
199// ```
200//
201// If the “translatable” attribute is set to a true value, GTK uses
202// `gettext()` (or `dgettext()` if the builder has a translation domain set)
203// to find a translation for the value. This happens before the value
204// is parsed, so it can be used for properties of any type, but it is
205// probably most useful for string properties. It is also possible to
206// specify a context to disambiguate short strings, and comments which
207// may help the translators:
208//
209// ```xml
210// <object class="GtkButton">
211//
212//	<property name="label"
213//	          translatable="yes"
214//	          context="button"
215//	          comments="A classic">Hello, world</property>
216//
217// </object>
218// ```
219//
220// The xgettext tool that is part of gettext can extract these strings,
221// but note that it only looks for translatable="yes".
222//
223// `GtkBuilder` can parse textual representations for the most common
224// property types:
225//
226//   - characters
227//   - strings
228//   - integers
229//   - floating-point numbers
230//   - booleans (strings like “TRUE”, “t”, “yes”, “y”, “1” are interpreted
231//     as true values, strings like “FALSE”, “f”, “no”, “n”, “0” are interpreted
232//     as false values)
233//   - string lists (separated by newlines)
234//   - enumeration types (can be specified by their full C identifier their short
235//     name used when registering the enumeration type, or their integer value)
236//   - flag types (can be specified by their C identifier or short name,
237//     optionally combined with “|” for bitwise OR, or a single integer value
238//     e.g., “GTK_INPUT_HINT_EMOJI|GTK_INPUT_HINT_LOWERCASE”, or “emoji|lowercase” or 520).
239//   - colors (in the format understood by [method@Gdk.RGBA.parse])
240//   - transforms (in the format understood by [func@Gsk.Transform.parse])
241//   - Pango attribute lists (in the format understood by [method@Pango.AttrList.to_string])
242//   - Pango tab arrays (in the format understood by [method@Pango.TabArray.to_string])
243//   - Pango font descriptions (in the format understood by [func@Pango.FontDescription.from_string])
244//   - `GVariant` (in the format understood by [func@GLib.Variant.parse])
245//   - textures (can be specified as an object id, a resource path or a filename of an image file to load relative to the Builder file or the CWD if [method@Gtk.Builder.add_from_string] was used)
246//   - GFile (like textures, can be specified as an object id, a URI or a filename of a file to load relative to the Builder file or the CWD if [method@Gtk.Builder.add_from_string] was used)
247//
248// Objects can be referred to by their name and by default refer to
249// objects declared in the local XML fragment and objects exposed via
250// [method@Gtk.Builder.expose_object]. In general, `GtkBuilder` allows
251// forward references to objects declared in the local XML; an object
252// doesn’t have to be constructed before it can be referred to. The
253// exception to this rule is that an object has to be constructed before
254// it can be used as the value of a construct-only property.
255//
256// ### Child objects
257//
258// Many widgets have properties for child widgets, such as
259// [property@Gtk.Expander:child]. In this case, the preferred way to
260// specify the child widget in a ui file is to simply set the property:
261//
262// ```xml
263// <object class="GtkExpander">
264//
265//	<property name="child">
266//	  <object class="GtkLabel">
267//	  ...
268//	  </object>
269//	</property>
270//
271// </object>
272// ```
273//
274// Generic containers that can contain an arbitrary number of children,
275// such as [class@Gtk.Box] instead use the `<child>` element. A `<child>`
276// element contains an `<object>` element which describes the child object.
277// Most often, child objects are widgets inside a container, but they can
278// also be, e.g., actions in an action group, or columns in a tree model.
279//
280// Any object type that implements the [iface@Gtk.Buildable] interface can
281// specify how children may be added to it. Since many objects and widgets that
282// are included with GTK already implement the `GtkBuildable` interface,
283// typically child objects can be added using the `<child>` element without
284// having to be concerned about the underlying implementation.
285//
286// See the [`GtkWidget` documentation](class.Widget.html#gtkwidget-as-gtkbuildable)
287// for many examples of using `GtkBuilder` with widgets, including setting
288// child objects using the `<child>` element.
289//
290// A noteworthy special case to the general rule that only objects implementing
291// `GtkBuildable` may specify how to handle the `<child>` element is that
292// `GtkBuilder` provides special support for adding objects to a
293// [class@Gio.ListStore] by using the `<child>` element. For instance:
294//
295// ```xml
296// <object class="GListStore">
297//
298//	<property name="item-type">MyObject</property>
299//	<child>
300//	  <object class="MyObject" />
301//	</child>
302//	...
303//
304// </object>
305// ```
306//
307// ### Property bindings
308//
309// It is also possible to bind a property value to another object's
310// property value using the attributes "bind-source" to specify the
311// source object of the binding, and optionally, "bind-property" and
312// "bind-flags" to specify the source property and source binding flags
313// respectively. Internally, `GtkBuilder` implements this using
314// [class@GObject.Binding] objects.
315//
316// For instance, in the example below the “label” property of the
317// `bottom_label` widget is bound to the “label” property of the
318// `top_button` widget:
319//
320// ```xml
321// <object class="GtkBox">
322//
323//	<property name="orientation">vertical</property>
324//	<child>
325//	  <object class="GtkButton" id="top_button">
326//	    <property name="label">Hello, world</property>
327//	  </object>
328//	</child>
329//	<child>
330//	  <object class="GtkLabel" id="bottom_label">
331//	    <property name="label"
332//	              bind-source="top_button"
333//	              bind-property="label"
334//	              bind-flags="sync-create" />
335//	  </object>
336//	</child>
337//
338// </object>
339// ```
340//
341// For more information, see the documentation of the
342// [method@GObject.Object.bind_property] method.
343//
344// Please note that another way to set up bindings between objects in .ui files
345// is to use the `GtkExpression` methodology. See the
346// [`GtkExpression` documentation](class.Expression.html#gtkexpression-in-ui-files)
347// for more information.
348//
349// ### Internal children
350//
351// Sometimes it is necessary to refer to widgets which have implicitly
352// been constructed by GTK as part of a composite widget, to set
353// properties on them or to add further children (e.g. the content area
354// of a `GtkDialog`). This can be achieved by setting the “internal-child”
355// property of the `<child>` element to a true value. Note that `GtkBuilder`
356// still requires an `<object>` element for the internal child, even if it
357// has already been constructed.
358//
359// ### Specialized children
360//
361// A number of widgets have different places where a child can be added
362// (e.g. tabs vs. page content in notebooks). This can be reflected in
363// a UI definition by specifying the “type” attribute on a `<child>`
364// The possible values for the “type” attribute are described in the
365// sections describing the widget-specific portions of UI definitions.
366//
367// ### Signal handlers and function pointers
368//
369// Signal handlers are set up with the `<signal>` element. The “name”
370// attribute specifies the name of the signal, and the “handler” attribute
371// specifies the function to connect to the signal.
372//
373// ```xml
374// <object class="GtkButton" id="hello_button">
375//
376//	<signal name="clicked" handler="hello_button__clicked" />
377//
378// </object>
379// ```
380//
381// The remaining attributes, “after”, “swapped” and “object”, have the
382// same meaning as the corresponding parameters of the
383// [func@GObject.signal_connect_object] or [func@GObject.signal_connect_data]
384// functions:
385//
386//   - “after” matches the `G_CONNECT_AFTER` flag, and will ensure that the
387//     handler is called after the default class closure for the signal
388//   - “swapped” matches the `G_CONNECT_SWAPPED` flag, and will swap the
389//     instance and closure arguments when invoking the signal handler
390//   - “object” will bind the signal handler to the lifetime of the object
391//     referenced by the attribute
392//
393// By default "swapped" will be set to "yes" if not specified otherwise, in
394// the case where "object" is set, for convenience. A “last_modification_time”
395// attribute is also allowed, but it does not have a meaning to the builder.
396//
397// When compiling applications for Windows, you must declare signal callbacks
398// with the `G_MODULE_EXPORT` decorator, or they will not be put in the symbol
399// table:
400//
401// ```c
402// G_MODULE_EXPORT void
403// hello_button__clicked (GtkButton *button,
404//
405//	gpointer data)
406//
407//	{
408//	  // ...
409//	}
410//
411// ```
412//
413// On Linux and Unix, this is not necessary; applications should instead
414// be compiled with the `-Wl,--export-dynamic` argument inside their compiler
415// flags, and linked against `gmodule-export-2.0`.
416//
417// ## Example UI Definition
418//
419// ```xml
420// <interface>
421//
422//	<object class="GtkDialog" id="dialog1">
423//	  <child internal-child="content_area">
424//	    <object class="GtkBox">
425//	      <child internal-child="action_area">
426//	        <object class="GtkBox">
427//	          <child>
428//	            <object class="GtkButton" id="ok_button">
429//	              <property name="label" translatable="yes">_Ok</property>
430//	              <property name="use-underline">True</property>
431//	              <signal name="clicked" handler="ok_button_clicked"/>
432//	            </object>
433//	          </child>
434//	        </object>
435//	      </child>
436//	    </object>
437//	  </child>
438//	</object>
439//
440// </interface>
441// ```
442//
443// ## Using GtkBuildable for extending UI definitions
444//
445// Objects can implement the [iface@Gtk.Buildable] interface to add custom
446// elements and attributes to the XML. Typically, any extension will be
447// documented in each type that implements the interface.
448//
449// ## Menus
450//
451// In addition to objects with properties that are created with `<object>` and
452// `<property>` elements, `GtkBuilder` also allows to parse XML menu definitions
453// as used by [class@Gio.Menu] when exporting menu models over D-Bus, and as
454// described in the [class@Gtk.PopoverMenu] documentation. Menus can be defined
455// as toplevel elements, or as property values for properties of type `GMenuModel`.
456//
457// ## Templates
458//
459// When describing a [class@Gtk.Widget], you can use the `<template>` tag to
460// describe a UI bound to a specific widget type. GTK will automatically load
461// the UI definition when instantiating the type, and bind children and
462// signal handlers to instance fields and function symbols.
463//
464// For more information, see the [`GtkWidget` documentation](class.Widget.html#building-composite-widgets-from-template-xml)
465// for details.
466type Builder struct {
467	gobject.Object
468}
469
470var xBuilderGLibType func() types.GType
471
472func BuilderGLibType() types.GType {
473	return xBuilderGLibType()
474}
475
476func BuilderNewFromInternalPtr(ptr uintptr) *Builder {
477	cls := &Builder{}
478	cls.Ptr = ptr
479	return cls
480}
481
482var xNewBuilder func() uintptr
483
484// Creates a new empty builder object.
485//
486// This function is only useful if you intend to make multiple calls
487// to [method@Gtk.Builder.add_from_file], [method@Gtk.Builder.add_from_resource]
488// or [method@Gtk.Builder.add_from_string] in order to merge multiple UI
489// descriptions into a single builder.
490func NewBuilder() *Builder {
491	var cls *Builder
492
493	cret := xNewBuilder()
494
495	if cret == 0 {
496		return nil
497	}
498	cls = &Builder{}
499	cls.Ptr = cret
500	return cls
501}
502
503var xNewBuilderFromFile func(string) uintptr
504
505// Parses the UI definition in the file @filename.
506//
507// If there is an error opening the file or parsing the description then
508// the program will be aborted. You should only ever attempt to parse
509// user interface descriptions that are shipped as part of your program.
510func NewBuilderFromFile(FilenameVar string) *Builder {
511	var cls *Builder
512
513	cret := xNewBuilderFromFile(FilenameVar)
514
515	if cret == 0 {
516		return nil
517	}
518	cls = &Builder{}
519	cls.Ptr = cret
520	return cls
521}
522
523var xNewBuilderFromResource func(string) uintptr
524
525// Parses the UI definition at @resource_path.
526//
527// If there is an error locating the resource or parsing the
528// description, then the program will be aborted.
529func NewBuilderFromResource(ResourcePathVar string) *Builder {
530	var cls *Builder
531
532	cret := xNewBuilderFromResource(ResourcePathVar)
533
534	if cret == 0 {
535		return nil
536	}
537	cls = &Builder{}
538	cls.Ptr = cret
539	return cls
540}
541
542var xNewBuilderFromString func(string, int) uintptr
543
544// Parses the UI definition in @string.
545//
546// If @string is %NULL-terminated, then @length should be -1.
547// If @length is not -1, then it is the length of @string.
548//
549// If there is an error parsing @string then the program will be
550// aborted. You should not attempt to parse user interface description
551// from untrusted sources.
552func NewBuilderFromString(StringVar string, LengthVar int) *Builder {
553	var cls *Builder
554
555	cret := xNewBuilderFromString(StringVar, LengthVar)
556
557	if cret == 0 {
558		return nil
559	}
560	cls = &Builder{}
561	cls.Ptr = cret
562	return cls
563}
564
565var xBuilderAddFromFile func(uintptr, string, **glib.Error) bool
566
567// Parses a file containing a UI definition and merges it with
568// the current contents of @builder.
569//
570// This function is useful if you need to call
571// [method@Gtk.Builder.set_current_object]) to add user data to
572// callbacks before loading GtkBuilder UI. Otherwise, you probably
573// want [ctor@Gtk.Builder.new_from_file] instead.
574//
575// If an error occurs, 0 will be returned and @error will be assigned a
576// `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_FILE_ERROR`
577// domains.
578//
579// It’s not really reasonable to attempt to handle failures of this
580// call. You should not use this function with untrusted files (ie:
581// files that are not part of your application). Broken `GtkBuilder`
582// files can easily crash your program, and it’s possible that memory
583// was leaked leading up to the reported failure. The only reasonable
584// thing to do when an error is detected is to call `g_error()`.
585func (x *Builder) AddFromFile(FilenameVar string) (bool, error) {
586	var cerr *glib.Error
587
588	cret := xBuilderAddFromFile(x.GoPointer(), FilenameVar, &cerr)
589	if cerr == nil {
590		return cret, nil
591	}
592	return cret, cerr
593
594}
595
596var xBuilderAddFromResource func(uintptr, string, **glib.Error) bool
597
598// Parses a resource file containing a UI definition
599// and merges it with the current contents of @builder.
600//
601// This function is useful if you need to call
602// [method@Gtk.Builder.set_current_object] to add user data to
603// callbacks before loading GtkBuilder UI. Otherwise, you probably
604// want [ctor@Gtk.Builder.new_from_resource] instead.
605//
606// If an error occurs, 0 will be returned and @error will be assigned a
607// `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
608// domain.
609//
610// It’s not really reasonable to attempt to handle failures of this
611// call.  The only reasonable thing to do when an error is detected is
612// to call g_error().
613func (x *Builder) AddFromResource(ResourcePathVar string) (bool, error) {
614	var cerr *glib.Error
615
616	cret := xBuilderAddFromResource(x.GoPointer(), ResourcePathVar, &cerr)
617	if cerr == nil {
618		return cret, nil
619	}
620	return cret, cerr
621
622}
623
624var xBuilderAddFromString func(uintptr, string, int, **glib.Error) bool
625
626// Parses a string containing a UI definition and merges it
627// with the current contents of @builder.
628//
629// This function is useful if you need to call
630// [method@Gtk.Builder.set_current_object] to add user data to
631// callbacks before loading `GtkBuilder` UI. Otherwise, you probably
632// want [ctor@Gtk.Builder.new_from_string] instead.
633//
634// Upon errors %FALSE will be returned and @error will be assigned a
635// `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or
636// %G_VARIANT_PARSE_ERROR domain.
637//
638// It’s not really reasonable to attempt to handle failures of this
639// call.  The only reasonable thing to do when an error is detected is
640// to call g_error().
641func (x *Builder) AddFromString(BufferVar string, LengthVar int) (bool, error) {
642	var cerr *glib.Error
643
644	cret := xBuilderAddFromString(x.GoPointer(), BufferVar, LengthVar, &cerr)
645	if cerr == nil {
646		return cret, nil
647	}
648	return cret, cerr
649
650}
651
652var xBuilderAddObjectsFromFile func(uintptr, string, []string, **glib.Error) bool
653
654// Parses a file containing a UI definition building only the
655// requested objects and merges them with the current contents
656// of @builder.
657//
658// Upon errors, 0 will be returned and @error will be assigned a
659// `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_FILE_ERROR
660// domain.
661//
662// If you are adding an object that depends on an object that is not
663// its child (for instance a `GtkTreeView` that depends on its
664// `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
665func (x *Builder) AddObjectsFromFile(FilenameVar string, ObjectIdsVar []string) (bool, error) {
666	var cerr *glib.Error
667
668	cret := xBuilderAddObjectsFromFile(x.GoPointer(), FilenameVar, ObjectIdsVar, &cerr)
669	if cerr == nil {
670		return cret, nil
671	}
672	return cret, cerr
673
674}
675
676var xBuilderAddObjectsFromResource func(uintptr, string, []string, **glib.Error) bool
677
678// Parses a resource file containing a UI definition, building
679// only the requested objects and merges them with the current
680// contents of @builder.
681//
682// Upon errors, 0 will be returned and @error will be assigned a
683// `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
684// domain.
685//
686// If you are adding an object that depends on an object that is not
687// its child (for instance a `GtkTreeView` that depends on its
688// `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
689func (x *Builder) AddObjectsFromResource(ResourcePathVar string, ObjectIdsVar []string) (bool, error) {
690	var cerr *glib.Error
691
692	cret := xBuilderAddObjectsFromResource(x.GoPointer(), ResourcePathVar, ObjectIdsVar, &cerr)
693	if cerr == nil {
694		return cret, nil
695	}
696	return cret, cerr
697
698}
699
700var xBuilderAddObjectsFromString func(uintptr, string, int, []string, **glib.Error) bool
701
702// Parses a string containing a UI definition, building only the
703// requested objects and merges them with the current contents of
704// @builder.
705//
706// Upon errors %FALSE will be returned and @error will be assigned a
707// `GError` from the %GTK_BUILDER_ERROR or %G_MARKUP_ERROR domain.
708//
709// If you are adding an object that depends on an object that is not
710// its child (for instance a `GtkTreeView` that depends on its
711// `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
712func (x *Builder) AddObjectsFromString(BufferVar string, LengthVar int, ObjectIdsVar []string) (bool, error) {
713	var cerr *glib.Error
714
715	cret := xBuilderAddObjectsFromString(x.GoPointer(), BufferVar, LengthVar, ObjectIdsVar, &cerr)
716	if cerr == nil {
717		return cret, nil
718	}
719	return cret, cerr
720
721}
722
723var xBuilderCreateClosure func(uintptr, string, BuilderClosureFlags, uintptr, **glib.Error) *gobject.Closure
724
725// Creates a closure to invoke the function called @function_name.
726//
727// This is using the create_closure() implementation of @builder's
728// [iface@Gtk.BuilderScope].
729//
730// If no closure could be created, %NULL will be returned and @error
731// will be set.
732func (x *Builder) CreateClosure(FunctionNameVar string, FlagsVar BuilderClosureFlags, ObjectVar *gobject.Object) (*gobject.Closure, error) {
733	var cerr *glib.Error
734
735	cret := xBuilderCreateClosure(x.GoPointer(), FunctionNameVar, FlagsVar, ObjectVar.GoPointer(), &cerr)
736	if cerr == nil {
737		return cret, nil
738	}
739	return cret, cerr
740
741}
742
743var xBuilderExposeObject func(uintptr, string, uintptr)
744
745// Add @object to the @builder object pool so it can be
746// referenced just like any other object built by builder.
747//
748// Only a single object may be added using @name. However,
749// it is not an error to expose the same object under multiple
750// names. `gtk_builder_get_object()` may be used to determine
751// if an object has already been added with @name.
752func (x *Builder) ExposeObject(NameVar string, ObjectVar *gobject.Object) {
753
754	xBuilderExposeObject(x.GoPointer(), NameVar, ObjectVar.GoPointer())
755
756}
757
758var xBuilderExtendWithTemplate func(uintptr, uintptr, types.GType, string, int, **glib.Error) bool
759
760// Main private entry point for building composite components
761// from template XML.
762//
763// Most likely you do not need to call this function in applications as
764// templates are handled by `GtkWidget`.
765func (x *Builder) ExtendWithTemplate(ObjectVar *gobject.Object, TemplateTypeVar types.GType, BufferVar string, LengthVar int) (bool, error) {
766	var cerr *glib.Error
767
768	cret := xBuilderExtendWithTemplate(x.GoPointer(), ObjectVar.GoPointer(), TemplateTypeVar, BufferVar, LengthVar, &cerr)
769	if cerr == nil {
770		return cret, nil
771	}
772	return cret, cerr
773
774}
775
776var xBuilderGetCurrentObject func(uintptr) uintptr
777
778// Gets the current object set via gtk_builder_set_current_object().
779func (x *Builder) GetCurrentObject() *gobject.Object {
780	var cls *gobject.Object
781
782	cret := xBuilderGetCurrentObject(x.GoPointer())
783
784	if cret == 0 {
785		return nil
786	}
787	gobject.IncreaseRef(cret)
788	cls = &gobject.Object{}
789	cls.Ptr = cret
790	return cls
791}
792
793var xBuilderGetObject func(uintptr, string) uintptr
794
795// Gets the object named @name.
796//
797// Note that this function does not increment the reference count
798// of the returned object.
799func (x *Builder) GetObject(NameVar string) *gobject.Object {
800	var cls *gobject.Object
801
802	cret := xBuilderGetObject(x.GoPointer(), NameVar)
803
804	if cret == 0 {
805		return nil
806	}
807	gobject.IncreaseRef(cret)
808	cls = &gobject.Object{}
809	cls.Ptr = cret
810	return cls
811}
812
813var xBuilderGetObjects func(uintptr) *glib.SList
814
815// Gets all objects that have been constructed by @builder.
816//
817// Note that this function does not increment the reference
818// counts of the returned objects.
819func (x *Builder) GetObjects() *glib.SList {
820
821	cret := xBuilderGetObjects(x.GoPointer())
822	return cret
823}
824
825var xBuilderGetScope func(uintptr) uintptr
826
827// Gets the scope in use that was set via gtk_builder_set_scope().
828func (x *Builder) GetScope() *BuilderScopeBase {
829	var cls *BuilderScopeBase
830
831	cret := xBuilderGetScope(x.GoPointer())
832
833	if cret == 0 {
834		return nil
835	}
836	gobject.IncreaseRef(cret)
837	cls = &BuilderScopeBase{}
838	cls.Ptr = cret
839	return cls
840}
841
842var xBuilderGetTranslationDomain func(uintptr) string
843
844// Gets the translation domain of @builder.
845func (x *Builder) GetTranslationDomain() string {
846
847	cret := xBuilderGetTranslationDomain(x.GoPointer())
848	return cret
849}
850
851var xBuilderGetTypeFromName func(uintptr, string) types.GType
852
853// Looks up a type by name.
854//
855// This is using the virtual function that `GtkBuilder` has
856// for that purpose. This is mainly used when implementing
857// the `GtkBuildable` interface on a type.
858func (x *Builder) GetTypeFromName(TypeNameVar string) types.GType {
859
860	cret := xBuilderGetTypeFromName(x.GoPointer(), TypeNameVar)
861	return cret
862}
863
864var xBuilderSetCurrentObject func(uintptr, uintptr)
865
866// Sets the current object for the @builder.
867//
868// The current object can be thought of as the `this` object that the
869// builder is working for and will often be used as the default object
870// when an object is optional.
871//
872// [method@Gtk.Widget.init_template] for example will set the current
873// object to the widget the template is inited for. For functions like
874// [ctor@Gtk.Builder.new_from_resource], the current object will be %NULL.
875func (x *Builder) SetCurrentObject(CurrentObjectVar *gobject.Object) {
876
877	xBuilderSetCurrentObject(x.GoPointer(), CurrentObjectVar.GoPointer())
878
879}
880
881var xBuilderSetScope func(uintptr, uintptr)
882
883// Sets the scope the builder should operate in.
884//
885// If @scope is %NULL, a new [class@Gtk.BuilderCScope] will be created.
886func (x *Builder) SetScope(ScopeVar BuilderScope) {
887
888	xBuilderSetScope(x.GoPointer(), ScopeVar.GoPointer())
889
890}
891
892var xBuilderSetTranslationDomain func(uintptr, uintptr)
893
894// Sets the translation domain of @builder.
895func (x *Builder) SetTranslationDomain(DomainVar *string) {
896
897	DomainVarPtr := core.GStrdupNullable(DomainVar)
898	defer core.GFreeNullable(DomainVarPtr)
899
900	xBuilderSetTranslationDomain(x.GoPointer(), DomainVarPtr)
901
902}
903
904var xBuilderValueFromString func(uintptr, uintptr, string, *gobject.Value, **glib.Error) bool
905
906// Demarshals a value from a string.
907//
908// This function calls g_value_init() on the @value argument,
909// so it need not be initialised beforehand.
910//
911// Can handle char, uchar, boolean, int, uint, long,
912// ulong, enum, flags, float, double, string, `GdkRGBA` and
913// `GtkAdjustment` type values.
914//
915// Upon errors %FALSE will be returned and @error will be
916// assigned a `GError` from the %GTK_BUILDER_ERROR domain.
917func (x *Builder) ValueFromString(PspecVar *gobject.ParamSpec, StringVar string, ValueVar *gobject.Value) (bool, error) {
918	var cerr *glib.Error
919
920	cret := xBuilderValueFromString(x.GoPointer(), PspecVar.GoPointer(), StringVar, ValueVar, &cerr)
921	if cerr == nil {
922		return cret, nil
923	}
924	return cret, cerr
925
926}
927
928var xBuilderValueFromStringType func(uintptr, types.GType, string, *gobject.Value, **glib.Error) bool
929
930// Demarshals a value from a string.
931//
932// Unlike [method@Gtk.Builder.value_from_string], this function
933// takes a `GType` instead of `GParamSpec`.
934//
935// Calls g_value_init() on the @value argument, so it
936// need not be initialised beforehand.
937//
938// Upon errors %FALSE will be returned and @error will be
939// assigned a `GError` from the %GTK_BUILDER_ERROR domain.
940func (x *Builder) ValueFromStringType(TypeVar types.GType, StringVar string, ValueVar *gobject.Value) (bool, error) {
941	var cerr *glib.Error
942
943	cret := xBuilderValueFromStringType(x.GoPointer(), TypeVar, StringVar, ValueVar, &cerr)
944	if cerr == nil {
945		return cret, nil
946	}
947	return cret, cerr
948
949}
950
951func (c *Builder) GoPointer() uintptr {
952	if c == nil {
953		return 0
954	}
955	return c.Ptr
956}
957
958func (c *Builder) SetGoPointer(ptr uintptr) {
959	c.Ptr = ptr
960}
961
962// SetPropertyTranslationDomain sets the "translation-domain" property.
963// The translation domain used when translating property values that
964// have been marked as translatable.
965//
966// If the translation domain is %NULL, `GtkBuilder` uses gettext(),
967// otherwise g_dgettext().
968func (x *Builder) SetPropertyTranslationDomain(value string) {
969	var v gobject.Value
970	v.Init(gobject.TypeStringVal)
971	v.SetString(&value)
972	x.SetProperty("translation-domain", &v)
973}
974
975// GetPropertyTranslationDomain gets the "translation-domain" property.
976// The translation domain used when translating property values that
977// have been marked as translatable.
978//
979// If the translation domain is %NULL, `GtkBuilder` uses gettext(),
980// otherwise g_dgettext().
981func (x *Builder) GetPropertyTranslationDomain() string {
982	var v gobject.Value
983	x.GetProperty("translation-domain", &v)
984	return v.GetString()
985}
986
987func init() {
988	core.SetPackageName("GTK", "gtk4")
989	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
990	var libs []uintptr
991	for _, libPath := range core.GetPaths("GTK") {
992		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
993		if err != nil {
994			panic(err)
995		}
996		libs = append(libs, lib)
997	}
998
999	core.PuregoSafeRegister(&xBuilderErrorGLibType, libs, "gtk_builder_error_get_type")
1000
1001	core.PuregoSafeRegister(&xBuilderErrorQuark, libs, "gtk_builder_error_quark")
1002
1003	core.PuregoSafeRegister(&xBuilderGLibType, libs, "gtk_builder_get_type")
1004
1005	core.PuregoSafeRegister(&xNewBuilder, libs, "gtk_builder_new")
1006	core.PuregoSafeRegister(&xNewBuilderFromFile, libs, "gtk_builder_new_from_file")
1007	core.PuregoSafeRegister(&xNewBuilderFromResource, libs, "gtk_builder_new_from_resource")
1008	core.PuregoSafeRegister(&xNewBuilderFromString, libs, "gtk_builder_new_from_string")
1009
1010	core.PuregoSafeRegister(&xBuilderAddFromFile, libs, "gtk_builder_add_from_file")
1011	core.PuregoSafeRegister(&xBuilderAddFromResource, libs, "gtk_builder_add_from_resource")
1012	core.PuregoSafeRegister(&xBuilderAddFromString, libs, "gtk_builder_add_from_string")
1013	core.PuregoSafeRegister(&xBuilderAddObjectsFromFile, libs, "gtk_builder_add_objects_from_file")
1014	core.PuregoSafeRegister(&xBuilderAddObjectsFromResource, libs, "gtk_builder_add_objects_from_resource")
1015	core.PuregoSafeRegister(&xBuilderAddObjectsFromString, libs, "gtk_builder_add_objects_from_string")
1016	core.PuregoSafeRegister(&xBuilderCreateClosure, libs, "gtk_builder_create_closure")
1017	core.PuregoSafeRegister(&xBuilderExposeObject, libs, "gtk_builder_expose_object")
1018	core.PuregoSafeRegister(&xBuilderExtendWithTemplate, libs, "gtk_builder_extend_with_template")
1019	core.PuregoSafeRegister(&xBuilderGetCurrentObject, libs, "gtk_builder_get_current_object")
1020	core.PuregoSafeRegister(&xBuilderGetObject, libs, "gtk_builder_get_object")
1021	core.PuregoSafeRegister(&xBuilderGetObjects, libs, "gtk_builder_get_objects")
1022	core.PuregoSafeRegister(&xBuilderGetScope, libs, "gtk_builder_get_scope")
1023	core.PuregoSafeRegister(&xBuilderGetTranslationDomain, libs, "gtk_builder_get_translation_domain")
1024	core.PuregoSafeRegister(&xBuilderGetTypeFromName, libs, "gtk_builder_get_type_from_name")
1025	core.PuregoSafeRegister(&xBuilderSetCurrentObject, libs, "gtk_builder_set_current_object")
1026	core.PuregoSafeRegister(&xBuilderSetScope, libs, "gtk_builder_set_scope")
1027	core.PuregoSafeRegister(&xBuilderSetTranslationDomain, libs, "gtk_builder_set_translation_domain")
1028	core.PuregoSafeRegister(&xBuilderValueFromString, libs, "gtk_builder_value_from_string")
1029	core.PuregoSafeRegister(&xBuilderValueFromStringType, libs, "gtk_builder_value_from_string_type")
1030
1031}

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