| 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // Tab to search (the keyword box on the left hand side). | 201 // Tab to search (the keyword box on the left hand side). |
| 202 tab_to_search_full_label_ = gtk_label_new(NULL); | 202 tab_to_search_full_label_ = gtk_label_new(NULL); |
| 203 tab_to_search_partial_label_ = gtk_label_new(NULL); | 203 tab_to_search_partial_label_ = gtk_label_new(NULL); |
| 204 GtkWidget* tab_to_search_label_hbox = gtk_hbox_new(FALSE, 0); | 204 GtkWidget* tab_to_search_label_hbox = gtk_hbox_new(FALSE, 0); |
| 205 gtk_box_pack_start(GTK_BOX(tab_to_search_label_hbox), | 205 gtk_box_pack_start(GTK_BOX(tab_to_search_label_hbox), |
| 206 tab_to_search_full_label_, FALSE, FALSE, 0); | 206 tab_to_search_full_label_, FALSE, FALSE, 0); |
| 207 gtk_box_pack_start(GTK_BOX(tab_to_search_label_hbox), | 207 gtk_box_pack_start(GTK_BOX(tab_to_search_label_hbox), |
| 208 tab_to_search_partial_label_, FALSE, FALSE, 0); | 208 tab_to_search_partial_label_, FALSE, FALSE, 0); |
| 209 GtkWidget* tab_to_search_hbox = gtk_hbox_new(FALSE, 0); | 209 GtkWidget* tab_to_search_hbox = gtk_hbox_new(FALSE, 0); |
| 210 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 210 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 211 GtkWidget* tab_to_search_lens = gtk_image_new_from_pixbuf( | 211 tab_to_search_magnifier_ = gtk_image_new_from_pixbuf( |
| 212 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); | 212 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); |
| 213 gtk_box_pack_start(GTK_BOX(tab_to_search_hbox), tab_to_search_lens, | 213 gtk_box_pack_start(GTK_BOX(tab_to_search_hbox), tab_to_search_magnifier_, |
| 214 FALSE, FALSE, 0); | 214 FALSE, FALSE, 0); |
| 215 gtk_util::CenterWidgetInHBox(tab_to_search_hbox, tab_to_search_label_hbox, | 215 gtk_util::CenterWidgetInHBox(tab_to_search_hbox, tab_to_search_label_hbox, |
| 216 false, 0); | 216 false, 0); |
| 217 | 217 |
| 218 // This creates a box around the keyword text with a border, background color, | 218 // This creates a box around the keyword text with a border, background color, |
| 219 // and padding around the text. | 219 // and padding around the text. |
| 220 tab_to_search_box_ = gtk_util::CreateGtkBorderBin( | 220 tab_to_search_box_ = gtk_util::CreateGtkBorderBin( |
| 221 tab_to_search_hbox, NULL, 1, 1, 1, 3); | 221 tab_to_search_hbox, NULL, 1, 1, 1, 3); |
| 222 gtk_widget_set_name(tab_to_search_box_, "chrome-tab-to-search-box"); | 222 gtk_widget_set_name(tab_to_search_box_, "chrome-tab-to-search-box"); |
| 223 gtk_util::ActAsRoundedWindow(tab_to_search_box_, kKeywordBorderColor, | 223 gtk_util::ActAsRoundedWindow(tab_to_search_box_, kKeywordBorderColor, |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 GetKeywordShortName(keyword, &is_extension_keyword); | 868 GetKeywordShortName(keyword, &is_extension_keyword); |
| 869 int message_id = is_extension_keyword ? | 869 int message_id = is_extension_keyword ? |
| 870 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; | 870 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; |
| 871 std::wstring full_name(l10n_util::GetStringF(message_id, short_name)); | 871 std::wstring full_name(l10n_util::GetStringF(message_id, short_name)); |
| 872 std::wstring partial_name(l10n_util::GetStringF( | 872 std::wstring partial_name(l10n_util::GetStringF( |
| 873 message_id, location_bar_util::CalculateMinString(short_name))); | 873 message_id, location_bar_util::CalculateMinString(short_name))); |
| 874 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), | 874 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), |
| 875 WideToUTF8(full_name).c_str()); | 875 WideToUTF8(full_name).c_str()); |
| 876 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), | 876 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), |
| 877 WideToUTF8(partial_name).c_str()); | 877 WideToUTF8(partial_name).c_str()); |
| 878 |
| 879 if (last_keyword_ != keyword) { |
| 880 last_keyword_ = keyword; |
| 881 |
| 882 if (is_extension_keyword) { |
| 883 const TemplateURL* template_url = |
| 884 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); |
| 885 const SkBitmap& bitmap = profile_->GetExtensionsService()-> |
| 886 GetOmniboxIcon(template_url->GetExtensionId()); |
| 887 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); |
| 888 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); |
| 889 g_object_unref(pixbuf); |
| 890 } else { |
| 891 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 892 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), |
| 893 rb.GetPixbufNamed(IDR_OMNIBOX_SEARCH)); |
| 894 } |
| 895 } |
| 878 } | 896 } |
| 879 | 897 |
| 880 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) { | 898 void LocationBarViewGtk::SetKeywordHintLabel(const std::wstring& keyword) { |
| 881 if (keyword.empty()) | 899 if (keyword.empty()) |
| 882 return; | 900 return; |
| 883 | 901 |
| 884 DCHECK(profile_); | 902 DCHECK(profile_); |
| 885 if (!profile_->GetTemplateURLModel()) | 903 if (!profile_->GetTemplateURLModel()) |
| 886 return; | 904 return; |
| 887 | 905 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 | 1421 |
| 1404 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1422 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1405 if (badge_text.empty()) | 1423 if (badge_text.empty()) |
| 1406 return FALSE; | 1424 return FALSE; |
| 1407 | 1425 |
| 1408 gfx::CanvasSkiaPaint canvas(event, false); | 1426 gfx::CanvasSkiaPaint canvas(event, false); |
| 1409 gfx::Rect bounding_rect(widget->allocation); | 1427 gfx::Rect bounding_rect(widget->allocation); |
| 1410 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1428 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1411 return FALSE; | 1429 return FALSE; |
| 1412 } | 1430 } |
| OLD | NEW |