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/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 Loading... | |
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 int y = allocation.height; |
Lei Zhang
2011/12/08 20:50:30
you can just get rid of |y| and use |height| inste
| |
242 cairo_move_to(cr, 0, y - 0.5); | 244 cairo_move_to(cr, 0, y - 0.5); |
243 cairo_rel_line_to(cr, sender->allocation.width, 0); | 245 cairo_rel_line_to(cr, allocation.width, 0); |
244 cairo_stroke(cr); | 246 cairo_stroke(cr); |
245 | 247 |
246 cairo_destroy(cr); | 248 cairo_destroy(cr); |
247 | 249 |
248 if (container()) { | 250 if (container()) { |
249 static_cast<InfoBarContainerGtk*>(container())-> | 251 static_cast<InfoBarContainerGtk*>(container())-> |
250 PaintInfobarBitsOn(sender, event, this); | 252 PaintInfobarBitsOn(sender, event, this); |
251 } | 253 } |
252 | 254 |
253 return FALSE; | 255 return FALSE; |
(...skipping 29 matching lines...) Expand all Loading... | |
283 const content::NotificationSource& source, | 285 const content::NotificationSource& source, |
284 const content::NotificationDetails& details) { | 286 const content::NotificationDetails& details) { |
285 UpdateBorderColor(); | 287 UpdateBorderColor(); |
286 } | 288 } |
287 | 289 |
288 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded, | 290 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded, |
289 GtkWidget* child, | 291 GtkWidget* child, |
290 GtkRequisition* requisition) { | 292 GtkRequisition* requisition) { |
291 requisition->height = -1; | 293 requisition->height = -1; |
292 } | 294 } |
OLD | NEW |