diff options
Diffstat (limited to 'chrome/browser/gtk/nine_box.cc')
-rw-r--r-- | chrome/browser/gtk/nine_box.cc | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc index ba1b856..af2de61 100644 --- a/chrome/browser/gtk/nine_box.cc +++ b/chrome/browser/gtk/nine_box.cc @@ -6,9 +6,11 @@ #include "app/resource_bundle.h" #include "app/theme_provider.h" +#include "base/basictypes.h" #include "base/gfx/gtk_util.h" #include "base/gfx/point.h" #include "base/logging.h" +#include "chrome/common/notification_service.h" namespace { @@ -45,25 +47,25 @@ NineBox::NineBox(int top_left, int top, int top_right, int left, int center, NineBox::NineBox(ThemeProvider* theme_provider, int top_left, int top, int top_right, int left, int center, - int right, int bottom_left, int bottom, int bottom_right) { - images_[0] = top_left ? - theme_provider->GetPixbufNamed(top_left) : NULL; - images_[1] = top ? - theme_provider->GetPixbufNamed(top) : NULL; - images_[2] = top_right ? - theme_provider->GetPixbufNamed(top_right) : NULL; - images_[3] = left ? - theme_provider->GetPixbufNamed(left) : NULL; - images_[4] = center ? - theme_provider->GetPixbufNamed(center) : NULL; - images_[5] = right ? - theme_provider->GetPixbufNamed(right) : NULL; - images_[6] = bottom_left ? - theme_provider->GetPixbufNamed(bottom_left) : NULL; - images_[7] = bottom ? - theme_provider->GetPixbufNamed(bottom) : NULL; - images_[8] = bottom_right ? - theme_provider->GetPixbufNamed(bottom_right) : NULL; + int right, int bottom_left, int bottom, int bottom_right) + : theme_provider_(theme_provider) { + image_ids_[0] = top_left; + image_ids_[1] = top; + image_ids_[2] = top_right; + image_ids_[3] = left; + image_ids_[4] = center; + image_ids_[5] = right; + image_ids_[6] = bottom_left; + image_ids_[7] = bottom; + image_ids_[8] = bottom_right; + + // Load images by pretending that we got a BROWSER_THEME_CHANGED + // notification. + Observe(NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources(), + NotificationService::NoDetails()); + registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, + NotificationService::AllSources()); } NineBox::~NineBox() { @@ -177,3 +179,17 @@ void NineBox::ContourWidget(GtkWidget* widget) const { g_object_unref(mask); cairo_destroy(cr); } + +void NineBox::Observe(NotificationType type, const NotificationSource& source, + const NotificationDetails& details) { + if (NotificationType::BROWSER_THEME_CHANGED != type) { + NOTREACHED(); + return; + } + + // Reload images. + for (size_t i = 0; i < arraysize(image_ids_); ++i) { + images_[i] = image_ids_[i] ? + theme_provider_->GetPixbufNamed(image_ids_[i]) : NULL; + } +} |