v0.2.2 9100209

gdkcontentprovider.go RawHistoryFolder

1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
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/gio"
12	"github.com/bnema/puregotk/v4/glib"
13	"github.com/bnema/puregotk/v4/gobject"
14	"github.com/bnema/puregotk/v4/gobject/types"
15)
16
17// Class structure for `GdkContentProvider`.
18type ContentProviderClass struct {
19	_ structs.HostLayout
20
21	ParentClass gobject.ObjectClass
22
23	xContentChanged uintptr
24
25	xAttachClipboard uintptr
26
27	xDetachClipboard uintptr
28
29	xRefFormats uintptr
30
31	xRefStorableFormats uintptr
32
33	xWriteMimeTypeAsync uintptr
34
35	xWriteMimeTypeFinish uintptr
36
37	xGetValue uintptr
38
39	Padding [8]uintptr
40}
41
42func (x *ContentProviderClass) GoPointer() uintptr {
43	return uintptr(unsafe.Pointer(x))
44}
45
46// OverrideContentChanged sets the "content_changed" callback function.
47// Signal class closure for `GdkContentProvider::content-changed`
48func (x *ContentProviderClass) OverrideContentChanged(cb func(*ContentProvider)) {
49	if cb == nil {
50		x.xContentChanged = 0
51	} else {
52		x.xContentChanged = purego.NewCallback(func(ProviderVarp uintptr) {
53			cb(ContentProviderNewFromInternalPtr(ProviderVarp))
54		})
55	}
56}
57
58// GetContentChanged gets the "content_changed" callback function.
59// Signal class closure for `GdkContentProvider::content-changed`
60func (x *ContentProviderClass) GetContentChanged() func(*ContentProvider) {
61	if x.xContentChanged == 0 {
62		return nil
63	}
64	var rawCallback func(ProviderVarp uintptr)
65	purego.RegisterFunc(&rawCallback, x.xContentChanged)
66	return func(ProviderVar *ContentProvider) {
67		rawCallback(ProviderVar.GoPointer())
68	}
69}
70
71// OverrideAttachClipboard sets the "attach_clipboard" callback function.
72func (x *ContentProviderClass) OverrideAttachClipboard(cb func(*ContentProvider, *Clipboard)) {
73	if cb == nil {
74		x.xAttachClipboard = 0
75	} else {
76		x.xAttachClipboard = purego.NewCallback(func(ProviderVarp uintptr, ClipboardVarp uintptr) {
77			cb(ContentProviderNewFromInternalPtr(ProviderVarp), ClipboardNewFromInternalPtr(ClipboardVarp))
78		})
79	}
80}
81
82// GetAttachClipboard gets the "attach_clipboard" callback function.
83func (x *ContentProviderClass) GetAttachClipboard() func(*ContentProvider, *Clipboard) {
84	if x.xAttachClipboard == 0 {
85		return nil
86	}
87	var rawCallback func(ProviderVarp uintptr, ClipboardVarp uintptr)
88	purego.RegisterFunc(&rawCallback, x.xAttachClipboard)
89	return func(ProviderVar *ContentProvider, ClipboardVar *Clipboard) {
90		rawCallback(ProviderVar.GoPointer(), ClipboardVar.GoPointer())
91	}
92}
93
94// OverrideDetachClipboard sets the "detach_clipboard" callback function.
95func (x *ContentProviderClass) OverrideDetachClipboard(cb func(*ContentProvider, *Clipboard)) {
96	if cb == nil {
97		x.xDetachClipboard = 0
98	} else {
99		x.xDetachClipboard = purego.NewCallback(func(ProviderVarp uintptr, ClipboardVarp uintptr) {
100			cb(ContentProviderNewFromInternalPtr(ProviderVarp), ClipboardNewFromInternalPtr(ClipboardVarp))
101		})
102	}
103}
104
105// GetDetachClipboard gets the "detach_clipboard" callback function.
106func (x *ContentProviderClass) GetDetachClipboard() func(*ContentProvider, *Clipboard) {
107	if x.xDetachClipboard == 0 {
108		return nil
109	}
110	var rawCallback func(ProviderVarp uintptr, ClipboardVarp uintptr)
111	purego.RegisterFunc(&rawCallback, x.xDetachClipboard)
112	return func(ProviderVar *ContentProvider, ClipboardVar *Clipboard) {
113		rawCallback(ProviderVar.GoPointer(), ClipboardVar.GoPointer())
114	}
115}
116
117// OverrideRefFormats sets the "ref_formats" callback function.
118func (x *ContentProviderClass) OverrideRefFormats(cb func(*ContentProvider) *ContentFormats) {
119	if cb == nil {
120		x.xRefFormats = 0
121	} else {
122		x.xRefFormats = purego.NewCallback(func(ProviderVarp uintptr) *ContentFormats {
123			return cb(ContentProviderNewFromInternalPtr(ProviderVarp))
124		})
125	}
126}
127
128// GetRefFormats gets the "ref_formats" callback function.
129func (x *ContentProviderClass) GetRefFormats() func(*ContentProvider) *ContentFormats {
130	if x.xRefFormats == 0 {
131		return nil
132	}
133	var rawCallback func(ProviderVarp uintptr) *ContentFormats
134	purego.RegisterFunc(&rawCallback, x.xRefFormats)
135	return func(ProviderVar *ContentProvider) *ContentFormats {
136		return rawCallback(ProviderVar.GoPointer())
137	}
138}
139
140// OverrideRefStorableFormats sets the "ref_storable_formats" callback function.
141func (x *ContentProviderClass) OverrideRefStorableFormats(cb func(*ContentProvider) *ContentFormats) {
142	if cb == nil {
143		x.xRefStorableFormats = 0
144	} else {
145		x.xRefStorableFormats = purego.NewCallback(func(ProviderVarp uintptr) *ContentFormats {
146			return cb(ContentProviderNewFromInternalPtr(ProviderVarp))
147		})
148	}
149}
150
151// GetRefStorableFormats gets the "ref_storable_formats" callback function.
152func (x *ContentProviderClass) GetRefStorableFormats() func(*ContentProvider) *ContentFormats {
153	if x.xRefStorableFormats == 0 {
154		return nil
155	}
156	var rawCallback func(ProviderVarp uintptr) *ContentFormats
157	purego.RegisterFunc(&rawCallback, x.xRefStorableFormats)
158	return func(ProviderVar *ContentProvider) *ContentFormats {
159		return rawCallback(ProviderVar.GoPointer())
160	}
161}
162
163// OverrideWriteMimeTypeAsync sets the "write_mime_type_async" callback function.
164func (x *ContentProviderClass) OverrideWriteMimeTypeAsync(cb func(*ContentProvider, string, *gio.OutputStream, int, *gio.Cancellable, *gio.AsyncReadyCallback, uintptr)) {
165	if cb == nil {
166		x.xWriteMimeTypeAsync = 0
167	} else {
168		x.xWriteMimeTypeAsync = purego.NewCallback(func(ProviderVarp uintptr, MimeTypeVarp string, StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
169			cb(ContentProviderNewFromInternalPtr(ProviderVarp), MimeTypeVarp, gio.OutputStreamNewFromInternalPtr(StreamVarp), IoPriorityVarp, gio.CancellableNewFromInternalPtr(CancellableVarp), (*gio.AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
170		})
171	}
172}
173
174// GetWriteMimeTypeAsync gets the "write_mime_type_async" callback function.
175func (x *ContentProviderClass) GetWriteMimeTypeAsync() func(*ContentProvider, string, *gio.OutputStream, int, *gio.Cancellable, *gio.AsyncReadyCallback, uintptr) {
176	if x.xWriteMimeTypeAsync == 0 {
177		return nil
178	}
179	var rawCallback func(ProviderVarp uintptr, MimeTypeVarp string, StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
180	purego.RegisterFunc(&rawCallback, x.xWriteMimeTypeAsync)
181	return func(ProviderVar *ContentProvider, MimeTypeVar string, StreamVar *gio.OutputStream, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
182		rawCallback(ProviderVar.GoPointer(), MimeTypeVar, StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
183	}
184}
185
186// OverrideWriteMimeTypeFinish sets the "write_mime_type_finish" callback function.
187func (x *ContentProviderClass) OverrideWriteMimeTypeFinish(cb func(*ContentProvider, gio.AsyncResult) bool) {
188	if cb == nil {
189		x.xWriteMimeTypeFinish = 0
190	} else {
191		x.xWriteMimeTypeFinish = purego.NewCallback(func(ProviderVarp uintptr, ResultVarp uintptr) bool {
192			return cb(ContentProviderNewFromInternalPtr(ProviderVarp), &gio.AsyncResultBase{Ptr: ResultVarp})
193		})
194	}
195}
196
197// GetWriteMimeTypeFinish gets the "write_mime_type_finish" callback function.
198func (x *ContentProviderClass) GetWriteMimeTypeFinish() func(*ContentProvider, gio.AsyncResult) bool {
199	if x.xWriteMimeTypeFinish == 0 {
200		return nil
201	}
202	var rawCallback func(ProviderVarp uintptr, ResultVarp uintptr) bool
203	purego.RegisterFunc(&rawCallback, x.xWriteMimeTypeFinish)
204	return func(ProviderVar *ContentProvider, ResultVar gio.AsyncResult) bool {
205		return rawCallback(ProviderVar.GoPointer(), ResultVar.GoPointer())
206	}
207}
208
209// OverrideGetValue sets the "get_value" callback function.
210func (x *ContentProviderClass) OverrideGetValue(cb func(*ContentProvider, *gobject.Value) bool) {
211	if cb == nil {
212		x.xGetValue = 0
213	} else {
214		x.xGetValue = purego.NewCallback(func(ProviderVarp uintptr, ValueVarp *gobject.Value) bool {
215			return cb(ContentProviderNewFromInternalPtr(ProviderVarp), ValueVarp)
216		})
217	}
218}
219
220// GetGetValue gets the "get_value" callback function.
221func (x *ContentProviderClass) GetGetValue() func(*ContentProvider, *gobject.Value) bool {
222	if x.xGetValue == 0 {
223		return nil
224	}
225	var rawCallback func(ProviderVarp uintptr, ValueVarp *gobject.Value) bool
226	purego.RegisterFunc(&rawCallback, x.xGetValue)
227	return func(ProviderVar *ContentProvider, ValueVar *gobject.Value) bool {
228		return rawCallback(ProviderVar.GoPointer(), ValueVar)
229	}
230}
231
232// Provides content for the clipboard or for drag-and-drop operations
233// in a number of formats.
234//
235// To create a `GdkContentProvider`, use [ctor@Gdk.ContentProvider.new_for_value]
236// or [ctor@Gdk.ContentProvider.new_for_bytes].
237//
238// GDK knows how to handle common text and image formats out-of-the-box. See
239// [class@Gdk.ContentSerializer] and [class@Gdk.ContentDeserializer] if you want
240// to add support for application-specific data formats.
241type ContentProvider struct {
242	gobject.Object
243}
244
245var xContentProviderGLibType func() types.GType
246
247func ContentProviderGLibType() types.GType {
248	return xContentProviderGLibType()
249}
250
251func ContentProviderNewFromInternalPtr(ptr uintptr) *ContentProvider {
252	cls := &ContentProvider{}
253	cls.Ptr = ptr
254	return cls
255}
256
257var xNewContentProviderForBytes func(string, *glib.Bytes) uintptr
258
259// Create a content provider that provides the given @bytes as data for
260// the given @mime_type.
261func NewContentProviderForBytes(MimeTypeVar string, BytesVar *glib.Bytes) *ContentProvider {
262	var cls *ContentProvider
263
264	cret := xNewContentProviderForBytes(MimeTypeVar, BytesVar)
265
266	if cret == 0 {
267		return nil
268	}
269	cls = &ContentProvider{}
270	cls.Ptr = cret
271	return cls
272}
273
274var xNewContentProviderForValue func(*gobject.Value) uintptr
275
276// Create a content provider that provides the given @value.
277func NewContentProviderForValue(ValueVar *gobject.Value) *ContentProvider {
278	var cls *ContentProvider
279
280	cret := xNewContentProviderForValue(ValueVar)
281
282	if cret == 0 {
283		return nil
284	}
285	cls = &ContentProvider{}
286	cls.Ptr = cret
287	return cls
288}
289
290var xNewContentProviderTyped func(types.GType, ...interface{}) uintptr
291
292// Create a content provider that provides the value of the given
293// @type.
294//
295// The value is provided using G_VALUE_COLLECT(), so the same rules
296// apply as when calling g_object_new() or g_object_set().
297func NewContentProviderTyped(TypeVar types.GType, varArgs ...interface{}) *ContentProvider {
298	var cls *ContentProvider
299
300	cret := xNewContentProviderTyped(TypeVar, varArgs...)
301
302	if cret == 0 {
303		return nil
304	}
305	cls = &ContentProvider{}
306	cls.Ptr = cret
307	return cls
308}
309
310var xNewContentProviderUnion func(uintptr, uint) uintptr
311
312// Creates a content provider that represents all the given @providers.
313//
314// Whenever data needs to be written, the union provider will try the given
315// @providers in the given order and the first one supporting a format will
316// be chosen to provide it.
317//
318// This allows an easy way to support providing data in different formats.
319// For example, an image may be provided by its file and by the image
320// contents with a call such as
321// ```c
322//
323//	gdk_content_provider_new_union ((GdkContentProvider *[2]) {
324//	                                  gdk_content_provider_new_typed (G_TYPE_FILE, file),
325//	                                  gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, texture)
326//	                                }, 2);
327//
328// ```
329func NewContentProviderUnion(ProvidersVar uintptr, NProvidersVar uint) *ContentProvider {
330	var cls *ContentProvider
331
332	cret := xNewContentProviderUnion(ProvidersVar, NProvidersVar)
333
334	if cret == 0 {
335		return nil
336	}
337	cls = &ContentProvider{}
338	cls.Ptr = cret
339	return cls
340}
341
342var xContentProviderContentChanged func(uintptr)
343
344// Emits the ::content-changed signal.
345func (x *ContentProvider) ContentChanged() {
346
347	xContentProviderContentChanged(x.GoPointer())
348
349}
350
351var xContentProviderGetValue func(uintptr, *gobject.Value, **glib.Error) bool
352
353// Gets the contents of @provider stored in @value.
354//
355// The @value will have been initialized to the `GType` the value should be
356// provided in. This given `GType` does not need to be listed in the formats
357// returned by [method@Gdk.ContentProvider.ref_formats]. However, if the
358// given `GType` is not supported, this operation can fail and
359// `G_IO_ERROR_NOT_SUPPORTED` will be reported.
360func (x *ContentProvider) GetValue(ValueVar *gobject.Value) (bool, error) {
361	var cerr *glib.Error
362
363	cret := xContentProviderGetValue(x.GoPointer(), ValueVar, &cerr)
364	if cerr == nil {
365		return cret, nil
366	}
367	return cret, cerr
368
369}
370
371var xContentProviderRefFormats func(uintptr) *ContentFormats
372
373// Gets the formats that the provider can provide its current contents in.
374func (x *ContentProvider) RefFormats() *ContentFormats {
375
376	cret := xContentProviderRefFormats(x.GoPointer())
377	return cret
378}
379
380var xContentProviderRefStorableFormats func(uintptr) *ContentFormats
381
382// Gets the formats that the provider suggests other applications to store
383// the data in.
384//
385// An example of such an application would be a clipboard manager.
386//
387// This can be assumed to be a subset of [method@Gdk.ContentProvider.ref_formats].
388func (x *ContentProvider) RefStorableFormats() *ContentFormats {
389
390	cret := xContentProviderRefStorableFormats(x.GoPointer())
391	return cret
392}
393
394var xContentProviderWriteMimeTypeAsync func(uintptr, string, uintptr, int, uintptr, uintptr, uintptr)
395
396// Asynchronously writes the contents of @provider to @stream in the given
397// @mime_type.
398//
399// The given mime type does not need to be listed in the formats returned by
400// [method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
401// not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
402//
403// The given @stream will not be closed.
404func (x *ContentProvider) WriteMimeTypeAsync(MimeTypeVar string, StreamVar *gio.OutputStream, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
405
406	var CallbackVarRef uintptr
407	if CallbackVar != nil {
408		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
409		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
410			CallbackVarRef = cbRefPtr
411		} else {
412			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
413				cbFn := *CallbackVar
414				cbFn(arg0, arg1, arg2)
415			}
416			CallbackVarRef = purego.NewCallback(fcb)
417			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
418		}
419	}
420
421	xContentProviderWriteMimeTypeAsync(x.GoPointer(), MimeTypeVar, StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
422
423}
424
425var xContentProviderWriteMimeTypeFinish func(uintptr, uintptr, **glib.Error) bool
426
427// Finishes an asynchronous write operation.
428//
429// See [method@Gdk.ContentProvider.write_mime_type_async].
430func (x *ContentProvider) WriteMimeTypeFinish(ResultVar gio.AsyncResult) (bool, error) {
431	var cerr *glib.Error
432
433	cret := xContentProviderWriteMimeTypeFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
434	if cerr == nil {
435		return cret, nil
436	}
437	return cret, cerr
438
439}
440
441func (c *ContentProvider) GoPointer() uintptr {
442	if c == nil {
443		return 0
444	}
445	return c.Ptr
446}
447
448func (c *ContentProvider) SetGoPointer(ptr uintptr) {
449	c.Ptr = ptr
450}
451
452// GetPropertyFormats gets the "formats" property.
453// The possible formats that the provider can provide its data in.
454func (x *ContentProvider) GetPropertyFormats() uintptr {
455	var v gobject.Value
456	x.GetProperty("formats", &v)
457	return v.GetPointer()
458}
459
460// GetPropertyStorableFormats gets the "storable-formats" property.
461// The subset of formats that clipboard managers should store this provider's data in.
462func (x *ContentProvider) GetPropertyStorableFormats() uintptr {
463	var v gobject.Value
464	x.GetProperty("storable-formats", &v)
465	return v.GetPointer()
466}
467
468// Emitted whenever the content provided by this provider has changed.
469func (x *ContentProvider) ConnectContentChanged(cb *func(ContentProvider)) uint {
470	cbPtr := uintptr(unsafe.Pointer(cb))
471	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
472		handlerID := gobject.SignalConnect(x.GoPointer(), "content-changed", cbRefPtr)
473		glib.SaveHandlerMapping(handlerID, cbPtr)
474		return handlerID
475	}
476
477	fcb := func(clsPtr uintptr) {
478		fa := ContentProvider{}
479		fa.Ptr = clsPtr
480		cbFn := *cb
481
482		cbFn(fa)
483
484	}
485	cbRefPtr := purego.NewCallback(fcb)
486	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
487	handlerID := gobject.SignalConnect(x.GoPointer(), "content-changed", cbRefPtr)
488	glib.SaveHandlerMapping(handlerID, cbPtr)
489	return handlerID
490}
491
492func init() {
493	core.SetPackageName("GDK", "gtk4")
494	core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
495	var libs []uintptr
496	for _, libPath := range core.GetPaths("GDK") {
497		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
498		if err != nil {
499			panic(err)
500		}
501		libs = append(libs, lib)
502	}
503
504	core.PuregoSafeRegister(&xContentProviderGLibType, libs, "gdk_content_provider_get_type")
505
506	core.PuregoSafeRegister(&xNewContentProviderForBytes, libs, "gdk_content_provider_new_for_bytes")
507	core.PuregoSafeRegister(&xNewContentProviderForValue, libs, "gdk_content_provider_new_for_value")
508	core.PuregoSafeRegister(&xNewContentProviderTyped, libs, "gdk_content_provider_new_typed")
509	core.PuregoSafeRegister(&xNewContentProviderUnion, libs, "gdk_content_provider_new_union")
510
511	core.PuregoSafeRegister(&xContentProviderContentChanged, libs, "gdk_content_provider_content_changed")
512	core.PuregoSafeRegister(&xContentProviderGetValue, libs, "gdk_content_provider_get_value")
513	core.PuregoSafeRegister(&xContentProviderRefFormats, libs, "gdk_content_provider_ref_formats")
514	core.PuregoSafeRegister(&xContentProviderRefStorableFormats, libs, "gdk_content_provider_ref_storable_formats")
515	core.PuregoSafeRegister(&xContentProviderWriteMimeTypeAsync, libs, "gdk_content_provider_write_mime_type_async")
516	core.PuregoSafeRegister(&xContentProviderWriteMimeTypeFinish, libs, "gdk_content_provider_write_mime_type_finish")
517
518}

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