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" |
11 #include "ui/base/gtk/gtk_signal.h" | 11 #include "ui/base/gtk/gtk_signal.h" |
12 | 12 |
13 InputWindowDialogGtk::InputWindowDialogGtk(GtkWindow* parent, | 13 InputWindowDialogGtk::InputWindowDialogGtk(GtkWindow* parent, |
14 const std::string& window_title, | 14 const std::string& window_title, |
15 const std::string& label, | 15 const std::string& label, |
16 const std::string& contents, | 16 const std::string& contents, |
17 Delegate* delegate) | 17 Delegate* delegate, |
| 18 ButtonType type) |
18 : dialog_(gtk_dialog_new_with_buttons( | 19 : dialog_(gtk_dialog_new_with_buttons( |
19 window_title.c_str(), | 20 window_title.c_str(), |
20 parent, | 21 parent, |
21 GTK_DIALOG_MODAL, | 22 GTK_DIALOG_MODAL, |
22 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | 23 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
23 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, | 24 type == BUTTON_TYPE_ADD ? GTK_STOCK_ADD : GTK_STOCK_SAVE, |
| 25 GTK_RESPONSE_ACCEPT, |
24 NULL)), | 26 NULL)), |
25 delegate_(delegate) { | 27 delegate_(delegate) { |
26 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); | 28 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); |
27 gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE); | 29 gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE); |
28 gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); | 30 gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); |
29 | 31 |
30 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); | 32 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
31 gtk_box_set_spacing(GTK_BOX(content_area), 18); | 33 gtk_box_set_spacing(GTK_BOX(content_area), 18); |
32 | 34 |
33 GtkWidget* hbox = gtk_hbox_new(FALSE, 6); | 35 GtkWidget* hbox = gtk_hbox_new(FALSE, 6); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 94 |
93 // Return true to prevent the gtk dialog from being destroyed. Close will | 95 // Return true to prevent the gtk dialog from being destroyed. Close will |
94 // destroy it for us and the default gtk_dialog_delete_event_handler() will | 96 // destroy it for us and the default gtk_dialog_delete_event_handler() will |
95 // force the destruction without us being able to stop it. | 97 // force the destruction without us being able to stop it. |
96 return TRUE; | 98 return TRUE; |
97 } | 99 } |
98 | 100 |
99 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { | 101 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { |
100 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
101 } | 103 } |
OLD | NEW |