summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:36:34 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 23:36:34 +0000
commitba7a68dfbf6f30e5b3efc3f5034499a952463d96 (patch)
treea90622682db23e4983778a96512995378f5ca284 /chrome/browser
parent4a560eddc550fbe5761aceb1461ff91e9097a3d3 (diff)
downloadchromium_src-ba7a68dfbf6f30e5b3efc3f5034499a952463d96.zip
chromium_src-ba7a68dfbf6f30e5b3efc3f5034499a952463d96.tar.gz
chromium_src-ba7a68dfbf6f30e5b3efc3f5034499a952463d96.tar.bz2
Restore RTL icons to CustomDrawButtonBase.
Since moving from ResourceBundle to ThemeProvider, we needed to plumb through GetRTLEnabledPixbufNamed in ThemeProvider. Review URL: http://codereview.chromium.org/149483 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_theme_provider.h6
-rw-r--r--chrome/browser/browser_theme_provider_gtk.cc22
-rw-r--r--chrome/browser/gtk/custom_button.cc17
3 files changed, 34 insertions, 11 deletions
diff --git a/chrome/browser/browser_theme_provider.h b/chrome/browser/browser_theme_provider.h
index f91b494..6d7bb70 100644
--- a/chrome/browser/browser_theme_provider.h
+++ b/chrome/browser/browser_theme_provider.h
@@ -137,6 +137,7 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
virtual bool HasCustomImage(int id);
#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
virtual GdkPixbuf* GetPixbufNamed(int id);
+ virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id);
#elif defined(OS_MACOSX)
virtual NSImage* GetNSImageNamed(int id);
virtual NSColor* GetNSColorTint(int id);
@@ -252,6 +253,11 @@ class BrowserThemeProvider : public base::RefCounted<BrowserThemeProvider>,
// from ClearCaches().
void FreePlatformCaches();
+#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
+ // Loads an image and flips it horizontally if |rtl_enabled| is true.
+ GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled);
+#endif
+
// Cached images. We cache all retrieved and generated bitmaps and keep
// track of the pointers. We own these and will delete them when we're done
// using them.
diff --git a/chrome/browser/browser_theme_provider_gtk.cc b/chrome/browser/browser_theme_provider_gtk.cc
index 9605344..2787dce 100644
--- a/chrome/browser/browser_theme_provider_gtk.cc
+++ b/chrome/browser/browser_theme_provider_gtk.cc
@@ -4,14 +4,25 @@
#include "chrome/browser/browser_theme_provider.h"
+#include "app/l10n_util.h"
#include "base/gfx/gtk_util.h"
#include "base/logging.h"
GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) {
+ return GetPixbufImpl(id, false);
+}
+
+GdkPixbuf* BrowserThemeProvider::GetRTLEnabledPixbufNamed(int id) {
+ return GetPixbufImpl(id, true);
+}
+
+GdkPixbuf* BrowserThemeProvider::GetPixbufImpl(int id, bool rtl_enabled) {
DCHECK(CalledOnValidThread());
+ // Use the negative |resource_id| for the key for BIDI-aware images.
+ int key = rtl_enabled ? -id : id;
// Check to see if we already have the pixbuf in the cache.
- GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(id);
+ GdkPixbufMap::const_iterator found = gdk_pixbufs_.find(key);
if (found != gdk_pixbufs_.end())
return found->second;
@@ -20,7 +31,14 @@ GdkPixbuf* BrowserThemeProvider::GetPixbufNamed(int id) {
// We loaded successfully. Cache the pixbuf.
if (pixbuf) {
- gdk_pixbufs_[id] = pixbuf;
+ if ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) &&
+ rtl_enabled) {
+ GdkPixbuf* original_pixbuf = pixbuf;
+ pixbuf = gdk_pixbuf_flip(pixbuf, TRUE);
+ g_object_unref(original_pixbuf);
+ }
+
+ gdk_pixbufs_[key] = pixbuf;
return pixbuf;
}
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc
index d2e092f..b49c422 100644
--- a/chrome/browser/gtk/custom_button.cc
+++ b/chrome/browser/gtk/custom_button.cc
@@ -80,16 +80,15 @@ void CustomDrawButtonBase::Observe(NotificationType type,
DCHECK(theme_provider_);
DCHECK(NotificationType::BROWSER_THEME_CHANGED == type);
- // TODO(tc): Add GetRTLEnabledPixbufNamed to ThemeProviderGtk.
- pixbufs_[GTK_STATE_NORMAL] =
- normal_id_ ? theme_provider_->GetPixbufNamed(normal_id_) : NULL;
- pixbufs_[GTK_STATE_ACTIVE] =
- active_id_ ? theme_provider_->GetPixbufNamed(active_id_) : NULL;
- pixbufs_[GTK_STATE_PRELIGHT] =
- highlight_id_ ? theme_provider_->GetPixbufNamed(highlight_id_) : NULL;
+ pixbufs_[GTK_STATE_NORMAL] = normal_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(normal_id_) : NULL;
+ pixbufs_[GTK_STATE_ACTIVE] = active_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(active_id_) : NULL;
+ pixbufs_[GTK_STATE_PRELIGHT] = highlight_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(highlight_id_) : NULL;
pixbufs_[GTK_STATE_SELECTED] = NULL;
- pixbufs_[GTK_STATE_INSENSITIVE] =
- depressed_id_ ? theme_provider_->GetPixbufNamed(depressed_id_) : NULL;
+ pixbufs_[GTK_STATE_INSENSITIVE] = depressed_id_ ?
+ theme_provider_->GetRTLEnabledPixbufNamed(depressed_id_) : NULL;
}
CustomDrawButton::CustomDrawButton(int normal_id, int active_id,