summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 00:27:42 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 00:27:42 +0000
commit1a4a5cc452e74bd71a9702a43e8ba116900e8629 (patch)
treedfd7e3b1ba84c7fcba17446223a6b90d08015acc
parentbc04c68a59eb4b7d6e154f396f6506cba7ba73e0 (diff)
downloadchromium_src-1a4a5cc452e74bd71a9702a43e8ba116900e8629.zip
chromium_src-1a4a5cc452e74bd71a9702a43e8ba116900e8629.tar.gz
chromium_src-1a4a5cc452e74bd71a9702a43e8ba116900e8629.tar.bz2
Allow link drags from the star, bookmarks bar, and bookmark bar menus
to the Gnome desktop (nautilus). These should create shortcuts. Other drag operations should be the same as before. BUG=24210 Review URL: http://codereview.chromium.org/548067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/gtk_dnd_util.cc11
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc11
-rw-r--r--chrome/browser/gtk/bookmark_manager_gtk.cc3
-rw-r--r--chrome/browser/gtk/bookmark_menu_controller_gtk.cc6
-rw-r--r--chrome/browser/gtk/bookmark_utils_gtk.cc11
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc21
-rw-r--r--chrome/browser/gtk/toolbar_star_toggle_gtk.cc7
7 files changed, 43 insertions, 27 deletions
diff --git a/app/gtk_dnd_util.cc b/app/gtk_dnd_util.cc
index da4362dc..fb2f492 100644
--- a/app/gtk_dnd_util.cc
+++ b/app/gtk_dnd_util.cc
@@ -154,6 +154,17 @@ void GtkDndUtil::WriteURLWithName(GtkSelectionData* selection_data,
pickle.size());
break;
}
+ case NETSCAPE_URL: {
+ // _NETSCAPE_URL format is URL + \n + title.
+ std::string utf8_text = url.spec() + "\n" + UTF16ToUTF8(title);
+ gtk_selection_data_set(selection_data,
+ selection_data->target,
+ kBitsPerByte,
+ reinterpret_cast<const guchar*>(utf8_text.c_str()),
+ utf8_text.length());
+ break;
+ }
+
default: {
NOTREACHED();
break;
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index d28972e..62edacf 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -757,11 +757,14 @@ GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) {
bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_provider_);
// The tool item is also a source for dragging
- gtk_drag_source_set(button, GDK_BUTTON1_MASK,
- NULL, 0, GDK_ACTION_MOVE);
+ gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY));
int target_mask = GtkDndUtil::CHROME_BOOKMARK_ITEM;
- if (node->is_url())
- target_mask |= GtkDndUtil::TEXT_URI_LIST | GtkDndUtil::TEXT_PLAIN;
+ if (node->is_url()) {
+ target_mask |= GtkDndUtil::TEXT_URI_LIST |
+ GtkDndUtil::TEXT_PLAIN |
+ GtkDndUtil::NETSCAPE_URL;
+ }
GtkDndUtil::SetSourceTargetListFromCodeMask(button, target_mask);
g_signal_connect(G_OBJECT(button), "drag-begin",
G_CALLBACK(&OnButtonDragBegin), this);
diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc
index 11100af..4422230 100644
--- a/chrome/browser/gtk/bookmark_manager_gtk.cc
+++ b/chrome/browser/gtk/bookmark_manager_gtk.cc
@@ -62,7 +62,8 @@ const int kDestTargetList[] = { GtkDndUtil::CHROME_BOOKMARK_ITEM, -1 };
// The source targets that the right tree view supports for dragging.
const int kSourceTargetMask = GtkDndUtil::CHROME_BOOKMARK_ITEM |
GtkDndUtil::TEXT_URI_LIST |
- GtkDndUtil::TEXT_PLAIN;
+ GtkDndUtil::TEXT_PLAIN |
+ GtkDndUtil::NETSCAPE_URL;
// We only have one manager open at a time.
BookmarkManagerGtk* manager = NULL;
diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
index 4ddda23..874ce96 100644
--- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
+++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
@@ -186,11 +186,11 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent,
NOTREACHED();
}
- gtk_drag_source_set(menu_item, GDK_BUTTON1_MASK,
- NULL, 0, GDK_ACTION_MOVE);
+ gtk_drag_source_set(menu_item, GDK_BUTTON1_MASK, NULL, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK));
int target_mask = GtkDndUtil::CHROME_BOOKMARK_ITEM;
if (node->is_url())
- target_mask |= GtkDndUtil::TEXT_URI_LIST;
+ target_mask |= GtkDndUtil::TEXT_URI_LIST | GtkDndUtil::NETSCAPE_URL;
GtkDndUtil::SetSourceTargetListFromCodeMask(menu_item, target_mask);
g_signal_connect(G_OBJECT(menu_item), "drag-begin",
G_CALLBACK(&OnMenuItemDragBegin), this);
diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc
index fd09af2..05aef12 100644
--- a/chrome/browser/gtk/bookmark_utils_gtk.cc
+++ b/chrome/browser/gtk/bookmark_utils_gtk.cc
@@ -224,6 +224,17 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes,
pickle.size());
break;
}
+ case GtkDndUtil::NETSCAPE_URL: {
+ // _NETSCAPE_URL format is URL + \n + title.
+ std::string utf8_text = nodes[0]->GetURL().spec() + "\n" + UTF16ToUTF8(
+ nodes[0]->GetTitleAsString16());
+ gtk_selection_data_set(selection_data,
+ selection_data->target,
+ kBitsInAByte,
+ reinterpret_cast<const guchar*>(utf8_text.c_str()),
+ utf8_text.length());
+ break;
+ }
case GtkDndUtil::TEXT_URI_LIST: {
gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) *
(nodes.size() + 1)));
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index b9883cc..39f7bda 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -127,7 +127,7 @@ void TabContentsDragSource::DidProcessEvent(GdkEvent* event) {
void TabContentsDragSource::OnDragDataGet(
GdkDragContext* context, GtkSelectionData* selection_data,
guint target_type, guint time) {
- const int bits_per_byte = 8;
+ const int kBitsPerByte = 8;
switch (target_type) {
case GtkDndUtil::TEXT_PLAIN: {
@@ -144,35 +144,24 @@ void TabContentsDragSource::OnDragDataGet(
gtk_selection_data_set(selection_data,
GtkDndUtil::GetAtomForTarget(
GtkDndUtil::TEXT_HTML),
- bits_per_byte,
+ kBitsPerByte,
reinterpret_cast<const guchar*>(utf8_text.c_str()),
utf8_text.length());
break;
}
case GtkDndUtil::TEXT_URI_LIST:
- case GtkDndUtil::CHROME_NAMED_URL: {
+ case GtkDndUtil::CHROME_NAMED_URL:
+ case GtkDndUtil::NETSCAPE_URL: {
GtkDndUtil::WriteURLWithName(selection_data, drop_data_->url,
drop_data_->url_title, target_type);
break;
}
- case GtkDndUtil::NETSCAPE_URL: {
- // _NETSCAPE_URL format is URL + \n + title.
- std::string utf8_text = drop_data_->url.spec() + "\n" + UTF16ToUTF8(
- drop_data_->url_title);
- gtk_selection_data_set(selection_data,
- selection_data->target,
- bits_per_byte,
- reinterpret_cast<const guchar*>(utf8_text.c_str()),
- utf8_text.length());
- break;
- }
-
case GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS: {
gtk_selection_data_set(
selection_data,
- drag_file_mime_type_, bits_per_byte,
+ drag_file_mime_type_, kBitsPerByte,
reinterpret_cast<const guchar*>(drop_data_->file_contents.data()),
drop_data_->file_contents.length());
break;
diff --git a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc
index 328b5e7..e709d7b 100644
--- a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc
+++ b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc
@@ -38,12 +38,13 @@ ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host)
G_CALLBACK(OnExpose), this);
GTK_WIDGET_UNSET_FLAGS(widget_.get(), GTK_CAN_FOCUS);
- gtk_drag_source_set(widget(), GDK_BUTTON1_MASK,
- NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set(widget(), GDK_BUTTON1_MASK, NULL, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK));
GtkDndUtil::SetSourceTargetListFromCodeMask(widget(),
GtkDndUtil::TEXT_PLAIN |
GtkDndUtil::TEXT_URI_LIST |
- GtkDndUtil::CHROME_NAMED_URL);
+ GtkDndUtil::CHROME_NAMED_URL |
+ GtkDndUtil::NETSCAPE_URL);
g_signal_connect(widget(), "drag-data-get", G_CALLBACK(OnDragDataGet), this);
theme_provider_->InitThemesFor(this);