1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
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/gdk"
12 "github.com/bnema/puregotk/v4/gio"
13 "github.com/bnema/puregotk/v4/glib"
14 "github.com/bnema/puregotk/v4/gobject"
15 "github.com/bnema/puregotk/v4/gobject/types"
16)
17
18type ColorDialogClass struct {
19 _ structs.HostLayout
20
21 ParentClass gobject.ObjectClass
22}
23
24func (x *ColorDialogClass) GoPointer() uintptr {
25 return uintptr(unsafe.Pointer(x))
26}
27
28// Asynchronous API to present a color chooser dialog.
29//
30// `GtkColorDialog` collects the arguments that are needed to present
31// the dialog to the user, such as a title for the dialog and whether
32// it should be modal.
33//
34// The dialog is shown with the [method@Gtk.ColorDialog.choose_rgba]
35// function.
36//
37// See [class@Gtk.ColorDialogButton] for a convenient control
38// that uses `GtkColorDialog` and presents the results.
39type ColorDialog struct {
40 gobject.Object
41}
42
43var xColorDialogGLibType func() types.GType
44
45func ColorDialogGLibType() types.GType {
46 return xColorDialogGLibType()
47}
48
49func ColorDialogNewFromInternalPtr(ptr uintptr) *ColorDialog {
50 cls := &ColorDialog{}
51 cls.Ptr = ptr
52 return cls
53}
54
55var xNewColorDialog func() uintptr
56
57// Creates a new `GtkColorDialog` object.
58func NewColorDialog() *ColorDialog {
59 var cls *ColorDialog
60
61 cret := xNewColorDialog()
62
63 if cret == 0 {
64 return nil
65 }
66 cls = &ColorDialog{}
67 cls.Ptr = cret
68 return cls
69}
70
71var xColorDialogChooseRgba func(uintptr, uintptr, *gdk.RGBA, uintptr, uintptr, uintptr)
72
73// Presents a color chooser dialog to the user.
74func (x *ColorDialog) ChooseRgba(ParentVar *Window, InitialColorVar *gdk.RGBA, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
75
76 var CallbackVarRef uintptr
77 if CallbackVar != nil {
78 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
79 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
80 CallbackVarRef = cbRefPtr
81 } else {
82 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
83 cbFn := *CallbackVar
84 cbFn(arg0, arg1, arg2)
85 }
86 CallbackVarRef = purego.NewCallback(fcb)
87 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
88 }
89 }
90
91 xColorDialogChooseRgba(x.GoPointer(), ParentVar.GoPointer(), InitialColorVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
92
93}
94
95var xColorDialogChooseRgbaFinish func(uintptr, uintptr, **glib.Error) *gdk.RGBA
96
97// Finishes the [method@Gtk.ColorDialog.choose_rgba] call
98//
99// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
100// error if the user cancels the dialog.
101func (x *ColorDialog) ChooseRgbaFinish(ResultVar gio.AsyncResult) (*gdk.RGBA, error) {
102 var cerr *glib.Error
103
104 cret := xColorDialogChooseRgbaFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
105 if cerr == nil {
106 return cret, nil
107 }
108 return cret, cerr
109
110}
111
112var xColorDialogGetModal func(uintptr) bool
113
114// Returns whether the color chooser dialog
115// blocks interaction with the parent window
116// while it is presented.
117func (x *ColorDialog) GetModal() bool {
118
119 cret := xColorDialogGetModal(x.GoPointer())
120 return cret
121}
122
123var xColorDialogGetTitle func(uintptr) string
124
125// Returns the title that will be shown on the
126// color chooser dialog.
127func (x *ColorDialog) GetTitle() string {
128
129 cret := xColorDialogGetTitle(x.GoPointer())
130 return cret
131}
132
133var xColorDialogGetWithAlpha func(uintptr) bool
134
135// Returns whether colors may have alpha.
136func (x *ColorDialog) GetWithAlpha() bool {
137
138 cret := xColorDialogGetWithAlpha(x.GoPointer())
139 return cret
140}
141
142var xColorDialogSetModal func(uintptr, bool)
143
144// Sets whether the color chooser dialog
145// blocks interaction with the parent window
146// while it is presented.
147func (x *ColorDialog) SetModal(ModalVar bool) {
148
149 xColorDialogSetModal(x.GoPointer(), ModalVar)
150
151}
152
153var xColorDialogSetTitle func(uintptr, string)
154
155// Sets the title that will be shown on the
156// color chooser dialog.
157func (x *ColorDialog) SetTitle(TitleVar string) {
158
159 xColorDialogSetTitle(x.GoPointer(), TitleVar)
160
161}
162
163var xColorDialogSetWithAlpha func(uintptr, bool)
164
165// Sets whether colors may have alpha.
166func (x *ColorDialog) SetWithAlpha(WithAlphaVar bool) {
167
168 xColorDialogSetWithAlpha(x.GoPointer(), WithAlphaVar)
169
170}
171
172func (c *ColorDialog) GoPointer() uintptr {
173 if c == nil {
174 return 0
175 }
176 return c.Ptr
177}
178
179func (c *ColorDialog) SetGoPointer(ptr uintptr) {
180 c.Ptr = ptr
181}
182
183// SetPropertyModal sets the "modal" property.
184// Whether the color chooser dialog is modal.
185func (x *ColorDialog) SetPropertyModal(value bool) {
186 var v gobject.Value
187 v.Init(gobject.TypeBooleanVal)
188 v.SetBoolean(value)
189 x.SetProperty("modal", &v)
190}
191
192// GetPropertyModal gets the "modal" property.
193// Whether the color chooser dialog is modal.
194func (x *ColorDialog) GetPropertyModal() bool {
195 var v gobject.Value
196 x.GetProperty("modal", &v)
197 return v.GetBoolean()
198}
199
200// SetPropertyTitle sets the "title" property.
201// A title that may be shown on the color chooser dialog.
202func (x *ColorDialog) SetPropertyTitle(value string) {
203 var v gobject.Value
204 v.Init(gobject.TypeStringVal)
205 v.SetString(&value)
206 x.SetProperty("title", &v)
207}
208
209// GetPropertyTitle gets the "title" property.
210// A title that may be shown on the color chooser dialog.
211func (x *ColorDialog) GetPropertyTitle() string {
212 var v gobject.Value
213 x.GetProperty("title", &v)
214 return v.GetString()
215}
216
217// SetPropertyWithAlpha sets the "with-alpha" property.
218// Whether colors may have alpha (translucency).
219//
220// When with-alpha is false, the color that is selected
221// will be forced to have alpha == 1.
222func (x *ColorDialog) SetPropertyWithAlpha(value bool) {
223 var v gobject.Value
224 v.Init(gobject.TypeBooleanVal)
225 v.SetBoolean(value)
226 x.SetProperty("with-alpha", &v)
227}
228
229// GetPropertyWithAlpha gets the "with-alpha" property.
230// Whether colors may have alpha (translucency).
231//
232// When with-alpha is false, the color that is selected
233// will be forced to have alpha == 1.
234func (x *ColorDialog) GetPropertyWithAlpha() bool {
235 var v gobject.Value
236 x.GetProperty("with-alpha", &v)
237 return v.GetBoolean()
238}
239
240func init() {
241 core.SetPackageName("GTK", "gtk4")
242 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
243 var libs []uintptr
244 for _, libPath := range core.GetPaths("GTK") {
245 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
246 if err != nil {
247 panic(err)
248 }
249 libs = append(libs, lib)
250 }
251
252 core.PuregoSafeRegister(&xColorDialogGLibType, libs, "gtk_color_dialog_get_type")
253
254 core.PuregoSafeRegister(&xNewColorDialog, libs, "gtk_color_dialog_new")
255
256 core.PuregoSafeRegister(&xColorDialogChooseRgba, libs, "gtk_color_dialog_choose_rgba")
257 core.PuregoSafeRegister(&xColorDialogChooseRgbaFinish, libs, "gtk_color_dialog_choose_rgba_finish")
258 core.PuregoSafeRegister(&xColorDialogGetModal, libs, "gtk_color_dialog_get_modal")
259 core.PuregoSafeRegister(&xColorDialogGetTitle, libs, "gtk_color_dialog_get_title")
260 core.PuregoSafeRegister(&xColorDialogGetWithAlpha, libs, "gtk_color_dialog_get_with_alpha")
261 core.PuregoSafeRegister(&xColorDialogSetModal, libs, "gtk_color_dialog_set_modal")
262 core.PuregoSafeRegister(&xColorDialogSetTitle, libs, "gtk_color_dialog_set_title")
263 core.PuregoSafeRegister(&xColorDialogSetWithAlpha, libs, "gtk_color_dialog_set_with_alpha")
264
265}