Drag and Drop Help



I'm trying to create a drag and drop destination, and I have the following code (excerpt):

gboolean
drag_motion (GtkWidget      *widget,
             GdkDragContext *context,
             gint            x,
             gint            y,
             guint           time,
             gpointer        data)
{
  g_print ("drag motion\n");
  gtk_drag_get_data (widget, context, GDK_POINTER_TO_ATOM(context->targets[0].data), time);

  return TRUE;
}

gboolean
drag_drop (GtkWidget      *widget,
           GdkDragContext *drag_context,
           gint            x,
           gint            y,
           guint           time,
           gpointer        user_data)
{
  g_print ("drag drop\n");
  return TRUE;
}

static void
drag_data_received (GtkWidget        *widget,
                    GdkDragContext   *context,
                    gint              x,
                    gint              y,
                    GtkSelectionData *selection_data,
                    guint             info,
                    guint             time,
                    gpointer data)
{
  g_print ("drag data received\n");

  gtk_drag_finish (context, TRUE, FALSE, time);
}

static void
shelf_init (GtkWidget *widget)
{
  gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, targets, 1, GDK_ACTION_LINK);

  g_signal_connect (G_OBJECT(widget), "drag-motion",
                    G_CALLBACK(drag_motion), NULL);
  g_signal_connect (G_OBJECT(widget), "drag-drop",
                    G_CALLBACK(drag_drop), NULL);
  g_signal_connect (G_OBJECT(widget), "drag-data-received",
                    G_CALLBACK(drag_data_received), NULL);

  g_print ("shelf_init\n");
}

The problem is, after running this code, the mouse is grabbed and not released, and I end up having to 
restart my system. Can anyone tell me what I'm doing wrong?

Also, the drag source is a GtkIconView. What type of selection data will I receive, and how do I parse it?


       
---------------------------------

Alt i ett. Få Yahoo! Mail med adressekartotek, kalender og notisblokk.


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