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