| 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/js_modal_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/js_modal_dialog_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 UTF16ToUTF8(dialog_->message_text()).c_str()); | 90 UTF16ToUTF8(dialog_->message_text()).c_str()); |
| 91 g_signal_connect(gtk_dialog_, "delete-event", | 91 g_signal_connect(gtk_dialog_, "delete-event", |
| 92 G_CALLBACK(gtk_widget_hide_on_delete), NULL); | 92 G_CALLBACK(gtk_widget_hide_on_delete), NULL); |
| 93 gtk_util::ApplyMessageDialogQuirks(gtk_dialog_); | 93 gtk_util::ApplyMessageDialogQuirks(gtk_dialog_); |
| 94 gtk_window_set_title(GTK_WINDOW(gtk_dialog_), | 94 gtk_window_set_title(GTK_WINDOW(gtk_dialog_), |
| 95 UTF16ToUTF8(dialog_->title()).c_str()); | 95 UTF16ToUTF8(dialog_->title()).c_str()); |
| 96 | 96 |
| 97 // Adjust content area as needed. Set up the prompt text entry or | 97 // Adjust content area as needed. Set up the prompt text entry or |
| 98 // suppression check box. | 98 // suppression check box. |
| 99 if (ui::MessageBoxFlags::kIsJavascriptPrompt == dialog_->dialog_flags()) { | 99 if (ui::MessageBoxFlags::kIsJavascriptPrompt == dialog_->dialog_flags()) { |
| 100 // TODO(tc): Replace with gtk_dialog_get_content_area() when using GTK 2.14+ | 100 GtkWidget* content_area = |
| 101 GtkWidget* contents_vbox = GTK_DIALOG(gtk_dialog_)->vbox; | 101 gtk_dialog_get_content_area(GTK_DIALOG(gtk_dialog_)); |
| 102 GtkWidget* text_box = gtk_entry_new(); | 102 GtkWidget* text_box = gtk_entry_new(); |
| 103 gtk_entry_set_text(GTK_ENTRY(text_box), | 103 gtk_entry_set_text(GTK_ENTRY(text_box), |
| 104 UTF16ToUTF8(dialog_->default_prompt_text()).c_str()); | 104 UTF16ToUTF8(dialog_->default_prompt_text()).c_str()); |
| 105 gtk_box_pack_start(GTK_BOX(contents_vbox), text_box, TRUE, TRUE, 0); | 105 gtk_box_pack_start(GTK_BOX(content_area), text_box, TRUE, TRUE, 0); |
| 106 g_object_set_data(G_OBJECT(gtk_dialog_), kPromptTextId, text_box); | 106 g_object_set_data(G_OBJECT(gtk_dialog_), kPromptTextId, text_box); |
| 107 gtk_entry_set_activates_default(GTK_ENTRY(text_box), TRUE); | 107 gtk_entry_set_activates_default(GTK_ENTRY(text_box), TRUE); |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (dialog_->display_suppress_checkbox()) { | 110 if (dialog_->display_suppress_checkbox()) { |
| 111 GtkWidget* contents_vbox = GTK_DIALOG(gtk_dialog_)->vbox; | 111 GtkWidget* content_area = |
| 112 gtk_dialog_get_content_area(GTK_DIALOG(gtk_dialog_)); |
| 112 GtkWidget* check_box = gtk_check_button_new_with_label( | 113 GtkWidget* check_box = gtk_check_button_new_with_label( |
| 113 l10n_util::GetStringUTF8( | 114 l10n_util::GetStringUTF8( |
| 114 IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION).c_str()); | 115 IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION).c_str()); |
| 115 gtk_box_pack_start(GTK_BOX(contents_vbox), check_box, TRUE, TRUE, 0); | 116 gtk_box_pack_start(GTK_BOX(content_area), check_box, TRUE, TRUE, 0); |
| 116 g_object_set_data(G_OBJECT(gtk_dialog_), kSuppressCheckboxId, check_box); | 117 g_object_set_data(G_OBJECT(gtk_dialog_), kSuppressCheckboxId, check_box); |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Adjust buttons/action area as needed. | 120 // Adjust buttons/action area as needed. |
| 120 if (dialog_->is_before_unload_dialog()) { | 121 if (dialog_->is_before_unload_dialog()) { |
| 121 std::string button_text = l10n_util::GetStringUTF8( | 122 std::string button_text = l10n_util::GetStringUTF8( |
| 122 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); | 123 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); |
| 123 gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_), button_text.c_str(), | 124 gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_), button_text.c_str(), |
| 124 GTK_RESPONSE_OK); | 125 GTK_RESPONSE_OK); |
| 125 | 126 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 //////////////////////////////////////////////////////////////////////////////// | 218 //////////////////////////////////////////////////////////////////////////////// |
| 218 // NativeAppModalDialog, public: | 219 // NativeAppModalDialog, public: |
| 219 | 220 |
| 220 // static | 221 // static |
| 221 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | 222 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( |
| 222 JavaScriptAppModalDialog* dialog, | 223 JavaScriptAppModalDialog* dialog, |
| 223 gfx::NativeWindow parent_window) { | 224 gfx::NativeWindow parent_window) { |
| 224 return new JSModalDialogGtk(dialog, parent_window); | 225 return new JSModalDialogGtk(dialog, parent_window); |
| 225 } | 226 } |
| OLD | NEW |