Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(996)

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 7227027: GTK: More 2.18 goodness. Move from macros to real accessor functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove views/ Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_VISIBLE(widget)) 133 if (gtk_widget_get_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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 bool LocationBarViewGtk::ShouldOnlyShowLocation() { 1156 bool LocationBarViewGtk::ShouldOnlyShowLocation() {
1157 return !browser_->is_type_tabbed(); 1157 return !browser_->is_type_tabbed();
1158 } 1158 }
1159 1159
1160 void LocationBarViewGtk::AdjustChildrenVisibility() { 1160 void LocationBarViewGtk::AdjustChildrenVisibility() {
1161 int text_width = location_entry_->TextWidth(); 1161 int text_width = location_entry_->TextWidth();
1162 int available_width = entry_box_width_ - text_width - kInnerPadding; 1162 int available_width = entry_box_width_ - text_width - kInnerPadding;
1163 1163
1164 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be 1164 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be
1165 // visible at the same time. 1165 // visible at the same time.
1166 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_alignment_)) 1166 if (!show_selected_keyword_ &&
1167 gtk_widget_get_visible(tab_to_search_alignment_)) {
1167 gtk_widget_hide(tab_to_search_alignment_); 1168 gtk_widget_hide(tab_to_search_alignment_);
1168 else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) 1169 } else if (!show_keyword_hint_ &&
1170 gtk_widget_get_visible(tab_to_search_hint_)) {
1169 gtk_widget_hide(tab_to_search_hint_); 1171 gtk_widget_hide(tab_to_search_hint_);
1172 }
1170 1173
1171 if (show_selected_keyword_) { 1174 if (show_selected_keyword_) {
1172 GtkRequisition box, full_label, partial_label; 1175 GtkRequisition box, full_label, partial_label;
1173 gtk_widget_size_request(tab_to_search_box_, &box); 1176 gtk_widget_size_request(tab_to_search_box_, &box);
1174 gtk_widget_size_request(tab_to_search_full_label_, &full_label); 1177 gtk_widget_size_request(tab_to_search_full_label_, &full_label);
1175 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); 1178 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label);
1176 int full_partial_width_diff = full_label.width - partial_label.width; 1179 int full_partial_width_diff = full_label.width - partial_label.width;
1177 int full_box_width; 1180 int full_box_width;
1178 int partial_box_width; 1181 int partial_box_width;
1179 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { 1182 if (gtk_widget_get_visible(tab_to_search_full_label_)) {
1180 full_box_width = box.width; 1183 full_box_width = box.width;
1181 partial_box_width = full_box_width - full_partial_width_diff; 1184 partial_box_width = full_box_width - full_partial_width_diff;
1182 } else { 1185 } else {
1183 partial_box_width = box.width; 1186 partial_box_width = box.width;
1184 full_box_width = partial_box_width + full_partial_width_diff; 1187 full_box_width = partial_box_width + full_partial_width_diff;
1185 } 1188 }
1186 1189
1187 if (partial_box_width >= entry_box_width_ - kInnerPadding) { 1190 if (partial_box_width >= entry_box_width_ - kInnerPadding) {
1188 gtk_widget_hide(tab_to_search_alignment_); 1191 gtk_widget_hide(tab_to_search_alignment_);
1189 } else if (full_box_width >= available_width) { 1192 } else if (full_box_width >= available_width) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { 1265 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() {
1263 image_.Destroy(); 1266 image_.Destroy();
1264 label_.Destroy(); 1267 label_.Destroy();
1265 event_box_.Destroy(); 1268 event_box_.Destroy();
1266 alignment_.Destroy(); 1269 alignment_.Destroy();
1267 1270
1268 if (content_setting_bubble_) 1271 if (content_setting_bubble_)
1269 content_setting_bubble_->Close(); 1272 content_setting_bubble_->Close();
1270 } 1273 }
1271 1274
1275 bool LocationBarViewGtk::ContentSettingImageViewGtk::IsVisible() {
1276 return gtk_widget_get_visible(widget());
1277 }
1278
1272 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( 1279 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents(
1273 TabContents* tab_contents) { 1280 TabContents* tab_contents) {
1274 content_setting_image_model_->UpdateFromTabContents(tab_contents); 1281 content_setting_image_model_->UpdateFromTabContents(tab_contents);
1275 if (!content_setting_image_model_->is_visible()) { 1282 if (!content_setting_image_model_->is_visible()) {
1276 gtk_widget_hide(widget()); 1283 gtk_widget_hide(widget());
1277 return; 1284 return;
1278 } 1285 }
1279 1286
1280 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), 1287 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
1281 GtkThemeService::GetFrom(profile_)->GetPixbufNamed( 1288 GtkThemeService::GetFrom(profile_)->GetPixbufNamed(
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 image_.Destroy(); 1467 image_.Destroy();
1461 event_box_.Destroy(); 1468 event_box_.Destroy();
1462 for (PixbufMap::iterator iter = pixbufs_.begin(); iter != pixbufs_.end(); 1469 for (PixbufMap::iterator iter = pixbufs_.begin(); iter != pixbufs_.end();
1463 ++iter) { 1470 ++iter) {
1464 g_object_unref(iter->second); 1471 g_object_unref(iter->second);
1465 } 1472 }
1466 if (last_icon_pixbuf_) 1473 if (last_icon_pixbuf_)
1467 g_object_unref(last_icon_pixbuf_); 1474 g_object_unref(last_icon_pixbuf_);
1468 } 1475 }
1469 1476
1477 bool LocationBarViewGtk::PageActionViewGtk::IsVisible() {
1478 return gtk_widget_get_visible(widget());
1479 }
1480
1470 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( 1481 void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility(
1471 TabContents* contents, const GURL& url) { 1482 TabContents* contents, const GURL& url) {
1472 // Save this off so we can pass it back to the extension when the action gets 1483 // Save this off so we can pass it back to the extension when the action gets
1473 // executed. See PageActionImageView::OnMousePressed. 1484 // executed. See PageActionImageView::OnMousePressed.
1474 current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1; 1485 current_tab_id_ = contents ? ExtensionTabUtil::GetTabId(contents) : -1;
1475 current_url_ = url; 1486 current_url_ = url;
1476 1487
1477 bool visible = contents && 1488 bool visible = contents &&
1478 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); 1489 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_));
1479 if (visible) { 1490 if (visible) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1636
1626 std::string badge_text = page_action_->GetBadgeText(tab_id); 1637 std::string badge_text = page_action_->GetBadgeText(tab_id);
1627 if (badge_text.empty()) 1638 if (badge_text.empty())
1628 return FALSE; 1639 return FALSE;
1629 1640
1630 gfx::CanvasSkiaPaint canvas(event, false); 1641 gfx::CanvasSkiaPaint canvas(event, false);
1631 gfx::Rect bounding_rect(widget->allocation); 1642 gfx::Rect bounding_rect(widget->allocation);
1632 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); 1643 page_action_->PaintBadge(&canvas, bounding_rect, tab_id);
1633 return FALSE; 1644 return FALSE;
1634 } 1645 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698