void add_object_drag (int column, std::string type_name);
void on_drag_begin (Glib::RefPtr<Gdk::DragContext> const & context);
+ void on_drag_end (Glib::RefPtr<Gdk::DragContext> const & context);
bool on_button_press_event (GdkEventButton *ev) {
press_start_x = ev->x;
drag_data.data_column = data_column;
drag_data.object_type = object_type;
}
+
+ void end_object_drag () {
+ drag_data.source = 0;
+ drag_data.data_column = -1;
+ drag_data.object_type = "";
+ }
};
template<class DataType>
DnDTreeView() {}
~DnDTreeView() {}
- sigc::signal<void,const std::list<DataType>&,Gtk::TreeView*,int,int,Glib::RefPtr<Gdk::DragContext>&> signal_drop;
+ sigc::signal<void, const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData&> signal_drop;
void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time) {
if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") {
}
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) {
-
- end_object_drag (const_cast<Glib::RefPtr<Gdk::DragContext>& > (context), x, y);
-
+ signal_drop (context, selection_data);
} else {
/* some kind of target type added by the app, which will be handled by a signal handler */
}
*source = drag_data.source;
}
-
- private:
- void end_object_drag (Glib::RefPtr<Gdk::DragContext>& context, int x, int y) {
- std::list<DataType> l;
- Gtk::TreeView* source;
- get_object_drag_data (l, &source);
- signal_drop (l, source, x, y, context);
- }
-
};
} // namespace
/** @return True if the child can be selected in the list ( if you don't want it to copy/paste/drag then turn this off ) */
virtual bool is_selectable () const = 0;
+
+ virtual bool drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &) { return false; }
};
/** A VBox whose contents can be dragged and dropped */
return false;
}
- void drag_data_get (Glib::RefPtr<Gdk::DragContext> const &, Gtk::SelectionData & selection_data, guint, guint, T* child)
+ void drag_data_get (Glib::RefPtr<Gdk::DragContext> const &context, Gtk::SelectionData & selection_data, guint, guint, T* child)
{
- selection_data.set (selection_data.get_target(), 8, (const guchar *) &child, sizeof (&child));
+ if (!child->drag_data_get(context, selection_data)) {
+ selection_data.set (selection_data.get_target(), 8, (const guchar *) &child, sizeof (&child));
+ }
}
void drag_data_received (