Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] GTK Question: How abort a DND operation?

Havoc,

How can I abort a drag&drop operations in GTK2.0 ?
In the following C code, gdk_drag_abort doesn't seem to work.

Felipe


#include <gtk/gtk.h>

static GtkTargetEntry target_table_source[] = {
  { "text/plain", 0, 10 },
  { "text/rtf", 0, 12 }
};
static guint n_targets_source = sizeof(target_table_source) /
sizeof(target_table_source[0]);

void source_drag_begin (GtkWidget *widget, GdkDragContext *context,
gpointer data) {
   /* Here the code attempt to do something and get a exception, dnd have
to be abort */
   g_print ( "Exception occured, attempting to abort\n" );
   gdk_drag_abort( context, context->start_time );   // Nothing happens...
}

int main( int   argc, char *argv[] ) {
   GtkWidget *window, *buttonSource;
   gtk_init (&argc, &argv);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_signal_connect (GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC
(gtk_main_quit), NULL);
   buttonSource = gtk_button_new_with_label ("Source");
   gtk_container_add (GTK_CONTAINER (window), buttonSource);
   gtk_drag_source_set (buttonSource, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
target_table_source, n_targets_source, GDK_ACTION_COPY | GDK_ACTION_MOVE);
   gtk_signal_connect ( GTK_OBJECT (buttonSource), "drag_begin",
GTK_SIGNAL_FUNC (source_drag_begin), NULL);
   gtk_widget_show_all (window);
   gtk_main ();
   return 0;
}





Back to the top