+ child = child->next;
+ }
+
+ return (GdkAtom) 0;
+}
+
+bool wxDropTarget::GetData()
+{
+ if (!m_dragData)
+ return false;
+
+ if (!m_dataObject)
+ return false;
+
+ wxDataFormat dragFormat(gtk_selection_data_get_target(m_dragData));
+
+ if (!m_dataObject->IsSupportedFormat( dragFormat ))
+ return false;
+
+ m_dataObject->SetData(dragFormat,
+ (size_t)gtk_selection_data_get_length(m_dragData),
+ (const void*)gtk_selection_data_get_data(m_dragData));
+
+ return true;
+}
+
+void wxDropTarget::GtkUnregisterWidget( 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::GtkRegisterWidget( 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 */
+ 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 *context,
+ GtkSelectionData *selection_data,
+ guint WXUNUSED(info),
+ guint WXUNUSED(time),
+ wxDropSource *drop_source )
+{
+ wxDataFormat format(gtk_selection_data_get_target(selection_data));
+
+ wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"),
+ format.GetId().c_str());
+
+ drop_source->m_retValue = wxDragError;
+
+ wxDataObject *data = drop_source->GetDataObject();
+
+ if (!data)
+ {
+ wxLogTrace(TRACE_DND, wxT("Drop source: no data object") );
+ return;
+ }
+
+ if (!data->IsSupportedFormat(format))
+ {
+ wxLogTrace(TRACE_DND, wxT("Drop source: unsupported format") );
+ return;
+ }
+
+ if (data->GetDataSize(format) == 0)
+ {
+ wxLogTrace(TRACE_DND, wxT("Drop source: empty data") );
+ return;
+ }
+
+ size_t size = data->GetDataSize(format);
+
+// printf( "data size: %d.\n", (int)data_size );
+
+ guchar *d = new guchar[size];
+
+ if (!data->GetDataHere( format, (void*)d ))
+ {
+ delete[] d;
+ return;
+ }
+
+ drop_source->m_retValue = ConvertFromGTK( context->action );
+
+ gtk_selection_data_set( selection_data,
+ gtk_selection_data_get_target(selection_data),
+ 8, // 8-bit
+ d,
+ size );
+
+ delete[] d;
+}
+}
+
+//----------------------------------------------------------------------------
+// "drag_end"
+//----------------------------------------------------------------------------
+
+extern "C" {
+static void source_drag_end( GtkWidget *WXUNUSED(widget),
+ GdkDragContext *WXUNUSED(context),
+ wxDropSource *drop_source )
+{
+ drop_source->m_waiting = false;
+}
+}
+
+//-----------------------------------------------------------------------------
+// "configure_event" from m_iconWindow