device: Add the :name property to InputDevice

The InputDevice should have a name, possibly user readable, coming from
the backend.
This commit is contained in:
Emmanuele Bassi 2010-01-15 11:37:43 +00:00
parent 79ad2b6a72
commit cf4e05930a
3 changed files with 57 additions and 4 deletions

View File

@ -45,7 +45,8 @@ enum
PROP_0,
PROP_ID,
PROP_DEVICE_TYPE
PROP_DEVICE_TYPE,
PROP_NAME
};
G_DEFINE_TYPE (ClutterInputDevice, clutter_input_device, G_TYPE_OBJECT);
@ -68,6 +69,10 @@ clutter_input_device_set_property (GObject *gobject,
self->device_type = g_value_get_enum (value);
break;
case PROP_NAME:
self->device_name = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@ -92,6 +97,10 @@ clutter_input_device_get_property (GObject *gobject,
g_value_set_enum (value, self->device_type);
break;
case PROP_NAME:
g_value_set_string (value, self->device_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@ -123,6 +132,21 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (gobject_class, PROP_ID, pspec);
/**
* ClutterInputDevice:name:
*
* The name of the device
*
* Since: 1.2
*/
pspec = g_param_spec_string ("name",
"Name",
"The name of the device",
NULL,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (gobject_class, PROP_NAME, pspec);
/**
* ClutterInputDevice:device-type:
*
@ -478,3 +502,23 @@ clutter_input_device_get_pointer_actor (ClutterInputDevice *device)
return device->cursor_actor;
}
/**
* clutter_input_device_get_device_name:
* @device: a #ClutterInputDevice
*
* Retrieves the name of the @device
*
* Return value: the name of the device, or %NULL. The returned string
* is owned by the #ClutterInputDevice and should never be modified
* or freed
*
* Since: 1.2
*/
G_CONST_RETURN gchar *
clutter_input_device_get_device_name (ClutterInputDevice *device)
{
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
return device->device_name;
}

View File

@ -42,9 +42,8 @@ G_BEGIN_DECLS
/**
* ClutterInputDevice:
*
* Generic representation of an input device. The
* actual contents of this structure depend on the
* backend used.
* Generic representation of an input device. The actual contents of this
* structure depend on the backend used.
*/
typedef struct _ClutterInputDevice ClutterInputDevice;
typedef struct _ClutterInputDeviceClass ClutterInputDeviceClass;
@ -93,6 +92,7 @@ void clutter_input_device_get_device_coords (ClutterInputDevic
gint *x,
gint *y);
ClutterActor * clutter_input_device_get_pointer_actor (ClutterInputDevice *device);
G_CONST_RETURN gchar * clutter_input_device_get_device_name (ClutterInputDevice *device);
G_END_DECLS

View File

@ -91,19 +91,28 @@ struct _ClutterInputDevice
ClutterInputDeviceType device_type;
gchar *device_name;
/* the actor underneath the pointer */
ClutterActor *cursor_actor;
/* the actor that has a grab in place for the device */
ClutterActor *pointer_grab_actor;
/* the current click count */
gint click_count;
/* the stage the device is on */
ClutterStage *stage;
/* the current state */
gint current_x;
gint current_y;
guint32 current_time;
gint current_button_number;
ClutterModifierType current_state;
/* the previous state, used for click count generation */
gint previous_x;
gint previous_y;
guint32 previous_time;