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

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

Issue 164539: Linux: Update PRIMARY selection on omnibox copy-to-clipboard. (Closed)
Patch Set: Created 11 years, 4 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
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 6940b4bda1fe7f80a06784677ee2213b8d0a4a36..108956f1aed4d4710251d90f8a48356f9c5ea746 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -209,6 +209,8 @@ void AutocompleteEditViewGtk::Init() {
G_CALLBACK(&HandleDragDataReceivedThunk), this);
g_signal_connect(text_view_, "backspace",
G_CALLBACK(&HandleBackSpaceThunk), this);
+ g_signal_connect(text_view_, "copy-clipboard",
+ G_CALLBACK(&HandleCopyClipboardThunk), this);
#if !defined(TOOLKIT_VIEWS)
registrar_.Add(this,
@@ -907,6 +909,20 @@ void AutocompleteEditViewGtk::HandleBackSpace() {
g_signal_stop_emission(text_view_, signal_id, 0);
}
+void AutocompleteEditViewGtk::HandleCopyClipboard() {
+ // On copy, we manually update the PRIMARY selection to contain the
+ // highlighted text. This matches Firefox -- we highlight the URL but don't
+ // update PRIMARY on Ctrl-L, so Ctrl-L, Ctrl-C and then middle-click is a
+ // convenient way to paste the current URL somewhere.
+ GtkTextIter start, end;
+ if (!gtk_text_buffer_get_selection_bounds(text_buffer_, &start, &end))
+ return;
+
+ gchar* text = gtk_text_buffer_get_text(text_buffer_, &start, &end, FALSE);
+ SavePrimarySelection(text);
+ g_free(text);
+}
+
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