| 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" | |
| 11 | 10 |
| 12 TranslateMessageInfoBar::TranslateMessageInfoBar( | 11 TranslateMessageInfoBar::TranslateMessageInfoBar( |
| 13 TabContentsWrapper* owner, | 12 TabContentsWrapper* owner, |
| 14 TranslateInfoBarDelegate* delegate) | 13 TranslateInfoBarDelegate* delegate) |
| 15 : TranslateInfoBarBase(owner, delegate) { | 14 : TranslateInfoBarBase(owner, delegate) { |
| 16 } | 15 } |
| 17 | 16 |
| 18 TranslateMessageInfoBar::~TranslateMessageInfoBar() { | 17 TranslateMessageInfoBar::~TranslateMessageInfoBar() { |
| 19 } | 18 } |
| 20 | 19 |
| 21 void TranslateMessageInfoBar::Init() { | 20 void TranslateMessageInfoBar::Init() { |
| 22 TranslateInfoBarBase::Init(); | 21 TranslateInfoBarBase::Init(); |
| 23 | 22 |
| 24 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); | 23 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); |
| 25 gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0); | 24 gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0); |
| 26 | 25 |
| 27 std::string text = UTF16ToUTF8(GetDelegate()->GetMessageInfoBarText()); | 26 std::string text = UTF16ToUTF8(GetDelegate()->GetMessageInfoBarText()); |
| 28 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(text.c_str()), FALSE, FALSE, 0); | 27 gtk_box_pack_start(GTK_BOX(hbox), CreateLabel(text.c_str()), FALSE, FALSE, 0); |
| 29 string16 button_text = GetDelegate()->GetMessageInfoBarButtonText(); | 28 string16 button_text = GetDelegate()->GetMessageInfoBarButtonText(); |
| 30 if (!button_text.empty()) { | 29 if (!button_text.empty()) { |
| 31 GtkWidget* button = | 30 GtkWidget* button = |
| 32 gtk_button_new_with_label(UTF16ToUTF8(button_text).c_str()); | 31 gtk_button_new_with_label(UTF16ToUTF8(button_text).c_str()); |
| 33 g_signal_connect(button, "clicked",G_CALLBACK(&OnButtonPressedThunk), this); | 32 g_signal_connect(button, "clicked",G_CALLBACK(&OnButtonPressedThunk), this); |
| 34 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 33 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 | 36 |
| 38 void TranslateMessageInfoBar::OnButtonPressed(GtkWidget* sender) { | 37 void TranslateMessageInfoBar::OnButtonPressed(GtkWidget* sender) { |
| 39 GetDelegate()->MessageInfoBarButtonPressed(); | 38 GetDelegate()->MessageInfoBarButtonPressed(); |
| 40 } | 39 } |
| OLD | NEW |