Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: chrome/browser/gtk/translate/before_translate_infobar_gtk.cc

Issue 6251001: Move chrome/browser/gtk/ to chrome/browser/ui/gtk/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/gtk/translate/before_translate_infobar_gtk.h"
6
7 #include "app/l10n_util.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/gtk/gtk_util.h"
10 #include "chrome/browser/translate/translate_infobar_delegate.h"
11 #include "grit/generated_resources.h"
12
13 BeforeTranslateInfoBar::BeforeTranslateInfoBar(
14 TranslateInfoBarDelegate* delegate)
15 : TranslateInfoBarBase(delegate) {
16 }
17
18 BeforeTranslateInfoBar::~BeforeTranslateInfoBar() {
19 }
20
21 void BeforeTranslateInfoBar::Init() {
22 TranslateInfoBarBase::Init();
23
24 GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
25 gtk_util::CenterWidgetInHBox(hbox_, hbox, false, 0);
26 size_t offset = 0;
27 string16 text =
28 l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_BEFORE_MESSAGE,
29 string16(), &offset);
30
31 gtk_box_pack_start(GTK_BOX(hbox),
32 CreateLabel(UTF16ToUTF8(text.substr(0, offset))),
33 FALSE, FALSE, 0);
34 GtkWidget* combobox =
35 CreateLanguageCombobox(GetDelegate()->original_language_index(),
36 GetDelegate()->target_language_index());
37 g_signal_connect(combobox, "changed",
38 G_CALLBACK(&OnLanguageModifiedThunk), this);
39 gtk_box_pack_start(GTK_BOX(hbox), combobox, FALSE, FALSE, 0);
40 gtk_box_pack_start(GTK_BOX(hbox),
41 CreateLabel(UTF16ToUTF8(text.substr(offset))),
42 FALSE, FALSE, 0);
43
44 GtkWidget* button = gtk_button_new_with_label(
45 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_ACCEPT).c_str());
46 g_signal_connect(button, "clicked",G_CALLBACK(&OnAcceptPressedThunk), this);
47 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
48
49 button = gtk_button_new_with_label(
50 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_DENY).c_str());
51 g_signal_connect(button, "clicked",G_CALLBACK(&OnDenyPressedThunk), this);
52 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
53
54 TranslateInfoBarDelegate* delegate = GetDelegate();
55 if (delegate->ShouldShowNeverTranslateButton()) {
56 std::string label =
57 l10n_util::GetStringFUTF8(IDS_TRANSLATE_INFOBAR_NEVER_TRANSLATE,
58 delegate->GetLanguageDisplayableNameAt(
59 delegate->original_language_index()));
60 button = gtk_button_new_with_label(label.c_str());
61 g_signal_connect(button, "clicked",
62 G_CALLBACK(&OnNeverTranslatePressedThunk), this);
63 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
64 }
65
66 if (delegate->ShouldShowAlwaysTranslateButton()) {
67 std::string label =
68 l10n_util::GetStringFUTF8(IDS_TRANSLATE_INFOBAR_ALWAYS_TRANSLATE,
69 delegate->GetLanguageDisplayableNameAt(
70 delegate->original_language_index()));
71 button = gtk_button_new_with_label(label.c_str());
72 g_signal_connect(button, "clicked",
73 G_CALLBACK(&OnAlwaysTranslatePressedThunk), this);
74 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
75 }
76 }
77
78 bool BeforeTranslateInfoBar::ShowOptionsMenuButton() const {
79 return true;
80 }
81
82 void BeforeTranslateInfoBar::OnLanguageModified(GtkWidget* sender) {
83 int index = GetLanguageComboboxActiveId(GTK_COMBO_BOX(sender));
84 if (index == GetDelegate()->original_language_index())
85 return;
86
87 GetDelegate()->SetOriginalLanguage(index);
88 }
89
90 void BeforeTranslateInfoBar::OnAcceptPressed(GtkWidget* sender) {
91 GetDelegate()->Translate();
92 }
93
94 void BeforeTranslateInfoBar::OnDenyPressed(GtkWidget* sender) {
95 GetDelegate()->TranslationDeclined();
96 RemoveInfoBar();
97 }
98
99 void BeforeTranslateInfoBar::OnNeverTranslatePressed(GtkWidget* sender) {
100 GetDelegate()->NeverTranslatePageLanguage();
101 }
102
103 void BeforeTranslateInfoBar::OnAlwaysTranslatePressed(GtkWidget* sender) {
104 GetDelegate()->AlwaysTranslatePageLanguage();
105 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/translate/before_translate_infobar_gtk.h ('k') | chrome/browser/gtk/translate/translate_infobar_base_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698