| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_infobar_base_gtk.h" | 5 #include "chrome/browser/gtk/translate/translate_infobar_base_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/slide_animation.h" | 8 #include "app/slide_animation.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/translate/options_menu_model.h" | 10 #include "chrome/browser/translate/options_menu_model.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (!gtk_combo_box_get_active_iter(combo, &iter)) | 172 if (!gtk_combo_box_get_active_iter(combo, &iter)) |
| 173 return 0; | 173 return 0; |
| 174 | 174 |
| 175 gint id = 0; | 175 gint id = 0; |
| 176 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, | 176 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, |
| 177 LANGUAGE_COMBO_COLUMN_ID, &id, | 177 LANGUAGE_COMBO_COLUMN_ID, &id, |
| 178 -1); | 178 -1); |
| 179 return id; | 179 return id; |
| 180 } | 180 } |
| 181 | 181 |
| 182 TranslateInfoBarDelegate* TranslateInfoBarBase::GetDelegate() const { | |
| 183 return static_cast<TranslateInfoBarDelegate*>(delegate()); | |
| 184 } | |
| 185 | |
| 186 // static | 182 // static |
| 187 GtkWidget* TranslateInfoBarBase::BuildOptionsMenuButton() { | 183 GtkWidget* TranslateInfoBarBase::BuildOptionsMenuButton() { |
| 188 GtkWidget* button = gtk_button_new(); | 184 GtkWidget* button = gtk_button_new(); |
| 189 GtkWidget* former_child = gtk_bin_get_child(GTK_BIN(button)); | 185 GtkWidget* former_child = gtk_bin_get_child(GTK_BIN(button)); |
| 190 if (former_child) | 186 if (former_child) |
| 191 gtk_container_remove(GTK_CONTAINER(button), former_child); | 187 gtk_container_remove(GTK_CONTAINER(button), former_child); |
| 192 | 188 |
| 193 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); | 189 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); |
| 194 | 190 |
| 195 GtkWidget* label = gtk_label_new( | 191 GtkWidget* label = gtk_label_new( |
| 196 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS).c_str()); | 192 l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS).c_str()); |
| 197 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 193 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
| 198 | 194 |
| 199 GtkWidget* arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); | 195 GtkWidget* arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); |
| 200 gtk_box_pack_start(GTK_BOX(hbox), arrow, FALSE, FALSE, 0); | 196 gtk_box_pack_start(GTK_BOX(hbox), arrow, FALSE, FALSE, 0); |
| 201 | 197 |
| 202 gtk_container_add(GTK_CONTAINER(button), hbox); | 198 gtk_container_add(GTK_CONTAINER(button), hbox); |
| 203 | 199 |
| 204 return button; | 200 return button; |
| 205 } | 201 } |
| 206 | 202 |
| 207 void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { | 203 void TranslateInfoBarBase::OnOptionsClicked(GtkWidget* sender) { |
| 204 if (!delegate()) |
| 205 return; |
| 208 if (!options_menu_model_.get()) { | 206 if (!options_menu_model_.get()) { |
| 209 options_menu_model_.reset(new OptionsMenuModel(GetDelegate())); | 207 options_menu_model_.reset(new OptionsMenuModel(GetDelegate())); |
| 210 options_menu_menu_.reset(new MenuGtk(NULL, options_menu_model_.get())); | 208 options_menu_menu_.reset(new MenuGtk(NULL, options_menu_model_.get())); |
| 211 } | 209 } |
| 212 options_menu_menu_->Popup(sender, 1, gtk_get_current_event_time()); | 210 options_menu_menu_->Popup(sender, 1, gtk_get_current_event_time()); |
| 213 } | 211 } |
| 214 | 212 |
| 215 // TranslateInfoBarDelegate specific method: | 213 // TranslateInfoBarDelegate specific method: |
| 216 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { | 214 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { |
| 217 TranslateInfoBarBase* infobar = NULL; | 215 TranslateInfoBarBase* infobar = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 228 break; | 226 break; |
| 229 default: | 227 default: |
| 230 NOTREACHED(); | 228 NOTREACHED(); |
| 231 } | 229 } |
| 232 infobar->Init(); | 230 infobar->Init(); |
| 233 // Set |infobar_view_| so that the model can notify the infobar when it | 231 // Set |infobar_view_| so that the model can notify the infobar when it |
| 234 // changes. | 232 // changes. |
| 235 infobar_view_ = infobar; | 233 infobar_view_ = infobar; |
| 236 return infobar; | 234 return infobar; |
| 237 } | 235 } |
| OLD | NEW |