OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/gtk/view_id_util.h" | 25 #include "chrome/browser/gtk/view_id_util.h" |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 26 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/browser/toolbar_model.h" | 27 #include "chrome/browser/toolbar_model.h" |
28 #include "chrome/common/notification_service.h" | 28 #include "chrome/common/notification_service.h" |
29 #include "gfx/font.h" | 29 #include "gfx/font.h" |
30 #include "gfx/gtk_util.h" | 30 #include "gfx/gtk_util.h" |
31 #include "gfx/skia_utils_gtk.h" | 31 #include "gfx/skia_utils_gtk.h" |
32 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
34 #include "net/base/escape.h" | 34 #include "net/base/escape.h" |
| 35 #include "third_party/undoview/undo_view.h" |
35 | 36 |
36 #if defined(TOOLKIT_VIEWS) | 37 #if defined(TOOLKIT_VIEWS) |
37 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 38 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
38 #include "chrome/browser/views/location_bar/location_bar_view.h" | 39 #include "chrome/browser/views/location_bar/location_bar_view.h" |
39 #else | 40 #else |
40 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 41 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
41 #include "chrome/browser/gtk/gtk_theme_provider.h" | 42 #include "chrome/browser/gtk/gtk_theme_provider.h" |
42 #include "chrome/browser/gtk/location_bar_view_gtk.h" | 43 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
43 #endif | 44 #endif |
44 | 45 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0)); | 210 alignment_.Own(gtk_alignment_new(0., 0.5, 1.0, 0.0)); |
210 gtk_widget_set_name(alignment_.get(), | 211 gtk_widget_set_name(alignment_.get(), |
211 "chrome-autocomplete-edit-view"); | 212 "chrome-autocomplete-edit-view"); |
212 | 213 |
213 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have | 214 // The GtkTagTable and GtkTextBuffer are not initially unowned, so we have |
214 // our own reference when we create them, and we own them. Adding them to | 215 // our own reference when we create them, and we own them. Adding them to |
215 // the other objects adds a reference; it doesn't adopt them. | 216 // the other objects adds a reference; it doesn't adopt them. |
216 tag_table_ = gtk_text_tag_table_new(); | 217 tag_table_ = gtk_text_tag_table_new(); |
217 text_buffer_ = gtk_text_buffer_new(tag_table_); | 218 text_buffer_ = gtk_text_buffer_new(tag_table_); |
218 g_object_set_data(G_OBJECT(text_buffer_), kAutocompleteEditViewGtkKey, this); | 219 g_object_set_data(G_OBJECT(text_buffer_), kAutocompleteEditViewGtkKey, this); |
219 text_view_ = gtk_text_view_new_with_buffer(text_buffer_); | 220 text_view_ = gtk_undo_view_new(text_buffer_); |
220 if (popup_window_mode_) | 221 if (popup_window_mode_) |
221 gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view_), false); | 222 gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view_), false); |
222 | 223 |
223 // One pixel left margin is necessary to make the cursor visible when UI | 224 // One pixel left margin is necessary to make the cursor visible when UI |
224 // language direction is LTR but |text_buffer_|'s content direction is RTL. | 225 // language direction is LTR but |text_buffer_|'s content direction is RTL. |
225 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_view_), 1); | 226 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_view_), 1); |
226 | 227 |
227 // See SetEntryStyle() comments. | 228 // See SetEntryStyle() comments. |
228 gtk_widget_set_name(text_view_, "chrome-location-bar-entry"); | 229 gtk_widget_set_name(text_view_, "chrome-location-bar-entry"); |
229 | 230 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 CharRange selection = GetSelection(); | 1598 CharRange selection = GetSelection(); |
1598 GURL url; | 1599 GURL url; |
1599 bool write_url; | 1600 bool write_url; |
1600 model_->AdjustTextForCopy(selection.selection_min(), IsSelectAll(), &text, | 1601 model_->AdjustTextForCopy(selection.selection_min(), IsSelectAll(), &text, |
1601 &url, &write_url); | 1602 &url, &write_url); |
1602 if (write_url) { | 1603 if (write_url) { |
1603 selected_text_ = WideToUTF8(text); | 1604 selected_text_ = WideToUTF8(text); |
1604 OwnPrimarySelection(selected_text_); | 1605 OwnPrimarySelection(selected_text_); |
1605 } | 1606 } |
1606 } | 1607 } |
OLD | NEW |