summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc19
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc56
-rw-r--r--chrome/common/gtk_util.cc9
-rw-r--r--chrome/common/gtk_util.h6
4 files changed, 48 insertions, 42 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index b542d8d..8191a4a 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -177,19 +177,21 @@ void BookmarkBarGtk::Init(Profile* profile) {
gtk_widget_modify_fg(instructions_label, GTK_STATE_NORMAL,
&kInstructionsColor);
gtk_container_add(GTK_CONTAINER(instructions_), instructions_label);
- gtk_box_pack_start(GTK_BOX(bookmark_hbox_.get()), instructions_,
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(bookmark_hbox_.get()),
+ instructions_, FALSE, FALSE, 0);
gtk_widget_set_app_paintable(bookmark_hbox_.get(), TRUE);
g_signal_connect(G_OBJECT(bookmark_hbox_.get()), "expose-event",
G_CALLBACK(&OnHBoxExpose), this);
bookmark_toolbar_.Own(gtk_toolbar_new());
+ if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
+ gtk_widget_set_direction(bookmark_toolbar_.get(), GTK_TEXT_DIR_RTL);
gtk_widget_set_app_paintable(bookmark_toolbar_.get(), TRUE);
g_signal_connect(G_OBJECT(bookmark_toolbar_.get()), "expose-event",
G_CALLBACK(&OnToolbarExpose), this);
- gtk_box_pack_start(GTK_BOX(bookmark_hbox_.get()), bookmark_toolbar_.get(),
- TRUE, TRUE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(bookmark_hbox_.get()),
+ bookmark_toolbar_.get(), TRUE, TRUE, 0);
gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP,
bookmark_utils::kTargetTable,
@@ -206,8 +208,8 @@ void BookmarkBarGtk::Init(Profile* profile) {
g_signal_connect(bookmark_toolbar_.get(), "button-press-event",
G_CALLBACK(&OnButtonPressed), this);
- gtk_box_pack_start(GTK_BOX(bookmark_hbox_.get()), gtk_vseparator_new(),
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(bookmark_hbox_.get()),
+ gtk_vseparator_new(), FALSE, FALSE, 0);
other_bookmarks_button_ = gtk_chrome_button_new();
ConnectFolderButtonEvents(other_bookmarks_button_);
@@ -219,8 +221,9 @@ void BookmarkBarGtk::Init(Profile* profile) {
// Set the proper text colors.
SetButtonTextColors(other_bookmarks_button_);
- gtk_box_pack_start(GTK_BOX(bookmark_hbox_.get()), other_bookmarks_button_,
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(bookmark_hbox_.get()),
+ other_bookmarks_button_,
+ FALSE, FALSE, 0);
gtk_widget_set_size_request(bookmark_hbox_.get(), -1, 0);
slide_animation_.reset(new SlideAnimation(this));
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 5088453..85c67ff 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -53,18 +53,6 @@ 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 ---------------------------------------------------
@@ -125,14 +113,14 @@ void BrowserToolbarGtk::Init(Profile* profile,
GtkWidget* back_forward_hbox_ = gtk_hbox_new(FALSE, 0);
back_.reset(new BackForwardButtonGtk(browser_, false));
- BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_), back_->widget(),
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_),
+ back_->widget(), FALSE, FALSE, 0);
forward_.reset(new BackForwardButtonGtk(browser_, true));
- BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_), forward_->widget(),
- FALSE, FALSE, 0);
- BoxPackWidgetWithDirection(GTK_BOX(toolbar_), back_forward_hbox_,
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(back_forward_hbox_),
+ forward_->widget(), FALSE, FALSE, 0);
+ gtk_util::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)));
@@ -144,19 +132,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)));
- BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), star_->widget(),
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), star_->widget(),
+ FALSE, FALSE, 0);
location_bar_->Init();
- BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), location_bar_->widget(),
- TRUE, TRUE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_),
+ location_bar_->widget(), TRUE, TRUE, 0);
go_.reset(new GoButtonGtk(location_bar_.get(), browser_));
- BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), go_->widget(),
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(omnibox_hbox_), go_->widget(),
+ FALSE, FALSE, 0);
- BoxPackWidgetWithDirection(GTK_BOX(toolbar_), omnibox_hbox_,
- TRUE, TRUE, 0);
+ gtk_util::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);
@@ -164,19 +152,19 @@ void BrowserToolbarGtk::Init(Profile* profile,
l10n_util::GetStringUTF8(IDS_PAGEMENU_TOOLTIP),
&page_menu_button_);
page_menu_.reset(new MenuGtk(this, GetStandardPageMenu(), accel_group_));
- BoxPackWidgetWithDirection(GTK_BOX(menus_hbox_), page_menu,
- FALSE, FALSE, 0);
+ gtk_util::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_));
- BoxPackWidgetWithDirection(GTK_BOX(menus_hbox_), chrome_menu,
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(menus_hbox_), chrome_menu,
+ FALSE, FALSE, 0);
- BoxPackWidgetWithDirection(GTK_BOX(toolbar_), menus_hbox_,
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(toolbar_), menus_hbox_,
+ FALSE, FALSE, 0);
gtk_widget_show_all(toolbar_);
@@ -324,8 +312,8 @@ CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton(
g_signal_connect(button->widget(), "button-release-event",
G_CALLBACK(OnButtonRelease), this);
- BoxPackWidgetWithDirection(GTK_BOX(toolbar_), button->widget(),
- FALSE, FALSE, 0);
+ gtk_util::BoxPackWidgetWithDirection(GTK_BOX(toolbar_), button->widget(),
+ FALSE, FALSE, 0);
return button;
}
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 0ff6111..46518ca 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -286,4 +286,13 @@ bool WidgetContainsCursor(GtkWidget* widget) {
return widget_allocation.Contains(x, y);
}
+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 gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index e4e7da3..d07393c 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -104,6 +104,12 @@ int MirroredLeftPointForRect(GtkWidget* widget, const gfx::Rect& bounds);
// Returns true if the pointer is currently inside the widget.
bool WidgetContainsCursor(GtkWidget* widget);
+// 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);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_