Commit 8a353753 authored by Richard Hughes's avatar Richard Hughes

color: Use colord-session to calibrate the display

This allows us to match the new mockups from Allan.
parent 4a5484ba
......@@ -108,6 +108,8 @@ LIBWACOM_REQUIRED_VERSION=0.7
CLUTTER_REQUIRED_VERSION=1.11.3
GOA_REQUIRED_VERSION=3.5.90
ACCOUNTSSERVICE_REQUIRED_VERSION=0.6.30
COLORD_REQUIRED_VERSION=0.1.27
COLORD_GTK_REQUIRED_VERSION=0.1.24
COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
glib-2.0 >= $GLIB_REQUIRED_VERSION
......@@ -144,7 +146,10 @@ PKG_CHECK_MODULES(NOTIFICATIONS_PANEL, $COMMON_MODULES libgnome-menu-3.0)
PKG_CHECK_MODULES(ONLINE_ACCOUNTS_PANEL, $COMMON_MODULES goa-1.0 goa-backend-1.0 >= $GOA_REQUIRED_VERSION)
PKG_CHECK_MODULES(POWER_PANEL, $COMMON_MODULES upower-glib >= 0.9.1
gnome-settings-daemon >= $GSD_REQUIRED_VERSION)
PKG_CHECK_MODULES(COLOR_PANEL, $COMMON_MODULES colord >= 0.1.8)
PKG_CHECK_MODULES(COLOR_PANEL, $COMMON_MODULES
colord >= $COLORD_REQUIRED_VERSION
colord-gtk >= $COLORD_GTK_REQUIRED_VERSION
gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION)
PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
PKG_CHECK_MODULES(PRIVACY_PANEL, $COMMON_MODULES)
......
......@@ -17,6 +17,10 @@ BUILT_SOURCES = \
libcolor_la_SOURCES = \
$(BUILT_SOURCES) \
cc-color-calibrate.c \
cc-color-calibrate.h \
cc-color-cell-renderer-text.c \
cc-color-cell-renderer-text.h \
cc-color-panel.c \
cc-color-panel.h
......
This diff is collapsed.
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2012 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 __CC_COLOR_CALIBRATE_H
#define __CC_COLOR_CALIBRATE_H
#include <glib-object.h>
#include <gtk/gtk.h>
#include <colord.h>
G_BEGIN_DECLS
#define CC_TYPE_COLOR_CALIBRATE (cc_color_calibrate_get_type ())
#define CC_COLOR_CALIBRATE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrate))
#define CC_COLOR_CALIBRATE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrateClass))
#define CC_IS_COLOR_CALIB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_COLOR_CALIBRATE))
#define CC_IS_COLOR_CALIB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_COLOR_CALIBRATE))
#define CC_COLOR_CALIBRATE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrateClass))
typedef struct _CcColorCalibratePrivate CcColorCalibratePrivate;
typedef struct _CcColorCalibrate CcColorCalibrate;
typedef struct _CcColorCalibrateClass CcColorCalibrateClass;
struct _CcColorCalibrate
{
GObject parent;
CcColorCalibratePrivate *priv;
};
struct _CcColorCalibrateClass
{
GObjectClass parent_class;
};
CcColorCalibrate *cc_color_calibrate_new (void);
GType cc_color_calibrate_get_type (void);
void cc_color_calibrate_set_kind (CcColorCalibrate *calibrate,
CdSensorCap kind);
void cc_color_calibrate_set_temperature (CcColorCalibrate *calibrate,
guint temperature);
void cc_color_calibrate_set_quality (CcColorCalibrate *calibrate,
CdProfileQuality quality);
CdProfileQuality cc_color_calibrate_get_quality (CcColorCalibrate *calibrate);
void cc_color_calibrate_set_device (CcColorCalibrate *calibrate,
CdDevice *device);
void cc_color_calibrate_set_sensor (CcColorCalibrate *calibrate,
CdSensor *sensor);
void cc_color_calibrate_set_title (CcColorCalibrate *calibrate,
const gchar *title);
gboolean cc_color_calibrate_start (CcColorCalibrate *calibrate,
GtkWindow *parent,
GError **error);
gboolean cc_color_calibrate_setup (CcColorCalibrate *calibrate,
GError **error);
G_END_DECLS
#endif /* __CC_COLOR_CALIBRATE_H */
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2012 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 <gtk/gtk.h>
#include "cc-color-cell-renderer-text.h"
enum {
PROP_0,
PROP_IS_DIM_LABEL,
PROP_LAST
};
G_DEFINE_TYPE (CcColorCellRendererText, cc_color_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT)
static gpointer parent_class = NULL;
static void
cc_color_cell_renderer_text_get_property (GObject *object, guint param_id,
GValue *value, GParamSpec *pspec)
{
CcColorCellRendererText *renderer = CC_COLOR_CELL_RENDERER_TEXT (object);
switch (param_id)
{
case PROP_IS_DIM_LABEL:
g_value_set_boolean (value, renderer->is_dim_label);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
cc_color_cell_renderer_text_set_property (GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec)
{
CcColorCellRendererText *renderer = CC_COLOR_CELL_RENDERER_TEXT (object);
switch (param_id)
{
case PROP_IS_DIM_LABEL:
renderer->is_dim_label = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
cc_color_cell_renderer_render (GtkCellRenderer *cell,
cairo_t *cr,
GtkWidget *widget,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
CcColorCellRendererText *renderer;
GtkStyleContext *context;
renderer = CC_COLOR_CELL_RENDERER_TEXT (cell);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
if (renderer->is_dim_label)
gtk_style_context_add_class (context, "dim-label");
else
gtk_style_context_remove_class (context, "dim-label");
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, cr, widget,
background_area,
cell_area, flags);
gtk_style_context_restore (context);
}
static void
cc_color_cell_renderer_text_class_init (CcColorCellRendererTextClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkCellRendererClass *object_class_gcr = GTK_CELL_RENDERER_CLASS (class);
object_class_gcr->render = cc_color_cell_renderer_render;
parent_class = g_type_class_peek_parent (class);
object_class->get_property = cc_color_cell_renderer_text_get_property;
object_class->set_property = cc_color_cell_renderer_text_set_property;
g_object_class_install_property (object_class, PROP_IS_DIM_LABEL,
g_param_spec_boolean ("is-dim-label",
NULL, NULL,
FALSE,
G_PARAM_READWRITE));
}
static void
cc_color_cell_renderer_text_init (CcColorCellRendererText *renderer)
{
renderer->is_dim_label = FALSE;
}
GtkCellRenderer *
cc_color_cell_renderer_text_new (void)
{
return g_object_new (CC_COLOR_TYPE_CELL_RENDERER_TEXT, NULL);
}
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2012 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 CC_COLOR_CELL_RENDERER_TEXT_H
#define CC_COLOR_CELL_RENDERER_TEXT_H
#include <gtk/gtk.h>
#define CC_COLOR_TYPE_CELL_RENDERER_TEXT (cc_color_cell_renderer_text_get_type())
#define CC_COLOR_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererText))
#define CC_COLOR_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererTextClass))
#define CC_COLOR_IS_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT))
#define CC_COLOR_IS_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), CC_COLOR_TYPE_CELL_RENDERER_TEXT))
#define CC_COLOR_CELL_RENDERER_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererTextClass))
G_BEGIN_DECLS
typedef struct _CcColorCellRendererText CcColorCellRendererText;
typedef struct _CcColorCellRendererTextClass CcColorCellRendererTextClass;
struct _CcColorCellRendererText
{
GtkCellRendererText parent;
gboolean is_dim_label;
};
struct _CcColorCellRendererTextClass
{
GtkCellRendererTextClass parent_class;
};
GType cc_color_cell_renderer_text_get_type (void);
GtkCellRenderer *cc_color_cell_renderer_text_new (void);
G_END_DECLS
#endif /* CC_COLOR_CELL_RENDERER_TEXT_H */
......@@ -26,6 +26,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "cc-color-calibrate.h"
#include "cc-color-cell-renderer-text.h"
#include "cc-color-panel.h"
#include "cc-color-resources.h"
......@@ -47,6 +49,7 @@ struct _CcColorPanelPrivate
GtkBuilder *builder;
GtkTreeStore *list_store_devices;
GtkWidget *main_window;
CcColorCalibrate *calibrate;
};
enum {
......@@ -72,6 +75,29 @@ enum {
GCM_PREFS_COMBO_COLUMN_NUM_COLUMNS
};
/* for the GtkListStores */
enum {
COLUMN_CALIB_KIND_DESCRIPTION,
COLUMN_CALIB_KIND_CAP_VALUE,
COLUMN_CALIB_KIND_LAST
};
enum {
COLUMN_CALIB_QUALITY_DESCRIPTION,
COLUMN_CALIB_QUALITY_APPROX_TIME,
COLUMN_CALIB_QUALITY_VALUE,
COLUMN_CALIB_QUALITY_LAST
};
enum {
COLUMN_CALIB_SENSOR_OBJECT,
COLUMN_CALIB_SENSOR_DESCRIPTION,
COLUMN_CALIB_SENSOR_LAST
};
enum {
COLUMN_CALIB_TEMP_DESCRIPTION,
COLUMN_CALIB_TEMP_VALUE_K,
COLUMN_CALIB_TEMP_LAST
};
#define GCM_SETTINGS_SCHEMA "org.gnome.settings-daemon.plugins.color"
#define GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD "recalibrate-printer-threshold"
#define GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD "recalibrate-display-threshold"
......@@ -257,6 +283,308 @@ gcm_prefs_file_chooser_get_icc_profile (CcColorPanel *prefs)
return file;
}
static void
gcm_prefs_calib_cancel_cb (GtkWidget *widget, CcColorPanel *prefs)
{
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
gtk_widget_hide (widget);
}
static gboolean
gcm_prefs_calib_delayed_complete_cb (gpointer user_data)
{
CcColorPanel *panel = CC_COLOR_PANEL (user_data);
GtkAssistant *assistant;
GtkWidget *widget;
assistant = GTK_ASSISTANT (gtk_builder_get_object (panel->priv->builder,
"assistant_calib"));
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"box_calib_brightness"));
gtk_assistant_set_page_complete (assistant, widget, TRUE);
return FALSE;
}
static void
gcm_prefs_calib_prepare_cb (GtkAssistant *assistant,
GtkWidget *page,
CcColorPanel *panel)
{
GtkWidget *widget;
/* give the user the indication they should actually manually set the
* desired brightness rather than clicking blindly by delaying the
* "Next" button deliberately for a second or so */
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
"box_calib_brightness"));
if (widget == page)
{
g_timeout_add_seconds (1, gcm_prefs_calib_delayed_complete_cb, panel);
return;
}
/* disable the brightness page as we don't want to show a 'Finished'
* button if the user goes back at any point */
gtk_assistant_set_page_complete (assistant, widget, FALSE);
}
static void
gcm_prefs_calib_apply_cb (GtkWidget *widget, CcColorPanel *prefs)
{
gboolean ret;
GError *error = NULL;
GtkWindow *window = NULL;
/* setup the calibration object with items that can fail */
ret = cc_color_calibrate_setup (prefs->priv->calibrate,
&error);
if (!ret)
{
g_warning ("failed to setup calibrate: %s", error->message);
g_error_free (error);
goto out;
}
/* actually start the calibration */
window = GTK_WINDOW (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
ret = cc_color_calibrate_start (prefs->priv->calibrate,
window,
&error);
if (!ret)
{
g_warning ("failed to start calibrate: %s", error->message);
g_error_free (error);
goto out;
}
out:
if (window != NULL)
gtk_widget_hide (GTK_WIDGET (window));
}
static gboolean
gcm_prefs_calib_delete_event_cb (GtkWidget *widget,
GdkEvent *event,
CcColorPanel *prefs)
{
/* do not destroy the window */
gcm_prefs_calib_cancel_cb (widget, prefs);
return TRUE;
}
static void
gcm_prefs_calib_temp_treeview_clicked_cb (GtkTreeSelection *selection,
CcColorPanel *prefs)
{
CcColorPanelPrivate *priv = prefs->priv;
gboolean ret;
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *widget;
guint target_whitepoint;
GtkAssistant *assistant;
/* check to see if anything is selected */
ret = gtk_tree_selection_get_selected (selection, &model, &iter);
assistant = GTK_ASSISTANT (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_temp"));
gtk_assistant_set_page_complete (assistant, widget, ret);
if (!ret)
return;
gtk_tree_model_get (model, &iter,
COLUMN_CALIB_TEMP_VALUE_K, &target_whitepoint,
-1);
cc_color_calibrate_set_temperature (priv->calibrate, target_whitepoint);
}
static void
gcm_prefs_calib_kind_treeview_clicked_cb (GtkTreeSelection *selection,
CcColorPanel *prefs)
{
CcColorPanelPrivate *priv = prefs->priv;
CdSensorCap device_kind;
gboolean ret;
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *widget;
GtkAssistant *assistant;
/* check to see if anything is selected */
ret = gtk_tree_selection_get_selected (selection, &model, &iter);
assistant = GTK_ASSISTANT (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_kind"));
gtk_assistant_set_page_complete (assistant, widget, ret);
if (!ret)
return;
/* save the values if we have a selection */
gtk_tree_model_get (model, &iter,
COLUMN_CALIB_KIND_CAP_VALUE, &device_kind,
-1);
cc_color_calibrate_set_kind (priv->calibrate, device_kind);
}
static void
gcm_prefs_calib_quality_treeview_clicked_cb (GtkTreeSelection *selection,
CcColorPanel *prefs)
{
CcColorPanelPrivate *priv = prefs->priv;
CdProfileQuality quality;
gboolean ret;
GtkAssistant *assistant;
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *widget;
/* check to see if anything is selected */
ret = gtk_tree_selection_get_selected (selection, &model, &iter);
assistant = GTK_ASSISTANT (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_quality"));
gtk_assistant_set_page_complete (assistant, widget, ret);
if (!ret)
return;
/* save the values if we have a selection */
gtk_tree_model_get (model, &iter,
COLUMN_CALIB_QUALITY_VALUE, &quality,
-1);
cc_color_calibrate_set_quality (priv->calibrate, quality);
}
static void
gcm_prefs_calib_sensor_treeview_clicked_cb (GtkTreeSelection *selection,
CcColorPanel *prefs)
{
CcColorPanelPrivate *priv = prefs->priv;
gboolean ret;
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *widget;
CdSensor *sensor;
GtkAssistant *assistant;
/* check to see if anything is selected */
ret = gtk_tree_selection_get_selected (selection, &model, &iter);
assistant = GTK_ASSISTANT (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_sensor"));
gtk_assistant_set_page_complete (assistant, widget, ret);
if (!ret)
return;
/* save the values if we have a selection */
gtk_tree_model_get (model, &iter,
COLUMN_CALIB_SENSOR_OBJECT, &sensor,
-1);
cc_color_calibrate_set_sensor (priv->calibrate, sensor);
g_object_unref (sensor);
}
static void
gcm_prefs_calibrate_display (CcColorPanel *prefs)
{
CcColorPanelPrivate *priv = prefs->priv;
CdSensor *sensor_tmp;
const gchar *tmp;
GtkListStore *liststore;
GtkTreeIter iter;
GtkWidget *page;
GtkWidget *widget;
guint i;
/* set target device */
cc_color_calibrate_set_device (priv->calibrate, priv->current_device);
/* add sensors to list */
liststore = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
"liststore_calib_sensor"));
gtk_list_store_clear (liststore);
page = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_sensor"));
if (priv->sensors->len > 1)
{
for (i = 0; i < priv->sensors->len; i++)
{
sensor_tmp = g_ptr_array_index (priv->sensors, i);
gtk_list_store_append (liststore, &iter);
gtk_list_store_set (liststore, &iter,
COLUMN_CALIB_SENSOR_OBJECT, sensor_tmp,
COLUMN_CALIB_SENSOR_DESCRIPTION, cd_sensor_get_model (sensor_tmp),
-1);
}
gtk_widget_set_visible (page, TRUE);
}
else
{
sensor_tmp = g_ptr_array_index (priv->sensors, 0);
cc_color_calibrate_set_sensor (priv->calibrate, sensor_tmp);
gtk_widget_set_visible (page, FALSE);
}
/* set default profile title */
tmp = cd_device_get_model (priv->current_device);
if (tmp == NULL)
tmp = cd_device_get_vendor (priv->current_device);
if (tmp == NULL)
tmp = _("Screen");
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"entry_calib_title"));
gtk_entry_set_text (GTK_ENTRY (widget), tmp);
cc_color_calibrate_set_title (priv->calibrate, tmp);
/* set the display whitepoint to D65 by default */
//FIXME?
/* show ui */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"assistant_calib"));
gtk_window_set_transient_for (GTK_WINDOW (widget),
GTK_WINDOW (priv->main_window));
gtk_widget_show (widget);
}
static gboolean
gcm_prefs_calib_treeview_realize_idle_cb (gpointer user_data)
{
GtkWidget *widget = GTK_WIDGET (user_data);
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
gtk_tree_selection_unselect_all (selection);
return FALSE;
}
static void
gcm_prefs_calib_treeview_realize_cb (GtkWidget *widget, CcColorPanel *prefs)
{
g_idle_add (gcm_prefs_calib_treeview_realize_idle_cb, widget);
}
static void
gcm_prefs_title_entry_changed_cb (GtkWidget *widget,
GParamSpec *param_spec,
CcColorPanel *prefs)
{
GtkAssistant *assistant;
GtkWidget *page;
const gchar *value;
assistant = GTK_ASSISTANT (gtk_builder_get_object (prefs->priv->builder,
"assistant_calib"));
page = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"box_calib_title"));
value = gtk_entry_get_text (GTK_ENTRY (widget));
gtk_assistant_set_page_complete (assistant, page, value[0] != '\0');
}
static void
gcm_prefs_calibrate_cb (GtkWidget *widget, CcColorPanel *prefs)
{
......@@ -266,6 +594,13 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, CcColorPanel *prefs)
GPtrArray *argv;
CcColorPanelPrivate *priv = prefs->priv;
/* use the new-style calibration helper */
if (cd_device_get_kind (priv->current_device) == CD_DEVICE_KIND_DISPLAY)
{
gcm_prefs_calibrate_display (prefs);
return;
}
/* get xid */
xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (priv->main_window)));
......@@ -2079,6 +2414,7 @@ cc_color_panel_dispose (GObject *object)
g_clear_object (&priv->builder);
g_clear_object (&priv->client);
g_clear_object (&priv->current_device);
g_clear_object (&priv->calibrate);
g_clear_pointer (&priv->sensors, g_ptr_array_unref);
G_OBJECT_CLASS (cc_color_panel_parent_class)->dispose (object);
......@@ -2111,8 +2447,10 @@ cc_color_panel_init (CcColorPanel *prefs)
{
CcColorPanelPrivate *priv;
GError *error = NULL;
GtkCellRenderer *renderer;
GtkStyleContext *context;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
GtkWidget *widget;
priv = prefs->priv = COLOR_PANEL_PRIVATE (prefs);
......@@ -2132,6 +2470,9 @@ cc_color_panel_init (CcColorPanel *prefs)
priv->cancellable = g_cancellable_new ();
/* can do native display calibration using colord-session */
priv->calibrate = cc_color_calibrate_new ();
/* setup defaults */
priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
......@@ -2254,6 +2595,124 @@ cc_color_panel_init (CcColorPanel *prefs)
g_signal_connect (widget, "clicked",
G_CALLBACK (gcm_prefs_button_assign_import_cb), prefs);
/* setup the calibration helper */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"assistant_calib"));
g_signal_connect (widget, "delete-event",
G_CALLBACK (gcm_prefs_calib_delete_event_cb),
prefs);
g_signal_connect (widget, "apply",
G_CALLBACK (gcm_prefs_calib_apply_cb),
prefs);
g_signal_connect (widget, "cancel",
G_CALLBACK (gcm_prefs_calib_cancel_cb),
prefs);
g_signal_connect (widget, "prepare",
G_CALLBACK (gcm_prefs_calib_prepare_cb),
prefs);
/* setup the calibration helper ::TreeView */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
"treeview_calib_quality"));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
g_signal_connect (selection, "changed",
G_CALLBACK (gcm_prefs_calib_quality_treeview_clicked_cb),
prefs);
column = gtk_tree_view_column_new ();
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer,
"xpad", 9,
"ypad", 9,
NULL);
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_add_attribute (column, renderer,
"markup", COLUMN_CALIB_QUALITY_DESCRIPTION);
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (widget),
GTK_TREE_VIEW_COLUMN (column));
column = gtk_tree_view_column_new ();
renderer = cc_color_cell_renderer_text_new ();
g_object_set (renderer,
"xpad", 9,
"ypad", 9,
"is-dim-label", TRUE,