[gnome-color-manager] Add a 'connected' property to GcmDevice
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add a 'connected' property to GcmDevice
- Date: Wed, 18 Nov 2009 13:15:28 +0000 (UTC)
commit c18eef396d99ebb1d1ec55b04bd197f7500d7def
Author: Richard Hughes <richard hughsie com>
Date: Wed Nov 18 12:40:15 2009 +0000
Add a 'connected' property to GcmDevice
src/gcm-client.c | 2 ++
src/gcm-device.c | 16 ++++++++++++++++
src/gcm-prefs.c | 25 +++++++++++++++++--------
3 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index c255adf..2d33e51 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -204,6 +204,7 @@ gcm_client_gudev_add_type (GcmClient *client, GUdevDevice *udev_device, GcmDevic
g_object_set (device,
"type", type,
"id", id,
+ "connected", TRUE,
"serial", serial,
"model", model,
"manufacturer", manufacturer,
@@ -515,6 +516,7 @@ gcm_client_xrandr_add (GcmClient *client, GnomeRROutput *output)
g_object_set (device,
"type", GCM_DEVICE_TYPE_DISPLAY,
"id", id,
+ "connected", TRUE,
"serial", serial,
"model", model,
"manufacturer", manufacturer,
diff --git a/src/gcm-device.c b/src/gcm-device.c
index b80cf70..2497938 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -51,6 +51,7 @@ static void gcm_device_finalize (GObject *object);
**/
struct _GcmDevicePrivate
{
+ gboolean connected;
gfloat gamma;
gfloat brightness;
gfloat contrast;
@@ -73,6 +74,7 @@ enum {
PROP_0,
PROP_TYPE,
PROP_ID,
+ PROP_CONNECTED,
PROP_SERIAL,
PROP_MODEL,
PROP_MANUFACTURER,
@@ -400,6 +402,9 @@ gcm_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case PROP_ID:
g_value_set_string (value, priv->id);
break;
+ case PROP_CONNECTED:
+ g_value_set_boolean (value, priv->connected);
+ break;
case PROP_SERIAL:
g_value_set_string (value, priv->serial);
break;
@@ -462,6 +467,9 @@ gcm_device_set_property (GObject *object, guint prop_id, const GValue *value, GP
g_free (priv->id);
priv->id = g_strdup (g_value_get_string (value));
break;
+ case PROP_CONNECTED:
+ priv->connected = g_value_get_boolean (value);
+ break;
case PROP_SERIAL:
g_free (priv->serial);
priv->serial = g_strdup (g_value_get_string (value));
@@ -534,6 +542,14 @@ gcm_device_class_init (GcmDeviceClass *klass)
g_object_class_install_property (object_class, PROP_ID, pspec);
/**
+ * GcmDevice:connected:
+ */
+ pspec = g_param_spec_boolean ("connected", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_CONNECTED, pspec);
+
+ /**
* GcmCalibrate:serial:
*/
pspec = g_param_spec_string ("serial", NULL, NULL,
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index f113bd2..137b325 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -1248,38 +1248,47 @@ gcm_prefs_add_device_type (GcmDevice *device)
{
GtkTreeIter iter;
gchar *title;
- gchar *title_tmp;
+ GString *string;
gchar *id;
GcmDeviceType type;
const gchar *icon_name;
+ gboolean connected;
/* get details */
g_object_get (device,
"id", &id,
- "title", &title_tmp,
+ "connected", &connected,
+ "title", &title,
"type", &type,
NULL);
/* get icon */
icon_name = gcm_prefs_device_type_to_icon_name (type);
+ /* create a title for the device */
+ string = g_string_new (title);
+
+ /* italic for non-connected devices */
+ if (!connected) {
+ /* TRANSLATORS: this is where the device has been setup but is not connected */
+ g_string_append_printf (string, " <i>[%s]</i>", _("Currently disconnected"));
+ }
+
/* use a different title for stuff that won't work yet */
- if (type == GCM_DEVICE_TYPE_DISPLAY) {
- title = g_strdup (title_tmp);
- } else {
+ if (type != GCM_DEVICE_TYPE_DISPLAY) {
/* TRANSLATORS: this is where the required software has not been written yet */
- title = g_strdup_printf ("%s\n(%s)", title_tmp, _("No software support"));
+ g_string_append_printf (string, "\n(%s)", _("No software support"));
}
/* add to list */
gtk_list_store_append (list_store_devices, &iter);
gtk_list_store_set (list_store_devices, &iter,
GPM_DEVICES_COLUMN_ID, id,
- GPM_DEVICES_COLUMN_TITLE, title,
+ GPM_DEVICES_COLUMN_TITLE, string->str,
GPM_DEVICES_COLUMN_ICON, icon_name, -1);
g_free (id);
g_free (title);
- g_free (title_tmp);
+ g_string_free (string, TRUE);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]