[gnome-control-center] color: Add a small italic indication when there are no color managed devices



commit 118aa6d1f04819c5748e55a6fc82383bc413a468
Author: Richard Hughes <richard hughsie com>
Date:   Wed Aug 24 13:09:11 2011 +0100

    color: Add a small italic indication when there are no color managed devices
    
    This happens on most virtual machines as we can't actually correct a virtual
    screen an there's not going to be many interesting USB devices plugged in.
    
    Thanks again to the guys in #gnome-design for all the help.

 panels/color/cc-color-panel.c |   60 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/panels/color/cc-color-panel.c b/panels/color/cc-color-panel.c
index 76d87c1..50a9754 100644
--- a/panels/color/cc-color-panel.c
+++ b/panels/color/cc-color-panel.c
@@ -904,6 +904,11 @@ gcm_prefs_profile_clicked (CcColorPanel *prefs, CdProfile *profile, CdDevice *de
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                "toolbutton_profile_view"));
   gtk_widget_set_sensitive (widget, TRUE);
+
+  /* hide device specific stuff */
+  widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                               "toolbutton_device_remove"));
+  gtk_widget_set_visible (widget, FALSE);
 }
 
 static void
@@ -940,7 +945,10 @@ gcm_prefs_devices_treeview_clicked_cb (GtkTreeSelection *selection,
   gtk_widget_set_visible (widget, FALSE);
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                "toolbutton_device_calibrate"));
-  gtk_widget_set_visible (widget, profile == NULL);
+  gtk_widget_set_visible (widget, device != NULL);
+  widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                               "toolbutton_profile_add"));
+  gtk_widget_set_visible (widget, device != NULL);
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                "toolbutton_profile_view"));
   gtk_widget_set_visible (widget, profile != NULL);
@@ -1623,6 +1631,7 @@ gcm_prefs_add_device (CcColorPanel *prefs, CdDevice *device)
   GtkTreeIter parent;
   CcColorPanelPrivate *priv = prefs->priv;
 
+
   /* get device properties */
   ret = cd_device_connect_sync (device, priv->cancellable, &error);
   if (!ret)
@@ -1701,12 +1710,54 @@ gcm_prefs_remove_device (CcColorPanel *prefs, CdDevice *cd_device)
 }
 
 static void
+gcm_prefs_update_device_list_extra_entry (CcColorPanel *prefs)
+{
+  CcColorPanelPrivate *priv = prefs->priv;
+  gboolean ret;
+  gchar *id_tmp;
+  gchar *title = NULL;
+  GtkTreeIter iter;
+
+  /* select the first device */
+  ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->list_store_devices), &iter);
+  if (!ret)
+    {
+      /* add the 'No devices detected' entry */
+      title = g_strdup_printf ("<i>%s</i>", _("No devices supporting color management detected"));
+      gtk_tree_store_append (priv->list_store_devices, &iter, NULL);
+      gtk_tree_store_set (priv->list_store_devices, &iter,
+                          GCM_PREFS_COLUMN_RADIO_VISIBLE, FALSE,
+                          GCM_PREFS_COLUMN_TITLE, title,
+                          -1);
+      g_free (title);
+      return;
+    }
+
+  /* remove the 'No devices detected' entry */
+  do
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store_devices), &iter,
+                          GCM_PREFS_COLUMN_DEVICE_PATH, &id_tmp,
+                          -1);
+      if (id_tmp == NULL)
+        {
+          gtk_tree_store_remove (priv->list_store_devices, &iter);
+          break;
+        }
+      g_free (id_tmp);
+    } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->list_store_devices), &iter));
+}
+
+static void
 gcm_prefs_device_added_cb (CdClient *client,
                            CdDevice *device,
                            CcColorPanel *prefs)
 {
   /* add the device */
   gcm_prefs_add_device (prefs, device);
+
+  /* ensure we're not showing the 'No devices detected' entry */
+  gcm_prefs_update_device_list_extra_entry (prefs);
 }
 
 static void
@@ -1731,6 +1782,9 @@ gcm_prefs_device_removed_cb (CdClient *client,
   /* remove from the UI */
   gcm_prefs_remove_device (prefs, device);
 
+  /* ensure we showing the 'No devices detected' entry if required */
+  gcm_prefs_update_device_list_extra_entry (prefs);
+
   /* select the first device */
   ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->list_store_devices), &iter);
   if (!ret)
@@ -1775,6 +1829,9 @@ gcm_prefs_get_devices_cb (GObject *object,
       gcm_prefs_add_device (prefs, device);
     }
 
+  /* ensure we show the 'No devices detected' entry if empty */
+  gcm_prefs_update_device_list_extra_entry (prefs);
+
   /* set the cursor on the first device */
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
                                                "treeview_devices"));
@@ -2006,6 +2063,7 @@ gcm_prefs_connect_cb (GObject *object,
   /* set calibrate button sensitivity */
   gcm_prefs_sensor_coldplug (prefs);
 
+
   /* get devices */
   cd_client_get_devices (priv->client,
                          priv->cancellable,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]