| 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 "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 13 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 15 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
| 16 #include "chrome/browser/gtk/location_bar_view_gtk.h" | 16 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/toolbar_model.h" | 18 #include "chrome/browser/toolbar_model.h" |
| 19 #include "chrome/common/gtk_util.h" |
| 19 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
| 20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const char kTextBaseColor[] = "#808080"; | 25 const char kTextBaseColor[] = "#808080"; |
| 25 const char kSecureSchemeColor[] = "#009614"; | 26 const char kSecureSchemeColor[] = "#009614"; |
| 26 const char kInsecureSchemeColor[] = "#c80000"; | 27 const char kInsecureSchemeColor[] = "#c80000"; |
| 27 | 28 |
| 28 size_t GetUTF8Offset(const std::wstring& wide_text, size_t wide_text_offset) { | 29 size_t GetUTF8Offset(const std::wstring& wide_text, size_t wide_text_offset) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // The height of the text view is going to change based on the font used. We | 80 // The height of the text view is going to change based on the font used. We |
| 80 // don't want to stretch the height, and we want it vertically centered. | 81 // don't want to stretch the height, and we want it vertically centered. |
| 81 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0)); | 82 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0)); |
| 82 | 83 |
| 83 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have | 84 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have |
| 84 // our own reference when we create them, and we own them. Adding them to | 85 // our own reference when we create them, and we own them. Adding them to |
| 85 // the other objects adds a reference; it doesn't adopt them. | 86 // the other objects adds a reference; it doesn't adopt them. |
| 86 tag_table_ = gtk_text_tag_table_new(); | 87 tag_table_ = gtk_text_tag_table_new(); |
| 87 text_buffer_ = gtk_text_buffer_new(tag_table_); | 88 text_buffer_ = gtk_text_buffer_new(tag_table_); |
| 88 text_view_ = gtk_text_view_new_with_buffer(text_buffer_); | 89 text_view_ = gtk_text_view_new_with_buffer(text_buffer_); |
| 90 // Until we switch to vector graphics, force the font size. |
| 91 gtk_util::ForceFontSizePixels(text_view_, 13.4); // 13.4px == 10pt @ 96dpi |
| 89 | 92 |
| 90 // The text view was floating. It will now be owned by the alignment. | 93 // The text view was floating. It will now be owned by the alignment. |
| 91 gtk_container_add(GTK_CONTAINER(alignment_.get()), text_view_); | 94 gtk_container_add(GTK_CONTAINER(alignment_.get()), text_view_); |
| 92 | 95 |
| 93 // TODO(deanm): This will probably have to be handled differently with the | 96 // TODO(deanm): This will probably have to be handled differently with the |
| 94 // tab to search business. Maybe we should just eat the tab characters. | 97 // tab to search business. Maybe we should just eat the tab characters. |
| 95 // We want the tab key to move focus, not insert a tab. | 98 // We want the tab key to move focus, not insert a tab. |
| 96 gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(text_view_), false); | 99 gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(text_view_), false); |
| 97 | 100 |
| 98 base_tag_ = gtk_text_buffer_create_tag(text_buffer_, | 101 base_tag_ = gtk_text_buffer_create_tag(text_buffer_, |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 gtk_text_buffer_apply_tag(text_buffer_, insecure_scheme_tag_, | 543 gtk_text_buffer_apply_tag(text_buffer_, insecure_scheme_tag_, |
| 541 &start, &end); | 544 &start, &end); |
| 542 } | 545 } |
| 543 } | 546 } |
| 544 } | 547 } |
| 545 | 548 |
| 546 void AutocompleteEditViewGtk::TextChanged() { | 549 void AutocompleteEditViewGtk::TextChanged() { |
| 547 EmphasizeURLComponents(); | 550 EmphasizeURLComponents(); |
| 548 controller_->OnChanged(); | 551 controller_->OnChanged(); |
| 549 } | 552 } |
| OLD | NEW |