Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4104)

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc

Issue 160369: GTK: Implement omnibox DnD destination behavior. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc (revision 21986)
+++ chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc (working copy)
@@ -192,6 +192,8 @@
G_CALLBACK(&HandlePopulatePopupThunk), this);
mark_set_handler_id_ = g_signal_connect(
text_buffer_, "mark-set", G_CALLBACK(&HandleMarkSetThunk), this);
+ g_signal_connect(text_view_, "drag-data-received",
+ G_CALLBACK(&HandleDragDataReceivedThunk), this);
}
void AutocompleteEditViewGtk::SetFocus() {
@@ -671,6 +673,29 @@
}
}
+// Just use the default behavior for DnD, except if the drop can be a PasteAndGo
+// then override.
+void AutocompleteEditViewGtk::HandleDragDataReceived(
+ GdkDragContext* context, gint x, gint y,
+ GtkSelectionData* selection_data, guint target_type, guint time) {
+ // Don't try to PasteAndGo on drops originating from this omnibox. However, do
+ // allow default behavior for such drags.
+ if (context->source_window == text_view_->window)
+ return;
+
+ guchar* text = gtk_selection_data_get_text(selection_data);
+ if (!text)
+ return;
+
+ std::wstring possible_url = UTF8ToWide(reinterpret_cast<char*>(text));
+ g_free(text);
+ if (model_->CanPasteAndGo(CollapseWhitespace(possible_url, true))) {
+ model_->PasteAndGo();
+ gtk_drag_finish(context, TRUE, TRUE, time);
+ g_signal_stop_emission_by_name(text_view_, "drag-data-received");
+ }
+}
+
void AutocompleteEditViewGtk::SelectAllInternal(bool reversed,
bool update_primary_selection) {
GtkTextIter start, end;
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698