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 ButtonType type) |
19 : dialog_(gtk_dialog_new_with_buttons( | 19 : dialog_(gtk_dialog_new_with_buttons( |
20 window_title.c_str(), | 20 window_title.c_str(), |
21 parent, | 21 parent, |
22 GTK_DIALOG_MODAL, | 22 GTK_DIALOG_MODAL, |
23 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | 23 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
24 type == BUTTON_TYPE_ADD ? GTK_STOCK_ADD : GTK_STOCK_SAVE, | 24 type == BUTTON_TYPE_ADD ? GTK_STOCK_ADD : GTK_STOCK_SAVE, |
25 GTK_RESPONSE_ACCEPT, | 25 GTK_RESPONSE_ACCEPT, |
26 NULL)), | 26 NULL)), |
27 delegate_(delegate) { | 27 delegate_(delegate) { |
28 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); | 28 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); |
| 29 #if !GTK_CHECK_VERSION(2, 22, 0) |
29 gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE); | 30 gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE); |
| 31 #endif |
30 gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); | 32 gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE); |
31 | 33 |
32 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); | 34 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
33 gtk_box_set_spacing(GTK_BOX(content_area), 18); | 35 gtk_box_set_spacing(GTK_BOX(content_area), 18); |
34 | 36 |
35 GtkWidget* hbox = gtk_hbox_new(FALSE, 6); | 37 GtkWidget* hbox = gtk_hbox_new(FALSE, 6); |
36 GtkWidget* label_widget = gtk_label_new(label.c_str()); | 38 GtkWidget* label_widget = gtk_label_new(label.c_str()); |
37 gtk_box_pack_start(GTK_BOX(hbox), label_widget, FALSE, FALSE, 0); | 39 gtk_box_pack_start(GTK_BOX(hbox), label_widget, FALSE, FALSE, 0); |
38 | 40 |
39 input_ = gtk_entry_new(); | 41 input_ = gtk_entry_new(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 100 |
99 // Return true to prevent the gtk dialog from being destroyed. Close will | 101 // Return true to prevent the gtk dialog from being destroyed. Close will |
100 // destroy it for us and the default gtk_dialog_delete_event_handler() will | 102 // destroy it for us and the default gtk_dialog_delete_event_handler() will |
101 // force the destruction without us being able to stop it. | 103 // force the destruction without us being able to stop it. |
102 return TRUE; | 104 return TRUE; |
103 } | 105 } |
104 | 106 |
105 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { | 107 void InputWindowDialogGtk::OnWindowDestroy(GtkWidget* widget) { |
106 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 108 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
107 } | 109 } |
OLD | NEW |