diff options
author | David Zeuthen <davidz@redhat.com> | 2010-12-14 12:37:40 -0500 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2010-12-14 12:37:40 -0500 |
commit | 0976fd063e1e488e388ec922fcd4dbed5b8da938 (patch) | |
tree | 54857c8694f9f8aa2eecfffb832226fa39512526 /extras/gudev/gudevdevice.c | |
parent | 48a0170b111b55e961be769d2cc4890511bcd991 (diff) |
Add GUdevEnumerator type and Device.get_tags() method
Also add JS example to check the added API works.
Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'extras/gudev/gudevdevice.c')
-rw-r--r-- | extras/gudev/gudevdevice.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/extras/gudev/gudevdevice.c b/extras/gudev/gudevdevice.c index 76f2d7e5f8..4c41849bb1 100644 --- a/extras/gudev/gudevdevice.c +++ b/extras/gudev/gudevdevice.c @@ -86,6 +86,7 @@ struct _GUdevDevicePrivate /* computed ondemand and cached */ gchar **device_file_symlinks; gchar **property_keys; + gchar **tags; GHashTable *prop_strvs; GHashTable *sysfs_attr_strvs; }; @@ -99,6 +100,7 @@ g_udev_device_finalize (GObject *object) g_strfreev (device->priv->device_file_symlinks); g_strfreev (device->priv->property_keys); + g_strfreev (device->priv->tags); if (device->priv->udevice != NULL) udev_device_unref (device->priv->udevice); @@ -889,3 +891,37 @@ g_udev_device_get_sysfs_attr_as_strv (GUdevDevice *device, out: return (const gchar* const *) result; } + +/** + * g_udev_device_get_tags: + * @device: A #GUdevDevice. + * + * Gets all tags for @device. + * + * Returns: (transfer none) (array zero-terminated=1) (element-type utf8): A %NULL terminated string array of tags. This array is owned by @device and should not be freed by the caller. + * + * Since: 165 + */ +const gchar* const * +g_udev_device_get_tags (GUdevDevice *device) +{ + struct udev_list_entry *l; + GPtrArray *p; + + g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL); + + if (device->priv->tags != NULL) + goto out; + + p = g_ptr_array_new (); + for (l = udev_device_get_tags_list_entry (device->priv->udevice); l != NULL; l = udev_list_entry_get_next (l)) + { + g_ptr_array_add (p, g_strdup (udev_list_entry_get_name (l))); + } + g_ptr_array_add (p, NULL); + device->priv->tags = (gchar **) g_ptr_array_free (p, FALSE); + + out: + return (const gchar * const *) device->priv->tags; +} + |