v0.2.1 c0399be

gdkcursor.go RawHistoryFolder

1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5	"unsafe"
6
7	"github.com/ebitengine/purego"
8
9	"github.com/bnema/puregotk/pkg/core"
10	"github.com/bnema/puregotk/v4/glib"
11	"github.com/bnema/puregotk/v4/gobject"
12	"github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// The type of callback used by a dynamic `GdkCursor` to generate
16// a texture for the cursor image at the given @cursor_size
17// and @scale.
18//
19// The actual cursor size in application pixels may be different
20// from @cursor_size x @cursor_size, and will be returned in
21// @width, @height. The returned texture should have a size that
22// corresponds to the actual cursor size, in device pixels (i.e.
23// application pixels, multiplied by @scale).
24//
25// This function may fail and return `NULL`, in which case
26// the fallback cursor will be used.
27type CursorGetTextureCallback func(uintptr, int, float64, *int, *int, *int, *int, uintptr) uintptr
28
29// Used to create and destroy cursors.
30//
31// Cursors are immutable objects, so once you created them, there is no way
32// to modify them later. You should create a new cursor when you want to change
33// something about it.
34//
35// Cursors by themselves are not very interesting: they must be bound to a
36// window for users to see them. This is done with [method@Gdk.Surface.set_cursor]
37// or [method@Gdk.Surface.set_device_cursor]. Applications will typically
38// use higher-level GTK functions such as [gtk_widget_set_cursor()](../gtk4/method.Widget.set_cursor.html)
39// instead.
40//
41// Cursors are not bound to a given [class@Gdk.Display], so they can be shared.
42// However, the appearance of cursors may vary when used on different
43// platforms.
44//
45// ## Named and texture cursors
46//
47// There are multiple ways to create cursors. The platform's own cursors
48// can be created with [ctor@Gdk.Cursor.new_from_name]. That function lists
49// the commonly available names that are shared with the CSS specification.
50// Other names may be available, depending on the platform in use. On some
51// platforms, what images are used for named cursors may be influenced by
52// the cursor theme.
53//
54// Another option to create a cursor is to use [ctor@Gdk.Cursor.new_from_texture]
55// and provide an image to use for the cursor.
56//
57// To ease work with unsupported cursors, a fallback cursor can be provided.
58// If a [class@Gdk.Surface] cannot use a cursor because of the reasons mentioned
59// above, it will try the fallback cursor. Fallback cursors can themselves have
60// fallback cursors again, so it is possible to provide a chain of progressively
61// easier to support cursors. If none of the provided cursors can be supported,
62// the default cursor will be the ultimate fallback.
63type Cursor struct {
64	gobject.Object
65}
66
67var xCursorGLibType func() types.GType
68
69func CursorGLibType() types.GType {
70	return xCursorGLibType()
71}
72
73func CursorNewFromInternalPtr(ptr uintptr) *Cursor {
74	cls := &Cursor{}
75	cls.Ptr = ptr
76	return cls
77}
78
79var xNewCursorFromCallback func(uintptr, uintptr, uintptr, uintptr) uintptr
80
81// Creates a new callback-based cursor object.
82//
83// Cursors of this kind produce textures for the cursor
84// image on demand, when the @callback is called.
85func NewCursorFromCallback(CallbackVar *CursorGetTextureCallback, DataVar uintptr, DestroyVar *glib.DestroyNotify, FallbackVar *Cursor) *Cursor {
86	var cls *Cursor
87
88	var CallbackVarRef uintptr
89	if CallbackVar != nil {
90		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
91		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
92			CallbackVarRef = cbRefPtr
93		} else {
94			fcb := func(arg0 uintptr, arg1 int, arg2 float64, arg3 *int, arg4 *int, arg5 *int, arg6 *int, arg7 uintptr) uintptr {
95				cbFn := *CallbackVar
96				return cbFn(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
97			}
98			CallbackVarRef = purego.NewCallback(fcb)
99			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
100		}
101	}
102
103	var DestroyVarRef uintptr
104	if DestroyVar != nil {
105		DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar))
106		if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok {
107			DestroyVarRef = cbRefPtr
108		} else {
109			fcb := func(arg0 uintptr) {
110				cbFn := *DestroyVar
111				cbFn(arg0)
112			}
113			DestroyVarRef = purego.NewCallback(fcb)
114			glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar)
115		}
116	}
117
118	cret := xNewCursorFromCallback(CallbackVarRef, DataVar, DestroyVarRef, FallbackVar.GoPointer())
119
120	if cret == 0 {
121		return nil
122	}
123	cls = &Cursor{}
124	cls.Ptr = cret
125	return cls
126}
127
128var xNewCursorFromName func(string, uintptr) uintptr
129
130// Creates a new cursor by looking up @name in the current cursor
131// theme.
132//
133// A recommended set of cursor names that will work across different
134// platforms can be found in the CSS specification:
135//
136// | | | |
137// | --- | --- | --- |
138// |                               | "none"          | No cursor |
139// | ![](default_cursor.png)       | "default"       | The default cursor |
140// | ![](help_cursor.png)          | "help"          | Help is available |
141// | ![](pointer_cursor.png)       | "pointer"       | Indicates a link or interactive element |
142// | ![](context_menu_cursor.png)  |"context-menu"   | A context menu is available |
143// | ![](progress_cursor.png)      | "progress"      | Progress indicator |
144// | ![](wait_cursor.png)          | "wait"          | Busy cursor |
145// | ![](cell_cursor.png)          | "cell"          | Cell(s) may be selected |
146// | ![](crosshair_cursor.png)     | "crosshair"     | Simple crosshair |
147// | ![](text_cursor.png)          | "text"          | Text may be selected |
148// | ![](vertical_text_cursor.png) | "vertical-text" | Vertical text may be selected |
149// | ![](alias_cursor.png)         | "alias"         | DND: Something will be linked |
150// | ![](copy_cursor.png)          | "copy"          | DND: Something will be copied |
151// | ![](move_cursor.png)          | "move"          | DND: Something will be moved |
152// | ![](dnd_ask_cursor.png)       | "dnd-ask"       | DND: User can choose action to be carried out |
153// | ![](no_drop_cursor.png)       | "no-drop"       | DND: Can't drop here |
154// | ![](not_allowed_cursor.png)   | "not-allowed"   | DND: Action will not be carried out |
155// | ![](grab_cursor.png)          | "grab"          | DND: Something can be grabbed |
156// | ![](grabbing_cursor.png)      | "grabbing"      | DND: Something is being grabbed |
157// | ![](n_resize_cursor.png)      | "n-resize"      | Resizing: Move north border |
158// | ![](e_resize_cursor.png)      | "e-resize"      | Resizing: Move east border |
159// | ![](s_resize_cursor.png)      | "s-resize"      | Resizing: Move south border |
160// | ![](w_resize_cursor.png)      | "w-resize"      | Resizing: Move west border |
161// | ![](ne_resize_cursor.png)     | "ne-resize"     | Resizing: Move north-east corner |
162// | ![](nw_resize_cursor.png)     | "nw-resize"     | Resizing: Move north-west corner |
163// | ![](sw_resize_cursor.png)     | "sw-resize"     | Resizing: Move south-west corner |
164// | ![](se_resize_cursor.png)     | "se-resize"     | Resizing: Move south-east corner |
165// | ![](col_resize_cursor.png)    | "col-resize"    | Resizing: Move an item or border horizontally |
166// | ![](row_resize_cursor.png)    | "row-resize"    | Resizing: Move an item or border vertically |
167// | ![](ew_resize_cursor.png)     | "ew-resize"     | Moving: Something can be moved horizontally |
168// | ![](ns_resize_cursor.png)     | "ns-resize"     | Moving: Something can be moved vertically |
169// | ![](nesw_resize_cursor.png)   | "nesw-resize"   | Moving: Something can be moved diagonally, north-east to south-west |
170// | ![](nwse_resize_cursor.png)   | "nwse-resize"   | Moving: something can be moved diagonally, north-west to south-east |
171// | ![](all_resize_cursor.png)    | "all-resize"    | Moving: Something can be moved in any direction |
172// | ![](all_scroll_cursor.png)    | "all-scroll"    | Can scroll in any direction |
173// | ![](zoom_in_cursor.png)       | "zoom-in"       | Zoom in |
174// | ![](zoom_out_cursor.png)      | "zoom-out"      | Zoom out |
175func NewCursorFromName(NameVar string, FallbackVar *Cursor) *Cursor {
176	var cls *Cursor
177
178	cret := xNewCursorFromName(NameVar, FallbackVar.GoPointer())
179
180	if cret == 0 {
181		return nil
182	}
183	cls = &Cursor{}
184	cls.Ptr = cret
185	return cls
186}
187
188var xNewCursorFromTexture func(uintptr, int, int, uintptr) uintptr
189
190// Creates a new cursor from a `GdkTexture`.
191func NewCursorFromTexture(TextureVar *Texture, HotspotXVar int, HotspotYVar int, FallbackVar *Cursor) *Cursor {
192	var cls *Cursor
193
194	cret := xNewCursorFromTexture(TextureVar.GoPointer(), HotspotXVar, HotspotYVar, FallbackVar.GoPointer())
195
196	if cret == 0 {
197		return nil
198	}
199	cls = &Cursor{}
200	cls.Ptr = cret
201	return cls
202}
203
204var xCursorGetFallback func(uintptr) uintptr
205
206// Returns the fallback for this @cursor.
207//
208// The fallback will be used if this cursor is not available on a given
209// `GdkDisplay`. For named cursors, this can happen when using nonstandard
210// names or when using an incomplete cursor theme. For textured cursors,
211// this can happen when the texture is too large or when the `GdkDisplay`
212// it is used on does not support textured cursors.
213func (x *Cursor) GetFallback() *Cursor {
214	var cls *Cursor
215
216	cret := xCursorGetFallback(x.GoPointer())
217
218	if cret == 0 {
219		return nil
220	}
221	gobject.IncreaseRef(cret)
222	cls = &Cursor{}
223	cls.Ptr = cret
224	return cls
225}
226
227var xCursorGetHotspotX func(uintptr) int
228
229// Returns the horizontal offset of the hotspot.
230//
231// The hotspot indicates the pixel that will be directly above the cursor.
232//
233// Note that named cursors may have a nonzero hotspot, but this function
234// will only return the hotspot position for cursors created with
235// [ctor@Gdk.Cursor.new_from_texture].
236func (x *Cursor) GetHotspotX() int {
237
238	cret := xCursorGetHotspotX(x.GoPointer())
239	return cret
240}
241
242var xCursorGetHotspotY func(uintptr) int
243
244// Returns the vertical offset of the hotspot.
245//
246// The hotspot indicates the pixel that will be directly above the cursor.
247//
248// Note that named cursors may have a nonzero hotspot, but this function
249// will only return the hotspot position for cursors created with
250// [ctor@Gdk.Cursor.new_from_texture].
251func (x *Cursor) GetHotspotY() int {
252
253	cret := xCursorGetHotspotY(x.GoPointer())
254	return cret
255}
256
257var xCursorGetName func(uintptr) string
258
259// Returns the name of the cursor.
260//
261// If the cursor is not a named cursor, %NULL will be returned.
262func (x *Cursor) GetName() string {
263
264	cret := xCursorGetName(x.GoPointer())
265	return cret
266}
267
268var xCursorGetTexture func(uintptr) uintptr
269
270// Returns the texture for the cursor.
271//
272// If the cursor is a named cursor, %NULL will be returned.
273func (x *Cursor) GetTexture() *Texture {
274	var cls *Texture
275
276	cret := xCursorGetTexture(x.GoPointer())
277
278	if cret == 0 {
279		return nil
280	}
281	gobject.IncreaseRef(cret)
282	cls = &Texture{}
283	cls.Ptr = cret
284	return cls
285}
286
287func (c *Cursor) GoPointer() uintptr {
288	if c == nil {
289		return 0
290	}
291	return c.Ptr
292}
293
294func (c *Cursor) SetGoPointer(ptr uintptr) {
295	c.Ptr = ptr
296}
297
298// SetPropertyHotspotX sets the "hotspot-x" property.
299// X position of the cursor hotspot in the cursor image.
300func (x *Cursor) SetPropertyHotspotX(value int) {
301	var v gobject.Value
302	v.Init(gobject.TypeIntVal)
303	v.SetInt(value)
304	x.SetProperty("hotspot-x", &v)
305}
306
307// GetPropertyHotspotX gets the "hotspot-x" property.
308// X position of the cursor hotspot in the cursor image.
309func (x *Cursor) GetPropertyHotspotX() int {
310	var v gobject.Value
311	x.GetProperty("hotspot-x", &v)
312	return v.GetInt()
313}
314
315// SetPropertyHotspotY sets the "hotspot-y" property.
316// Y position of the cursor hotspot in the cursor image.
317func (x *Cursor) SetPropertyHotspotY(value int) {
318	var v gobject.Value
319	v.Init(gobject.TypeIntVal)
320	v.SetInt(value)
321	x.SetProperty("hotspot-y", &v)
322}
323
324// GetPropertyHotspotY gets the "hotspot-y" property.
325// Y position of the cursor hotspot in the cursor image.
326func (x *Cursor) GetPropertyHotspotY() int {
327	var v gobject.Value
328	x.GetProperty("hotspot-y", &v)
329	return v.GetInt()
330}
331
332// SetPropertyName sets the "name" property.
333// Name of this this cursor.
334//
335// The name will be %NULL if the cursor was created from a texture.
336func (x *Cursor) SetPropertyName(value string) {
337	var v gobject.Value
338	v.Init(gobject.TypeStringVal)
339	v.SetString(&value)
340	x.SetProperty("name", &v)
341}
342
343// GetPropertyName gets the "name" property.
344// Name of this this cursor.
345//
346// The name will be %NULL if the cursor was created from a texture.
347func (x *Cursor) GetPropertyName() string {
348	var v gobject.Value
349	x.GetProperty("name", &v)
350	return v.GetString()
351}
352
353func init() {
354	core.SetPackageName("GDK", "gtk4")
355	core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
356	var libs []uintptr
357	for _, libPath := range core.GetPaths("GDK") {
358		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
359		if err != nil {
360			panic(err)
361		}
362		libs = append(libs, lib)
363	}
364
365	core.PuregoSafeRegister(&xCursorGLibType, libs, "gdk_cursor_get_type")
366
367	core.PuregoSafeRegister(&xNewCursorFromCallback, libs, "gdk_cursor_new_from_callback")
368	core.PuregoSafeRegister(&xNewCursorFromName, libs, "gdk_cursor_new_from_name")
369	core.PuregoSafeRegister(&xNewCursorFromTexture, libs, "gdk_cursor_new_from_texture")
370
371	core.PuregoSafeRegister(&xCursorGetFallback, libs, "gdk_cursor_get_fallback")
372	core.PuregoSafeRegister(&xCursorGetHotspotX, libs, "gdk_cursor_get_hotspot_x")
373	core.PuregoSafeRegister(&xCursorGetHotspotY, libs, "gdk_cursor_get_hotspot_y")
374	core.PuregoSafeRegister(&xCursorGetName, libs, "gdk_cursor_get_name")
375	core.PuregoSafeRegister(&xCursorGetTexture, libs, "gdk_cursor_get_texture")
376
377}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close