| 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1194 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
| 1195 return browser_->type() != Browser::TYPE_NORMAL; | 1195 return browser_->type() != Browser::TYPE_NORMAL; |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1198 void LocationBarViewGtk::AdjustChildrenVisibility() { |
| 1199 int text_width = location_entry_->TextWidth(); | 1199 int text_width = location_entry_->TextWidth(); |
| 1200 int available_width = entry_box_width_ - text_width - kInnerPadding; | 1200 int available_width = entry_box_width_ - text_width - kInnerPadding; |
| 1201 | 1201 |
| 1202 // Only one of |tab_to_search_box_| and |tab_to_search_hint_| can be visible | 1202 // Only one of |tab_to_search_box_| and |tab_to_search_hint_| can be visible |
| 1203 // at the same time. | 1203 // at the same time. |
| 1204 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_box_)) { | 1204 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_box_)) |
| 1205 gtk_widget_hide(tab_to_search_box_); | 1205 gtk_widget_hide(tab_to_search_box_); |
| 1206 } else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) { | 1206 else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) |
| 1207 gtk_widget_hide(tab_to_search_hint_); | 1207 gtk_widget_hide(tab_to_search_hint_); |
| 1208 location_entry_->set_enable_tab_to_search(false); | |
| 1209 } | |
| 1210 | 1208 |
| 1211 if (show_selected_keyword_) { | 1209 if (show_selected_keyword_) { |
| 1212 GtkRequisition box, full_label, partial_label; | 1210 GtkRequisition box, full_label, partial_label; |
| 1213 gtk_widget_size_request(tab_to_search_box_, &box); | 1211 gtk_widget_size_request(tab_to_search_box_, &box); |
| 1214 gtk_widget_size_request(tab_to_search_full_label_, &full_label); | 1212 gtk_widget_size_request(tab_to_search_full_label_, &full_label); |
| 1215 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); | 1213 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); |
| 1216 int full_partial_width_diff = full_label.width - partial_label.width; | 1214 int full_partial_width_diff = full_label.width - partial_label.width; |
| 1217 int full_box_width; | 1215 int full_box_width; |
| 1218 int partial_box_width; | 1216 int partial_box_width; |
| 1219 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { | 1217 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1237 } | 1235 } |
| 1238 } else if (show_keyword_hint_) { | 1236 } else if (show_keyword_hint_) { |
| 1239 GtkRequisition leading, icon, trailing; | 1237 GtkRequisition leading, icon, trailing; |
| 1240 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); | 1238 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); |
| 1241 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); | 1239 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); |
| 1242 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); | 1240 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); |
| 1243 int full_width = leading.width + icon.width + trailing.width; | 1241 int full_width = leading.width + icon.width + trailing.width; |
| 1244 | 1242 |
| 1245 if (icon.width >= entry_box_width_ - kInnerPadding) { | 1243 if (icon.width >= entry_box_width_ - kInnerPadding) { |
| 1246 gtk_widget_hide(tab_to_search_hint_); | 1244 gtk_widget_hide(tab_to_search_hint_); |
| 1247 location_entry_->set_enable_tab_to_search(false); | |
| 1248 } else if (full_width >= available_width) { | 1245 } else if (full_width >= available_width) { |
| 1249 gtk_widget_hide(tab_to_search_hint_leading_label_); | 1246 gtk_widget_hide(tab_to_search_hint_leading_label_); |
| 1250 gtk_widget_hide(tab_to_search_hint_trailing_label_); | 1247 gtk_widget_hide(tab_to_search_hint_trailing_label_); |
| 1251 gtk_widget_show(tab_to_search_hint_); | 1248 gtk_widget_show(tab_to_search_hint_); |
| 1252 location_entry_->set_enable_tab_to_search(true); | |
| 1253 } else if (full_width < available_width) { | 1249 } else if (full_width < available_width) { |
| 1254 gtk_widget_show(tab_to_search_hint_leading_label_); | 1250 gtk_widget_show(tab_to_search_hint_leading_label_); |
| 1255 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1251 gtk_widget_show(tab_to_search_hint_trailing_label_); |
| 1256 gtk_widget_show(tab_to_search_hint_); | 1252 gtk_widget_show(tab_to_search_hint_); |
| 1257 location_entry_->set_enable_tab_to_search(true); | |
| 1258 } | 1253 } |
| 1259 } | 1254 } |
| 1260 } | 1255 } |
| 1261 | 1256 |
| 1262 //////////////////////////////////////////////////////////////////////////////// | 1257 //////////////////////////////////////////////////////////////////////////////// |
| 1263 // LocationBarViewGtk::ContentSettingImageViewGtk | 1258 // LocationBarViewGtk::ContentSettingImageViewGtk |
| 1264 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( | 1259 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( |
| 1265 ContentSettingsType content_type, | 1260 ContentSettingsType content_type, |
| 1266 const LocationBarViewGtk* parent, | 1261 const LocationBarViewGtk* parent, |
| 1267 Profile* profile) | 1262 Profile* profile) |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 | 1546 |
| 1552 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1547 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1553 if (badge_text.empty()) | 1548 if (badge_text.empty()) |
| 1554 return FALSE; | 1549 return FALSE; |
| 1555 | 1550 |
| 1556 gfx::CanvasSkiaPaint canvas(event, false); | 1551 gfx::CanvasSkiaPaint canvas(event, false); |
| 1557 gfx::Rect bounding_rect(widget->allocation); | 1552 gfx::Rect bounding_rect(widget->allocation); |
| 1558 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1553 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1559 return FALSE; | 1554 return FALSE; |
| 1560 } | 1555 } |
| OLD | NEW |