Some background: I’m working on VICE, the Commodore 8-bit emulator suite, and this specific issue relates to VSID, a SID file player we provide. Here’s a screenshot making it easier to explain what I’m doing:
I have three ‘panes’: the left one has controls and info on the current SID song, the middle displays extra information from an external database (this one gives me trouble), and the right pane contains a playlist.
The trouble is the middle pane: it’s a GtkGrid, which contains a GtkLabel at 0,0, and a GtkScrolledWindow at 0,1 containing the GtkTextView which doesn’t respond to drop events.
On Windows, connecting the ‘drag-data-received’ and ‘drag-drop’ events to signal handlers which play a new SID file works. On Linux dragging a SID file onto the label above the GtkTextView works, but even hooking up event handlers to the GtkTextView and/or GtkScrolledWindow on Linux doesn’t trigger anything (my event handlers use g_print() for ‘debugging’, nothing is printed).
It’s a little difficult to distil my code to the absolute minimum (but I’m prepared to do that), meanwhile, here’s some of the relevant code:
My drop targets:
/** \brief List of drag targets for the drag-n-drop event handler
*
* It would appear different OS'es/WM's pass dropped files using various
* mime-types.
*/
GtkTargetEntry ui_drag_targets[UI_DRAG_TARGETS_COUNT] = {
{ "text/plain", 0, DT_TEXT }, /* we get this on at least my Linux
box with Mate */
{ "text/uri", 0, DT_URI },
{ "text/uri-list", 0, DT_URI_LIST } /* we get this using Windows
Explorer or macOS Finder */
};
And here I connect the signal handlers (the stil_widget
is the GtkGrid containing the widgets in the middle pane):
/* middle pane: STIL widget */
gtk_drag_dest_set(
stil_widget,
GTK_DEST_DEFAULT_ALL,
ui_drag_targets,
UI_DRAG_TARGETS_COUNT,
GDK_ACTION_COPY);
g_signal_connect(stil_widget, "drag-data-received",
G_CALLBACK(on_drag_data_received), NULL);
g_signal_connect(stil_widget, "drag-drop",
G_CALLBACK(on_drag_drop), NULL);
I’ve tried doing the same for the GtkScrolledWindow and the GtkTextView, but on Linux no event handler is triggered.
Should I wrap the GtkGrid in an event box and have that handle the drop events? I’m a little confused at the moment, especially since Windows seems to handle this 'correctly. I can even drag files from/to the VM and the playlist works, it’s the GtkTextView that only accepts drop events on Windows and not on Linux (on bare metal neither).
/Compyx