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/platform_util.h" | 8 #include "chrome/browser/platform_util.h" |
9 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 9 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
10 #include "chrome/browser/ui/gtk/custom_button.h" | 10 #include "chrome/browser/ui/gtk/custom_button.h" |
11 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 11 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
12 #include "chrome/browser/ui/gtk/gtk_expanded_container.h" | 12 #include "chrome/browser/ui/gtk/gtk_expanded_container.h" |
13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 13 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
15 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" | 15 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "content/common/notification_service.h" | 18 #include "content/common/notification_service.h" |
18 #include "ui/gfx/gtk_util.h" | 19 #include "ui/gfx/gtk_util.h" |
19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Pixels between infobar elements. | 24 // Pixels between infobar elements. |
24 const int kElementPadding = 5; | 25 const int kElementPadding = 5; |
25 | 26 |
26 // Extra padding on either end of info bar. | 27 // Extra padding on either end of info bar. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 G_CALLBACK(OnCloseButtonThunk), this); | 85 G_CALLBACK(OnCloseButtonThunk), this); |
85 | 86 |
86 widget_.Own(gtk_expanded_container_new()); | 87 widget_.Own(gtk_expanded_container_new()); |
87 gtk_container_add(GTK_CONTAINER(widget_.get()), bg_box_); | 88 gtk_container_add(GTK_CONTAINER(widget_.get()), bg_box_); |
88 gtk_widget_set_size_request(widget_.get(), -1, 0); | 89 gtk_widget_set_size_request(widget_.get(), -1, 0); |
89 | 90 |
90 g_signal_connect(widget_.get(), "child-size-request", | 91 g_signal_connect(widget_.get(), "child-size-request", |
91 G_CALLBACK(OnChildSizeRequestThunk), | 92 G_CALLBACK(OnChildSizeRequestThunk), |
92 this); | 93 this); |
93 | 94 |
94 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 95 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
95 Source<ThemeService>(theme_service_)); | 96 Source<ThemeService>(theme_service_)); |
96 UpdateBorderColor(); | 97 UpdateBorderColor(); |
97 } | 98 } |
98 | 99 |
99 InfoBarGtk::~InfoBarGtk() { | 100 InfoBarGtk::~InfoBarGtk() { |
100 } | 101 } |
101 | 102 |
102 GtkWidget* InfoBarGtk::widget() { | 103 GtkWidget* InfoBarGtk::widget() { |
103 return widget_.get(); | 104 return widget_.get(); |
104 } | 105 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void InfoBarGtk::PlatformSpecificOnHeightsRecalculated() { | 245 void InfoBarGtk::PlatformSpecificOnHeightsRecalculated() { |
245 GtkRequisition req; | 246 GtkRequisition req; |
246 gtk_widget_size_request(bg_box_, &req); | 247 gtk_widget_size_request(bg_box_, &req); |
247 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()), | 248 gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()), |
248 bg_box_, 0, bar_height() - req.height); | 249 bg_box_, 0, bar_height() - req.height); |
249 | 250 |
250 gtk_widget_set_size_request(widget_.get(), -1, bar_height()); | 251 gtk_widget_set_size_request(widget_.get(), -1, bar_height()); |
251 gtk_widget_queue_draw(widget_.get()); | 252 gtk_widget_queue_draw(widget_.get()); |
252 } | 253 } |
253 | 254 |
254 void InfoBarGtk::Observe(NotificationType type, | 255 void InfoBarGtk::Observe(int type, |
255 const NotificationSource& source, | 256 const NotificationSource& source, |
256 const NotificationDetails& details) { | 257 const NotificationDetails& details) { |
257 UpdateBorderColor(); | 258 UpdateBorderColor(); |
258 } | 259 } |
259 | 260 |
260 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded, | 261 void InfoBarGtk::OnChildSizeRequest(GtkWidget* expanded, |
261 GtkWidget* child, | 262 GtkWidget* child, |
262 GtkRequisition* requisition) { | 263 GtkRequisition* requisition) { |
263 requisition->height = -1; | 264 requisition->height = -1; |
264 } | 265 } |
OLD | NEW |