wacom: Update files from g-s-d

More stylus metadata exported.
This commit is contained in:
Bastien Nocera 2012-01-16 16:07:08 +00:00
parent a771f350d6
commit 5d680981de
2 changed files with 87 additions and 5 deletions

View file

@ -54,6 +54,8 @@ struct GsdWacomStylusPrivate
char *name;
const char *icon_name;
GSettings *settings;
gboolean has_eraser;
int num_buttons;
};
static void gsd_wacom_stylus_class_init (GsdWacomStylusClass *klass);
@ -109,6 +111,9 @@ get_icon_name_from_type (WacomStylusType type)
{
switch (type) {
case WSTYLUS_INKING:
case WSTYLUS_STROKE:
/* The stroke pen is the same as the inking pen with
* a different nib */
return "wacom-stylus-inking";
case WSTYLUS_AIRBRUSH:
return "wacom-stylus-airbrush";
@ -135,6 +140,8 @@ gsd_wacom_stylus_new (GsdWacomDevice *device,
stylus->priv->settings = settings;
stylus->priv->type = libwacom_stylus_get_type (wstylus);
stylus->priv->icon_name = get_icon_name_from_type (stylus->priv->type);
stylus->priv->has_eraser = libwacom_stylus_has_eraser (wstylus);
stylus->priv->num_buttons = libwacom_stylus_get_num_buttons (wstylus);
return stylus;
}
@ -171,6 +178,49 @@ gsd_wacom_stylus_get_device (GsdWacomStylus *stylus)
return stylus->priv->device;
}
gboolean
gsd_wacom_stylus_get_has_eraser (GsdWacomStylus *stylus)
{
g_return_val_if_fail (GSD_IS_WACOM_STYLUS (stylus), FALSE);
return stylus->priv->has_eraser;
}
int
gsd_wacom_stylus_get_num_buttons (GsdWacomStylus *stylus)
{
g_return_val_if_fail (GSD_IS_WACOM_STYLUS (stylus), -1);
return stylus->priv->num_buttons;
}
GsdWacomStylusType
gsd_wacom_stylus_get_stylus_type (GsdWacomStylus *stylus)
{
g_return_val_if_fail (GSD_IS_WACOM_STYLUS (stylus), WACOM_STYLUS_TYPE_UNKNOWN);
switch (stylus->priv->type) {
case WSTYLUS_UNKNOWN:
return WACOM_STYLUS_TYPE_UNKNOWN;
case WSTYLUS_GENERAL:
return WACOM_STYLUS_TYPE_GENERAL;
case WSTYLUS_INKING:
return WACOM_STYLUS_TYPE_INKING;
case WSTYLUS_AIRBRUSH:
return WACOM_STYLUS_TYPE_AIRBRUSH;
case WSTYLUS_CLASSIC:
return WACOM_STYLUS_TYPE_CLASSIC;
case WSTYLUS_MARKER:
return WACOM_STYLUS_TYPE_MARKER;
case WSTYLUS_STROKE:
return WACOM_STYLUS_TYPE_STROKE;
default:
g_assert_not_reached ();
}
return WACOM_STYLUS_TYPE_UNKNOWN;
}
#define GSD_WACOM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_WACOM_DEVICE, GsdWacomDevicePrivate))
/* we support two types of settings:
@ -644,6 +694,23 @@ gsd_wacom_device_list_styli (GsdWacomDevice *device)
return g_list_copy (device->priv->styli);
}
GsdWacomStylus *
gsd_wacom_device_get_stylus_for_type (GsdWacomDevice *device,
GsdWacomStylusType type)
{
GList *l;
g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), NULL);
for (l = device->priv->styli; l != NULL; l = l->next) {
GsdWacomStylus *stylus = l->data;
if (gsd_wacom_stylus_get_stylus_type (stylus) == type)
return stylus;
}
return NULL;
}
const char *
gsd_wacom_device_get_name (GsdWacomDevice *device)
{

View file

@ -66,11 +66,24 @@ typedef struct
GObjectClass parent_class;
} GsdWacomStylusClass;
typedef enum {
WACOM_STYLUS_TYPE_UNKNOWN,
WACOM_STYLUS_TYPE_GENERAL,
WACOM_STYLUS_TYPE_INKING,
WACOM_STYLUS_TYPE_AIRBRUSH,
WACOM_STYLUS_TYPE_CLASSIC,
WACOM_STYLUS_TYPE_MARKER,
WACOM_STYLUS_TYPE_STROKE
} GsdWacomStylusType;
GType gsd_wacom_stylus_get_type (void);
GSettings * gsd_wacom_stylus_get_settings (GsdWacomStylus *stylus);
const char * gsd_wacom_stylus_get_name (GsdWacomStylus *stylus);
const char * gsd_wacom_stylus_get_icon_name(GsdWacomStylus *stylus);
const char * gsd_wacom_stylus_get_icon_name (GsdWacomStylus *stylus);
GsdWacomDevice * gsd_wacom_stylus_get_device (GsdWacomStylus *stylus);
gboolean gsd_wacom_stylus_get_has_eraser (GsdWacomStylus *stylus);
int gsd_wacom_stylus_get_num_buttons(GsdWacomStylus *stylus);
GsdWacomStylusType gsd_wacom_stylus_get_stylus_type (GsdWacomStylus *stylus);
/* Device types to apply a setting to */
typedef enum {
@ -94,6 +107,8 @@ gboolean gsd_wacom_device_is_screen_tablet (GsdWacomDevice *device);
GSettings * gsd_wacom_device_get_settings (GsdWacomDevice *device);
void gsd_wacom_device_set_current_stylus (GsdWacomDevice *device,
int stylus_id);
GsdWacomStylus * gsd_wacom_device_get_stylus_for_type (GsdWacomDevice *device,
GsdWacomStylusType type);
GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
gint * gsd_wacom_device_get_area (GsdWacomDevice *device);