| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/gtk/infobar_gtk.h" | 5 #include "chrome/browser/gtk/infobar_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/gfx/gtk_util.h" | 9 #include "app/gfx/gtk_util.h" |
| 10 #include "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 // We don't want any spacing between the elements, so we pack them into | 170 // We don't want any spacing between the elements, so we pack them into |
| 171 // this hbox that doesn't use kElementPadding. | 171 // this hbox that doesn't use kElementPadding. |
| 172 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); | 172 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); |
| 173 gtk_box_pack_start(GTK_BOX(hbox), initial_label, FALSE, FALSE, 0); | 173 gtk_box_pack_start(GTK_BOX(hbox), initial_label, FALSE, FALSE, 0); |
| 174 gtk_box_pack_start(GTK_BOX(hbox), link_button_->widget(), | 174 gtk_box_pack_start(GTK_BOX(hbox), link_button_->widget(), |
| 175 FALSE, FALSE, 0); | 175 FALSE, FALSE, 0); |
| 176 gtk_box_pack_start(GTK_BOX(hbox), trailing_label, FALSE, FALSE, 0); | 176 gtk_box_pack_start(GTK_BOX(hbox), trailing_label, FALSE, FALSE, 0); |
| 177 gtk_box_pack_start(GTK_BOX(hbox_), hbox, FALSE, FALSE, 0); | 177 gtk_box_pack_start(GTK_BOX(hbox_), hbox, FALSE, FALSE, 0); |
| 178 } | 178 } |
| 179 |
| 180 gtk_widget_show_all(border_bin_.get()); |
| 179 } | 181 } |
| 180 | 182 |
| 181 private: | 183 private: |
| 182 static void OnLinkClick(GtkWidget* button, LinkInfoBar* link_info_bar) { | 184 static void OnLinkClick(GtkWidget* button, LinkInfoBar* link_info_bar) { |
| 183 // TODO(estade): we need an equivalent for DispositionFromEventFlags(). | 185 // TODO(estade): we need an equivalent for DispositionFromEventFlags(). |
| 184 if (link_info_bar->delegate_->AsLinkInfoBarDelegate()-> | 186 if (link_info_bar->delegate_->AsLinkInfoBarDelegate()-> |
| 185 LinkClicked(CURRENT_TAB)) { | 187 LinkClicked(CURRENT_TAB)) { |
| 186 link_info_bar->RemoveInfoBar(); | 188 link_info_bar->RemoveInfoBar(); |
| 187 } | 189 } |
| 188 } | 190 } |
| 189 | 191 |
| 190 // The clickable link text. | 192 // The clickable link text. |
| 191 scoped_ptr<LinkButtonGtk> link_button_; | 193 scoped_ptr<LinkButtonGtk> link_button_; |
| 192 }; | 194 }; |
| 193 | 195 |
| 194 // ConfirmInfoBar -------------------------------------------------------------- | 196 // ConfirmInfoBar -------------------------------------------------------------- |
| 195 | 197 |
| 196 class ConfirmInfoBar : public AlertInfoBar { | 198 class ConfirmInfoBar : public AlertInfoBar { |
| 197 public: | 199 public: |
| 198 ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) | 200 ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) |
| 199 : AlertInfoBar(delegate) { | 201 : AlertInfoBar(delegate) { |
| 200 AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_CANCEL); | 202 AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_CANCEL); |
| 201 AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_OK); | 203 AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_OK); |
| 204 |
| 205 gtk_widget_show_all(border_bin_.get()); |
| 202 } | 206 } |
| 203 | 207 |
| 204 private: | 208 private: |
| 205 // Adds a button to the info bar by type. It will do nothing if the delegate | 209 // Adds a button to the info bar by type. It will do nothing if the delegate |
| 206 // doesn't specify a button of the given type. | 210 // doesn't specify a button of the given type. |
| 207 void AddConfirmButton(ConfirmInfoBarDelegate::InfoBarButton type) { | 211 void AddConfirmButton(ConfirmInfoBarDelegate::InfoBarButton type) { |
| 208 if (delegate_->AsConfirmInfoBarDelegate()->GetButtons() & type) { | 212 if (delegate_->AsConfirmInfoBarDelegate()->GetButtons() & type) { |
| 209 GtkWidget* button = gtk_button_new_with_label(WideToUTF8( | 213 GtkWidget* button = gtk_button_new_with_label(WideToUTF8( |
| 210 delegate_->AsConfirmInfoBarDelegate()->GetButtonLabel(type)).c_str()); | 214 delegate_->AsConfirmInfoBarDelegate()->GetButtonLabel(type)).c_str()); |
| 211 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); | 215 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 239 | 243 |
| 240 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { | 244 InfoBar* LinkInfoBarDelegate::CreateInfoBar() { |
| 241 return new LinkInfoBar(this); | 245 return new LinkInfoBar(this); |
| 242 } | 246 } |
| 243 | 247 |
| 244 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- | 248 // ConfirmInfoBarDelegate, InfoBarDelegate overrides: -------------------------- |
| 245 | 249 |
| 246 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { | 250 InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() { |
| 247 return new ConfirmInfoBar(this); | 251 return new ConfirmInfoBar(this); |
| 248 } | 252 } |
| OLD | NEW |