summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2012-12-17 12:45:37 +0000
committerRichard Hughes <richard@hughsie.com>2012-12-17 12:46:19 +0000
commit9a07b786cb123994e4a2b26d60d86ee143153609 (patch)
tree495260dc98b03d3ec1545b9976df2a296a0ba788 /client
parent6d04f27d025165f6ba9957394b2c1c2bfaeb5374 (diff)
downloadcolord-9a07b786cb123994e4a2b26d60d86ee143153609.tar.gz
Add the ability to 'disable' a device so that color management can be turned off
To achieve this, add a 'Device.Enabled' property and a Device.SetEnabled(bool) method that controls the 'Device.Profiles' property much like the inhibitor functionality. If the enabled state is changed then this is reflected for all users and persistent across reboots. Devices are enabled by default and changing the enabled state is a privileged operation.
Diffstat (limited to 'client')
-rw-r--r--client/cd-util.c53
-rwxr-xr-xclient/colormgr-completion.bash1
2 files changed, 54 insertions, 0 deletions
diff --git a/client/cd-util.c b/client/cd-util.c
index b32e162..512cefb 100644
--- a/client/cd-util.c
+++ b/client/cd-util.c
@@ -238,6 +238,10 @@ cd_util_show_device (CdDevice *device)
cd_util_print_field (_("Type"),
cd_device_kind_to_string (cd_device_get_kind (device)));
+ /* TRANSLATORS: the device enabled state */
+ cd_util_print_field (_("Enabled"),
+ cd_device_get_enabled (device) ? "Yes" : "No");
+
/* TRANSLATORS: the device model */
cd_util_print_field (_("Model"),
cd_device_get_model (device));
@@ -1584,6 +1588,50 @@ out:
}
/**
+ * cd_util_device_set_enabled:
+ **/
+static gboolean
+cd_util_device_set_enabled (CdUtilPrivate *priv, gchar **values, GError **error)
+{
+ CdDevice *device = NULL;
+ gboolean ret = TRUE;
+
+ if (g_strv_length (values) < 2) {
+ ret = FALSE;
+ g_set_error_literal (error,
+ 1, 0,
+ "Not enough arguments, "
+ "expected device path, True|False");
+ goto out;
+ }
+
+ /* check is valid object path */
+ if (!g_variant_is_object_path (values[0])) {
+ ret = FALSE;
+ g_set_error (error,
+ 1, 0,
+ "Not a valid object path: %s",
+ values[0]);
+ goto out;
+ }
+
+ device = cd_device_new_with_object_path (values[0]);
+ ret = cd_device_connect_sync (device, NULL, error);
+ if (!ret)
+ goto out;
+ ret = cd_device_set_enabled_sync (device,
+ g_strcmp0 (values[1], "True") == 0,
+ NULL,
+ error);
+ if (!ret)
+ goto out;
+out:
+ if (device != NULL)
+ g_object_unref (device);
+ return ret;
+}
+
+/**
* cd_util_device_get_default_profile:
**/
static gboolean
@@ -2020,6 +2068,11 @@ main (int argc, char *argv[])
_("Sets the device model"),
cd_util_device_set_model);
cd_util_add (priv->cmd_array,
+ "device-set-enabled",
+ /* TRANSLATORS: command description */
+ _("Enables or disables the device"),
+ cd_util_device_set_enabled);
+ cd_util_add (priv->cmd_array,
"device-get-default-profile",
/* TRANSLATORS: command description */
_("Gets the default profile for a device"),
diff --git a/client/colormgr-completion.bash b/client/colormgr-completion.bash
index 9b7f6e2..084899f 100755
--- a/client/colormgr-completion.bash
+++ b/client/colormgr-completion.bash
@@ -33,6 +33,7 @@ __colormgr_commandlist="
device-set-model
device-set-serial
device-set-vendor
+ device-set-enabled
find-device
find-device-by-property
find-profile