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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc

Issue 174058: Linux: Revert updating PRIMARY selection on Ctrl-C in omnibox. (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 unified diff | Download patch
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 g_signal_connect(text_view_, "size-request", 203 g_signal_connect(text_view_, "size-request",
204 G_CALLBACK(&HandleViewSizeRequestThunk), this); 204 G_CALLBACK(&HandleViewSizeRequestThunk), this);
205 g_signal_connect(text_view_, "populate-popup", 205 g_signal_connect(text_view_, "populate-popup",
206 G_CALLBACK(&HandlePopulatePopupThunk), this); 206 G_CALLBACK(&HandlePopulatePopupThunk), this);
207 mark_set_handler_id_ = g_signal_connect( 207 mark_set_handler_id_ = g_signal_connect(
208 text_buffer_, "mark-set", G_CALLBACK(&HandleMarkSetThunk), this); 208 text_buffer_, "mark-set", G_CALLBACK(&HandleMarkSetThunk), this);
209 g_signal_connect(text_view_, "drag-data-received", 209 g_signal_connect(text_view_, "drag-data-received",
210 G_CALLBACK(&HandleDragDataReceivedThunk), this); 210 G_CALLBACK(&HandleDragDataReceivedThunk), this);
211 g_signal_connect(text_view_, "backspace", 211 g_signal_connect(text_view_, "backspace",
212 G_CALLBACK(&HandleBackSpaceThunk), this); 212 G_CALLBACK(&HandleBackSpaceThunk), this);
213 g_signal_connect(text_view_, "copy-clipboard",
214 G_CALLBACK(&HandleCopyClipboardThunk), this);
215 213
216 #if !defined(TOOLKIT_VIEWS) 214 #if !defined(TOOLKIT_VIEWS)
217 registrar_.Add(this, 215 registrar_.Add(this,
218 NotificationType::BROWSER_THEME_CHANGED, 216 NotificationType::BROWSER_THEME_CHANGED,
219 NotificationService::AllSources()); 217 NotificationService::AllSources());
220 theme_provider_->InitThemesFor(this); 218 theme_provider_->InitThemesFor(this);
221 #else 219 #else
222 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe 220 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe
223 // themes. 221 // themes.
224 SetBaseColor(); 222 SetBaseColor();
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 914
917 // We're showing a keyword and the user pressed backspace at the beginning 915 // We're showing a keyword and the user pressed backspace at the beginning
918 // of the text. Delete the selected keyword. 916 // of the text. Delete the selected keyword.
919 model_->ClearKeyword(GetText()); 917 model_->ClearKeyword(GetText());
920 918
921 // Stop propagating the signal emission into GtkTextView. 919 // Stop propagating the signal emission into GtkTextView.
922 static guint signal_id = g_signal_lookup("backspace", GTK_TYPE_TEXT_VIEW); 920 static guint signal_id = g_signal_lookup("backspace", GTK_TYPE_TEXT_VIEW);
923 g_signal_stop_emission(text_view_, signal_id, 0); 921 g_signal_stop_emission(text_view_, signal_id, 0);
924 } 922 }
925 923
926 void AutocompleteEditViewGtk::HandleCopyClipboard() {
927 // On copy, we manually update the PRIMARY selection to contain the
928 // highlighted text. This matches Firefox -- we highlight the URL but don't
929 // update PRIMARY on Ctrl-L, so Ctrl-L, Ctrl-C and then middle-click is a
930 // convenient way to paste the current URL somewhere.
931 GtkTextIter start, end;
932 if (!gtk_text_buffer_get_selection_bounds(text_buffer_, &start, &end))
933 return;
934
935 gchar* text = gtk_text_buffer_get_text(text_buffer_, &start, &end, FALSE);
936 SavePrimarySelection(text);
937 g_free(text);
938 }
939
940 void AutocompleteEditViewGtk::SelectAllInternal(bool reversed, 924 void AutocompleteEditViewGtk::SelectAllInternal(bool reversed,
941 bool update_primary_selection) { 925 bool update_primary_selection) {
942 GtkTextIter start, end; 926 GtkTextIter start, end;
943 if (reversed) { 927 if (reversed) {
944 gtk_text_buffer_get_bounds(text_buffer_, &end, &start); 928 gtk_text_buffer_get_bounds(text_buffer_, &end, &start);
945 } else { 929 } else {
946 gtk_text_buffer_get_bounds(text_buffer_, &start, &end); 930 gtk_text_buffer_get_bounds(text_buffer_, &start, &end);
947 } 931 }
948 if (!update_primary_selection) 932 if (!update_primary_selection)
949 StartUpdatingHighlightedText(); 933 StartUpdatingHighlightedText();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 const std::string& selected_text) { 1049 const std::string& selected_text) {
1066 GtkClipboard* clipboard = 1050 GtkClipboard* clipboard =
1067 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); 1051 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY);
1068 DCHECK(clipboard); 1052 DCHECK(clipboard);
1069 if (!clipboard) 1053 if (!clipboard)
1070 return; 1054 return;
1071 1055
1072 gtk_clipboard_set_text( 1056 gtk_clipboard_set_text(
1073 clipboard, selected_text.data(), selected_text.size()); 1057 clipboard, selected_text.data(), selected_text.size());
1074 } 1058 }
OLDNEW
« 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