1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
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// Handles launching an application in a graphical context.
14//
15// It is an implementation of `GAppLaunchContext` that provides startup
16// notification and allows to launch applications on a specific workspace.
17//
18// ## Launching an application
19//
20// ```c
21// GdkAppLaunchContext *context;
22//
23// context = gdk_display_get_app_launch_context (display);
24//
25// gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));
26//
27// if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
28//
29// g_warning ("Launching failed: %s\n", error->message);
30//
31// g_object_unref (context);
32// ```
33type AppLaunchContext struct {
34 gio.AppLaunchContext
35}
36
37var xAppLaunchContextGLibType func() types.GType
38
39func AppLaunchContextGLibType() types.GType {
40 return xAppLaunchContextGLibType()
41}
42
43func AppLaunchContextNewFromInternalPtr(ptr uintptr) *AppLaunchContext {
44 cls := &AppLaunchContext{}
45 cls.Ptr = ptr
46 return cls
47}
48
49var xAppLaunchContextGetDisplay func(uintptr) uintptr
50
51// Gets the `GdkDisplay` that @context is for.
52func (x *AppLaunchContext) GetDisplay() *Display {
53 var cls *Display
54
55 cret := xAppLaunchContextGetDisplay(x.GoPointer())
56
57 if cret == 0 {
58 return nil
59 }
60 gobject.IncreaseRef(cret)
61 cls = &Display{}
62 cls.Ptr = cret
63 return cls
64}
65
66var xAppLaunchContextSetDesktop func(uintptr, int)
67
68// Sets the workspace on which applications will be launched.
69//
70// This only works when running under a window manager that
71// supports multiple workspaces, as described in the
72// [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec).
73// Specifically this sets the `_NET_WM_DESKTOP` property described
74// in that spec.
75//
76// This only works when using the X11 backend.
77//
78// When the workspace is not specified or @desktop is set to -1,
79// it is up to the window manager to pick one, typically it will
80// be the current workspace.
81func (x *AppLaunchContext) SetDesktop(DesktopVar int) {
82
83 xAppLaunchContextSetDesktop(x.GoPointer(), DesktopVar)
84
85}
86
87var xAppLaunchContextSetIcon func(uintptr, uintptr)
88
89// Sets the icon for applications that are launched with this
90// context.
91//
92// Window Managers can use this information when displaying startup
93// notification.
94//
95// See also [method@Gdk.AppLaunchContext.set_icon_name].
96func (x *AppLaunchContext) SetIcon(IconVar gio.Icon) {
97
98 xAppLaunchContextSetIcon(x.GoPointer(), IconVar.GoPointer())
99
100}
101
102var xAppLaunchContextSetIconName func(uintptr, uintptr)
103
104// Sets the icon for applications that are launched with this context.
105//
106// The @icon_name will be interpreted in the same way as the Icon field
107// in desktop files. See also [method@Gdk.AppLaunchContext.set_icon].
108//
109// If both @icon and @icon_name are set, the @icon_name takes priority.
110// If neither @icon or @icon_name is set, the icon is taken from either
111// the file that is passed to launched application or from the `GAppInfo`
112// for the launched application itself.
113func (x *AppLaunchContext) SetIconName(IconNameVar *string) {
114
115 IconNameVarPtr := core.GStrdupNullable(IconNameVar)
116 defer core.GFreeNullable(IconNameVarPtr)
117
118 xAppLaunchContextSetIconName(x.GoPointer(), IconNameVarPtr)
119
120}
121
122var xAppLaunchContextSetTimestamp func(uintptr, uint32)
123
124// Sets the timestamp of @context.
125//
126// The timestamp should ideally be taken from the event that
127// triggered the launch.
128//
129// Window managers can use this information to avoid moving the
130// focus to the newly launched application when the user is busy
131// typing in another window. This is also known as 'focus stealing
132// prevention'.
133func (x *AppLaunchContext) SetTimestamp(TimestampVar uint32) {
134
135 xAppLaunchContextSetTimestamp(x.GoPointer(), TimestampVar)
136
137}
138
139func (c *AppLaunchContext) GoPointer() uintptr {
140 if c == nil {
141 return 0
142 }
143 return c.Ptr
144}
145
146func (c *AppLaunchContext) SetGoPointer(ptr uintptr) {
147 c.Ptr = ptr
148}
149
150func init() {
151 core.SetPackageName("GDK", "gtk4")
152 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
153 var libs []uintptr
154 for _, libPath := range core.GetPaths("GDK") {
155 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
156 if err != nil {
157 panic(err)
158 }
159 libs = append(libs, lib)
160 }
161
162 core.PuregoSafeRegister(&xAppLaunchContextGLibType, libs, "gdk_app_launch_context_get_type")
163
164 core.PuregoSafeRegister(&xAppLaunchContextGetDisplay, libs, "gdk_app_launch_context_get_display")
165 core.PuregoSafeRegister(&xAppLaunchContextSetDesktop, libs, "gdk_app_launch_context_set_desktop")
166 core.PuregoSafeRegister(&xAppLaunchContextSetIcon, libs, "gdk_app_launch_context_set_icon")
167 core.PuregoSafeRegister(&xAppLaunchContextSetIconName, libs, "gdk_app_launch_context_set_icon_name")
168 core.PuregoSafeRegister(&xAppLaunchContextSetTimestamp, libs, "gdk_app_launch_context_set_timestamp")
169
170}