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