Re: Enabling drag destination



http://roojs.com/blog.php/View/186/Drag%20and%20Drop%20with%20seed%20(Javascript)%20and%20Gtk

works with seed, should be ok on gjs


i did not have much luck with mime type dragging, it works ok with strings, but everything else was problematic.

Never had time or need to investigate further.

Regards
Alan
 --- On 21/Nov/2011, Chris Vine wrote: 
> 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
> _______________________________________________
> javascript-list mailing list
> javascript-list gnome org
> http://mail.gnome.org/mailman/listinfo/javascript-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]