diff options
-rw-r--r-- | mail/em-folder-tree.c | 105 |
1 files changed, 73 insertions, 32 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 95c5dbda88..e0bace6fae 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -1095,12 +1095,15 @@ render_icon (GtkTreeViewColumn *column, GtkTreeIter *iter) { GtkTreeSelection *selection; + GtkTreePath *drag_dest_row; GtkWidget *tree_view; GIcon *icon; guint unread; guint old_unread; gchar *icon_name; - gboolean row_selected, is_drafts = FALSE; + gboolean is_selected; + gboolean is_drafts = FALSE; + gboolean is_drag_dest = FALSE; gtk_tree_model_get ( model, iter, @@ -1113,14 +1116,37 @@ render_icon (GtkTreeViewColumn *column, if (icon_name == NULL) return; - icon = g_themed_icon_new (icon_name); - tree_view = gtk_tree_view_column_get_tree_view (column); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - row_selected = gtk_tree_selection_iter_is_selected (selection, iter); + is_selected = gtk_tree_selection_iter_is_selected (selection, iter); + + gtk_tree_view_get_drag_dest_row ( + GTK_TREE_VIEW (tree_view), &drag_dest_row, NULL); + if (drag_dest_row != NULL) { + GtkTreePath *path; + + path = gtk_tree_model_get_path (model, iter); + if (gtk_tree_path_compare (path, drag_dest_row) == 0) + is_drag_dest = TRUE; + gtk_tree_path_free (path); + + gtk_tree_path_free (drag_dest_row); + } + + if (g_strcmp0 (icon_name, "folder") == 0) { + if (is_selected) { + g_free (icon_name); + icon_name = g_strdup ("folder-open"); + } else if (is_drag_dest) { + g_free (icon_name); + icon_name = g_strdup ("folder-drag-accept"); + } + } + + icon = g_themed_icon_new (icon_name); /* Show an emblem if there's new mail. */ - if (!row_selected && unread > old_unread && !is_drafts) { + if (!is_selected && unread > old_unread && !is_drafts) { GIcon *temp_icon; GEmblem *emblem; @@ -1412,19 +1438,26 @@ tree_drag_begin (GtkWidget *widget, { EMFolderTreePrivate *priv = folder_tree->priv; GtkTreeSelection *selection; + GtkTreeView *tree_view; + GdkColormap *colormap; + GdkPixmap *pixmap; GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; - selection = gtk_tree_view_get_selection ((GtkTreeView *) widget); + tree_view = GTK_TREE_VIEW (widget); + selection = gtk_tree_view_get_selection (tree_view); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return; path = gtk_tree_model_get_path (model, &iter); priv->drag_row = gtk_tree_row_reference_new (model, path); - gtk_tree_path_free (path); - /* FIXME: set a drag icon? */ + pixmap = gtk_tree_view_create_row_drag_icon (tree_view, path); + colormap = gdk_drawable_get_colormap (pixmap); + gtk_drag_set_icon_pixmap (context, colormap, pixmap, NULL, 0, 0); + + gtk_tree_path_free (path); } static void @@ -2004,7 +2037,7 @@ tree_drag_end (GtkWidget *widget, { EMFolderTreePrivate *priv = folder_tree->priv; - if (priv->drag_row) { + if (priv->drag_row != NULL) { gtk_tree_row_reference_free (priv->drag_row); priv->drag_row = NULL; } @@ -2036,7 +2069,8 @@ tree_drag_leave (GtkWidget *widget, priv->autoexpand_id = 0; } - gtk_tree_view_set_drag_dest_row(tree_view, NULL, GTK_TREE_VIEW_DROP_BEFORE); + gtk_tree_view_set_drag_dest_row ( + tree_view, NULL, GTK_TREE_VIEW_DROP_BEFORE); } #define SCROLL_EDGE_SIZE 15 @@ -2099,7 +2133,12 @@ tree_autoexpand (EMFolderTree *folder_tree) } static gboolean -tree_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, EMFolderTree *folder_tree) +tree_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time, + EMFolderTree *folder_tree) { EMFolderTreePrivate *priv = folder_tree->priv; GtkTreeViewDropPosition pos; @@ -2116,11 +2155,12 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, gu tree_view = GTK_TREE_VIEW (folder_tree); model = gtk_tree_view_get_model (tree_view); - if (!gtk_tree_view_get_dest_row_at_pos(tree_view, x, y, &path, &pos)) + if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, &pos)) return FALSE; if (priv->autoscroll_id == 0) - priv->autoscroll_id = g_timeout_add (150, (GSourceFunc) tree_autoscroll, folder_tree); + priv->autoscroll_id = g_timeout_add ( + 150, (GSourceFunc) tree_autoscroll, folder_tree); gtk_tree_model_get_iter (model, &iter, path); @@ -2153,28 +2193,29 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, gu target = folder_tree_drop_target ( folder_tree, context, path, &actions, &suggested_action); - if (target != GDK_NONE) { - for (i=0; i<NUM_DROP_TYPES; i++) { - if (drop_atoms[i] == target) { - switch (i) { - case DND_DROP_TYPE_UID_LIST: - case DND_DROP_TYPE_FOLDER: - chosen_action = suggested_action; - if (chosen_action == GDK_ACTION_COPY && (actions & GDK_ACTION_MOVE)) - chosen_action = GDK_ACTION_MOVE; - gtk_tree_view_set_drag_dest_row(tree_view, path, GTK_TREE_VIEW_DROP_INTO_OR_AFTER); - break; - default: - gtk_tree_view_set_drag_dest_row(tree_view, path, GTK_TREE_VIEW_DROP_INTO_OR_AFTER); - chosen_action = suggested_action; - break; - } + for (i = 0; target != GDK_NONE && i < NUM_DROP_TYPES; i++) { + if (drop_atoms[i] != target) + continue; + switch (i) { + case DND_DROP_TYPE_UID_LIST: + case DND_DROP_TYPE_FOLDER: + chosen_action = suggested_action; + if (chosen_action == GDK_ACTION_COPY && (actions & GDK_ACTION_MOVE)) + chosen_action = GDK_ACTION_MOVE; + gtk_tree_view_set_drag_dest_row ( + tree_view, path, + GTK_TREE_VIEW_DROP_INTO_OR_AFTER); + break; + default: + gtk_tree_view_set_drag_dest_row ( + tree_view, path, + GTK_TREE_VIEW_DROP_INTO_OR_AFTER); + chosen_action = suggested_action; break; - } } - } - gtk_tree_path_free(path); + break; + } gdk_drag_status(context, chosen_action, time); |