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

Side by Side Diff: chrome/browser/ui/gtk/infobars/infobar_gtk.cc

Issue 8885016: GTK: Even more changes from raw allocation access to gtk_widget_get_allocation(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove temporary Created 9 years 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
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/infobars/infobar_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/infobars/infobar_tab_helper.h" 8 #include "chrome/browser/infobars/infobar_tab_helper.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 10 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void InfoBarGtk::OnCloseButton(GtkWidget* button) { 205 void InfoBarGtk::OnCloseButton(GtkWidget* button) {
206 // If we're not owned, we're already closing, so don't call 206 // If we're not owned, we're already closing, so don't call
207 // InfoBarDismissed(), since this can lead to us double-recording dismissals. 207 // InfoBarDismissed(), since this can lead to us double-recording dismissals.
208 if (delegate() && owned()) 208 if (delegate() && owned())
209 delegate()->InfoBarDismissed(); 209 delegate()->InfoBarDismissed();
210 RemoveSelf(); 210 RemoveSelf();
211 } 211 }
212 212
213 gboolean InfoBarGtk::OnBackgroundExpose(GtkWidget* sender, 213 gboolean InfoBarGtk::OnBackgroundExpose(GtkWidget* sender,
214 GdkEventExpose* event) { 214 GdkEventExpose* event) {
215 const int height = sender->allocation.height; 215 GtkAllocation allocation;
216 gtk_widget_get_allocation(sender, &allocation);
217 const int height = allocation.height;
216 218
217 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(sender->window)); 219 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(sender->window));
218 gdk_cairo_rectangle(cr, &event->area); 220 gdk_cairo_rectangle(cr, &event->area);
219 cairo_clip(cr); 221 cairo_clip(cr);
220 222
221 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); 223 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height);
222 224
223 double top_r, top_g, top_b; 225 double top_r, top_g, top_b;
224 GetTopColor(delegate()->GetInfoBarType(), &top_r, &top_g, &top_b); 226 GetTopColor(delegate()->GetInfoBarType(), &top_r, &top_g, &top_b);
225 cairo_pattern_add_color_stop_rgb(pattern, 0.0, top_r, top_g, top_b); 227 cairo_pattern_add_color_stop_rgb(pattern, 0.0, top_r, top_g, top_b);
226 228
227 double bottom_r, bottom_g, bottom_b; 229 double bottom_r, bottom_g, bottom_b;
228 GetBottomColor(delegate()->GetInfoBarType(), &bottom_r, &bottom_g, &bottom_b); 230 GetBottomColor(delegate()->GetInfoBarType(), &bottom_r, &bottom_g, &bottom_b);
229 cairo_pattern_add_color_stop_rgb( 231 cairo_pattern_add_color_stop_rgb(
230 pattern, 1.0, bottom_r, bottom_g, bottom_b); 232 pattern, 1.0, bottom_r, bottom_g, bottom_b);
231 cairo_set_source(cr, pattern); 233 cairo_set_source(cr, pattern);
232 cairo_paint(cr); 234 cairo_paint(cr);
233 cairo_pattern_destroy(pattern); 235 cairo_pattern_destroy(pattern);
234 236
235 // Draw the bottom border. 237 // Draw the bottom border.
236 GdkColor border_color = GetBorderColor(); 238 GdkColor border_color = GetBorderColor();
237 cairo_set_source_rgb(cr, border_color.red / 65535.0, 239 cairo_set_source_rgb(cr, border_color.red / 65535.0,
238 border_color.green / 65535.0, 240 border_color.green / 65535.0,
239 border_color.blue / 65535.0); 241 border_color.blue / 65535.0);
240 cairo_set_line_width(cr, 1.0); 242 cairo_set_line_width(cr, 1.0);
241 int y = sender->allocation.height; 243 cairo_move_to(cr, 0, allocation.height - 0.5);
242 cairo_move_to(cr, 0, y - 0.5); 244 cairo_rel_line_to(cr, allocation.width, 0);
243 cairo_rel_line_to(cr, sender->allocation.width, 0);
244 cairo_stroke(cr); 245 cairo_stroke(cr);
245 246
246 cairo_destroy(cr); 247 cairo_destroy(cr);
247 248
248 if (container()) { 249 if (container()) {
249 static_cast<InfoBarContainerGtk*>(container())-> 250 static_cast<InfoBarContainerGtk*>(container())->
250 PaintInfobarBitsOn(sender, event, this); 251 PaintInfobarBitsOn(sender, event, this);
251 } 252 }
252 253
253 return FALSE; 254 return FALSE;
(...skipping 29 matching lines...) Expand all
283 const content::NotificationSource& source, 284 const content::NotificationSource& source,
284 const content::NotificationDetails& details) { 285 const content::NotificationDetails& details) {
285 UpdateBorderColor(); 286 UpdateBorderColor();
286 } 287 }
287 288
288 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded, 289 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded,
289 GtkWidget* child, 290 GtkWidget* child,
290 GtkRequisition* requisition) { 291 GtkRequisition* requisition) {
291 requisition->height = -1; 292 requisition->height = -1;
292 } 293 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698