introspection-friendly ClutterEvent accessors

ClutterEvent is not really gobject-introspection friendly because
of the whole discriminated union thing. In particular, if you get
a ClutterEvent in a signal handler, you probably can't access the
event-type-specific fields, and you probably can't call methods
like clutter_key_event_symbol() either, because you can't cast the
ClutterEvent to a ClutterKeyEvent.

The cleanest solution is to turn every accessor into ClutterEvent
methods, accepting a ClutterEvent* and internally checking the event
type.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1585
This commit is contained in:
Emmanuele Bassi
2009-06-06 15:27:37 +01:00
parent 04dc4106e5
commit 41e85f3073
11 changed files with 240 additions and 116 deletions

View File

@ -1280,13 +1280,10 @@ clutter_text_key_press (ClutterActor *actor,
ClutterTextPrivate *priv = self->priv;
ClutterBindingPool *pool;
gboolean res;
gint keyval;
if (!priv->editable)
return FALSE;
keyval = clutter_key_event_symbol (event);
/* we need to use the ClutterText type name to find our own
* key bindings; subclasses will override or chain up this
* event handler, so they can do whatever they want there
@ -1297,10 +1294,10 @@ clutter_text_key_press (ClutterActor *actor,
/* we allow passing synthetic events that only contain
* the Unicode value and not the key symbol
*/
if (keyval == 0 && (event->flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
if (event->keyval == 0 && (event->flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
res = FALSE;
else
res = clutter_binding_pool_activate (pool, keyval,
res = clutter_binding_pool_activate (pool, event->keyval,
event->modifier_state,
G_OBJECT (actor));
@ -1313,7 +1310,9 @@ clutter_text_key_press (ClutterActor *actor,
return TRUE;
else
{
gunichar key_unichar = clutter_key_event_unicode (event);
gunichar key_unichar;
key_unichar = clutter_event_get_key_unicode ((ClutterEvent *) event);
/* return is reported as CR, but we want LF */
if (key_unichar == '\r')