clutter: Add ClutterInputDeviceTool:id property

This commit is contained in:
Carlos Garnacho 2016-05-12 17:53:36 +02:00
parent d3be071196
commit be9997c717
2 changed files with 40 additions and 2 deletions

View File

@ -34,12 +34,14 @@ struct _ClutterInputDeviceToolPrivate
{
ClutterInputDeviceToolType type;
guint64 serial;
guint64 id;
};
enum {
PROP_0,
PROP_TYPE,
PROP_SERIAL,
PROP_ID,
PROP_LAST
};
@ -66,6 +68,9 @@ clutter_input_device_tool_set_property (GObject *object,
case PROP_SERIAL:
priv->serial = g_value_get_uint64 (value);
break;
case PROP_ID:
priv->id = g_value_get_uint64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -90,6 +95,9 @@ clutter_input_device_tool_get_property (GObject *object,
case PROP_SERIAL:
g_value_set_uint64 (value, priv->serial);
break;
case PROP_ID:
g_value_set_uint64 (value, priv->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -116,6 +124,12 @@ clutter_input_device_tool_class_init (ClutterInputDeviceToolClass *klass)
P_("Tool serial"),
0, G_MAXUINT64, 0,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
props[PROP_ID] =
g_param_spec_uint64 ("id",
P_("Tool ID"),
P_("Tool ID"),
0, G_MAXUINT64, 0,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (gobject_class, PROP_LAST, props);
}
@ -136,7 +150,7 @@ clutter_input_device_tool_init (ClutterInputDeviceTool *tool)
*
* Since: 1.28
**/
guint
guint64
clutter_input_device_tool_get_serial (ClutterInputDeviceTool *tool)
{
ClutterInputDeviceToolPrivate *priv;
@ -170,3 +184,24 @@ clutter_input_device_tool_get_tool_type (ClutterInputDeviceTool *tool)
return priv->type;
}
/**
* clutter_input_device_tool_get_id:
* @tool: a #ClutterInputDeviceTool
*
* Gets the ID of this tool, this value can be used to identify a
* physical tool (eg. a tablet pen) across program executions.
*
* Returns: The tool ID for this tool
**/
guint64
clutter_input_device_tool_get_id (ClutterInputDeviceTool *tool)
{
ClutterInputDeviceToolPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL (tool), 0);
priv = clutter_input_device_tool_get_instance_private (tool);
return priv->id;
}

View File

@ -56,11 +56,14 @@ CLUTTER_AVAILABLE_IN_ALL
GType clutter_input_device_tool_get_type (void) G_GNUC_CONST;
CLUTTER_AVAILABLE_IN_ALL
guint clutter_input_device_tool_get_serial (ClutterInputDeviceTool *tool);
guint64 clutter_input_device_tool_get_serial (ClutterInputDeviceTool *tool);
CLUTTER_AVAILABLE_IN_ALL
ClutterInputDeviceToolType clutter_input_device_tool_get_tool_type (ClutterInputDeviceTool *tool);
CLUTTER_AVAILABLE_IN_ALL
guint64 clutter_input_device_tool_get_id (ClutterInputDeviceTool *tool);
G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_TOOL_H__ */