X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/86f19f7ce546b37e69a710d3f1140b8a7463239d..55410bb4f67febe1ca20654f078ea4fb9a6223ae:/src/gtk/dnd.cpp diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 431141ef46..dd9fe2745c 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -166,7 +166,7 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget), { /* inform the wxDropTarget about the current GdkDragContext. this is only valid for the duration of this call */ - drop_target->SetDragContext( context ); + drop_target->GtkSetDragContext( context ); /* we don't need return values. this event is just for information */ @@ -176,7 +176,7 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget), drop_target->m_firstMotion = true; /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); + drop_target->GtkSetDragContext( NULL ); } } @@ -196,9 +196,19 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), return FALSE, otherwise call gtk_drag_status() and return TRUE" */ +#if 0 + wxPrintf( "motion\n" ); + GList *tmp_list; + for (tmp_list = context->targets; tmp_list; tmp_list = tmp_list->next) + { + wxString atom = wxString::FromAscii( gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data)) ); + wxPrintf( "Atom: %s\n", atom ); + } +#endif + /* inform the wxDropTarget about the current GdkDragContext. this is only valid for the duration of this call */ - drop_target->SetDragContext( context ); + drop_target->GtkSetDragContext( context ); // GTK+ always supposes that we want to copy the data by default while we // might want to move it, so examine not only suggested_action - which is @@ -208,27 +218,28 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), if (drop_target->GetDefaultAction() == wxDragNone) { // use default action set by wxDropSource::DoDragDrop() - if ( (gs_flagsForDrag & wxDrag_DefaultMove) == wxDrag_DefaultMove && + if ( (gs_flagsForDrag & wxDrag_DefaultMove) == wxDrag_DefaultMove && (context->actions & GDK_ACTION_MOVE ) ) - { - // move is requested by the program and allowed by GTK+ - do it, even - // though suggested_action may be currently wxDragCopy - result = wxDragMove; - } - else // use whatever GTK+ says we should - { - result = ConvertFromGTK(context->suggested_action); - - if ( (result == wxDragMove) && !(gs_flagsForDrag & wxDrag_AllowMove) ) { - // we're requested to move but we can't - result = wxDragCopy; + // move is requested by the program and allowed by GTK+ - do it, even + // though suggested_action may be currently wxDragCopy + result = wxDragMove; + } + else // use whatever GTK+ says we should + { + result = ConvertFromGTK(context->suggested_action); + + if ( (result == wxDragMove) && !(gs_flagsForDrag & wxDrag_AllowMove) ) + { + // we're requested to move but we can't + result = wxDragCopy; + } } - } } else if (drop_target->GetDefaultAction() == wxDragMove && (context->actions & GDK_ACTION_MOVE)) { + result = wxDragMove; } else @@ -267,7 +278,7 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), } /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); + drop_target->GtkSetDragContext( NULL ); /* this has to be done because GDK has no "drag_enter" event */ drop_target->m_firstMotion = false; @@ -293,23 +304,21 @@ static gboolean target_drag_drop( GtkWidget *widget, 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 ); + drop_target->GtkSetDragContext( context ); /* inform the wxDropTarget about the current drag widget. this is only valid for the duration of this call */ - drop_target->SetDragWidget( widget ); + drop_target->GtkSetDragWidget( widget ); /* inform the wxDropTarget about the current drag time. this is only valid for the duration of this call */ - drop_target->SetDragTime( time ); + drop_target->GtkSetDragTime( time ); /* wxDragResult result = wxDragMove; @@ -345,7 +354,7 @@ static gboolean target_drag_drop( GtkWidget *widget, /* disable GUI threads */ #endif - GdkAtom format = drop_target->GetMatchingPair(); + GdkAtom format = drop_target->GtkGetMatchingPair(); // this does happen somehow, see bug 555111 wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") ); @@ -367,10 +376,10 @@ static gboolean target_drag_drop( GtkWidget *widget, } /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); + drop_target->GtkSetDragContext( NULL ); /* after this, invalidate the drop_target's drag widget */ - drop_target->SetDragWidget( (GtkWidget*) NULL ); + drop_target->GtkSetDragWidget( NULL ); /* this has to be done because GDK has no "drag_enter" event */ drop_target->m_firstMotion = true; @@ -411,7 +420,7 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), /* inform the wxDropTarget about the current GtkSelectionData. this is only valid for the duration of this call */ - drop_target->SetDragData( data ); + drop_target->GtkSetDragData( data ); wxDragResult result = ConvertFromGTK(context->action); @@ -435,7 +444,7 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), } /* after this, invalidate the drop_target's drag data */ - drop_target->SetDragData( (GtkSelectionData*) NULL ); + drop_target->GtkSetDragData( NULL ); } } @@ -447,9 +456,9 @@ wxDropTarget::wxDropTarget( wxDataObject *data ) : wxDropTargetBase( data ) { m_firstMotion = true; - m_dragContext = (GdkDragContext*) NULL; - m_dragWidget = (GtkWidget*) NULL; - m_dragData = (GtkSelectionData*) NULL; + m_dragContext = NULL; + m_dragWidget = NULL; + m_dragData = NULL; m_dragTime = 0; } @@ -465,7 +474,7 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x), wxLogNull noLog; #endif // Debug - return (GetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone; + return (GtkGetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone; } bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) @@ -473,7 +482,7 @@ bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) if (!m_dataObject) return false; - return (GetMatchingPair() != (GdkAtom) 0); + return (GtkGetMatchingPair() != (GdkAtom) 0); } wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), @@ -482,13 +491,19 @@ wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), if (!m_dataObject) return wxDragNone; - if (GetMatchingPair() == (GdkAtom) 0) + if (GtkGetMatchingPair() == (GdkAtom) 0) return wxDragNone; return GetData() ? def : wxDragNone; } -GdkAtom wxDropTarget::GetMatchingPair() + +wxDataFormat wxDropTarget::GetMatchingPair() +{ + return wxDataFormat( GtkGetMatchingPair() ); +} + +GdkAtom wxDropTarget::GtkGetMatchingPair() { if (!m_dataObject) return (GdkAtom) 0; @@ -534,7 +549,7 @@ bool wxDropTarget::GetData() return true; } -void wxDropTarget::UnregisterWidget( GtkWidget *widget ) +void wxDropTarget::GtkUnregisterWidget( GtkWidget *widget ) { wxCHECK_RET( widget != NULL, wxT("unregister widget is NULL") ); @@ -550,7 +565,7 @@ void wxDropTarget::UnregisterWidget( GtkWidget *widget ) (gpointer) target_drag_data_received, this); } -void wxDropTarget::RegisterWidget( GtkWidget *widget ) +void wxDropTarget::GtkRegisterWidget( GtkWidget *widget ) { wxCHECK_RET( widget != NULL, wxT("register widget is NULL") ); @@ -566,7 +581,7 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget ) gtk_drag_dest_set( widget, (GtkDestDefaults) 0, /* no default behaviour */ - (GtkTargetEntry*) NULL, /* we don't supply any formats here */ + NULL, /* we don't supply any formats here */ 0, /* number of targets = 0 */ (GdkDragAction) 0 ); /* we don't supply any actions here */ @@ -701,7 +716,7 @@ wxDropSource::wxDropSource(wxWindow *win, { m_waiting = true; - m_iconWindow = (GtkWidget*) NULL; + m_iconWindow = NULL; m_window = win; m_widget = win->m_widget; @@ -722,7 +737,7 @@ wxDropSource::wxDropSource(wxDataObject& data, SetData( data ); - m_iconWindow = (GtkWidget*) NULL; + m_iconWindow = NULL; m_window = win; m_widget = win->m_widget; @@ -768,7 +783,7 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context ) if ( icon->GetMask() ) mask = icon->GetMask()->GetBitmap(); else - mask = (GdkBitmap *)NULL; + mask = NULL; GdkPixmap *pixmap = icon->GetPixmap(); @@ -820,7 +835,7 @@ wxDragResult wxDropSource::DoDragDrop(int flags) m_waiting = true; - GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 ); + GtkTargetList *target_list = gtk_target_list_new( NULL, 0 ); wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ]; m_data->GetAllFormats( array );