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

Unified Diff: chrome/browser/app_modal_dialog_gtk.cc

Issue 100124: Implement a couple more methods for dialog boxes. (Closed)
Patch Set: comments Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_modal_dialog_gtk.cc
diff --git a/chrome/browser/app_modal_dialog_gtk.cc b/chrome/browser/app_modal_dialog_gtk.cc
index 2f9337dffa2228b414c4dd3b449960802f77aff4..02ce7c3279296910839b9b2b3a76f5e8701a1d73 100644
--- a/chrome/browser/app_modal_dialog_gtk.cc
+++ b/chrome/browser/app_modal_dialog_gtk.cc
@@ -16,13 +16,27 @@
namespace {
+// If there's a text entry in the dialog, get the text from the first one and
+// return it.
+std::wstring GetPromptText(GtkDialog* dialog) {
+ // TODO(tc): Replace with gtk_dialog_get_content_area() when using GTK 2.14+
+ GtkWidget* contents_vbox = dialog->vbox;
+ GList* first_child = gtk_container_get_children(GTK_CONTAINER(contents_vbox));
+ for (GList* item = first_child; item; g_list_next(item)) {
+ if (GTK_IS_ENTRY(item->data)) {
+ return UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(item->data)));
+ }
+ }
+ return std::wstring();
+}
+
void OnDialogResponse(GtkDialog* dialog, gint response_id,
AppModalDialog* app_modal_dialog) {
switch (response_id) {
case GTK_RESPONSE_OK:
// The first arg is the prompt text and the second is true if we want to
// suppress additional popups from the page.
- app_modal_dialog->OnAccept(std::wstring(), false);
+ app_modal_dialog->OnAccept(GetPromptText(dialog), false);
break;
case GTK_RESPONSE_CANCEL:
@@ -63,13 +77,7 @@ void AppModalDialog::CreateAndShowDialog() {
break;
case MessageBoxFlags::kIsJavascriptPrompt:
- // We need to make a custom message box for javascript prompts. For now
- // just have an OK button and send back an empty string. Maybe we can
- // cram a GtkEntry into the content area of the message box via
- // gtk_dialog_get_content_area.
- // http://crbug.com/9623
- NOTIMPLEMENTED();
- buttons = GTK_BUTTONS_OK;
+ buttons = GTK_BUTTONS_OK_CANCEL;
message_type = GTK_MESSAGE_QUESTION;
break;
@@ -92,6 +100,14 @@ void AppModalDialog::CreateAndShowDialog() {
IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL);
gtk_dialog_add_button(GTK_DIALOG(dialog_), button_text.c_str(),
GTK_RESPONSE_CANCEL);
+ } else if (MessageBoxFlags::kIsJavascriptPrompt == dialog_flags_) {
+ // TODO(tc): Replace with gtk_dialog_get_content_area() when using GTK 2.14+
+ GtkWidget* contents_vbox = GTK_DIALOG(dialog_)->vbox;
+ GtkWidget* text_box = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(text_box),
+ WideToUTF8(default_prompt_text_).c_str());
+ gtk_widget_show(text_box);
+ gtk_box_pack_start(GTK_BOX(contents_vbox), text_box, TRUE, TRUE, 0);
}
g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponse), this);
@@ -99,11 +115,11 @@ void AppModalDialog::CreateAndShowDialog() {
}
void AppModalDialog::ActivateModalDialog() {
- NOTIMPLEMENTED();
+ gtk_window_present(GTK_WINDOW(dialog_));
}
void AppModalDialog::CloseModalDialog() {
- NOTIMPLEMENTED();
+ OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT, this);
}
int AppModalDialog::GetDialogButtons() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698