1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/gdk"
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// Used to specify options for gtk_icon_theme_lookup_icon().
18type IconLookupFlags int
19
20var xIconLookupFlagsGLibType func() types.GType
21
22func IconLookupFlagsGLibType() types.GType {
23 return xIconLookupFlagsGLibType()
24}
25
26const (
27
28 // Perform a regular lookup.
29 IconLookupNoneValue IconLookupFlags = 0
30 // Try to always load regular icons, even
31 // when symbolic icon names are given
32 IconLookupForceRegularValue IconLookupFlags = 1
33 // Try to always load symbolic icons, even
34 // when regular icon names are given
35 IconLookupForceSymbolicValue IconLookupFlags = 2
36 // Starts loading the texture in the background
37 // so it is ready when later needed.
38 IconLookupPreloadValue IconLookupFlags = 4
39)
40
41// Error codes for `GtkIconTheme` operations.
42type IconThemeError int
43
44var xIconThemeErrorGLibType func() types.GType
45
46func IconThemeErrorGLibType() types.GType {
47 return xIconThemeErrorGLibType()
48}
49
50const (
51
52 // The icon specified does not exist in the theme
53 IconThemeNotFoundValue IconThemeError = 0
54 // An unspecified error occurred.
55 IconThemeFailedValue IconThemeError = 1
56)
57
58var xIconThemeErrorQuark func() glib.Quark
59
60// Registers an error quark for [class@Gtk.IconTheme] errors.
61func IconThemeErrorQuark() glib.Quark {
62
63 cret := xIconThemeErrorQuark()
64 return cret
65}
66
67// Loads themed icons.
68//
69// The main reason for using a name rather than simply providing a filename
70// is to allow different icons to be used depending on what “icon theme” is
71// selected by the user. The operation of icon themes on Linux and Unix
72// follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
73// There is a fallback icon theme, named `hicolor`, where applications
74// should install their icons, but additional icon themes can be installed
75// as operating system vendors and users choose.
76//
77// In many cases, named themes are used indirectly, via [class@Gtk.Image]
78// rather than directly, but looking up icons directly is also simple. The
79// `GtkIconTheme` object acts as a database of all the icons in the current
80// theme. You can create new `GtkIconTheme` objects, but it’s much more
81// efficient to use the standard icon theme of the `GtkWidget` so that the
82// icon information is shared with other people looking up icons.
83//
84// ```c
85// GtkIconTheme *icon_theme;
86// GtkIconPaintable *icon;
87// GdkPaintable *paintable;
88//
89// icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
90// icon = gtk_icon_theme_lookup_icon (icon_theme,
91//
92// "my-icon-name", // icon name
93// 48, // icon size
94// 1, // scale
95// 0, // flags);
96//
97// paintable = GDK_PAINTABLE (icon);
98// // Use the paintable
99// g_object_unref (icon);
100// ```
101type IconTheme struct {
102 gobject.Object
103}
104
105var xIconThemeGLibType func() types.GType
106
107func IconThemeGLibType() types.GType {
108 return xIconThemeGLibType()
109}
110
111func IconThemeNewFromInternalPtr(ptr uintptr) *IconTheme {
112 cls := &IconTheme{}
113 cls.Ptr = ptr
114 return cls
115}
116
117var xNewIconTheme func() uintptr
118
119// Creates a new icon theme object.
120//
121// Icon theme objects are used to lookup up an icon by name
122// in a particular icon theme. Usually, you’ll want to use
123// [func@Gtk.IconTheme.get_for_display] rather than creating
124// a new icon theme object for scratch.
125func NewIconTheme() *IconTheme {
126 var cls *IconTheme
127
128 cret := xNewIconTheme()
129
130 if cret == 0 {
131 return nil
132 }
133 cls = &IconTheme{}
134 cls.Ptr = cret
135 return cls
136}
137
138var xIconThemeAddResourcePath func(uintptr, string)
139
140// Adds a resource path that will be looked at when looking
141// for icons, similar to search paths.
142//
143// See [method@Gtk.IconTheme.set_resource_path].
144//
145// This function should be used to make application-specific icons
146// available as part of the icon theme.
147func (x *IconTheme) AddResourcePath(PathVar string) {
148
149 xIconThemeAddResourcePath(x.GoPointer(), PathVar)
150
151}
152
153var xIconThemeAddSearchPath func(uintptr, string)
154
155// Appends a directory to the search path.
156//
157// See [method@Gtk.IconTheme.set_search_path].
158func (x *IconTheme) AddSearchPath(PathVar string) {
159
160 xIconThemeAddSearchPath(x.GoPointer(), PathVar)
161
162}
163
164var xIconThemeGetDisplay func(uintptr) uintptr
165
166// Returns the display that the `GtkIconTheme` object was
167// created for.
168func (x *IconTheme) GetDisplay() *gdk.Display {
169 var cls *gdk.Display
170
171 cret := xIconThemeGetDisplay(x.GoPointer())
172
173 if cret == 0 {
174 return nil
175 }
176 gobject.IncreaseRef(cret)
177 cls = &gdk.Display{}
178 cls.Ptr = cret
179 return cls
180}
181
182var xIconThemeGetIconNames func(uintptr) []string
183
184// Lists the names of icons in the current icon theme.
185func (x *IconTheme) GetIconNames() []string {
186
187 cret := xIconThemeGetIconNames(x.GoPointer())
188 return cret
189}
190
191var xIconThemeGetIconSizes func(uintptr, string) uintptr
192
193// Returns an array of integers describing the sizes at which
194// the icon is available without scaling.
195//
196// A size of -1 means that the icon is available in a scalable
197// format. The array is zero-terminated.
198func (x *IconTheme) GetIconSizes(IconNameVar string) uintptr {
199
200 cret := xIconThemeGetIconSizes(x.GoPointer(), IconNameVar)
201 return cret
202}
203
204var xIconThemeGetResourcePath func(uintptr) []string
205
206// Gets the current resource path.
207//
208// See [method@Gtk.IconTheme.set_resource_path].
209func (x *IconTheme) GetResourcePath() []string {
210
211 cret := xIconThemeGetResourcePath(x.GoPointer())
212 return cret
213}
214
215var xIconThemeGetSearchPath func(uintptr) []string
216
217// Gets the current search path.
218//
219// See [method@Gtk.IconTheme.set_search_path].
220func (x *IconTheme) GetSearchPath() []string {
221
222 cret := xIconThemeGetSearchPath(x.GoPointer())
223 return cret
224}
225
226var xIconThemeGetThemeName func(uintptr) string
227
228// Gets the current icon theme name.
229func (x *IconTheme) GetThemeName() string {
230
231 cret := xIconThemeGetThemeName(x.GoPointer())
232 return cret
233}
234
235var xIconThemeHasGicon func(uintptr, uintptr) bool
236
237// Checks whether an icon theme includes an icon
238// for a particular `GIcon`.
239func (x *IconTheme) HasGicon(GiconVar gio.Icon) bool {
240
241 cret := xIconThemeHasGicon(x.GoPointer(), GiconVar.GoPointer())
242 return cret
243}
244
245var xIconThemeHasIcon func(uintptr, string) bool
246
247// Checks whether an icon theme includes an icon
248// for a particular name.
249func (x *IconTheme) HasIcon(IconNameVar string) bool {
250
251 cret := xIconThemeHasIcon(x.GoPointer(), IconNameVar)
252 return cret
253}
254
255var xIconThemeLookupByGicon func(uintptr, uintptr, int, int, TextDirection, IconLookupFlags) uintptr
256
257// Looks up a icon for a desired size and window scale.
258//
259// The icon can then be rendered by using it as a `GdkPaintable`,
260// or you can get information such as the filename and size.
261func (x *IconTheme) LookupByGicon(IconVar gio.Icon, SizeVar int, ScaleVar int, DirectionVar TextDirection, FlagsVar IconLookupFlags) *IconPaintable {
262 var cls *IconPaintable
263
264 cret := xIconThemeLookupByGicon(x.GoPointer(), IconVar.GoPointer(), SizeVar, ScaleVar, DirectionVar, FlagsVar)
265
266 if cret == 0 {
267 return nil
268 }
269 cls = &IconPaintable{}
270 cls.Ptr = cret
271 return cls
272}
273
274var xIconThemeLookupIcon func(uintptr, string, []string, int, int, TextDirection, IconLookupFlags) uintptr
275
276// Looks up a named icon for a desired size and window scale,
277// returning a `GtkIconPaintable`.
278//
279// The icon can then be rendered by using it as a `GdkPaintable`,
280// or you can get information such as the filename and size.
281//
282// If the available @icon_name is not available and @fallbacks are
283// provided, they will be tried in order.
284//
285// If no matching icon is found, then a paintable that renders the
286// "missing icon" icon is returned. If you need to do something else
287// for missing icons you need to use [method@Gtk.IconTheme.has_icon].
288//
289// Note that you probably want to listen for icon theme changes and
290// update the icon. This is usually done by overriding the
291// GtkWidgetClass.css-changed() function.
292func (x *IconTheme) LookupIcon(IconNameVar string, FallbacksVar []string, SizeVar int, ScaleVar int, DirectionVar TextDirection, FlagsVar IconLookupFlags) *IconPaintable {
293 var cls *IconPaintable
294
295 cret := xIconThemeLookupIcon(x.GoPointer(), IconNameVar, FallbacksVar, SizeVar, ScaleVar, DirectionVar, FlagsVar)
296
297 if cret == 0 {
298 return nil
299 }
300 cls = &IconPaintable{}
301 cls.Ptr = cret
302 return cls
303}
304
305var xIconThemeSetResourcePath func(uintptr, []string)
306
307// Sets the resource paths that will be looked at when
308// looking for icons, similar to search paths.
309//
310// The resources are considered as part of the hicolor icon theme
311// and must be located in subdirectories that are defined in the
312// hicolor icon theme, such as `@path/16x16/actions/run.png`
313// or `@path/scalable/actions/run.svg`.
314//
315// Icons that are directly placed in the resource path instead
316// of a subdirectory are also considered as ultimate fallback,
317// but they are treated like unthemed icons.
318func (x *IconTheme) SetResourcePath(PathVar []string) {
319
320 xIconThemeSetResourcePath(x.GoPointer(), PathVar)
321
322}
323
324var xIconThemeSetSearchPath func(uintptr, []string)
325
326// Sets the search path for the icon theme object.
327//
328// When looking for an icon theme, GTK will search for a subdirectory
329// of one or more of the directories in @path with the same name
330// as the icon theme containing an index.theme file. (Themes from
331// multiple of the path elements are combined to allow themes to be
332// extended by adding icons in the user’s home directory.)
333//
334// In addition if an icon found isn’t found either in the current
335// icon theme or the default icon theme, and an image file with
336// the right name is found directly in one of the elements of
337// @path, then that image will be used for the icon name.
338// (This is legacy feature, and new icons should be put
339// into the fallback icon theme, which is called hicolor,
340// rather than directly on the icon path.)
341func (x *IconTheme) SetSearchPath(PathVar []string) {
342
343 xIconThemeSetSearchPath(x.GoPointer(), PathVar)
344
345}
346
347var xIconThemeSetThemeName func(uintptr, uintptr)
348
349// Sets the name of the icon theme that the `GtkIconTheme` object uses
350// overriding system configuration.
351//
352// This function cannot be called on the icon theme objects returned
353// from [func@Gtk.IconTheme.get_for_display].
354func (x *IconTheme) SetThemeName(ThemeNameVar *string) {
355
356 ThemeNameVarPtr := core.GStrdupNullable(ThemeNameVar)
357 defer core.GFreeNullable(ThemeNameVarPtr)
358
359 xIconThemeSetThemeName(x.GoPointer(), ThemeNameVarPtr)
360
361}
362
363func (c *IconTheme) GoPointer() uintptr {
364 if c == nil {
365 return 0
366 }
367 return c.Ptr
368}
369
370func (c *IconTheme) SetGoPointer(ptr uintptr) {
371 c.Ptr = ptr
372}
373
374// GetPropertyIconNames gets the "icon-names" property.
375// The icon names that are supported by the icon theme.
376func (x *IconTheme) GetPropertyIconNames() []string {
377 var v gobject.Value
378 x.GetProperty("icon-names", &v)
379 return core.GoStringSlice(v.GetBoxed())
380}
381
382// SetPropertyResourcePath sets the "resource-path" property.
383// Resource paths that will be looked at when looking for icons,
384// similar to search paths.
385//
386// The resources are considered as part of the hicolor icon theme
387// and must be located in subdirectories that are defined in the
388// hicolor icon theme, such as `@path/16x16/actions/run.png`.
389// Icons that are directly placed in the resource path instead
390// of a subdirectory are also considered as ultimate fallback.
391func (x *IconTheme) SetPropertyResourcePath(value []string) {
392 var v gobject.Value
393 v.Init(glib.StrvGetType())
394 v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
395 x.SetProperty("resource-path", &v)
396}
397
398// GetPropertyResourcePath gets the "resource-path" property.
399// Resource paths that will be looked at when looking for icons,
400// similar to search paths.
401//
402// The resources are considered as part of the hicolor icon theme
403// and must be located in subdirectories that are defined in the
404// hicolor icon theme, such as `@path/16x16/actions/run.png`.
405// Icons that are directly placed in the resource path instead
406// of a subdirectory are also considered as ultimate fallback.
407func (x *IconTheme) GetPropertyResourcePath() []string {
408 var v gobject.Value
409 x.GetProperty("resource-path", &v)
410 return core.GoStringSlice(v.GetBoxed())
411}
412
413// SetPropertySearchPath sets the "search-path" property.
414// The search path for this icon theme.
415//
416// When looking for icons, GTK will search for a subdirectory of
417// one or more of the directories in the search path with the same
418// name as the icon theme containing an index.theme file. (Themes
419// from multiple of the path elements are combined to allow themes
420// to be extended by adding icons in the user’s home directory.)
421func (x *IconTheme) SetPropertySearchPath(value []string) {
422 var v gobject.Value
423 v.Init(glib.StrvGetType())
424 v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
425 x.SetProperty("search-path", &v)
426}
427
428// GetPropertySearchPath gets the "search-path" property.
429// The search path for this icon theme.
430//
431// When looking for icons, GTK will search for a subdirectory of
432// one or more of the directories in the search path with the same
433// name as the icon theme containing an index.theme file. (Themes
434// from multiple of the path elements are combined to allow themes
435// to be extended by adding icons in the user’s home directory.)
436func (x *IconTheme) GetPropertySearchPath() []string {
437 var v gobject.Value
438 x.GetProperty("search-path", &v)
439 return core.GoStringSlice(v.GetBoxed())
440}
441
442// SetPropertyThemeName sets the "theme-name" property.
443// The name of the icon theme that is being used.
444//
445// Unless set to a different value, this will be the value of
446// the `GtkSettings:gtk-icon-theme-name` property of the `GtkSettings`
447// object associated to the display of the icontheme object.
448func (x *IconTheme) SetPropertyThemeName(value string) {
449 var v gobject.Value
450 v.Init(gobject.TypeStringVal)
451 v.SetString(&value)
452 x.SetProperty("theme-name", &v)
453}
454
455// GetPropertyThemeName gets the "theme-name" property.
456// The name of the icon theme that is being used.
457//
458// Unless set to a different value, this will be the value of
459// the `GtkSettings:gtk-icon-theme-name` property of the `GtkSettings`
460// object associated to the display of the icontheme object.
461func (x *IconTheme) GetPropertyThemeName() string {
462 var v gobject.Value
463 x.GetProperty("theme-name", &v)
464 return v.GetString()
465}
466
467// Emitted when the icon theme changes.
468//
469// This can happen because current icon theme is switched or
470// because GTK detects that a change has occurred in the
471// contents of the current icon theme.
472func (x *IconTheme) ConnectChanged(cb *func(IconTheme)) uint {
473 cbPtr := uintptr(unsafe.Pointer(cb))
474 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
475 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
476 glib.SaveHandlerMapping(handlerID, cbPtr)
477 return handlerID
478 }
479
480 fcb := func(clsPtr uintptr) {
481 fa := IconTheme{}
482 fa.Ptr = clsPtr
483 cbFn := *cb
484
485 cbFn(fa)
486
487 }
488 cbRefPtr := purego.NewCallback(fcb)
489 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
490 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
491 glib.SaveHandlerMapping(handlerID, cbPtr)
492 return handlerID
493}
494
495var xIconThemeGetForDisplay func(uintptr) uintptr
496
497// Gets the icon theme object associated with @display.
498//
499// If this function has not previously been called for the given
500// display, a new icon theme object will be created and associated
501// with the display. Icon theme objects are fairly expensive to create,
502// so using this function is usually a better choice than calling
503// [ctor@Gtk.IconTheme.new] and setting the display yourself; by using
504// this function a single icon theme object will be shared between users.
505func IconThemeGetForDisplay(DisplayVar *gdk.Display) *IconTheme {
506 var cls *IconTheme
507
508 cret := xIconThemeGetForDisplay(DisplayVar.GoPointer())
509
510 if cret == 0 {
511 return nil
512 }
513 gobject.IncreaseRef(cret)
514 cls = &IconTheme{}
515 cls.Ptr = cret
516 return cls
517}
518
519func init() {
520 core.SetPackageName("GTK", "gtk4")
521 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
522 var libs []uintptr
523 for _, libPath := range core.GetPaths("GTK") {
524 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
525 if err != nil {
526 panic(err)
527 }
528 libs = append(libs, lib)
529 }
530
531 core.PuregoSafeRegister(&xIconLookupFlagsGLibType, libs, "gtk_icon_lookup_flags_get_type")
532
533 core.PuregoSafeRegister(&xIconThemeErrorGLibType, libs, "gtk_icon_theme_error_get_type")
534
535 core.PuregoSafeRegister(&xIconThemeErrorQuark, libs, "gtk_icon_theme_error_quark")
536
537 core.PuregoSafeRegister(&xIconThemeGLibType, libs, "gtk_icon_theme_get_type")
538
539 core.PuregoSafeRegister(&xNewIconTheme, libs, "gtk_icon_theme_new")
540
541 core.PuregoSafeRegister(&xIconThemeAddResourcePath, libs, "gtk_icon_theme_add_resource_path")
542 core.PuregoSafeRegister(&xIconThemeAddSearchPath, libs, "gtk_icon_theme_add_search_path")
543 core.PuregoSafeRegister(&xIconThemeGetDisplay, libs, "gtk_icon_theme_get_display")
544 core.PuregoSafeRegister(&xIconThemeGetIconNames, libs, "gtk_icon_theme_get_icon_names")
545 core.PuregoSafeRegister(&xIconThemeGetIconSizes, libs, "gtk_icon_theme_get_icon_sizes")
546 core.PuregoSafeRegister(&xIconThemeGetResourcePath, libs, "gtk_icon_theme_get_resource_path")
547 core.PuregoSafeRegister(&xIconThemeGetSearchPath, libs, "gtk_icon_theme_get_search_path")
548 core.PuregoSafeRegister(&xIconThemeGetThemeName, libs, "gtk_icon_theme_get_theme_name")
549 core.PuregoSafeRegister(&xIconThemeHasGicon, libs, "gtk_icon_theme_has_gicon")
550 core.PuregoSafeRegister(&xIconThemeHasIcon, libs, "gtk_icon_theme_has_icon")
551 core.PuregoSafeRegister(&xIconThemeLookupByGicon, libs, "gtk_icon_theme_lookup_by_gicon")
552 core.PuregoSafeRegister(&xIconThemeLookupIcon, libs, "gtk_icon_theme_lookup_icon")
553 core.PuregoSafeRegister(&xIconThemeSetResourcePath, libs, "gtk_icon_theme_set_resource_path")
554 core.PuregoSafeRegister(&xIconThemeSetSearchPath, libs, "gtk_icon_theme_set_search_path")
555 core.PuregoSafeRegister(&xIconThemeSetThemeName, libs, "gtk_icon_theme_set_theme_name")
556
557 core.PuregoSafeRegister(&xIconThemeGetForDisplay, libs, "gtk_icon_theme_get_for_display")
558
559}