gtk dnd using gtk_drag_begin()



Hi,
  After reading the doco that I could find, ie. the gtk tutorial,
http://www.gtk.org/tutorial/ch-dragangdrop.html
http://wolfpack.twu.net/docs/gtkdnd/
http://mail.gnome.org/archives/gtk-list/2000-October/msg00115.html

I have decided to write this msg just in case I am doing something very wrong.
Keeping it short, I have a target list created like:
    GtkTargetList* tlist=0;
   enum
       {
           TARGET_URI_LIST=1,
           TARGET_TEXT_PLAIN
       };
   static GtkTargetEntry d_types[] = {
       { "text/uri-list", 0, TARGET_URI_LIST }
   };

   tlist = gtk_target_list_new (d_types, 1);
(    tlist is passed in and becomes ev->drag_targets in the following )



and in the callback hooked up like
   gtk_signal_connect(GTK_OBJECT(gevas), "leave_notify_event",
                      GTK_SIGNAL_FUNC(__gevasevh_group_selector_leave_notify_cb), ev);

I create a gtk+ drag using
static gint __gevasevh_group_selector_leave_notify_cb(
   GtkWidget          *widget,
   GdkEventCrossing   *event,
   GtkgEvasEvHGroupSelector* ev
   )
{
...
       ev->drag_context = gtk_drag_begin (GTK_WIDGET (ev->rect->gevas),
                                          ev->drag_targets,
                                          GDK_ACTION_COPY,
//                                           GDK_ACTION_MOVE | GDK_ACTION_COPY,
                                          1, event);

       gtk_drag_set_icon_default (ev->drag_context);
...
}

which works fine to start a drag, the mouse cursor changes and a little file
appears that is being dragged. The only glitch is that either dropping on a
accepting target (eg. the panel) or hitting esc will segv the app.

I am wondering if I have done anything dumb in the above that is obvious
to the more seasoned gtk+ developer?

I have a few other things hooked up, but only the drag_begin() gets called,
which I notice is actually called from gtk_drag_begin() when I looked at the
src code for gtk+.

   gtk_signal_connect(GTK_OBJECT(gevas), "drag_begin",
                      GTK_SIGNAL_FUNC(__drag_begin), ev);
   gtk_signal_connect(GTK_OBJECT(gevas), "drag_end",
                      GTK_SIGNAL_FUNC(__drag_end), ev);
   gtk_signal_connect(GTK_OBJECT(gevas), "drag_data_get",
                      GTK_SIGNAL_FUNC(__drag_data_get), ev);
   gtk_signal_connect(GTK_OBJECT(gevas), "drag_data_delete",
                      GTK_SIGNAL_FUNC(__drag_data_delete), ev);

Any ideas / leads ?


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