diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 00:17:01 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 00:17:01 +0000 |
commit | d99bf7472cb7c9e2adaeda17d497a2b1d7abb5a9 (patch) | |
tree | 613d7cedcb20473a7f8f238ae79630e3b3b8230d /chrome/browser | |
parent | e953d76afc04c4bb5357866836116a25e5296924 (diff) | |
download | chromium_src-d99bf7472cb7c9e2adaeda17d497a2b1d7abb5a9.zip chromium_src-d99bf7472cb7c9e2adaeda17d497a2b1d7abb5a9.tar.gz chromium_src-d99bf7472cb7c9e2adaeda17d497a2b1d7abb5a9.tar.bz2 |
bookmarks dnd:
- Correct row index calculation in bookmark manager drag receive.
- Support multiple target dnd
also see http://crbug.com/15240
BUG=none
TEST=multi dragging in bookmark manager/bookmark bar. See cited bug for explanation of how to multi-drag.
Review URL: http://codereview.chromium.org/147107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 26 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_utils_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_utils_gtk.h | 6 |
4 files changed, 32 insertions, 18 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 8191a4a..37f654e 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -817,11 +817,12 @@ void BookmarkBarGtk::OnToolbarDragReceived(GtkWidget* widget, &delete_selection_data, &dnd_success); DCHECK(!nodes.empty()); + gint index = gtk_toolbar_get_drop_index( + GTK_TOOLBAR(bar->bookmark_toolbar_.get()), x, y); for (std::vector<BookmarkNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it) { - gint index = gtk_toolbar_get_drop_index( - GTK_TOOLBAR(bar->bookmark_toolbar_.get()), x, y); - bar->model_->Move(*it, bar->model_->GetBookmarkBarNode(), index++); + bar->model_->Move(*it, bar->model_->GetBookmarkBarNode(), index); + index = bar->model_->GetBookmarkBarNode()->IndexOfChild(*it) + 1; } gtk_drag_finish(context, dnd_success, delete_selection_data, time); diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index 80a5eec..c2a892f 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -425,6 +425,8 @@ GtkWidget* BookmarkManagerGtk::MakeRightPane() { gtk_tree_view_append_column(GTK_TREE_VIEW(right_tree_view_), title_column); gtk_tree_view_append_column(GTK_TREE_VIEW(right_tree_view_), url_column); gtk_tree_view_append_column(GTK_TREE_VIEW(right_tree_view_), path_column_); + gtk_tree_selection_set_mode(right_selection(), GTK_SELECTION_MULTIPLE); + g_signal_connect(right_tree_view_, "row-activated", G_CALLBACK(OnRightTreeViewRowActivated), this); g_signal_connect(right_selection(), "changed", @@ -810,10 +812,9 @@ void BookmarkManagerGtk::OnRightTreeViewDragGet( GtkWidget* tree_view, GdkDragContext* context, GtkSelectionData* selection_data, guint target_type, guint time, BookmarkManagerGtk* bookmark_manager) { - // TODO(estade): support multiple target drag. - BookmarkNode* node = bookmark_manager->GetRightSelection().at(0); - bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, - bookmark_manager->profile_); + bookmark_utils::WriteBookmarksToSelection( + bookmark_manager->GetRightSelection(), selection_data, target_type, + bookmark_manager->profile_); } // static @@ -864,23 +865,20 @@ void BookmarkManagerGtk::OnRightTreeViewDragReceived( } if (drop_before || drop_after || !path) { - if (path) { - if (drop_before) - gtk_tree_path_prev(path); - else - gtk_tree_path_next(path); - } + if (path && drop_after) + gtk_tree_path_next(path); // We will get a null path when the drop is below the lowest row. parent = bm->GetFolder(); - idx = !path ? parent->GetChildCount() : - gtk_tree_path_get_indices(path)[gtk_tree_path_get_depth(path) - 1]; + idx = !path ? parent->GetChildCount() : gtk_tree_path_get_indices(path)[0]; } for (std::vector<BookmarkNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it) { // Don't try to drop a node into one of its descendants. - if (!parent->HasAncestor(*it)) - bm->model_->Move(*it, parent, idx++); + if (!parent->HasAncestor(*it)) { + bm->model_->Move(*it, parent, idx); + idx = parent->IndexOfChild(*it) + 1; + } } gtk_tree_path_free(path); diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc index 9858f3e..313dca4 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/gtk/bookmark_utils_gtk.cc @@ -73,9 +73,18 @@ void WriteBookmarkToSelection(BookmarkNode* node, guint target_type, Profile* profile) { DCHECK(node); + std::vector<BookmarkNode*> nodes; + nodes.push_back(node); + WriteBookmarksToSelection(nodes, selection_data, target_type, profile); +} + +void WriteBookmarksToSelection(const std::vector<BookmarkNode*>& nodes, + GtkSelectionData* selection_data, + guint target_type, + Profile* profile) { switch (target_type) { case dnd::X_CHROME_BOOKMARK_ITEM: { - BookmarkDragData data(node); + BookmarkDragData data(nodes); Pickle pickle; data.WriteToPickle(profile, &pickle); diff --git a/chrome/browser/gtk/bookmark_utils_gtk.h b/chrome/browser/gtk/bookmark_utils_gtk.h index 9306f20..819748c 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.h +++ b/chrome/browser/gtk/bookmark_utils_gtk.h @@ -35,6 +35,12 @@ void WriteBookmarkToSelection(BookmarkNode* node, guint target_type, Profile* profile); +// Pickle a vector of nodes into a GtkSelection. +void WriteBookmarksToSelection(const std::vector<BookmarkNode*>& nodes, + GtkSelectionData* selection_data, + guint target_type, + Profile* profile); + // Un-pickle node(s) from a GtkSelection. // The last two arguments are out parameters. std::vector<BookmarkNode*> GetNodesFromSelection( |