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