summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 20:15:04 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 20:15:04 +0000
commitcef3252ec55262e7b89cf15081e3db81a24385eb (patch)
tree1482b87742294f13522e0d0ec2557c5a7b1b61f9 /chrome
parent80aa5e2327f4b3185557e83f8f6efa18e72b750c (diff)
downloadchromium_src-cef3252ec55262e7b89cf15081e3db81a24385eb.zip
chromium_src-cef3252ec55262e7b89cf15081e3db81a24385eb.tar.gz
chromium_src-cef3252ec55262e7b89cf15081e3db81a24385eb.tar.bz2
Add support for RTL languages in the gtk toolbar layout.
BUG=none TEST=Open a browser window in a RTL language (--lang=he). The toolbar layout should correctly be in RTL layout. Review URL: http://codereview.chromium.org/147102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc48
1 files changed, 34 insertions, 14 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index c31d93e..5088453 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -53,6 +53,18 @@ const int kPopupTopMargin = 0;
// to leave 1 pixel on both side here so that the borders line up.
const int kPopupLeftRightMargin = 1;
+// Packs |widget| into |parent|. If the current UI text direction is
+// RIGHT_TO_LEFT, the widget is packed at the end; otherwise, it is packed at
+// the beginning.
+void BoxPackWidgetWithDirection(GtkBox* parent, GtkWidget* widget,
+ guint expand, guint fill, guint padding) {
+ if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
+ gtk_box_pack_end(parent, widget, expand, fill, padding);
+ } else {
+ gtk_box_pack_start(parent, widget, expand, fill, padding);
+ }
+}
+
} // namespace
// BrowserToolbarGtk, public ---------------------------------------------------
@@ -113,13 +125,14 @@ void BrowserToolbarGtk::Init(Profile* profile,
GtkWidget* back_forward_hbox_ = gtk_hbox_new(FALSE, 0);
back_.reset(new BackForwardButtonGtk(browser_, false));
- gtk_box_pack_start(GTK_BOX(back_forward_hbox_), back_->widget(), FALSE,
- FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_), back_->widget(),
+ FALSE, FALSE, 0);
forward_.reset(new BackForwardButtonGtk(browser_, true));
- gtk_box_pack_start(GTK_BOX(back_forward_hbox_), forward_->widget(), FALSE,
- FALSE, 0);
- gtk_box_pack_start(GTK_BOX(toolbar_), back_forward_hbox_, FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_), forward_->widget(),
+ FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(toolbar_), back_forward_hbox_,
+ FALSE, FALSE, 0);
reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0,
l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD)));
@@ -131,16 +144,19 @@ void BrowserToolbarGtk::Init(Profile* profile,
// Group the start, omnibox, and go button into an hbox.
GtkWidget* omnibox_hbox_ = gtk_hbox_new(FALSE, 0);
star_.reset(BuildStarButton(l10n_util::GetStringUTF8(IDS_TOOLTIP_STAR)));
- gtk_box_pack_start(GTK_BOX(omnibox_hbox_), star_->widget(), FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), star_->widget(),
+ FALSE, FALSE, 0);
location_bar_->Init();
- gtk_box_pack_start(GTK_BOX(omnibox_hbox_), location_bar_->widget(), TRUE,
- TRUE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), location_bar_->widget(),
+ TRUE, TRUE, 0);
go_.reset(new GoButtonGtk(location_bar_.get(), browser_));
- gtk_box_pack_start(GTK_BOX(omnibox_hbox_), go_->widget(), FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), go_->widget(),
+ FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(toolbar_), omnibox_hbox_, TRUE, TRUE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(toolbar_), omnibox_hbox_,
+ TRUE, TRUE, 0);
// Group the menu buttons together in an hbox.
GtkWidget* menus_hbox_ = gtk_hbox_new(FALSE, 0);
@@ -148,16 +164,19 @@ void BrowserToolbarGtk::Init(Profile* profile,
l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP),
&page_menu_button_);
page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(), accel_group_));
- gtk_box_pack_start(GTK_BOX(menus_hbox_), page_menu, FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(menus_hbox_), page_menu,
+ FALSE, FALSE, 0);
GtkWidget* chrome_menu = BuildToolbarMenuButton(IDR_MENU_CHROME,
l10n_util::GetStringFUTF8(IDS_APPMENU_TOOLTIP,
WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))),
&app_menu_button_);
app_menu_.reset(new MenuGtk(this, GetStandardAppMenu(), accel_group_));
- gtk_box_pack_start(GTK_BOX(menus_hbox_), chrome_menu, FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(menus_hbox_), chrome_menu,
+ FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(toolbar_), menus_hbox_, FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(toolbar_), menus_hbox_,
+ FALSE, FALSE, 0);
gtk_widget_show_all(toolbar_);
@@ -305,7 +324,8 @@ CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
g_signal_connect(button->widget(), "button-release-event",
G_CALLBACK(OnButtonRelease), this);
- gtk_box_pack_start(GTK_BOX(toolbar_), button->widget(), FALSE, FALSE, 0);
+ BoxPackWidgetWithDirection(GTK_BOX(toolbar_), button->widget(),
+ FALSE, FALSE, 0);
return button;
}