| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/infobars/translate_message_infobar_gtk.h" | 5 #include "chrome/browser/ui/gtk/infobars/translate_message_infobar_gtk.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/translate/translate_infobar_delegate.h" | 8 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 10 #include "ui/base/gtk/gtk_hig_constants.h" | 10 #include "ui/base/gtk/gtk_hig_constants.h" |
| 11 #include "ui/base/gtk/gtk_signal_registrar.h" | 11 #include "ui/base/gtk/gtk_signal_registrar.h" |
| 12 | 12 |
| 13 TranslateMessageInfoBar::TranslateMessageInfoBar( | 13 TranslateMessageInfoBar::TranslateMessageInfoBar( |
| 14 InfoBarService* owner, | 14 InfoBarService* owner, |
| 15 TranslateInfoBarDelegate* delegate) | 15 TranslateInfoBarDelegate* delegate) |
| 16 : TranslateInfoBarBase(owner, delegate) { | 16 : TranslateInfoBarBase(owner, delegate) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 TranslateMessageInfoBar::~TranslateMessageInfoBar() { | 19 TranslateMessageInfoBar::~TranslateMessageInfoBar() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 void TranslateMessageInfoBar::Init() { | 22 void TranslateMessageInfoBar::InitWidgets() { |
| 23 TranslateInfoBarBase::Init(); | 23 TranslateInfoBarBase::InitWidgets(); |
| 24 | 24 |
| 25 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); | 25 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); |
| 26 gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0); | 26 gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0); |
| 27 | 27 |
| 28 std::string text = UTF16ToUTF8(GetDelegate()->GetMessageInfoBarText()); | 28 std::string text = UTF16ToUTF8(GetDelegate()->GetMessageInfoBarText()); |
| 29 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(text.c_str()), FALSE, FALSE, 0); | 29 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(text.c_str()), FALSE, FALSE, 0); |
| 30 string16 button_text = GetDelegate()->GetMessageInfoBarButtonText(); | 30 string16 button_text = GetDelegate()->GetMessageInfoBarButtonText(); |
| 31 if (!button_text.empty()) { | 31 if (!button_text.empty()) { |
| 32 GtkWidget* button = | 32 GtkWidget* button = |
| 33 gtk_button_new_with_label(UTF16ToUTF8(button_text).c_str()); | 33 gtk_button_new_with_label(UTF16ToUTF8(button_text).c_str()); |
| 34 Signals()->Connect(button, "clicked",G_CALLBACK(&OnButtonPressedThunk), | 34 Signals()->Connect(button, "clicked",G_CALLBACK(&OnButtonPressedThunk), |
| 35 this); | 35 this); |
| 36 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 36 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 void TranslateMessageInfoBar::OnButtonPressed(GtkWidget* sender) { | 40 void TranslateMessageInfoBar::OnButtonPressed(GtkWidget* sender) { |
| 41 GetDelegate()->MessageInfoBarButtonPressed(); | 41 GetDelegate()->MessageInfoBarButtonPressed(); |
| 42 } | 42 } |
| OLD | NEW |