v0.2.1 c0399be

gtkbuilderscope.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 BuilderCScopeClass struct {
17	_ structs.HostLayout
18
19	ParentClass gobject.ObjectClass
20}
21
22func (x *BuilderCScopeClass) GoPointer() uintptr {
23	return uintptr(unsafe.Pointer(x))
24}
25
26// The virtual function table to implement for `GtkBuilderScope` implementations.
27// Default implementations for each function do exist, but they usually just fail,
28// so it is suggested that implementations implement all of them.
29type BuilderScopeInterface struct {
30	_ structs.HostLayout
31
32	GIface uintptr
33
34	xGetTypeFromName uintptr
35
36	xGetTypeFromFunction uintptr
37
38	xCreateClosure uintptr
39}
40
41func (x *BuilderScopeInterface) GoPointer() uintptr {
42	return uintptr(unsafe.Pointer(x))
43}
44
45// OverrideGetTypeFromName sets the "get_type_from_name" callback function.
46// Try to lookup a `GType` via the its name. See
47//
48//	gtk_builder_get_type_from_name() for more details.
49//	The C implementation will use g_type_from_name() and if that fails try to guess the
50//	correct function name for registering the type and then use dlsym() to load it.
51//	The default implementation just tries g_type_from_name() and otherwise fails.
52func (x *BuilderScopeInterface) OverrideGetTypeFromName(cb func(BuilderScope, *Builder, string) types.GType) {
53	if cb == nil {
54		x.xGetTypeFromName = 0
55	} else {
56		x.xGetTypeFromName = purego.NewCallback(func(SelfVarp uintptr, BuilderVarp uintptr, TypeNameVarp string) types.GType {
57			return cb(&BuilderScopeBase{Ptr: SelfVarp}, BuilderNewFromInternalPtr(BuilderVarp), TypeNameVarp)
58		})
59	}
60}
61
62// GetGetTypeFromName gets the "get_type_from_name" callback function.
63// Try to lookup a `GType` via the its name. See
64//
65//	gtk_builder_get_type_from_name() for more details.
66//	The C implementation will use g_type_from_name() and if that fails try to guess the
67//	correct function name for registering the type and then use dlsym() to load it.
68//	The default implementation just tries g_type_from_name() and otherwise fails.
69func (x *BuilderScopeInterface) GetGetTypeFromName() func(BuilderScope, *Builder, string) types.GType {
70	if x.xGetTypeFromName == 0 {
71		return nil
72	}
73	var rawCallback func(SelfVarp uintptr, BuilderVarp uintptr, TypeNameVarp string) types.GType
74	purego.RegisterFunc(&rawCallback, x.xGetTypeFromName)
75	return func(SelfVar BuilderScope, BuilderVar *Builder, TypeNameVar string) types.GType {
76		return rawCallback(SelfVar.GoPointer(), BuilderVar.GoPointer(), TypeNameVar)
77	}
78}
79
80// OverrideGetTypeFromFunction sets the "get_type_from_function" callback function.
81// Try to lookup a `GType` via the given function name, specified
82//
83//	explicitly in a GtkBuilder file, like via the "type-func" attribute in the `<object>` tag.
84//	This function is very rarely used.
85//	The C implementation will use dlsym() and call the resulting function as a `GTypeFunc`.
86//	The default implementation will fail and just return %G_TYPE_INVALID.
87func (x *BuilderScopeInterface) OverrideGetTypeFromFunction(cb func(BuilderScope, *Builder, string) types.GType) {
88	if cb == nil {
89		x.xGetTypeFromFunction = 0
90	} else {
91		x.xGetTypeFromFunction = purego.NewCallback(func(SelfVarp uintptr, BuilderVarp uintptr, FunctionNameVarp string) types.GType {
92			return cb(&BuilderScopeBase{Ptr: SelfVarp}, BuilderNewFromInternalPtr(BuilderVarp), FunctionNameVarp)
93		})
94	}
95}
96
97// GetGetTypeFromFunction gets the "get_type_from_function" callback function.
98// Try to lookup a `GType` via the given function name, specified
99//
100//	explicitly in a GtkBuilder file, like via the "type-func" attribute in the `<object>` tag.
101//	This function is very rarely used.
102//	The C implementation will use dlsym() and call the resulting function as a `GTypeFunc`.
103//	The default implementation will fail and just return %G_TYPE_INVALID.
104func (x *BuilderScopeInterface) GetGetTypeFromFunction() func(BuilderScope, *Builder, string) types.GType {
105	if x.xGetTypeFromFunction == 0 {
106		return nil
107	}
108	var rawCallback func(SelfVarp uintptr, BuilderVarp uintptr, FunctionNameVarp string) types.GType
109	purego.RegisterFunc(&rawCallback, x.xGetTypeFromFunction)
110	return func(SelfVar BuilderScope, BuilderVar *Builder, FunctionNameVar string) types.GType {
111		return rawCallback(SelfVar.GoPointer(), BuilderVar.GoPointer(), FunctionNameVar)
112	}
113}
114
115// OverrideCreateClosure sets the "create_closure" callback function.
116// Create a closure with the given arguments. See gtk_builder_create_closure()
117//
118//	for more details on those.
119//	The C implementation will try to use dlsym() to locate the function name and then
120//	g_cclosure_new() to create a closure for the symbol.
121//	The default implementation just fails and returns %NULL.
122func (x *BuilderScopeInterface) OverrideCreateClosure(cb func(BuilderScope, *Builder, string, BuilderClosureFlags, *gobject.Object) *gobject.Closure) {
123	if cb == nil {
124		x.xCreateClosure = 0
125	} else {
126		x.xCreateClosure = purego.NewCallback(func(SelfVarp uintptr, BuilderVarp uintptr, FunctionNameVarp string, FlagsVarp BuilderClosureFlags, ObjectVarp uintptr) *gobject.Closure {
127			return cb(&BuilderScopeBase{Ptr: SelfVarp}, BuilderNewFromInternalPtr(BuilderVarp), FunctionNameVarp, FlagsVarp, gobject.ObjectNewFromInternalPtr(ObjectVarp))
128		})
129	}
130}
131
132// GetCreateClosure gets the "create_closure" callback function.
133// Create a closure with the given arguments. See gtk_builder_create_closure()
134//
135//	for more details on those.
136//	The C implementation will try to use dlsym() to locate the function name and then
137//	g_cclosure_new() to create a closure for the symbol.
138//	The default implementation just fails and returns %NULL.
139func (x *BuilderScopeInterface) GetCreateClosure() func(BuilderScope, *Builder, string, BuilderClosureFlags, *gobject.Object) *gobject.Closure {
140	if x.xCreateClosure == 0 {
141		return nil
142	}
143	var rawCallback func(SelfVarp uintptr, BuilderVarp uintptr, FunctionNameVarp string, FlagsVarp BuilderClosureFlags, ObjectVarp uintptr) *gobject.Closure
144	purego.RegisterFunc(&rawCallback, x.xCreateClosure)
145	return func(SelfVar BuilderScope, BuilderVar *Builder, FunctionNameVar string, FlagsVar BuilderClosureFlags, ObjectVar *gobject.Object) *gobject.Closure {
146		return rawCallback(SelfVar.GoPointer(), BuilderVar.GoPointer(), FunctionNameVar, FlagsVar, ObjectVar.GoPointer())
147	}
148}
149
150// Provides language binding support to `GtkBuilder`.
151//
152// The goal of `GtkBuilderScope` is to look up programming-language-specific
153// values for strings that are given in a `GtkBuilder` UI file.
154//
155// The primary intended audience is bindings that want to provide deeper
156// integration of `GtkBuilder` into the language.
157//
158// A `GtkBuilderScope` instance may be used with multiple `GtkBuilder` objects,
159// even at once.
160//
161// By default, GTK will use its own implementation of `GtkBuilderScope`
162// for the C language which can be created via [ctor@Gtk.BuilderCScope.new].
163//
164// If you implement `GtkBuilderScope` for a language binding, you
165// may want to (partially) derive from or fall back to a [class@Gtk.BuilderCScope],
166// as that class implements support for automatic lookups from C symbols.
167type BuilderScope interface {
168	GoPointer() uintptr
169	SetGoPointer(uintptr)
170}
171
172var xBuilderScopeGLibType func() types.GType
173
174func BuilderScopeGLibType() types.GType {
175	return xBuilderScopeGLibType()
176}
177
178type BuilderScopeBase struct {
179	Ptr uintptr
180}
181
182func (x *BuilderScopeBase) GoPointer() uintptr {
183	if x == nil {
184		return 0
185	}
186	return x.Ptr
187}
188
189func (x *BuilderScopeBase) SetGoPointer(ptr uintptr) {
190	x.Ptr = ptr
191}
192
193// The list of flags that can be passed to gtk_builder_create_closure().
194//
195// New values may be added in the future for new features, so external
196// implementations of [iface@Gtk.BuilderScope] should test the flags
197// for unknown values and raise a %GTK_BUILDER_ERROR_INVALID_ATTRIBUTE error
198// when they encounter one.
199type BuilderClosureFlags int
200
201var xBuilderClosureFlagsGLibType func() types.GType
202
203func BuilderClosureFlagsGLibType() types.GType {
204	return xBuilderClosureFlagsGLibType()
205}
206
207const (
208
209	// The closure should be created swapped. See
210	//   g_cclosure_new_swap() for details.
211	BuilderClosureSwappedValue BuilderClosureFlags = 1
212)
213
214// A `GtkBuilderScope` implementation for the C language.
215//
216// `GtkBuilderCScope` instances use symbols explicitly added to @builder
217// with prior calls to [method@Gtk.BuilderCScope.add_callback_symbol].
218// If developers want to do that, they are encouraged to create their
219// own scopes for that purpose.
220//
221// In the case that symbols are not explicitly added; GTK will uses
222// `GModule`’s introspective features (by opening the module %NULL) to
223// look at the application’s symbol table. From here it tries to match
224// the signal function names given in the interface description with
225// symbols in the application.
226//
227// Note that unless [method@Gtk.BuilderCScope.add_callback_symbol] is
228// called for all signal callbacks which are referenced by the loaded XML,
229// this functionality will require that `GModule` be supported on the platform.
230type BuilderCScope struct {
231	gobject.Object
232}
233
234var xBuilderCScopeGLibType func() types.GType
235
236func BuilderCScopeGLibType() types.GType {
237	return xBuilderCScopeGLibType()
238}
239
240func BuilderCScopeNewFromInternalPtr(ptr uintptr) *BuilderCScope {
241	cls := &BuilderCScope{}
242	cls.Ptr = ptr
243	return cls
244}
245
246var xNewBuilderCScope func() uintptr
247
248// Creates a new `GtkBuilderCScope` object to use with future
249// `GtkBuilder` instances.
250//
251// Calling this function is only necessary if you want to add
252// custom callbacks via [method@Gtk.BuilderCScope.add_callback_symbol].
253func NewBuilderCScope() *BuilderCScope {
254	var cls *BuilderCScope
255
256	cret := xNewBuilderCScope()
257
258	if cret == 0 {
259		return nil
260	}
261	cls = &BuilderCScope{}
262	cls.Ptr = cret
263	return cls
264}
265
266var xBuilderCScopeAddCallbackSymbol func(uintptr, string, uintptr)
267
268// Adds the @callback_symbol to the scope of @builder under the
269// given @callback_name.
270//
271// Using this function overrides the behavior of
272// [method@Gtk.Builder.create_closure] for any callback symbols that
273// are added. Using this method allows for better encapsulation as it
274// does not require that callback symbols be declared in the global
275// namespace.
276func (x *BuilderCScope) AddCallbackSymbol(CallbackNameVar string, CallbackSymbolVar *gobject.Callback) {
277
278	var CallbackSymbolVarRef uintptr
279	if CallbackSymbolVar != nil {
280		CallbackSymbolVarPtr := uintptr(unsafe.Pointer(CallbackSymbolVar))
281		if cbRefPtr, ok := glib.GetCallback(CallbackSymbolVarPtr); ok {
282			CallbackSymbolVarRef = cbRefPtr
283		} else {
284			fcb := func() {
285				cbFn := *CallbackSymbolVar
286				cbFn()
287			}
288			CallbackSymbolVarRef = purego.NewCallback(fcb)
289			glib.SaveCallbackWithClosure(CallbackSymbolVarPtr, CallbackSymbolVarRef, CallbackSymbolVar)
290		}
291	}
292
293	xBuilderCScopeAddCallbackSymbol(x.GoPointer(), CallbackNameVar, CallbackSymbolVarRef)
294
295}
296
297var xBuilderCScopeAddCallbackSymbols func(uintptr, string, uintptr, ...interface{})
298
299// A convenience function to add many callbacks.
300//
301// This is equivalent to calling [method@Gtk.BuilderCScope.add_callback_symbol]
302// for each symbol.
303func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCallbackSymbolVar *gobject.Callback, varArgs ...interface{}) {
304
305	var FirstCallbackSymbolVarRef uintptr
306	if FirstCallbackSymbolVar != nil {
307		FirstCallbackSymbolVarPtr := uintptr(unsafe.Pointer(FirstCallbackSymbolVar))
308		if cbRefPtr, ok := glib.GetCallback(FirstCallbackSymbolVarPtr); ok {
309			FirstCallbackSymbolVarRef = cbRefPtr
310		} else {
311			fcb := func() {
312				cbFn := *FirstCallbackSymbolVar
313				cbFn()
314			}
315			FirstCallbackSymbolVarRef = purego.NewCallback(fcb)
316			glib.SaveCallbackWithClosure(FirstCallbackSymbolVarPtr, FirstCallbackSymbolVarRef, FirstCallbackSymbolVar)
317		}
318	}
319
320	xBuilderCScopeAddCallbackSymbols(x.GoPointer(), FirstCallbackNameVar, FirstCallbackSymbolVarRef, varArgs...)
321
322}
323
324var xBuilderCScopeLookupCallbackSymbol func(uintptr, string) uintptr
325
326// Fetches a symbol previously added with
327// gtk_builder_cscope_add_callback_symbol().
328func (x *BuilderCScope) LookupCallbackSymbol(CallbackNameVar string) uintptr {
329
330	cret := xBuilderCScopeLookupCallbackSymbol(x.GoPointer(), CallbackNameVar)
331	return cret
332}
333
334func (c *BuilderCScope) GoPointer() uintptr {
335	if c == nil {
336		return 0
337	}
338	return c.Ptr
339}
340
341func (c *BuilderCScope) SetGoPointer(ptr uintptr) {
342	c.Ptr = ptr
343}
344
345func init() {
346	core.SetPackageName("GTK", "gtk4")
347	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
348	var libs []uintptr
349	for _, libPath := range core.GetPaths("GTK") {
350		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
351		if err != nil {
352			panic(err)
353		}
354		libs = append(libs, lib)
355	}
356
357	core.PuregoSafeRegister(&xBuilderClosureFlagsGLibType, libs, "gtk_builder_closure_flags_get_type")
358
359	core.PuregoSafeRegister(&xBuilderCScopeGLibType, libs, "gtk_builder_cscope_get_type")
360
361	core.PuregoSafeRegister(&xNewBuilderCScope, libs, "gtk_builder_cscope_new")
362
363	core.PuregoSafeRegister(&xBuilderCScopeAddCallbackSymbol, libs, "gtk_builder_cscope_add_callback_symbol")
364	core.PuregoSafeRegister(&xBuilderCScopeAddCallbackSymbols, libs, "gtk_builder_cscope_add_callback_symbols")
365	core.PuregoSafeRegister(&xBuilderCScopeLookupCallbackSymbol, libs, "gtk_builder_cscope_lookup_callback_symbol")
366
367	core.PuregoSafeRegister(&xBuilderScopeGLibType, libs, "gtk_builder_scope_get_type")
368
369}

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