0

GTK: Move TranslateInfoBarBase::BuildOptionsMenuButton to InfoBarGtk::CreateMenuButton

BUG=NONE
TEST=NONE


Review URL: http://codereview.chromium.org/9602007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125090 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
yujie.mao@intel.com
2012-03-06 03:17:09 +00:00
parent 41842cb105
commit 0c7cc28a96
5 changed files with 29 additions and 28 deletions

@ -167,3 +167,4 @@ Peter Collingbourne <peter@pcc.me.uk>
Aaron Randolph <aaron.randolph@gmail.com>
Yumikiyo Osanai <yumios.art@gmail.com>
Matthew Robertson <matthewrobertson03@gmail.com>
Mao Yujie <yujie.mao@intel.com>

@ -128,6 +128,26 @@ GtkWidget* InfoBarGtk::CreateLinkButton(const std::string& text) {
return theme_service_->BuildChromeLinkButton(text);
}
// static
GtkWidget* InfoBarGtk::CreateMenuButton(const std::string& text) {
GtkWidget* button = gtk_button_new();
GtkWidget* former_child = gtk_bin_get_child(GTK_BIN(button));
if (former_child)
gtk_container_remove(GTK_CONTAINER(button), former_child);
GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
GtkWidget* label = gtk_label_new(text.c_str());
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
GtkWidget* arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_box_pack_start(GTK_BOX(hbox), arrow, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), hbox);
return button;
}
SkColor InfoBarGtk::ConvertGetColor(ColorGetter getter) {
double r, g, b;
(this->*getter)(delegate()->GetInfoBarType(), &r, &g, &b);

@ -71,6 +71,10 @@ class InfoBarGtk : public InfoBar,
// Creates a link button with the appropriate current gtk-theme state.
GtkWidget* CreateLinkButton(const std::string& text);
// Builds a button with an arrow in it to emulate the menu-button style from
// the windows version.
static GtkWidget* CreateMenuButton(const std::string& text);
// Adds |display_text| to the infobar. If |link_text| is not empty, it is
// rendered as a hyperlink and inserted into |display_text| at |link_offset|,
// or right aligned in the infobar if |link_offset| is |npos|. If a link is

@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -63,7 +63,8 @@ void TranslateInfoBarBase::Init() {
// The options button sits outside the translate_box so that it can be end
// packed in hbox_.
GtkWidget* options_menu_button = BuildOptionsMenuButton();
GtkWidget* options_menu_button = CreateMenuButton(
l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS));
Signals()->Connect(options_menu_button, "clicked",
G_CALLBACK(&OnOptionsClickedThunk), this);
gtk_widget_show_all(options_menu_button);
@ -188,27 +189,6 @@ TranslateInfoBarDelegate* TranslateInfoBarBase::GetDelegate() {
return static_cast<TranslateInfoBarDelegate*>(delegate());
}
// static
GtkWidget* TranslateInfoBarBase::BuildOptionsMenuButton() {
GtkWidget* button = gtk_button_new();
GtkWidget* former_child = gtk_bin_get_child(GTK_BIN(button));
if (former_child)
gtk_container_remove(GTK_CONTAINER(button), former_child);
GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
GtkWidget* label = gtk_label_new(
l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS).c_str());
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
GtkWidget* arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_box_pack_start(GTK_BOX(hbox), arrow, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(button), hbox);
return button;
}
void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) {
ShowMenuWithModel(sender, NULL, new OptionsMenuModel(GetDelegate()));
}

@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -55,10 +55,6 @@ class TranslateInfoBarBase : public InfoBarGtk {
TranslateInfoBarDelegate* GetDelegate();
private:
// Builds a button with an arrow in it to emulate the menu-button style from
// the windows version.
static GtkWidget* BuildOptionsMenuButton();
CHROMEGTK_CALLBACK_0(TranslateInfoBarBase, void, OnOptionsClicked);
// A percentage to average the normal page action background with the error