Using DnD from a GtkImage



Hi,

I've been trying to set up an application so that a user can perform a
drag and drop operation by dragging from a GtkImage and dropping it to
an external application, but I seem to be having no luck.

I currently have the following:

void setup_dnd() {
        GtkWidget *photo = GTK_WIDGET(gtk_builder_get_object(builder, "photo"));
        GtkTargetEntry *target = malloc(sizeof(GtkTargetEntry));

        target->target = "text/plain";
        target->flags = 0;
        target->info = 0;

        gtk_drag_source_set(photo, 0, target, 1, GDK_ACTION_COPY);
        g_message("dnd setup complete");
}

void drag(GtkWidget* widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, gpointer 
user_data) {
        g_message("dragging");
        gtk_selection_data_set_text(data, "Not Yet Fully Implemented", -1);
}

Finally, in the function where I set up my signals, I have the following
(amongst others):

GObject* signaltmp;
[...]
signaltmp = G_OBJECT(gtk_builder_get_object(builder, "photo"));
g_signal_connect(signaltmp, "drag-data-get", G_CALLBACK(drag), NULL);

Yet it seems as though the "drag" callback is never called -- and yes,
the "dnd setup complete" message does show up, so that part seems fine.

What am I missing?

-- 
It is easy to love a country that is famous for chocolate and beer

  -- Barack Obama, speaking in Brussels, Belgium, 2014-03-26


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]