Mercurial > pidgin
comparison console/libgnt/gntwidget.c @ 14239:a0b1ab181316
[gaim-migrate @ 16921]
Allow remapping keys for widgets.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 20 Aug 2006 22:46:20 +0000 |
parents | ae4cbed1b309 |
children | c111a7e718d0 |
comparison
equal
deleted
inserted
replaced
14238:f189327b9968 | 14239:a0b1ab181316 |
---|---|
94 continue_emission = !signal_handled; | 94 continue_emission = !signal_handled; |
95 | 95 |
96 return continue_emission; | 96 return continue_emission; |
97 } | 97 } |
98 | 98 |
99 | |
100 static void | 99 static void |
101 gnt_widget_class_init(GntWidgetClass *klass) | 100 gnt_widget_class_init(GntWidgetClass *klass) |
102 { | 101 { |
103 GObjectClass *obj_class = G_OBJECT_CLASS(klass); | 102 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
104 | 103 |
212 G_SIGNAL_RUN_LAST, | 211 G_SIGNAL_RUN_LAST, |
213 G_STRUCT_OFFSET(GntWidgetClass, key_pressed), | 212 G_STRUCT_OFFSET(GntWidgetClass, key_pressed), |
214 gnt_boolean_handled_accumulator, NULL, | 213 gnt_boolean_handled_accumulator, NULL, |
215 gnt_closure_marshal_BOOLEAN__STRING, | 214 gnt_closure_marshal_BOOLEAN__STRING, |
216 G_TYPE_BOOLEAN, 1, G_TYPE_STRING); | 215 G_TYPE_BOOLEAN, 1, G_TYPE_STRING); |
216 | |
217 DEBUG; | 217 DEBUG; |
218 } | 218 } |
219 | 219 |
220 /****************************************************************************** | 220 /****************************************************************************** |
221 * GntWidget API | 221 * GntWidget API |
229 static const GTypeInfo info = { | 229 static const GTypeInfo info = { |
230 sizeof(GntWidgetClass), | 230 sizeof(GntWidgetClass), |
231 NULL, /* base_init */ | 231 NULL, /* base_init */ |
232 NULL, /* base_finalize */ | 232 NULL, /* base_finalize */ |
233 (GClassInitFunc)gnt_widget_class_init, | 233 (GClassInitFunc)gnt_widget_class_init, |
234 NULL, /* class_finalize */ | 234 NULL, |
235 NULL, /* class_data */ | 235 NULL, /* class_data */ |
236 sizeof(GntWidget), | 236 sizeof(GntWidget), |
237 0, /* n_preallocs */ | 237 0, /* n_preallocs */ |
238 gnt_widget_init, /* instance_init */ | 238 gnt_widget_init, /* instance_init */ |
239 }; | 239 }; |
242 "GntWidget", | 242 "GntWidget", |
243 &info, G_TYPE_FLAG_ABSTRACT); | 243 &info, G_TYPE_FLAG_ABSTRACT); |
244 } | 244 } |
245 | 245 |
246 return type; | 246 return type; |
247 } | |
248 | |
249 static const char * | |
250 gnt_widget_remap_keys(GntWidget *widget, const char *text) | |
251 { | |
252 const char *remap = NULL; | |
253 GType type = G_OBJECT_TYPE(widget); | |
254 GntWidgetClass *klass = GNT_WIDGET_CLASS(G_OBJECT_GET_CLASS(widget)); | |
255 | |
256 if (klass->remaps == NULL) | |
257 { | |
258 klass->remaps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
259 gnt_styles_get_keyremaps(type, klass->remaps); | |
260 } | |
261 | |
262 remap = g_hash_table_lookup(klass->remaps, text); | |
263 | |
264 return (remap ? remap : text); | |
247 } | 265 } |
248 | 266 |
249 static void | 267 static void |
250 gnt_widget_take_focus(GntWidget *widget) | 268 gnt_widget_take_focus(GntWidget *widget) |
251 { | 269 { |
325 gnt_widget_key_pressed(GntWidget *widget, const char *keys) | 343 gnt_widget_key_pressed(GntWidget *widget, const char *keys) |
326 { | 344 { |
327 gboolean ret; | 345 gboolean ret; |
328 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) | 346 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) |
329 return FALSE; | 347 return FALSE; |
348 | |
349 keys = gnt_widget_remap_keys(widget, keys); | |
330 g_signal_emit(widget, signals[SIG_KEY_PRESSED], 0, keys, &ret); | 350 g_signal_emit(widget, signals[SIG_KEY_PRESSED], 0, keys, &ret); |
331 return ret; | 351 return ret; |
332 } | 352 } |
333 | 353 |
334 void | 354 void |