| 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/before_translate_infobar_gtk.h" | 5 #include "chrome/browser/ui/gtk/infobars/before_translate_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 "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 51 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 52 | 52 |
| 53 button = gtk_button_new_with_label( | 53 button = gtk_button_new_with_label( |
| 54 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_DENY).c_str()); | 54 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_DENY).c_str()); |
| 55 Signals()->Connect(button, "clicked", | 55 Signals()->Connect(button, "clicked", |
| 56 G_CALLBACK(&OnDenyPressedThunk), this); | 56 G_CALLBACK(&OnDenyPressedThunk), this); |
| 57 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 57 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 58 | 58 |
| 59 TranslateInfoBarDelegate* delegate = GetDelegate(); | 59 TranslateInfoBarDelegate* delegate = GetDelegate(); |
| 60 if (delegate->ShouldShowNeverTranslateButton()) { | 60 if (delegate->ShouldShowNeverTranslateButton()) { |
| 61 std::string label = | 61 std::string label = l10n_util::GetStringFUTF8( |
| 62 l10n_util::GetStringFUTF8(IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, | 62 IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE, |
| 63 delegate->GetLanguageDisplayableNameAt( | 63 delegate->language_name_at(delegate->original_language_index())); |
| 64 delegate->original_language_index())); | |
| 65 button = gtk_button_new_with_label(label.c_str()); | 64 button = gtk_button_new_with_label(label.c_str()); |
| 66 Signals()->Connect(button, "clicked", | 65 Signals()->Connect(button, "clicked", |
| 67 G_CALLBACK(&OnNeverTranslatePressedThunk), this); | 66 G_CALLBACK(&OnNeverTranslatePressedThunk), this); |
| 68 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 67 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 69 } | 68 } |
| 70 | 69 |
| 71 if (delegate->ShouldShowAlwaysTranslateButton()) { | 70 if (delegate->ShouldShowAlwaysTranslateButton()) { |
| 72 std::string label = | 71 std::string label = l10n_util::GetStringFUTF8( |
| 73 l10n_util::GetStringFUTF8(IDS_TRANSLATE_INFOBAR_ALWAYS_TRANSLATE, | 72 IDS_TRANSLATE_INFOBAR_ALWAYS_TRANSLATE, |
| 74 delegate->GetLanguageDisplayableNameAt( | 73 delegate->language_name_at(delegate->original_language_index())); |
| 75 delegate->original_language_index())); | |
| 76 button = gtk_button_new_with_label(label.c_str()); | 74 button = gtk_button_new_with_label(label.c_str()); |
| 77 Signals()->Connect(button, "clicked", | 75 Signals()->Connect(button, "clicked", |
| 78 G_CALLBACK(&OnAlwaysTranslatePressedThunk), this); | 76 G_CALLBACK(&OnAlwaysTranslatePressedThunk), this); |
| 79 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 77 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
| 80 } | 78 } |
| 81 } | 79 } |
| 82 | 80 |
| 83 bool BeforeTranslateInfoBar::ShowOptionsMenuButton() const { | 81 bool BeforeTranslateInfoBar::ShowOptionsMenuButton() const { |
| 84 return true; | 82 return true; |
| 85 } | 83 } |
| 86 | 84 |
| 87 void BeforeTranslateInfoBar::OnLanguageModified(GtkWidget* sender) { | 85 void BeforeTranslateInfoBar::OnLanguageModified(GtkWidget* sender) { |
| 88 size_t index = GetLanguageComboboxActiveId(GTK_COMBO_BOX(sender)); | 86 GetDelegate()->set_original_language_index( |
| 89 if (index == GetDelegate()->original_language_index()) | 87 GetLanguageComboboxActiveId(GTK_COMBO_BOX(sender))); |
| 90 return; | |
| 91 | |
| 92 GetDelegate()->SetOriginalLanguage(index); | |
| 93 } | 88 } |
| 94 | 89 |
| 95 void BeforeTranslateInfoBar::OnAcceptPressed(GtkWidget* sender) { | 90 void BeforeTranslateInfoBar::OnAcceptPressed(GtkWidget* sender) { |
| 96 GetDelegate()->Translate(); | 91 GetDelegate()->Translate(); |
| 97 } | 92 } |
| 98 | 93 |
| 99 void BeforeTranslateInfoBar::OnDenyPressed(GtkWidget* sender) { | 94 void BeforeTranslateInfoBar::OnDenyPressed(GtkWidget* sender) { |
| 100 GetDelegate()->TranslationDeclined(); | 95 GetDelegate()->TranslationDeclined(); |
| 101 RemoveSelf(); | 96 RemoveSelf(); |
| 102 } | 97 } |
| 103 | 98 |
| 104 void BeforeTranslateInfoBar::OnNeverTranslatePressed(GtkWidget* sender) { | 99 void BeforeTranslateInfoBar::OnNeverTranslatePressed(GtkWidget* sender) { |
| 105 GetDelegate()->NeverTranslatePageLanguage(); | 100 GetDelegate()->NeverTranslatePageLanguage(); |
| 106 } | 101 } |
| 107 | 102 |
| 108 void BeforeTranslateInfoBar::OnAlwaysTranslatePressed(GtkWidget* sender) { | 103 void BeforeTranslateInfoBar::OnAlwaysTranslatePressed(GtkWidget* sender) { |
| 109 GetDelegate()->AlwaysTranslatePageLanguage(); | 104 GetDelegate()->AlwaysTranslatePageLanguage(); |
| 110 } | 105 } |
| OLD | NEW |