summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 23:38:17 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 23:38:17 +0000
commita96182f9c4be4a711bddf2c5aaee9e2638ea12e1 (patch)
tree051145df5bb5aaad21d789b0fef09be8e10b108b
parent05d47875219edd6f25490d8a878021ff2d564170 (diff)
downloadchromium_src-a96182f9c4be4a711bddf2c5aaee9e2638ea12e1.zip
chromium_src-a96182f9c4be4a711bddf2c5aaee9e2638ea12e1.tar.gz
chromium_src-a96182f9c4be4a711bddf2c5aaee9e2638ea12e1.tar.bz2
Linux: Hook up confirm info bar buttons. Session restore works.
Review URL: http://codereview.chromium.org/62163 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/infobar_gtk.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc
index b1e0506..7212b8e 100644
--- a/chrome/browser/gtk/infobar_gtk.cc
+++ b/chrome/browser/gtk/infobar_gtk.cc
@@ -52,7 +52,7 @@ InfoBar::InfoBar(InfoBarDelegate* delegate)
gtk_widget_set_size_request(widget_.get(), -1, kInfoBarHeight);
close_button_.reset(CustomDrawButton::AddBarCloseButton(hbox_));
- g_signal_connect(G_OBJECT(close_button_->widget()), "clicked",
+ g_signal_connect(close_button_->widget(), "clicked",
G_CALLBACK(OnCloseButton), this);
g_object_set_data(G_OBJECT(widget_.get()), "info-bar", this);
@@ -130,7 +130,35 @@ class ConfirmInfoBar : public AlertInfoBar {
public:
ConfirmInfoBar(ConfirmInfoBarDelegate* delegate)
: AlertInfoBar(delegate) {
- NOTIMPLEMENTED();
+ AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_CANCEL);
+ AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_OK);
+ }
+
+ private:
+ // Adds a button to the info bar by type. It will do nothing if the delegate
+ // doesn't specify a button of the given type.
+ void AddConfirmButton(ConfirmInfoBarDelegate::InfoBarButton type) {
+ if (delegate_->AsConfirmInfoBarDelegate()->GetButtons() & type) {
+ GtkWidget* button = gtk_button_new_with_label(WideToUTF8(
+ delegate_->AsConfirmInfoBarDelegate()->GetButtonLabel(type)).c_str());
+ GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(centering_vbox), button, TRUE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox_), centering_vbox, FALSE, FALSE, 0);
+ g_signal_connect(button, "clicked",
+ G_CALLBACK(type == ConfirmInfoBarDelegate::BUTTON_OK ?
+ OnOkButton : OnCancelButton),
+ this);
+ }
+ }
+
+ static void OnCancelButton(GtkWidget* button, ConfirmInfoBar* info_bar) {
+ if (info_bar->delegate_->AsConfirmInfoBarDelegate()->Cancel())
+ info_bar->RemoveInfoBar();
+ }
+
+ static void OnOkButton(GtkWidget* button, ConfirmInfoBar* info_bar) {
+ if (info_bar->delegate_->AsConfirmInfoBarDelegate()->Accept())
+ info_bar->RemoveInfoBar();
}
};