+static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ /* Owen Taylor: "if the coordinates not in a drop zone,
+ return FALSE, otherwise call gtk_drag_status() and
+ return TRUE" */
+
+ /* inform the wxDropTarget about the current GdkDragContext.
+ this is only valid for the duration of this call */
+ drop_target->SetDragContext( context );
+
+ if (drop_target->m_firstMotion)
+ {
+ /* the first "drag_motion" event substitutes a "drag_enter" event */
+ drop_target->OnEnter();
+ }
+
+ /* give program a chance to react (i.e. to say no by returning FALSE) */
+ bool ret = drop_target->OnMove( x, y );
+
+ /* we don't yet handle which "actions" (i.e. copy or move)
+ the target accepts. so far we simply accept the
+ suggested action. TODO. */
+ if (ret)
+ gdk_drag_status( context, context->suggested_action, time );
+
+ /* after this, invalidate the drop_target's GdkDragContext */
+ drop_target->SetDragContext( (GdkDragContext*) NULL );
+
+ /* this has to be done because GDK has no "drag_enter" event */
+ drop_target->m_firstMotion = FALSE;
+
+ return ret;
+}
+
+// ----------------------------------------------------------------------------
+// "drag_drop"
+// ----------------------------------------------------------------------------
+
+static gboolean target_drag_drop( GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ wxDropTarget *drop_target )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ /* Owen Taylor: "if the drop is not in a drop zone,
+ return FALSE, otherwise, if you aren't accepting
+ the drop, call gtk_drag_finish() with success == FALSE
+ otherwise call gtk_drag_data_get()" */
+
+// printf( "drop.\n" );
+
+ /* this seems to make a difference between not accepting
+ due to wrong target area and due to wrong format. let
+ us hope that this is not required.. */
+
+ /* inform the wxDropTarget about the current GdkDragContext.
+ this is only valid for the duration of this call */
+ drop_target->SetDragContext( context );
+
+ /* inform the wxDropTarget about the current drag widget.
+ this is only valid for the duration of this call */
+ drop_target->SetDragWidget( widget );
+
+ /* inform the wxDropTarget about the current drag time.
+ this is only valid for the duration of this call */
+ drop_target->SetDragTime( time );
+
+ bool ret = drop_target->OnDrop( x, y );
+
+ if (!ret)
+ {
+ /* cancel the whole thing */
+ gtk_drag_finish( context,
+ FALSE, /* no success */
+ FALSE, /* don't delete data on dropping side */
+ time );
+ }
+
+ /* after this, invalidate the drop_target's GdkDragContext */
+ drop_target->SetDragContext( (GdkDragContext*) NULL );
+
+ /* after this, invalidate the drop_target's drag widget */
+ drop_target->SetDragWidget( (GtkWidget*) NULL );
+
+ /* this has to be done because GDK has no "drag_enter" event */
+ drop_target->m_firstMotion = TRUE;
+
+ return ret;
+}
+
+// ----------------------------------------------------------------------------
+// "drag_data_received"
+// ----------------------------------------------------------------------------
+
+static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint WXUNUSED(info),
+ guint time,
+ wxDropTarget *drop_target )
+{
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ /* Owen Taylor: "call gtk_drag_finish() with
+ success == TRUE" */
+
+// printf( "data received.\n" );
+
+ if ((data->length <= 0) || (data->format != 8))
+ {
+ /* negative data length and non 8-bit data format
+ qualifies for junk */
+ gtk_drag_finish (context, FALSE, FALSE, time);
+
+// printf( "no data.\n" );
+
+ return;
+ }
+
+ /* inform the wxDropTarget about the current GtkSelectionData.
+ this is only valid for the duration of this call */
+ drop_target->SetDragData( data );
+
+ if (drop_target->OnData( x, y ))
+ {
+ /* tell GTK that data transfer was successfull */
+ gtk_drag_finish( context, TRUE, FALSE, time );
+ }
+ else
+ {
+ /* tell GTK that data transfer was not successfull */
+ gtk_drag_finish( context, FALSE, FALSE, time );
+ }
+
+ /* after this, invalidate the drop_target's drag data */
+ drop_target->SetDragData( (GtkSelectionData*) NULL );
+}
+
+//----------------------------------------------------------------------------
+// wxDropTarget
+//----------------------------------------------------------------------------
+