add device-presentation-hide property
authorDavid Zeuthen <davidz@redhat.com>
Wed, 15 Apr 2009 14:47:24 +0000 (10:47 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Wed, 15 Apr 2009 14:47:24 +0000 (10:47 -0400)
This is useful for a number of things

 - hiding firmware/update partitions (similar to how volume.ignore is used
   in HAL to hide e.g. HP_RECOVERY, RECOVERY etc. partitions)

 - hiding unwanted things used in things like live cd environments, cf.
   https://bugzilla.redhat.com/show_bug.cgi?id=495170

src/devkit-disks-device-private.c
src/devkit-disks-device-private.h
src/devkit-disks-device.c
src/org.freedesktop.DeviceKit.Disks.Device.xml
tools/devkit-disks.c

index 932e6a3..b23ae64 100644 (file)
@@ -389,6 +389,16 @@ devkit_disks_device_set_device_mount_paths (DevkitDisksDevice *device, GStrv val
 }
 
 void
+devkit_disks_device_set_device_presentation_hide (DevkitDisksDevice *device, gboolean value)
+{
+  if (G_UNLIKELY (device->priv->device_presentation_hide != value))
+    {
+      device->priv->device_presentation_hide = value;
+      emit_changed (device, "device_presentation_hide");
+    }
+}
+
+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))
index 3dfd4a1..2135ae1 100644 (file)
@@ -119,6 +119,7 @@ struct DevkitDisksDevicePrivate
         gboolean device_is_mounted;
         GPtrArray *device_mount_paths;
         uid_t device_mounted_by_uid;
+        gboolean device_presentation_hide;
         char *device_presentation_name;
         char *device_presentation_icon_name;
 
@@ -246,6 +247,7 @@ 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_paths (DevkitDisksDevice *device, GStrv value);
 void devkit_disks_device_set_device_mounted_by_uid (DevkitDisksDevice *device, guint value);
+void devkit_disks_device_set_device_presentation_hide (DevkitDisksDevice *device, gboolean 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);
 
index 4441d65..873c3d9 100644 (file)
@@ -161,6 +161,7 @@ enum
         PROP_DEVICE_IS_MOUNTED,
         PROP_DEVICE_MOUNT_PATHS,
         PROP_DEVICE_MOUNTED_BY_UID,
+        PROP_DEVICE_PRESENTATION_HIDE,
         PROP_DEVICE_PRESENTATION_NAME,
         PROP_DEVICE_PRESENTATION_ICON_NAME,
 
@@ -377,6 +378,9 @@ 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_HIDE:
+               g_value_set_boolean (value, device->priv->device_presentation_hide);
+               break;
        case PROP_DEVICE_PRESENTATION_NAME:
                g_value_set_string (value, device->priv->device_presentation_name);
                break;
@@ -806,6 +810,10 @@ devkit_disks_device_class_init (DevkitDisksDeviceClass *klass)
                 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_HIDE,
+                g_param_spec_boolean ("device-presentation-hide", NULL, NULL, FALSE, 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 (
@@ -1627,6 +1635,9 @@ diff_sorted_lists (GList         *list1,
 static gboolean
 update_info_presentation (DevkitDisksDevice *device)
 {
+        devkit_disks_device_set_device_presentation_hide (device,
+               devkit_device_get_property_as_boolean (device->priv->d, "DKD_PRESENTATION_HIDE"));
+
         devkit_disks_device_set_device_presentation_name (device,
                devkit_device_get_property (device->priv->d, "DKD_PRESENTATION_NAME"));
 
@@ -3041,7 +3052,7 @@ update_info (DevkitDisksDevice *device)
          *
          */
 
-        /* device_presentation_name and device_presentation_icon_name properties */
+        /* device_presentation_hide, device_presentation_name and device_presentation_icon_name properties */
         if (!update_info_presentation (device))
                 goto out;
 
index 2d0d085..6fb05ee 100644 (file)
             The block size of the device in bytes.
       </doc:para></doc:description></doc:doc>
     </property>
+    <property name="device-presentation-hide" type="b" access="read">
+      <doc:doc><doc:description><doc:para>
+            A hint if the device should be hidden from the user interface.
+      </doc:para></doc:description></doc:doc>
+    </property>
     <property name="device-presentation-name" type="s" access="read">
       <doc:doc><doc:description><doc:para>
             The name to use when presenting the device to an end user.
index 9868876..e76094b 100644 (file)
@@ -387,6 +387,7 @@ typedef struct
         gboolean device_is_linux_md;
         char   **device_mount_paths;
         uid_t    device_mounted_by_uid;
+        gboolean device_presentation_hide;
         char    *device_presentation_name;
         char    *device_presentation_icon_name;
         guint64  device_size;
@@ -540,6 +541,8 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props)
                 props->device_mount_paths = g_strdupv (g_value_get_boxed (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-hide") == 0)
+                props->device_presentation_hide = g_value_get_boolean (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)
@@ -1018,6 +1021,7 @@ do_show_info (const char *object_path)
         }
         g_print ("\n");
         g_print ("  mounted by uid:          %d\n", props->device_mounted_by_uid);
+        g_print ("  presentation hide:       %d\n", props->device_presentation_hide);
         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);