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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const double kContentSettingTopColor[] = { 0xff / 255.0, | 123 const double kContentSettingTopColor[] = { 0xff / 255.0, |
124 0xf8 / 255.0, | 124 0xf8 / 255.0, |
125 0xd4 / 255.0 }; | 125 0xd4 / 255.0 }; |
126 const double kContentSettingBottomColor[] = { 0xff / 255.0, | 126 const double kContentSettingBottomColor[] = { 0xff / 255.0, |
127 0xe6 / 255.0, | 127 0xe6 / 255.0, |
128 0xaf / 255.0 }; | 128 0xaf / 255.0 }; |
129 | 129 |
130 // If widget is visible, increment the int pointed to by count. | 130 // If widget is visible, increment the int pointed to by count. |
131 // Suitible for use with gtk_container_foreach. | 131 // Suitible for use with gtk_container_foreach. |
132 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { | 132 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { |
133 if (gtk_widget_get_visible(widget)) | 133 if (GTK_WIDGET_VISIBLE(widget)) |
134 *static_cast<int*>(count) += 1; | 134 *static_cast<int*>(count) += 1; |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 | 138 |
139 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
140 // LocationBarViewGtk | 140 // LocationBarViewGtk |
141 | 141 |
142 // static | 142 // static |
143 const GdkColor LocationBarViewGtk::kBackgroundColor = | 143 const GdkColor LocationBarViewGtk::kBackgroundColor = |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1151 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
1152 return !browser_->is_type_tabbed(); | 1152 return !browser_->is_type_tabbed(); |
1153 } | 1153 } |
1154 | 1154 |
1155 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1155 void LocationBarViewGtk::AdjustChildrenVisibility() { |
1156 int text_width = location_entry_->TextWidth(); | 1156 int text_width = location_entry_->TextWidth(); |
1157 int available_width = entry_box_width_ - text_width - kInnerPadding; | 1157 int available_width = entry_box_width_ - text_width - kInnerPadding; |
1158 | 1158 |
1159 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be | 1159 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be |
1160 // visible at the same time. | 1160 // visible at the same time. |
1161 if (!show_selected_keyword_ && | 1161 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_alignment_)) |
1162 gtk_widget_get_visible(tab_to_search_alignment_)) { | |
1163 gtk_widget_hide(tab_to_search_alignment_); | 1162 gtk_widget_hide(tab_to_search_alignment_); |
1164 } else if (!show_keyword_hint_ && | 1163 else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) |
1165 gtk_widget_get_visible(tab_to_search_hint_)) { | |
1166 gtk_widget_hide(tab_to_search_hint_); | 1164 gtk_widget_hide(tab_to_search_hint_); |
1167 } | |
1168 | 1165 |
1169 if (show_selected_keyword_) { | 1166 if (show_selected_keyword_) { |
1170 GtkRequisition box, full_label, partial_label; | 1167 GtkRequisition box, full_label, partial_label; |
1171 gtk_widget_size_request(tab_to_search_box_, &box); | 1168 gtk_widget_size_request(tab_to_search_box_, &box); |
1172 gtk_widget_size_request(tab_to_search_full_label_, &full_label); | 1169 gtk_widget_size_request(tab_to_search_full_label_, &full_label); |
1173 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); | 1170 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); |
1174 int full_partial_width_diff = full_label.width - partial_label.width; | 1171 int full_partial_width_diff = full_label.width - partial_label.width; |
1175 int full_box_width; | 1172 int full_box_width; |
1176 int partial_box_width; | 1173 int partial_box_width; |
1177 if (gtk_widget_get_visible(tab_to_search_full_label_)) { | 1174 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { |
1178 full_box_width = box.width; | 1175 full_box_width = box.width; |
1179 partial_box_width = full_box_width - full_partial_width_diff; | 1176 partial_box_width = full_box_width - full_partial_width_diff; |
1180 } else { | 1177 } else { |
1181 partial_box_width = box.width; | 1178 partial_box_width = box.width; |
1182 full_box_width = partial_box_width + full_partial_width_diff; | 1179 full_box_width = partial_box_width + full_partial_width_diff; |
1183 } | 1180 } |
1184 | 1181 |
1185 if (partial_box_width >= entry_box_width_ - kInnerPadding) { | 1182 if (partial_box_width >= entry_box_width_ - kInnerPadding) { |
1186 gtk_widget_hide(tab_to_search_alignment_); | 1183 gtk_widget_hide(tab_to_search_alignment_); |
1187 } else if (full_box_width >= available_width) { | 1184 } else if (full_box_width >= available_width) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { | 1257 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { |
1261 image_.Destroy(); | 1258 image_.Destroy(); |
1262 label_.Destroy(); | 1259 label_.Destroy(); |
1263 event_box_.Destroy(); | 1260 event_box_.Destroy(); |
1264 alignment_.Destroy(); | 1261 alignment_.Destroy(); |
1265 | 1262 |
1266 if (content_setting_bubble_) | 1263 if (content_setting_bubble_) |
1267 content_setting_bubble_->Close(); | 1264 content_setting_bubble_->Close(); |
1268 } | 1265 } |
1269 | 1266 |
1270 bool LocationBarViewGtk::ContentSettingImageViewGtk::IsVisible() { | |
1271 return gtk_widget_get_visible(widget()); | |
1272 } | |
1273 | |
1274 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( | 1267 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( |
1275 TabContents* tab_contents) { | 1268 TabContents* tab_contents) { |
1276 content_setting_image_model_->UpdateFromTabContents(tab_contents); | 1269 content_setting_image_model_->UpdateFromTabContents(tab_contents); |
1277 if (!content_setting_image_model_->is_visible()) { | 1270 if (!content_setting_image_model_->is_visible()) { |
1278 gtk_widget_hide(widget()); | 1271 gtk_widget_hide(widget()); |
1279 return; | 1272 return; |
1280 } | 1273 } |
1281 | 1274 |
1282 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), | 1275 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), |
1283 GtkThemeService::GetFrom(profile_)->GetPixbufNamed( | 1276 GtkThemeService::GetFrom(profile_)->GetPixbufNamed( |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 image_.Destroy(); | 1455 image_.Destroy(); |
1463 event_box_.Destroy(); | 1456 event_box_.Destroy(); |
1464 for (PixbufMap::iterator iter = pixbufs_.begin(); iter != pixbufs_.end(); | 1457 for (PixbufMap::iterator iter = pixbufs_.begin(); iter != pixbufs_.end(); |
1465 ++iter) { | 1458 ++iter) { |
1466 g_object_unref(iter->second); | 1459 g_object_unref(iter->second); |
1467 } | 1460 } |
1468 if (last_icon_pixbuf_) | 1461 if (last_icon_pixbuf_) |
1469 g_object_unref(last_icon_pixbuf_); | 1462 g_object_unref(last_icon_pixbuf_); |
1470 } | 1463 } |
1471 | 1464 |
1472 bool LocationBarViewGtk::PageActionViewGtk::IsVisible() { | |
1473 return gtk_widget_get_visible(widget()); | |
1474 } | |
1475 | |
1476 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( | 1465 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( |
1477 TabContents* contents, const GURL& url) { | 1466 TabContents* contents, const GURL& url) { |
1478 // Save this off so we can pass it back to the extension when the action gets | 1467 // Save this off so we can pass it back to the extension when the action gets |
1479 // executed. See PageActionImageView::OnMousePressed. | 1468 // executed. See PageActionImageView::OnMousePressed. |
1480 current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; | 1469 current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; |
1481 current_url_ = url; | 1470 current_url_ = url; |
1482 | 1471 |
1483 bool visible = contents && | 1472 bool visible = contents && |
1484 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); | 1473 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); |
1485 if (visible) { | 1474 if (visible) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 | 1620 |
1632 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1621 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1633 if (badge_text.empty()) | 1622 if (badge_text.empty()) |
1634 return FALSE; | 1623 return FALSE; |
1635 | 1624 |
1636 gfx::CanvasSkiaPaint canvas(event, false); | 1625 gfx::CanvasSkiaPaint canvas(event, false); |
1637 gfx::Rect bounding_rect(widget->allocation); | 1626 gfx::Rect bounding_rect(widget->allocation); |
1638 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1627 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1639 return FALSE; | 1628 return FALSE; |
1640 } | 1629 } |
OLD | NEW |