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"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type FileIconClass struct {
17 _ structs.HostLayout
18}
19
20func (x *FileIconClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// `GFileIcon` specifies an icon by pointing to an image file
25// to be used as icon.
26//
27// It implements [iface@Gio.LoadableIcon].
28type FileIcon struct {
29 gobject.Object
30}
31
32var xFileIconGLibType func() types.GType
33
34func FileIconGLibType() types.GType {
35 return xFileIconGLibType()
36}
37
38func FileIconNewFromInternalPtr(ptr uintptr) *FileIcon {
39 cls := &FileIcon{}
40 cls.Ptr = ptr
41 return cls
42}
43
44var xNewFileIcon func(uintptr) uintptr
45
46// Creates a new icon for a file.
47func NewFileIcon(FileVar File) *FileIcon {
48 var cls *FileIcon
49
50 cret := xNewFileIcon(FileVar.GoPointer())
51
52 if cret == 0 {
53 return nil
54 }
55 cls = &FileIcon{}
56 cls.Ptr = cret
57 return cls
58}
59
60var xFileIconGetFile func(uintptr) uintptr
61
62// Gets the #GFile associated with the given @icon.
63func (x *FileIcon) GetFile() *FileBase {
64 var cls *FileBase
65
66 cret := xFileIconGetFile(x.GoPointer())
67
68 if cret == 0 {
69 return nil
70 }
71 gobject.IncreaseRef(cret)
72 cls = &FileBase{}
73 cls.Ptr = cret
74 return cls
75}
76
77func (c *FileIcon) GoPointer() uintptr {
78 if c == nil {
79 return 0
80 }
81 return c.Ptr
82}
83
84func (c *FileIcon) SetGoPointer(ptr uintptr) {
85 c.Ptr = ptr
86}
87
88// Checks if two icons are equal.
89func (x *FileIcon) Equal(Icon2Var Icon) bool {
90
91 cret := XGIconEqual(x.GoPointer(), Icon2Var.GoPointer())
92 return cret
93}
94
95// Gets a hash for an icon.
96func (x *FileIcon) Hash() uint {
97
98 cret := XGIconHash(x.GoPointer())
99 return cret
100}
101
102// Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
103// back by calling g_icon_deserialize() on the returned value.
104// As serialization will avoid using raw icon data when possible, it only
105// makes sense to transfer the #GVariant between processes on the same machine,
106// (as opposed to over the network), and within the same file system namespace.
107func (x *FileIcon) Serialize() *glib.Variant {
108
109 cret := XGIconSerialize(x.GoPointer())
110 return cret
111}
112
113// Generates a textual representation of @icon that can be used for
114// serialization such as when passing @icon to a different process or
115// saving it to persistent storage. Use g_icon_new_for_string() to
116// get @icon back from the returned string.
117//
118// The encoding of the returned string is proprietary to #GIcon except
119// in the following two cases
120//
121// - If @icon is a #GFileIcon, the returned string is a native path
122// (such as `/path/to/my icon.png`) without escaping
123// if the #GFile for @icon is a native file. If the file is not
124// native, the returned string is the result of g_file_get_uri()
125// (such as `sftp://path/to/my%20icon.png`).
126//
127// - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
128// the encoding is simply the name (such as `network-server`).
129func (x *FileIcon) ToString() string {
130
131 cret := XGIconToString(x.GoPointer())
132 return cret
133}
134
135// Loads a loadable icon. For the asynchronous version of this function,
136// see g_loadable_icon_load_async().
137func (x *FileIcon) Load(SizeVar int, TypeVar *string, CancellableVar *Cancellable) (*InputStream, error) {
138 var cls *InputStream
139 var cerr *glib.Error
140
141 cret := XGLoadableIconLoad(x.GoPointer(), SizeVar, TypeVar, CancellableVar.GoPointer(), &cerr)
142
143 if cret == 0 {
144 return nil, cerr
145 }
146 cls = &InputStream{}
147 cls.Ptr = cret
148 if cerr == nil {
149 return cls, nil
150 }
151 return cls, cerr
152
153}
154
155// Loads an icon asynchronously. To finish this function, see
156// g_loadable_icon_load_finish(). For the synchronous, blocking
157// version of this function, see g_loadable_icon_load().
158func (x *FileIcon) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
159
160 XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
161
162}
163
164// Finishes an asynchronous icon load started in g_loadable_icon_load_async().
165func (x *FileIcon) LoadFinish(ResVar AsyncResult, TypeVar *string) (*InputStream, error) {
166 var cls *InputStream
167 var cerr *glib.Error
168
169 cret := XGLoadableIconLoadFinish(x.GoPointer(), ResVar.GoPointer(), TypeVar, &cerr)
170
171 if cret == 0 {
172 return nil, cerr
173 }
174 cls = &InputStream{}
175 cls.Ptr = cret
176 if cerr == nil {
177 return cls, nil
178 }
179 return cls, cerr
180
181}
182
183func init() {
184 core.SetPackageName("GIO", "gio-2.0")
185 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
186 var libs []uintptr
187 for _, libPath := range core.GetPaths("GIO") {
188 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
189 if err != nil {
190 panic(err)
191 }
192 libs = append(libs, lib)
193 }
194
195 core.PuregoSafeRegister(&xFileIconGLibType, libs, "g_file_icon_get_type")
196
197 core.PuregoSafeRegister(&xNewFileIcon, libs, "g_file_icon_new")
198
199 core.PuregoSafeRegister(&xFileIconGetFile, libs, "g_file_icon_get_file")
200
201}