1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
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/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type PopupInterface struct {
16 _ structs.HostLayout
17}
18
19func (x *PopupInterface) GoPointer() uintptr {
20 return uintptr(unsafe.Pointer(x))
21}
22
23// A surface that is attached to another surface.
24//
25// The `GdkPopup` is positioned relative to its parent surface.
26//
27// `GdkPopup`s are typically used to implement menus and similar popups.
28// They can be modal, which is indicated by the [property@Gdk.Popup:autohide]
29// property.
30type Popup interface {
31 GoPointer() uintptr
32 SetGoPointer(uintptr)
33 GetAutohide() bool
34 GetParent() *Surface
35 GetPositionX() int
36 GetPositionY() int
37 GetRectAnchor() Gravity
38 GetSurfaceAnchor() Gravity
39 Present(WidthVar int, HeightVar int, LayoutVar *PopupLayout) bool
40}
41
42var xPopupGLibType func() types.GType
43
44func PopupGLibType() types.GType {
45 return xPopupGLibType()
46}
47
48type PopupBase struct {
49 Ptr uintptr
50}
51
52func (x *PopupBase) GoPointer() uintptr {
53 if x == nil {
54 return 0
55 }
56 return x.Ptr
57}
58
59func (x *PopupBase) SetGoPointer(ptr uintptr) {
60 x.Ptr = ptr
61}
62
63// Returns whether this popup is set to hide on outside clicks.
64func (x *PopupBase) GetAutohide() bool {
65
66 cret := XGdkPopupGetAutohide(x.GoPointer())
67 return cret
68}
69
70// Returns the parent surface of a popup.
71func (x *PopupBase) GetParent() *Surface {
72 var cls *Surface
73
74 cret := XGdkPopupGetParent(x.GoPointer())
75
76 if cret == 0 {
77 return nil
78 }
79 gobject.IncreaseRef(cret)
80 cls = &Surface{}
81 cls.Ptr = cret
82 return cls
83}
84
85// Obtains the position of the popup relative to its parent.
86func (x *PopupBase) GetPositionX() int {
87
88 cret := XGdkPopupGetPositionX(x.GoPointer())
89 return cret
90}
91
92// Obtains the position of the popup relative to its parent.
93func (x *PopupBase) GetPositionY() int {
94
95 cret := XGdkPopupGetPositionY(x.GoPointer())
96 return cret
97}
98
99// Gets the current popup rectangle anchor.
100//
101// The value returned may change after calling [method@Gdk.Popup.present],
102// or after the [signal@Gdk.Surface::layout] signal is emitted.
103func (x *PopupBase) GetRectAnchor() Gravity {
104
105 cret := XGdkPopupGetRectAnchor(x.GoPointer())
106 return cret
107}
108
109// Gets the current popup surface anchor.
110//
111// The value returned may change after calling [method@Gdk.Popup.present],
112// or after the [signal@Gdk.Surface::layout] signal is emitted.
113func (x *PopupBase) GetSurfaceAnchor() Gravity {
114
115 cret := XGdkPopupGetSurfaceAnchor(x.GoPointer())
116 return cret
117}
118
119// Present @popup after having processed the `GdkPopupLayout` rules.
120//
121// If the popup was previously not showing, it will be shown,
122// otherwise it will change position according to @layout.
123//
124// After calling this function, the result should be handled in response
125// to the [signal@Gdk.Surface::layout] signal being emitted. The resulting
126// popup position can be queried using [method@Gdk.Popup.get_position_x],
127// [method@Gdk.Popup.get_position_y], and the resulting size will be sent as
128// parameters in the layout signal. Use [method@Gdk.Popup.get_rect_anchor]
129// and [method@Gdk.Popup.get_surface_anchor] to get the resulting anchors.
130//
131// Presenting may fail, for example if the @popup is set to autohide
132// and is immediately hidden upon being presented. If presenting failed,
133// the [signal@Gdk.Surface::layout] signal will not me emitted.
134func (x *PopupBase) Present(WidthVar int, HeightVar int, LayoutVar *PopupLayout) bool {
135
136 cret := XGdkPopupPresent(x.GoPointer(), WidthVar, HeightVar, LayoutVar)
137 return cret
138}
139
140// SetPropertyAutohide sets the "autohide" property.
141// Whether to hide on outside clicks.
142func (x *PopupBase) SetPropertyAutohide(value bool) {
143 obj := gobject.Object{}
144 obj.Ptr = x.GoPointer()
145 var v gobject.Value
146 v.Init(gobject.TypeBooleanVal)
147 v.SetBoolean(value)
148 obj.SetProperty("autohide", &v)
149}
150
151// GetPropertyAutohide gets the "autohide" property.
152// Whether to hide on outside clicks.
153func (x *PopupBase) GetPropertyAutohide() bool {
154 obj := gobject.Object{}
155 obj.Ptr = x.GoPointer()
156 var v gobject.Value
157 obj.GetProperty("autohide", &v)
158 return v.GetBoolean()
159}
160
161var XGdkPopupGetAutohide func(uintptr) bool
162var XGdkPopupGetParent func(uintptr) uintptr
163var XGdkPopupGetPositionX func(uintptr) int
164var XGdkPopupGetPositionY func(uintptr) int
165var XGdkPopupGetRectAnchor func(uintptr) Gravity
166var XGdkPopupGetSurfaceAnchor func(uintptr) Gravity
167var XGdkPopupPresent func(uintptr, int, int, *PopupLayout) bool
168
169func init() {
170 core.SetPackageName("GDK", "gtk4")
171 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
172 var libs []uintptr
173 for _, libPath := range core.GetPaths("GDK") {
174 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
175 if err != nil {
176 panic(err)
177 }
178 libs = append(libs, lib)
179 }
180
181 core.PuregoSafeRegister(&xPopupGLibType, libs, "gdk_popup_get_type")
182
183 core.PuregoSafeRegister(&XGdkPopupGetAutohide, libs, "gdk_popup_get_autohide")
184 core.PuregoSafeRegister(&XGdkPopupGetParent, libs, "gdk_popup_get_parent")
185 core.PuregoSafeRegister(&XGdkPopupGetPositionX, libs, "gdk_popup_get_position_x")
186 core.PuregoSafeRegister(&XGdkPopupGetPositionY, libs, "gdk_popup_get_position_y")
187 core.PuregoSafeRegister(&XGdkPopupGetRectAnchor, libs, "gdk_popup_get_rect_anchor")
188 core.PuregoSafeRegister(&XGdkPopupGetSurfaceAnchor, libs, "gdk_popup_get_surface_anchor")
189 core.PuregoSafeRegister(&XGdkPopupPresent, libs, "gdk_popup_present")
190
191}