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 MenuAttributeIterClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xGetNext uintptr
22}
23
24func (x *MenuAttributeIterClass) GoPointer() uintptr {
25 return uintptr(unsafe.Pointer(x))
26}
27
28// OverrideGetNext sets the "get_next" callback function.
29func (x *MenuAttributeIterClass) OverrideGetNext(cb func(*MenuAttributeIter, *string, **glib.Variant) bool) {
30 if cb == nil {
31 x.xGetNext = 0
32 } else {
33 x.xGetNext = purego.NewCallback(func(IterVarp uintptr, OutNameVarp *string, ValueVarp **glib.Variant) bool {
34 return cb(MenuAttributeIterNewFromInternalPtr(IterVarp), OutNameVarp, ValueVarp)
35 })
36 }
37}
38
39// GetGetNext gets the "get_next" callback function.
40func (x *MenuAttributeIterClass) GetGetNext() func(*MenuAttributeIter, *string, **glib.Variant) bool {
41 if x.xGetNext == 0 {
42 return nil
43 }
44 var rawCallback func(IterVarp uintptr, OutNameVarp *string, ValueVarp **glib.Variant) bool
45 purego.RegisterFunc(&rawCallback, x.xGetNext)
46 return func(IterVar *MenuAttributeIter, OutNameVar *string, ValueVar **glib.Variant) bool {
47 return rawCallback(IterVar.GoPointer(), OutNameVar, ValueVar)
48 }
49}
50
51type MenuAttributeIterPrivate struct {
52 _ structs.HostLayout
53}
54
55func (x *MenuAttributeIterPrivate) GoPointer() uintptr {
56 return uintptr(unsafe.Pointer(x))
57}
58
59type MenuLinkIterClass struct {
60 _ structs.HostLayout
61
62 ParentClass gobject.ObjectClass
63
64 xGetNext uintptr
65}
66
67func (x *MenuLinkIterClass) GoPointer() uintptr {
68 return uintptr(unsafe.Pointer(x))
69}
70
71// OverrideGetNext sets the "get_next" callback function.
72func (x *MenuLinkIterClass) OverrideGetNext(cb func(*MenuLinkIter, *string, **MenuModel) bool) {
73 if cb == nil {
74 x.xGetNext = 0
75 } else {
76 x.xGetNext = purego.NewCallback(func(IterVarp uintptr, OutLinkVarp *string, ValueVarp **MenuModel) bool {
77 return cb(MenuLinkIterNewFromInternalPtr(IterVarp), OutLinkVarp, ValueVarp)
78 })
79 }
80}
81
82// GetGetNext gets the "get_next" callback function.
83func (x *MenuLinkIterClass) GetGetNext() func(*MenuLinkIter, *string, **MenuModel) bool {
84 if x.xGetNext == 0 {
85 return nil
86 }
87 var rawCallback func(IterVarp uintptr, OutLinkVarp *string, ValueVarp **MenuModel) bool
88 purego.RegisterFunc(&rawCallback, x.xGetNext)
89 return func(IterVar *MenuLinkIter, OutLinkVar *string, ValueVar **MenuModel) bool {
90 return rawCallback(IterVar.GoPointer(), OutLinkVar, ValueVar)
91 }
92}
93
94type MenuLinkIterPrivate struct {
95 _ structs.HostLayout
96}
97
98func (x *MenuLinkIterPrivate) GoPointer() uintptr {
99 return uintptr(unsafe.Pointer(x))
100}
101
102type MenuModelClass struct {
103 _ structs.HostLayout
104
105 ParentClass gobject.ObjectClass
106
107 xIsMutable uintptr
108
109 xGetNItems uintptr
110
111 xGetItemAttributes uintptr
112
113 xIterateItemAttributes uintptr
114
115 xGetItemAttributeValue uintptr
116
117 xGetItemLinks uintptr
118
119 xIterateItemLinks uintptr
120
121 xGetItemLink uintptr
122}
123
124func (x *MenuModelClass) GoPointer() uintptr {
125 return uintptr(unsafe.Pointer(x))
126}
127
128// OverrideIsMutable sets the "is_mutable" callback function.
129func (x *MenuModelClass) OverrideIsMutable(cb func(*MenuModel) bool) {
130 if cb == nil {
131 x.xIsMutable = 0
132 } else {
133 x.xIsMutable = purego.NewCallback(func(ModelVarp uintptr) bool {
134 return cb(MenuModelNewFromInternalPtr(ModelVarp))
135 })
136 }
137}
138
139// GetIsMutable gets the "is_mutable" callback function.
140func (x *MenuModelClass) GetIsMutable() func(*MenuModel) bool {
141 if x.xIsMutable == 0 {
142 return nil
143 }
144 var rawCallback func(ModelVarp uintptr) bool
145 purego.RegisterFunc(&rawCallback, x.xIsMutable)
146 return func(ModelVar *MenuModel) bool {
147 return rawCallback(ModelVar.GoPointer())
148 }
149}
150
151// OverrideGetNItems sets the "get_n_items" callback function.
152func (x *MenuModelClass) OverrideGetNItems(cb func(*MenuModel) int) {
153 if cb == nil {
154 x.xGetNItems = 0
155 } else {
156 x.xGetNItems = purego.NewCallback(func(ModelVarp uintptr) int {
157 return cb(MenuModelNewFromInternalPtr(ModelVarp))
158 })
159 }
160}
161
162// GetGetNItems gets the "get_n_items" callback function.
163func (x *MenuModelClass) GetGetNItems() func(*MenuModel) int {
164 if x.xGetNItems == 0 {
165 return nil
166 }
167 var rawCallback func(ModelVarp uintptr) int
168 purego.RegisterFunc(&rawCallback, x.xGetNItems)
169 return func(ModelVar *MenuModel) int {
170 return rawCallback(ModelVar.GoPointer())
171 }
172}
173
174// OverrideGetItemAttributes sets the "get_item_attributes" callback function.
175func (x *MenuModelClass) OverrideGetItemAttributes(cb func(*MenuModel, int, **glib.HashTable)) {
176 if cb == nil {
177 x.xGetItemAttributes = 0
178 } else {
179 x.xGetItemAttributes = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int, AttributesVarp **glib.HashTable) {
180 cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp, AttributesVarp)
181 })
182 }
183}
184
185// GetGetItemAttributes gets the "get_item_attributes" callback function.
186func (x *MenuModelClass) GetGetItemAttributes() func(*MenuModel, int, **glib.HashTable) {
187 if x.xGetItemAttributes == 0 {
188 return nil
189 }
190 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int, AttributesVarp **glib.HashTable)
191 purego.RegisterFunc(&rawCallback, x.xGetItemAttributes)
192 return func(ModelVar *MenuModel, ItemIndexVar int, AttributesVar **glib.HashTable) {
193 rawCallback(ModelVar.GoPointer(), ItemIndexVar, AttributesVar)
194 }
195}
196
197// OverrideIterateItemAttributes sets the "iterate_item_attributes" callback function.
198func (x *MenuModelClass) OverrideIterateItemAttributes(cb func(*MenuModel, int) *MenuAttributeIter) {
199 if cb == nil {
200 x.xIterateItemAttributes = 0
201 } else {
202 x.xIterateItemAttributes = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int) uintptr {
203 ret := cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp)
204 if ret == nil {
205 return 0
206 }
207 return ret.GoPointer()
208 })
209 }
210}
211
212// GetIterateItemAttributes gets the "iterate_item_attributes" callback function.
213func (x *MenuModelClass) GetIterateItemAttributes() func(*MenuModel, int) *MenuAttributeIter {
214 if x.xIterateItemAttributes == 0 {
215 return nil
216 }
217 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int) uintptr
218 purego.RegisterFunc(&rawCallback, x.xIterateItemAttributes)
219 return func(ModelVar *MenuModel, ItemIndexVar int) *MenuAttributeIter {
220 rawRet := rawCallback(ModelVar.GoPointer(), ItemIndexVar)
221 if rawRet == 0 {
222 return nil
223 }
224 ret := &MenuAttributeIter{}
225 ret.Ptr = rawRet
226 return ret
227 }
228}
229
230// OverrideGetItemAttributeValue sets the "get_item_attribute_value" callback function.
231func (x *MenuModelClass) OverrideGetItemAttributeValue(cb func(*MenuModel, int, string, *glib.VariantType) *glib.Variant) {
232 if cb == nil {
233 x.xGetItemAttributeValue = 0
234 } else {
235 x.xGetItemAttributeValue = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int, AttributeVarp string, ExpectedTypeVarp *glib.VariantType) *glib.Variant {
236 return cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp, AttributeVarp, ExpectedTypeVarp)
237 })
238 }
239}
240
241// GetGetItemAttributeValue gets the "get_item_attribute_value" callback function.
242func (x *MenuModelClass) GetGetItemAttributeValue() func(*MenuModel, int, string, *glib.VariantType) *glib.Variant {
243 if x.xGetItemAttributeValue == 0 {
244 return nil
245 }
246 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int, AttributeVarp string, ExpectedTypeVarp *glib.VariantType) *glib.Variant
247 purego.RegisterFunc(&rawCallback, x.xGetItemAttributeValue)
248 return func(ModelVar *MenuModel, ItemIndexVar int, AttributeVar string, ExpectedTypeVar *glib.VariantType) *glib.Variant {
249 return rawCallback(ModelVar.GoPointer(), ItemIndexVar, AttributeVar, ExpectedTypeVar)
250 }
251}
252
253// OverrideGetItemLinks sets the "get_item_links" callback function.
254func (x *MenuModelClass) OverrideGetItemLinks(cb func(*MenuModel, int, **glib.HashTable)) {
255 if cb == nil {
256 x.xGetItemLinks = 0
257 } else {
258 x.xGetItemLinks = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int, LinksVarp **glib.HashTable) {
259 cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp, LinksVarp)
260 })
261 }
262}
263
264// GetGetItemLinks gets the "get_item_links" callback function.
265func (x *MenuModelClass) GetGetItemLinks() func(*MenuModel, int, **glib.HashTable) {
266 if x.xGetItemLinks == 0 {
267 return nil
268 }
269 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int, LinksVarp **glib.HashTable)
270 purego.RegisterFunc(&rawCallback, x.xGetItemLinks)
271 return func(ModelVar *MenuModel, ItemIndexVar int, LinksVar **glib.HashTable) {
272 rawCallback(ModelVar.GoPointer(), ItemIndexVar, LinksVar)
273 }
274}
275
276// OverrideIterateItemLinks sets the "iterate_item_links" callback function.
277func (x *MenuModelClass) OverrideIterateItemLinks(cb func(*MenuModel, int) *MenuLinkIter) {
278 if cb == nil {
279 x.xIterateItemLinks = 0
280 } else {
281 x.xIterateItemLinks = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int) uintptr {
282 ret := cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp)
283 if ret == nil {
284 return 0
285 }
286 return ret.GoPointer()
287 })
288 }
289}
290
291// GetIterateItemLinks gets the "iterate_item_links" callback function.
292func (x *MenuModelClass) GetIterateItemLinks() func(*MenuModel, int) *MenuLinkIter {
293 if x.xIterateItemLinks == 0 {
294 return nil
295 }
296 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int) uintptr
297 purego.RegisterFunc(&rawCallback, x.xIterateItemLinks)
298 return func(ModelVar *MenuModel, ItemIndexVar int) *MenuLinkIter {
299 rawRet := rawCallback(ModelVar.GoPointer(), ItemIndexVar)
300 if rawRet == 0 {
301 return nil
302 }
303 ret := &MenuLinkIter{}
304 ret.Ptr = rawRet
305 return ret
306 }
307}
308
309// OverrideGetItemLink sets the "get_item_link" callback function.
310func (x *MenuModelClass) OverrideGetItemLink(cb func(*MenuModel, int, string) *MenuModel) {
311 if cb == nil {
312 x.xGetItemLink = 0
313 } else {
314 x.xGetItemLink = purego.NewCallback(func(ModelVarp uintptr, ItemIndexVarp int, LinkVarp string) uintptr {
315 ret := cb(MenuModelNewFromInternalPtr(ModelVarp), ItemIndexVarp, LinkVarp)
316 if ret == nil {
317 return 0
318 }
319 return ret.GoPointer()
320 })
321 }
322}
323
324// GetGetItemLink gets the "get_item_link" callback function.
325func (x *MenuModelClass) GetGetItemLink() func(*MenuModel, int, string) *MenuModel {
326 if x.xGetItemLink == 0 {
327 return nil
328 }
329 var rawCallback func(ModelVarp uintptr, ItemIndexVarp int, LinkVarp string) uintptr
330 purego.RegisterFunc(&rawCallback, x.xGetItemLink)
331 return func(ModelVar *MenuModel, ItemIndexVar int, LinkVar string) *MenuModel {
332 rawRet := rawCallback(ModelVar.GoPointer(), ItemIndexVar, LinkVar)
333 if rawRet == 0 {
334 return nil
335 }
336 ret := &MenuModel{}
337 ret.Ptr = rawRet
338 return ret
339 }
340}
341
342type MenuModelPrivate struct {
343 _ structs.HostLayout
344}
345
346func (x *MenuModelPrivate) GoPointer() uintptr {
347 return uintptr(unsafe.Pointer(x))
348}
349
350const (
351 // The menu item attribute which holds the action name of the item. Action
352 // names are namespaced with an identifier for the action group in which the
353 // action resides. For example, "win." for window-specific actions and "app."
354 // for application-wide actions.
355 //
356 // See also g_menu_model_get_item_attribute() and g_menu_item_set_attribute().
357 MENU_ATTRIBUTE_ACTION string = "action"
358 // The menu item attribute that holds the namespace for all action names in
359 // menus that are linked from this item.
360 MENU_ATTRIBUTE_ACTION_NAMESPACE string = "action-namespace"
361 // The menu item attribute which holds the icon of the item.
362 //
363 // The icon is stored in the format returned by g_icon_serialize().
364 //
365 // This attribute is intended only to represent 'noun' icons such as
366 // favicons for a webpage, or application icons. It should not be used
367 // for 'verbs' (ie: stock icons).
368 MENU_ATTRIBUTE_ICON string = "icon"
369 // The menu item attribute which holds the label of the item.
370 MENU_ATTRIBUTE_LABEL string = "label"
371 // The menu item attribute which holds the target with which the item's action
372 // will be activated.
373 //
374 // See also g_menu_item_set_action_and_target()
375 MENU_ATTRIBUTE_TARGET string = "target"
376 // The name of the link that associates a menu item with a section. The linked
377 // menu will usually be shown in place of the menu item, using the item's label
378 // as a header.
379 //
380 // See also g_menu_item_set_link().
381 MENU_LINK_SECTION string = "section"
382 // The name of the link that associates a menu item with a submenu.
383 //
384 // See also g_menu_item_set_link().
385 MENU_LINK_SUBMENU string = "submenu"
386)
387
388// #GMenuAttributeIter is an opaque structure type. You must access it
389// using the functions below.
390type MenuAttributeIter struct {
391 gobject.Object
392}
393
394var xMenuAttributeIterGLibType func() types.GType
395
396func MenuAttributeIterGLibType() types.GType {
397 return xMenuAttributeIterGLibType()
398}
399
400func MenuAttributeIterNewFromInternalPtr(ptr uintptr) *MenuAttributeIter {
401 cls := &MenuAttributeIter{}
402 cls.Ptr = ptr
403 return cls
404}
405
406var xMenuAttributeIterGetName func(uintptr) string
407
408// Gets the name of the attribute at the current iterator position, as
409// a string.
410//
411// The iterator is not advanced.
412func (x *MenuAttributeIter) GetName() string {
413
414 cret := xMenuAttributeIterGetName(x.GoPointer())
415 return cret
416}
417
418var xMenuAttributeIterGetNext func(uintptr, *string, **glib.Variant) bool
419
420// This function combines g_menu_attribute_iter_next() with
421// g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value().
422//
423// First the iterator is advanced to the next (possibly first) attribute.
424// If that fails, then %FALSE is returned and there are no other
425// effects.
426//
427// If successful, @name and @value are set to the name and value of the
428// attribute that has just been advanced to. At this point,
429// g_menu_attribute_iter_get_name() and g_menu_attribute_iter_get_value() will
430// return the same values again.
431//
432// The value returned in @name remains valid for as long as the iterator
433// remains at the current position. The value returned in @value must
434// be unreffed using g_variant_unref() when it is no longer in use.
435func (x *MenuAttributeIter) GetNext(OutNameVar *string, ValueVar **glib.Variant) bool {
436
437 cret := xMenuAttributeIterGetNext(x.GoPointer(), OutNameVar, ValueVar)
438 return cret
439}
440
441var xMenuAttributeIterGetValue func(uintptr) *glib.Variant
442
443// Gets the value of the attribute at the current iterator position.
444//
445// The iterator is not advanced.
446func (x *MenuAttributeIter) GetValue() *glib.Variant {
447
448 cret := xMenuAttributeIterGetValue(x.GoPointer())
449 return cret
450}
451
452var xMenuAttributeIterNext func(uintptr) bool
453
454// Attempts to advance the iterator to the next (possibly first)
455// attribute.
456//
457// %TRUE is returned on success, or %FALSE if there are no more
458// attributes.
459//
460// You must call this function when you first acquire the iterator
461// to advance it to the first attribute (and determine if the first
462// attribute exists at all).
463func (x *MenuAttributeIter) Next() bool {
464
465 cret := xMenuAttributeIterNext(x.GoPointer())
466 return cret
467}
468
469func (c *MenuAttributeIter) GoPointer() uintptr {
470 if c == nil {
471 return 0
472 }
473 return c.Ptr
474}
475
476func (c *MenuAttributeIter) SetGoPointer(ptr uintptr) {
477 c.Ptr = ptr
478}
479
480// #GMenuLinkIter is an opaque structure type. You must access it using
481// the functions below.
482type MenuLinkIter struct {
483 gobject.Object
484}
485
486var xMenuLinkIterGLibType func() types.GType
487
488func MenuLinkIterGLibType() types.GType {
489 return xMenuLinkIterGLibType()
490}
491
492func MenuLinkIterNewFromInternalPtr(ptr uintptr) *MenuLinkIter {
493 cls := &MenuLinkIter{}
494 cls.Ptr = ptr
495 return cls
496}
497
498var xMenuLinkIterGetName func(uintptr) string
499
500// Gets the name of the link at the current iterator position.
501//
502// The iterator is not advanced.
503func (x *MenuLinkIter) GetName() string {
504
505 cret := xMenuLinkIterGetName(x.GoPointer())
506 return cret
507}
508
509var xMenuLinkIterGetNext func(uintptr, *string, **MenuModel) bool
510
511// This function combines g_menu_link_iter_next() with
512// g_menu_link_iter_get_name() and g_menu_link_iter_get_value().
513//
514// First the iterator is advanced to the next (possibly first) link.
515// If that fails, then %FALSE is returned and there are no other effects.
516//
517// If successful, @out_link and @value are set to the name and #GMenuModel
518// of the link that has just been advanced to. At this point,
519// g_menu_link_iter_get_name() and g_menu_link_iter_get_value() will return the
520// same values again.
521//
522// The value returned in @out_link remains valid for as long as the iterator
523// remains at the current position. The value returned in @value must
524// be unreffed using g_object_unref() when it is no longer in use.
525func (x *MenuLinkIter) GetNext(OutLinkVar *string, ValueVar **MenuModel) bool {
526
527 cret := xMenuLinkIterGetNext(x.GoPointer(), OutLinkVar, ValueVar)
528 return cret
529}
530
531var xMenuLinkIterGetValue func(uintptr) uintptr
532
533// Gets the linked #GMenuModel at the current iterator position.
534//
535// The iterator is not advanced.
536func (x *MenuLinkIter) GetValue() *MenuModel {
537 var cls *MenuModel
538
539 cret := xMenuLinkIterGetValue(x.GoPointer())
540
541 if cret == 0 {
542 return nil
543 }
544 cls = &MenuModel{}
545 cls.Ptr = cret
546 return cls
547}
548
549var xMenuLinkIterNext func(uintptr) bool
550
551// Attempts to advance the iterator to the next (possibly first)
552// link.
553//
554// %TRUE is returned on success, or %FALSE if there are no more links.
555//
556// You must call this function when you first acquire the iterator to
557// advance it to the first link (and determine if the first link exists
558// at all).
559func (x *MenuLinkIter) Next() bool {
560
561 cret := xMenuLinkIterNext(x.GoPointer())
562 return cret
563}
564
565func (c *MenuLinkIter) GoPointer() uintptr {
566 if c == nil {
567 return 0
568 }
569 return c.Ptr
570}
571
572func (c *MenuLinkIter) SetGoPointer(ptr uintptr) {
573 c.Ptr = ptr
574}
575
576// `GMenuModel` represents the contents of a menu — an ordered list of
577// menu items. The items are associated with actions, which can be
578// activated through them. Items can be grouped in sections, and may
579// have submenus associated with them. Both items and sections usually
580// have some representation data, such as labels or icons. The type of
581// the associated action (ie whether it is stateful, and what kind of
582// state it has) can influence the representation of the item.
583//
584// The conceptual model of menus in `GMenuModel` is hierarchical:
585// sections and submenus are again represented by `GMenuModel`s.
586// Menus themselves do not define their own roles. Rather, the role
587// of a particular `GMenuModel` is defined by the item that references
588// it (or, in the case of the ‘root’ menu, is defined by the context
589// in which it is used).
590//
591// As an example, consider the visible portions of this menu:
592//
593// ## An example menu
594//
595// 
596//
597// While this kind of deeply nested menu is no longer considered good UI
598// practice, it serves as a good example of the concepts in `GMenuModel`.
599// There are 8 ‘menus’ visible in the screenshot: one menubar, two
600// submenus and 5 sections:
601//
602// - the toplevel menubar (containing 4 items)
603// - the View submenu (containing 3 sections)
604// - the first section of the View submenu (containing 2 items)
605// - the second section of the View submenu (containing 1 item)
606// - the final section of the View submenu (containing 1 item)
607// - the Highlight Mode submenu (containing 2 sections)
608// - the Sources section (containing 2 items)
609// - the Markup section (containing 2 items)
610//
611// The [example](#a-menu-example) illustrates the conceptual connection between
612// these 8 menus. Each large block in the figure represents a menu and the
613// smaller blocks within the large block represent items in that menu. Some
614// items contain references to other menus.
615//
616// ## A menu example
617//
618// <picture>
619//
620// <source srcset="menu-model-dark.svg" media="(prefers-color-scheme: dark)">
621// <img src="menu-model-light.svg" alt="menu model">
622//
623// </picture>
624//
625// Notice that the separators visible in the [example](#an-example-menu)
626// appear nowhere in the [menu model](#a-menu-example). This is because
627// separators are not explicitly represented in the menu model. Instead,
628// a separator is inserted between any two non-empty sections of a menu.
629// Section items can have labels just like any other item. In that case,
630// a display system may show a section header instead of a separator.
631//
632// The motivation for this abstract model of application controls is
633// that modern user interfaces tend to make these controls available
634// outside the application. Examples include global menus, jumplists,
635// dash boards, etc. To support such uses, it is necessary to ‘export’
636// information about actions and their representation in menus, which
637// is exactly what the action group exporter and the menu model exporter do for
638// [iface@Gio.ActionGroup] and [class@Gio.MenuModel]. The client-side
639// counterparts to make use of the exported information are
640// [class@Gio.DBusActionGroup] and [class@Gio.DBusMenuModel].
641//
642// The API of `GMenuModel` is very generic, with iterators for the
643// attributes and links of an item, see
644// [method@Gio.MenuModel.iterate_item_attributes] and
645// [method@Gio.MenuModel.iterate_item_links]. The ‘standard’ attributes and
646// link types have predefined names: `G_MENU_ATTRIBUTE_LABEL`,
647// `G_MENU_ATTRIBUTE_ACTION`, `G_MENU_ATTRIBUTE_TARGET`, `G_MENU_LINK_SECTION`
648// and `G_MENU_LINK_SUBMENU`.
649//
650// Items in a `GMenuModel` represent active controls if they refer to
651// an action that can get activated when the user interacts with the
652// menu item. The reference to the action is encoded by the string ID
653// in the `G_MENU_ATTRIBUTE_ACTION` attribute. An action ID uniquely
654// identifies an action in an action group. Which action group(s) provide
655// actions depends on the context in which the menu model is used.
656// E.g. when the model is exported as the application menu of a
657// [`GtkApplication`](https://docs.gtk.org/gtk4/class.Application.html),
658// actions can be application-wide or window-specific (and thus come from
659// two different action groups). By convention, the application-wide actions
660// have names that start with `app.`, while the names of window-specific
661// actions start with `win.`.
662//
663// While a wide variety of stateful actions is possible, the following
664// is the minimum that is expected to be supported by all users of exported
665// menu information:
666// - an action with no parameter type and no state
667// - an action with no parameter type and boolean state
668// - an action with string parameter type and string state
669//
670// ## Stateless
671//
672// A stateless action typically corresponds to an ordinary menu item.
673//
674// Selecting such a menu item will activate the action (with no parameter).
675//
676// ## Boolean State
677//
678// An action with a boolean state will most typically be used with a ‘toggle’
679// or ‘switch’ menu item. The state can be set directly, but activating the
680// action (with no parameter) results in the state being toggled.
681//
682// Selecting a toggle menu item will activate the action. The menu item should
683// be rendered as ‘checked’ when the state is true.
684//
685// ## String Parameter and State
686//
687// Actions with string parameters and state will most typically be used to
688// represent an enumerated choice over the items available for a group of
689// radio menu items. Activating the action with a string parameter is
690// equivalent to setting that parameter as the state.
691//
692// Radio menu items, in addition to being associated with the action, will
693// have a target value. Selecting that menu item will result in activation
694// of the action with the target value as the parameter. The menu item should
695// be rendered as ‘selected’ when the state of the action is equal to the
696// target value of the menu item.
697type MenuModel struct {
698 gobject.Object
699}
700
701var xMenuModelGLibType func() types.GType
702
703func MenuModelGLibType() types.GType {
704 return xMenuModelGLibType()
705}
706
707func MenuModelNewFromInternalPtr(ptr uintptr) *MenuModel {
708 cls := &MenuModel{}
709 cls.Ptr = ptr
710 return cls
711}
712
713var xMenuModelGetItemAttribute func(uintptr, int, string, string, ...interface{}) bool
714
715// Queries item at position @item_index in @model for the attribute
716// specified by @attribute.
717//
718// If the attribute exists and matches the #GVariantType corresponding
719// to @format_string then @format_string is used to deconstruct the
720// value into the positional parameters and %TRUE is returned.
721//
722// If the attribute does not exist, or it does exist but has the wrong
723// type, then the positional parameters are ignored and %FALSE is
724// returned.
725//
726// This function is a mix of g_menu_model_get_item_attribute_value() and
727// g_variant_get(), followed by a g_variant_unref(). As such,
728// @format_string must make a complete copy of the data (since the
729// #GVariant may go away after the call to g_variant_unref()). In
730// particular, no '&' characters are allowed in @format_string.
731func (x *MenuModel) GetItemAttribute(ItemIndexVar int, AttributeVar string, FormatStringVar string, varArgs ...interface{}) bool {
732
733 cret := xMenuModelGetItemAttribute(x.GoPointer(), ItemIndexVar, AttributeVar, FormatStringVar, varArgs...)
734 return cret
735}
736
737var xMenuModelGetItemAttributeValue func(uintptr, int, string, *glib.VariantType) *glib.Variant
738
739// Queries the item at position @item_index in @model for the attribute
740// specified by @attribute.
741//
742// If @expected_type is non-%NULL then it specifies the expected type of
743// the attribute. If it is %NULL then any type will be accepted.
744//
745// If the attribute exists and matches @expected_type (or if the
746// expected type is unspecified) then the value is returned.
747//
748// If the attribute does not exist, or does not match the expected type
749// then %NULL is returned.
750func (x *MenuModel) GetItemAttributeValue(ItemIndexVar int, AttributeVar string, ExpectedTypeVar *glib.VariantType) *glib.Variant {
751
752 cret := xMenuModelGetItemAttributeValue(x.GoPointer(), ItemIndexVar, AttributeVar, ExpectedTypeVar)
753 return cret
754}
755
756var xMenuModelGetItemLink func(uintptr, int, string) uintptr
757
758// Queries the item at position @item_index in @model for the link
759// specified by @link.
760//
761// If the link exists, the linked #GMenuModel is returned. If the link
762// does not exist, %NULL is returned.
763func (x *MenuModel) GetItemLink(ItemIndexVar int, LinkVar string) *MenuModel {
764 var cls *MenuModel
765
766 cret := xMenuModelGetItemLink(x.GoPointer(), ItemIndexVar, LinkVar)
767
768 if cret == 0 {
769 return nil
770 }
771 cls = &MenuModel{}
772 cls.Ptr = cret
773 return cls
774}
775
776var xMenuModelGetNItems func(uintptr) int
777
778// Query the number of items in @model.
779func (x *MenuModel) GetNItems() int {
780
781 cret := xMenuModelGetNItems(x.GoPointer())
782 return cret
783}
784
785var xMenuModelIsMutable func(uintptr) bool
786
787// Queries if @model is mutable.
788//
789// An immutable #GMenuModel will never emit the #GMenuModel::items-changed
790// signal. Consumers of the model may make optimisations accordingly.
791func (x *MenuModel) IsMutable() bool {
792
793 cret := xMenuModelIsMutable(x.GoPointer())
794 return cret
795}
796
797var xMenuModelItemsChanged func(uintptr, int, int, int)
798
799// Requests emission of the #GMenuModel::items-changed signal on @model.
800//
801// This function should never be called except by #GMenuModel
802// subclasses. Any other calls to this function will very likely lead
803// to a violation of the interface of the model.
804//
805// The implementation should update its internal representation of the
806// menu before emitting the signal. The implementation should further
807// expect to receive queries about the new state of the menu (and
808// particularly added menu items) while signal handlers are running.
809//
810// The implementation must dispatch this call directly from a mainloop
811// entry and not in response to calls -- particularly those from the
812// #GMenuModel API. Said another way: the menu must not change while
813// user code is running without returning to the mainloop.
814func (x *MenuModel) ItemsChanged(PositionVar int, RemovedVar int, AddedVar int) {
815
816 xMenuModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
817
818}
819
820var xMenuModelIterateItemAttributes func(uintptr, int) uintptr
821
822// Creates a #GMenuAttributeIter to iterate over the attributes of
823// the item at position @item_index in @model.
824//
825// You must free the iterator with g_object_unref() when you are done.
826func (x *MenuModel) IterateItemAttributes(ItemIndexVar int) *MenuAttributeIter {
827 var cls *MenuAttributeIter
828
829 cret := xMenuModelIterateItemAttributes(x.GoPointer(), ItemIndexVar)
830
831 if cret == 0 {
832 return nil
833 }
834 cls = &MenuAttributeIter{}
835 cls.Ptr = cret
836 return cls
837}
838
839var xMenuModelIterateItemLinks func(uintptr, int) uintptr
840
841// Creates a #GMenuLinkIter to iterate over the links of the item at
842// position @item_index in @model.
843//
844// You must free the iterator with g_object_unref() when you are done.
845func (x *MenuModel) IterateItemLinks(ItemIndexVar int) *MenuLinkIter {
846 var cls *MenuLinkIter
847
848 cret := xMenuModelIterateItemLinks(x.GoPointer(), ItemIndexVar)
849
850 if cret == 0 {
851 return nil
852 }
853 cls = &MenuLinkIter{}
854 cls.Ptr = cret
855 return cls
856}
857
858func (c *MenuModel) GoPointer() uintptr {
859 if c == nil {
860 return 0
861 }
862 return c.Ptr
863}
864
865func (c *MenuModel) SetGoPointer(ptr uintptr) {
866 c.Ptr = ptr
867}
868
869// Emitted when a change has occurred to the menu.
870//
871// The only changes that can occur to a menu is that items are removed
872// or added. Items may not change (except by being removed and added
873// back in the same location). This signal is capable of describing
874// both of those changes (at the same time).
875//
876// The signal means that starting at the index @position, @removed
877// items were removed and @added items were added in their place. If
878// @removed is zero then only items were added. If @added is zero
879// then only items were removed.
880//
881// As an example, if the menu contains items a, b, c, d (in that
882// order) and the signal (2, 1, 3) occurs then the new composition of
883// the menu will be a, b, _, _, _, d (with each _ representing some
884// new item).
885//
886// Signal handlers may query the model (particularly the added items)
887// and expect to see the results of the modification that is being
888// reported. The signal is emitted after the modification.
889func (x *MenuModel) ConnectItemsChanged(cb *func(MenuModel, int, int, int)) uint {
890 cbPtr := uintptr(unsafe.Pointer(cb))
891 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
892 handlerID := gobject.SignalConnect(x.GoPointer(), "items-changed", cbRefPtr)
893 glib.SaveHandlerMapping(handlerID, cbPtr)
894 return handlerID
895 }
896
897 fcb := func(clsPtr uintptr, PositionVarp int, RemovedVarp int, AddedVarp int) {
898 fa := MenuModel{}
899 fa.Ptr = clsPtr
900 cbFn := *cb
901
902 cbFn(fa, PositionVarp, RemovedVarp, AddedVarp)
903
904 }
905 cbRefPtr := purego.NewCallback(fcb)
906 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
907 handlerID := gobject.SignalConnect(x.GoPointer(), "items-changed", cbRefPtr)
908 glib.SaveHandlerMapping(handlerID, cbPtr)
909 return handlerID
910}
911
912func init() {
913 core.SetPackageName("GIO", "gio-2.0")
914 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
915 var libs []uintptr
916 for _, libPath := range core.GetPaths("GIO") {
917 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
918 if err != nil {
919 panic(err)
920 }
921 libs = append(libs, lib)
922 }
923
924 core.PuregoSafeRegister(&xMenuAttributeIterGLibType, libs, "g_menu_attribute_iter_get_type")
925
926 core.PuregoSafeRegister(&xMenuAttributeIterGetName, libs, "g_menu_attribute_iter_get_name")
927 core.PuregoSafeRegister(&xMenuAttributeIterGetNext, libs, "g_menu_attribute_iter_get_next")
928 core.PuregoSafeRegister(&xMenuAttributeIterGetValue, libs, "g_menu_attribute_iter_get_value")
929 core.PuregoSafeRegister(&xMenuAttributeIterNext, libs, "g_menu_attribute_iter_next")
930
931 core.PuregoSafeRegister(&xMenuLinkIterGLibType, libs, "g_menu_link_iter_get_type")
932
933 core.PuregoSafeRegister(&xMenuLinkIterGetName, libs, "g_menu_link_iter_get_name")
934 core.PuregoSafeRegister(&xMenuLinkIterGetNext, libs, "g_menu_link_iter_get_next")
935 core.PuregoSafeRegister(&xMenuLinkIterGetValue, libs, "g_menu_link_iter_get_value")
936 core.PuregoSafeRegister(&xMenuLinkIterNext, libs, "g_menu_link_iter_next")
937
938 core.PuregoSafeRegister(&xMenuModelGLibType, libs, "g_menu_model_get_type")
939
940 core.PuregoSafeRegister(&xMenuModelGetItemAttribute, libs, "g_menu_model_get_item_attribute")
941 core.PuregoSafeRegister(&xMenuModelGetItemAttributeValue, libs, "g_menu_model_get_item_attribute_value")
942 core.PuregoSafeRegister(&xMenuModelGetItemLink, libs, "g_menu_model_get_item_link")
943 core.PuregoSafeRegister(&xMenuModelGetNItems, libs, "g_menu_model_get_n_items")
944 core.PuregoSafeRegister(&xMenuModelIsMutable, libs, "g_menu_model_is_mutable")
945 core.PuregoSafeRegister(&xMenuModelItemsChanged, libs, "g_menu_model_items_changed")
946 core.PuregoSafeRegister(&xMenuModelIterateItemAttributes, libs, "g_menu_model_iterate_item_attributes")
947 core.PuregoSafeRegister(&xMenuModelIterateItemLinks, libs, "g_menu_model_iterate_item_links")
948
949}