v0.2.1 c0399be

gicon.go RawHistoryFolder

1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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/types"
13)
14
15// GIconIface is used to implement GIcon types for various
16// different systems. See #GThemedIcon and #GLoadableIcon for
17// examples of how to implement this interface.
18type IconIface struct {
19	_ structs.HostLayout
20
21	GIface uintptr
22
23	xHash uintptr
24
25	xEqual uintptr
26
27	xToTokens uintptr
28
29	xFromTokens uintptr
30
31	xSerialize uintptr
32}
33
34func (x *IconIface) GoPointer() uintptr {
35	return uintptr(unsafe.Pointer(x))
36}
37
38// OverrideHash sets the "hash" callback function.
39// A hash for a given #GIcon.
40func (x *IconIface) OverrideHash(cb func(Icon) uint) {
41	if cb == nil {
42		x.xHash = 0
43	} else {
44		x.xHash = purego.NewCallback(func(IconVarp uintptr) uint {
45			return cb(&IconBase{Ptr: IconVarp})
46		})
47	}
48}
49
50// GetHash gets the "hash" callback function.
51// A hash for a given #GIcon.
52func (x *IconIface) GetHash() func(Icon) uint {
53	if x.xHash == 0 {
54		return nil
55	}
56	var rawCallback func(IconVarp uintptr) uint
57	purego.RegisterFunc(&rawCallback, x.xHash)
58	return func(IconVar Icon) uint {
59		return rawCallback(IconVar.GoPointer())
60	}
61}
62
63// OverrideEqual sets the "equal" callback function.
64// Checks if two #GIcons are equal.
65func (x *IconIface) OverrideEqual(cb func(Icon, Icon) bool) {
66	if cb == nil {
67		x.xEqual = 0
68	} else {
69		x.xEqual = purego.NewCallback(func(Icon1Varp uintptr, Icon2Varp uintptr) bool {
70			return cb(&IconBase{Ptr: Icon1Varp}, &IconBase{Ptr: Icon2Varp})
71		})
72	}
73}
74
75// GetEqual gets the "equal" callback function.
76// Checks if two #GIcons are equal.
77func (x *IconIface) GetEqual() func(Icon, Icon) bool {
78	if x.xEqual == 0 {
79		return nil
80	}
81	var rawCallback func(Icon1Varp uintptr, Icon2Varp uintptr) bool
82	purego.RegisterFunc(&rawCallback, x.xEqual)
83	return func(Icon1Var Icon, Icon2Var Icon) bool {
84		return rawCallback(Icon1Var.GoPointer(), Icon2Var.GoPointer())
85	}
86}
87
88// OverrideToTokens sets the "to_tokens" callback function.
89// Serializes a #GIcon into tokens. The tokens must not
90// contain any whitespace. Don't implement if the #GIcon can't be
91// serialized (Since 2.20).
92func (x *IconIface) OverrideToTokens(cb func(Icon, *[]string, *int) bool) {
93	if cb == nil {
94		x.xToTokens = 0
95	} else {
96		x.xToTokens = purego.NewCallback(func(IconVarp uintptr, TokensVarp *[]string, OutVersionVarp *int) bool {
97			return cb(&IconBase{Ptr: IconVarp}, TokensVarp, OutVersionVarp)
98		})
99	}
100}
101
102// GetToTokens gets the "to_tokens" callback function.
103// Serializes a #GIcon into tokens. The tokens must not
104// contain any whitespace. Don't implement if the #GIcon can't be
105// serialized (Since 2.20).
106func (x *IconIface) GetToTokens() func(Icon, *[]string, *int) bool {
107	if x.xToTokens == 0 {
108		return nil
109	}
110	var rawCallback func(IconVarp uintptr, TokensVarp *[]string, OutVersionVarp *int) bool
111	purego.RegisterFunc(&rawCallback, x.xToTokens)
112	return func(IconVar Icon, TokensVar *[]string, OutVersionVar *int) bool {
113		return rawCallback(IconVar.GoPointer(), TokensVar, OutVersionVar)
114	}
115}
116
117// OverrideFromTokens sets the "from_tokens" callback function.
118// Constructs a #GIcon from tokens. Set the #GError if
119// the tokens are malformed. Don't implement if the #GIcon can't be
120// serialized (Since 2.20).
121func (x *IconIface) OverrideFromTokens(cb func(string, int, int) *IconBase) {
122	if cb == nil {
123		x.xFromTokens = 0
124	} else {
125		x.xFromTokens = purego.NewCallback(func(TokensVarp string, NumTokensVarp int, VersionVarp int) uintptr {
126			ret := cb(TokensVarp, NumTokensVarp, VersionVarp)
127			if ret == nil {
128				return 0
129			}
130			return ret.GoPointer()
131		})
132	}
133}
134
135// GetFromTokens gets the "from_tokens" callback function.
136// Constructs a #GIcon from tokens. Set the #GError if
137// the tokens are malformed. Don't implement if the #GIcon can't be
138// serialized (Since 2.20).
139func (x *IconIface) GetFromTokens() func(string, int, int) *IconBase {
140	if x.xFromTokens == 0 {
141		return nil
142	}
143	var rawCallback func(TokensVarp string, NumTokensVarp int, VersionVarp int) uintptr
144	purego.RegisterFunc(&rawCallback, x.xFromTokens)
145	return func(TokensVar string, NumTokensVar int, VersionVar int) *IconBase {
146		rawRet := rawCallback(TokensVar, NumTokensVar, VersionVar)
147		if rawRet == 0 {
148			return nil
149		}
150		ret := &IconBase{}
151		ret.Ptr = rawRet
152		return ret
153	}
154}
155
156// OverrideSerialize sets the "serialize" callback function.
157// Serializes a #GIcon into a #GVariant. Since: 2.38
158func (x *IconIface) OverrideSerialize(cb func(Icon) *glib.Variant) {
159	if cb == nil {
160		x.xSerialize = 0
161	} else {
162		x.xSerialize = purego.NewCallback(func(IconVarp uintptr) *glib.Variant {
163			return cb(&IconBase{Ptr: IconVarp})
164		})
165	}
166}
167
168// GetSerialize gets the "serialize" callback function.
169// Serializes a #GIcon into a #GVariant. Since: 2.38
170func (x *IconIface) GetSerialize() func(Icon) *glib.Variant {
171	if x.xSerialize == 0 {
172		return nil
173	}
174	var rawCallback func(IconVarp uintptr) *glib.Variant
175	purego.RegisterFunc(&rawCallback, x.xSerialize)
176	return func(IconVar Icon) *glib.Variant {
177		return rawCallback(IconVar.GoPointer())
178	}
179}
180
181// `GIcon` is a very minimal interface for icons. It provides functions
182// for checking the equality of two icons, hashing of icons and
183// serializing an icon to and from strings.
184//
185// `GIcon` does not provide the actual pixmap for the icon as this is out
186// of GIO's scope, however implementations of `GIcon` may contain the name
187// of an icon (see [class@Gio.ThemedIcon]), or the path to an icon
188// (see [iface@Gio.LoadableIcon]).
189//
190// To obtain a hash of a `GIcon`, see [method@Gio.Icon.hash].
191//
192// To check if two `GIcon`s are equal, see [method@Gio.Icon.equal].
193//
194// For serializing a `GIcon`, use [method@Gio.Icon.serialize] and
195// [func@Gio.Icon.deserialize].
196//
197// If you want to consume `GIcon` (for example, in a toolkit) you must
198// be prepared to handle at least the three following cases:
199// [iface@Gio.LoadableIcon], [class@Gio.ThemedIcon] and [class@Gio.EmblemedIcon].
200// It may also make sense to have fast-paths for other cases (like handling
201// [`GdkPixbuf`](https://docs.gtk.org/gdk-pixbuf/class.Pixbuf.html) directly,
202// for example) but all compliant `GIcon` implementations outside of GIO must
203// implement [iface@Gio.LoadableIcon].
204//
205// If your application or library provides one or more `GIcon`
206// implementations you need to ensure that your new implementation also
207// implements [iface@Gio.LoadableIcon].  Additionally, you must provide an
208// implementation of [method@Gio.Icon.serialize] that gives a result that is
209// understood by [func@Gio.Icon.deserialize], yielding one of the built-in
210// icon types.
211type Icon interface {
212	GoPointer() uintptr
213	SetGoPointer(uintptr)
214	Equal(Icon2Var Icon) bool
215	Hash() uint
216	Serialize() *glib.Variant
217	ToString() string
218}
219
220var xIconGLibType func() types.GType
221
222func IconGLibType() types.GType {
223	return xIconGLibType()
224}
225
226type IconBase struct {
227	Ptr uintptr
228}
229
230func (x *IconBase) GoPointer() uintptr {
231	if x == nil {
232		return 0
233	}
234	return x.Ptr
235}
236
237func (x *IconBase) SetGoPointer(ptr uintptr) {
238	x.Ptr = ptr
239}
240
241// Checks if two icons are equal.
242func (x *IconBase) Equal(Icon2Var Icon) bool {
243
244	cret := XGIconEqual(x.GoPointer(), Icon2Var.GoPointer())
245	return cret
246}
247
248// Gets a hash for an icon.
249func (x *IconBase) Hash() uint {
250
251	cret := XGIconHash(x.GoPointer())
252	return cret
253}
254
255// Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
256// back by calling g_icon_deserialize() on the returned value.
257// As serialization will avoid using raw icon data when possible, it only
258// makes sense to transfer the #GVariant between processes on the same machine,
259// (as opposed to over the network), and within the same file system namespace.
260func (x *IconBase) Serialize() *glib.Variant {
261
262	cret := XGIconSerialize(x.GoPointer())
263	return cret
264}
265
266// Generates a textual representation of @icon that can be used for
267// serialization such as when passing @icon to a different process or
268// saving it to persistent storage. Use g_icon_new_for_string() to
269// get @icon back from the returned string.
270//
271// The encoding of the returned string is proprietary to #GIcon except
272// in the following two cases
273//
274//   - If @icon is a #GFileIcon, the returned string is a native path
275//     (such as `/path/to/my icon.png`) without escaping
276//     if the #GFile for @icon is a native file.  If the file is not
277//     native, the returned string is the result of g_file_get_uri()
278//     (such as `sftp://path/to/my%20icon.png`).
279//
280//   - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
281//     the encoding is simply the name (such as `network-server`).
282func (x *IconBase) ToString() string {
283
284	cret := XGIconToString(x.GoPointer())
285	return cret
286}
287
288var XGIconEqual func(uintptr, uintptr) bool
289var XGIconHash func(uintptr) uint
290var XGIconSerialize func(uintptr) *glib.Variant
291var XGIconToString func(uintptr) string
292
293var xIconDeserialize func(*glib.Variant) uintptr
294
295// Deserializes a #GIcon previously serialized using g_icon_serialize().
296func IconDeserialize(ValueVar *glib.Variant) *IconBase {
297	var cls *IconBase
298
299	cret := xIconDeserialize(ValueVar)
300
301	if cret == 0 {
302		return nil
303	}
304	cls = &IconBase{}
305	cls.Ptr = cret
306	return cls
307}
308
309var xIconNewForString func(string, **glib.Error) uintptr
310
311// Generate a #GIcon instance from @str. This function can fail if
312// @str is not valid - see g_icon_to_string() for discussion.
313//
314// If your application or library provides one or more #GIcon
315// implementations you need to ensure that each #GType is registered
316// with the type system prior to calling g_icon_new_for_string().
317func IconNewForString(StrVar string) (*IconBase, error) {
318	var cls *IconBase
319	var cerr *glib.Error
320
321	cret := xIconNewForString(StrVar, &cerr)
322
323	if cret == 0 {
324		return nil, cerr
325	}
326	cls = &IconBase{}
327	cls.Ptr = cret
328	if cerr == nil {
329		return cls, nil
330	}
331	return cls, cerr
332
333}
334
335func init() {
336	core.SetPackageName("GIO", "gio-2.0")
337	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
338	var libs []uintptr
339	for _, libPath := range core.GetPaths("GIO") {
340		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
341		if err != nil {
342			panic(err)
343		}
344		libs = append(libs, lib)
345	}
346
347	core.PuregoSafeRegister(&xIconDeserialize, libs, "g_icon_deserialize")
348	core.PuregoSafeRegister(&xIconNewForString, libs, "g_icon_new_for_string")
349
350	core.PuregoSafeRegister(&xIconGLibType, libs, "g_icon_get_type")
351
352	core.PuregoSafeRegister(&XGIconEqual, libs, "g_icon_equal")
353	core.PuregoSafeRegister(&XGIconHash, libs, "g_icon_hash")
354	core.PuregoSafeRegister(&XGIconSerialize, libs, "g_icon_serialize")
355	core.PuregoSafeRegister(&XGIconToString, libs, "g_icon_to_string")
356
357}

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