| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/omnibox/omnibox_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.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 #include "third_party/undoview/undo_view.h" |
| 36 #include "ui/base/animation/multi_animation.h" | 36 #include "ui/base/animation/multi_animation.h" |
| 37 #include "ui/base/dragdrop/drag_drop_types.h" | 37 #include "ui/base/dragdrop/drag_drop_types.h" |
| 38 #include "ui/base/dragdrop/gtk_dnd_util.h" | 38 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 39 #include "ui/base/gtk/gtk_compat.h" |
| 39 #include "ui/base/gtk/gtk_hig_constants.h" | 40 #include "ui/base/gtk/gtk_hig_constants.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 41 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 42 #include "ui/gfx/color_utils.h" | 43 #include "ui/gfx/color_utils.h" |
| 43 #include "ui/gfx/font.h" | 44 #include "ui/gfx/font.h" |
| 44 #include "ui/gfx/gtk_util.h" | 45 #include "ui/gfx/gtk_util.h" |
| 45 #include "ui/gfx/skia_utils_gtk.h" | 46 #include "ui/gfx/skia_utils_gtk.h" |
| 46 | 47 |
| 47 #if defined(TOOLKIT_VIEWS) | 48 #if defined(TOOLKIT_VIEWS) |
| 48 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" | 49 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 757 |
| 757 return something_changed; | 758 return something_changed; |
| 758 } | 759 } |
| 759 | 760 |
| 760 gfx::NativeView OmniboxViewGtk::GetNativeView() const { | 761 gfx::NativeView OmniboxViewGtk::GetNativeView() const { |
| 761 return alignment_.get(); | 762 return alignment_.get(); |
| 762 } | 763 } |
| 763 | 764 |
| 764 gfx::NativeView OmniboxViewGtk::GetRelativeWindowForPopup() const { | 765 gfx::NativeView OmniboxViewGtk::GetRelativeWindowForPopup() const { |
| 765 GtkWidget* toplevel = gtk_widget_get_toplevel(GetNativeView()); | 766 GtkWidget* toplevel = gtk_widget_get_toplevel(GetNativeView()); |
| 766 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel)); | 767 DCHECK(gtk_widget_is_toplevel(toplevel)); |
| 767 return toplevel; | 768 return toplevel; |
| 768 } | 769 } |
| 769 | 770 |
| 770 CommandUpdater* OmniboxViewGtk::GetCommandUpdater() { | 771 CommandUpdater* OmniboxViewGtk::GetCommandUpdater() { |
| 771 return command_updater_; | 772 return command_updater_; |
| 772 } | 773 } |
| 773 | 774 |
| 774 void OmniboxViewGtk::SetInstantSuggestion(const string16& suggestion, | 775 void OmniboxViewGtk::SetInstantSuggestion(const string16& suggestion, |
| 775 bool animate_to_complete) { | 776 bool animate_to_complete) { |
| 776 std::string suggestion_utf8 = UTF16ToUTF8(suggestion); | 777 std::string suggestion_utf8 = UTF16ToUTF8(suggestion); |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 GetTextBufferBounds(&start, &end); | 1926 GetTextBufferBounds(&start, &end); |
| 1926 } | 1927 } |
| 1927 if (!update_primary_selection) | 1928 if (!update_primary_selection) |
| 1928 StartUpdatingHighlightedText(); | 1929 StartUpdatingHighlightedText(); |
| 1929 gtk_text_buffer_select_range(text_buffer_, &start, &end); | 1930 gtk_text_buffer_select_range(text_buffer_, &start, &end); |
| 1930 if (!update_primary_selection) | 1931 if (!update_primary_selection) |
| 1931 FinishUpdatingHighlightedText(); | 1932 FinishUpdatingHighlightedText(); |
| 1932 } | 1933 } |
| 1933 | 1934 |
| 1934 void OmniboxViewGtk::StartUpdatingHighlightedText() { | 1935 void OmniboxViewGtk::StartUpdatingHighlightedText() { |
| 1935 if (GTK_WIDGET_REALIZED(text_view_)) { | 1936 if (gtk_widget_get_realized(text_view_)) { |
| 1936 GtkClipboard* clipboard = | 1937 GtkClipboard* clipboard = |
| 1937 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); | 1938 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); |
| 1938 DCHECK(clipboard); | 1939 DCHECK(clipboard); |
| 1939 if (clipboard) | 1940 if (clipboard) |
| 1940 gtk_text_buffer_remove_selection_clipboard(text_buffer_, clipboard); | 1941 gtk_text_buffer_remove_selection_clipboard(text_buffer_, clipboard); |
| 1941 } | 1942 } |
| 1942 g_signal_handler_block(text_buffer_, mark_set_handler_id_); | 1943 g_signal_handler_block(text_buffer_, mark_set_handler_id_); |
| 1943 g_signal_handler_block(text_buffer_, mark_set_handler_id2_); | 1944 g_signal_handler_block(text_buffer_, mark_set_handler_id2_); |
| 1944 } | 1945 } |
| 1945 | 1946 |
| 1946 void OmniboxViewGtk::FinishUpdatingHighlightedText() { | 1947 void OmniboxViewGtk::FinishUpdatingHighlightedText() { |
| 1947 if (GTK_WIDGET_REALIZED(text_view_)) { | 1948 if (gtk_widget_get_realized(text_view_)) { |
| 1948 GtkClipboard* clipboard = | 1949 GtkClipboard* clipboard = |
| 1949 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); | 1950 gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); |
| 1950 DCHECK(clipboard); | 1951 DCHECK(clipboard); |
| 1951 if (clipboard) | 1952 if (clipboard) |
| 1952 gtk_text_buffer_add_selection_clipboard(text_buffer_, clipboard); | 1953 gtk_text_buffer_add_selection_clipboard(text_buffer_, clipboard); |
| 1953 } | 1954 } |
| 1954 g_signal_handler_unblock(text_buffer_, mark_set_handler_id_); | 1955 g_signal_handler_unblock(text_buffer_, mark_set_handler_id_); |
| 1955 g_signal_handler_unblock(text_buffer_, mark_set_handler_id2_); | 1956 g_signal_handler_unblock(text_buffer_, mark_set_handler_id2_); |
| 1956 } | 1957 } |
| 1957 | 1958 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 | 2395 |
| 2395 // Make all the children of the widget visible. NOTE: this won't display | 2396 // Make all the children of the widget visible. NOTE: this won't display |
| 2396 // anything, it just toggles the visible flag. | 2397 // anything, it just toggles the visible flag. |
| 2397 gtk_widget_show_all(omnibox_view->GetNativeView()); | 2398 gtk_widget_show_all(omnibox_view->GetNativeView()); |
| 2398 // Hide the widget. NativeViewHostGtk will make it visible again as necessary. | 2399 // Hide the widget. NativeViewHostGtk will make it visible again as necessary. |
| 2399 gtk_widget_hide(omnibox_view->GetNativeView()); | 2400 gtk_widget_hide(omnibox_view->GetNativeView()); |
| 2400 | 2401 |
| 2401 return omnibox_view; | 2402 return omnibox_view; |
| 2402 } | 2403 } |
| 2403 #endif | 2404 #endif |
| OLD | NEW |