DnDTreeview: allow to handle multiple drag-targets

This commit is contained in:
Robin Gareus
2016-05-06 14:51:29 +02:00
parent 24e864d770
commit 864f9e497d
2 changed files with 9 additions and 6 deletions

View File

@@ -141,5 +141,3 @@ DnDTreeViewBase::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int
drag_data.source = 0;
return TreeView::on_drag_drop (context, x, y, time);
}

View File

@@ -142,11 +142,16 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") {
TreeView::on_drag_data_received (context, x, y, selection_data, info, time);
} else if (selection_data.get_target() == object_type) {
signal_drop (context, selection_data);
context->drag_finish (true, false, time);
} else {
/* some kind of target type added by the app, which will be handled by a signal handler */
/* some kind of target type, usually 'object_type' added by the app,
* which will be handled by a signal handler */
for (std::list<Gtk::TargetEntry>::const_iterator i = draggable.begin(); i != draggable.end (); ++i) {
if (selection_data.get_target() == (*i).get_target()) {
signal_drop (context, selection_data);
context->drag_finish (true, false, time);
break;
}
}
}
}