diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 01:01:53 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 01:01:53 +0000 |
commit | 3f873e1cd9bc39d4eb8c40e6ee68e7dd6af68aae (patch) | |
tree | c621c73bfd4e502574583cad8ecac23c486eae3e /chrome | |
parent | d0e7a1430e0fe39134acdfd12cf6e4d84511ca8d (diff) | |
download | chromium_src-3f873e1cd9bc39d4eb8c40e6ee68e7dd6af68aae.zip chromium_src-3f873e1cd9bc39d4eb8c40e6ee68e7dd6af68aae.tar.gz chromium_src-3f873e1cd9bc39d4eb8c40e6ee68e7dd6af68aae.tar.bz2 |
Gtk: URI list dragging for bookmarks (source side only)
BUG=none
TEST=drag a bookmark into the webview or onto another program such as konqueror. The right thing should happen.
Review URL: http://codereview.chromium.org/149301
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_utils_gtk.cc | 18 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_dnd_util.cc | 8 |
4 files changed, 31 insertions, 4 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 24acccf..1a36e71 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -399,7 +399,8 @@ GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_MOVE); GtkDndUtil::SetSourceTargetListFromCodeMask( - button, GtkDndUtil::X_CHROME_BOOKMARK_ITEM); + button, GtkDndUtil::X_CHROME_BOOKMARK_ITEM | + GtkDndUtil::X_CHROME_TEXT_URI_LIST); g_signal_connect(G_OBJECT(button), "drag-begin", G_CALLBACK(&OnButtonDragBegin), this); g_signal_connect(G_OBJECT(button), "drag-end", diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index 534766a..52832f2 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -507,7 +507,8 @@ GtkWidget* BookmarkManagerGtk::MakeRightPane() { GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_MOVE); GtkDndUtil::SetSourceTargetListFromCodeMask( - right_tree_view_, GtkDndUtil::X_CHROME_BOOKMARK_ITEM); + right_tree_view_, GtkDndUtil::X_CHROME_BOOKMARK_ITEM | + GtkDndUtil::X_CHROME_TEXT_URI_LIST); // We connect to drag dest signals, but we don't actually enable the widget // as a drag destination unless it corresponds to the contents of a folder. @@ -1134,7 +1135,8 @@ gboolean BookmarkManagerGtk::OnRightTreeViewMotion(GtkWidget* tree_view, bm->mousedown_event_.x, bm->mousedown_event_.y, event->x, event->y)) { bm->delaying_mousedown_ = false; GtkTargetList* targets = GtkDndUtil::GetTargetListFromCodeMask( - GtkDndUtil::X_CHROME_BOOKMARK_ITEM); + GtkDndUtil::X_CHROME_BOOKMARK_ITEM | + GtkDndUtil::X_CHROME_TEXT_URI_LIST); gtk_drag_begin(tree_view, targets, GDK_ACTION_MOVE, 1, reinterpret_cast<GdkEvent*>(event)); // The drag adds a ref; let it own the list. diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc index 81bea90..9e6f948 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/gtk/bookmark_utils_gtk.cc @@ -190,6 +190,24 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, pickle.size()); break; } + case GtkDndUtil::X_CHROME_TEXT_URI_LIST: { + gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * + (nodes.size() + 1))); + for (size_t i = 0; i < nodes.size(); ++i) { + // If the node is a folder, this will be empty. TODO(estade): figure out + // if there are any ramifications to passing an empty URI. After a + // lttle testing, it seems fine. + const GURL& url = nodes[i]->GetURL(); + // This const cast should be safe as gtk_selection_data_set_uris() + // makes copies. + uris[i] = const_cast<gchar*>(url.spec().c_str()); + } + uris[nodes.size()] = NULL; + + gtk_selection_data_set_uris(selection_data, uris); + free(uris); + break; + } default: { DLOG(ERROR) << "Unsupported drag get type!"; } diff --git a/chrome/browser/gtk/gtk_dnd_util.cc b/chrome/browser/gtk/gtk_dnd_util.cc index 88668f3..2174019 100644 --- a/chrome/browser/gtk/gtk_dnd_util.cc +++ b/chrome/browser/gtk/gtk_dnd_util.cc @@ -25,8 +25,14 @@ GdkAtom GtkDndUtil::GetAtomForTarget(int target) { return bookmark_atom; case X_CHROME_TEXT_PLAIN: + static GdkAtom text_atom = gdk_atom_intern( + const_cast<char*>("text/plain"), false); + return text_atom; + case X_CHROME_TEXT_URI_LIST: - return NULL; + static GdkAtom uris_atom = gdk_atom_intern( + const_cast<char*>("text/uri-list"), false); + return uris_atom; default: NOTREACHED(); |