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

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

Issue 362018: Reverts some useful code accidently removed by CL http://codereview.chromium.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 G_CALLBACK(&HandleBeginUserActionThunk), this); 187 G_CALLBACK(&HandleBeginUserActionThunk), this);
188 g_signal_connect(text_buffer_, "end-user-action", 188 g_signal_connect(text_buffer_, "end-user-action",
189 G_CALLBACK(&HandleEndUserActionThunk), this); 189 G_CALLBACK(&HandleEndUserActionThunk), this);
190 g_signal_connect(text_buffer_, "insert-text", 190 g_signal_connect(text_buffer_, "insert-text",
191 G_CALLBACK(&HandleInsertTextThunk), this); 191 G_CALLBACK(&HandleInsertTextThunk), this);
192 // We connect to key press and release for special handling of a few keys. 192 // We connect to key press and release for special handling of a few keys.
193 g_signal_connect(text_view_, "key-press-event", 193 g_signal_connect(text_view_, "key-press-event",
194 G_CALLBACK(&HandleKeyPressThunk), this); 194 G_CALLBACK(&HandleKeyPressThunk), this);
195 g_signal_connect(text_view_, "key-release-event", 195 g_signal_connect(text_view_, "key-release-event",
196 G_CALLBACK(&HandleKeyReleaseThunk), this); 196 G_CALLBACK(&HandleKeyReleaseThunk), this);
197 #if defined(OS_CHROMEOS)
198 g_signal_connect(text_view_, "button-press-event", 197 g_signal_connect(text_view_, "button-press-event",
199 G_CALLBACK(&HandleViewButtonPressThunk), this); 198 G_CALLBACK(&HandleViewButtonPressThunk), this);
200 g_signal_connect(text_view_, "button-release-event", 199 g_signal_connect(text_view_, "button-release-event",
201 G_CALLBACK(&HandleViewButtonReleaseThunk), this); 200 G_CALLBACK(&HandleViewButtonReleaseThunk), this);
202 #endif
203 g_signal_connect(text_view_, "focus-in-event", 201 g_signal_connect(text_view_, "focus-in-event",
204 G_CALLBACK(&HandleViewFocusInThunk), this); 202 G_CALLBACK(&HandleViewFocusInThunk), this);
205 g_signal_connect(text_view_, "focus-out-event", 203 g_signal_connect(text_view_, "focus-out-event",
206 G_CALLBACK(&HandleViewFocusOutThunk), this); 204 G_CALLBACK(&HandleViewFocusOutThunk), this);
207 // NOTE: The GtkTextView documentation asks you not to connect to this 205 // NOTE: The GtkTextView documentation asks you not to connect to this
208 // signal, but it is very convenient and clean for catching up/down. 206 // signal, but it is very convenient and clean for catching up/down.
209 g_signal_connect(text_view_, "move-cursor", 207 g_signal_connect(text_view_, "move-cursor",
210 G_CALLBACK(&HandleViewMoveCursorThunk), this); 208 G_CALLBACK(&HandleViewMoveCursorThunk), this);
211 g_signal_connect(text_view_, "move-focus", 209 g_signal_connect(text_view_, "move-focus",
212 G_CALLBACK(&HandleViewMoveFocusThunk), this); 210 G_CALLBACK(&HandleViewMoveFocusThunk), this);
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (!(mod & GDK_CONTROL_MASK)) 717 if (!(mod & GDK_CONTROL_MASK))
720 model_->OnControlKeyChanged(false); 718 model_->OnControlKeyChanged(false);
721 } 719 }
722 720
723 // Even though we handled the press ourselves, let GtkTextView handle the 721 // Even though we handled the press ourselves, let GtkTextView handle the
724 // release. It shouldn't do anything particularly interesting, but it will 722 // release. It shouldn't do anything particularly interesting, but it will
725 // handle the IME work for us. 723 // handle the IME work for us.
726 return FALSE; // Propagate into GtkTextView. 724 return FALSE; // Propagate into GtkTextView.
727 } 725 }
728 726
729 #if defined(OS_CHROMEOS)
730 gboolean AutocompleteEditViewGtk::HandleViewButtonPress(GdkEventButton* event) { 727 gboolean AutocompleteEditViewGtk::HandleViewButtonPress(GdkEventButton* event) {
731 // We don't need to care about double and triple clicks. 728 // We don't need to care about double and triple clicks.
732 if (event->type != GDK_BUTTON_PRESS) 729 if (event->type != GDK_BUTTON_PRESS)
733 return FALSE; 730 return FALSE;
734 731
735 if (event->button == 1) { 732 if (event->button == 1) {
733 #if defined(OS_CHROMEOS)
736 // When the first button is pressed, track some stuff that will help us 734 // When the first button is pressed, track some stuff that will help us
737 // determine whether we should select all of the text when the button is 735 // determine whether we should select all of the text when the button is
738 // released. 736 // released.
739 button_1_pressed_ = true; 737 button_1_pressed_ = true;
740 text_view_focused_before_button_press_ = GTK_WIDGET_HAS_FOCUS(text_view_); 738 text_view_focused_before_button_press_ = GTK_WIDGET_HAS_FOCUS(text_view_);
741 text_selected_during_click_ = false; 739 text_selected_during_click_ = false;
740 #endif
742 741
743 // Button press event may change the selection, we need to record the change 742 // Button press event may change the selection, we need to record the change
744 // and report it to |model_| later when button is released. 743 // and report it to |model_| later when button is released.
745 OnBeforePossibleChange(); 744 OnBeforePossibleChange();
746 } else if (event->button == 2) { 745 } else if (event->button == 2) {
747 // GtkTextView pastes PRIMARY selection with middle click. 746 // GtkTextView pastes PRIMARY selection with middle click.
748 // We can't call model_->on_paste_replacing_all() here, because the actual 747 // We can't call model_->on_paste_replacing_all() here, because the actual
749 // paste clipboard action may not be performed if the clipboard is empty. 748 // paste clipboard action may not be performed if the clipboard is empty.
750 paste_clipboard_requested_ = true; 749 paste_clipboard_requested_ = true;
751 } 750 }
752 return FALSE; 751 return FALSE;
753 } 752 }
754 753
755 gboolean AutocompleteEditViewGtk::HandleViewButtonRelease( 754 gboolean AutocompleteEditViewGtk::HandleViewButtonRelease(
756 GdkEventButton* event) { 755 GdkEventButton* event) {
757 if (event->button != 1) 756 if (event->button != 1)
758 return FALSE; 757 return FALSE;
759 758
759 #if defined(OS_CHROMEOS)
760 button_1_pressed_ = false; 760 button_1_pressed_ = false;
761 #endif
761 762
762 // Call the GtkTextView default handler, ignoring the fact that it will 763 // Call the GtkTextView default handler, ignoring the fact that it will
763 // likely have told us to stop propagating. We want to handle selection. 764 // likely have told us to stop propagating. We want to handle selection.
764 GtkWidgetClass* klass = GTK_WIDGET_GET_CLASS(text_view_); 765 GtkWidgetClass* klass = GTK_WIDGET_GET_CLASS(text_view_);
765 klass->button_release_event(text_view_, event); 766 klass->button_release_event(text_view_, event);
766 767
768 #if defined(OS_CHROMEOS)
767 if (!text_view_focused_before_button_press_ && !text_selected_during_click_) { 769 if (!text_view_focused_before_button_press_ && !text_selected_during_click_) {
768 // If this was a focusing click and the user didn't drag to highlight any 770 // If this was a focusing click and the user didn't drag to highlight any
769 // text, select the full input and update the PRIMARY selection. 771 // text, select the full input and update the PRIMARY selection.
770 SelectAllInternal(false, true); 772 SelectAllInternal(false, true);
771 773
772 // So we told the buffer where the cursor should be, but make sure to tell 774 // So we told the buffer where the cursor should be, but make sure to tell
773 // the view so it can scroll it to be visible if needed. 775 // the view so it can scroll it to be visible if needed.
774 // NOTE: This function doesn't seem to like a count of 0, looking at the 776 // NOTE: This function doesn't seem to like a count of 0, looking at the
775 // code it will skip an important loop. Use -1 to achieve the same. 777 // code it will skip an important loop. Use -1 to achieve the same.
776 GtkTextIter start, end; 778 GtkTextIter start, end;
777 gtk_text_buffer_get_bounds(text_buffer_, &start, &end); 779 gtk_text_buffer_get_bounds(text_buffer_, &start, &end);
778 gtk_text_view_move_visually(GTK_TEXT_VIEW(text_view_), &start, -1); 780 gtk_text_view_move_visually(GTK_TEXT_VIEW(text_view_), &start, -1);
779 } 781 }
782 #endif
780 783
781 // Inform |model_| about possible text selection change. 784 // Inform |model_| about possible text selection change.
782 OnAfterPossibleChange(); 785 OnAfterPossibleChange();
783 786
784 return TRUE; // Don't continue, we called the default handler already. 787 return TRUE; // Don't continue, we called the default handler already.
785 } 788 }
786 #endif
787 789
788 gboolean AutocompleteEditViewGtk::HandleViewFocusIn() { 790 gboolean AutocompleteEditViewGtk::HandleViewFocusIn() {
789 GdkModifierType modifiers; 791 GdkModifierType modifiers;
790 gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers); 792 gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers);
791 model_->OnSetFocus((modifiers & GDK_CONTROL_MASK) != 0); 793 model_->OnSetFocus((modifiers & GDK_CONTROL_MASK) != 0);
792 controller_->OnSetFocus(); 794 controller_->OnSetFocus();
793 // TODO(deanm): Some keyword hit business, etc here. 795 // TODO(deanm): Some keyword hit business, etc here.
794 796
795 return FALSE; // Continue propagation. 797 return FALSE; // Continue propagation.
796 } 798 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 std::string utf8 = WideToUTF8(text); 1287 std::string utf8 = WideToUTF8(text);
1286 gtk_text_buffer_set_text(text_buffer_, utf8.data(), utf8.length()); 1288 gtk_text_buffer_set_text(text_buffer_, utf8.data(), utf8.length());
1287 SetSelectedRange(range); 1289 SetSelectedRange(range);
1288 } 1290 }
1289 1291
1290 void AutocompleteEditViewGtk::SetSelectedRange(const CharRange& range) { 1292 void AutocompleteEditViewGtk::SetSelectedRange(const CharRange& range) {
1291 GtkTextIter insert, bound; 1293 GtkTextIter insert, bound;
1292 ItersFromCharRange(range, &bound, &insert); 1294 ItersFromCharRange(range, &bound, &insert);
1293 gtk_text_buffer_select_range(text_buffer_, &insert, &bound); 1295 gtk_text_buffer_select_range(text_buffer_, &insert, &bound);
1294 } 1296 }
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