Enabling drag destination
- From: Chris Vine <chris cvine freeserve co uk>
- To: javascript-list gnome org
- Subject: Enabling drag destination
- Date: Mon, 21 Nov 2011 11:23:47 +0000
I am making a desktop utility which will accept a text/plain drop from
another application, and then do something with it (actually all it
does is check if the dropped text appears to be a valid URL, and if so
executes wget on it). The utility is thus relatively trivial, so I
thought it would be suitable for GTK+3's introspection bindings.
The following works fine when written in C/C++, where 'drop_box' is a
GtkEventBox:
static GtkTargetEntry target_array[] = {
{(char*)"STRING", 0, 0},
{(char*)"text/plain", 0, 0}
};
static guint target_size = G_N_ELEMENTS(target_array);
gtk_drag_dest_set(drop_box, GTK_DEST_DEFAULT_ALL,
target_array, target_size,
GDK_ACTION_COPY);
g_signal_connect(drop_box, "drag_data_received",
G_CALLBACK(drag_data_received), this);
However, I cannot get an equivalent to this to go with gjs-1.30.0 and
gobject-introspection-1.30.0. A naive attempt to create a
Gtk.TargetEntry object with:
var target1 = new Gtk.TargetEntry({target: "text/plain",
flags: 0,
info: 0});
fails with:
"Unable to construct boxed type TargetEntry since it has no zero-args
<constructor>, can only wrap an existing one"
I see that Gtk.TargetEntry has a static 'new' method representing
gtk_target_entry_new(), and although calling it appears to produce
something, as follows:
var target1 = Gtk.TargetEntry.new("text/plain", 0, 0);
any attempt to use the returned value by putting it in an array and
passing it Gtk.Widget.drag_dest_set() or to Gtk.TargetList.new()
segfaults with no explanation.
What is the correct way to enable a destination drop using gjs?
Chris
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]