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/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15 "github.com/bnema/puregotk/v4/pango"
16)
17
18type FontDialogClass struct {
19 _ structs.HostLayout
20
21 ParentClass gobject.ObjectClass
22}
23
24func (x *FontDialogClass) GoPointer() uintptr {
25 return uintptr(unsafe.Pointer(x))
26}
27
28// Asynchronous API to present a font chooser dialog.
29//
30// `GtkFontDialog` 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.FontDialog.choose_font]
35// function or its variants.
36//
37// See [class@Gtk.FontDialogButton] for a convenient control
38// that uses `GtkFontDialog` and presents the results.
39type FontDialog struct {
40 gobject.Object
41}
42
43var xFontDialogGLibType func() types.GType
44
45func FontDialogGLibType() types.GType {
46 return xFontDialogGLibType()
47}
48
49func FontDialogNewFromInternalPtr(ptr uintptr) *FontDialog {
50 cls := &FontDialog{}
51 cls.Ptr = ptr
52 return cls
53}
54
55var xNewFontDialog func() uintptr
56
57// Creates a new `GtkFontDialog` object.
58func NewFontDialog() *FontDialog {
59 var cls *FontDialog
60
61 cret := xNewFontDialog()
62
63 if cret == 0 {
64 return nil
65 }
66 cls = &FontDialog{}
67 cls.Ptr = cret
68 return cls
69}
70
71var xFontDialogChooseFace func(uintptr, uintptr, uintptr, uintptr, uintptr, uintptr)
72
73// Presents a font chooser dialog to the user.
74//
75// The font chooser dialog will be set up for selecting a font face.
76//
77// A font face represents a font family and style, but no specific font size.
78func (x *FontDialog) ChooseFace(ParentVar *Window, InitialValueVar *pango.FontFace, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
79
80 var CallbackVarRef uintptr
81 if CallbackVar != nil {
82 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
83 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
84 CallbackVarRef = cbRefPtr
85 } else {
86 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
87 cbFn := *CallbackVar
88 cbFn(arg0, arg1, arg2)
89 }
90 CallbackVarRef = purego.NewCallback(fcb)
91 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
92 }
93 }
94
95 xFontDialogChooseFace(x.GoPointer(), ParentVar.GoPointer(), InitialValueVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
96
97}
98
99var xFontDialogChooseFaceFinish func(uintptr, uintptr, **glib.Error) uintptr
100
101// Finishes the [method@Gtk.FontDialog.choose_face] call.
102//
103// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
104// error if the user cancels the dialog.
105func (x *FontDialog) ChooseFaceFinish(ResultVar gio.AsyncResult) (*pango.FontFace, error) {
106 var cls *pango.FontFace
107 var cerr *glib.Error
108
109 cret := xFontDialogChooseFaceFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
110
111 if cret == 0 {
112 return nil, cerr
113 }
114 cls = &pango.FontFace{}
115 cls.Ptr = cret
116 if cerr == nil {
117 return cls, nil
118 }
119 return cls, cerr
120
121}
122
123var xFontDialogChooseFamily func(uintptr, uintptr, uintptr, uintptr, uintptr, uintptr)
124
125// Presents a font chooser dialog to the user.
126//
127// The font chooser dialog will be set up for selecting a font family.
128func (x *FontDialog) ChooseFamily(ParentVar *Window, InitialValueVar *pango.FontFamily, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
129
130 var CallbackVarRef uintptr
131 if CallbackVar != nil {
132 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
133 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
134 CallbackVarRef = cbRefPtr
135 } else {
136 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
137 cbFn := *CallbackVar
138 cbFn(arg0, arg1, arg2)
139 }
140 CallbackVarRef = purego.NewCallback(fcb)
141 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
142 }
143 }
144
145 xFontDialogChooseFamily(x.GoPointer(), ParentVar.GoPointer(), InitialValueVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
146
147}
148
149var xFontDialogChooseFamilyFinish func(uintptr, uintptr, **glib.Error) uintptr
150
151// Finishes the [method@Gtk.FontDialog.choose_family] call.
152//
153// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
154// error if the user cancels the dialog.
155func (x *FontDialog) ChooseFamilyFinish(ResultVar gio.AsyncResult) (*pango.FontFamily, error) {
156 var cls *pango.FontFamily
157 var cerr *glib.Error
158
159 cret := xFontDialogChooseFamilyFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
160
161 if cret == 0 {
162 return nil, cerr
163 }
164 cls = &pango.FontFamily{}
165 cls.Ptr = cret
166 if cerr == nil {
167 return cls, nil
168 }
169 return cls, cerr
170
171}
172
173var xFontDialogChooseFont func(uintptr, uintptr, *pango.FontDescription, uintptr, uintptr, uintptr)
174
175// Presents a font chooser dialog to the user.
176//
177// The font chooser dialog will be set up for selecting a font.
178//
179// If you want to let the user select font features as well,
180// use [method@Gtk.FontDialog.choose_font_and_features] instead.
181func (x *FontDialog) ChooseFont(ParentVar *Window, InitialValueVar *pango.FontDescription, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
182
183 var CallbackVarRef uintptr
184 if CallbackVar != nil {
185 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
186 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
187 CallbackVarRef = cbRefPtr
188 } else {
189 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
190 cbFn := *CallbackVar
191 cbFn(arg0, arg1, arg2)
192 }
193 CallbackVarRef = purego.NewCallback(fcb)
194 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
195 }
196 }
197
198 xFontDialogChooseFont(x.GoPointer(), ParentVar.GoPointer(), InitialValueVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
199
200}
201
202var xFontDialogChooseFontAndFeatures func(uintptr, uintptr, *pango.FontDescription, uintptr, uintptr, uintptr)
203
204// Presents a font chooser dialog to the user.
205//
206// The font chooser dialog will be set up for selecting a font
207// and specify features for the selected font.
208//
209// Font features affect how the font is rendered, for example
210// enabling glyph variants or ligatures.
211func (x *FontDialog) ChooseFontAndFeatures(ParentVar *Window, InitialValueVar *pango.FontDescription, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
212
213 var CallbackVarRef uintptr
214 if CallbackVar != nil {
215 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
216 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
217 CallbackVarRef = cbRefPtr
218 } else {
219 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
220 cbFn := *CallbackVar
221 cbFn(arg0, arg1, arg2)
222 }
223 CallbackVarRef = purego.NewCallback(fcb)
224 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
225 }
226 }
227
228 xFontDialogChooseFontAndFeatures(x.GoPointer(), ParentVar.GoPointer(), InitialValueVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
229
230}
231
232var xFontDialogChooseFontAndFeaturesFinish func(uintptr, uintptr, **pango.FontDescription, *string, **pango.Language, **glib.Error) bool
233
234// Finishes the [method@Gtk.FontDialog.choose_font_and_features] call.
235//
236// The selected font and features are returned in @font_desc and
237// @font_features.
238//
239// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
240// error if the user cancels the dialog.
241func (x *FontDialog) ChooseFontAndFeaturesFinish(ResultVar gio.AsyncResult, FontDescVar **pango.FontDescription, FontFeaturesVar *string, LanguageVar **pango.Language) (bool, error) {
242 var cerr *glib.Error
243
244 cret := xFontDialogChooseFontAndFeaturesFinish(x.GoPointer(), ResultVar.GoPointer(), FontDescVar, FontFeaturesVar, LanguageVar, &cerr)
245 if cerr == nil {
246 return cret, nil
247 }
248 return cret, cerr
249
250}
251
252var xFontDialogChooseFontFinish func(uintptr, uintptr, **glib.Error) *pango.FontDescription
253
254// Finishes the [method@Gtk.FontDialog.choose_font] call.
255//
256// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
257// error if the user cancels the dialog.
258func (x *FontDialog) ChooseFontFinish(ResultVar gio.AsyncResult) (*pango.FontDescription, error) {
259 var cerr *glib.Error
260
261 cret := xFontDialogChooseFontFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
262 if cerr == nil {
263 return cret, nil
264 }
265 return cret, cerr
266
267}
268
269var xFontDialogGetFilter func(uintptr) uintptr
270
271// Returns the filter that decides which fonts to display
272// in the font chooser dialog.
273func (x *FontDialog) GetFilter() *Filter {
274 var cls *Filter
275
276 cret := xFontDialogGetFilter(x.GoPointer())
277
278 if cret == 0 {
279 return nil
280 }
281 gobject.IncreaseRef(cret)
282 cls = &Filter{}
283 cls.Ptr = cret
284 return cls
285}
286
287var xFontDialogGetFontMap func(uintptr) uintptr
288
289// Returns the fontmap from which fonts are selected,
290// or `NULL` for the default fontmap.
291func (x *FontDialog) GetFontMap() *pango.FontMap {
292 var cls *pango.FontMap
293
294 cret := xFontDialogGetFontMap(x.GoPointer())
295
296 if cret == 0 {
297 return nil
298 }
299 gobject.IncreaseRef(cret)
300 cls = &pango.FontMap{}
301 cls.Ptr = cret
302 return cls
303}
304
305var xFontDialogGetLanguage func(uintptr) *pango.Language
306
307// Returns the language for which font features are applied.
308func (x *FontDialog) GetLanguage() *pango.Language {
309
310 cret := xFontDialogGetLanguage(x.GoPointer())
311 return cret
312}
313
314var xFontDialogGetModal func(uintptr) bool
315
316// Returns whether the font chooser dialog blocks interaction
317// with the parent window while it is presented.
318func (x *FontDialog) GetModal() bool {
319
320 cret := xFontDialogGetModal(x.GoPointer())
321 return cret
322}
323
324var xFontDialogGetTitle func(uintptr) string
325
326// Returns the title that will be shown on the font chooser dialog.
327func (x *FontDialog) GetTitle() string {
328
329 cret := xFontDialogGetTitle(x.GoPointer())
330 return cret
331}
332
333var xFontDialogSetFilter func(uintptr, uintptr)
334
335// Adds a filter that decides which fonts to display
336// in the font chooser dialog.
337//
338// The filter must be able to handle both `PangoFontFamily`
339// and `PangoFontFace` objects.
340func (x *FontDialog) SetFilter(FilterVar *Filter) {
341
342 xFontDialogSetFilter(x.GoPointer(), FilterVar.GoPointer())
343
344}
345
346var xFontDialogSetFontMap func(uintptr, uintptr)
347
348// Sets the fontmap from which fonts are selected.
349//
350// If @fontmap is `NULL`, the default fontmap is used.
351func (x *FontDialog) SetFontMap(FontmapVar *pango.FontMap) {
352
353 xFontDialogSetFontMap(x.GoPointer(), FontmapVar.GoPointer())
354
355}
356
357var xFontDialogSetLanguage func(uintptr, *pango.Language)
358
359// Sets the language for which font features are applied.
360func (x *FontDialog) SetLanguage(LanguageVar *pango.Language) {
361
362 xFontDialogSetLanguage(x.GoPointer(), LanguageVar)
363
364}
365
366var xFontDialogSetModal func(uintptr, bool)
367
368// Sets whether the font chooser dialog blocks interaction
369// with the parent window while it is presented.
370func (x *FontDialog) SetModal(ModalVar bool) {
371
372 xFontDialogSetModal(x.GoPointer(), ModalVar)
373
374}
375
376var xFontDialogSetTitle func(uintptr, string)
377
378// Sets the title that will be shown on the font chooser dialog.
379func (x *FontDialog) SetTitle(TitleVar string) {
380
381 xFontDialogSetTitle(x.GoPointer(), TitleVar)
382
383}
384
385func (c *FontDialog) GoPointer() uintptr {
386 if c == nil {
387 return 0
388 }
389 return c.Ptr
390}
391
392func (c *FontDialog) SetGoPointer(ptr uintptr) {
393 c.Ptr = ptr
394}
395
396// SetPropertyLanguage sets the "language" property.
397// The language for which the font features are selected.
398func (x *FontDialog) SetPropertyLanguage(value uintptr) {
399 var v gobject.Value
400 v.Init(gobject.TypePointerVal)
401 v.SetPointer(value)
402 x.SetProperty("language", &v)
403}
404
405// GetPropertyLanguage gets the "language" property.
406// The language for which the font features are selected.
407func (x *FontDialog) GetPropertyLanguage() uintptr {
408 var v gobject.Value
409 x.GetProperty("language", &v)
410 return v.GetPointer()
411}
412
413// SetPropertyModal sets the "modal" property.
414// Whether the font chooser dialog is modal.
415func (x *FontDialog) SetPropertyModal(value bool) {
416 var v gobject.Value
417 v.Init(gobject.TypeBooleanVal)
418 v.SetBoolean(value)
419 x.SetProperty("modal", &v)
420}
421
422// GetPropertyModal gets the "modal" property.
423// Whether the font chooser dialog is modal.
424func (x *FontDialog) GetPropertyModal() bool {
425 var v gobject.Value
426 x.GetProperty("modal", &v)
427 return v.GetBoolean()
428}
429
430// SetPropertyTitle sets the "title" property.
431// A title that may be shown on the font chooser
432// dialog that is presented by [method@Gtk.FontDialog.choose_font].
433func (x *FontDialog) SetPropertyTitle(value string) {
434 var v gobject.Value
435 v.Init(gobject.TypeStringVal)
436 v.SetString(&value)
437 x.SetProperty("title", &v)
438}
439
440// GetPropertyTitle gets the "title" property.
441// A title that may be shown on the font chooser
442// dialog that is presented by [method@Gtk.FontDialog.choose_font].
443func (x *FontDialog) GetPropertyTitle() string {
444 var v gobject.Value
445 x.GetProperty("title", &v)
446 return v.GetString()
447}
448
449func init() {
450 core.SetPackageName("GTK", "gtk4")
451 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
452 var libs []uintptr
453 for _, libPath := range core.GetPaths("GTK") {
454 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
455 if err != nil {
456 panic(err)
457 }
458 libs = append(libs, lib)
459 }
460
461 core.PuregoSafeRegister(&xFontDialogGLibType, libs, "gtk_font_dialog_get_type")
462
463 core.PuregoSafeRegister(&xNewFontDialog, libs, "gtk_font_dialog_new")
464
465 core.PuregoSafeRegister(&xFontDialogChooseFace, libs, "gtk_font_dialog_choose_face")
466 core.PuregoSafeRegister(&xFontDialogChooseFaceFinish, libs, "gtk_font_dialog_choose_face_finish")
467 core.PuregoSafeRegister(&xFontDialogChooseFamily, libs, "gtk_font_dialog_choose_family")
468 core.PuregoSafeRegister(&xFontDialogChooseFamilyFinish, libs, "gtk_font_dialog_choose_family_finish")
469 core.PuregoSafeRegister(&xFontDialogChooseFont, libs, "gtk_font_dialog_choose_font")
470 core.PuregoSafeRegister(&xFontDialogChooseFontAndFeatures, libs, "gtk_font_dialog_choose_font_and_features")
471 core.PuregoSafeRegister(&xFontDialogChooseFontAndFeaturesFinish, libs, "gtk_font_dialog_choose_font_and_features_finish")
472 core.PuregoSafeRegister(&xFontDialogChooseFontFinish, libs, "gtk_font_dialog_choose_font_finish")
473 core.PuregoSafeRegister(&xFontDialogGetFilter, libs, "gtk_font_dialog_get_filter")
474 core.PuregoSafeRegister(&xFontDialogGetFontMap, libs, "gtk_font_dialog_get_font_map")
475 core.PuregoSafeRegister(&xFontDialogGetLanguage, libs, "gtk_font_dialog_get_language")
476 core.PuregoSafeRegister(&xFontDialogGetModal, libs, "gtk_font_dialog_get_modal")
477 core.PuregoSafeRegister(&xFontDialogGetTitle, libs, "gtk_font_dialog_get_title")
478 core.PuregoSafeRegister(&xFontDialogSetFilter, libs, "gtk_font_dialog_set_filter")
479 core.PuregoSafeRegister(&xFontDialogSetFontMap, libs, "gtk_font_dialog_set_font_map")
480 core.PuregoSafeRegister(&xFontDialogSetLanguage, libs, "gtk_font_dialog_set_language")
481 core.PuregoSafeRegister(&xFontDialogSetModal, libs, "gtk_font_dialog_set_modal")
482 core.PuregoSafeRegister(&xFontDialogSetTitle, libs, "gtk_font_dialog_set_title")
483
484}