[gnome-color-manager] Rework the preferences panel based on feedback from the designers
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Rework the preferences panel based on feedback from the designers
- Date: Fri, 20 May 2011 15:14:04 +0000 (UTC)
commit a7faa7ac35ddc1722d3897b6b46c5ec34bf144de
Author: Richard Hughes <richard hughsie com>
Date: Wed May 18 13:44:04 2011 +0100
Rework the preferences panel based on feedback from the designers
data/gcm-prefs.ui | 62 +----------
po/POTFILES.in | 2 +-
src/Makefile.am | 4 +-
src/gcm-calibrate.c | 9 +--
src/gcm-cell-renderer-profile-date.c | 199 ++++++++++++++++++++++++++++++++++
src/gcm-cell-renderer-profile-date.h | 59 ++++++++++
src/gcm-cell-renderer-profile-icon.c | 136 -----------------------
src/gcm-cell-renderer-profile-icon.h | 59 ----------
src/gcm-list-store-profiles.c | 22 +----
src/gcm-list-store-profiles.h | 1 -
src/gcm-prefs.c | 180 +++++++++++++++++++++++++------
11 files changed, 414 insertions(+), 319 deletions(-)
---
diff --git a/data/gcm-prefs.ui b/data/gcm-prefs.ui
index ded2456..85cd7d7 100644
--- a/data/gcm-prefs.ui
+++ b/data/gcm-prefs.ui
@@ -195,34 +195,6 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">9</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Devices:</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -235,7 +207,6 @@
<object class="GtkTreeView" id="treeview_devices">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
@@ -345,35 +316,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">9</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Profiles:</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -389,7 +332,6 @@
<object class="GtkTreeView" id="treeview_assign">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
@@ -499,7 +441,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 894daf5..0fa143a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,7 +14,7 @@ src/gcm-calibrate.c
src/gcm-calibrate-dialog.c
src/gcm-calibrate-manual.c
src/gcm-calibrate-native.c
-src/gcm-cell-renderer-profile-icon.c
+src/gcm-cell-renderer-profile-date.c
src/gcm-cell-renderer-profile-text.c
src/gcm-list-store-profiles.c
src/gcm-import.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ae6b26..1d838c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,10 +98,10 @@ gcm_prefs_SOURCES = \
gcm-calibrate-manual.h \
gcm-calibrate-native.c \
gcm-calibrate-native.h \
- gcm-cell-renderer-profile-icon.c \
- gcm-cell-renderer-profile-icon.h \
gcm-cell-renderer-profile-text.c \
gcm-cell-renderer-profile-text.h \
+ gcm-cell-renderer-profile-date.c \
+ gcm-cell-renderer-profile-date.h \
gcm-gamma-widget.c \
gcm-gamma-widget.h \
gcm-list-store-profiles.c \
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index fb179f3..4b4dfcf 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -147,14 +147,9 @@ gchar *
gcm_calibrate_get_profile_description (GcmCalibrate *calibrate)
{
gchar *text;
- GDate *date = NULL;
const gchar *description;
GcmCalibratePrivate *priv = calibrate->priv;
- /* create date and set it to now */
- date = g_date_new ();
- g_date_set_time_t (date, time (NULL));
-
/* we've got something set */
if (priv->description != NULL) {
description = priv->description;
@@ -164,9 +159,7 @@ gcm_calibrate_get_profile_description (GcmCalibrate *calibrate)
}
/* get description */
- text = g_strdup_printf ("%s, %s (%04i-%02i-%02i)", priv->device, description, date->year, date->month, date->day);
-
- g_date_free (date);
+ text = g_strdup_printf ("%s, %s", priv->device, description);
return text;
}
diff --git a/src/gcm-cell-renderer-profile-date.c b/src/gcm-cell-renderer-profile-date.c
new file mode 100644
index 0000000..4f8dcc9
--- /dev/null
+++ b/src/gcm-cell-renderer-profile-date.c
@@ -0,0 +1,199 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gcm-cell-renderer-profile-date.h"
+#include "gcm-utils.h"
+
+enum {
+ PROP_0,
+ PROP_PROFILE,
+ PROP_IS_DEFAULT,
+ PROP_LAST
+};
+
+G_DEFINE_TYPE (GcmCellRendererProfileDate, gcm_cell_renderer_profile_date, GTK_TYPE_CELL_RENDERER_TEXT)
+
+static gpointer parent_class = NULL;
+
+static void
+gcm_cell_renderer_profile_date_get_property (GObject *object, guint param_id,
+ GValue *value, GParamSpec *pspec)
+{
+ GcmCellRendererProfileDate *renderer = GCM_CELL_RENDERER_PROFILE_DATE (object);
+
+ switch (param_id) {
+ case PROP_PROFILE:
+ g_value_set_object (value, renderer->profile);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static GString *
+gcm_cell_renderer_get_profile_date (CdProfile *profile)
+{
+ gint now;
+ gint64 age;
+ GString *string;
+
+ if (profile == NULL) {
+ /* TRANSLATORS: this is when there is no profile for the device */
+ string = g_string_new (_("No profile"));
+ goto out;
+ }
+
+ /* get profile age */
+ now = g_get_real_time () / G_USEC_PER_SEC;
+ age = now - cd_profile_get_created (profile);
+
+ /* days */
+ string = g_string_new ("");
+ age /= 60 * 60 * 24;
+
+ /* approximate years */
+ if (age > 365) {
+ age /= 365;
+ g_string_append_printf (string, ngettext (
+ "%i year",
+ "%i years",
+ age), (guint) age);
+ goto out;
+ }
+
+ /* approximate months */
+ if (age > 30) {
+ age /= 30;
+ g_string_append_printf (string, ngettext (
+ "%i month",
+ "%i months",
+ age), (guint) age);
+ goto out;
+ }
+
+ /* approximate weeks */
+ if (age > 7) {
+ age /= 7;
+ g_string_append_printf (string, ngettext (
+ "%i week",
+ "%i weeks",
+ age), (guint) age);
+ goto out;
+ }
+
+ /* fallback */
+ g_string_append_printf (string, _("Less than 1 week"));
+out:
+ g_string_prepend (string, "<span foreground='gray'>");
+ g_string_append (string, "</span>");
+ return string;
+}
+
+static void
+gcm_cell_renderer_set_markup (GcmCellRendererProfileDate *renderer)
+{
+ GString *string;
+
+ /* do we have a profile to load? */
+ string = gcm_cell_renderer_get_profile_date (renderer->profile);
+
+ /* assign */
+ g_free (renderer->markup);
+ renderer->markup = g_string_free (string, FALSE);
+ g_object_set (renderer, "markup", renderer->markup, NULL);
+}
+
+static void
+gcm_cell_renderer_profile_date_set_property (GObject *object, guint param_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ GcmCellRendererProfileDate *renderer = GCM_CELL_RENDERER_PROFILE_DATE (object);
+
+ switch (param_id) {
+ case PROP_PROFILE:
+ if (renderer->profile != NULL)
+ g_object_unref (renderer->profile);
+ renderer->profile = g_value_dup_object (value);
+ gcm_cell_renderer_set_markup (renderer);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+/**
+ * gcm_cell_renderer_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gcm_cell_renderer_finalize (GObject *object)
+{
+ GcmCellRendererProfileDate *renderer;
+ renderer = GCM_CELL_RENDERER_PROFILE_DATE (object);
+ g_free (renderer->markup);
+ if (renderer->profile != NULL)
+ g_object_unref (renderer->profile);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gcm_cell_renderer_profile_date_class_init (GcmCellRendererProfileDateClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = gcm_cell_renderer_finalize;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class->get_property = gcm_cell_renderer_profile_date_get_property;
+ object_class->set_property = gcm_cell_renderer_profile_date_set_property;
+
+ g_object_class_install_property (object_class, PROP_PROFILE,
+ g_param_spec_object ("profile", "PROFILE",
+ "PROFILE", CD_TYPE_PROFILE, G_PARAM_READWRITE));
+}
+
+/**
+ * gcm_cell_renderer_profile_date_init:
+ **/
+static void
+gcm_cell_renderer_profile_date_init (GcmCellRendererProfileDate *renderer)
+{
+ renderer->profile = NULL;
+ renderer->markup = NULL;
+}
+
+/**
+ * gcm_cell_renderer_profile_date_new:
+ **/
+GtkCellRenderer *
+gcm_cell_renderer_profile_date_new (void)
+{
+ return g_object_new (GCM_TYPE_CELL_RENDERER_PROFILE_DATE, NULL);
+}
+
diff --git a/src/gcm-cell-renderer-profile-date.h b/src/gcm-cell-renderer-profile-date.h
new file mode 100644
index 0000000..c7b192c
--- /dev/null
+++ b/src/gcm-cell-renderer-profile-date.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef GCM_CELL_RENDERER_PROFILE_DATE_H
+#define GCM_CELL_RENDERER_PROFILE_DATE_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <colord.h>
+
+#define GCM_TYPE_CELL_RENDERER_PROFILE_DATE (gcm_cell_renderer_profile_date_get_type())
+#define GCM_CELL_RENDERER_PROFILE_DATE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCM_TYPE_CELL_RENDERER_PROFILE_DATE, GcmCellRendererProfileDate))
+#define GCM_CELL_RENDERER_PROFILE_DATE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), GCM_TYPE_CELL_RENDERER_PROFILE_DATE, GcmCellRendererProfileDateClass))
+#define GCM_IS_CELL_RENDERER_PROFILE_DATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCM_TYPE_CELL_RENDERER_PROFILE_DATE))
+#define GCM_IS_CELL_RENDERER_PROFILE_DATE_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), GCM_TYPE_CELL_RENDERER_PROFILE_DATE))
+#define GCM_CELL_RENDERER_PROFILE_DATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCM_TYPE_CELL_RENDERER_PROFILE_DATE, GcmCellRendererProfileDateClass))
+
+G_BEGIN_DECLS
+
+typedef struct _GcmCellRendererProfileDate GcmCellRendererProfileDate;
+typedef struct _GcmCellRendererProfileDateClass GcmCellRendererProfileDateClass;
+
+struct _GcmCellRendererProfileDate
+{
+ GtkCellRendererText parent;
+ CdProfile *profile;
+ gchar *markup;
+};
+
+struct _GcmCellRendererProfileDateClass
+{
+ GtkCellRendererTextClass parent_class;
+};
+
+GType gcm_cell_renderer_profile_date_get_type (void);
+GtkCellRenderer *gcm_cell_renderer_profile_date_new (void);
+
+G_END_DECLS
+
+#endif /* GCM_CELL_RENDERER_PROFILE_DATE_H */
+
diff --git a/src/gcm-list-store-profiles.c b/src/gcm-list-store-profiles.c
index 04d9787..08af3ad 100644
--- a/src/gcm-list-store-profiles.c
+++ b/src/gcm-list-store-profiles.c
@@ -37,25 +37,6 @@ struct GcmListStoreProfilesPrivate
};
/**
- * cc_color_panel_profile_get_tooltip:
- **/
-static const gchar *
-cc_color_panel_profile_get_tooltip (CdProfile *profile)
-{
- const gchar *tooltip = NULL;
-
- /* VCGT warning */
- if (cd_profile_get_kind (profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
- !cd_profile_get_has_vcgt (profile)) {
- /* TRANSLATORS: this is displayed when the profile is crap */
- tooltip = _("This profile does not have the information required for whole-screen color correction.");
- goto out;
- }
-out:
- return tooltip;
-}
-
-/**
* gcm_list_store_refresh_profiles:
**/
static void
@@ -86,7 +67,6 @@ gcm_list_store_refresh_profiles (GtkListStore *list_store)
GCM_LIST_STORE_PROFILES_COLUMN_PROFILE, profile,
GCM_LIST_STORE_PROFILES_COLUMN_SORT, (i == 0) ? "0" : "1",
GCM_LIST_STORE_PROFILES_COLUMN_IS_DEFAULT, (i == 0),
- GCM_LIST_STORE_PROFILES_COLUMN_TOOLTIP, cc_color_panel_profile_get_tooltip (profile),
GCM_LIST_STORE_PROFILES_COLUMN_RELATION, relation,
-1);
}
@@ -132,7 +112,7 @@ gcm_list_store_profiles_set_from_device (GtkListStore *list_store, CdDevice *dev
static void
gcm_list_store_profiles_init (GcmListStoreProfiles *list_store)
{
- GType types[] = { G_TYPE_STRING, CD_TYPE_PROFILE, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT };
+ GType types[] = { G_TYPE_STRING, CD_TYPE_PROFILE, G_TYPE_BOOLEAN, G_TYPE_UINT };
list_store->priv = GCM_LIST_STORE_PROFILES_GET_PRIVATE (list_store);
gtk_list_store_set_column_types (GTK_LIST_STORE (list_store), GCM_LIST_STORE_PROFILES_COLUMN_LAST, types);
}
diff --git a/src/gcm-list-store-profiles.h b/src/gcm-list-store-profiles.h
index d5a5ba0..f350c59 100644
--- a/src/gcm-list-store-profiles.h
+++ b/src/gcm-list-store-profiles.h
@@ -38,7 +38,6 @@ enum {
GCM_LIST_STORE_PROFILES_COLUMN_SORT,
GCM_LIST_STORE_PROFILES_COLUMN_PROFILE,
GCM_LIST_STORE_PROFILES_COLUMN_IS_DEFAULT,
- GCM_LIST_STORE_PROFILES_COLUMN_TOOLTIP,
GCM_LIST_STORE_PROFILES_COLUMN_RELATION,
GCM_LIST_STORE_PROFILES_COLUMN_LAST
};
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index b6488f4..f36efff 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -31,7 +31,7 @@
#include <colord.h>
#include "gcm-cell-renderer-profile-text.h"
-#include "gcm-cell-renderer-profile-icon.h"
+#include "gcm-cell-renderer-profile-date.h"
#include "gcm-calibrate-argyll.h"
#include "gcm-debug.h"
#include "gcm-exif.h"
@@ -66,6 +66,9 @@ enum {
CD_DEVICES_COLUMN_ICON,
CD_DEVICES_COLUMN_TITLE,
CD_DEVICES_COLUMN_DEVICE,
+ CD_DEVICES_COLUMN_STATUS,
+ CD_DEVICES_COLUMN_STATUS_IMAGE,
+ CD_DEVICES_COLUMN_TOOLTIP,
CD_DEVICES_COLUMN_LAST
};
@@ -1247,26 +1250,57 @@ gcm_prefs_add_devices_columns (GcmPrefsPriv *prefs,
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ gtk_tree_view_set_headers_visible (treeview, TRUE);
+
+ /* --- column for device image and device title --- */
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_expand (column, TRUE);
+ /* TRANSLATORS: column for device list */
+ gtk_tree_view_column_set_title (column, _("Device"));
+
/* image */
renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
- column = gtk_tree_view_column_new_with_attributes ("", renderer,
- "icon-name", CD_DEVICES_COLUMN_ICON,
- NULL);
- gtk_tree_view_append_column (treeview, column);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_add_attribute (column, renderer,
+ "icon-name", CD_DEVICES_COLUMN_ICON);
- /* column for text */
+ /* text */
renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer,
- "wrap-mode", PANGO_WRAP_WORD,
- NULL);
- column = gtk_tree_view_column_new_with_attributes ("", renderer,
- "markup", CD_DEVICES_COLUMN_TITLE,
- NULL);
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_add_attribute (column, renderer,
+ "markup", CD_DEVICES_COLUMN_TITLE);
+ gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_column_set_sort_column_id (column, CD_DEVICES_COLUMN_SORT);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (prefs->list_store_devices), CD_DEVICES_COLUMN_SORT, GTK_SORT_ASCENDING);
- gtk_tree_view_append_column (treeview, column);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (prefs->list_store_devices),
+ CD_DEVICES_COLUMN_SORT,
+ GTK_SORT_ASCENDING);
+ gtk_tree_view_append_column (treeview, GTK_TREE_VIEW_COLUMN(column));
+
+ /* --- column for device status --- */
+ column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_expand (column, TRUE);
+ /* TRANSLATORS: column for device list */
+ gtk_tree_view_column_set_title (column, _("Status"));
+
+ /* image */
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_add_attribute (column, renderer,
+ "icon-name", CD_DEVICES_COLUMN_STATUS_IMAGE);
+
+ /* text */
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_add_attribute (column, renderer,
+ "markup", CD_DEVICES_COLUMN_STATUS);
+ gtk_tree_view_column_set_expand (column, FALSE);
+ gtk_tree_view_append_column (treeview, GTK_TREE_VIEW_COLUMN(column));
+
+ /* tooltip */
+ gtk_tree_view_set_tooltip_column (treeview,
+ CD_DEVICES_COLUMN_TOOLTIP);
}
/**
@@ -1284,23 +1318,23 @@ gcm_prefs_add_assign_columns (GcmPrefsPriv *prefs,
g_object_set (renderer,
"wrap-mode", PANGO_WRAP_WORD,
NULL);
- column = gtk_tree_view_column_new_with_attributes ("", renderer,
+ column = gtk_tree_view_column_new_with_attributes (_("Profile"), renderer,
"profile", GCM_LIST_STORE_PROFILES_COLUMN_PROFILE,
"is-default", GCM_LIST_STORE_PROFILES_COLUMN_IS_DEFAULT,
NULL);
- gtk_tree_view_column_set_sort_column_id (column, GCM_LIST_STORE_PROFILES_COLUMN_SORT);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (prefs->list_store_profiles), GCM_LIST_STORE_PROFILES_COLUMN_SORT, GTK_SORT_ASCENDING);
gtk_tree_view_append_column (treeview, column);
gtk_tree_view_column_set_expand (column, TRUE);
- /* column for icon */
- renderer = gcm_cell_renderer_profile_icon_new ();
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
- column = gtk_tree_view_column_new_with_attributes ("", renderer,
+ /* column for text */
+ renderer = gcm_cell_renderer_profile_date_new ();
+ g_object_set (renderer,
+ "wrap-mode", PANGO_WRAP_WORD,
+ NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Age"), renderer,
"profile", GCM_LIST_STORE_PROFILES_COLUMN_PROFILE,
NULL);
gtk_tree_view_append_column (treeview, column);
- gtk_tree_view_column_set_expand (column, FALSE);
+ gtk_tree_view_column_set_expand (column, TRUE);
}
/**
@@ -1796,6 +1830,83 @@ gcm_prefs_device_kind_to_icon_name (CdDeviceKind kind)
}
/**
+ * gcm_prefs_device_set_model_by_iter:
+ **/
+static void
+gcm_prefs_device_set_model_by_iter (GcmPrefsPriv *prefs, CdDevice *device, GtkTreeIter *iter)
+{
+ GString *status;
+ const gchar *status_image;
+ const gchar *tooltip = NULL;
+ CdProfile *profile = NULL;
+
+ /* set status */
+ profile = cd_device_get_default_profile (device);
+ if (profile == NULL) {
+ status = g_string_new (_("Uncalibrated"));
+ status_image = "emblem-important-symbolic";
+ tooltip = _("This device is not color managed.");
+ goto out;
+ }
+
+ /* autogenerated profiles are crap */
+ if (cd_profile_get_kind (profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
+ !cd_profile_get_has_vcgt (profile)) {
+ status = g_string_new (_("Uncalibrated"));
+ status_image = "emblem-important-symbolic";
+ tooltip = _("This device does not have a profile suitable for whole-screen color correction.");
+ goto out;
+ }
+
+ /* yay! */
+ status = g_string_new (_("Calibrated"));
+ status_image = "emblem-default-symbolic";
+out:
+ g_string_prepend (status, "<span foreground='gray'>");
+ g_string_append (status, "</span>");
+
+ /* save to store */
+ gtk_list_store_set (prefs->list_store_devices, iter,
+ CD_DEVICES_COLUMN_STATUS, status->str,
+ CD_DEVICES_COLUMN_STATUS_IMAGE, status_image,
+ CD_DEVICES_COLUMN_TOOLTIP, tooltip,
+ -1);
+ g_string_free (status, TRUE);
+ if (profile != NULL)
+ g_object_unref (profile);
+}
+
+/**
+ * gcm_prefs_device_changed_cb:
+ **/
+static void
+gcm_prefs_device_changed_cb (CdDevice *device, GcmPrefsPriv *prefs)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ const gchar *id;
+ gchar *id_tmp;
+ gboolean ret;
+
+ /* get first element */
+ model = GTK_TREE_MODEL (prefs->list_store_devices);
+ ret = gtk_tree_model_get_iter_first (model, &iter);
+ if (!ret)
+ return;
+
+ /* get the other elements */
+ id = cd_device_get_id (device);
+ do {
+ gtk_tree_model_get (model, &iter,
+ CD_DEVICES_COLUMN_ID, &id_tmp,
+ -1);
+ if (g_strcmp0 (id_tmp, id) == 0)
+ gcm_prefs_device_set_model_by_iter (prefs, device, &iter);
+ g_free (id_tmp);
+ } while (gtk_tree_model_iter_next (model, &iter));
+}
+
+/**
* gcm_prefs_add_device:
**/
static void
@@ -1830,16 +1941,22 @@ gcm_prefs_add_device (GcmPrefsPriv *prefs, CdDevice *device)
gcm_prefs_device_kind_to_string (kind),
title);
+ /* watch for changes to update the status icons */
+ g_signal_connect (device, "changed",
+ G_CALLBACK (gcm_prefs_device_changed_cb), prefs);
+
/* add to list */
id = cd_device_get_id (device);
g_debug ("add %s to device list", id);
gtk_list_store_append (prefs->list_store_devices, &iter);
+ gcm_prefs_device_set_model_by_iter (prefs, device, &iter);
gtk_list_store_set (prefs->list_store_devices, &iter,
CD_DEVICES_COLUMN_DEVICE, device,
CD_DEVICES_COLUMN_ID, id,
CD_DEVICES_COLUMN_SORT, sort,
CD_DEVICES_COLUMN_TITLE, title,
- CD_DEVICES_COLUMN_ICON, icon_name, -1);
+ CD_DEVICES_COLUMN_ICON, icon_name,
+ -1);
g_free (sort);
g_free (title);
}
@@ -2288,11 +2405,14 @@ gcm_viewer_startup_cb (GApplication *application, GcmPrefsPriv *prefs)
/* create list stores */
prefs->list_store_devices = gtk_list_store_new (CD_DEVICES_COLUMN_LAST,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING,
- CD_TYPE_DEVICE);
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ CD_TYPE_DEVICE,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
prefs->list_store_profiles = gcm_list_store_profiles_new ();
/* assign buttons */
@@ -2330,7 +2450,7 @@ gcm_viewer_startup_cb (GApplication *application, GcmPrefsPriv *prefs)
/* force to be at least 3 rows high */
widget = GTK_WIDGET (gtk_builder_get_object (prefs->builder,
"scrolledwindow_devices"));
- gtk_widget_set_size_request (widget, 550, 36 * 3);
+ gtk_widget_set_size_request (widget, 550, 36 * 4);
/* create assign tree view */
widget = GTK_WIDGET (gtk_builder_get_object (prefs->builder,
@@ -2349,8 +2469,6 @@ gcm_viewer_startup_cb (GApplication *application, GcmPrefsPriv *prefs)
gcm_prefs_add_assign_columns (prefs, GTK_TREE_VIEW (widget));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget));
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (widget), TRUE);
- gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (widget),
- GCM_LIST_STORE_PROFILES_COLUMN_TOOLTIP);
/* force to be at least 2 rows high */
widget = GTK_WIDGET (gtk_builder_get_object (prefs->builder,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]