From: David Zeuthen Date: Thu, 26 Feb 2009 00:25:22 +0000 (-0500) Subject: add new device-presentation-name and -icon-name properties X-Git-Tag: upstream/2.1.2~936 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c25fbe3a3cf5b69f6f2b3fde7307cb45449549b0;p=platform%2Fupstream%2Fudisks2.git add new device-presentation-name and -icon-name properties Also read these from udev properties DKD_PRESENTATION_NAME DKD_PRESENTATION_ICON_NAME and set ICON_NAME for the iPod we have listed there. --- diff --git a/src/95-devkit-disks.rules b/src/95-devkit-disks.rules index b209ba4..5a78558 100644 --- a/src/95-devkit-disks.rules +++ b/src/95-devkit-disks.rules @@ -84,7 +84,7 @@ SYSFS{idVendor}=="05e3", SYSFS{idProduct}=="070e", ENV{ID_INSTANCE}=="0:3", ENV{ # Apple iPod Video # -SYSFS{idVendor}=="05ac", SYSFS{idProduct}=="1209", ENV{ID_DRIVE_REQUIRES_EJECT}="1" +SYSFS{idVendor}=="05ac", SYSFS{idProduct}=="1209", ENV{ID_DRIVE_REQUIRES_EJECT}="1", ENV{DKD_PRESENTATION_ICON_NAME}="multimedia-player-ipod-white" # USB floppy drives # diff --git a/src/devkit-disks-device-private.c b/src/devkit-disks-device-private.c index 5034e35..d799c55 100644 --- a/src/devkit-disks-device-private.c +++ b/src/devkit-disks-device-private.c @@ -438,6 +438,28 @@ devkit_disks_device_set_device_mount_path (DevkitDisksDevice *device, const gcha } void +devkit_disks_device_set_device_presentation_name (DevkitDisksDevice *device, const gchar *value) +{ + if (G_UNLIKELY (g_strcmp0 (device->priv->device_presentation_name, value) != 0)) + { + g_free (device->priv->device_presentation_name); + device->priv->device_presentation_name = g_strdup (value); + emit_changed (device, "device_presentation_name"); + } +} + +void +devkit_disks_device_set_device_presentation_icon_name (DevkitDisksDevice *device, const gchar *value) +{ + if (G_UNLIKELY (g_strcmp0 (device->priv->device_presentation_icon_name, value) != 0)) + { + g_free (device->priv->device_presentation_icon_name); + device->priv->device_presentation_icon_name = g_strdup (value); + emit_changed (device, "device_presentation_icon_name"); + } +} + +void devkit_disks_device_set_device_mounted_by_uid (DevkitDisksDevice *device, guint value) { if (G_UNLIKELY (device->priv->device_mounted_by_uid != value)) diff --git a/src/devkit-disks-device-private.h b/src/devkit-disks-device-private.h index e8769b7..0de4b20 100644 --- a/src/devkit-disks-device-private.h +++ b/src/devkit-disks-device-private.h @@ -113,6 +113,8 @@ struct DevkitDisksDevicePrivate gboolean device_is_mounted; char *device_mount_path; uid_t device_mounted_by_uid; + char *device_presentation_name; + char *device_presentation_icon_name; char *id_usage; char *id_type; @@ -232,6 +234,8 @@ void devkit_disks_device_set_device_block_size (DevkitDisksDevice *device, guint void devkit_disks_device_set_device_is_mounted (DevkitDisksDevice *device, gboolean value); void devkit_disks_device_set_device_mount_path (DevkitDisksDevice *device, const gchar *value); void devkit_disks_device_set_device_mounted_by_uid (DevkitDisksDevice *device, guint value); +void devkit_disks_device_set_device_presentation_name (DevkitDisksDevice *device, const gchar *value); +void devkit_disks_device_set_device_presentation_icon_name (DevkitDisksDevice *device, const gchar *value); void devkit_disks_device_set_id_usage (DevkitDisksDevice *device, const gchar *value); void devkit_disks_device_set_id_type (DevkitDisksDevice *device, const gchar *value); diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index c6658b2..609b887 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -150,6 +150,8 @@ enum PROP_DEVICE_IS_BUSY, PROP_DEVICE_MOUNT_PATH, PROP_DEVICE_MOUNTED_BY_UID, + PROP_DEVICE_PRESENTATION_NAME, + PROP_DEVICE_PRESENTATION_ICON_NAME, PROP_JOB_IN_PROGRESS, PROP_JOB_ID, @@ -353,6 +355,12 @@ get_property (GObject *object, case PROP_DEVICE_MOUNTED_BY_UID: g_value_set_uint (value, device->priv->device_mounted_by_uid); break; + case PROP_DEVICE_PRESENTATION_NAME: + g_value_set_string (value, device->priv->device_presentation_name); + break; + case PROP_DEVICE_PRESENTATION_ICON_NAME: + g_value_set_string (value, device->priv->device_presentation_icon_name); + break; case PROP_JOB_IN_PROGRESS: g_value_set_boolean (value, device->priv->job_in_progress); @@ -749,6 +757,14 @@ devkit_disks_device_class_init (DevkitDisksDeviceClass *klass) object_class, PROP_DEVICE_MOUNTED_BY_UID, g_param_spec_uint ("device-mounted-by-uid", NULL, NULL, 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_DEVICE_PRESENTATION_NAME, + g_param_spec_string ("device-presentation-name", NULL, NULL, NULL, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_DEVICE_PRESENTATION_ICON_NAME, + g_param_spec_string ("device-presentation-icon-name", NULL, NULL, NULL, G_PARAM_READABLE)); g_object_class_install_property ( object_class, @@ -1132,6 +1148,9 @@ devkit_disks_device_finalize (GObject *object) g_ptr_array_foreach (device->priv->device_file_by_path, (GFunc) g_free, NULL); g_ptr_array_free (device->priv->device_file_by_id, TRUE); g_ptr_array_free (device->priv->device_file_by_path, TRUE); + g_free (device->priv->device_mount_path); + g_free (device->priv->device_presentation_name); + g_free (device->priv->device_presentation_icon_name); g_free (device->priv->id_usage); g_free (device->priv->id_type); @@ -1543,6 +1562,21 @@ diff_sorted_lists (GList *list1, /* update id_* properties */ static gboolean +update_info_presentation (DevkitDisksDevice *device) +{ + devkit_disks_device_set_device_presentation_name (device, + devkit_device_get_property (device->priv->d, "DKD_PRESENTATION_NAME")); + + devkit_disks_device_set_device_presentation_icon_name (device, + devkit_device_get_property (device->priv->d, "DKD_PRESENTATION_ICON_NAME")); + + return TRUE; +} + +/* ---------------------------------------------------------------------------------------------------- */ + +/* update id_* properties */ +static gboolean update_info_id (DevkitDisksDevice *device) { gchar *decoded_string; @@ -2735,6 +2769,10 @@ update_info (DevkitDisksDevice *device) * */ + /* device_presentation_name and device_presentation_icon_name properties */ + if (!update_info_presentation (device)) + goto out; + /* id_* properties */ if (!update_info_id (device)) goto out; diff --git a/src/org.freedesktop.DeviceKit.Disks.Device.xml b/src/org.freedesktop.DeviceKit.Disks.Device.xml index 0ef6103..8bbad79 100644 --- a/src/org.freedesktop.DeviceKit.Disks.Device.xml +++ b/src/org.freedesktop.DeviceKit.Disks.Device.xml @@ -1539,6 +1539,17 @@ The block size of the device in bytes. + + + The name to use when presenting the device to an end user. + + + + + The icon to use when presenting the device to an end user. If set, must be a name + following the freedesktop.org icon theme specification. + + diff --git a/tools/devkit-disks.c b/tools/devkit-disks.c index 5948b6d..84f8ee4 100644 --- a/tools/devkit-disks.c +++ b/tools/devkit-disks.c @@ -421,6 +421,8 @@ typedef struct gboolean device_is_linux_md; char *device_mount_path; uid_t device_mounted_by_uid; + char *device_presentation_name; + char *device_presentation_icon_name; guint64 device_size; guint64 device_block_size; @@ -562,6 +564,10 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props) props->device_mount_path = g_strdup (g_value_get_string (value)); else if (strcmp (key, "device-mounted-by-uid") == 0) props->device_mounted_by_uid = g_value_get_uint (value); + else if (strcmp (key, "device-presentation-name") == 0) + props->device_presentation_name = g_strdup (g_value_get_string (value)); + else if (strcmp (key, "device-presentation-icon-name") == 0) + props->device_presentation_icon_name = g_strdup (g_value_get_string (value)); else if (strcmp (key, "device-size") == 0) props->device_size = g_value_get_uint64 (value); else if (strcmp (key, "device-block-size") == 0) @@ -758,6 +764,8 @@ device_properties_free (DeviceProperties *props) g_strfreev (props->device_file_by_id); g_strfreev (props->device_file_by_path); g_free (props->device_mount_path); + g_free (props->device_presentation_name); + g_free (props->device_presentation_icon_name); g_free (props->job_id); g_free (props->job_cur_task_id); g_free (props->id_usage); @@ -902,6 +910,8 @@ do_show_info (const char *object_path) g_print (" is busy: %d\n", props->device_is_busy); g_print (" mount path: %s\n", props->device_mount_path); g_print (" mounted by uid: %d\n", props->device_mounted_by_uid); + g_print (" presentation name: %s\n", props->device_presentation_name); + g_print (" presentation icon: %s\n", props->device_presentation_icon_name); g_print (" size: %" G_GUINT64_FORMAT "\n", props->device_size); g_print (" block size: %" G_GUINT64_FORMAT "\n", props->device_block_size);