I'm making a text editor using GTK3 in Vala. I need to drag a file and, when I drop it into the application window, the application opens that file. I'm using a Gtk.Notebook
that contains the Gtk.SourceView
's. It works when I drop a file into an empty Gtk.Notebook
, but when there is at least one Gtk.SourceView
appended on it, the SourceView
grabs the URI of the file, shows it and the window can't handle the opening of the file.
In this case, what can I do to prevent a Gtk.SourceView
from grabbing the URI of a file when I drop a file into a Gtk.SourceView
.
PS: I tried to use the drag_dest_unset()
inside the SourceView
derived class. It worked, the SourceView
didn't grab the URI and the window could open the file, but the application showed a message like this, in runtime:
Gtk-WARNING **: Can't set a target list on a widget until you've called gtk_drag_dest_set() to make the widget into a drag destination
To make the
Gtk.SourceView
stop grabbing the uri, I used the following code snippet:This way, the uri of the file that I drop in the source view is not pasted in it and I can open the file in another tab.
This sounds like you're trying to drag the file into the SourceView widget with the idea that it will open a new tab instead of opening that file in that source view widget.
What you need to do is not disable the drag event, you need to redirect it. The event will come into the sourceview widget and then you connect to it and pass it to your code (in your window?) which deals with opening a new tab.
Does this make sense? do you need code samples?