Use TargetEntry drag setup for GTK draw area

This commit is contained in:
Stu 2025-12-13 22:31:30 -05:00
parent 2239c5cf3a
commit 6fc4d80e6c

View File

@ -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()