| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/app_modal_dialog.h" | 5 #include "chrome/browser/app_modal_dialog.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/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/tab_contents/web_contents.h" | 11 #include "chrome/browser/tab_contents/web_contents.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents_view.h" | 12 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 13 #include "chrome/common/l10n_util.h" | 13 #include "chrome/common/l10n_util.h" |
| 14 #include "chrome/common/message_box_flags.h" | 14 #include "chrome/common/message_box_flags.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // If there's a text entry in the dialog, get the text from the first one and | 19 // If there's a text entry in the dialog, get the text from the first one and |
| 20 // return it. | 20 // return it. |
| 21 std::wstring GetPromptText(GtkDialog* dialog) { | 21 std::wstring GetPromptText(GtkDialog* dialog) { |
| 22 // TODO(tc): Replace with gtk_dialog_get_content_area() when using GTK 2.14+ | 22 // TODO(tc): Replace with gtk_dialog_get_content_area() when using GTK 2.14+ |
| 23 GtkWidget* contents_vbox = dialog->vbox; | 23 GtkWidget* contents_vbox = dialog->vbox; |
| 24 GList* first_child = gtk_container_get_children(GTK_CONTAINER(contents_vbox)); | 24 GList* first_child = gtk_container_get_children(GTK_CONTAINER(contents_vbox)); |
| 25 for (GList* item = first_child; item; g_list_next(item)) { | 25 for (GList* item = first_child; item; item = g_list_next(item)) { |
| 26 if (GTK_IS_ENTRY(item->data)) { | 26 if (GTK_IS_ENTRY(item->data)) { |
| 27 return UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(item->data))); | 27 return UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(item->data))); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 return std::wstring(); | 30 return std::wstring(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void OnDialogResponse(GtkDialog* dialog, gint response_id, | 33 void OnDialogResponse(GtkDialog* dialog, gint response_id, |
| 34 AppModalDialog* app_modal_dialog) { | 34 AppModalDialog* app_modal_dialog) { |
| 35 switch (response_id) { | 35 switch (response_id) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void AppModalDialog::AcceptWindow() { | 143 void AppModalDialog::AcceptWindow() { |
| 144 OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_OK, this); | 144 OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_OK, this); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void AppModalDialog::CancelWindow() { | 147 void AppModalDialog::CancelWindow() { |
| 148 OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_CANCEL, this); | 148 OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_CANCEL, this); |
| 149 } | 149 } |
| OLD | NEW |