diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 21:54:23 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 21:54:23 +0000 |
commit | 10ae1be6a6766ae1148db89c4f68e0c8ac466ad5 (patch) | |
tree | 92c0c069b887a163014b9861999376e0dc72602c | |
parent | 092a2fab32125a0cc94ac732f0ee881c36c3009b (diff) | |
download | chromium_src-10ae1be6a6766ae1148db89c4f68e0c8ac466ad5.zip chromium_src-10ae1be6a6766ae1148db89c4f68e0c8ac466ad5.tar.gz chromium_src-10ae1be6a6766ae1148db89c4f68e0c8ac466ad5.tar.bz2 |
GTK: Buttons on Confirm Infobars should have matching sizes.
BUG=77576
TEST=On a confirm infobar with multiple buttons, all buttons are the same width.
Review URL: http://codereview.chromium.org/7066031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86500 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc index 51fc25b..2314a8c 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.cc @@ -20,7 +20,8 @@ InfoBar* ConfirmInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { // ConfirmInfoBarGtk ----------------------------------------------------------- ConfirmInfoBarGtk::ConfirmInfoBarGtk(ConfirmInfoBarDelegate* delegate) - : InfoBar(delegate) { + : InfoBar(delegate), + size_group_(NULL) { confirm_hbox_ = gtk_chrome_shrinkable_hbox_new(FALSE, FALSE, kEndOfLabelSpacing); // This alignment allocates the confirm hbox only as much space as it @@ -59,12 +60,19 @@ ConfirmInfoBarGtk::ConfirmInfoBarGtk(ConfirmInfoBarDelegate* delegate) } ConfirmInfoBarGtk::~ConfirmInfoBarGtk() { + if (size_group_) + g_object_unref(size_group_); } void ConfirmInfoBarGtk::AddButton(ConfirmInfoBarDelegate::InfoBarButton type) { if (delegate_->AsConfirmInfoBarDelegate()->GetButtons() & type) { + if (!size_group_) + size_group_ = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkWidget* button = gtk_button_new_with_label(UTF16ToUTF8( delegate_->AsConfirmInfoBarDelegate()->GetButtonLabel(type)).c_str()); + gtk_size_group_add_widget(size_group_, button); + gtk_util::CenterWidgetInHBox(confirm_hbox_, button, true, 0); g_signal_connect(button, "clicked", G_CALLBACK(type == ConfirmInfoBarDelegate::BUTTON_OK ? diff --git a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h index dce45da..8fc0ac7 100644 --- a/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h +++ b/chrome/browser/ui/gtk/infobars/confirm_infobar_gtk.h @@ -11,6 +11,7 @@ #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" #include "ui/base/gtk/gtk_signal.h" +typedef struct _GtkSizeGroup GtkSizeGroup; typedef struct _GtkWidget GtkWidget; // An infobar that shows a message, up to two optional buttons, and an optional, @@ -33,6 +34,8 @@ class ConfirmInfoBarGtk : public InfoBar { GtkWidget* confirm_hbox_; + GtkSizeGroup* size_group_; + DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarGtk); }; |