// display title
$title = new GtkLabel("Drag and Drop between a table and a list - Part 2 drag-and-drop in both directions");$title->modify_font(new PangoFontDescription("Times New Roman Italic 10"));$title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff"));$title->set_size_request(-1, 48);$vbox->pack_start($title, false);

Set up drop on the left side (the table). Note that the main purpose of the drag from right to left is remove selections from the left. As such, for this drop, it's set up on the GtkTable so that the user can drop anywhere on the table.

Note that in this example we attached an additional information "tree" in the dragged data when the user starts dragging from the left. This is to allow us to know if the user dropped the data on the left instead of on the right.

Similarly, we attached an additional information "treeview" in the dragged data when the user starts dragging from the right. This is to allow us to know if the user dropped the data on the right instead of on the left.

Check for any duplication. We basically loop through the existing items in the treeview. If there's no duplication, we will add the new item.