Use TargetEntry drag setup for GTK draw area
This commit is contained in:
parent
2239c5cf3a
commit
6fc4d80e6c
|
|
@ -269,9 +269,10 @@ func preferDark() {
|
||||||
func setupDragDest(p *pane, win *gtk.Window) {
|
func setupDragDest(p *pane, win *gtk.Window) {
|
||||||
// Accept URI drops using a target list
|
// Accept URI drops using a target list
|
||||||
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, nil, gdk.ACTION_COPY)
|
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, nil, gdk.ACTION_COPY)
|
||||||
if tl, err := gtk.TargetListNew([]gtk.TargetEntry{}); err == nil && tl != nil {
|
// gotk3 doesn't expose TargetList easily on drawing area; set default URI target via TargetEntry
|
||||||
tl.AddURITargets(0)
|
target, err := gtk.TargetEntryNew("text/uri-list", gtk.TARGET_OTHER_APP, 0)
|
||||||
p.area.DragDestSetTargetList(tl)
|
if err == nil {
|
||||||
|
p.area.DragDestSet(gtk.DEST_DEFAULT_ALL, []gtk.TargetEntry{*target}, gdk.ACTION_COPY)
|
||||||
}
|
}
|
||||||
p.area.Connect("drag-data-received", func(_ *gtk.DrawingArea, ctx *gdk.DragContext, x, y int, data *gtk.SelectionData, info uint, t uint32) {
|
p.area.Connect("drag-data-received", func(_ *gtk.DrawingArea, ctx *gdk.DragContext, x, y int, data *gtk.SelectionData, info uint, t uint32) {
|
||||||
uris := data.GetURIs()
|
uris := data.GetURIs()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user