| 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/input_window_dialog_gtk.h" | 5 #include "chrome/browser/ui/input_window_dialog_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Under the model that we've inherited from Windows, dialogs can receive | 66 // Under the model that we've inherited from Windows, dialogs can receive |
| 67 // more than one Close() call inside the current message loop event. | 67 // more than one Close() call inside the current message loop event. |
| 68 if (dialog_) { | 68 if (dialog_) { |
| 69 gtk_widget_destroy(dialog_); | 69 gtk_widget_destroy(dialog_); |
| 70 dialog_ = NULL; | 70 dialog_ = NULL; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void InputWindowDialogGtk::OnEntryChanged(GtkEditable* entry) { | 74 void InputWindowDialogGtk::OnEntryChanged(GtkEditable* entry) { |
| 75 string16 value(UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(entry)))); | 75 string16 value(UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(entry)))); |
| 76 InputWindowDialog::InputTexts texts; |
| 77 texts.push_back(value); |
| 76 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog_), | 78 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog_), |
| 77 GTK_RESPONSE_ACCEPT, | 79 GTK_RESPONSE_ACCEPT, |
| 78 delegate_->IsValid(value)); | 80 delegate_->IsValid(texts)); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void InputWindowDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { | 83 void InputWindowDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { |
| 82 if (response_id == GTK_RESPONSE_ACCEPT) { | 84 if (response_id == GTK_RESPONSE_ACCEPT) { |
| 83 string16 value(UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(input_)))); | 85 string16 value(UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(input_)))); |
| 84 delegate_->InputAccepted(value); | 86 InputTexts texts; |
| 87 texts.push_back(value); |
| 88 delegate_->InputAccepted(texts); |
| 85 } else { | 89 } else { |
| 86 delegate_->InputCanceled(); | 90 delegate_->InputCanceled(); |
| 87 } | 91 } |
| 88 Close(); | 92 Close(); |
| 89 } | 93 } |
| 90 | 94 |
| 91 gboolean InputWindowDialogGtk::OnWindowDeleteEvent(GtkWidget* widget, | 95 gboolean InputWindowDialogGtk::OnWindowDeleteEvent(GtkWidget* widget, |
| 92 GdkEvent* event) { | 96 GdkEvent* event) { |
| 93 Close(); | 97 Close(); |
| 94 | 98 |
| 95 // Return true to prevent the gtk dialog from being destroyed. Close will | 99 // Return true to prevent the gtk dialog from being destroyed. Close will |
| 96 // destroy it for us and the default gtk_dialog_delete_event_handler() will | 100 // destroy it for us and the default gtk_dialog_delete_event_handler() will |
| 97 // force the destruction without us being able to stop it. | 101 // force the destruction without us being able to stop it. |
| 98 return TRUE; | 102 return TRUE; |
| 99 } | 103 } |
| 100 | 104 |
| 101 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { | 105 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { |
| 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 106 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 103 } | 107 } |
| OLD | NEW |