v0.2.2 9100209

gdkdrag.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// Used in `GdkDrag` to the reason of a cancelled DND operation.
16type DragCancelReason int
17
18var xDragCancelReasonGLibType func() types.GType
19
20func DragCancelReasonGLibType() types.GType {
21	return xDragCancelReasonGLibType()
22}
23
24const (
25
26	// There is no suitable drop target.
27	DragCancelNoTargetValue DragCancelReason = 0
28	// Drag cancelled by the user
29	DragCancelUserCancelledValue DragCancelReason = 1
30	// Unspecified error.
31	DragCancelErrorValue DragCancelReason = 2
32)
33
34var xDragActionIsUnique func(DragAction) bool
35
36// Checks if @action represents a single action or includes
37// multiple actions.
38//
39// When @action is `GDK_ACTION_NONE` - ie no action was given, `TRUE`
40// is returned.
41func DragActionIsUnique(ActionVar DragAction) bool {
42
43	cret := xDragActionIsUnique(ActionVar)
44	return cret
45}
46
47// Represents the source of an ongoing DND operation.
48//
49// A `GdkDrag` is created when a drag is started, and stays alive for duration of
50// the DND operation. After a drag has been started with [func@Gdk.Drag.begin],
51// the caller gets informed about the status of the ongoing drag operation
52// with signals on the `GdkDrag` object.
53//
54// GTK provides a higher level abstraction based on top of these functions,
55// and so they are not normally needed in GTK applications. See the
56// "Drag and Drop" section of the GTK documentation for more information.
57type Drag struct {
58	gobject.Object
59}
60
61var xDragGLibType func() types.GType
62
63func DragGLibType() types.GType {
64	return xDragGLibType()
65}
66
67func DragNewFromInternalPtr(ptr uintptr) *Drag {
68	cls := &Drag{}
69	cls.Ptr = ptr
70	return cls
71}
72
73var xDragDropDone func(uintptr, bool)
74
75// Informs GDK that the drop ended.
76//
77// Passing %FALSE for @success may trigger a drag cancellation
78// animation.
79//
80// This function is called by the drag source, and should be the
81// last call before dropping the reference to the @drag.
82//
83// The `GdkDrag` will only take the first [method@Gdk.Drag.drop_done]
84// call as effective, if this function is called multiple times,
85// all subsequent calls will be ignored.
86func (x *Drag) DropDone(SuccessVar bool) {
87
88	xDragDropDone(x.GoPointer(), SuccessVar)
89
90}
91
92var xDragGetActions func(uintptr) DragAction
93
94// Determines the bitmask of possible actions proposed by the source.
95func (x *Drag) GetActions() DragAction {
96
97	cret := xDragGetActions(x.GoPointer())
98	return cret
99}
100
101var xDragGetContent func(uintptr) uintptr
102
103// Returns the `GdkContentProvider` associated to the `GdkDrag` object.
104func (x *Drag) GetContent() *ContentProvider {
105	var cls *ContentProvider
106
107	cret := xDragGetContent(x.GoPointer())
108
109	if cret == 0 {
110		return nil
111	}
112	gobject.IncreaseRef(cret)
113	cls = &ContentProvider{}
114	cls.Ptr = cret
115	return cls
116}
117
118var xDragGetDevice func(uintptr) uintptr
119
120// Returns the `GdkDevice` associated to the `GdkDrag` object.
121func (x *Drag) GetDevice() *Device {
122	var cls *Device
123
124	cret := xDragGetDevice(x.GoPointer())
125
126	if cret == 0 {
127		return nil
128	}
129	gobject.IncreaseRef(cret)
130	cls = &Device{}
131	cls.Ptr = cret
132	return cls
133}
134
135var xDragGetDisplay func(uintptr) uintptr
136
137// Gets the `GdkDisplay` that the drag object was created for.
138func (x *Drag) GetDisplay() *Display {
139	var cls *Display
140
141	cret := xDragGetDisplay(x.GoPointer())
142
143	if cret == 0 {
144		return nil
145	}
146	gobject.IncreaseRef(cret)
147	cls = &Display{}
148	cls.Ptr = cret
149	return cls
150}
151
152var xDragGetDragSurface func(uintptr) uintptr
153
154// Returns the surface on which the drag icon should be rendered
155// during the drag operation.
156//
157// Note that the surface may not be available until the drag operation
158// has begun. GDK will move the surface in accordance with the ongoing
159// drag operation. The surface is owned by @drag and will be destroyed
160// when the drag operation is over.
161func (x *Drag) GetDragSurface() *Surface {
162	var cls *Surface
163
164	cret := xDragGetDragSurface(x.GoPointer())
165
166	if cret == 0 {
167		return nil
168	}
169	gobject.IncreaseRef(cret)
170	cls = &Surface{}
171	cls.Ptr = cret
172	return cls
173}
174
175var xDragGetFormats func(uintptr) *ContentFormats
176
177// Retrieves the formats supported by this `GdkDrag` object.
178func (x *Drag) GetFormats() *ContentFormats {
179
180	cret := xDragGetFormats(x.GoPointer())
181	return cret
182}
183
184var xDragGetSelectedAction func(uintptr) DragAction
185
186// Determines the action chosen by the drag destination.
187func (x *Drag) GetSelectedAction() DragAction {
188
189	cret := xDragGetSelectedAction(x.GoPointer())
190	return cret
191}
192
193var xDragGetSurface func(uintptr) uintptr
194
195// Returns the `GdkSurface` where the drag originates.
196func (x *Drag) GetSurface() *Surface {
197	var cls *Surface
198
199	cret := xDragGetSurface(x.GoPointer())
200
201	if cret == 0 {
202		return nil
203	}
204	gobject.IncreaseRef(cret)
205	cls = &Surface{}
206	cls.Ptr = cret
207	return cls
208}
209
210var xDragSetHotspot func(uintptr, int, int)
211
212// Sets the position of the drag surface that will be kept
213// under the cursor hotspot.
214//
215// Initially, the hotspot is at the top left corner of the drag surface.
216func (x *Drag) SetHotspot(HotXVar int, HotYVar int) {
217
218	xDragSetHotspot(x.GoPointer(), HotXVar, HotYVar)
219
220}
221
222func (c *Drag) GoPointer() uintptr {
223	if c == nil {
224		return 0
225	}
226	return c.Ptr
227}
228
229func (c *Drag) SetGoPointer(ptr uintptr) {
230	c.Ptr = ptr
231}
232
233// SetPropertyFormats sets the "formats" property.
234// The possible formats that the drag can provide its data in.
235func (x *Drag) SetPropertyFormats(value uintptr) {
236	var v gobject.Value
237	v.Init(gobject.TypePointerVal)
238	v.SetPointer(value)
239	x.SetProperty("formats", &v)
240}
241
242// GetPropertyFormats gets the "formats" property.
243// The possible formats that the drag can provide its data in.
244func (x *Drag) GetPropertyFormats() uintptr {
245	var v gobject.Value
246	x.GetProperty("formats", &v)
247	return v.GetPointer()
248}
249
250// Emitted when the drag operation is cancelled.
251func (x *Drag) ConnectCancel(cb *func(Drag, DragCancelReason)) uint {
252	cbPtr := uintptr(unsafe.Pointer(cb))
253	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
254		handlerID := gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr)
255		glib.SaveHandlerMapping(handlerID, cbPtr)
256		return handlerID
257	}
258
259	fcb := func(clsPtr uintptr, ReasonVarp DragCancelReason) {
260		fa := Drag{}
261		fa.Ptr = clsPtr
262		cbFn := *cb
263
264		cbFn(fa, ReasonVarp)
265
266	}
267	cbRefPtr := purego.NewCallback(fcb)
268	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
269	handlerID := gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr)
270	glib.SaveHandlerMapping(handlerID, cbPtr)
271	return handlerID
272}
273
274// Emitted when the destination side has finished reading all data.
275//
276// The drag object can now free all miscellaneous data.
277func (x *Drag) ConnectDndFinished(cb *func(Drag)) uint {
278	cbPtr := uintptr(unsafe.Pointer(cb))
279	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
280		handlerID := gobject.SignalConnect(x.GoPointer(), "dnd-finished", cbRefPtr)
281		glib.SaveHandlerMapping(handlerID, cbPtr)
282		return handlerID
283	}
284
285	fcb := func(clsPtr uintptr) {
286		fa := Drag{}
287		fa.Ptr = clsPtr
288		cbFn := *cb
289
290		cbFn(fa)
291
292	}
293	cbRefPtr := purego.NewCallback(fcb)
294	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
295	handlerID := gobject.SignalConnect(x.GoPointer(), "dnd-finished", cbRefPtr)
296	glib.SaveHandlerMapping(handlerID, cbPtr)
297	return handlerID
298}
299
300// Emitted when the drop operation is performed on an accepting client.
301func (x *Drag) ConnectDropPerformed(cb *func(Drag)) uint {
302	cbPtr := uintptr(unsafe.Pointer(cb))
303	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
304		handlerID := gobject.SignalConnect(x.GoPointer(), "drop-performed", cbRefPtr)
305		glib.SaveHandlerMapping(handlerID, cbPtr)
306		return handlerID
307	}
308
309	fcb := func(clsPtr uintptr) {
310		fa := Drag{}
311		fa.Ptr = clsPtr
312		cbFn := *cb
313
314		cbFn(fa)
315
316	}
317	cbRefPtr := purego.NewCallback(fcb)
318	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
319	handlerID := gobject.SignalConnect(x.GoPointer(), "drop-performed", cbRefPtr)
320	glib.SaveHandlerMapping(handlerID, cbPtr)
321	return handlerID
322}
323
324var xDragBegin func(uintptr, uintptr, uintptr, DragAction, float64, float64) uintptr
325
326// Starts a drag and creates a new drag context for it.
327//
328// This function is called by the drag source. After this call, you
329// probably want to set up the drag icon using the surface returned
330// by [method@Gdk.Drag.get_drag_surface].
331//
332// This function returns a reference to the [class@Gdk.Drag] object,
333// but GTK keeps its own reference as well, as long as the DND operation
334// is going on.
335//
336// Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
337// the [signal@Gdk.Drag::dnd-finished] signal and delete the data at
338// the source if [method@Gdk.Drag.get_selected_action] returns
339// %GDK_ACTION_MOVE.
340func DragBegin(SurfaceVar *Surface, DeviceVar *Device, ContentVar *ContentProvider, ActionsVar DragAction, DxVar float64, DyVar float64) *Drag {
341	var cls *Drag
342
343	cret := xDragBegin(SurfaceVar.GoPointer(), DeviceVar.GoPointer(), ContentVar.GoPointer(), ActionsVar, DxVar, DyVar)
344
345	if cret == 0 {
346		return nil
347	}
348	cls = &Drag{}
349	cls.Ptr = cret
350	return cls
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(&xDragCancelReasonGLibType, libs, "gdk_drag_cancel_reason_get_type")
366
367	core.PuregoSafeRegister(&xDragActionIsUnique, libs, "gdk_drag_action_is_unique")
368
369	core.PuregoSafeRegister(&xDragGLibType, libs, "gdk_drag_get_type")
370
371	core.PuregoSafeRegister(&xDragDropDone, libs, "gdk_drag_drop_done")
372	core.PuregoSafeRegister(&xDragGetActions, libs, "gdk_drag_get_actions")
373	core.PuregoSafeRegister(&xDragGetContent, libs, "gdk_drag_get_content")
374	core.PuregoSafeRegister(&xDragGetDevice, libs, "gdk_drag_get_device")
375	core.PuregoSafeRegister(&xDragGetDisplay, libs, "gdk_drag_get_display")
376	core.PuregoSafeRegister(&xDragGetDragSurface, libs, "gdk_drag_get_drag_surface")
377	core.PuregoSafeRegister(&xDragGetFormats, libs, "gdk_drag_get_formats")
378	core.PuregoSafeRegister(&xDragGetSelectedAction, libs, "gdk_drag_get_selected_action")
379	core.PuregoSafeRegister(&xDragGetSurface, libs, "gdk_drag_get_surface")
380	core.PuregoSafeRegister(&xDragSetHotspot, libs, "gdk_drag_set_hotspot")
381
382	core.PuregoSafeRegister(&xDragBegin, libs, "gdk_drag_begin")
383
384}

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