Dear Jers,

Recently I have started experimenting with gtk in J. I have figured out how the 
basics work from the demo felidae3 project - how to setup and arrange various 
widgets, link 'clicked' signal to callbacks, load images, etc.

Still being both a J and GTK beginner I'm wondering if someone could help me 
with implementing basic drag and drop.

Based on the tutorial at http://live.gnome.org/GnomeLove/DragNDropTutorial it 
should work the following way :

1. Set widget1 (which will be dragged) as the drag source
    Set widget2 (the widget to which widget 1 should be dragged to) as the drag 
destination
2. Connect the gtk drag and drop signals to the event handler functions
3. Implement the drag and drop event handlers

-----
What I am thinking so far :

1. For setting the widgets as dragndrop source/destination I guess sth like the 
following would be done :

gtk_drag_source_set widget1, GDK_BUTTON1_MASK, target_list, n_targets, 
GDK_ACTION_MOVE
gtk_drag_dest_set widget2, GTK_DEST_DEFAULT_MOTION, target_list, n_targets, 
GDK_ACTION_MOVE
NB. I don't know what should be in the 'target_list' argument here

2. For connecting the signals to callbacks(event_handlers) would be sth like 
the following :

consig widget1;'drag-begin';'drag_begin_handl'

consig widget1;'drag-data-get';'drag_data_get_handl'
consig widget1;'drag-data-delete';'drag_data_delete_handl'
consig widget1;'drag-end';'drag_end_handl'
consig widget1;'drag-begin';'drag_begin_handl'


consig widget2;'drag-data-received';'drag_data_received_handl'
consig widget2;'drag-leave';'drag_leave_handl'
consig widget2;'drag-motion';'drag_motion_handl'
consig widget2;'drag-drop';'drag_drop_handl'

NB. Is the gtk signal name 'drag dash begin' or 'drag underscore begin' ? 
(drag-begin or drag_begin) 
NB. What is the difference between 'consig' and 'consig3' which can be seen in 
felidae3 demo code(glade.ijs) ? (I also saw some other consigs in the source 
file like consig2, consig4)

3. And then implementing the handlers (I am really wandering in the dark 
here)...

How would this C/Gtk code be translated to J ?

drag_begin_handl (GtkWidget *widget, GdkDragContext *context, gpointer 
user_data){
      const gchar *name = gtk_widget_get_name (widget);
      g_print("%s: drag_begin_handl\n", name);
}

NB. So far I know only how to print message/don't know how to send the 
arguments as done in the C function above :)
drag_begin_handl=: 3 : 0
'widget data'=. y
smoutput 'drag begins now'
0
)

Any pointers or suggestions would be much appreciated regarding the above 
approach and questions [or best if there is a simple working demo program :)]

Many Thanks in advance,
Emir Ustamujic
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to