| 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 "app/gfx/font.h" |
| 10 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 11 #include "base/gfx/gtk_util.h" | 12 #include "base/gfx/gtk_util.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 14 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 16 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
| 18 #include "chrome/browser/command_updater.h" | 19 #include "chrome/browser/command_updater.h" |
| 19 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 CommandUpdater* command_updater, | 73 CommandUpdater* command_updater, |
| 73 bool popup_window_mode, | 74 bool popup_window_mode, |
| 74 AutocompletePopupPositioner* popup_positioner) | 75 AutocompletePopupPositioner* popup_positioner) |
| 75 : text_view_(NULL), | 76 : text_view_(NULL), |
| 76 tag_table_(NULL), | 77 tag_table_(NULL), |
| 77 text_buffer_(NULL), | 78 text_buffer_(NULL), |
| 78 base_tag_(NULL), | 79 base_tag_(NULL), |
| 79 secure_scheme_tag_(NULL), | 80 secure_scheme_tag_(NULL), |
| 80 insecure_scheme_tag_(NULL), | 81 insecure_scheme_tag_(NULL), |
| 81 model_(new AutocompleteEditModel(this, controller, profile)), | 82 model_(new AutocompleteEditModel(this, controller, profile)), |
| 82 popup_view_(new AutocompletePopupViewGtk(this, model_.get(), profile, | 83 popup_view_(AutocompletePopupView::CreatePopupView(gfx::Font(), this, |
| 83 popup_positioner)), | 84 model_.get(), |
| 85 profile, |
| 86 popup_positioner)), |
| 84 controller_(controller), | 87 controller_(controller), |
| 85 toolbar_model_(toolbar_model), | 88 toolbar_model_(toolbar_model), |
| 86 command_updater_(command_updater), | 89 command_updater_(command_updater), |
| 87 popup_window_mode_(popup_window_mode), | 90 popup_window_mode_(popup_window_mode), |
| 88 scheme_security_level_(ToolbarModel::NORMAL), | 91 scheme_security_level_(ToolbarModel::NORMAL), |
| 89 selection_saved_(false), | 92 selection_saved_(false), |
| 90 mark_set_handler_id_(0), | 93 mark_set_handler_id_(0), |
| 91 button_1_pressed_(false), | 94 button_1_pressed_(false), |
| 92 text_selected_during_click_(false), | 95 text_selected_during_click_(false), |
| 93 text_view_focused_before_button_press_(false) { | 96 text_view_focused_before_button_press_(false) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 422 |
| 420 bool something_changed = model_->OnAfterPossibleChange(new_text, | 423 bool something_changed = model_->OnAfterPossibleChange(new_text, |
| 421 selection_differs, text_differs, just_deleted_text, at_end_of_edit); | 424 selection_differs, text_differs, just_deleted_text, at_end_of_edit); |
| 422 | 425 |
| 423 if (something_changed && text_differs) | 426 if (something_changed && text_differs) |
| 424 TextChanged(); | 427 TextChanged(); |
| 425 | 428 |
| 426 return something_changed; | 429 return something_changed; |
| 427 } | 430 } |
| 428 | 431 |
| 432 gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const { |
| 433 return alignment_.get(); |
| 434 } |
| 435 |
| 429 void AutocompleteEditViewGtk::HandleBeginUserAction() { | 436 void AutocompleteEditViewGtk::HandleBeginUserAction() { |
| 430 OnBeforePossibleChange(); | 437 OnBeforePossibleChange(); |
| 431 } | 438 } |
| 432 | 439 |
| 433 void AutocompleteEditViewGtk::HandleEndUserAction() { | 440 void AutocompleteEditViewGtk::HandleEndUserAction() { |
| 434 // Eat any newline / paragraphs that might have come in, for example in a | 441 // Eat any newline / paragraphs that might have come in, for example in a |
| 435 // copy and paste. We want to make sure our widget stays single line. | 442 // copy and paste. We want to make sure our widget stays single line. |
| 436 for (;;) { | 443 for (;;) { |
| 437 GtkTextIter cur; | 444 GtkTextIter cur; |
| 438 gtk_text_buffer_get_start_iter(text_buffer_, &cur); | 445 gtk_text_buffer_get_start_iter(text_buffer_, &cur); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 const std::string& selected_text) { | 810 const std::string& selected_text) { |
| 804 GtkClipboard* clipboard = | 811 GtkClipboard* clipboard = |
| 805 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); | 812 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); |
| 806 DCHECK(clipboard); | 813 DCHECK(clipboard); |
| 807 if (!clipboard) | 814 if (!clipboard) |
| 808 return; | 815 return; |
| 809 | 816 |
| 810 gtk_clipboard_set_text( | 817 gtk_clipboard_set_text( |
| 811 clipboard, selected_text.data(), selected_text.size()); | 818 clipboard, selected_text.data(), selected_text.size()); |
| 812 } | 819 } |
| OLD | NEW |