| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel_titlebar_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_titlebar_gtk.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/gtk/custom_button.h" | 8 #include "chrome/browser/ui/gtk/custom_button.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 11 #include "chrome/browser/ui/panels/panel.h" | 11 #include "chrome/browser/ui/panels/panel.h" |
| 12 #include "chrome/browser/ui/panels/panel_gtk.h" | 12 #include "chrome/browser/ui/panels/panel_gtk.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | |
| 17 #include "ui/base/gtk/gtk_compat.h" | 16 #include "ui/base/gtk/gtk_compat.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/skia_utils_gtk.h" | 20 #include "ui/gfx/skia_utils_gtk.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Padding around the titlebar. | 24 // Padding around the titlebar. |
| 25 const int kPanelTitlebarPaddingTop = 7; | 25 const int kPanelTitlebarPaddingTop = 7; |
| 26 const int kPanelTitlebarPaddingBottom = 7; | 26 const int kPanelTitlebarPaddingBottom = 7; |
| 27 const int kPanelTitlebarPaddingLeft = 4; | 27 const int kPanelTitlebarPaddingLeft = 4; |
| 28 const int kPanelTitlebarPaddingRight = 8; | 28 const int kPanelTitlebarPaddingRight = 8; |
| 29 | 29 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 void PanelTitlebarGtk::UpdateThrobber( | 210 void PanelTitlebarGtk::UpdateThrobber( |
| 211 content::WebContents* web_contents) { | 211 content::WebContents* web_contents) { |
| 212 if (web_contents && web_contents->IsLoading()) { | 212 if (web_contents && web_contents->IsLoading()) { |
| 213 GdkPixbuf* icon_pixbuf = | 213 GdkPixbuf* icon_pixbuf = |
| 214 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); | 214 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
| 215 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); | 215 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); |
| 216 } else { | 216 } else { |
| 217 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 217 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 218 | 218 |
| 219 SkBitmap icon = panel_gtk_->panel()->GetCurrentPageIcon(); | 219 gfx::Image icon = panel_gtk_->panel()->GetCurrentPageIcon(); |
| 220 if (icon.empty()) { | 220 if (icon.IsEmpty()) { |
| 221 // Fallback to the Chromium icon if the page has no icon. | 221 // Fallback to the Chromium icon if the page has no icon. |
| 222 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), | 222 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), |
| 223 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); | 223 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 224 } else { | 224 } else { |
| 225 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); | 225 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon.ToGdkPixbuf()); |
| 226 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); | |
| 227 g_object_unref(icon_pixbuf); | |
| 228 } | 226 } |
| 229 | 227 |
| 230 throbber_.Reset(); | 228 throbber_.Reset(); |
| 231 } | 229 } |
| 232 } | 230 } |
| 233 | 231 |
| 234 void PanelTitlebarGtk::UpdateTextColor() { | 232 void PanelTitlebarGtk::UpdateTextColor() { |
| 235 GdkColor text_color = gfx::SkColorToGdkColor(GetTextColor()); | 233 GdkColor text_color = gfx::SkColorToGdkColor(GetTextColor()); |
| 236 gtk_util::SetLabelColor(title_, &text_color); | 234 gtk_util::SetLabelColor(title_, &text_color); |
| 237 } | 235 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 event->crossing.state = 0; | 300 event->crossing.state = 0; |
| 303 | 301 |
| 304 g_signal_emit_by_name(GTK_OBJECT(close_button()->widget()), | 302 g_signal_emit_by_name(GTK_OBJECT(close_button()->widget()), |
| 305 "enter-notify-event", event, | 303 "enter-notify-event", event, |
| 306 &return_value); | 304 &return_value); |
| 307 } | 305 } |
| 308 | 306 |
| 309 GtkWidget* PanelTitlebarGtk::widget() const { | 307 GtkWidget* PanelTitlebarGtk::widget() const { |
| 310 return container_; | 308 return container_; |
| 311 } | 309 } |
| OLD | NEW |