Mercurial > pidgin
comparison finch/libgnt/gntcombobox.c @ 30194:6943aec8cf61
Allow rebinding the key to show the dropdown menu for comboboxes.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 15 Jun 2010 17:12:48 +0000 |
parents | a18f421696dc |
children | 658e8b9522bc |
comparison
equal
deleted
inserted
replaced
30193:b3c4f33643a6 | 30194:6943aec8cf61 |
---|---|
23 #include "gntinternal.h" | 23 #include "gntinternal.h" |
24 #include "gntbox.h" | 24 #include "gntbox.h" |
25 #include "gntcombobox.h" | 25 #include "gntcombobox.h" |
26 #include "gnttree.h" | 26 #include "gnttree.h" |
27 #include "gntmarshal.h" | 27 #include "gntmarshal.h" |
28 #include "gntstyle.h" | |
28 #include "gntutils.h" | 29 #include "gntutils.h" |
29 | 30 |
30 #include <string.h> | 31 #include <string.h> |
31 | 32 |
32 enum | 33 enum |
166 } | 167 } |
167 } | 168 } |
168 if (gnt_widget_key_pressed(box->dropdown, text)) | 169 if (gnt_widget_key_pressed(box->dropdown, text)) |
169 return TRUE; | 170 return TRUE; |
170 } | 171 } |
171 else | |
172 { | |
173 if (text[0] == 27) | |
174 { | |
175 if (strcmp(text, GNT_KEY_UP) == 0 || | |
176 strcmp(text, GNT_KEY_DOWN) == 0) | |
177 { | |
178 popup_dropdown(box); | |
179 return TRUE; | |
180 } | |
181 } | |
182 } | |
183 | 172 |
184 return FALSE; | 173 return FALSE; |
185 } | 174 } |
186 | 175 |
187 static void | 176 static void |
227 { | 216 { |
228 GntComboBox *box = GNT_COMBO_BOX(widget); | 217 GntComboBox *box = GNT_COMBO_BOX(widget); |
229 gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height); | 218 gnt_widget_set_size(box->dropdown, widget->priv.width - 1, box->dropdown->priv.height); |
230 } | 219 } |
231 | 220 |
221 static gboolean | |
222 dropdown_menu(GntBindable *b, GList *null) | |
223 { | |
224 if (GNT_WIDGET_IS_FLAG_SET(GNT_COMBO_BOX(b)->dropdown->parent, GNT_WIDGET_MAPPED)) | |
225 return FALSE; | |
226 popup_dropdown(GNT_COMBO_BOX(b)); | |
227 return TRUE; | |
228 } | |
229 | |
232 static void | 230 static void |
233 gnt_combo_box_class_init(GntComboBoxClass *klass) | 231 gnt_combo_box_class_init(GntComboBoxClass *klass) |
234 { | 232 { |
233 GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); | |
234 | |
235 parent_class = GNT_WIDGET_CLASS(klass); | 235 parent_class = GNT_WIDGET_CLASS(klass); |
236 | 236 |
237 parent_class->destroy = gnt_combo_box_destroy; | 237 parent_class->destroy = gnt_combo_box_destroy; |
238 parent_class->draw = gnt_combo_box_draw; | 238 parent_class->draw = gnt_combo_box_draw; |
239 parent_class->map = gnt_combo_box_map; | 239 parent_class->map = gnt_combo_box_map; |
243 parent_class->size_changed = gnt_combo_box_size_changed; | 243 parent_class->size_changed = gnt_combo_box_size_changed; |
244 | 244 |
245 widget_lost_focus = parent_class->lost_focus; | 245 widget_lost_focus = parent_class->lost_focus; |
246 parent_class->lost_focus = gnt_combo_box_lost_focus; | 246 parent_class->lost_focus = gnt_combo_box_lost_focus; |
247 | 247 |
248 signals[SIG_SELECTION_CHANGED] = | 248 signals[SIG_SELECTION_CHANGED] = |
249 g_signal_new("selection-changed", | 249 g_signal_new("selection-changed", |
250 G_TYPE_FROM_CLASS(klass), | 250 G_TYPE_FROM_CLASS(klass), |
251 G_SIGNAL_RUN_LAST, | 251 G_SIGNAL_RUN_LAST, |
252 0, | 252 0, |
253 NULL, NULL, | 253 NULL, NULL, |
254 gnt_closure_marshal_VOID__POINTER_POINTER, | 254 gnt_closure_marshal_VOID__POINTER_POINTER, |
255 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); | 255 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); |
256 | 256 |
257 gnt_bindable_class_register_action(bindable, "dropdown", dropdown_menu, | |
258 GNT_KEY_DOWN, NULL); | |
259 gnt_bindable_register_binding(bindable, "dropdown", GNT_KEY_UP, NULL); | |
260 | |
261 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); | |
262 | |
257 GNTDEBUG; | 263 GNTDEBUG; |
258 } | 264 } |
259 | 265 |
260 static void | 266 static void |
261 gnt_combo_box_init(GTypeInstance *instance, gpointer class) | 267 gnt_combo_box_init(GTypeInstance *instance, gpointer class) |
270 | 276 |
271 box = gnt_box_new(FALSE, FALSE); | 277 box = gnt_box_new(FALSE, FALSE); |
272 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT); | 278 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | GNT_WIDGET_TRANSIENT); |
273 gnt_box_set_pad(GNT_BOX(box), 0); | 279 gnt_box_set_pad(GNT_BOX(box), 0); |
274 gnt_box_add_widget(GNT_BOX(box), combo->dropdown); | 280 gnt_box_add_widget(GNT_BOX(box), combo->dropdown); |
275 | 281 |
276 widget->priv.minw = 4; | 282 widget->priv.minw = 4; |
277 widget->priv.minh = 3; | 283 widget->priv.minh = 3; |
278 GNTDEBUG; | 284 GNTDEBUG; |
279 } | 285 } |
280 | 286 |