+bool wxDropTarget::GetData()
+{
+ if (!m_dragData)
+ return false;
+
+ if (!m_dataObject)
+ return false;
+
+ wxDataFormat dragFormat( m_dragData->target );
+
+ if (!m_dataObject->IsSupportedFormat( dragFormat ))
+ return false;
+
+ m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data );
+
+ return true;
+}
+
+void wxDropTarget::UnregisterWidget( GtkWidget *widget )
+{
+ wxCHECK_RET( widget != NULL, wxT("unregister widget is NULL") );
+
+ gtk_drag_dest_unset( widget );
+
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_leave, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_motion, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_drop, this);
+ g_signal_handlers_disconnect_by_func (widget,
+ (gpointer) target_drag_data_received, this);
+}
+
+void wxDropTarget::RegisterWidget( GtkWidget *widget )
+{
+ wxCHECK_RET( widget != NULL, wxT("register widget is NULL") );
+
+ /* gtk_drag_dest_set() determines what default behaviour we'd like
+ GTK to supply. we don't want to specify out targets (=formats)
+ or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and
+ not GTK_DEST_DEFAULT_DROP). instead we react individually to
+ "drag_motion" and "drag_drop" events. this makes it possible
+ to allow dropping on only a small area. we should set
+ GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice
+ highlighting if dragging over standard controls, but this
+ seems to be broken without the other two. */
+
+ gtk_drag_dest_set( widget,
+ (GtkDestDefaults) 0, /* no default behaviour */
+ (GtkTargetEntry*) NULL, /* we don't supply any formats here */
+ 0, /* number of targets = 0 */
+ (GdkDragAction) 0 ); /* we don't supply any actions here */
+
+ g_signal_connect (widget, "drag_leave",
+ G_CALLBACK (target_drag_leave), this);
+
+ g_signal_connect (widget, "drag_motion",
+ G_CALLBACK (target_drag_motion), this);
+
+ g_signal_connect (widget, "drag_drop",
+ G_CALLBACK (target_drag_drop), this);
+
+ g_signal_connect (widget, "drag_data_received",
+ G_CALLBACK (target_drag_data_received), this);
+}
+
+//----------------------------------------------------------------------------
+// "drag_data_get"
+//----------------------------------------------------------------------------
+
+extern "C" {
+static void
+source_drag_data_get (GtkWidget *WXUNUSED(widget),
+ GdkDragContext *WXUNUSED(context),
+ GtkSelectionData *selection_data,
+ guint WXUNUSED(info),
+ guint WXUNUSED(time),
+ wxDropSource *drop_source )
+{
+ wxDataFormat format( selection_data->target );
+
+#ifdef __WXDEBUG__
+ wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"),
+ format.GetId().c_str());
+#endif
+
+ drop_source->m_retValue = wxDragCancel;
+
+ wxDataObject *data = drop_source->GetDataObject();