Commit 54880091 authored by Matthias Clasen's avatar Matthias Clasen Committed by Carlos Garnacho

Add more getters for event fields

parent c7431f46
......@@ -1412,6 +1412,69 @@ gdk_event_get_keycode (const GdkEvent *event,
return fetched;
}
gboolean
gdk_event_get_key_group (const GdkEvent *event,
guint *group)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*group = event->key.group;
break;
default:
*group = 0;
fetched = FALSE;
break;
}
return fetched;
}
gboolean
gdk_event_get_string (const GdkEvent *event,
const char **string)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*string = event->key.string;
break;
default:
*string = NULL;
fetched = FALSE;
break;
}
return fetched;
}
gboolean
gdk_event_get_key_is_modifier (const GdkEvent *event,
gboolean *is_modifier)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*is_modifier = event->key.is_modifier;
break;
default:
*is_modifier = FALSE;
fetched = FALSE;
break;
}
return fetched;
}
/**
* gdk_event_get_scroll_direction:
* @event: a #GdkEvent
......@@ -2605,3 +2668,122 @@ gdk_event_get_user_data (const GdkEvent *event)
private = (GdkEventPrivate *) event;
return private->user_data;
}
gboolean
gdk_event_get_setting (const GdkEvent *event,
const char **setting)
{
if (event && event->type == GDK_SETTING)
{
*setting = event->setting.name;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_is_sent (const GdkEvent *event)
{
if (!event)
return FALSE;
return event->any.send_event;
}
gboolean
gdk_event_get_drag_context (const GdkEvent *event,
GdkDragContext **context)
{
if (!event)
return FALSE;
if (event->type == GDK_DRAG_ENTER ||
event->type == GDK_DRAG_LEAVE ||
event->type == GDK_DRAG_MOTION ||
event->type == GDK_DRAG_STATUS ||
event->type == GDK_DROP_START ||
event->type == GDK_DROP_FINISHED)
{
*context = event->dnd.context;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_crossing_mode (const GdkEvent *event,
GdkCrossingMode *mode)
{
if (!event)
return FALSE;
if (event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY)
{
*mode = event->crossing.mode;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_crossing_detail (const GdkEvent *event,
GdkNotifyType *detail)
{
if (!event)
return FALSE;
if (event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY)
{
*detail = event->crossing.detail;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_touchpad_gesture_phase (const GdkEvent *event,
GdkTouchpadGesturePhase *phase)
{
if (!event)
return FALSE;
if (event->type == GDK_TOUCHPAD_PINCH)
{
*phase = event->touchpad_pinch.phase;
return TRUE;
}
else if (event->type == GDK_TOUCHPAD_SWIPE)
{
*phase = event->touchpad_swipe.phase;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_touchpad_gesture_n_fingers (const GdkEvent *event,
guint *n_fingers)
{
if (!event)
return FALSE;
if (event->type == GDK_TOUCHPAD_PINCH)
{
*n_fingers = event->touchpad_pinch.n_fingers;
return TRUE;
}
else if (event->type == GDK_TOUCHPAD_SWIPE)
{
*n_fingers = event->touchpad_swipe.n_fingers;
return TRUE;
}
return FALSE;
}
......@@ -639,6 +639,16 @@ gboolean gdk_event_get_keyval (const GdkEvent *event,
GDK_AVAILABLE_IN_3_2
gboolean gdk_event_get_keycode (const GdkEvent *event,
guint16 *keycode);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
gboolean *is_modifier);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_key_group (const GdkEvent *event,
guint *group);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_string (const GdkEvent *event,
const char **string);
GDK_AVAILABLE_IN_3_2
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
GdkScrollDirection *direction);
......@@ -729,6 +739,30 @@ GDK_AVAILABLE_IN_3_92
void gdk_event_set_user_data (GdkEvent *event,
GObject *user_data);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_setting (const GdkEvent *event,
const char **setting);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_is_sent (const GdkEvent *event);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_drag_context (const GdkEvent *event,
GdkDragContext **context);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_crossing_mode (const GdkEvent *event,
GdkCrossingMode *mode);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_crossing_detail (const GdkEvent *event,
GdkNotifyType *detail);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_touchpad_gesture_phase (const GdkEvent *event,
GdkTouchpadGesturePhase *phase);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_touchpad_gesture_n_fingers(const GdkEvent *event,
guint *n_fingers);
G_END_DECLS
#endif /* __GDK_EVENTS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment