Tip an GTK2-Programmierer

J

juedan

Guest
Hallo Forum,

diemal möchte ich einen Tip an alle GTK-Programmierer loswerden.

Folgendes Szenario:
Drag-and-Drop zwischen Applikation A (=Selbstbau) und Applikation B (=Nautilus)


Ablauf im DnD-Protokoll:
Code:
Applikation: Event:       GdkDragAction GdkDragAction      GdkDragAction
                            actions;      suggested_action;  action; 
(linke Maustaste)
A:           drag begin   2             6                  0
A:           drag motion  2             6                  0
A:           drag leave   2             6                  0

B->A:        drag get     2             6                  0

(loslassen auf Ziel)
B->A:        drag get     2             6                  [color=red]2[/color]
B->A:        drag end

Die Ziffern bedeuten dabei folgendes:
GDK_ACTION_COPY = 2
GDK_ACTION_COPY + GDK_ACTION_MOVE = 6
GdkDragAction stammt aus dem Event-Callback für "drag-get"
Code:
void drag_get(GtkWidget *widget,
   [color=green]GdkDragContext[/color] *drag_context,
   GtkSelectionData *data,
   guint info,
   guint time,
   gpointer user_data);

typedef struct {
  GObject parent_instance;

  
  GdkDragProtocol protocol;
  
  gboolean is_source;
  
  GdkWindow *source_window;
  GdkWindow *dest_window;

  GList *targets;
  GdkDragAction actions;
  GdkDragAction suggested_action;
[color=red]
  GdkDragAction action; 
[/color]
  guint32 start_time;
} [color=green]GdkDragContext;[/color]

Der Knackpunkt ist nun, daß in der Spalte "GdkDragAction->action" der Wert von "0" auf "2" (rot markiert) springt. Damit gibt die Zielapplikation zu verstehen, daß sie die DnD-Elemente annimmt oder angenommen hat.
Dies ist leider nirgends dokumentiert. Alle code-snippets gehen davon aus, dass Drag-and-Drop nur innerhalb einer Applikation stattfindet. Selbst bei Koders.com bin ich absolut nicht fündig geworden.

Anderen GTK-Programmierern möchte ich hiermit die zeitaufwändige Protokollanalyse ersparen.

Ich hoffe es hilft dem einen oder anderen weiter.

Viele Grüße und einen schönen Abend noch

Jürgen
 
Zuletzt bearbeitet von einem Moderator:
Zurück
Oben