Commit 877b0af3 authored by estade@chromium.org's avatar estade@chromium.org

GTK: Allow user to drag onto folder in bookmark bar.

This is only half of the bug fix. We also should match windows in that a drag held over a folder for more than a second or so shows the folder's contents and allows the user to continue the drag into the folder.

Also, it's kind of hard to use this new feature since the bookmark items float around when you are dragging out of the same bookmark bar you're dragging into, but the fix for that would be separate (and would require some design decisions).

BUG=14222
TEST=drag single or multiple bookmarks onto a bookmark bar folder

Review URL: http://codereview.chromium.org/149307

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20186 0039d316-1c4b-4281-b951-d872f2087c98
parent 5be20ecd
......@@ -440,6 +440,12 @@ GtkToolItem* BookmarkBarGtk::CreateBookmarkToolItem(const BookmarkNode* node) {
}
void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget) {
gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_MOVE);
GtkDndUtil::SetDestTargetListFromCodeMask(widget,
GtkDndUtil::X_CHROME_BOOKMARK_ITEM);
g_signal_connect(widget, "drag-data-received",
G_CALLBACK(&OnFolderDragReceived), this);
// Connect to 'button-release-event' instead of 'clicked' because we need
// access to the modifier keys and we do different things on each
// button.
......@@ -645,6 +651,31 @@ gboolean BookmarkBarGtk::OnFolderButtonReleased(GtkWidget* sender,
return FALSE;
}
// static
void BookmarkBarGtk::OnFolderDragReceived(GtkWidget* widget,
GdkDragContext* context, gint x, gint y, GtkSelectionData* selection_data,
guint target_type, guint time, BookmarkBarGtk* bar) {
gboolean dnd_success = FALSE;
gboolean delete_selection_data = FALSE;
const BookmarkNode* dest_node = bar->GetNodeForToolButton(widget);
DCHECK(dest_node->is_folder());
std::vector<const BookmarkNode*> nodes =
bookmark_utils::GetNodesFromSelection(context, selection_data,
target_type,
bar->profile_,
&delete_selection_data,
&dnd_success);
DCHECK(!nodes.empty());
for (std::vector<const BookmarkNode*>::iterator it = nodes.begin();
it != nodes.end(); ++it) {
bar->model_->Move(*it, dest_node, dest_node->GetChildCount());
}
gtk_drag_finish(context, dnd_success, delete_selection_data, time);
}
// static
gboolean BookmarkBarGtk::OnToolbarExpose(GtkWidget* widget,
GdkEventExpose* event,
......
......@@ -120,7 +120,6 @@ class BookmarkBarGtk : public AnimationDelegate,
virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
const BookmarkNode* node);
private:
GtkWidget* CreateBookmarkButton(const BookmarkNode* node);
GtkToolItem* CreateBookmarkToolItem(const BookmarkNode* node);
......@@ -158,6 +157,12 @@ class BookmarkBarGtk : public AnimationDelegate,
static gboolean OnFolderButtonReleased(GtkWidget* sender,
GdkEventButton* event,
BookmarkBarGtk* bar);
static void OnFolderDragReceived(GtkWidget* widget,
GdkDragContext* context,
gint x, gint y,
GtkSelectionData* selection_data,
guint target_type, guint time,
BookmarkBarGtk* bar);
// GtkToolbar callbacks
static gboolean OnToolbarExpose(GtkWidget* widget, GdkEventExpose* event,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment