OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "views/controls/combobox/native_combobox_gtk.h" | 7 #include "views/controls/combobox/native_combobox_gtk.h" |
8 | 8 |
9 #include "app/combobox_model.h" | 9 #include "app/combobox_model.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 g_object_unref(G_OBJECT(store)); | 107 g_object_unref(G_OBJECT(store)); |
108 | 108 |
109 GtkCellRenderer* cell = gtk_cell_renderer_text_new(); | 109 GtkCellRenderer* cell = gtk_cell_renderer_text_new(); |
110 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), cell, TRUE); | 110 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), cell, TRUE); |
111 gtk_cell_layout_set_attributes( | 111 gtk_cell_layout_set_attributes( |
112 GTK_CELL_LAYOUT(widget), cell, "text", 0, NULL); | 112 GTK_CELL_LAYOUT(widget), cell, "text", 0, NULL); |
113 g_signal_connect(G_OBJECT(widget), "changed", | 113 g_signal_connect(G_OBJECT(widget), "changed", |
114 G_CALLBACK(CallChanged), this); | 114 G_CALLBACK(CallChanged), this); |
115 | 115 |
116 NativeControlCreated(widget); | 116 NativeControlCreated(widget); |
| 117 } |
| 118 |
| 119 void NativeComboboxGtk::NativeControlCreated(GtkWidget* native_control) { |
| 120 NativeControlGtk::NativeControlCreated(native_control); |
117 | 121 |
118 // Set the data from combobox | 122 // Set the data from combobox |
119 UpdateFromModel(); | 123 UpdateFromModel(); |
120 // and show the 1st item by default. | 124 // and show the 1st item by default. |
121 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0); | 125 gtk_combo_box_set_active(GTK_COMBO_BOX(native_control), 0); |
122 } | |
123 | |
124 void NativeComboboxGtk::NativeControlCreated(GtkWidget* native_control) { | |
125 NativeControlGtk::NativeControlCreated(native_control); | |
126 } | 126 } |
127 | 127 |
128 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
129 // NativeComboboxGtk, private: | 129 // NativeComboboxGtk, private: |
130 void NativeComboboxGtk::SelectionChanged() { | 130 void NativeComboboxGtk::SelectionChanged() { |
131 combobox_->SelectionChanged(); | 131 combobox_->SelectionChanged(); |
132 } | 132 } |
133 | 133 |
134 // static | 134 // static |
135 void NativeComboboxGtk::CallChanged(GtkWidget* widget, | 135 void NativeComboboxGtk::CallChanged(GtkWidget* widget, |
136 NativeComboboxGtk* combo) { | 136 NativeComboboxGtk* combo) { |
137 combo->SelectionChanged(); | 137 combo->SelectionChanged(); |
138 } | 138 } |
139 | 139 |
140 //////////////////////////////////////////////////////////////////////////////// | 140 //////////////////////////////////////////////////////////////////////////////// |
141 // NativeComboboxWrapper, public: | 141 // NativeComboboxWrapper, public: |
142 | 142 |
143 // static | 143 // static |
144 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 144 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
145 Combobox* combobox) { | 145 Combobox* combobox) { |
146 return new NativeComboboxGtk(combobox); | 146 return new NativeComboboxGtk(combobox); |
147 } | 147 } |
148 | 148 |
149 } // namespace views | 149 } // namespace views |
OLD | NEW |