- switch (info) {
- case MODEST_HEADER_ROW:
- gtk_tree_set_row_drag_data (selection_data, model, source_row);
- break;
- case MODEST_MSG: {
- TnyHeader *hdr = NULL;
- gtk_tree_model_get (model, &iter,
- TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN, &hdr,
- -1);
- if (hdr) {
- g_object_unref (G_OBJECT(hdr));
- }
- break;
- }
- default:
- g_message ("%s: default switch case.", __FUNCTION__);
- }
+ self = MODEST_HEADER_VIEW (widget);
+ priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
+
+ /* Set the data. Do not use the current selection because it
+ could be different than the selection at the beginning of
+ the d&d */
+ modest_dnd_selection_data_set_paths (selection_data,
+ priv->drag_begin_cached_selected_rows);
+}
+
+/**
+ * We're caching the selected rows at the beginning because the
+ * selection could change between drag-begin and drag-data-get, for
+ * example if we have a set of rows already selected, and then we
+ * click in one of them (without SHIFT key pressed) and begin a drag,
+ * the selection at that moment contains all the selected lines, but
+ * after dropping the selection, the release event provokes that only
+ * the row used to begin the drag is selected, so at the end the
+ * drag&drop affects only one rows instead of all the selected ones.
+ *
+ */
+static void
+drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gpointer data)
+{
+ ModestHeaderView *self = NULL;
+ ModestHeaderViewPrivate *priv = NULL;
+ GtkTreeSelection *selection;
+
+ self = MODEST_HEADER_VIEW (widget);
+ priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+ priv->drag_begin_cached_selected_rows =
+ gtk_tree_selection_get_selected_rows (selection, NULL);
+}