gtkappchooser.go RawHistoryFolder
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/gio"
9 "github.com/bnema/puregotk/v4/gobject"
10 "github.com/bnema/puregotk/v4/gobject/types"
11)
12
13// `GtkAppChooser` is an interface for widgets which allow the user to
14// choose an application.
15//
16// The main objects that implement this interface are
17// [class@Gtk.AppChooserWidget],
18// [class@Gtk.AppChooserDialog] and [class@Gtk.AppChooserButton].
19//
20// Applications are represented by GIO `GAppInfo` objects here.
21// GIO has a concept of recommended and fallback applications for a
22// given content type. Recommended applications are those that claim
23// to handle the content type itself, while fallback also includes
24// applications that handle a more generic content type. GIO also
25// knows the default and last-used application for a given content
26// type. The `GtkAppChooserWidget` provides detailed control over
27// whether the shown list of applications should include default,
28// recommended or fallback applications.
29//
30// To obtain the application that has been selected in a `GtkAppChooser`,
31// use [method@Gtk.AppChooser.get_app_info].
32type AppChooser interface {
33 GoPointer() uintptr
34 SetGoPointer(uintptr)
35 GetAppInfo() *gio.AppInfoBase
36 GetContentType() string
37 Refresh()
38}
39
40var xAppChooserGLibType func() types.GType
41
42func AppChooserGLibType() types.GType {
43 return xAppChooserGLibType()
44}
45
46type AppChooserBase struct {
47 Ptr uintptr
48}
49
50func (x *AppChooserBase) GoPointer() uintptr {
51 if x == nil {
52 return 0
53 }
54 return x.Ptr
55}
56
57func (x *AppChooserBase) SetGoPointer(ptr uintptr) {
58 x.Ptr = ptr
59}
60
61// Returns the currently selected application.
62func (x *AppChooserBase) GetAppInfo() *gio.AppInfoBase {
63 var cls *gio.AppInfoBase
64
65 cret := XGtkAppChooserGetAppInfo(x.GoPointer())
66
67 if cret == 0 {
68 return nil
69 }
70 cls = &gio.AppInfoBase{}
71 cls.Ptr = cret
72 return cls
73}
74
75// Returns the content type for which the `GtkAppChooser`
76// shows applications.
77func (x *AppChooserBase) GetContentType() string {
78
79 cret := XGtkAppChooserGetContentType(x.GoPointer())
80 return cret
81}
82
83// Reloads the list of applications.
84func (x *AppChooserBase) Refresh() {
85
86 XGtkAppChooserRefresh(x.GoPointer())
87
88}
89
90// SetPropertyContentType sets the "content-type" property.
91// The content type of the `GtkAppChooser` object.
92//
93// See `GContentType` for more information about content types.
94func (x *AppChooserBase) SetPropertyContentType(value string) {
95 obj := gobject.Object{}
96 obj.Ptr = x.GoPointer()
97 var v gobject.Value
98 v.Init(gobject.TypeStringVal)
99 v.SetString(&value)
100 obj.SetProperty("content-type", &v)
101}
102
103// GetPropertyContentType gets the "content-type" property.
104// The content type of the `GtkAppChooser` object.
105//
106// See `GContentType` for more information about content types.
107func (x *AppChooserBase) GetPropertyContentType() string {
108 obj := gobject.Object{}
109 obj.Ptr = x.GoPointer()
110 var v gobject.Value
111 obj.GetProperty("content-type", &v)
112 return v.GetString()
113}
114
115var XGtkAppChooserGetAppInfo func(uintptr) uintptr
116var XGtkAppChooserGetContentType func(uintptr) string
117var XGtkAppChooserRefresh func(uintptr)
118
119func init() {
120 core.SetPackageName("GTK", "gtk4")
121 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
122 var libs []uintptr
123 for _, libPath := range core.GetPaths("GTK") {
124 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
125 if err != nil {
126 panic(err)
127 }
128 libs = append(libs, lib)
129 }
130
131 core.PuregoSafeRegister(&xAppChooserGLibType, libs, "gtk_app_chooser_get_type")
132
133 core.PuregoSafeRegister(&XGtkAppChooserGetAppInfo, libs, "gtk_app_chooser_get_app_info")
134 core.PuregoSafeRegister(&XGtkAppChooserGetContentType, libs, "gtk_app_chooser_get_content_type")
135 core.PuregoSafeRegister(&XGtkAppChooserRefresh, libs, "gtk_app_chooser_refresh")
136
137}