1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8 "github.com/bnema/puregotk/v4/gdk"
9 "github.com/bnema/puregotk/v4/gio"
10 "github.com/bnema/puregotk/v4/gobject"
11 "github.com/bnema/puregotk/v4/gobject/types"
12 "github.com/bnema/puregotk/v4/gsk"
13)
14
15// A subclass of `GtkPopover` that implements menu behavior.
16//
17// <picture>
18//
19// <source srcset="menu-dark.png" media="(prefers-color-scheme: dark)">
20// <img alt="An example GtkPopoverMenu" src="menu.png">
21//
22// </picture>
23//
24// `GtkPopoverMenu` treats its children like menus and allows switching
25// between them. It can open submenus as traditional, nested submenus,
26// or in a more touch-friendly sliding fashion.
27// The property [property@Gtk.PopoverMenu:flags] controls this appearance.
28//
29// `GtkPopoverMenu` is meant to be used primarily with menu models,
30// using [ctor@Gtk.PopoverMenu.new_from_model]. If you need to put
31// other widgets such as a `GtkSpinButton` or a `GtkSwitch` into a popover,
32// you can use [method@Gtk.PopoverMenu.add_child].
33//
34// For more dialog-like behavior, use a plain `GtkPopover`.
35//
36// ## Menu models
37//
38// The XML format understood by `GtkBuilder` for `GMenuModel` consists
39// of a toplevel `<menu>` element, which contains one or more `<item>`
40// elements. Each `<item>` element contains `<attribute>` and `<link>`
41// elements with a mandatory name attribute. `<link>` elements have the
42// same content model as `<menu>`. Instead of `<link name="submenu">`
43// or `<link name="section">`, you can use `<submenu>` or `<section>`
44// elements.
45//
46// ```xml
47// <menu id='app-menu'>
48//
49// <section>
50// <item>
51// <attribute name='label' translatable='yes'>_New Window</attribute>
52// <attribute name='action'>app.new</attribute>
53// </item>
54// <item>
55// <attribute name='label' translatable='yes'>_About Sunny</attribute>
56// <attribute name='action'>app.about</attribute>
57// </item>
58// <item>
59// <attribute name='label' translatable='yes'>_Quit</attribute>
60// <attribute name='action'>app.quit</attribute>
61// </item>
62// </section>
63//
64// </menu>
65// ```
66//
67// Attribute values can be translated using gettext, like other `GtkBuilder`
68// content. `<attribute>` elements can be marked for translation with a
69// `translatable="yes"` attribute. It is also possible to specify message
70// context and translator comments, using the context and comments attributes.
71// To make use of this, the `GtkBuilder` must have been given the gettext
72// domain to use.
73//
74// The following attributes are used when constructing menu items:
75//
76// - "label": a user-visible string to display
77// - "use-markup": whether the text in the menu item includes [Pango markup](https://docs.gtk.org/Pango/pango_markup.html)
78// - "action": the prefixed name of the action to trigger
79// - "target": the parameter to use when activating the action
80// - "icon" and "verb-icon": names of icons that may be displayed
81// - "submenu-action": name of an action that may be used to track
82// whether a submenu is open
83// - "hidden-when": a string used to determine when the item will be hidden.
84// Possible values include "action-disabled", "action-missing", "macos-menubar".
85// This is mainly useful for exported menus, see [method@Gtk.Application.set_menubar].
86// - "custom": a string used to match against the ID of a custom child added with
87// [method@Gtk.PopoverMenu.add_child], [method@Gtk.PopoverMenuBar.add_child],
88// or in the ui file with `<child type="ID">`.
89//
90// The following attributes are used when constructing sections:
91//
92// - "label": a user-visible string to use as section heading
93// - "display-hint": a string used to determine special formatting for the section.
94// Possible values include "horizontal-buttons", "circular-buttons" and
95// "inline-buttons". They all indicate that section should be
96// displayed as a horizontal row of buttons.
97// - "text-direction": a string used to determine the `GtkTextDirection` to use
98// when "display-hint" is set to "horizontal-buttons". Possible values
99// include "rtl", "ltr", and "none".
100//
101// The following attributes are used when constructing submenus:
102//
103// - "label": a user-visible string to display
104// - "icon": icon name to display
105// - "gtk-macos-special": (macOS only, ignored by others) Add special meaning to a menu
106// in the macOS menu bar. See [Using GTK on Apple macOS](osx.html).
107//
108// Menu items will also show accelerators, which are usually associated
109// with actions via [method@Gtk.Application.set_accels_for_action],
110// [method@WidgetClass.add_binding_action] or
111// [method@Gtk.ShortcutController.add_shortcut].
112//
113// # Shortcuts and Gestures
114//
115// `GtkPopoverMenu` supports the following keyboard shortcuts:
116//
117// - <kbd>Space</kbd> activates the default widget.
118//
119// # CSS Nodes
120//
121// `GtkPopoverMenu` is just a subclass of `GtkPopover` that adds custom content
122// to it, therefore it has the same CSS nodes. It is one of the cases that add
123// a `.menu` style class to the main `popover` node.
124//
125// Menu items have nodes with name `button` and class `.model`. If a section
126// display-hint is set, the section gets a node `box` with class `horizontal`
127// plus a class with the same text as the display hint. Note that said box may
128// not be the direct ancestor of the item `button`s. Thus, for example, to style
129// items in an `inline-buttons` section, select `.inline-buttons button.model`.
130// Other things that may be of interest to style in menus include `label` nodes.
131//
132// # Accessibility
133//
134// `GtkPopoverMenu` uses the [enum@Gtk.AccessibleRole.menu] role, and its
135// items use the [enum@Gtk.AccessibleRole.menu_item],
136// [enum@Gtk.AccessibleRole.checkbox] or [enum@Gtk.AccessibleRole.menu_item_radio]
137// roles, depending on the action they are connected to.
138type PopoverMenu struct {
139 Popover
140}
141
142var xPopoverMenuGLibType func() types.GType
143
144func PopoverMenuGLibType() types.GType {
145 return xPopoverMenuGLibType()
146}
147
148func PopoverMenuNewFromInternalPtr(ptr uintptr) *PopoverMenu {
149 cls := &PopoverMenu{}
150 cls.Ptr = ptr
151 return cls
152}
153
154var xNewPopoverMenuFromModel func(uintptr) uintptr
155
156// Creates a `GtkPopoverMenu` and populates it according to @model.
157//
158// The created buttons are connected to actions found in the
159// `GtkApplicationWindow` to which the popover belongs - typically
160// by means of being attached to a widget that is contained within
161// the `GtkApplicationWindow`s widget hierarchy.
162//
163// Actions can also be added using [method@Gtk.Widget.insert_action_group]
164// on the menus attach widget or on any of its parent widgets.
165//
166// This function creates menus with sliding submenus.
167// See [ctor@Gtk.PopoverMenu.new_from_model_full] for a way
168// to control this.
169func NewPopoverMenuFromModel(ModelVar *gio.MenuModel) *PopoverMenu {
170 var cls *PopoverMenu
171
172 cret := xNewPopoverMenuFromModel(ModelVar.GoPointer())
173
174 if cret == 0 {
175 return nil
176 }
177 gobject.IncreaseRef(cret)
178 cls = &PopoverMenu{}
179 cls.Ptr = cret
180 return cls
181}
182
183var xNewPopoverMenuFromModelFull func(uintptr, PopoverMenuFlags) uintptr
184
185// Creates a `GtkPopoverMenu` and populates it according to @model.
186//
187// The created buttons are connected to actions found in the
188// action groups that are accessible from the parent widget.
189// This includes the `GtkApplicationWindow` to which the popover
190// belongs. Actions can also be added using [method@Gtk.Widget.insert_action_group]
191// on the parent widget or on any of its parent widgets.
192func NewPopoverMenuFromModelFull(ModelVar *gio.MenuModel, FlagsVar PopoverMenuFlags) *PopoverMenu {
193 var cls *PopoverMenu
194
195 cret := xNewPopoverMenuFromModelFull(ModelVar.GoPointer(), FlagsVar)
196
197 if cret == 0 {
198 return nil
199 }
200 gobject.IncreaseRef(cret)
201 cls = &PopoverMenu{}
202 cls.Ptr = cret
203 return cls
204}
205
206var xPopoverMenuAddChild func(uintptr, uintptr, string) bool
207
208// Adds a custom widget to a generated menu.
209//
210// For this to work, the menu model of @popover must have
211// an item with a `custom` attribute that matches @id.
212func (x *PopoverMenu) AddChild(ChildVar *Widget, IdVar string) bool {
213
214 cret := xPopoverMenuAddChild(x.GoPointer(), ChildVar.GoPointer(), IdVar)
215 return cret
216}
217
218var xPopoverMenuGetFlags func(uintptr) PopoverMenuFlags
219
220// Returns the flags that @popover uses to create/display a menu from its model.
221func (x *PopoverMenu) GetFlags() PopoverMenuFlags {
222
223 cret := xPopoverMenuGetFlags(x.GoPointer())
224 return cret
225}
226
227var xPopoverMenuGetMenuModel func(uintptr) uintptr
228
229// Returns the menu model used to populate the popover.
230func (x *PopoverMenu) GetMenuModel() *gio.MenuModel {
231 var cls *gio.MenuModel
232
233 cret := xPopoverMenuGetMenuModel(x.GoPointer())
234
235 if cret == 0 {
236 return nil
237 }
238 gobject.IncreaseRef(cret)
239 cls = &gio.MenuModel{}
240 cls.Ptr = cret
241 return cls
242}
243
244var xPopoverMenuRemoveChild func(uintptr, uintptr) bool
245
246// Removes a widget that has previously been added with
247// [method@Gtk.PopoverMenu.add_child]
248func (x *PopoverMenu) RemoveChild(ChildVar *Widget) bool {
249
250 cret := xPopoverMenuRemoveChild(x.GoPointer(), ChildVar.GoPointer())
251 return cret
252}
253
254var xPopoverMenuSetFlags func(uintptr, PopoverMenuFlags)
255
256// Sets the flags that @popover uses to create/display a menu from its model.
257//
258// If a model is set and the flags change, contents are rebuilt, so if setting
259// properties individually, set flags before model to avoid a redundant rebuild.
260func (x *PopoverMenu) SetFlags(FlagsVar PopoverMenuFlags) {
261
262 xPopoverMenuSetFlags(x.GoPointer(), FlagsVar)
263
264}
265
266var xPopoverMenuSetMenuModel func(uintptr, uintptr)
267
268// Sets a new menu model on @popover.
269//
270// The existing contents of @popover are removed, and
271// the @popover is populated with new contents according
272// to @model.
273func (x *PopoverMenu) SetMenuModel(ModelVar *gio.MenuModel) {
274
275 xPopoverMenuSetMenuModel(x.GoPointer(), ModelVar.GoPointer())
276
277}
278
279func (c *PopoverMenu) GoPointer() uintptr {
280 if c == nil {
281 return 0
282 }
283 return c.Ptr
284}
285
286func (c *PopoverMenu) SetGoPointer(ptr uintptr) {
287 c.Ptr = ptr
288}
289
290// SetPropertyVisibleSubmenu sets the "visible-submenu" property.
291// The name of the visible submenu.
292func (x *PopoverMenu) SetPropertyVisibleSubmenu(value string) {
293 var v gobject.Value
294 v.Init(gobject.TypeStringVal)
295 v.SetString(&value)
296 x.SetProperty("visible-submenu", &v)
297}
298
299// GetPropertyVisibleSubmenu gets the "visible-submenu" property.
300// The name of the visible submenu.
301func (x *PopoverMenu) GetPropertyVisibleSubmenu() string {
302 var v gobject.Value
303 x.GetProperty("visible-submenu", &v)
304 return v.GetString()
305}
306
307// Requests the user's screen reader to announce the given message.
308//
309// This kind of notification is useful for messages that
310// either have only a visual representation or that are not
311// exposed visually at all, e.g. a notification about a
312// successful operation.
313//
314// Also, by using this API, you can ensure that the message
315// does not interrupts the user's current screen reader output.
316func (x *PopoverMenu) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
317
318 XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
319
320}
321
322// Retrieves the accessible parent for an accessible object.
323//
324// This function returns `NULL` for top level widgets.
325func (x *PopoverMenu) GetAccessibleParent() *AccessibleBase {
326 var cls *AccessibleBase
327
328 cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
329
330 if cret == 0 {
331 return nil
332 }
333 cls = &AccessibleBase{}
334 cls.Ptr = cret
335 return cls
336}
337
338// Retrieves the accessible role of an accessible object.
339func (x *PopoverMenu) GetAccessibleRole() AccessibleRole {
340
341 cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
342 return cret
343}
344
345// Retrieves the implementation for the given accessible object.
346func (x *PopoverMenu) GetAtContext() *ATContext {
347 var cls *ATContext
348
349 cret := XGtkAccessibleGetAtContext(x.GoPointer())
350
351 if cret == 0 {
352 return nil
353 }
354 cls = &ATContext{}
355 cls.Ptr = cret
356 return cls
357}
358
359// Queries the coordinates and dimensions of this accessible
360//
361// This functionality can be overridden by `GtkAccessible`
362// implementations, e.g. to get the bounds from an ignored
363// child widget.
364func (x *PopoverMenu) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
365
366 cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
367 return cret
368}
369
370// Retrieves the first accessible child of an accessible object.
371func (x *PopoverMenu) GetFirstAccessibleChild() *AccessibleBase {
372 var cls *AccessibleBase
373
374 cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
375
376 if cret == 0 {
377 return nil
378 }
379 cls = &AccessibleBase{}
380 cls.Ptr = cret
381 return cls
382}
383
384// Retrieves the next accessible sibling of an accessible object
385func (x *PopoverMenu) GetNextAccessibleSibling() *AccessibleBase {
386 var cls *AccessibleBase
387
388 cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
389
390 if cret == 0 {
391 return nil
392 }
393 cls = &AccessibleBase{}
394 cls.Ptr = cret
395 return cls
396}
397
398// Queries a platform state, such as focus.
399//
400// This functionality can be overridden by `GtkAccessible`
401// implementations, e.g. to get platform state from an ignored
402// child widget, as is the case for `GtkText` wrappers.
403func (x *PopoverMenu) GetPlatformState(StateVar AccessiblePlatformState) bool {
404
405 cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
406 return cret
407}
408
409// Resets the accessible property to its default value.
410func (x *PopoverMenu) ResetProperty(PropertyVar AccessibleProperty) {
411
412 XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
413
414}
415
416// Resets the accessible relation to its default value.
417func (x *PopoverMenu) ResetRelation(RelationVar AccessibleRelation) {
418
419 XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
420
421}
422
423// Resets the accessible state to its default value.
424func (x *PopoverMenu) ResetState(StateVar AccessibleState) {
425
426 XGtkAccessibleResetState(x.GoPointer(), StateVar)
427
428}
429
430// Sets the parent and sibling of an accessible object.
431//
432// This function is meant to be used by accessible implementations that are
433// not part of the widget hierarchy, and but act as a logical bridge between
434// widgets. For instance, if a widget creates an object that holds metadata
435// for each child, and you want that object to implement the `GtkAccessible`
436// interface, you will use this function to ensure that the parent of each
437// child widget is the metadata object, and the parent of each metadata
438// object is the container widget.
439func (x *PopoverMenu) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
440
441 XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
442
443}
444
445// Updates the next accessible sibling.
446//
447// That might be useful when a new child of a custom accessible
448// is created, and it needs to be linked to a previous child.
449func (x *PopoverMenu) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
450
451 XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
452
453}
454
455// Informs ATs that the platform state has changed.
456//
457// This function should be used by `GtkAccessible` implementations that
458// have a platform state but are not widgets. Widgets handle platform
459// states automatically.
460func (x *PopoverMenu) UpdatePlatformState(StateVar AccessiblePlatformState) {
461
462 XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
463
464}
465
466// Updates a list of accessible properties.
467//
468// See the [enum@Gtk.AccessibleProperty] documentation for the
469// value types of accessible properties.
470//
471// This function should be called by `GtkWidget` types whenever
472// an accessible property change must be communicated to assistive
473// technologies.
474//
475// Example:
476// ```c
477// value = gtk_adjustment_get_value (adjustment);
478// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
479//
480// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
481// -1);
482//
483// ```
484func (x *PopoverMenu) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
485
486 XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
487
488}
489
490// Updates an array of accessible properties.
491//
492// This function should be called by `GtkWidget` types whenever an accessible
493// property change must be communicated to assistive technologies.
494//
495// This function is meant to be used by language bindings.
496func (x *PopoverMenu) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
497
498 XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
499
500}
501
502// Updates a list of accessible relations.
503//
504// This function should be called by `GtkWidget` types whenever an accessible
505// relation change must be communicated to assistive technologies.
506//
507// If the [enum@Gtk.AccessibleRelation] requires a list of references,
508// you should pass each reference individually, followed by `NULL`, e.g.
509//
510// ```c
511// gtk_accessible_update_relation (accessible,
512//
513// GTK_ACCESSIBLE_RELATION_CONTROLS,
514// ref1, NULL,
515// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
516// ref1, ref2, ref3, NULL,
517// -1);
518//
519// ```
520func (x *PopoverMenu) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
521
522 XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
523
524}
525
526// Updates an array of accessible relations.
527//
528// This function should be called by `GtkWidget` types whenever an accessible
529// relation change must be communicated to assistive technologies.
530//
531// This function is meant to be used by language bindings.
532func (x *PopoverMenu) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
533
534 XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
535
536}
537
538// Updates a list of accessible states.
539//
540// See the [enum@Gtk.AccessibleState] documentation for the
541// value types of accessible states.
542//
543// This function should be called by `GtkWidget` types whenever
544// an accessible state change must be communicated to assistive
545// technologies.
546//
547// Example:
548//
549// ```c
550// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
551// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
552//
553// GTK_ACCESSIBLE_STATE_CHECKED, value,
554// -1);
555//
556// ```
557func (x *PopoverMenu) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
558
559 XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
560
561}
562
563// Updates an array of accessible states.
564//
565// This function should be called by `GtkWidget` types whenever an accessible
566// state change must be communicated to assistive technologies.
567//
568// This function is meant to be used by language bindings.
569func (x *PopoverMenu) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
570
571 XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
572
573}
574
575// Gets the ID of the @buildable object.
576//
577// `GtkBuilder` sets the name based on the ID attribute
578// of the `<object>` tag used to construct the @buildable.
579func (x *PopoverMenu) GetBuildableId() string {
580
581 cret := XGtkBuildableGetBuildableId(x.GoPointer())
582 return cret
583}
584
585// Returns the renderer that is used for this `GtkNative`.
586func (x *PopoverMenu) GetRenderer() *gsk.Renderer {
587 var cls *gsk.Renderer
588
589 cret := XGtkNativeGetRenderer(x.GoPointer())
590
591 if cret == 0 {
592 return nil
593 }
594 gobject.IncreaseRef(cret)
595 cls = &gsk.Renderer{}
596 cls.Ptr = cret
597 return cls
598}
599
600// Returns the surface of this `GtkNative`.
601func (x *PopoverMenu) GetSurface() *gdk.Surface {
602 var cls *gdk.Surface
603
604 cret := XGtkNativeGetSurface(x.GoPointer())
605
606 if cret == 0 {
607 return nil
608 }
609 gobject.IncreaseRef(cret)
610 cls = &gdk.Surface{}
611 cls.Ptr = cret
612 return cls
613}
614
615// Retrieves the surface transform of @self.
616//
617// This is the translation from @self's surface coordinates into
618// @self's widget coordinates.
619func (x *PopoverMenu) GetSurfaceTransform(XVar *float64, YVar *float64) {
620
621 XGtkNativeGetSurfaceTransform(x.GoPointer(), XVar, YVar)
622
623}
624
625// Realizes a `GtkNative`.
626//
627// This should only be used by subclasses.
628func (x *PopoverMenu) Realize() {
629
630 XGtkNativeRealize(x.GoPointer())
631
632}
633
634// Unrealizes a `GtkNative`.
635//
636// This should only be used by subclasses.
637func (x *PopoverMenu) Unrealize() {
638
639 XGtkNativeUnrealize(x.GoPointer())
640
641}
642
643func init() {
644 core.SetPackageName("GTK", "gtk4")
645 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
646 var libs []uintptr
647 for _, libPath := range core.GetPaths("GTK") {
648 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
649 if err != nil {
650 panic(err)
651 }
652 libs = append(libs, lib)
653 }
654
655 core.PuregoSafeRegister(&xPopoverMenuGLibType, libs, "gtk_popover_menu_get_type")
656
657 core.PuregoSafeRegister(&xNewPopoverMenuFromModel, libs, "gtk_popover_menu_new_from_model")
658 core.PuregoSafeRegister(&xNewPopoverMenuFromModelFull, libs, "gtk_popover_menu_new_from_model_full")
659
660 core.PuregoSafeRegister(&xPopoverMenuAddChild, libs, "gtk_popover_menu_add_child")
661 core.PuregoSafeRegister(&xPopoverMenuGetFlags, libs, "gtk_popover_menu_get_flags")
662 core.PuregoSafeRegister(&xPopoverMenuGetMenuModel, libs, "gtk_popover_menu_get_menu_model")
663 core.PuregoSafeRegister(&xPopoverMenuRemoveChild, libs, "gtk_popover_menu_remove_child")
664 core.PuregoSafeRegister(&xPopoverMenuSetFlags, libs, "gtk_popover_menu_set_flags")
665 core.PuregoSafeRegister(&xPopoverMenuSetMenuModel, libs, "gtk_popover_menu_set_menu_model")
666
667}