static void interactive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); GtkWidget *tool_item = NULL; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); /* create a drop indicator when a tool button was found */ g_assert (NULL == drop_item); if (GTK_IS_TOOL_ITEM (tool_item)) { drop_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); gdk_drag_status (context, GDK_ACTION_COPY, time); gtk_widget_queue_draw (widget); } }
static void interactive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); GtkWidget *tool_item = NULL; CanvasItem *item; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); /* create a canvas item when a tool button was found */ g_assert (NULL == drop_item); if (!GTK_IS_TOOL_ITEM (tool_item)) return; if (drop_item) { canvas_item_free (drop_item); drop_item = NULL; } item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); /* Either create a new item or just create a preview item, depending on why the drag data was requested. */ if(drag_data_requested_for_drop) { canvas_items = g_list_append (canvas_items, item); drop_item = NULL; gtk_drag_finish (context, TRUE, FALSE, time); } else { drop_item = item; gdk_drag_status (context, GDK_ACTION_COPY, time); } gtk_widget_queue_draw (widget); }
static void passive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button, which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); CanvasItem *canvas_item = NULL; GtkWidget *tool_item = NULL; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); g_assert (NULL == drop_item); /* append a new canvas item when a tool button was found */ if (GTK_IS_TOOL_ITEM (tool_item)) canvas_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); if (canvas_item) { canvas_items = g_list_append (canvas_items, canvas_item); gtk_widget_queue_draw (widget); } }