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> |
11 | 11 |
12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/multi_animation.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
17 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 18 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" |
19 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 20 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
20 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 21 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/command_updater.h" | 23 #include "chrome/browser/command_updater.h" |
23 #include "chrome/browser/defaults.h" | 24 #include "chrome/browser/defaults.h" |
24 #include "chrome/browser/gtk/gtk_util.h" | 25 #include "chrome/browser/gtk/gtk_util.h" |
25 #include "chrome/browser/gtk/view_id_util.h" | 26 #include "chrome/browser/gtk/view_id_util.h" |
| 27 #include "chrome/browser/instant/instant_controller.h" |
26 #include "chrome/browser/platform_util.h" | 28 #include "chrome/browser/platform_util.h" |
27 #include "chrome/browser/tab_contents/tab_contents.h" | 29 #include "chrome/browser/tab_contents/tab_contents.h" |
28 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 30 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
29 #include "chrome/common/notification_service.h" | 31 #include "chrome/common/notification_service.h" |
| 32 #include "gfx/color_utils.h" |
30 #include "gfx/font.h" | 33 #include "gfx/font.h" |
31 #include "gfx/gtk_util.h" | 34 #include "gfx/gtk_util.h" |
32 #include "gfx/skia_utils_gtk.h" | 35 #include "gfx/skia_utils_gtk.h" |
33 #include "googleurl/src/gurl.h" | 36 #include "googleurl/src/gurl.h" |
34 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
35 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
36 #include "third_party/undoview/undo_view.h" | 39 #include "third_party/undoview/undo_view.h" |
37 | 40 |
38 #if defined(TOOLKIT_VIEWS) | 41 #if defined(TOOLKIT_VIEWS) |
39 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 42 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 g_signal_connect(text_view_, "redo", G_CALLBACK(&HandleUndoRedoThunk), this); | 333 g_signal_connect(text_view_, "redo", G_CALLBACK(&HandleUndoRedoThunk), this); |
331 g_signal_connect_after(text_view_, "undo", | 334 g_signal_connect_after(text_view_, "undo", |
332 G_CALLBACK(&HandleUndoRedoAfterThunk), this); | 335 G_CALLBACK(&HandleUndoRedoAfterThunk), this); |
333 g_signal_connect_after(text_view_, "redo", | 336 g_signal_connect_after(text_view_, "redo", |
334 G_CALLBACK(&HandleUndoRedoAfterThunk), this); | 337 G_CALLBACK(&HandleUndoRedoAfterThunk), this); |
335 | 338 |
336 // Setup for the Instant suggestion text view. | 339 // Setup for the Instant suggestion text view. |
337 // GtkLabel is used instead of GtkTextView to get transparent background. | 340 // GtkLabel is used instead of GtkTextView to get transparent background. |
338 instant_view_ = gtk_label_new(NULL); | 341 instant_view_ = gtk_label_new(NULL); |
339 gtk_widget_set_no_show_all(instant_view_, TRUE); | 342 gtk_widget_set_no_show_all(instant_view_, TRUE); |
| 343 gtk_label_set_selectable(GTK_LABEL(instant_view_), TRUE); |
340 | 344 |
341 GtkTextIter end_iter; | 345 GtkTextIter end_iter; |
342 gtk_text_buffer_get_end_iter(text_buffer_, &end_iter); | 346 gtk_text_buffer_get_end_iter(text_buffer_, &end_iter); |
343 | 347 |
344 // Insert a Zero Width Space character just before the instant anchor. | 348 // Insert a Zero Width Space character just before the instant anchor. |
345 // It's a hack to workaround a bug of GtkTextView which can not align the | 349 // It's a hack to workaround a bug of GtkTextView which can not align the |
346 // preedit string and a child anchor correctly when there is no other content | 350 // preedit string and a child anchor correctly when there is no other content |
347 // around the preedit string. | 351 // around the preedit string. |
348 gtk_text_buffer_insert(text_buffer_, &end_iter, "\342\200\213", -1); | 352 gtk_text_buffer_insert(text_buffer_, &end_iter, "\342\200\213", -1); |
349 GtkTextChildAnchor* instant_anchor = | 353 GtkTextChildAnchor* instant_anchor = |
(...skipping 16 matching lines...) Expand all Loading... |
366 instant_mark_ = | 370 instant_mark_ = |
367 gtk_text_buffer_create_mark(text_buffer_, NULL, &start_iter, FALSE); | 371 gtk_text_buffer_create_mark(text_buffer_, NULL, &start_iter, FALSE); |
368 | 372 |
369 // Hooking up this handler after setting up above hacks for Instant view, so | 373 // Hooking up this handler after setting up above hacks for Instant view, so |
370 // that we won't filter out the special ZWP mark itself. | 374 // that we won't filter out the special ZWP mark itself. |
371 g_signal_connect(text_buffer_, "insert-text", | 375 g_signal_connect(text_buffer_, "insert-text", |
372 G_CALLBACK(&HandleInsertTextThunk), this); | 376 G_CALLBACK(&HandleInsertTextThunk), this); |
373 | 377 |
374 AdjustVerticalAlignmentOfInstantView(); | 378 AdjustVerticalAlignmentOfInstantView(); |
375 | 379 |
| 380 MultiAnimation::Parts parts; |
| 381 parts.push_back(MultiAnimation::Part( |
| 382 InstantController::kAutoCommitPauseTimeMS, Tween::ZERO)); |
| 383 parts.push_back(MultiAnimation::Part( |
| 384 InstantController::kAutoCommitFadeInTimeMS, Tween::EASE_IN)); |
| 385 instant_animation_.reset(new MultiAnimation(parts)); |
| 386 instant_animation_->set_continuous(false); |
| 387 |
376 #if !defined(TOOLKIT_VIEWS) | 388 #if !defined(TOOLKIT_VIEWS) |
377 registrar_.Add(this, | 389 registrar_.Add(this, |
378 NotificationType::BROWSER_THEME_CHANGED, | 390 NotificationType::BROWSER_THEME_CHANGED, |
379 NotificationService::AllSources()); | 391 NotificationService::AllSources()); |
380 theme_provider_->InitThemesFor(this); | 392 theme_provider_->InitThemesFor(this); |
381 #else | 393 #else |
382 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe | 394 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe |
383 // themes. | 395 // themes. |
384 SetBaseColor(); | 396 SetBaseColor(); |
385 #endif | 397 #endif |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 } | 746 } |
735 | 747 |
736 void AutocompleteEditViewGtk::Observe(NotificationType type, | 748 void AutocompleteEditViewGtk::Observe(NotificationType type, |
737 const NotificationSource& source, | 749 const NotificationSource& source, |
738 const NotificationDetails& details) { | 750 const NotificationDetails& details) { |
739 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 751 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
740 | 752 |
741 SetBaseColor(); | 753 SetBaseColor(); |
742 } | 754 } |
743 | 755 |
| 756 void AutocompleteEditViewGtk::AnimationEnded(const Animation* animation) { |
| 757 controller_->OnCommitSuggestedText(GetText()); |
| 758 } |
| 759 |
| 760 void AutocompleteEditViewGtk::AnimationProgressed(const Animation* animation) { |
| 761 UpdateInstantViewColors(); |
| 762 } |
| 763 |
| 764 void AutocompleteEditViewGtk::AnimationCanceled(const Animation* animation) { |
| 765 UpdateInstantViewColors(); |
| 766 } |
| 767 |
744 void AutocompleteEditViewGtk::SetBaseColor() { | 768 void AutocompleteEditViewGtk::SetBaseColor() { |
745 #if defined(TOOLKIT_VIEWS) | 769 #if defined(TOOLKIT_VIEWS) |
746 bool use_gtk = false; | 770 bool use_gtk = false; |
747 #else | 771 #else |
748 bool use_gtk = theme_provider_->UseGtkTheme(); | 772 bool use_gtk = theme_provider_->UseGtkTheme(); |
749 #endif | 773 #endif |
750 | 774 |
751 if (use_gtk) { | 775 if (use_gtk) { |
752 gtk_widget_modify_cursor(text_view_, NULL, NULL); | 776 gtk_widget_modify_cursor(text_view_, NULL, NULL); |
753 gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, NULL); | 777 gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, NULL); |
754 gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, NULL); | 778 gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, NULL); |
755 gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, NULL); | 779 gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, NULL); |
756 gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, NULL); | 780 gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, NULL); |
757 gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, NULL); | 781 gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, NULL); |
758 | 782 |
759 gtk_util::UndoForceFontSize(text_view_); | 783 gtk_util::UndoForceFontSize(text_view_); |
760 gtk_util::UndoForceFontSize(instant_view_); | 784 gtk_util::UndoForceFontSize(instant_view_); |
761 | 785 |
762 // Grab the text colors out of the style and set our tags to use them. | 786 // Grab the text colors out of the style and set our tags to use them. |
763 GtkStyle* style = gtk_rc_get_style(text_view_); | 787 GtkStyle* style = gtk_rc_get_style(text_view_); |
764 | 788 |
765 // style may be unrealized at this point, so calculate the halfway point | 789 // style may be unrealized at this point, so calculate the halfway point |
766 // between text[] and base[] manually instead of just using text_aa[]. | 790 // between text[] and base[] manually instead of just using text_aa[]. |
767 GdkColor average_color = gtk_util::AverageColors( | 791 GdkColor average_color = gtk_util::AverageColors( |
768 style->text[GTK_STATE_NORMAL], style->base[GTK_STATE_NORMAL]); | 792 style->text[GTK_STATE_NORMAL], style->base[GTK_STATE_NORMAL]); |
769 | 793 |
770 g_object_set(faded_text_tag_, "foreground-gdk", &average_color, NULL); | 794 g_object_set(faded_text_tag_, "foreground-gdk", &average_color, NULL); |
771 g_object_set(normal_text_tag_, "foreground-gdk", | 795 g_object_set(normal_text_tag_, "foreground-gdk", |
772 &style->text[GTK_STATE_NORMAL], NULL); | 796 &style->text[GTK_STATE_NORMAL], NULL); |
773 | |
774 // GtkLabel uses fg color instead of text color. | |
775 gtk_widget_modify_fg(instant_view_, GTK_STATE_NORMAL, &average_color); | |
776 } else { | 797 } else { |
777 const GdkColor* background_color_ptr; | 798 const GdkColor* background_color_ptr; |
778 #if defined(TOOLKIT_VIEWS) | 799 #if defined(TOOLKIT_VIEWS) |
779 const GdkColor background_color = gfx::SkColorToGdkColor( | 800 const GdkColor background_color = gfx::SkColorToGdkColor( |
780 LocationBarView::GetColor(ToolbarModel::NONE, | 801 LocationBarView::GetColor(ToolbarModel::NONE, |
781 LocationBarView::BACKGROUND)); | 802 LocationBarView::BACKGROUND)); |
782 background_color_ptr = &background_color; | 803 background_color_ptr = &background_color; |
783 #else | 804 #else |
784 background_color_ptr = &LocationBarViewGtk::kBackgroundColor; | 805 background_color_ptr = &LocationBarViewGtk::kBackgroundColor; |
785 #endif | 806 #endif |
786 gtk_widget_modify_cursor( | 807 gtk_widget_modify_cursor( |
787 text_view_, >k_util::kGdkBlack, >k_util::kGdkGray); | 808 text_view_, >k_util::kGdkBlack, >k_util::kGdkGray); |
788 gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, background_color_ptr); | 809 gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, background_color_ptr); |
789 | 810 |
| 811 #if !defined(TOOLKIT_VIEWS) |
790 GdkColor c; | 812 GdkColor c; |
791 #if !defined(TOOLKIT_VIEWS) | |
792 // Override the selected colors so we don't leak colors from the current | 813 // Override the selected colors so we don't leak colors from the current |
793 // gtk theme into the chrome-theme. | 814 // gtk theme into the chrome-theme. |
794 c = gfx::SkColorToGdkColor( | 815 c = gfx::SkColorToGdkColor( |
795 theme_provider_->get_active_selection_bg_color()); | 816 theme_provider_->get_active_selection_bg_color()); |
796 gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, &c); | 817 gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, &c); |
797 | 818 |
798 c = gfx::SkColorToGdkColor( | 819 c = gfx::SkColorToGdkColor( |
799 theme_provider_->get_active_selection_fg_color()); | 820 theme_provider_->get_active_selection_fg_color()); |
800 gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, &c); | 821 gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, &c); |
801 | 822 |
802 c = gfx::SkColorToGdkColor( | 823 c = gfx::SkColorToGdkColor( |
803 theme_provider_->get_inactive_selection_bg_color()); | 824 theme_provider_->get_inactive_selection_bg_color()); |
804 gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, &c); | 825 gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, &c); |
805 | 826 |
806 c = gfx::SkColorToGdkColor( | 827 c = gfx::SkColorToGdkColor( |
807 theme_provider_->get_inactive_selection_fg_color()); | 828 theme_provider_->get_inactive_selection_fg_color()); |
808 gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, &c); | 829 gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, &c); |
809 #endif | 830 #endif |
810 | 831 |
811 gdk_color_parse(kTextBaseColor, &c); | |
812 gtk_widget_modify_fg(instant_view_, GTK_STATE_NORMAL, &c); | |
813 | |
814 // Until we switch to vector graphics, force the font size. | 832 // Until we switch to vector graphics, force the font size. |
815 gtk_util::ForceFontSizePixels(text_view_, | 833 gtk_util::ForceFontSizePixels(text_view_, |
816 popup_window_mode_ ? | 834 popup_window_mode_ ? |
817 browser_defaults::kAutocompleteEditFontPixelSizeInPopup : | 835 browser_defaults::kAutocompleteEditFontPixelSizeInPopup : |
818 browser_defaults::kAutocompleteEditFontPixelSize); | 836 browser_defaults::kAutocompleteEditFontPixelSize); |
819 | 837 |
820 gtk_util::ForceFontSizePixels(instant_view_, | 838 gtk_util::ForceFontSizePixels(instant_view_, |
821 popup_window_mode_ ? | 839 popup_window_mode_ ? |
822 browser_defaults::kAutocompleteEditFontPixelSizeInPopup : | 840 browser_defaults::kAutocompleteEditFontPixelSizeInPopup : |
823 browser_defaults::kAutocompleteEditFontPixelSize); | 841 browser_defaults::kAutocompleteEditFontPixelSize); |
824 | 842 |
825 g_object_set(faded_text_tag_, "foreground", kTextBaseColor, NULL); | 843 g_object_set(faded_text_tag_, "foreground", kTextBaseColor, NULL); |
826 g_object_set(normal_text_tag_, "foreground", "#000000", NULL); | 844 g_object_set(normal_text_tag_, "foreground", "#000000", NULL); |
827 } | 845 } |
828 | 846 |
829 AdjustVerticalAlignmentOfInstantView(); | 847 AdjustVerticalAlignmentOfInstantView(); |
| 848 UpdateInstantViewColors(); |
| 849 } |
| 850 |
| 851 void AutocompleteEditViewGtk::UpdateInstantViewColors() { |
| 852 #if !defined(TOOLKIT_VIEWS) |
| 853 SkColor selection_text, selection_bg; |
| 854 GdkColor faded_text, normal_bg; |
| 855 |
| 856 if (theme_provider_->UseGtkTheme()) { |
| 857 GtkStyle* style = gtk_rc_get_style(text_view_); |
| 858 |
| 859 faded_text = gtk_util::AverageColors( |
| 860 style->text[GTK_STATE_NORMAL], style->base[GTK_STATE_NORMAL]); |
| 861 normal_bg = style->base[GTK_STATE_NORMAL]; |
| 862 |
| 863 selection_text = gfx::GdkColorToSkColor(style->text[GTK_STATE_SELECTED]); |
| 864 selection_bg = gfx::GdkColorToSkColor(style->base[GTK_STATE_SELECTED]); |
| 865 } else { |
| 866 gdk_color_parse(kTextBaseColor, &faded_text); |
| 867 normal_bg = LocationBarViewGtk::kBackgroundColor; |
| 868 |
| 869 selection_text = |
| 870 theme_provider_->get_active_selection_fg_color(); |
| 871 selection_bg = |
| 872 theme_provider_->get_active_selection_bg_color(); |
| 873 } |
| 874 |
| 875 double alpha = instant_animation_->GetCurrentValue(); |
| 876 GdkColor text = gfx::SkColorToGdkColor(color_utils::AlphaBlend( |
| 877 selection_text, |
| 878 gfx::GdkColorToSkColor(faded_text), |
| 879 alpha * 0xff)); |
| 880 GdkColor bg = gfx::SkColorToGdkColor(color_utils::AlphaBlend( |
| 881 selection_bg, |
| 882 gfx::GdkColorToSkColor(normal_bg), |
| 883 alpha * 0xff)); |
| 884 |
| 885 // ACTIVE is the state for text that is selected, but not focused (the |
| 886 // instant view is always fully selected and never has focus). |
| 887 gtk_widget_modify_text(instant_view_, GTK_STATE_ACTIVE, &text); |
| 888 gtk_widget_modify_base(instant_view_, GTK_STATE_ACTIVE, &bg); |
| 889 #else // defined(TOOLKIT_VIEWS) |
| 890 // We don't worry about views because it doesn't use the instant view. |
| 891 #endif |
830 } | 892 } |
831 | 893 |
832 void AutocompleteEditViewGtk::HandleBeginUserAction(GtkTextBuffer* sender) { | 894 void AutocompleteEditViewGtk::HandleBeginUserAction(GtkTextBuffer* sender) { |
833 OnBeforePossibleChange(); | 895 OnBeforePossibleChange(); |
834 } | 896 } |
835 | 897 |
836 void AutocompleteEditViewGtk::HandleEndUserAction(GtkTextBuffer* sender) { | 898 void AutocompleteEditViewGtk::HandleEndUserAction(GtkTextBuffer* sender) { |
837 OnAfterPossibleChange(); | 899 OnAfterPossibleChange(); |
838 } | 900 } |
839 | 901 |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end); | 1753 gtk_text_buffer_apply_tag(text_buffer_, faded_text_tag_, &start, &end); |
1692 } else { | 1754 } else { |
1693 gtk_text_buffer_apply_tag(text_buffer_, secure_scheme_tag_, &start, &end); | 1755 gtk_text_buffer_apply_tag(text_buffer_, secure_scheme_tag_, &start, &end); |
1694 } | 1756 } |
1695 } | 1757 } |
1696 } | 1758 } |
1697 | 1759 |
1698 void AutocompleteEditViewGtk::SetInstantSuggestion( | 1760 void AutocompleteEditViewGtk::SetInstantSuggestion( |
1699 const std::string& suggestion) { | 1761 const std::string& suggestion) { |
1700 gtk_label_set_text(GTK_LABEL(instant_view_), suggestion.c_str()); | 1762 gtk_label_set_text(GTK_LABEL(instant_view_), suggestion.c_str()); |
| 1763 // Select the whole thing. |
| 1764 gtk_label_select_region(GTK_LABEL(instant_view_), 0, -1); |
| 1765 |
| 1766 // Clear the animation delegate so we don't get an AnimationEnded() callback. |
| 1767 instant_animation_->set_delegate(NULL); |
| 1768 instant_animation_->Stop(); |
| 1769 |
1701 if (suggestion.empty()) { | 1770 if (suggestion.empty()) { |
1702 gtk_widget_hide(instant_view_); | 1771 gtk_widget_hide(instant_view_); |
1703 } else { | 1772 } else { |
| 1773 if (InstantController::IsEnabled(model_->profile(), |
| 1774 InstantController::PREDICTIVE_TYPE)) { |
| 1775 instant_animation_->set_delegate(this); |
| 1776 instant_animation_->Start(); |
| 1777 } |
| 1778 |
1704 gtk_widget_show(instant_view_); | 1779 gtk_widget_show(instant_view_); |
1705 AdjustVerticalAlignmentOfInstantView(); | 1780 AdjustVerticalAlignmentOfInstantView(); |
| 1781 UpdateInstantViewColors(); |
1706 } | 1782 } |
1707 } | 1783 } |
1708 | 1784 |
1709 bool AutocompleteEditViewGtk::CommitInstantSuggestion() { | 1785 bool AutocompleteEditViewGtk::CommitInstantSuggestion() { |
1710 const gchar* suggestion = gtk_label_get_text(GTK_LABEL(instant_view_)); | 1786 const gchar* suggestion = gtk_label_get_text(GTK_LABEL(instant_view_)); |
1711 if (!suggestion || !*suggestion) | 1787 if (!suggestion || !*suggestion) |
1712 return false; | 1788 return false; |
1713 | 1789 |
1714 model()->FinalizeInstantQuery(GetText() + UTF8ToWide(suggestion)); | 1790 model()->FinalizeInstantQuery(GetText() + UTF8ToWide(suggestion)); |
1715 return true; | 1791 return true; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 // baseline, so we need to move the |instant_view_| down to make sure it | 2052 // baseline, so we need to move the |instant_view_| down to make sure it |
1977 // has the same baseline as the |text_view_|. | 2053 // has the same baseline as the |text_view_|. |
1978 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); | 2054 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); |
1979 int height; | 2055 int height; |
1980 pango_layout_get_size(layout, NULL, &height); | 2056 pango_layout_get_size(layout, NULL, &height); |
1981 PangoLayoutIter* iter = pango_layout_get_iter(layout); | 2057 PangoLayoutIter* iter = pango_layout_get_iter(layout); |
1982 int baseline = pango_layout_iter_get_baseline(iter); | 2058 int baseline = pango_layout_iter_get_baseline(iter); |
1983 pango_layout_iter_free(iter); | 2059 pango_layout_iter_free(iter); |
1984 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); | 2060 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); |
1985 } | 2061 } |
OLD | NEW |