OLD | NEW |
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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 if (something_changed && text_differs) | 498 if (something_changed && text_differs) |
499 TextChanged(); | 499 TextChanged(); |
500 | 500 |
501 return something_changed; | 501 return something_changed; |
502 } | 502 } |
503 | 503 |
504 gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const { | 504 gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const { |
505 return alignment_.get(); | 505 return alignment_.get(); |
506 } | 506 } |
507 | 507 |
508 gfx::NativeView AutocompleteEditViewGtk::GetFocusNativeView() const { | |
509 return text_view_; | |
510 } | |
511 | |
512 void AutocompleteEditViewGtk::Observe(NotificationType type, | 508 void AutocompleteEditViewGtk::Observe(NotificationType type, |
513 const NotificationSource& source, | 509 const NotificationSource& source, |
514 const NotificationDetails& details) { | 510 const NotificationDetails& details) { |
515 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 511 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
516 | 512 |
517 SetBaseColor(); | 513 SetBaseColor(); |
518 } | 514 } |
519 | 515 |
520 void AutocompleteEditViewGtk::SetBaseColor() { | 516 void AutocompleteEditViewGtk::SetBaseColor() { |
521 #if defined(TOOLKIT_VIEWS) | 517 #if defined(TOOLKIT_VIEWS) |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 gtk_text_view_move_visually(GTK_TEXT_VIEW(text_view_), &start, -1); | 749 gtk_text_view_move_visually(GTK_TEXT_VIEW(text_view_), &start, -1); |
754 } | 750 } |
755 | 751 |
756 return TRUE; // Don't continue, we called the default handler already. | 752 return TRUE; // Don't continue, we called the default handler already. |
757 } | 753 } |
758 | 754 |
759 gboolean AutocompleteEditViewGtk::HandleViewFocusIn() { | 755 gboolean AutocompleteEditViewGtk::HandleViewFocusIn() { |
760 GdkModifierType modifiers; | 756 GdkModifierType modifiers; |
761 gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers); | 757 gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers); |
762 model_->OnSetFocus((modifiers & GDK_CONTROL_MASK) != 0); | 758 model_->OnSetFocus((modifiers & GDK_CONTROL_MASK) != 0); |
| 759 controller_->OnSetFocus(); |
763 // TODO(deanm): Some keyword hit business, etc here. | 760 // TODO(deanm): Some keyword hit business, etc here. |
764 | 761 |
765 return FALSE; // Continue propagation. | 762 return FALSE; // Continue propagation. |
766 } | 763 } |
767 | 764 |
768 gboolean AutocompleteEditViewGtk::HandleViewFocusOut() { | 765 gboolean AutocompleteEditViewGtk::HandleViewFocusOut() { |
769 // Close the popup. | 766 // Close the popup. |
770 ClosePopup(); | 767 ClosePopup(); |
771 // Tell the model to reset itself. | 768 // Tell the model to reset itself. |
772 model_->OnKillFocus(); | 769 model_->OnKillFocus(); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 std::string utf8 = WideToUTF8(text); | 1177 std::string utf8 = WideToUTF8(text); |
1181 gtk_text_buffer_set_text(text_buffer_, utf8.data(), utf8.length()); | 1178 gtk_text_buffer_set_text(text_buffer_, utf8.data(), utf8.length()); |
1182 SetSelectedRange(range); | 1179 SetSelectedRange(range); |
1183 } | 1180 } |
1184 | 1181 |
1185 void AutocompleteEditViewGtk::SetSelectedRange(const CharRange& range) { | 1182 void AutocompleteEditViewGtk::SetSelectedRange(const CharRange& range) { |
1186 GtkTextIter insert, bound; | 1183 GtkTextIter insert, bound; |
1187 ItersFromCharRange(range, &bound, &insert); | 1184 ItersFromCharRange(range, &bound, &insert); |
1188 gtk_text_buffer_select_range(text_buffer_, &insert, &bound); | 1185 gtk_text_buffer_select_range(text_buffer_, &insert, &bound); |
1189 } | 1186 } |
OLD | NEW |