Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Troubled day for virgins over 16 who are beautiful and wealthy and live in eucalyptus trees.


comp / comp.lang.tcl / File drags from tcl/tkdnd apps into a GTK3 app are ignored

SubjectAuthor
o File drags from tcl/tkdnd apps into a GTK3 app are ignoredericg

1
Subject: File drags from tcl/tkdnd apps into a GTK3 app are ignored
From: ericg
Newsgroups: comp.lang.tcl
Organization: RetroBBS
Date: Tue, 20 Aug 2024 20:56 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.quux.org!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail
From: eric_gilbertson@yahoo.com (ericg)
Newsgroups: comp.lang.tcl
Subject: File drags from tcl/tkdnd apps into a GTK3 app are ignored
Date: Tue, 20 Aug 2024 20:56:18 +0000
Organization: RetroBBS
Message-ID: <25f8aa0c20256da919abdf73e590202f@www.rocksolidbbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="3272347"; mail-complaints-to="usenet@i2pn2.org";
posting-account="gzBaNA6IaLmSxSjvQTw6hmon9aHLlFN2IQhR5kQJj3g";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0
X-Rslight-Site: $2y$10$b7fZ43T7Kbi.Vyd9sxbAd.f/C7m3VSHAL3fHXA6s0C20XvyG5bm7i
X-Rslight-Posting-User: e45e7d91c1b324da5fdbb17ef66ead78b54a8e03
View all headers

File drags from my tcl/tkdnd app into a GTK3 app are ignored. The issue
appears to be that the drop data is interpreted as a string rather than
a list of file URIs, e.g. dropData.get_data() returns the dropped file
name but dropData.get_uris() returns an empty list, as demonstrated by
the following demo code. I also noticed that the drop target cursor
changes to a hand when dropping a file from Nautilus File (Gtk based)
tool but it does not change when dropping from the tcl/tk app. Any
pointers on how to get the tck/tk client to work with Gtk3 are much
appreciated. Alternatively, is there a tool that I can use to view the
WM messages that are sent during the drag/drop in order to debug the
issue? I am running Gnome 42.9 on Ubuntu 22.04.

Tcl/tkdnd drop file source app:
package require tkdnd
catch {console show}

pack [ttk::button .drag_source_files -text " Drag File "] -fill x -padx
20 -pady 20

tkdnd::drag_source register .drag_source_files DND_Files

bind .drag_source_files <<DragInitCmd>> \
{list {copy} DND_Files [list "file:///tmp/test.wav" ]}

## Event <<DragEndCmd>>
bind .drag_source_files <<DragEndCmd>> {
puts "Drop action: %A"
}

Gtk drop receiver app:

import gi
gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk

window = Gtk.Window()
window.connect("delete-event", Gtk.main_quit)

box = Gtk.HBox()
window.add(box)

# Called when the Drop button is dropped on
def on_drag_data_received(widget, drag_context, x, y, data, info, time):
print("Received uris: {}".format(data.get_uris())) # returns empty
list
print("Received data: {}".format(data.get_data())) # returns file
name

# The button into which the file can be dropped
drop_button = Gtk.Button(label="Drop")
drop_button.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY)
drop_button.drag_dest_add_uri_targets() # This makes sure that the
buttons are using URIs, not text
drop_button.connect("drag-data-received", on_drag_data_received)
box.add(drop_button)

window.show_all()
Gtk.main()

1

rocksolid light 0.9.8
clearnet tor