Merge lp:~noskcaj/ubuntu/vivid/gnome-color-manager/3.14 into lp:ubuntu/vivid/gnome-color-manager

Proposed by Jackson Doak
Status: Needs review
Proposed branch: lp:~noskcaj/ubuntu/vivid/gnome-color-manager/3.14
Merge into: lp:ubuntu/vivid/gnome-color-manager
Diff against target: 133582 lines (+37805/-31465)
178 files modified
.pc/01_unity_control_center.patch/src/gcm-calibrate-main.c (+0/-2370)
.pc/applied-patches (+0/-1)
ChangeLog (+1855/-85)
INSTALL (+2/-2)
Makefile.am (+13/-8)
Makefile.in (+30/-20)
NEWS (+231/-29)
aclocal.m4 (+478/-285)
config.guess (+27/-165)
config.h (+3/-9)
config.h.in (+0/-6)
config.sub (+25/-15)
configure (+292/-654)
configure.ac (+7/-30)
data/Makefile.am (+2/-0)
data/Makefile.in (+8/-9)
data/appdata/Makefile.am (+8/-0)
data/appdata/Makefile.in (+502/-0)
data/appdata/gcm-viewer.appdata.xml.in (+26/-0)
data/figures/Makefile.am (+1/-0)
data/figures/Makefile.in (+7/-9)
data/gcm-picker.ui (+310/-421)
data/gcm-viewer.ui (+3/-48)
data/icons/16x16/Makefile.am (+2/-0)
data/icons/16x16/Makefile.in (+7/-9)
data/icons/22x22/Makefile.am (+2/-0)
data/icons/22x22/Makefile.in (+7/-9)
data/icons/24x24/Makefile.am (+2/-0)
data/icons/24x24/Makefile.in (+7/-9)
data/icons/256x256/Makefile.am (+2/-0)
data/icons/256x256/Makefile.in (+7/-9)
data/icons/32x32/Makefile.am (+2/-0)
data/icons/32x32/Makefile.in (+7/-9)
data/icons/48x48/Makefile.am (+2/-0)
data/icons/48x48/Makefile.in (+7/-9)
data/icons/64x64/Makefile.am (+2/-0)
data/icons/64x64/Makefile.in (+7/-9)
data/icons/Makefile.am (+1/-0)
data/icons/Makefile.in (+7/-9)
data/icons/scalable/Makefile.am (+1/-0)
data/icons/scalable/Makefile.in (+7/-9)
data/targets/Makefile.am (+1/-0)
data/targets/Makefile.in (+7/-9)
data/tests/Makefile.am (+1/-0)
data/tests/Makefile.in (+7/-9)
data/ti1/Makefile.am (+2/-0)
data/ti1/Makefile.in (+7/-9)
debian/changelog (+56/-0)
debian/control (+8/-10)
debian/control.in (+8/-10)
debian/patches/01_unity_control_center.patch (+28/-10)
debian/rules (+1/-0)
help/Makefile.am (+5/-1)
help/Makefile.in (+10/-10)
help/fi/color-import-linux.page (+26/-0)
help/fi/color-import-osx.page (+26/-0)
help/fi/color-import-windows.page (+46/-0)
help/fi/fi.po (+256/-0)
help/fi/legal.xml (+4/-0)
help/gl/color-import-linux.page (+26/-0)
help/gl/color-import-osx.page (+26/-0)
help/gl/color-import-windows.page (+46/-0)
help/gl/gl.po (+256/-0)
help/gl/legal.xml (+4/-0)
help/hu/color-import-linux.page (+26/-0)
help/hu/color-import-osx.page (+26/-0)
help/hu/color-import-windows.page (+46/-0)
help/hu/hu.po (+263/-0)
help/hu/legal.xml (+4/-0)
help/zh_CN/color-import-osx.page (+1/-4)
help/zh_CN/legal.xml (+1/-2)
help/zh_CN/zh_CN.po (+2/-2)
help/zh_HK/color-import-linux.page (+26/-0)
help/zh_HK/color-import-osx.page (+34/-0)
help/zh_HK/color-import-windows.page (+95/-0)
help/zh_HK/legal.xml (+4/-0)
help/zh_HK/zh_HK.po (+199/-0)
help/zh_TW/color-import-linux.page (+26/-0)
help/zh_TW/color-import-osx.page (+34/-0)
help/zh_TW/color-import-windows.page (+95/-0)
help/zh_TW/legal.xml (+4/-0)
help/zh_TW/zh_TW.po (+207/-0)
m4/libtool.m4 (+9/-3)
man/Makefile.am (+5/-0)
man/Makefile.in (+12/-9)
missing (+2/-2)
po/LINGUAS (+4/-0)
po/POTFILES.in (+1/-1)
po/as.po (+428/-369)
po/bn_IN.po (+577/-409)
po/ca.po (+423/-376)
po/ca@valencia.po (+427/-379)
po/cs.po (+396/-373)
po/da.po (+425/-377)
po/de.po (+459/-404)
po/el.po (+495/-446)
po/es.po (+415/-368)
po/et.po (+37/-26)
po/eu.po (+424/-375)
po/fa.po (+431/-387)
po/fi.po (+553/-472)
po/fr.po (+398/-374)
po/fur.po (+1753/-0)
po/gl.po (+421/-373)
po/gu.po (+435/-374)
po/he.po (+578/-457)
po/hi.po (+433/-374)
po/hu.po (+430/-373)
po/id.po (+393/-369)
po/it.po (+391/-367)
po/ja.po (+497/-394)
po/kk.po (+1824/-0)
po/kn.po (+438/-393)
po/ko.po (+570/-543)
po/lt.po (+399/-369)
po/lv.po (+426/-373)
po/ml.po (+255/-249)
po/mr.po (+440/-381)
po/nb.po (+407/-383)
po/ne.po (+1812/-0)
po/nl.po (+1843/-0)
po/or.po (+427/-368)
po/pa.po (+421/-366)
po/pl.po (+392/-369)
po/pt.po (+427/-1273)
po/pt_BR.po (+422/-372)
po/ro.po (+1922/-1500)
po/ru.po (+442/-434)
po/sk.po (+511/-369)
po/sl.po (+417/-368)
po/sr.po (+413/-365)
po/sr@latin.po (+413/-365)
po/sv.po (+712/-487)
po/ta.po (+427/-378)
po/te.po (+435/-378)
po/tg.po (+728/-596)
po/tr.po (+499/-464)
po/ug.po (+39/-55)
po/uk.po (+431/-376)
po/zh_CN.po (+492/-369)
po/zh_HK.po (+413/-370)
po/zh_TW.po (+415/-370)
src/Makefile.am (+2/-28)
src/Makefile.in (+34/-172)
src/gcm-calibrate-argyll.c (+90/-24)
src/gcm-calibrate-main.c (+76/-26)
src/gcm-calibrate.c (+6/-10)
src/gcm-calibrate.h (+5/-1)
src/gcm-cell-renderer-color.c (+12/-8)
src/gcm-cell-renderer-color.h (+1/-1)
src/gcm-cell-renderer-profile-text.c (+1/-2)
src/gcm-cie-widget.c (+1/-1)
src/gcm-cie-widget.h (+2/-2)
src/gcm-clut.c (+0/-251)
src/gcm-clut.h (+0/-69)
src/gcm-exif.c (+12/-4)
src/gcm-hull-widget.c (+0/-371)
src/gcm-hull-widget.h (+0/-62)
src/gcm-hull.c (+0/-279)
src/gcm-hull.h (+0/-68)
src/gcm-image.c (+0/-528)
src/gcm-image.h (+0/-76)
src/gcm-import.c (+13/-10)
src/gcm-inspect.c (+10/-8)
src/gcm-named-color.c (+0/-248)
src/gcm-named-color.h (+0/-62)
src/gcm-picker-resources.c (+479/-223)
src/gcm-picker.c (+44/-27)
src/gcm-print.c (+1/-5)
src/gcm-profile.c (+0/-2479)
src/gcm-profile.h (+0/-150)
src/gcm-self-test.c (+14/-369)
src/gcm-trc-widget.c (+32/-39)
src/gcm-utils.c (+101/-23)
src/gcm-utils.h (+6/-29)
src/gcm-viewer-resources.c (+433/-433)
src/gcm-viewer.c (+91/-136)
test-driver (+16/-4)
To merge this branch: bzr merge lp:~noskcaj/ubuntu/vivid/gnome-color-manager/3.14
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+245494@code.launchpad.net

Description of the change

Merge from debian.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Thanks. Uploaded.

review: Approve

Unmerged revisions

40. By Jackson Doak

Add .pc files, again

39. By Jackson Doak

Actually new upstream release

38. By Jackson Doak

New upstream release.

37. By Jackson Doak

Update-maintaner

36. By Jackson Doak

Add .pc files

35. By Jackson Doak

* Merge from debian. Remiaining changes:
  - debian/patches/01_unity_control_center.patch:
    + Use Unity Control Center in Unity
* New upstream release.
* Point Homepage to the upstream git repository as there is no real project
  website now.
* Bump Standards-Version to 3.9.6.
* New upstream release
* debian/rules: enable parallel build. Closes: #759118
* debian/control: Use vte2.91 instead of vte2.90
* New upstream release.
* Bump Standards-Version to 3.9.5
* Team upload.
* New upstream release
* New upstream release (3.10.1).
* Update 'libcolord-dev' and 'colord' dependency according to configure.ac.
* New upstream release (3.12.0).
* Update build-dependencies according to configure.ac changes:
  - Drop unused libxrandr-dev, libx11-dev and libgnome-desktop-3-dev.

34. By Jackson Doak

Merging shared upstream rev into target branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory '.pc/01_unity_control_center.patch'
=== removed directory '.pc/01_unity_control_center.patch'
=== added file '.pc/01_unity_control_center.patch/.timestamp'
=== added directory '.pc/01_unity_control_center.patch/src'
=== removed directory '.pc/01_unity_control_center.patch/src'
=== added file '.pc/01_unity_control_center.patch/src/gcm-calibrate-main.c'
--- .pc/01_unity_control_center.patch/src/gcm-calibrate-main.c 1970-01-01 00:00:00 +0000
+++ .pc/01_unity_control_center.patch/src/gcm-calibrate-main.c 2015-01-02 20:29:31 +0000
@@ -0,0 +1,2415 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2009-2011 Richard Hughes <richard@hughsie.com>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "config.h"
23
24#include <glib/gi18n.h>
25#include <gtk/gtk.h>
26#include <gdk/gdkx.h>
27#include <glib/gstdio.h>
28#include <locale.h>
29#include <canberra-gtk.h>
30#include <colord.h>
31#include <lcms2.h>
32#include <stdlib.h>
33
34#include "gcm-utils.h"
35#include "gcm-debug.h"
36#include "gcm-calibrate.h"
37#include "gcm-calibrate-argyll.h"
38
39typedef enum {
40 GCM_CALIBRATE_PAGE_INTRO,
41 GCM_CALIBRATE_PAGE_DISPLAY_KIND,
42 GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE,
43 GCM_CALIBRATE_PAGE_DISPLAY_CONFIG,
44 GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS,
45 GCM_CALIBRATE_PAGE_INSTALL_TARGETS,
46 GCM_CALIBRATE_PAGE_PRECISION,
47 GCM_CALIBRATE_PAGE_PRINT_KIND,
48 GCM_CALIBRATE_PAGE_TARGET_KIND,
49 GCM_CALIBRATE_PAGE_SENSOR,
50 GCM_CALIBRATE_PAGE_ACTION,
51 GCM_CALIBRATE_PAGE_FAILURE,
52 GCM_CALIBRATE_PAGE_TITLE,
53 GCM_CALIBRATE_PAGE_LAST
54} GcmCalibratePage;
55
56typedef struct {
57 GtkApplication *application;
58 CdClient *client;
59 GcmCalibrate *calibrate;
60 CdDevice *device;
61 CdDeviceKind device_kind;
62 GCancellable *cancellable;
63 gchar *device_id;
64 guint xid;
65 GtkWindow *main_window;
66 GPtrArray *pages;
67 gboolean internal_lcd;
68 GtkWidget *reference_preview;
69 GtkWidget *action_title;
70 GtkWidget *action_message;
71 GtkWidget *action_image;
72 GtkWidget *action_progress;
73 gboolean has_pending_interaction;
74 gboolean started_calibration;
75 GcmCalibratePage current_page;
76 gint inhibit_cookie;
77} GcmCalibratePriv;
78
79/**
80 * gcm_window_set_parent_xid:
81 **/
82static void
83gcm_window_set_parent_xid (GtkWindow *window, guint32 xid)
84{
85 GdkDisplay *display;
86 GdkWindow *parent_window;
87 GdkWindow *our_window;
88
89 display = gdk_display_get_default ();
90 parent_window = gdk_x11_window_foreign_new_for_display (display, xid);
91 if (parent_window == NULL) {
92 g_warning ("failed to get parent window");
93 return;
94 }
95
96 gtk_widget_realize (GTK_WIDGET (window));
97 our_window = gtk_widget_get_window (GTK_WIDGET (window));
98 if (our_window == NULL) {
99 g_warning ("failed to get our window");
100 return;
101 }
102
103 /* set this above our parent */
104 gtk_window_set_modal (window, TRUE);
105 gdk_window_set_transient_for (our_window, parent_window);
106 gtk_window_set_title (window, "");
107}
108
109/**
110 * gcm_calib_activate_cb:
111 **/
112static void
113gcm_calib_activate_cb (GApplication *application, GcmCalibratePriv *priv)
114{
115 gtk_window_present (priv->main_window);
116}
117
118static void
119gcm_calib_confirm_quit_cb (GtkDialog *dialog,
120 gint response_id,
121 GcmCalibratePriv *priv)
122{
123 if (response_id != GTK_RESPONSE_CLOSE) {
124 gtk_widget_destroy (GTK_WIDGET (dialog));
125 return;
126 }
127 gcm_calibrate_interaction (priv->calibrate, GTK_RESPONSE_CANCEL);
128 g_application_release (G_APPLICATION (priv->application));
129}
130
131/**
132 * gcm_calib_confirm_quit:
133 **/
134static void
135gcm_calib_confirm_quit (GcmCalibratePriv *priv)
136{
137 GtkWidget *dialog;
138
139 /* do not ask for confirmation on the initial page */
140 if (priv->current_page == GCM_CALIBRATE_PAGE_INTRO)
141 g_application_release (G_APPLICATION (priv->application));
142
143 dialog = gtk_message_dialog_new (GTK_WINDOW (priv->main_window),
144 GTK_DIALOG_MODAL,
145 GTK_MESSAGE_QUESTION,
146 GTK_BUTTONS_NONE,
147 "%s", _("Calibration is not complete"));
148 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
149 "%s",
150 _("Are you sure you want to cancel the calibration?"));
151 /* TRANSLATORS: button text */
152 gtk_dialog_add_button (GTK_DIALOG (dialog),
153 _("Continue calibration"),
154 GTK_RESPONSE_CANCEL);
155 /* TRANSLATORS: button text */
156 gtk_dialog_add_button (GTK_DIALOG (dialog),
157 _("Cancel and close"),
158 GTK_RESPONSE_CLOSE);
159 g_signal_connect (dialog, "response",
160 G_CALLBACK (gcm_calib_confirm_quit_cb),
161 priv);
162 gtk_widget_show (dialog);
163}
164
165/**
166 * gcm_calib_delete_event_cb:
167 **/
168static gboolean
169gcm_calib_delete_event_cb (GtkWidget *widget, GdkEvent *event, GcmCalibratePriv *priv)
170{
171 gcm_calib_confirm_quit (priv);
172 return FALSE;
173}
174
175/**
176 * gcm_calib_assistant_cancel_cb:
177 **/
178static void
179gcm_calib_assistant_cancel_cb (GtkAssistant *assistant, GcmCalibratePriv *priv)
180{
181 gcm_calib_confirm_quit (priv);
182}
183
184/**
185 * gcm_calib_assistant_close_cb:
186 **/
187static void
188gcm_calib_assistant_close_cb (GtkAssistant *assistant, GcmCalibratePriv *priv)
189{
190 g_application_release (G_APPLICATION (priv->application));
191}
192
193/**
194 * gcm_calib_play_sound:
195 **/
196static void
197gcm_calib_play_sound (GcmCalibratePriv *priv)
198{
199 /* play sound from the naming spec */
200 ca_context_play (ca_gtk_context_get (), 0,
201 CA_PROP_EVENT_ID, "complete",
202 /* TRANSLATORS: this is the application name for libcanberra */
203 CA_PROP_APPLICATION_NAME, _("GNOME Color Manager"),
204 /* TRANSLATORS: this is the sound description */
205 CA_PROP_EVENT_DESCRIPTION, _("Profiling completed"),
206 NULL);
207}
208
209
210/**
211 * gcm_calib_get_vbox_for_page:
212 **/
213static GtkWidget *
214gcm_calib_get_vbox_for_page (GcmCalibratePriv *priv,
215 GcmCalibratePage page)
216{
217 guint i;
218 GtkWidget *tmp;
219 GcmCalibratePage page_tmp;
220
221 for (i=0; i<priv->pages->len; i++) {
222 tmp = g_ptr_array_index (priv->pages, i);
223 page_tmp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tmp),
224 "GcmCalibrateMain::Index"));
225 if (page_tmp == page)
226 return tmp;
227 }
228 return NULL;
229}
230
231static wchar_t *
232utf8_to_wchar_t (const char *src)
233{
234 gsize len;
235 gsize converted;
236 wchar_t *buf = NULL;
237
238 len = mbstowcs (NULL, src, 0);
239 if (len == (gsize) -1) {
240 g_warning ("Invalid UTF-8 in string %s", src);
241 goto out;
242 }
243 len += 1;
244 buf = g_malloc (sizeof (wchar_t) * len);
245 converted = mbstowcs (buf, src, len - 1);
246 g_assert (converted != (gsize) -1);
247 buf[converted] = '\0';
248out:
249 return buf;
250}
251
252static cmsBool
253_cmsDictAddEntryAscii (cmsHANDLE dict,
254 const gchar *key,
255 const gchar *value)
256{
257 cmsBool ret = FALSE;
258 wchar_t *mb_key = NULL;
259 wchar_t *mb_value = NULL;
260
261 mb_key = utf8_to_wchar_t (key);
262 if (mb_key == NULL)
263 goto out;
264 mb_value = utf8_to_wchar_t (value);
265 if (mb_value == NULL)
266 goto out;
267 ret = cmsDictAddEntry (dict, mb_key, mb_value, NULL, NULL);
268out:
269 g_free (mb_key);
270 g_free (mb_value);
271 return ret;
272}
273
274static gboolean
275gcm_calib_set_extra_metadata (GcmCalibratePriv *priv,
276 const gchar *filename,
277 GError **error)
278{
279 cmsHANDLE dict = NULL;
280 cmsHPROFILE lcms_profile;
281 gboolean ret = TRUE;
282 gchar *data = NULL;
283 gchar *screen_brightness_str = NULL;
284 gsize len;
285 guint percentage;
286 CdSensor *sensor;
287
288 /* parse */
289 ret = g_file_get_contents (filename, &data, &len, error);
290 if (!ret)
291 goto out;
292 lcms_profile = cmsOpenProfileFromMem (data, len);
293 if (lcms_profile == NULL) {
294 g_set_error_literal (error, 1, 0,
295 "failed to open profile");
296 ret = FALSE;
297 goto out;
298 }
299
300 /* just create a new dict */
301 dict = cmsDictAlloc (NULL);
302 _cmsDictAddEntryAscii (dict,
303 CD_PROFILE_METADATA_CMF_PRODUCT,
304 PACKAGE_NAME);
305 _cmsDictAddEntryAscii (dict,
306 CD_PROFILE_METADATA_CMF_BINARY,
307 "gcm-calibrate");
308 _cmsDictAddEntryAscii (dict,
309 CD_PROFILE_METADATA_CMF_VERSION,
310 PACKAGE_VERSION);
311 _cmsDictAddEntryAscii (dict,
312 CD_PROFILE_METADATA_DATA_SOURCE,
313 CD_PROFILE_METADATA_DATA_SOURCE_CALIB);
314 sensor = gcm_calibrate_get_sensor (priv->calibrate);
315 if (sensor != NULL) {
316 _cmsDictAddEntryAscii (dict,
317 CD_PROFILE_METADATA_MEASUREMENT_DEVICE,
318 cd_sensor_kind_to_string (cd_sensor_get_kind (sensor)));
319 }
320 _cmsDictAddEntryAscii (dict,
321 CD_PROFILE_METADATA_MAPPING_DEVICE_ID,
322 cd_device_get_id (priv->device));
323
324 /* add the calibration brightness if an internal panel */
325 percentage = gcm_calibrate_get_screen_brightness (priv->calibrate);
326 if (percentage > 0) {
327 screen_brightness_str = g_strdup_printf ("%i", percentage);
328 _cmsDictAddEntryAscii (dict,
329 CD_PROFILE_METADATA_SCREEN_BRIGHTNESS,
330 screen_brightness_str);
331 }
332
333 /* just write dict */
334 ret = cmsWriteTag (lcms_profile, cmsSigMetaTag, dict);
335 if (!ret) {
336 g_set_error_literal (error, 1, 0,
337 "cannot write metadata");
338 goto out;
339 }
340
341 /* write profile id */
342 ret = cmsMD5computeID (lcms_profile);
343 if (!ret) {
344 g_set_error_literal (error, 1, 0,
345 "failed to write profile id");
346 goto out;
347 }
348
349 /* save, TODO: get error */
350 cmsSaveProfileToFile (lcms_profile, filename);
351 ret = TRUE;
352out:
353 g_free (screen_brightness_str);
354 g_free (data);
355 if (dict != NULL)
356 cmsDictFree (dict);
357 return ret;
358}
359
360/**
361 * gcm_calib_set_sensor_options_cb:
362 **/
363static void
364gcm_calib_set_sensor_options_cb (GObject *object,
365 GAsyncResult *res,
366 gpointer user_data)
367{
368 CdSensor *sensor = CD_SENSOR (object);
369 gboolean ret;
370 GError *error = NULL;
371
372 /* get return value */
373 ret = cd_sensor_set_options_finish (sensor, res, &error);
374 if (!ret) {
375 g_warning ("Failed to set sensor option: %s",
376 error->message);
377 g_error_free (error);
378 }
379}
380
381static void
382gcm_calib_set_sensor_options (GcmCalibratePriv *priv,
383 const gchar *filename)
384{
385 CdSensor *sensor;
386 gboolean ret;
387 gchar *data = NULL;
388 gchar *sha1 = NULL;
389 GError *error = NULL;
390 GHashTable *hash = NULL;
391 gsize len;
392
393 /* get ChSensor */
394 sensor = gcm_calibrate_get_sensor (priv->calibrate);
395 if (sensor == NULL)
396 goto out;
397
398 /* set the remote profile hash */
399 hash = g_hash_table_new_full (g_str_hash,
400 g_str_equal,
401 g_free,
402 (GDestroyNotify) g_variant_unref);
403 ret = g_file_get_contents (filename, &data, &len, &error);
404 if (!ret) {
405 g_warning ("Failed to get SHA1 hash: %s",
406 error->message);
407 g_error_free (error);
408 goto out;
409 }
410 sha1 = g_compute_checksum_for_data (G_CHECKSUM_SHA1,
411 (const guchar *) data,
412 len);
413 g_hash_table_insert (hash,
414 g_strdup ("remote-profile-hash"),
415 g_variant_ref_sink (g_variant_new_string (sha1)));
416 cd_sensor_set_options (sensor, hash, NULL,
417 gcm_calib_set_sensor_options_cb,
418 priv);
419out:
420 g_free (data);
421 g_free (sha1);
422 if (hash != NULL)
423 g_hash_table_unref (hash);
424}
425
426static gboolean
427gcm_calib_start_idle_cb (gpointer user_data)
428{
429 CdProfile *profile = NULL;
430 const gchar *filename;
431 gboolean ret;
432 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
433 GError *error = NULL;
434 GFile *file = NULL;
435 gint inhibit_cookie;
436 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
437 GtkWidget *vbox;
438
439 /* inhibit */
440 inhibit_cookie = gtk_application_inhibit (priv->application,
441 priv->main_window,
442 GTK_APPLICATION_INHIBIT_LOGOUT |
443 GTK_APPLICATION_INHIBIT_SWITCH |
444 GTK_APPLICATION_INHIBIT_SUSPEND |
445 GTK_APPLICATION_INHIBIT_IDLE,
446 "Calibration in progress");
447
448 /* actually do the action */
449 priv->started_calibration = TRUE;
450 ret = gcm_calibrate_device (priv->calibrate,
451 priv->device,
452 priv->main_window,
453 &error);
454 if (!ret) {
455 gcm_calibrate_set_title (priv->calibrate,
456 _("Failed to calibrate"),
457 GCM_CALIBRATE_UI_ERROR);
458 gcm_calibrate_set_message (priv->calibrate,
459 error->message,
460 GCM_CALIBRATE_UI_ERROR);
461 gcm_calibrate_set_image (priv->calibrate, NULL);
462
463 g_warning ("failed to calibrate: %s",
464 error->message);
465 g_error_free (error);
466
467 /* mark this box as the end */
468 vbox = gcm_calib_get_vbox_for_page (priv, GCM_CALIBRATE_PAGE_ACTION);
469 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
470 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
471 goto out;
472 }
473
474 /* get profile */
475 filename = gcm_calibrate_get_filename_result (priv->calibrate);
476 if (filename == NULL) {
477 g_warning ("failed to get filename from calibration");
478 goto out;
479 }
480
481 /* set some private properties */
482 ret = gcm_calib_set_extra_metadata (priv, filename, &error);
483 if (!ret) {
484 g_warning ("failed to set extra metadata: %s",
485 error->message);
486 g_error_free (error);
487 goto out;
488 }
489
490 /* inform the sensor about the last successful profile */
491 gcm_calib_set_sensor_options (priv, filename);
492
493 /* copy the ICC file to the proper location */
494 file = g_file_new_for_path (filename);
495 profile = cd_client_import_profile_sync (priv->client,
496 file,
497 priv->cancellable,
498 &error);
499 if (profile == NULL) {
500 g_warning ("failed to find calibration profile: %s",
501 error->message);
502 g_error_free (error);
503 goto out;
504 }
505 ret = cd_device_add_profile_sync (priv->device,
506 CD_DEVICE_RELATION_HARD,
507 profile,
508 priv->cancellable,
509 &error);
510 if (!ret) {
511 g_warning ("failed to add %s to %s: %s",
512 cd_profile_get_object_path (profile),
513 cd_device_get_object_path (priv->device),
514 error->message);
515 g_error_free (error);
516 goto out;
517 }
518
519 /* remove temporary file */
520 g_unlink (filename);
521
522 /* allow forward */
523 vbox = gcm_calib_get_vbox_for_page (priv,
524 GCM_CALIBRATE_PAGE_ACTION);
525 gtk_assistant_set_page_complete (assistant,
526 vbox, TRUE);
527
528 /* set to summary page */
529 gtk_assistant_set_current_page (assistant,
530 gtk_assistant_get_n_pages (assistant) - 1);
531out:
532 if (inhibit_cookie != 0) {
533 gtk_application_uninhibit (priv->application,
534 priv->inhibit_cookie);
535 }
536 if (profile != NULL)
537 g_object_unref (profile);
538 if (file != NULL)
539 g_object_unref (file);
540 return FALSE;
541}
542
543static gint
544gcm_calib_assistant_page_forward_cb (gint current_page, gpointer user_data)
545{
546 GtkWidget *vbox;
547 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
548
549 /* shouldn't happen... */
550 if (priv->current_page != GCM_CALIBRATE_PAGE_ACTION)
551 return current_page + 1;
552
553 if (!priv->has_pending_interaction)
554 return current_page;
555
556 /* continue calibration */
557 gcm_calibrate_interaction (priv->calibrate, GTK_RESPONSE_OK);
558 priv->has_pending_interaction = FALSE;
559
560 /* no longer allow forward */
561 vbox = gcm_calib_get_vbox_for_page (priv,
562 GCM_CALIBRATE_PAGE_ACTION);
563
564 gtk_assistant_set_page_complete (GTK_ASSISTANT (priv->main_window),
565 vbox, FALSE);
566 return current_page;
567}
568
569/**
570 * gcm_calib_assistant_prepare_cb:
571 **/
572static gboolean
573gcm_calib_assistant_prepare_cb (GtkAssistant *assistant,
574 GtkWidget *page_widget,
575 GcmCalibratePriv *priv)
576{
577 priv->current_page = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (page_widget),
578 "GcmCalibrateMain::Index"));
579 switch (priv->current_page) {
580 case GCM_CALIBRATE_PAGE_LAST:
581 gcm_calib_play_sound (priv);
582 break;
583 case GCM_CALIBRATE_PAGE_ACTION:
584 g_debug ("lights! camera! action!");
585 if (!priv->started_calibration)
586 g_idle_add (gcm_calib_start_idle_cb, priv);
587 break;
588 default:
589 break;
590 }
591
592 /* ensure we cancel argyllcms if the user clicks back */
593 if (priv->current_page != GCM_CALIBRATE_PAGE_ACTION &&
594 priv->started_calibration) {
595 gcm_calibrate_interaction (priv->calibrate,
596 GTK_RESPONSE_CANCEL);
597 priv->started_calibration = FALSE;
598 }
599
600 /* forward on the action page just unsticks the calibration */
601 if (priv->current_page == GCM_CALIBRATE_PAGE_ACTION) {
602 gtk_assistant_set_forward_page_func (assistant,
603 gcm_calib_assistant_page_forward_cb,
604 priv,
605 NULL);
606 } else {
607 gtk_assistant_set_forward_page_func (assistant,
608 NULL, NULL, NULL);
609 }
610
611 /* use the default on each page */
612 switch (priv->current_page) {
613 case GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS:
614 case GCM_CALIBRATE_PAGE_SENSOR:
615 case GCM_CALIBRATE_PAGE_ACTION:
616 break;
617 default:
618 gtk_assistant_set_page_complete (assistant, page_widget, TRUE);
619 break;
620 }
621 return FALSE;
622}
623
624/**
625 * gcm_calib_add_page_title:
626 **/
627static GtkWidget *
628gcm_calib_add_page_title (GcmCalibratePriv *priv, const gchar *text)
629{
630 GtkWidget *label;
631 GtkWidget *hbox;
632 GtkWidget *vbox;
633 gchar *markup;
634
635 markup = g_strdup_printf ("<span size=\"large\" font_weight=\"bold\">%s</span>", text);
636 label = gtk_label_new (NULL);
637 gtk_label_set_markup (GTK_LABEL (label), markup);
638
639 /* make left aligned */
640 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
641 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
642
643 /* header */
644 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
645 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
646
647 g_free (markup);
648 return vbox;
649}
650
651static gboolean
652gcm_calib_label_activate_link_cb (GtkLabel *label,
653 gchar *uri,
654 GcmCalibratePriv *priv)
655{
656 gboolean ret;
657 GError *error = NULL;
658 const gchar *argv[] = { BINDIR "/gnome-control-center color",
659 "color",
660 NULL };
661 ret = g_spawn_async (NULL,
662 (gchar **) argv,
663 NULL,
664 0,
665 NULL, NULL,
666 NULL,
667 &error);
668 if (!ret) {
669 g_warning ("failed to launch the control center: %s",
670 error->message);
671 g_error_free (error);
672 }
673 return ret;
674}
675
676/**
677 * gcm_calib_add_page_para:
678 **/
679static GtkWidget *
680gcm_calib_add_page_para (GtkWidget *vbox, const gchar *text)
681{
682 GtkWidget *label;
683 GtkWidget *hbox;
684
685 label = gtk_label_new (NULL);
686 g_signal_connect (label, "activate-link",
687 G_CALLBACK (gcm_calib_label_activate_link_cb),
688 NULL);
689 gtk_label_set_markup (GTK_LABEL (label), text);
690 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
691 gtk_label_set_width_chars (GTK_LABEL (label), 40);
692 gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f);
693
694 /* make left aligned */
695 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
696 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
697 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
698 return label;
699}
700
701/**
702 * gcm_calib_add_page_bullet:
703 **/
704static void
705gcm_calib_add_page_bullet (GtkWidget *vbox, const gchar *text)
706{
707 gchar *markup;
708 markup = g_strdup_printf ("• %s", text);
709 gcm_calib_add_page_para (vbox, markup);
710 g_free (markup);
711}
712
713/**
714 * gcm_calib_setup_page_intro:
715 **/
716static void
717gcm_calib_setup_page_intro (GcmCalibratePriv *priv)
718{
719 GtkWidget *vbox;
720 GtkWidget *content;
721 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
722
723 /* TRANSLATORS: this is intro page text */
724 switch (priv->device_kind) {
725 case CD_DEVICE_KIND_CAMERA:
726 case CD_DEVICE_KIND_WEBCAM:
727 /* TRANSLATORS: this is the page title */
728 vbox = gcm_calib_add_page_title (priv, _("Calibrate your camera"));
729 break;
730 case CD_DEVICE_KIND_DISPLAY:
731 /* TRANSLATORS: this is the page title */
732 vbox = gcm_calib_add_page_title (priv, _("Calibrate your display"));
733 break;
734 case CD_DEVICE_KIND_PRINTER:
735 /* TRANSLATORS: this is the page title */
736 vbox = gcm_calib_add_page_title (priv, _("Calibrate your printer"));
737 break;
738 default:
739 /* TRANSLATORS: this is the page title */
740 vbox = gcm_calib_add_page_title (priv, _("Calibrate your device"));
741 break;
742 }
743
744 /* main contents */
745 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
746 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
747
748 /* TRANSLATORS: this is intro page text */
749 switch (priv->device_kind) {
750 case CD_DEVICE_KIND_DISPLAY:
751 /* TRANSLATORS: this is the final intro page text */
752 gcm_calib_add_page_para (content, _("Any existing screen correction will be temporarily turned off and the brightness set to maximum."));
753 break;
754 default:
755 break;
756 }
757
758 /* TRANSLATORS: this is the final intro page text */
759 gcm_calib_add_page_para (content, _("You can cancel this process at any stage by pressing the cancel button."));
760
761 /* add to assistant */
762 gtk_assistant_append_page (assistant, vbox);
763 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_INTRO);
764 /* TRANSLATORS: this is the calibration wizard page title */
765 gtk_assistant_set_page_title (assistant, vbox, _("Introduction"));
766 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
767 g_ptr_array_add (priv->pages, vbox);
768 g_object_set_data (G_OBJECT (vbox),
769 "GcmCalibrateMain::Index",
770 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INTRO));
771
772 /* show page */
773 gtk_widget_show_all (vbox);
774}
775
776/**
777 * gcm_calibrate_is_livecd:
778 **/
779static gboolean
780gcm_calibrate_is_livecd (void)
781{
782#ifdef __linux__
783 gboolean ret;
784 gchar *data = NULL;
785 GError *error = NULL;
786
787 /* get the kernel commandline */
788 ret = g_file_get_contents ("/proc/cmdline", &data, NULL, &error);
789 if (!ret) {
790 g_warning ("failed to get kernel command line: %s",
791 error->message);
792 g_error_free (error);
793 goto out;
794 }
795 ret = (g_strstr_len (data, -1, "liveimg") != NULL ||
796 g_strstr_len (data, -1, "casper") != NULL);
797out:
798 g_free (data);
799 return ret;
800#else
801 return FALSE;
802#endif
803}
804
805/**
806 * gcm_calib_show_profile_button_clicked_cb:
807 **/
808static void
809gcm_calib_show_profile_button_clicked_cb (GtkButton *button,
810 GcmCalibratePriv *priv)
811{
812 const gchar *argv[] = { BINDIR "/nautilus", "", NULL };
813 gboolean ret;
814 gchar *path;
815 GError *error = NULL;
816
817 /* just hardcode nautilus to open the folder */
818 path = g_build_filename (g_get_user_data_dir (), "icc", NULL);
819 argv[1] = path;
820 ret = g_spawn_async (NULL,
821 (gchar **) argv,
822 NULL,
823 0,
824 NULL, NULL,
825 NULL,
826 &error);
827 if (!ret) {
828 g_warning ("failed to show profile: %s", error->message);
829 g_error_free (error);
830 goto out;
831 }
832out:
833 g_free (path);
834}
835
836/**
837 * gcm_calib_get_show_profile_button:
838 **/
839static GtkWidget *
840gcm_calib_get_show_profile_button (GcmCalibratePriv *priv)
841{
842 GtkStyleContext *context;
843 GtkWidget *button;
844 GtkWidget *image;
845 GtkWidget *label;
846 GtkWidget *vbox;
847
848 /* add button to show profile */
849 button = gtk_button_new ();
850 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
851 image = gtk_image_new_from_icon_name ("folder-publicshare-symbolic",
852 GTK_ICON_SIZE_DIALOG);
853
854 /* make image have a gray foreground */
855 context = gtk_widget_get_style_context (image);
856 gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
857
858 gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
859 label = gtk_label_new (_("Show File"));
860 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
861 gtk_container_add (GTK_CONTAINER (button), vbox);
862 gtk_widget_set_tooltip_text (button, _("Click here to show the profile"));
863 g_signal_connect (button, "clicked",
864 G_CALLBACK (gcm_calib_show_profile_button_clicked_cb),
865 priv);
866 gtk_container_set_border_width (GTK_CONTAINER (vbox), 15);
867 gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
868 gtk_widget_show_all (button);
869 return button;
870}
871
872/**
873 * gcm_calib_setup_page_summary:
874 **/
875static void
876gcm_calib_setup_page_summary (GcmCalibratePriv *priv)
877{
878 gboolean ret;
879 GtkWidget *vbox;
880 GtkWidget *content;
881 GtkWidget *image;
882 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
883
884 /* TRANSLATORS: this is the page title */
885 vbox = gcm_calib_add_page_title (priv, _("All done!"));
886
887 /* main contents */
888 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
889 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
890
891 switch (priv->device_kind) {
892 case CD_DEVICE_KIND_CAMERA:
893 case CD_DEVICE_KIND_WEBCAM:
894 /* TRANSLATORS: this is the final summary */
895 gcm_calib_add_page_para (content, _("The camera has been calibrated successfully."));
896 break;
897 case CD_DEVICE_KIND_DISPLAY:
898 /* TRANSLATORS: this is the final summary */
899 gcm_calib_add_page_para (content, _("The display has been calibrated successfully."));
900 break;
901 case CD_DEVICE_KIND_PRINTER:
902 /* TRANSLATORS: this is the final summary */
903 gcm_calib_add_page_para (content, _("The printer has been calibrated successfully."));
904 break;
905 default:
906 /* TRANSLATORS: this is the final summary */
907 gcm_calib_add_page_para (content, _("The device has been calibrated successfully."));
908 break;
909 }
910
911 /* only display the backlink if not launched from the control center itself */
912 if (priv->xid == 0) {
913 /* TRANSLATORS: this is the final summary */
914 gcm_calib_add_page_para (content, _("To view details about the new profile or to undo the calibration visit the <a href=\"control-center://color\">control center</a>."));
915 }
916
917 /* show the user the profile to copy off the live system */
918 ret = gcm_calibrate_is_livecd ();
919 if (ret) {
920 /* show button to copy profile */
921 image = gcm_calib_get_show_profile_button (priv);
922 gtk_box_pack_start (GTK_BOX (content), image, FALSE, FALSE, 30);
923 gcm_calib_add_page_para (content, _("You can use the profile with <a href=\"import-linux\">Linux</a>, <a href=\"import-osx\">Apple OS X</a> and <a href=\"import-windows\">Microsoft Windows</a> systems."));
924 } else {
925 /* add image for success */
926 image = gtk_image_new ();
927 gtk_image_set_from_icon_name (GTK_IMAGE (image), "face-smile", GTK_ICON_SIZE_DIALOG);
928 gtk_box_pack_start (GTK_BOX (content), image, FALSE, FALSE, 0);
929 }
930
931 /* add to assistant */
932 gtk_assistant_append_page (assistant, vbox);
933 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
934 /* TRANSLATORS: this is the calibration wizard page title */
935 gtk_assistant_set_page_title (assistant, vbox, _("Summary"));
936 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
937 g_ptr_array_add (priv->pages, vbox);
938 g_object_set_data (G_OBJECT (vbox),
939 "GcmCalibrateMain::Index",
940 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_LAST));
941
942 /* show page */
943 gtk_widget_show_all (vbox);
944}
945
946/**
947 * gcm_calib_setup_page_action:
948 **/
949static void
950gcm_calib_setup_page_action (GcmCalibratePriv *priv)
951{
952 GtkWidget *vbox;
953 GtkWidget *content;
954 GList *list;
955 GList *list2;
956 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
957
958 /* TRANSLATORS: this is the page title */
959 vbox = gcm_calib_add_page_title (priv, _("Performing calibration"));
960
961 /* grab title */
962 list = gtk_container_get_children (GTK_CONTAINER (vbox));
963 list2 = gtk_container_get_children (GTK_CONTAINER (list->data));
964 priv->action_title = list2->data;
965 g_list_free (list);
966 g_list_free (list2);
967
968 /* main contents */
969 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
970 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
971
972 priv->action_message = gcm_calib_add_page_para (content, _("Calibration is about to start"));
973
974 /* add image for success */
975 priv->action_image = gtk_image_new ();
976 gtk_image_set_from_icon_name (GTK_IMAGE (priv->action_image), "face-frown", GTK_ICON_SIZE_DIALOG);
977 gtk_box_pack_start (GTK_BOX (content), priv->action_image, FALSE, FALSE, 0);
978
979 /* add progress marker */
980 priv->action_progress = gtk_progress_bar_new ();
981 gtk_box_pack_start (GTK_BOX (content), priv->action_progress, FALSE, FALSE, 0);
982
983 /* add content widget */
984 gcm_calibrate_set_content_widget (priv->calibrate, vbox);
985
986 /* add to assistant */
987 gtk_assistant_append_page (assistant, vbox);
988 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
989 /* TRANSLATORS: this is the calibration wizard page title */
990 gtk_assistant_set_page_title (assistant, vbox, _("Action"));
991 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
992 g_ptr_array_add (priv->pages, vbox);
993 g_object_set_data (G_OBJECT (vbox),
994 "GcmCalibrateMain::Index",
995 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_ACTION));
996
997 /* show page */
998 gtk_widget_show_all (vbox);
999 gtk_widget_hide (priv->action_image);
1000}
1001
1002/**
1003 * gcm_calib_setup_page_display_configure_wait:
1004 **/
1005static void
1006gcm_calib_setup_page_display_configure_wait (GcmCalibratePriv *priv)
1007{
1008 GtkWidget *vbox;
1009 GtkWidget *content;
1010 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1011
1012 /* TRANSLATORS: dialog message, preface */
1013 vbox = gcm_calib_add_page_title (priv, _("Calibration checklist"));
1014
1015 /* main contents */
1016 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1017 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1018
1019 /* TRANSLATORS: this is intro page text */
1020 gcm_calib_add_page_para (content, _("Before calibrating the display, it is recommended to configure your display with the following settings to get optimal results."));
1021
1022 /* TRANSLATORS: dialog message, preface */
1023if(0) gcm_calib_add_page_para (content, _("You may want to consult the owner's manual for your display on how to achieve these settings."));
1024
1025 /* TRANSLATORS: dialog message, bullet item */
1026if(0) gcm_calib_add_page_bullet (content, _("Reset your display to the factory defaults."));
1027
1028 /* TRANSLATORS: dialog message, bullet item */
1029if(0) gcm_calib_add_page_bullet (content, _("Disable dynamic contrast if your display has this feature."));
1030
1031 /* TRANSLATORS: dialog message, bullet item */
1032if(0) gcm_calib_add_page_bullet (content, _("Configure your display with custom color settings and ensure the RGB channels are set to the same values."));
1033
1034 /* TRANSLATORS: dialog message, addition to bullet item */
1035if(0) gcm_calib_add_page_para (content, _("If custom color is not available then use a 6500K color temperature."));
1036
1037 /* TRANSLATORS: dialog message, bullet item */
1038if(0) gcm_calib_add_page_bullet (content, _("Adjust the display brightness to a comfortable level for prolonged viewing."));
1039
1040 gcm_calib_add_page_para (content, "");
1041
1042 /* TRANSLATORS: dialog message, suffix */
1043 gcm_calib_add_page_para (content, _("For best results, the display should have been powered for at least 15 minutes before starting the calibration."));
1044
1045 /* add to assistant */
1046 gtk_assistant_append_page (assistant, vbox);
1047 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1048 /* TRANSLATORS: this is the calibration wizard page title */
1049 gtk_assistant_set_page_title (assistant, vbox, _("Check Settings"));
1050 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1051 g_ptr_array_add (priv->pages, vbox);
1052 g_object_set_data (G_OBJECT (vbox),
1053 "GcmCalibrateMain::Index",
1054 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_CONFIG));
1055
1056 /* show page */
1057 gtk_widget_show_all (vbox);
1058}
1059
1060/**
1061 * gcm_calib_button_clicked_install_argyllcms_cb:
1062 **/
1063static void
1064gcm_calib_button_clicked_install_argyllcms_cb (GtkButton *button, GcmCalibratePriv *priv)
1065{
1066 gboolean ret;
1067 GtkWidget *vbox;
1068 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1069
1070 ret = gcm_utils_install_package (GCM_PREFS_PACKAGE_NAME_ARGYLLCMS,
1071 priv->main_window);
1072 /* we can continue now */
1073 if (TRUE || ret) {
1074 vbox = gcm_calib_get_vbox_for_page (priv,
1075 GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS);
1076 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1077 gtk_assistant_next_page (assistant);
1078
1079 /* we ddn't need to re-install now */
1080 gtk_widget_hide (vbox);
1081 }
1082}
1083
1084/**
1085 * gcm_calib_setup_page_install_argyllcms:
1086 **/
1087static void
1088gcm_calib_setup_page_install_argyllcms (GcmCalibratePriv *priv)
1089{
1090 GtkWidget *vbox;
1091 GtkWidget *content;
1092 GtkWidget *button;
1093 GString *string;
1094 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1095
1096 string = g_string_new ("");
1097
1098 /* TRANSLATORS: dialog message saying the argyllcms is not installed */
1099 g_string_append_printf (string, "%s\n",
1100 _("Calibration and profiling software is not installed."));
1101 /* TRANSLATORS: dialog message saying the color targets are not installed */
1102 g_string_append_printf (string, "%s",
1103 _("These tools are required to build color profiles for devices."));
1104
1105 /* TRANSLATORS: this is the page title */
1106 vbox = gcm_calib_add_page_title (priv, _("More software is required!"));
1107
1108 /* main contents */
1109 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1110 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1111
1112 /* TRANSLATORS: this is intro page text */
1113 gcm_calib_add_page_para (content, string->str);
1114
1115 button = gtk_button_new_with_label (_("Install required software"));
1116 g_signal_connect (button, "clicked",
1117 G_CALLBACK (gcm_calib_button_clicked_install_argyllcms_cb),
1118 priv);
1119 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1120
1121 /* add to assistant */
1122 gtk_assistant_append_page (assistant, vbox);
1123 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1124 /* TRANSLATORS: this is the calibration wizard page title */
1125 gtk_assistant_set_page_title (assistant, vbox, _("Install Tools"));
1126 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1127 g_ptr_array_add (priv->pages, vbox);
1128 g_object_set_data (G_OBJECT (vbox),
1129 "GcmCalibrateMain::Index",
1130 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS));
1131 g_string_free (string, TRUE);
1132
1133 /* show page */
1134 gtk_widget_show_all (vbox);
1135}
1136
1137/**
1138 * gcm_calib_button_clicked_install_targets_cb:
1139 **/
1140static void
1141gcm_calib_button_clicked_install_targets_cb (GtkButton *button, GcmCalibratePriv *priv)
1142{
1143 gboolean ret;
1144 GtkWidget *vbox;
1145 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1146
1147 ret = gcm_utils_install_package (GCM_PREFS_PACKAGE_NAME_SHARED_COLOR_TARGETS,
1148 priv->main_window);
1149 /* we can continue now */
1150 if (ret) {
1151 vbox = gcm_calib_get_vbox_for_page (priv,
1152 GCM_CALIBRATE_PAGE_INSTALL_TARGETS);
1153 gtk_assistant_next_page (assistant);
1154
1155 /* we ddn't need to re-install now */
1156 gtk_widget_hide (vbox);
1157 }
1158}
1159
1160/**
1161 * gcm_calib_setup_page_install_targets:
1162 **/
1163static void
1164gcm_calib_setup_page_install_targets (GcmCalibratePriv *priv)
1165{
1166 GtkWidget *vbox;
1167 GtkWidget *content;
1168 GtkWidget *button;
1169 GString *string;
1170 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1171
1172 string = g_string_new ("");
1173
1174 /* TRANSLATORS: dialog message saying the color targets are not installed */
1175 g_string_append_printf (string, "%s\n", _("Common color target files are not installed on this computer."));
1176 /* TRANSLATORS: dialog message saying the color targets are not installed */
1177 g_string_append_printf (string, "%s\n\n", _("Color target files are needed to convert the image to a color profile."));
1178 /* TRANSLATORS: dialog message, asking if it's okay to install them */
1179 g_string_append_printf (string, "%s\n\n", _("Do you want them to be installed?"));
1180 /* TRANSLATORS: dialog message, if the user has the target file on a CDROM then there's no need for this package */
1181 g_string_append_printf (string, "%s", _("If you already have the correct file, you can skip this step."));
1182
1183 /* TRANSLATORS: this is the page title */
1184 vbox = gcm_calib_add_page_title (priv, _("Optional data files available"));
1185
1186 /* main contents */
1187 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1188 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1189
1190 /* TRANSLATORS: this is intro page text */
1191 gcm_calib_add_page_para (content, string->str);
1192
1193 button = gtk_button_new_with_label (_("Install Now"));
1194 g_signal_connect (button, "clicked",
1195 G_CALLBACK (gcm_calib_button_clicked_install_targets_cb),
1196 priv);
1197 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1198
1199 /* add to assistant */
1200 gtk_assistant_append_page (assistant, vbox);
1201 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1202 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1203 /* TRANSLATORS: this is the calibration wizard page title */
1204 gtk_assistant_set_page_title (assistant, vbox, _("Install Targets"));
1205 g_ptr_array_add (priv->pages, vbox);
1206 g_object_set_data (G_OBJECT (vbox),
1207 "GcmCalibrateMain::Index",
1208 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INSTALL_TARGETS));
1209 g_string_free (string, TRUE);
1210
1211 /* show page */
1212 gtk_widget_show_all (vbox);
1213}
1214
1215
1216/**
1217 * gcm_calib_reference_kind_to_localised_string:
1218 **/
1219static const gchar *
1220gcm_calib_reference_kind_to_localised_string (GcmCalibrateReferenceKind kind)
1221{
1222 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DIGITAL_TARGET_3) {
1223 /* TRANSLATORS: this is probably a brand name */
1224 return _("CMP Digital Target 3");
1225 }
1226 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DT_003) {
1227 /* TRANSLATORS: this is probably a brand name */
1228 return _("CMP DT 003");
1229 }
1230 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER) {
1231 /* TRANSLATORS: this is probably a brand name */
1232 return _("ColorChecker");
1233 }
1234 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_DC) {
1235 /* TRANSLATORS: this is probably a brand name */
1236 return _("ColorChecker DC");
1237 }
1238 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_SG) {
1239 /* TRANSLATORS: this is probably a brand name */
1240 return _("ColorChecker SG");
1241 }
1242 if (kind == GCM_CALIBRATE_REFERENCE_KIND_HUTCHCOLOR) {
1243 /* TRANSLATORS: this is probably a brand name */
1244 return _("Hutchcolor");
1245 }
1246 if (kind == GCM_CALIBRATE_REFERENCE_KIND_I1_RGB_SCAN_1_4) {
1247 /* TRANSLATORS: this is probably a brand name */
1248 return _("i1 RGB Scan 1.4");
1249 }
1250 if (kind == GCM_CALIBRATE_REFERENCE_KIND_IT8) {
1251 /* TRANSLATORS: this is probably a brand name */
1252 return _("IT8.7/2");
1253 }
1254 if (kind == GCM_CALIBRATE_REFERENCE_KIND_LASER_SOFT_DC_PRO) {
1255 /* TRANSLATORS: this is probably a brand name */
1256 return _("Laser Soft DC Pro");
1257 }
1258 if (kind == GCM_CALIBRATE_REFERENCE_KIND_QPCARD_201) {
1259 /* TRANSLATORS: this is probably a brand name */
1260 return _("QPcard 201");
1261 }
1262 return NULL;
1263}
1264
1265/**
1266 * gcm_calib_reference_kind_to_image_filename:
1267 **/
1268static const gchar *
1269gcm_calib_reference_kind_to_image_filename (GcmCalibrateReferenceKind kind)
1270{
1271 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DIGITAL_TARGET_3)
1272 return "CMP-DigitalTarget3.png";
1273 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DT_003)
1274 return "CMP_DT_003.png";
1275 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER)
1276 return "ColorChecker24.png";
1277 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_DC)
1278 return "ColorCheckerDC.png";
1279 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_SG)
1280 return "ColorCheckerSG.png";
1281 if (kind == GCM_CALIBRATE_REFERENCE_KIND_HUTCHCOLOR)
1282 return NULL;
1283 if (kind == GCM_CALIBRATE_REFERENCE_KIND_I1_RGB_SCAN_1_4)
1284 return "i1_RGB_Scan_14.png";
1285 if (kind == GCM_CALIBRATE_REFERENCE_KIND_IT8)
1286 return "IT872.png";
1287 if (kind == GCM_CALIBRATE_REFERENCE_KIND_LASER_SOFT_DC_PRO)
1288 return "LaserSoftDCPro.png";
1289 if (kind == GCM_CALIBRATE_REFERENCE_KIND_QPCARD_201)
1290 return "QPcard_201.png";
1291 return NULL;
1292}
1293
1294/**
1295 * gcm_calib_reference_kind_combobox_cb:
1296 **/
1297static void
1298gcm_calib_reference_kind_combobox_cb (GtkComboBox *combo_box,
1299 GcmCalibratePriv *priv)
1300{
1301 const gchar *filename;
1302 gchar *path;
1303 GcmCalibrateReferenceKind reference_kind;
1304
1305 /* not sorted so we can just use the index */
1306 reference_kind = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
1307 g_object_set (priv->calibrate,
1308 "reference-kind", reference_kind,
1309 NULL);
1310 filename = gcm_calib_reference_kind_to_image_filename (reference_kind);
1311
1312 /* fallback */
1313 if (filename == NULL)
1314 filename = "unknown.png";
1315
1316 path = g_build_filename (GCM_DATA, "targets", filename, NULL);
1317 gtk_image_set_from_file (GTK_IMAGE (priv->reference_preview), path);
1318 g_free (path);
1319}
1320
1321/**
1322 * gcm_calib_setup_page_target_kind:
1323 **/
1324static void
1325gcm_calib_setup_page_target_kind (GcmCalibratePriv *priv)
1326{
1327 GtkWidget *vbox;
1328 GtkWidget *content;
1329 GtkWidget *combo;
1330 GString *string;
1331 guint i;
1332 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1333
1334 string = g_string_new ("");
1335
1336 /* TRANSLATORS: dialog message, preface. A calibration target looks like
1337 * this: http://www.colorreference.de/targets/target.jpg */
1338 g_string_append_printf (string, "%s\n", _("Before profiling the device, you have to manually capture an image of a calibration target and save it as a TIFF image file."));
1339
1340 /* scanner specific options */
1341 if (priv->device_kind == CD_DEVICE_KIND_SCANNER) {
1342 /* TRANSLATORS: dialog message, preface */
1343 g_string_append_printf (string, "%s\n", _("Ensure that the contrast and brightness are not changed and color correction profiles have not been applied."));
1344
1345 /* TRANSLATORS: dialog message, suffix */
1346 g_string_append_printf (string, "%s\n", _("The device sensor should have been cleaned prior to scanning and the output file resolution should be at least 200dpi."));
1347 }
1348
1349 /* camera specific options */
1350 if (priv->device_kind == CD_DEVICE_KIND_CAMERA) {
1351 /* TRANSLATORS: dialog message, preface */
1352 g_string_append_printf (string, "%s\n", _("Ensure that the white-balance has not been modified by the camera and that the lens is clean."));
1353 }
1354
1355 /* TRANSLATORS: this is the message body for the chart selection */
1356 g_string_append_printf (string, "\n%s", _("Please select the calibration target type."));
1357
1358 /* TRANSLATORS: this is the page title */
1359 vbox = gcm_calib_add_page_title (priv, _("What target type do you have?"));
1360
1361 /* main contents */
1362 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1363 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1364
1365 /* TRANSLATORS: this is intro page text */
1366 gcm_calib_add_page_para (content, string->str);
1367
1368 /* pack in a preview image */
1369 priv->reference_preview = gtk_image_new ();
1370 gtk_box_pack_start (GTK_BOX (vbox), priv->reference_preview, FALSE, FALSE, 0);
1371
1372 combo = gtk_combo_box_text_new ();
1373 for (i=0; i<GCM_CALIBRATE_REFERENCE_KIND_UNKNOWN; i++) {
1374 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo),
1375 gcm_calib_reference_kind_to_localised_string (i));
1376 }
1377 g_signal_connect (combo, "changed",
1378 G_CALLBACK (gcm_calib_reference_kind_combobox_cb),
1379 priv);
1380
1381 /* use IT8 by default */
1382 gtk_combo_box_set_active (GTK_COMBO_BOX (combo), GCM_CALIBRATE_REFERENCE_KIND_IT8);
1383
1384 gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
1385
1386 /* add to assistant */
1387 gtk_assistant_append_page (assistant, vbox);
1388 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1389 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1390 /* TRANSLATORS: this is the calibration wizard page title */
1391 gtk_assistant_set_page_title (assistant, vbox, _("Select Target"));
1392 g_ptr_array_add (priv->pages, vbox);
1393 g_object_set_data (G_OBJECT (vbox),
1394 "GcmCalibrateMain::Index",
1395 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_TARGET_KIND));
1396 g_string_free (string, TRUE);
1397
1398 /* show page */
1399 gtk_widget_show_all (vbox);
1400}
1401
1402static void
1403gcm_calib_display_kind_toggled_cb (GtkToggleButton *togglebutton,
1404 GcmCalibratePriv *priv)
1405{
1406 GcmCalibrateDisplayKind display_kind;
1407
1408 if (!gtk_toggle_button_get_active (togglebutton))
1409 return;
1410 display_kind = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1411 "GcmCalib::display-kind"));
1412 g_object_set (priv->calibrate,
1413 "display-kind", display_kind,
1414 NULL);
1415}
1416
1417/**
1418 * gcm_calib_setup_page_display_kind:
1419 **/
1420static void
1421gcm_calib_setup_page_display_kind (GcmCalibratePriv *priv)
1422{
1423 GtkWidget *vbox;
1424 GtkWidget *content;
1425 GtkWidget *widget;
1426 GSList *list;
1427 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1428
1429 /* TRANSLATORS: this is the page title */
1430 vbox = gcm_calib_add_page_title (priv, _("Choose your display type"));
1431
1432 /* main contents */
1433 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1434 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1435
1436 /* TRANSLATORS: this is intro page text */
1437 gcm_calib_add_page_para (content, _("Select the monitor type that is attached to your computer."));
1438
1439 widget = gtk_radio_button_new_with_label (NULL, _("LCD (CCFL backlight)"));
1440 g_object_set_data (G_OBJECT (widget),
1441 "GcmCalib::display-kind",
1442 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD_CCFL));
1443 g_signal_connect (widget, "toggled",
1444 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1445 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1446
1447 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1448 widget = gtk_radio_button_new_with_label (list, _("LCD (White LED backlight)"));
1449 g_object_set_data (G_OBJECT (widget),
1450 "GcmCalib::display-kind",
1451 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD_LED_WHITE));
1452 g_signal_connect (widget, "toggled",
1453 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1454 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1455
1456 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1457 widget = gtk_radio_button_new_with_label (list, _("LCD (RGB LED backlight)"));
1458 g_object_set_data (G_OBJECT (widget),
1459 "GcmCalib::display-kind",
1460 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD_LED_RGB));
1461 g_signal_connect (widget, "toggled",
1462 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1463 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1464
1465 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1466 widget = gtk_radio_button_new_with_label (list, _("LCD (Wide Gamut RGB LED backlight)"));
1467 g_object_set_data (G_OBJECT (widget),
1468 "GcmCalib::display-kind",
1469 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD_LED_RGB_WIDE));
1470 g_signal_connect (widget, "toggled",
1471 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1472 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1473
1474 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1475 widget = gtk_radio_button_new_with_label (list, _("LCD (Wide Gamut CCFL backlight)"));
1476 g_object_set_data (G_OBJECT (widget),
1477 "GcmCalib::display-kind",
1478 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD_CCFL_WIDE));
1479 g_signal_connect (widget, "toggled",
1480 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1481 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1482
1483 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1484 widget = gtk_radio_button_new_with_label (list, _("CRT"));
1485 g_object_set_data (G_OBJECT (widget),
1486 "GcmCalib::display-kind",
1487 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_CRT));
1488 g_signal_connect (widget, "toggled",
1489 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1490 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1491
1492 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1493 widget = gtk_radio_button_new_with_label (list, _("Plasma"));
1494 g_object_set_data (G_OBJECT (widget),
1495 "GcmCalib::display-kind",
1496 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_CRT));
1497 g_signal_connect (widget, "toggled",
1498 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1499 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1500
1501 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1502 widget = gtk_radio_button_new_with_label (list, _("Projector"));
1503 g_object_set_data (G_OBJECT (widget),
1504 "GcmCalib::display-kind",
1505 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_PROJECTOR));
1506 g_signal_connect (widget, "toggled",
1507 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1508 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1509
1510 /* add to assistant */
1511 gtk_assistant_append_page (assistant, vbox);
1512 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1513 /* TRANSLATORS: this is the calibration wizard page title */
1514 gtk_assistant_set_page_title (assistant, vbox, _("Choose Display Type"));
1515 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1516 g_ptr_array_add (priv->pages, vbox);
1517 g_object_set_data (G_OBJECT (vbox),
1518 "GcmCalibrateMain::Index",
1519 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_KIND));
1520
1521 /* show page */
1522 gtk_widget_show_all (vbox);
1523}
1524
1525static void
1526gcm_calib_display_temp_toggled_cb (GtkToggleButton *togglebutton,
1527 GcmCalibratePriv *priv)
1528{
1529 guint display_temp;
1530 if (!gtk_toggle_button_get_active (togglebutton))
1531 return;
1532 display_temp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1533 "GcmCalib::display-temp"));
1534 g_object_set (priv->calibrate,
1535 "target-whitepoint", display_temp,
1536 NULL);
1537}
1538
1539/**
1540 * gcm_calib_setup_page_display_temp:
1541 **/
1542static void
1543gcm_calib_setup_page_display_temp (GcmCalibratePriv *priv)
1544{
1545 GtkWidget *vbox;
1546 GtkWidget *content;
1547 GtkWidget *widget;
1548 GSList *list;
1549 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1550
1551 /* TRANSLATORS: this is the page title */
1552 vbox = gcm_calib_add_page_title (priv, _("Choose your display target white point"));
1553
1554 /* main contents */
1555 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1556 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1557
1558 /* TRANSLATORS: this is intro page text */
1559 gcm_calib_add_page_para (content, _("Most displays should be calibrated to a CIE D65 illuminant for general usage."));
1560
1561 widget = gtk_radio_button_new_with_label (NULL, _("CIE D50 (Printing and publishing)"));
1562 g_object_set_data (G_OBJECT (widget),
1563 "GcmCalib::display-temp",
1564 GUINT_TO_POINTER (5000));
1565 g_signal_connect (widget, "toggled",
1566 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1567 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1568
1569 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1570 widget = gtk_radio_button_new_with_label (list, _("CIE D55"));
1571 g_object_set_data (G_OBJECT (widget),
1572 "GcmCalib::display-temp",
1573 GUINT_TO_POINTER (5500));
1574 g_signal_connect (widget, "toggled",
1575 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1576 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1577
1578 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1579 widget = gtk_radio_button_new_with_label (list, _("CIE D65 (Photography and graphics)"));
1580 g_object_set_data (G_OBJECT (widget),
1581 "GcmCalib::display-temp",
1582 GUINT_TO_POINTER (6500));
1583 g_signal_connect (widget, "toggled",
1584 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1585 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1586 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
1587
1588 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1589 widget = gtk_radio_button_new_with_label (list, _("CIE D75"));
1590 g_object_set_data (G_OBJECT (widget),
1591 "GcmCalib::display-temp",
1592 GUINT_TO_POINTER (7500));
1593 g_signal_connect (widget, "toggled",
1594 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1595 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1596
1597 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1598 widget = gtk_radio_button_new_with_label (list, _("Native (Already set manually)"));
1599 g_object_set_data (G_OBJECT (widget),
1600 "GcmCalib::display-temp",
1601 GUINT_TO_POINTER (0));
1602 g_signal_connect (widget, "toggled",
1603 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1604 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1605
1606 /* add to assistant */
1607 gtk_assistant_append_page (assistant, vbox);
1608 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1609 /* TRANSLATORS: this is the calibration wizard page title */
1610 gtk_assistant_set_page_title (assistant, vbox, _("Choose Display Whitepoint"));
1611 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1612 g_ptr_array_add (priv->pages, vbox);
1613 g_object_set_data (G_OBJECT (vbox),
1614 "GcmCalibrateMain::Index",
1615 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE));
1616
1617 /* show page */
1618 gtk_widget_show_all (vbox);
1619}
1620
1621static void
1622gcm_calib_print_kind_toggled_cb (GtkToggleButton *togglebutton,
1623 GcmCalibratePriv *priv)
1624{
1625 GcmCalibratePrintKind print_kind;
1626 if (!gtk_toggle_button_get_active (togglebutton))
1627 return;
1628 print_kind = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1629 "GcmCalib::print-kind"));
1630 g_object_set (priv->calibrate,
1631 "print-kind", print_kind,
1632 NULL);
1633}
1634
1635/**
1636 * gcm_calib_setup_page_print_kind:
1637 **/
1638static void
1639gcm_calib_setup_page_print_kind (GcmCalibratePriv *priv)
1640{
1641 GtkWidget *vbox;
1642 GtkWidget *content;
1643 GtkWidget *widget;
1644 GSList *list;
1645 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1646
1647 /* TRANSLATORS: this is the page title */
1648 vbox = gcm_calib_add_page_title (priv, _("Choose profiling mode"));
1649
1650 /* main contents */
1651 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1652 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1653
1654 /* TRANSLATORS: this is intro page text */
1655 gcm_calib_add_page_para (content, _("Please indicate if you want to profile a local printer, generate some test patches, or profile using existing test patches."));
1656
1657 widget = gtk_radio_button_new_with_label (NULL, "Local printer");
1658 g_object_set_data (G_OBJECT (widget),
1659 "GcmCalib::print-kind",
1660 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_LOCAL));
1661 g_signal_connect (widget, "toggled",
1662 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1663 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1664
1665 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1666 widget = gtk_radio_button_new_with_label (list, "Generate patches for remote printer");
1667 g_object_set_data (G_OBJECT (widget),
1668 "GcmCalib::print-kind",
1669 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_GENERATE));
1670 g_signal_connect (widget, "toggled",
1671 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1672 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1673
1674 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1675 widget = gtk_radio_button_new_with_label (list, "Generate profile from existing test patches");
1676 g_object_set_data (G_OBJECT (widget),
1677 "GcmCalib::print-kind",
1678 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_ANALYZE));
1679 g_signal_connect (widget, "toggled",
1680 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1681 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1682
1683 /* sync the default */
1684 g_object_set (priv->calibrate,
1685 "print-kind", GCM_CALIBRATE_PRINT_KIND_LOCAL,
1686 NULL);
1687
1688 /* add to assistant */
1689 gtk_assistant_append_page (assistant, vbox);
1690 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1691 /* TRANSLATORS: this is the calibration wizard page title */
1692 gtk_assistant_set_page_title (assistant, vbox, _("Calibration Mode"));
1693 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1694 g_ptr_array_add (priv->pages, vbox);
1695 g_object_set_data (G_OBJECT (vbox),
1696 "GcmCalibrateMain::Index",
1697 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_PRINT_KIND));
1698
1699 /* show page */
1700 gtk_widget_show_all (vbox);
1701}
1702
1703static void
1704gcm_calib_precision_toggled_cb (GtkToggleButton *togglebutton,
1705 GcmCalibratePriv *priv)
1706{
1707 GcmCalibratePrecision precision;
1708 if (!gtk_toggle_button_get_active (togglebutton))
1709 return;
1710 precision = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1711 "GcmCalib::precision"));
1712 g_object_set (priv->calibrate,
1713 "precision", precision,
1714 NULL);
1715}
1716
1717/**
1718 * gcm_calib_setup_page_precision:
1719 **/
1720static void
1721gcm_calib_setup_page_precision (GcmCalibratePriv *priv)
1722{
1723 GtkWidget *vbox;
1724 GtkWidget *content;
1725 GtkWidget *widget;
1726 GSList *list;
1727 GString *labels[3];
1728 guint i;
1729 guint values_printer[] = { 6, 4, 2}; /* sheets */
1730 guint values_display[] = { 60, 40, 20}; /* minutes */
1731 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1732
1733 /* TRANSLATORS: this is the page title */
1734 vbox = gcm_calib_add_page_title (priv, _("Choose calibration quality"));
1735
1736 /* main contents */
1737 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1738 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1739
1740 /* TRANSLATORS: this is intro page text */
1741 gcm_calib_add_page_para (content, _("Higher quality calibration requires many color samples and more time."));
1742
1743#if 0
1744 /* TRANSLATORS: this is the message body for the chart selection */
1745 g_string_append (string, _("A higher precision profile provides higher accuracy in color matching but requires more time for reading the color patches."));
1746
1747 /* TRANSLATORS: this is the message body for the chart selection */
1748 g_string_append_printf (string, "\n%s", _("For a typical workflow, a normal precision profile is sufficient."));
1749
1750 /* printer specific options */
1751 if (priv->device_kind == CD_DEVICE_KIND_PRINTER) {
1752 /* TRANSLATORS: dialog message, preface */
1753 g_string_append_printf (string, "\n%s", _("The high precision profile also requires more paper and printer ink."));
1754 }
1755#endif
1756
1757 /* TRANSLATORS: radio options for calibration precision */
1758 labels[0] = g_string_new (_("Accurate"));
1759 labels[1] = g_string_new (_("Normal"));
1760 labels[2] = g_string_new (_("Quick"));
1761 switch (priv->device_kind) {
1762 case CD_DEVICE_KIND_PRINTER:
1763 for (i=0; i<3; i++) {
1764 g_string_append (labels[i], " ");
1765 /* TRANSLATORS: radio options for calibration precision */
1766 g_string_append_printf (labels[i], ngettext (
1767 "(about %i sheet of paper)",
1768 "(about %i sheets of paper)",
1769 values_printer[i]),
1770 values_printer[i]);
1771 }
1772 break;
1773 case CD_DEVICE_KIND_DISPLAY:
1774 for (i=0; i<3; i++) {
1775 g_string_append (labels[i], " ");
1776 /* TRANSLATORS: radio options for calibration precision */
1777 g_string_append_printf (labels[i], ngettext (
1778 "(about %i minute)",
1779 "(about %i minutes)",
1780 values_display[i]),
1781 values_display[i]);
1782 }
1783 break;
1784 default:
1785 break;
1786 }
1787
1788 widget = gtk_radio_button_new_with_label (NULL, labels[0]->str);
1789 g_object_set_data (G_OBJECT (widget),
1790 "GcmCalib::precision",
1791 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_LONG));
1792 g_signal_connect (widget, "toggled",
1793 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1794 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1795
1796 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1797 widget = gtk_radio_button_new_with_label (list, labels[1]->str);
1798 g_object_set_data (G_OBJECT (widget),
1799 "GcmCalib::precision",
1800 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_NORMAL));
1801 g_signal_connect (widget, "toggled",
1802 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1803 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1804
1805 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1806 widget = gtk_radio_button_new_with_label (list, labels[2]->str);
1807 g_object_set_data (G_OBJECT (widget),
1808 "GcmCalib::precision",
1809 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_SHORT));
1810 g_signal_connect (widget, "toggled",
1811 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1812 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1813 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
1814
1815 /* add to assistant */
1816 gtk_assistant_append_page (assistant, vbox);
1817 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1818 /* TRANSLATORS: this is the calibration wizard page title */
1819 gtk_assistant_set_page_title (assistant, vbox, _("Calibration Quality"));
1820 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1821 g_ptr_array_add (priv->pages, vbox);
1822 g_object_set_data (G_OBJECT (vbox),
1823 "GcmCalibrateMain::Index",
1824 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_PRECISION));
1825
1826 for (i=0; i<3; i++)
1827 g_string_free (labels[i], TRUE);
1828
1829 /* show page */
1830 gtk_widget_show_all (vbox);
1831}
1832
1833static void
1834gcm_calib_text_changed_cb (GtkEntry *entry,
1835 GcmCalibratePriv *priv)
1836{
1837 g_object_set (priv->calibrate,
1838 "description", gtk_entry_get_text (entry),
1839 NULL);
1840}
1841
1842/**
1843 * gcm_calib_setup_page_profile_title:
1844 **/
1845static void
1846gcm_calib_setup_page_profile_title (GcmCalibratePriv *priv)
1847{
1848 GtkWidget *vbox;
1849 GtkWidget *content;
1850 GtkWidget *widget;
1851 gchar *tmp = NULL;
1852 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1853
1854 /* TRANSLATORS: this is the page title */
1855 vbox = gcm_calib_add_page_title (priv, _("Profile title"));
1856
1857 /* main contents */
1858 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1859 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1860
1861 /* TRANSLATORS: this is intro page text */
1862 gcm_calib_add_page_para (content, _("Choose a title to identify the profile on your system."));
1863
1864 widget = gtk_entry_new ();
1865 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1866 gtk_entry_set_max_length (GTK_ENTRY (widget), 128);
1867
1868 /* set the current title */
1869 g_object_get (priv->calibrate,
1870 "description", &tmp,
1871 NULL);
1872 gtk_entry_set_text (GTK_ENTRY (widget), tmp);
1873 g_free (tmp);
1874
1875 /* watch for changes */
1876 g_signal_connect (GTK_EDITABLE (widget), "changed",
1877 G_CALLBACK (gcm_calib_text_changed_cb), priv);
1878
1879 /* add to assistant */
1880 gtk_assistant_append_page (assistant, vbox);
1881 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1882 /* TRANSLATORS: this is the calibration wizard page title */
1883 gtk_assistant_set_page_title (assistant, vbox, _("Profile Title"));
1884 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1885 g_ptr_array_add (priv->pages, vbox);
1886 g_object_set_data (G_OBJECT (vbox),
1887 "GcmCalibrateMain::Index",
1888 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_TITLE));
1889
1890 /* show page */
1891 gtk_widget_show_all (vbox);
1892}
1893
1894/**
1895 * gcm_calib_setup_page_sensor:
1896 **/
1897static void
1898gcm_calib_setup_page_sensor (GcmCalibratePriv *priv)
1899{
1900 GtkWidget *vbox;
1901 GtkWidget *content;
1902 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1903
1904 /* TRANSLATORS: this is the page title */
1905 vbox = gcm_calib_add_page_title (priv, _("Insert sensor hardware"));
1906
1907 /* main contents */
1908 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1909 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1910
1911 /* TRANSLATORS: this is intro page text */
1912 gcm_calib_add_page_para (content, _("You need to insert sensor hardware to continue."));
1913
1914 /* add to assistant */
1915 gtk_assistant_append_page (assistant, vbox);
1916 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1917 /* TRANSLATORS: this is the calibration wizard page title */
1918 gtk_assistant_set_page_title (assistant, vbox, _("Sensor Check"));
1919 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1920 g_ptr_array_add (priv->pages, vbox);
1921 g_object_set_data (G_OBJECT (vbox),
1922 "GcmCalibrateMain::Index",
1923 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_SENSOR));
1924
1925 /* show page */
1926 gtk_widget_show_all (vbox);
1927}
1928
1929/**
1930 * gcm_calib_setup_page_failure:
1931 **/
1932static void
1933gcm_calib_setup_page_failure (GcmCalibratePriv *priv)
1934{
1935 GtkWidget *vbox;
1936 GtkWidget *content;
1937 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1938
1939 /* TRANSLATORS: this is the page title */
1940 vbox = gcm_calib_add_page_title (priv, _("Failed to calibrate"));
1941
1942 /* main contents */
1943 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1944 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1945
1946 /* TRANSLATORS: this is intro page text */
1947 gcm_calib_add_page_para (content, _("The device could not be found. Ensure it is plugged in and turned on."));
1948
1949 /* add to assistant */
1950 gtk_assistant_append_page (assistant, vbox);
1951 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
1952 /* TRANSLATORS: this is the calibration wizard page title */
1953 gtk_assistant_set_page_title (assistant, vbox, _("Summary"));
1954 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1955 g_ptr_array_add (priv->pages, vbox);
1956 g_object_set_data (G_OBJECT (vbox),
1957 "GcmCalibrateMain::Index",
1958 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_FAILURE));
1959
1960 /* show page */
1961 gtk_widget_show_all (vbox);
1962}
1963
1964/**
1965 * gcm_calib_got_sensor:
1966 **/
1967static void
1968gcm_calib_got_sensor (GcmCalibratePriv *priv, CdSensor *sensor)
1969{
1970 gboolean is_lowend = FALSE;
1971 gboolean ret;
1972 GError *error = NULL;
1973 GtkWidget *vbox;
1974
1975 /* connect to sensor */
1976 ret = cd_sensor_connect_sync (sensor, NULL, &error);
1977 if (!ret) {
1978 g_warning ("failed to connect to sensor: %s",
1979 error->message);
1980 g_error_free (error);
1981 goto out;
1982 }
1983 gcm_calibrate_set_sensor (priv->calibrate, sensor);
1984
1985 /* hide the prompt for the user to insert a sensor */
1986 vbox = gcm_calib_get_vbox_for_page (priv,
1987 GCM_CALIBRATE_PAGE_SENSOR);
1988 gtk_widget_hide (vbox);
1989
1990 /* if the device is a simple colorimeter, hide the temperature
1991 * chooser. Only expensive accurate spectrophotometers are
1992 * accurate enough to do a good job without a color cast */
1993 if (cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_COLORHUG) {
1994 is_lowend = TRUE;
1995 }
1996 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
1997 vbox = gcm_calib_get_vbox_for_page (priv,
1998 GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE);
1999 gtk_widget_set_visible (vbox, !is_lowend);
2000 }
2001out:
2002 return;
2003}
2004
2005/**
2006 * gcm_calib_get_sensors_cb:
2007 **/
2008static void
2009gcm_calib_get_sensors_cb (GObject *object,
2010 GAsyncResult *res,
2011 gpointer user_data)
2012{
2013 CdClient *client = CD_CLIENT (object);
2014 CdSensor *sensor_tmp;
2015 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
2016 GError *error = NULL;
2017 GPtrArray *sensors;
2018
2019 /* get the result */
2020 sensors = cd_client_get_sensors_finish (client, res, &error);
2021 if (sensors == NULL) {
2022 g_warning ("failed to get sensors: %s",
2023 error->message);
2024 g_error_free (error);
2025 goto out;
2026 }
2027
2028 /* we've got a sensor */
2029 if (sensors->len != 0) {
2030 sensor_tmp = g_ptr_array_index (sensors, 0);
2031 gcm_calib_got_sensor (priv, sensor_tmp);
2032 }
2033out:
2034 if (sensors != NULL)
2035 g_ptr_array_unref (sensors);
2036}
2037
2038/**
2039 * gcm_calib_add_pages:
2040 **/
2041static void
2042gcm_calib_add_pages (GcmCalibratePriv *priv)
2043{
2044 gboolean ret;
2045 const gchar *xrandr_name;
2046
2047 /* device not found */
2048 if (priv->device_kind == CD_DEVICE_KIND_UNKNOWN) {
2049 gcm_calib_setup_page_failure (priv);
2050 gtk_widget_show_all (GTK_WIDGET (priv->main_window));
2051 return;
2052 }
2053
2054 gcm_calib_setup_page_intro (priv);
2055
2056 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY ||
2057 priv->device_kind == CD_DEVICE_KIND_PRINTER)
2058 gcm_calib_setup_page_sensor (priv);
2059
2060 /* find whether argyllcms is installed using a tool which should exist */
2061 ret = gcm_calibrate_get_enabled (priv->calibrate);
2062 if (!ret)
2063 gcm_calib_setup_page_install_argyllcms (priv);
2064
2065 xrandr_name = cd_device_get_metadata_item (priv->device,
2066 CD_DEVICE_METADATA_XRANDR_NAME);
2067 if (xrandr_name != NULL)
2068 priv->internal_lcd = gcm_utils_output_is_lcd_internal (xrandr_name);
2069 if (!priv->internal_lcd && priv->device_kind == CD_DEVICE_KIND_DISPLAY)
2070 gcm_calib_setup_page_display_configure_wait (priv);
2071
2072 gcm_calib_setup_page_precision (priv);
2073
2074 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2075 gcm_calib_setup_page_display_kind (priv);
2076 gcm_calib_setup_page_display_temp (priv);
2077 } else if (priv->device_kind == CD_DEVICE_KIND_PRINTER) {
2078 gcm_calib_setup_page_print_kind (priv);
2079 } else {
2080 gcm_calib_setup_page_target_kind (priv);
2081 ret = g_file_test ("/usr/share/shared-color-targets", G_FILE_TEST_IS_DIR);
2082 if (!ret)
2083 gcm_calib_setup_page_install_targets (priv);
2084 }
2085
2086 gcm_calib_setup_page_profile_title (priv);
2087 gcm_calib_setup_page_action (priv);
2088
2089 gcm_calib_setup_page_summary (priv);
2090
2091 /* see if we can hide the sensor check */
2092 cd_client_get_sensors (priv->client,
2093 NULL,
2094 gcm_calib_get_sensors_cb,
2095 priv);
2096}
2097
2098/**
2099 * gcm_calib_sensor_added_cb:
2100 **/
2101static void
2102gcm_calib_sensor_added_cb (CdClient *client, CdSensor *sensor, GcmCalibratePriv *priv)
2103{
2104 g_debug ("sensor inserted");
2105 gcm_calib_got_sensor (priv, sensor);
2106 gtk_assistant_next_page (GTK_ASSISTANT (priv->main_window));
2107}
2108
2109/**
2110 * gcm_calib_startup_cb:
2111 **/
2112static void
2113gcm_calib_startup_cb (GApplication *application, GcmCalibratePriv *priv)
2114{
2115 const gint window_width = 640;
2116 const gint window_height = 440;
2117
2118 const gchar *description;
2119 const gchar *manufacturer;
2120 const gchar *model;
2121 const gchar *native_device;
2122 const gchar *serial;
2123 gchar *copyright = NULL;
2124 gboolean ret;
2125 GDateTime *dt = NULL;
2126 GError *error = NULL;
2127
2128 /* add application specific icons to search path */
2129 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
2130 GCM_DATA G_DIR_SEPARATOR_S "icons");
2131
2132 /* connect to colord */
2133 priv->client = cd_client_new ();
2134 g_signal_connect (priv->client, "sensor-added",
2135 G_CALLBACK (gcm_calib_sensor_added_cb), priv);
2136 ret = cd_client_connect_sync (priv->client,
2137 NULL,
2138 &error);
2139 if (!ret) {
2140 g_warning ("failed to connect to colord: %s",
2141 error->message);
2142 g_error_free (error);
2143 goto out;
2144 }
2145
2146 /* show main UI */
2147 priv->main_window = GTK_WINDOW (gtk_assistant_new ());
2148 gtk_window_set_default_size (priv->main_window, window_width, window_height);
2149 gtk_window_set_resizable (priv->main_window, TRUE);
2150 gtk_window_set_title (priv->main_window, "");
2151 gtk_container_set_border_width (GTK_CONTAINER (priv->main_window), 12);
2152 g_signal_connect (priv->main_window, "delete_event",
2153 G_CALLBACK (gcm_calib_delete_event_cb), priv);
2154 g_signal_connect (priv->main_window, "close",
2155 G_CALLBACK (gcm_calib_assistant_close_cb), priv);
2156 g_signal_connect (priv->main_window, "cancel",
2157 G_CALLBACK (gcm_calib_assistant_cancel_cb), priv);
2158 g_signal_connect (priv->main_window, "prepare",
2159 G_CALLBACK (gcm_calib_assistant_prepare_cb), priv);
2160 gtk_application_add_window (priv->application,
2161 priv->main_window);
2162
2163 /* set the parent window if it is specified */
2164 if (priv->xid != 0) {
2165 g_debug ("Setting xid %i", priv->xid);
2166 gcm_window_set_parent_xid (GTK_WINDOW (priv->main_window), priv->xid);
2167 }
2168
2169 /* select a specific profile only */
2170 priv->device = cd_client_find_device_sync (priv->client,
2171 priv->device_id,
2172 NULL,
2173 &error);
2174 if (priv->device == NULL) {
2175 g_warning ("failed to get device %s: %s",
2176 priv->device_id,
2177 error->message);
2178 g_error_free (error);
2179 goto out;
2180 }
2181
2182 /* connect to the device */
2183 ret = cd_device_connect_sync (priv->device,
2184 NULL,
2185 &error);
2186 if (!ret) {
2187 g_warning ("failed to connect to device: %s",
2188 error->message);
2189 g_error_free (error);
2190 goto out;
2191 }
2192
2193 /* get the device properties */
2194 priv->device_kind = cd_device_get_kind (priv->device);
2195
2196 /* for display calibration move the window to lower right area to
2197 * limit argyll from obscuring the window (too much) */
2198 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2199 gtk_window_set_gravity (priv->main_window, GDK_GRAVITY_SOUTH_EAST);
2200 gtk_window_move (priv->main_window, gdk_screen_width() - window_width,
2201 gdk_screen_height() - window_height);
2202 }
2203
2204 /* set, with fallbacks */
2205 serial = cd_device_get_serial (priv->device);
2206 if (serial == NULL) {
2207 /* TRANSLATORS: this is saved in the profile */
2208 serial = _("Unknown serial");
2209 }
2210 model = cd_device_get_model (priv->device);
2211 if (model == NULL) {
2212 /* TRANSLATORS: this is saved in the profile */
2213 model = _("Unknown model");
2214 }
2215 description = cd_device_get_model (priv->device);
2216 if (description == NULL) {
2217 /* TRANSLATORS: this is saved in the profile */
2218 description = _("Unknown description");
2219 }
2220 manufacturer = cd_device_get_vendor (priv->device);
2221 if (manufacturer == NULL) {
2222 /* TRANSLATORS: this is saved in the profile */
2223 manufacturer = _("Unknown manufacturer");
2224 }
2225
2226 dt = g_date_time_new_now_local ();
2227 /* TRANSLATORS: this is the copyright string, where it might be
2228 * "Copyright (c) 2009 Edward Scissorhands"
2229 * BIG RED FLASHING NOTE: YOU NEED TO USE ASCII ONLY */
2230 copyright = g_strdup_printf ("%s %04i %s", _("Copyright (c)"),
2231 g_date_time_get_year (dt),
2232 g_get_real_name ());
2233
2234 /* set the proper values */
2235 g_object_set (priv->calibrate,
2236 "device-kind", priv->device_kind,
2237 "model", model,
2238 "description", description,
2239 "manufacturer", manufacturer,
2240 "serial", serial,
2241 "copyright", copyright,
2242 NULL);
2243
2244 /* display specific properties */
2245 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2246 native_device = cd_device_get_metadata_item (priv->device,
2247 CD_DEVICE_METADATA_XRANDR_NAME);
2248 if (native_device == NULL) {
2249 g_warning ("failed to get output");
2250 goto out;
2251 }
2252 g_object_set (priv->calibrate,
2253 "output-name", native_device,
2254 NULL);
2255 }
2256out:
2257 /* add different pages depending on the device kind */
2258 gcm_calib_add_pages (priv);
2259 gtk_assistant_set_current_page (GTK_ASSISTANT (priv->main_window), 0);
2260 if (dt != NULL)
2261 g_date_time_unref (dt);
2262 g_free (copyright);
2263}
2264
2265static void
2266gcm_calib_title_changed_cb (GcmCalibrate *calibrate,
2267 const gchar *title,
2268 GcmCalibratePriv *priv)
2269{
2270 gchar *markup;
2271
2272 markup = g_strdup_printf ("<span size=\"large\" font_weight=\"bold\">%s</span>", title);
2273 gtk_label_set_markup (GTK_LABEL (priv->action_title), markup);
2274 g_free (markup);
2275}
2276
2277static void
2278gcm_calib_message_changed_cb (GcmCalibrate *calibrate,
2279 const gchar *title,
2280 GcmCalibratePriv *priv)
2281{
2282 gtk_label_set_label (GTK_LABEL (priv->action_message), title);
2283}
2284
2285static void
2286gcm_calib_progress_changed_cb (GcmCalibrate *calibrate,
2287 guint percentage,
2288 GcmCalibratePriv *priv)
2289{
2290 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->action_progress),
2291 percentage / 100.0f);
2292}
2293
2294static void
2295gcm_calib_image_changed_cb (GcmCalibrate *calibrate,
2296 const gchar *filename,
2297 GcmCalibratePriv *priv)
2298{
2299 GdkPixbuf *pixbuf;
2300 GError *error = NULL;
2301
2302 if (filename != NULL) {
2303 pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 200, 400, &error);
2304 if (pixbuf == NULL) {
2305 g_warning ("failed to load image: %s", error->message);
2306 g_error_free (error);
2307 gtk_widget_hide (priv->action_image);
2308 } else {
2309 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->action_image), pixbuf);
2310 gtk_widget_show (priv->action_image);
2311 }
2312 } else {
2313 gtk_widget_hide (priv->action_image);
2314 }
2315}
2316
2317static void
2318gcm_calib_interaction_required_cb (GcmCalibrate *calibrate,
2319 const gchar *button_text,
2320 GcmCalibratePriv *priv)
2321{
2322 GtkWidget *vbox;
2323 vbox = gcm_calib_get_vbox_for_page (priv,
2324 GCM_CALIBRATE_PAGE_ACTION);
2325 gtk_assistant_set_page_complete (GTK_ASSISTANT (priv->main_window),
2326 vbox, TRUE);
2327 priv->has_pending_interaction = TRUE;
2328}
2329
2330/**
2331 * main:
2332 **/
2333int
2334main (int argc, char **argv)
2335{
2336 gchar *device_id = NULL;
2337 GcmCalibratePriv *priv;
2338 GOptionContext *context;
2339 guint xid = 0;
2340 int status = 0;
2341
2342 const GOptionEntry options[] = {
2343 { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
2344 /* TRANSLATORS: we can make this modal (stay on top of) another window */
2345 _("Set the parent window to make this modal"), NULL },
2346 { "device", 'd', 0, G_OPTION_ARG_STRING, &device_id,
2347 /* TRANSLATORS: show just the one profile, rather than all */
2348 _("Set the specific device to calibrate"), NULL },
2349 { NULL}
2350 };
2351
2352 setlocale (LC_ALL, "");
2353
2354 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
2355 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
2356 textdomain (GETTEXT_PACKAGE);
2357
2358 gtk_init (&argc, &argv);
2359
2360 context = g_option_context_new ("gnome-color-manager calibration tool");
2361 g_option_context_add_main_entries (context, options, NULL);
2362 g_option_context_add_group (context, gcm_debug_get_option_group ());
2363 g_option_context_add_group (context, gtk_get_option_group (TRUE));
2364 g_option_context_parse (context, &argc, &argv, NULL);
2365 g_option_context_free (context);
2366
2367 priv = g_new0 (GcmCalibratePriv, 1);
2368 priv->pages = g_ptr_array_new ();
2369 priv->xid = xid;
2370 priv->device_id = device_id;
2371 priv->calibrate = gcm_calibrate_argyll_new ();
2372 g_object_set (priv->calibrate,
2373 "precision", GCM_CALIBRATE_PRECISION_LONG,
2374 NULL);
2375 priv->device_kind = CD_DEVICE_KIND_UNKNOWN;
2376 g_signal_connect (priv->calibrate, "title-changed",
2377 G_CALLBACK (gcm_calib_title_changed_cb), priv);
2378 g_signal_connect (priv->calibrate, "message-changed",
2379 G_CALLBACK (gcm_calib_message_changed_cb), priv);
2380 g_signal_connect (priv->calibrate, "image-changed",
2381 G_CALLBACK (gcm_calib_image_changed_cb), priv);
2382 g_signal_connect (priv->calibrate, "progress-changed",
2383 G_CALLBACK (gcm_calib_progress_changed_cb), priv);
2384 g_signal_connect (priv->calibrate, "interaction-required",
2385 G_CALLBACK (gcm_calib_interaction_required_cb), priv);
2386
2387 /* nothing specified */
2388 if (priv->device_id == NULL) {
2389 g_print ("%s\n", _("No device was specified!"));
2390 goto out;
2391 }
2392
2393 /* ensure single instance */
2394 priv->application = gtk_application_new ("org.gnome.ColorManager.Calibration", 0);
2395 g_signal_connect (priv->application, "startup",
2396 G_CALLBACK (gcm_calib_startup_cb), priv);
2397 g_signal_connect (priv->application, "activate",
2398 G_CALLBACK (gcm_calib_activate_cb), priv);
2399
2400 /* wait */
2401 status = g_application_run (G_APPLICATION (priv->application), argc, argv);
2402
2403 g_ptr_array_unref (priv->pages);
2404 g_object_unref (priv->application);
2405 g_object_unref (priv->calibrate);
2406 if (priv->client != NULL)
2407 g_object_unref (priv->client);
2408 if (priv->device_id != NULL)
2409 g_free (priv->device_id);
2410 if (priv->device != NULL)
2411 g_object_unref (priv->device);
2412 g_free (priv);
2413out:
2414 return status;
2415}
02416
=== removed file '.pc/01_unity_control_center.patch/src/gcm-calibrate-main.c'
--- .pc/01_unity_control_center.patch/src/gcm-calibrate-main.c 2014-01-15 16:15:06 +0000
+++ .pc/01_unity_control_center.patch/src/gcm-calibrate-main.c 1970-01-01 00:00:00 +0000
@@ -1,2370 +0,0 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2009-2011 Richard Hughes <richard@hughsie.com>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "config.h"
23
24#include <glib/gi18n.h>
25#include <gtk/gtk.h>
26#include <gdk/gdkx.h>
27#include <glib/gstdio.h>
28#include <locale.h>
29#include <canberra-gtk.h>
30#include <colord.h>
31#include <lcms2.h>
32#include <stdlib.h>
33
34#include "gcm-utils.h"
35#include "gcm-debug.h"
36#include "gcm-calibrate.h"
37#include "gcm-calibrate-argyll.h"
38
39typedef enum {
40 GCM_CALIBRATE_PAGE_INTRO,
41 GCM_CALIBRATE_PAGE_DISPLAY_KIND,
42 GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE,
43 GCM_CALIBRATE_PAGE_DISPLAY_CONFIG,
44 GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS,
45 GCM_CALIBRATE_PAGE_INSTALL_TARGETS,
46 GCM_CALIBRATE_PAGE_PRECISION,
47 GCM_CALIBRATE_PAGE_PRINT_KIND,
48 GCM_CALIBRATE_PAGE_TARGET_KIND,
49 GCM_CALIBRATE_PAGE_SENSOR,
50 GCM_CALIBRATE_PAGE_ACTION,
51 GCM_CALIBRATE_PAGE_FAILURE,
52 GCM_CALIBRATE_PAGE_TITLE,
53 GCM_CALIBRATE_PAGE_LAST
54} GcmCalibratePage;
55
56typedef struct {
57 GtkApplication *application;
58 CdClient *client;
59 GcmCalibrate *calibrate;
60 CdDevice *device;
61 CdDeviceKind device_kind;
62 GCancellable *cancellable;
63 gchar *device_id;
64 guint xid;
65 GtkWindow *main_window;
66 GPtrArray *pages;
67 gboolean internal_lcd;
68 GtkWidget *reference_preview;
69 GtkWidget *action_title;
70 GtkWidget *action_message;
71 GtkWidget *action_image;
72 GtkWidget *action_progress;
73 gboolean has_pending_interaction;
74 gboolean started_calibration;
75 GcmCalibratePage current_page;
76 gint inhibit_cookie;
77} GcmCalibratePriv;
78
79/**
80 * gcm_window_set_parent_xid:
81 **/
82static void
83gcm_window_set_parent_xid (GtkWindow *window, guint32 xid)
84{
85 GdkDisplay *display;
86 GdkWindow *parent_window;
87 GdkWindow *our_window;
88
89 display = gdk_display_get_default ();
90 parent_window = gdk_x11_window_foreign_new_for_display (display, xid);
91 if (parent_window == NULL) {
92 g_warning ("failed to get parent window");
93 return;
94 }
95
96 gtk_widget_realize (GTK_WIDGET (window));
97 our_window = gtk_widget_get_window (GTK_WIDGET (window));
98 if (our_window == NULL) {
99 g_warning ("failed to get our window");
100 return;
101 }
102
103 /* set this above our parent */
104 gtk_window_set_modal (window, TRUE);
105 gdk_window_set_transient_for (our_window, parent_window);
106 gtk_window_set_title (window, "");
107}
108
109/**
110 * gcm_calib_activate_cb:
111 **/
112static void
113gcm_calib_activate_cb (GApplication *application, GcmCalibratePriv *priv)
114{
115 gtk_window_present (priv->main_window);
116}
117
118static void
119gcm_calib_confirm_quit_cb (GtkDialog *dialog,
120 gint response_id,
121 GcmCalibratePriv *priv)
122{
123 if (response_id != GTK_RESPONSE_CLOSE) {
124 gtk_widget_destroy (GTK_WIDGET (dialog));
125 return;
126 }
127 gcm_calibrate_interaction (priv->calibrate, GTK_RESPONSE_CANCEL);
128 g_application_release (G_APPLICATION (priv->application));
129}
130
131/**
132 * gcm_calib_confirm_quit:
133 **/
134static void
135gcm_calib_confirm_quit (GcmCalibratePriv *priv)
136{
137 GtkWidget *dialog;
138
139 /* do not ask for confirmation on the initial page */
140 if (priv->current_page == GCM_CALIBRATE_PAGE_INTRO)
141 g_application_release (G_APPLICATION (priv->application));
142
143 dialog = gtk_message_dialog_new (GTK_WINDOW (priv->main_window),
144 GTK_DIALOG_MODAL,
145 GTK_MESSAGE_QUESTION,
146 GTK_BUTTONS_NONE,
147 "%s", _("Calibration is not complete"));
148 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
149 "%s",
150 _("Are you sure you want to cancel the calibration?"));
151 /* TRANSLATORS: button text */
152 gtk_dialog_add_button (GTK_DIALOG (dialog),
153 _("Continue calibration"),
154 GTK_RESPONSE_CANCEL);
155 /* TRANSLATORS: button text */
156 gtk_dialog_add_button (GTK_DIALOG (dialog),
157 _("Cancel and close"),
158 GTK_RESPONSE_CLOSE);
159 g_signal_connect (dialog, "response",
160 G_CALLBACK (gcm_calib_confirm_quit_cb),
161 priv);
162 gtk_widget_show (dialog);
163}
164
165/**
166 * gcm_calib_delete_event_cb:
167 **/
168static gboolean
169gcm_calib_delete_event_cb (GtkWidget *widget, GdkEvent *event, GcmCalibratePriv *priv)
170{
171 gcm_calib_confirm_quit (priv);
172 return FALSE;
173}
174
175/**
176 * gcm_calib_assistant_cancel_cb:
177 **/
178static void
179gcm_calib_assistant_cancel_cb (GtkAssistant *assistant, GcmCalibratePriv *priv)
180{
181 gcm_calib_confirm_quit (priv);
182}
183
184/**
185 * gcm_calib_assistant_close_cb:
186 **/
187static void
188gcm_calib_assistant_close_cb (GtkAssistant *assistant, GcmCalibratePriv *priv)
189{
190 g_application_release (G_APPLICATION (priv->application));
191}
192
193/**
194 * gcm_calib_play_sound:
195 **/
196static void
197gcm_calib_play_sound (GcmCalibratePriv *priv)
198{
199 /* play sound from the naming spec */
200 ca_context_play (ca_gtk_context_get (), 0,
201 CA_PROP_EVENT_ID, "complete",
202 /* TRANSLATORS: this is the application name for libcanberra */
203 CA_PROP_APPLICATION_NAME, _("GNOME Color Manager"),
204 /* TRANSLATORS: this is the sound description */
205 CA_PROP_EVENT_DESCRIPTION, _("Profiling completed"),
206 NULL);
207}
208
209
210/**
211 * gcm_calib_get_vbox_for_page:
212 **/
213static GtkWidget *
214gcm_calib_get_vbox_for_page (GcmCalibratePriv *priv,
215 GcmCalibratePage page)
216{
217 guint i;
218 GtkWidget *tmp;
219 GcmCalibratePage page_tmp;
220
221 for (i=0; i<priv->pages->len; i++) {
222 tmp = g_ptr_array_index (priv->pages, i);
223 page_tmp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tmp),
224 "GcmCalibrateMain::Index"));
225 if (page_tmp == page)
226 return tmp;
227 }
228 return NULL;
229}
230
231static wchar_t *
232utf8_to_wchar_t (const char *src)
233{
234 gsize len;
235 gsize converted;
236 wchar_t *buf = NULL;
237
238 len = mbstowcs (NULL, src, 0);
239 if (len == (gsize) -1) {
240 g_warning ("Invalid UTF-8 in string %s", src);
241 goto out;
242 }
243 len += 1;
244 buf = g_malloc (sizeof (wchar_t) * len);
245 converted = mbstowcs (buf, src, len - 1);
246 g_assert (converted != (gsize) -1);
247 buf[converted] = '\0';
248out:
249 return buf;
250}
251
252static cmsBool
253_cmsDictAddEntryAscii (cmsHANDLE dict,
254 const gchar *key,
255 const gchar *value)
256{
257 cmsBool ret = FALSE;
258 wchar_t *mb_key = NULL;
259 wchar_t *mb_value = NULL;
260
261 mb_key = utf8_to_wchar_t (key);
262 if (mb_key == NULL)
263 goto out;
264 mb_value = utf8_to_wchar_t (value);
265 if (mb_value == NULL)
266 goto out;
267 ret = cmsDictAddEntry (dict, mb_key, mb_value, NULL, NULL);
268out:
269 g_free (mb_key);
270 g_free (mb_value);
271 return ret;
272}
273
274static gboolean
275gcm_calib_set_extra_metadata (GcmCalibratePriv *priv,
276 const gchar *filename,
277 GError **error)
278{
279 cmsHANDLE dict = NULL;
280 cmsHPROFILE lcms_profile;
281 gboolean ret = TRUE;
282 gchar *data = NULL;
283 gchar *screen_brightness_str = NULL;
284 gsize len;
285 guint percentage;
286 CdSensor *sensor;
287
288 /* parse */
289 ret = g_file_get_contents (filename, &data, &len, error);
290 if (!ret)
291 goto out;
292 lcms_profile = cmsOpenProfileFromMem (data, len);
293 if (lcms_profile == NULL) {
294 g_set_error_literal (error, 1, 0,
295 "failed to open profile");
296 ret = FALSE;
297 goto out;
298 }
299
300 /* just create a new dict */
301 dict = cmsDictAlloc (NULL);
302 _cmsDictAddEntryAscii (dict,
303 CD_PROFILE_METADATA_CMF_PRODUCT,
304 PACKAGE_NAME);
305 _cmsDictAddEntryAscii (dict,
306 CD_PROFILE_METADATA_CMF_BINARY,
307 "gcm-calibrate");
308 _cmsDictAddEntryAscii (dict,
309 CD_PROFILE_METADATA_CMF_VERSION,
310 PACKAGE_VERSION);
311 _cmsDictAddEntryAscii (dict,
312 CD_PROFILE_METADATA_DATA_SOURCE,
313 CD_PROFILE_METADATA_DATA_SOURCE_CALIB);
314 sensor = gcm_calibrate_get_sensor (priv->calibrate);
315 if (sensor != NULL) {
316 _cmsDictAddEntryAscii (dict,
317 CD_PROFILE_METADATA_MEASUREMENT_DEVICE,
318 cd_sensor_kind_to_string (cd_sensor_get_kind (sensor)));
319 }
320 _cmsDictAddEntryAscii (dict,
321 CD_PROFILE_METADATA_MAPPING_DEVICE_ID,
322 cd_device_get_id (priv->device));
323
324 /* add the calibration brightness if an internal panel */
325 percentage = gcm_calibrate_get_screen_brightness (priv->calibrate);
326 if (percentage > 0) {
327 screen_brightness_str = g_strdup_printf ("%i", percentage);
328 _cmsDictAddEntryAscii (dict,
329 CD_PROFILE_METADATA_SCREEN_BRIGHTNESS,
330 screen_brightness_str);
331 }
332
333 /* just write dict */
334 ret = cmsWriteTag (lcms_profile, cmsSigMetaTag, dict);
335 if (!ret) {
336 g_set_error_literal (error, 1, 0,
337 "cannot write metadata");
338 goto out;
339 }
340
341 /* write profile id */
342 ret = cmsMD5computeID (lcms_profile);
343 if (!ret) {
344 g_set_error_literal (error, 1, 0,
345 "failed to write profile id");
346 goto out;
347 }
348
349 /* save, TODO: get error */
350 cmsSaveProfileToFile (lcms_profile, filename);
351 ret = TRUE;
352out:
353 g_free (screen_brightness_str);
354 g_free (data);
355 if (dict != NULL)
356 cmsDictFree (dict);
357 return ret;
358}
359
360/**
361 * gcm_calib_set_sensor_options_cb:
362 **/
363static void
364gcm_calib_set_sensor_options_cb (GObject *object,
365 GAsyncResult *res,
366 gpointer user_data)
367{
368 CdSensor *sensor = CD_SENSOR (object);
369 gboolean ret;
370 GError *error = NULL;
371
372 /* get return value */
373 ret = cd_sensor_set_options_finish (sensor, res, &error);
374 if (!ret) {
375 g_warning ("Failed to set sensor option: %s",
376 error->message);
377 g_error_free (error);
378 }
379}
380
381static void
382gcm_calib_set_sensor_options (GcmCalibratePriv *priv,
383 const gchar *filename)
384{
385 CdSensor *sensor;
386 gboolean ret;
387 gchar *data = NULL;
388 gchar *sha1 = NULL;
389 GError *error = NULL;
390 GHashTable *hash = NULL;
391 gsize len;
392
393 /* get ChSensor */
394 sensor = gcm_calibrate_get_sensor (priv->calibrate);
395 if (sensor == NULL)
396 goto out;
397
398 /* set the remote profile hash */
399 hash = g_hash_table_new_full (g_str_hash,
400 g_str_equal,
401 g_free,
402 (GDestroyNotify) g_variant_unref);
403 ret = g_file_get_contents (filename, &data, &len, &error);
404 if (!ret) {
405 g_warning ("Failed to get SHA1 hash: %s",
406 error->message);
407 g_error_free (error);
408 goto out;
409 }
410 sha1 = g_compute_checksum_for_data (G_CHECKSUM_SHA1,
411 (const guchar *) data,
412 len);
413 g_hash_table_insert (hash,
414 g_strdup ("remote-profile-hash"),
415 g_variant_ref_sink (g_variant_new_string (sha1)));
416 cd_sensor_set_options (sensor, hash, NULL,
417 gcm_calib_set_sensor_options_cb,
418 priv);
419out:
420 g_free (data);
421 g_free (sha1);
422 if (hash != NULL)
423 g_hash_table_unref (hash);
424}
425
426static gboolean
427gcm_calib_start_idle_cb (gpointer user_data)
428{
429 CdProfile *profile = NULL;
430 const gchar *filename;
431 gboolean ret;
432 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
433 GError *error = NULL;
434 GFile *file = NULL;
435 gint inhibit_cookie;
436 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
437 GtkWidget *vbox;
438
439 /* inhibit */
440 inhibit_cookie = gtk_application_inhibit (priv->application,
441 priv->main_window,
442 GTK_APPLICATION_INHIBIT_LOGOUT |
443 GTK_APPLICATION_INHIBIT_SWITCH |
444 GTK_APPLICATION_INHIBIT_SUSPEND |
445 GTK_APPLICATION_INHIBIT_IDLE,
446 "Calibration in progress");
447
448 /* actually do the action */
449 priv->started_calibration = TRUE;
450 ret = gcm_calibrate_device (priv->calibrate,
451 priv->device,
452 priv->main_window,
453 &error);
454 if (!ret) {
455 gcm_calibrate_set_title (priv->calibrate,
456 _("Failed to calibrate"),
457 GCM_CALIBRATE_UI_ERROR);
458 gcm_calibrate_set_message (priv->calibrate,
459 error->message,
460 GCM_CALIBRATE_UI_ERROR);
461 gcm_calibrate_set_image (priv->calibrate, NULL);
462
463 g_warning ("failed to calibrate: %s",
464 error->message);
465 g_error_free (error);
466
467 /* mark this box as the end */
468 vbox = gcm_calib_get_vbox_for_page (priv, GCM_CALIBRATE_PAGE_ACTION);
469 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
470 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
471 goto out;
472 }
473
474 /* get profile */
475 filename = gcm_calibrate_get_filename_result (priv->calibrate);
476 if (filename == NULL) {
477 g_warning ("failed to get filename from calibration");
478 goto out;
479 }
480
481 /* set some private properties */
482 ret = gcm_calib_set_extra_metadata (priv, filename, &error);
483 if (!ret) {
484 g_warning ("failed to set extra metadata: %s",
485 error->message);
486 g_error_free (error);
487 goto out;
488 }
489
490 /* inform the sensor about the last successful profile */
491 gcm_calib_set_sensor_options (priv, filename);
492
493 /* copy the ICC file to the proper location */
494 file = g_file_new_for_path (filename);
495 profile = cd_client_import_profile_sync (priv->client,
496 file,
497 priv->cancellable,
498 &error);
499 if (profile == NULL) {
500 g_warning ("failed to find calibration profile: %s",
501 error->message);
502 g_error_free (error);
503 goto out;
504 }
505 ret = cd_device_add_profile_sync (priv->device,
506 CD_DEVICE_RELATION_HARD,
507 profile,
508 priv->cancellable,
509 &error);
510 if (!ret) {
511 g_warning ("failed to add %s to %s: %s",
512 cd_profile_get_object_path (profile),
513 cd_device_get_object_path (priv->device),
514 error->message);
515 g_error_free (error);
516 goto out;
517 }
518
519 /* remove temporary file */
520 g_unlink (filename);
521
522 /* allow forward */
523 vbox = gcm_calib_get_vbox_for_page (priv,
524 GCM_CALIBRATE_PAGE_ACTION);
525 gtk_assistant_set_page_complete (assistant,
526 vbox, TRUE);
527
528 /* set to summary page */
529 gtk_assistant_set_current_page (assistant,
530 gtk_assistant_get_n_pages (assistant) - 1);
531out:
532 if (inhibit_cookie != 0) {
533 gtk_application_uninhibit (priv->application,
534 priv->inhibit_cookie);
535 }
536 if (profile != NULL)
537 g_object_unref (profile);
538 if (file != NULL)
539 g_object_unref (file);
540 return FALSE;
541}
542
543static gint
544gcm_calib_assistant_page_forward_cb (gint current_page, gpointer user_data)
545{
546 GtkWidget *vbox;
547 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
548
549 /* shouldn't happen... */
550 if (priv->current_page != GCM_CALIBRATE_PAGE_ACTION)
551 return current_page + 1;
552
553 if (!priv->has_pending_interaction)
554 return current_page;
555
556 /* continue calibration */
557 gcm_calibrate_interaction (priv->calibrate, GTK_RESPONSE_OK);
558 priv->has_pending_interaction = FALSE;
559
560 /* no longer allow forward */
561 vbox = gcm_calib_get_vbox_for_page (priv,
562 GCM_CALIBRATE_PAGE_ACTION);
563
564 gtk_assistant_set_page_complete (GTK_ASSISTANT (priv->main_window),
565 vbox, FALSE);
566 return current_page;
567}
568
569/**
570 * gcm_calib_assistant_prepare_cb:
571 **/
572static gboolean
573gcm_calib_assistant_prepare_cb (GtkAssistant *assistant,
574 GtkWidget *page_widget,
575 GcmCalibratePriv *priv)
576{
577 priv->current_page = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (page_widget),
578 "GcmCalibrateMain::Index"));
579 switch (priv->current_page) {
580 case GCM_CALIBRATE_PAGE_LAST:
581 gcm_calib_play_sound (priv);
582 break;
583 case GCM_CALIBRATE_PAGE_ACTION:
584 g_debug ("lights! camera! action!");
585 if (!priv->started_calibration)
586 g_idle_add (gcm_calib_start_idle_cb, priv);
587 break;
588 default:
589 break;
590 }
591
592 /* ensure we cancel argyllcms if the user clicks back */
593 if (priv->current_page != GCM_CALIBRATE_PAGE_ACTION &&
594 priv->started_calibration) {
595 gcm_calibrate_interaction (priv->calibrate,
596 GTK_RESPONSE_CANCEL);
597 priv->started_calibration = FALSE;
598 }
599
600 /* forward on the action page just unsticks the calibration */
601 if (priv->current_page == GCM_CALIBRATE_PAGE_ACTION) {
602 gtk_assistant_set_forward_page_func (assistant,
603 gcm_calib_assistant_page_forward_cb,
604 priv,
605 NULL);
606 } else {
607 gtk_assistant_set_forward_page_func (assistant,
608 NULL, NULL, NULL);
609 }
610
611 /* use the default on each page */
612 switch (priv->current_page) {
613 case GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS:
614 case GCM_CALIBRATE_PAGE_SENSOR:
615 case GCM_CALIBRATE_PAGE_ACTION:
616 break;
617 default:
618 gtk_assistant_set_page_complete (assistant, page_widget, TRUE);
619 break;
620 }
621 return FALSE;
622}
623
624/**
625 * gcm_calib_add_page_title:
626 **/
627static GtkWidget *
628gcm_calib_add_page_title (GcmCalibratePriv *priv, const gchar *text)
629{
630 GtkWidget *label;
631 GtkWidget *hbox;
632 GtkWidget *vbox;
633 gchar *markup;
634
635 markup = g_strdup_printf ("<span size=\"large\" font_weight=\"bold\">%s</span>", text);
636 label = gtk_label_new (NULL);
637 gtk_label_set_markup (GTK_LABEL (label), markup);
638
639 /* make left aligned */
640 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
641 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
642
643 /* header */
644 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
645 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
646
647 g_free (markup);
648 return vbox;
649}
650
651static gboolean
652gcm_calib_label_activate_link_cb (GtkLabel *label,
653 gchar *uri,
654 GcmCalibratePriv *priv)
655{
656 gboolean ret;
657 GError *error = NULL;
658 ret = g_spawn_command_line_async (BINDIR "/gnome-control-center color", &error);
659 if (!ret) {
660 g_warning ("failed to launch the control center: %s",
661 error->message);
662 g_error_free (error);
663 }
664 return ret;
665}
666
667/**
668 * gcm_calib_add_page_para:
669 **/
670static GtkWidget *
671gcm_calib_add_page_para (GtkWidget *vbox, const gchar *text)
672{
673 GtkWidget *label;
674 GtkWidget *hbox;
675
676 label = gtk_label_new (NULL);
677 g_signal_connect (label, "activate-link",
678 G_CALLBACK (gcm_calib_label_activate_link_cb),
679 NULL);
680 gtk_label_set_markup (GTK_LABEL (label), text);
681 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
682 gtk_label_set_width_chars (GTK_LABEL (label), 40);
683 gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f);
684
685 /* make left aligned */
686 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
687 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
688 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
689 return label;
690}
691
692/**
693 * gcm_calib_add_page_bullet:
694 **/
695static void
696gcm_calib_add_page_bullet (GtkWidget *vbox, const gchar *text)
697{
698 gchar *markup;
699 markup = g_strdup_printf ("• %s", text);
700 gcm_calib_add_page_para (vbox, markup);
701 g_free (markup);
702}
703
704/**
705 * gcm_calib_setup_page_intro:
706 **/
707static void
708gcm_calib_setup_page_intro (GcmCalibratePriv *priv)
709{
710 GtkWidget *vbox;
711 GtkWidget *content;
712 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
713
714 /* TRANSLATORS: this is intro page text */
715 switch (priv->device_kind) {
716 case CD_DEVICE_KIND_CAMERA:
717 case CD_DEVICE_KIND_WEBCAM:
718 /* TRANSLATORS: this is the page title */
719 vbox = gcm_calib_add_page_title (priv, _("Calibrate your camera"));
720 break;
721 case CD_DEVICE_KIND_DISPLAY:
722 /* TRANSLATORS: this is the page title */
723 vbox = gcm_calib_add_page_title (priv, _("Calibrate your display"));
724 break;
725 case CD_DEVICE_KIND_PRINTER:
726 /* TRANSLATORS: this is the page title */
727 vbox = gcm_calib_add_page_title (priv, _("Calibrate your printer"));
728 break;
729 default:
730 /* TRANSLATORS: this is the page title */
731 vbox = gcm_calib_add_page_title (priv, _("Calibrate your device"));
732 break;
733 }
734
735 /* main contents */
736 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
737 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
738
739 /* TRANSLATORS: this is intro page text */
740 switch (priv->device_kind) {
741 case CD_DEVICE_KIND_DISPLAY:
742 /* TRANSLATORS: this is the final intro page text */
743 gcm_calib_add_page_para (content, _("Any existing screen correction will be temporarily turned off and the brightness set to maximum."));
744 break;
745 default:
746 break;
747 }
748
749 /* TRANSLATORS: this is the final intro page text */
750 gcm_calib_add_page_para (content, _("You can cancel this process at any stage by pressing the cancel button."));
751
752 /* add to assistant */
753 gtk_assistant_append_page (assistant, vbox);
754 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_INTRO);
755 /* TRANSLATORS: this is the calibration wizard page title */
756 gtk_assistant_set_page_title (assistant, vbox, _("Introduction"));
757 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
758 g_ptr_array_add (priv->pages, vbox);
759 g_object_set_data (G_OBJECT (vbox),
760 "GcmCalibrateMain::Index",
761 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INTRO));
762
763 /* show page */
764 gtk_widget_show_all (vbox);
765}
766
767/**
768 * gcm_calibrate_is_livecd:
769 **/
770static gboolean
771gcm_calibrate_is_livecd (void)
772{
773#ifdef __linux__
774 gboolean ret;
775 gchar *data = NULL;
776 GError *error = NULL;
777
778 /* get the kernel commandline */
779 ret = g_file_get_contents ("/proc/cmdline", &data, NULL, &error);
780 if (!ret) {
781 g_warning ("failed to get kernel command line: %s",
782 error->message);
783 g_error_free (error);
784 goto out;
785 }
786 ret = (g_strstr_len (data, -1, "liveimg") != NULL ||
787 g_strstr_len (data, -1, "casper") != NULL);
788out:
789 g_free (data);
790 return ret;
791#else
792 return FALSE;
793#endif
794}
795
796/**
797 * gcm_calib_show_profile_button_clicked_cb:
798 **/
799static void
800gcm_calib_show_profile_button_clicked_cb (GtkButton *button,
801 GcmCalibratePriv *priv)
802{
803 gboolean ret;
804 gchar *command_line;
805 GError *error = NULL;
806
807 /* just hardcode nautilus to open the folder */
808 command_line = g_strdup_printf ("nautilus %s/%s",
809 g_get_user_data_dir (),
810 "icc");
811 ret = g_spawn_command_line_async (command_line, &error);
812 if (!ret) {
813 g_warning ("failed to show profile: %s", error->message);
814 g_error_free (error);
815 goto out;
816 }
817out:
818 g_free (command_line);
819}
820
821/**
822 * gcm_calib_get_show_profile_button:
823 **/
824static GtkWidget *
825gcm_calib_get_show_profile_button (GcmCalibratePriv *priv)
826{
827 GtkStyleContext *context;
828 GtkWidget *button;
829 GtkWidget *image;
830 GtkWidget *label;
831 GtkWidget *vbox;
832
833 /* add button to show profile */
834 button = gtk_button_new ();
835 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
836 image = gtk_image_new_from_icon_name ("folder-publicshare-symbolic",
837 GTK_ICON_SIZE_DIALOG);
838
839 /* make image have a gray foreground */
840 context = gtk_widget_get_style_context (image);
841 gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
842
843 gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
844 label = gtk_label_new (_("Show File"));
845 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
846 gtk_container_add (GTK_CONTAINER (button), vbox);
847 gtk_widget_set_tooltip_text (button, _("Click here to show the profile"));
848 g_signal_connect (button, "clicked",
849 G_CALLBACK (gcm_calib_show_profile_button_clicked_cb),
850 priv);
851 gtk_container_set_border_width (GTK_CONTAINER (vbox), 15);
852 gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
853 gtk_widget_show_all (button);
854 return button;
855}
856
857/**
858 * gcm_calib_setup_page_summary:
859 **/
860static void
861gcm_calib_setup_page_summary (GcmCalibratePriv *priv)
862{
863 gboolean ret;
864 GtkWidget *vbox;
865 GtkWidget *content;
866 GtkWidget *image;
867 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
868
869 /* TRANSLATORS: this is the page title */
870 vbox = gcm_calib_add_page_title (priv, _("All done!"));
871
872 /* main contents */
873 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
874 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
875
876 switch (priv->device_kind) {
877 case CD_DEVICE_KIND_CAMERA:
878 case CD_DEVICE_KIND_WEBCAM:
879 /* TRANSLATORS: this is the final summary */
880 gcm_calib_add_page_para (content, _("The camera has been calibrated successfully."));
881 break;
882 case CD_DEVICE_KIND_DISPLAY:
883 /* TRANSLATORS: this is the final summary */
884 gcm_calib_add_page_para (content, _("The display has been calibrated successfully."));
885 break;
886 case CD_DEVICE_KIND_PRINTER:
887 /* TRANSLATORS: this is the final summary */
888 gcm_calib_add_page_para (content, _("The printer has been calibrated successfully."));
889 break;
890 default:
891 /* TRANSLATORS: this is the final summary */
892 gcm_calib_add_page_para (content, _("The device has been calibrated successfully."));
893 break;
894 }
895
896 /* only display the backlink if not launched from the control center itself */
897 if (priv->xid == 0) {
898 /* TRANSLATORS: this is the final summary */
899 gcm_calib_add_page_para (content, _("To view details about the new profile or to undo the calibration visit the <a href=\"control-center://color\">control center</a>."));
900 }
901
902 /* show the user the profile to copy off the live system */
903 ret = gcm_calibrate_is_livecd ();
904 if (ret) {
905 /* show button to copy profile */
906 image = gcm_calib_get_show_profile_button (priv);
907 gtk_box_pack_start (GTK_BOX (content), image, FALSE, FALSE, 30);
908 gcm_calib_add_page_para (content, _("You can use the profile with <a href=\"import-linux\">Linux</a>, <a href=\"import-osx\">Apple OS X</a> and <a href=\"import-windows\">Microsoft Windows</a> systems."));
909 } else {
910 /* add image for success */
911 image = gtk_image_new ();
912 gtk_image_set_from_icon_name (GTK_IMAGE (image), "face-smile", GTK_ICON_SIZE_DIALOG);
913 gtk_box_pack_start (GTK_BOX (content), image, FALSE, FALSE, 0);
914 }
915
916 /* add to assistant */
917 gtk_assistant_append_page (assistant, vbox);
918 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
919 /* TRANSLATORS: this is the calibration wizard page title */
920 gtk_assistant_set_page_title (assistant, vbox, _("Summary"));
921 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
922 g_ptr_array_add (priv->pages, vbox);
923 g_object_set_data (G_OBJECT (vbox),
924 "GcmCalibrateMain::Index",
925 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_LAST));
926
927 /* show page */
928 gtk_widget_show_all (vbox);
929}
930
931/**
932 * gcm_calib_setup_page_action:
933 **/
934static void
935gcm_calib_setup_page_action (GcmCalibratePriv *priv)
936{
937 GtkWidget *vbox;
938 GtkWidget *content;
939 GList *list;
940 GList *list2;
941 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
942
943 /* TRANSLATORS: this is the page title */
944 vbox = gcm_calib_add_page_title (priv, _("Performing calibration"));
945
946 /* grab title */
947 list = gtk_container_get_children (GTK_CONTAINER (vbox));
948 list2 = gtk_container_get_children (GTK_CONTAINER (list->data));
949 priv->action_title = list2->data;
950 g_list_free (list);
951 g_list_free (list2);
952
953 /* main contents */
954 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
955 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
956
957 priv->action_message = gcm_calib_add_page_para (content, _("Calibration is about to start"));
958
959 /* add image for success */
960 priv->action_image = gtk_image_new ();
961 gtk_image_set_from_icon_name (GTK_IMAGE (priv->action_image), "face-frown", GTK_ICON_SIZE_DIALOG);
962 gtk_box_pack_start (GTK_BOX (content), priv->action_image, FALSE, FALSE, 0);
963
964 /* add progress marker */
965 priv->action_progress = gtk_progress_bar_new ();
966 gtk_box_pack_start (GTK_BOX (content), priv->action_progress, FALSE, FALSE, 0);
967
968 /* add content widget */
969 gcm_calibrate_set_content_widget (priv->calibrate, vbox);
970
971 /* add to assistant */
972 gtk_assistant_append_page (assistant, vbox);
973 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
974 /* TRANSLATORS: this is the calibration wizard page title */
975 gtk_assistant_set_page_title (assistant, vbox, _("Action"));
976 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
977 g_ptr_array_add (priv->pages, vbox);
978 g_object_set_data (G_OBJECT (vbox),
979 "GcmCalibrateMain::Index",
980 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_ACTION));
981
982 /* show page */
983 gtk_widget_show_all (vbox);
984 gtk_widget_hide (priv->action_image);
985}
986
987/**
988 * gcm_calib_setup_page_display_configure_wait:
989 **/
990static void
991gcm_calib_setup_page_display_configure_wait (GcmCalibratePriv *priv)
992{
993 GtkWidget *vbox;
994 GtkWidget *content;
995 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
996
997 /* TRANSLATORS: dialog message, preface */
998 vbox = gcm_calib_add_page_title (priv, _("Calibration checklist"));
999
1000 /* main contents */
1001 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1002 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1003
1004 /* TRANSLATORS: this is intro page text */
1005 gcm_calib_add_page_para (content, _("Before calibrating the display, it is recommended to configure your display with the following settings to get optimal results."));
1006
1007 /* TRANSLATORS: dialog message, preface */
1008if(0) gcm_calib_add_page_para (content, _("You may want to consult the owner's manual for your display on how to achieve these settings."));
1009
1010 /* TRANSLATORS: dialog message, bullet item */
1011if(0) gcm_calib_add_page_bullet (content, _("Reset your display to the factory defaults."));
1012
1013 /* TRANSLATORS: dialog message, bullet item */
1014if(0) gcm_calib_add_page_bullet (content, _("Disable dynamic contrast if your display has this feature."));
1015
1016 /* TRANSLATORS: dialog message, bullet item */
1017if(0) gcm_calib_add_page_bullet (content, _("Configure your display with custom color settings and ensure the RGB channels are set to the same values."));
1018
1019 /* TRANSLATORS: dialog message, addition to bullet item */
1020if(0) gcm_calib_add_page_para (content, _("If custom color is not available then use a 6500K color temperature."));
1021
1022 /* TRANSLATORS: dialog message, bullet item */
1023if(0) gcm_calib_add_page_bullet (content, _("Adjust the display brightness to a comfortable level for prolonged viewing."));
1024
1025 gcm_calib_add_page_para (content, "");
1026
1027 /* TRANSLATORS: dialog message, suffix */
1028 gcm_calib_add_page_para (content, _("For best results, the display should have been powered for at least 15 minutes before starting the calibration."));
1029
1030 /* add to assistant */
1031 gtk_assistant_append_page (assistant, vbox);
1032 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1033 /* TRANSLATORS: this is the calibration wizard page title */
1034 gtk_assistant_set_page_title (assistant, vbox, _("Check Settings"));
1035 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1036 g_ptr_array_add (priv->pages, vbox);
1037 g_object_set_data (G_OBJECT (vbox),
1038 "GcmCalibrateMain::Index",
1039 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_CONFIG));
1040
1041 /* show page */
1042 gtk_widget_show_all (vbox);
1043}
1044
1045/**
1046 * gcm_calib_button_clicked_install_argyllcms_cb:
1047 **/
1048static void
1049gcm_calib_button_clicked_install_argyllcms_cb (GtkButton *button, GcmCalibratePriv *priv)
1050{
1051 gboolean ret;
1052 GtkWidget *vbox;
1053 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1054
1055 ret = gcm_utils_install_package (GCM_PREFS_PACKAGE_NAME_ARGYLLCMS,
1056 priv->main_window);
1057 /* we can continue now */
1058 if (TRUE || ret) {
1059 vbox = gcm_calib_get_vbox_for_page (priv,
1060 GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS);
1061 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1062 gtk_assistant_next_page (assistant);
1063
1064 /* we ddn't need to re-install now */
1065 gtk_widget_hide (vbox);
1066 }
1067}
1068
1069/**
1070 * gcm_calib_setup_page_install_argyllcms:
1071 **/
1072static void
1073gcm_calib_setup_page_install_argyllcms (GcmCalibratePriv *priv)
1074{
1075 GtkWidget *vbox;
1076 GtkWidget *content;
1077 GtkWidget *button;
1078 GString *string;
1079 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1080
1081 string = g_string_new ("");
1082
1083 /* TRANSLATORS: dialog message saying the argyllcms is not installed */
1084 g_string_append_printf (string, "%s\n",
1085 _("Calibration and profiling software is not installed."));
1086 /* TRANSLATORS: dialog message saying the color targets are not installed */
1087 g_string_append_printf (string, "%s",
1088 _("These tools are required to build color profiles for devices."));
1089
1090 /* TRANSLATORS: this is the page title */
1091 vbox = gcm_calib_add_page_title (priv, _("More software is required!"));
1092
1093 /* main contents */
1094 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1095 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1096
1097 /* TRANSLATORS: this is intro page text */
1098 gcm_calib_add_page_para (content, string->str);
1099
1100 button = gtk_button_new_with_label (_("Install required software"));
1101 g_signal_connect (button, "clicked",
1102 G_CALLBACK (gcm_calib_button_clicked_install_argyllcms_cb),
1103 priv);
1104 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1105
1106 /* add to assistant */
1107 gtk_assistant_append_page (assistant, vbox);
1108 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1109 /* TRANSLATORS: this is the calibration wizard page title */
1110 gtk_assistant_set_page_title (assistant, vbox, _("Install Tools"));
1111 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1112 g_ptr_array_add (priv->pages, vbox);
1113 g_object_set_data (G_OBJECT (vbox),
1114 "GcmCalibrateMain::Index",
1115 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INSTALL_ARGYLLCMS));
1116 g_string_free (string, TRUE);
1117
1118 /* show page */
1119 gtk_widget_show_all (vbox);
1120}
1121
1122/**
1123 * gcm_calib_button_clicked_install_targets_cb:
1124 **/
1125static void
1126gcm_calib_button_clicked_install_targets_cb (GtkButton *button, GcmCalibratePriv *priv)
1127{
1128 gboolean ret;
1129 GtkWidget *vbox;
1130 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1131
1132 ret = gcm_utils_install_package (GCM_PREFS_PACKAGE_NAME_SHARED_COLOR_TARGETS,
1133 priv->main_window);
1134 /* we can continue now */
1135 if (ret) {
1136 vbox = gcm_calib_get_vbox_for_page (priv,
1137 GCM_CALIBRATE_PAGE_INSTALL_TARGETS);
1138 gtk_assistant_next_page (assistant);
1139
1140 /* we ddn't need to re-install now */
1141 gtk_widget_hide (vbox);
1142 }
1143}
1144
1145/**
1146 * gcm_calib_setup_page_install_targets:
1147 **/
1148static void
1149gcm_calib_setup_page_install_targets (GcmCalibratePriv *priv)
1150{
1151 GtkWidget *vbox;
1152 GtkWidget *content;
1153 GtkWidget *button;
1154 GString *string;
1155 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1156
1157 string = g_string_new ("");
1158
1159 /* TRANSLATORS: dialog message saying the color targets are not installed */
1160 g_string_append_printf (string, "%s\n", _("Common color target files are not installed on this computer."));
1161 /* TRANSLATORS: dialog message saying the color targets are not installed */
1162 g_string_append_printf (string, "%s\n\n", _("Color target files are needed to convert the image to a color profile."));
1163 /* TRANSLATORS: dialog message, asking if it's okay to install them */
1164 g_string_append_printf (string, "%s\n\n", _("Do you want them to be installed?"));
1165 /* TRANSLATORS: dialog message, if the user has the target file on a CDROM then there's no need for this package */
1166 g_string_append_printf (string, "%s", _("If you already have the correct file, you can skip this step."));
1167
1168 /* TRANSLATORS: this is the page title */
1169 vbox = gcm_calib_add_page_title (priv, _("Optional data files available"));
1170
1171 /* main contents */
1172 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1173 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1174
1175 /* TRANSLATORS: this is intro page text */
1176 gcm_calib_add_page_para (content, string->str);
1177
1178 button = gtk_button_new_with_label (_("Install Now"));
1179 g_signal_connect (button, "clicked",
1180 G_CALLBACK (gcm_calib_button_clicked_install_targets_cb),
1181 priv);
1182 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1183
1184 /* add to assistant */
1185 gtk_assistant_append_page (assistant, vbox);
1186 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1187 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1188 /* TRANSLATORS: this is the calibration wizard page title */
1189 gtk_assistant_set_page_title (assistant, vbox, _("Install Targets"));
1190 g_ptr_array_add (priv->pages, vbox);
1191 g_object_set_data (G_OBJECT (vbox),
1192 "GcmCalibrateMain::Index",
1193 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_INSTALL_TARGETS));
1194 g_string_free (string, TRUE);
1195
1196 /* show page */
1197 gtk_widget_show_all (vbox);
1198}
1199
1200
1201/**
1202 * gcm_calib_reference_kind_to_localised_string:
1203 **/
1204static const gchar *
1205gcm_calib_reference_kind_to_localised_string (GcmCalibrateReferenceKind kind)
1206{
1207 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DIGITAL_TARGET_3) {
1208 /* TRANSLATORS: this is probably a brand name */
1209 return _("CMP Digital Target 3");
1210 }
1211 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DT_003) {
1212 /* TRANSLATORS: this is probably a brand name */
1213 return _("CMP DT 003");
1214 }
1215 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER) {
1216 /* TRANSLATORS: this is probably a brand name */
1217 return _("Color Checker");
1218 }
1219 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_DC) {
1220 /* TRANSLATORS: this is probably a brand name */
1221 return _("Color Checker DC");
1222 }
1223 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_SG) {
1224 /* TRANSLATORS: this is probably a brand name */
1225 return _("Color Checker SG");
1226 }
1227 if (kind == GCM_CALIBRATE_REFERENCE_KIND_HUTCHCOLOR) {
1228 /* TRANSLATORS: this is probably a brand name */
1229 return _("Hutchcolor");
1230 }
1231 if (kind == GCM_CALIBRATE_REFERENCE_KIND_I1_RGB_SCAN_1_4) {
1232 /* TRANSLATORS: this is probably a brand name */
1233 return _("i1 RGB Scan 1.4");
1234 }
1235 if (kind == GCM_CALIBRATE_REFERENCE_KIND_IT8) {
1236 /* TRANSLATORS: this is probably a brand name */
1237 return _("IT8.7/2");
1238 }
1239 if (kind == GCM_CALIBRATE_REFERENCE_KIND_LASER_SOFT_DC_PRO) {
1240 /* TRANSLATORS: this is probably a brand name */
1241 return _("Laser Soft DC Pro");
1242 }
1243 if (kind == GCM_CALIBRATE_REFERENCE_KIND_QPCARD_201) {
1244 /* TRANSLATORS: this is probably a brand name */
1245 return _("QPcard 201");
1246 }
1247 return NULL;
1248}
1249
1250/**
1251 * gcm_calib_reference_kind_to_image_filename:
1252 **/
1253static const gchar *
1254gcm_calib_reference_kind_to_image_filename (GcmCalibrateReferenceKind kind)
1255{
1256 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DIGITAL_TARGET_3)
1257 return "CMP-DigitalTarget3.png";
1258 if (kind == GCM_CALIBRATE_REFERENCE_KIND_CMP_DT_003)
1259 return "CMP_DT_003.png";
1260 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER)
1261 return "ColorChecker24.png";
1262 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_DC)
1263 return "ColorCheckerDC.png";
1264 if (kind == GCM_CALIBRATE_REFERENCE_KIND_COLOR_CHECKER_SG)
1265 return "ColorCheckerSG.png";
1266 if (kind == GCM_CALIBRATE_REFERENCE_KIND_HUTCHCOLOR)
1267 return NULL;
1268 if (kind == GCM_CALIBRATE_REFERENCE_KIND_I1_RGB_SCAN_1_4)
1269 return "i1_RGB_Scan_14.png";
1270 if (kind == GCM_CALIBRATE_REFERENCE_KIND_IT8)
1271 return "IT872.png";
1272 if (kind == GCM_CALIBRATE_REFERENCE_KIND_LASER_SOFT_DC_PRO)
1273 return "LaserSoftDCPro.png";
1274 if (kind == GCM_CALIBRATE_REFERENCE_KIND_QPCARD_201)
1275 return "QPcard_201.png";
1276 return NULL;
1277}
1278
1279/**
1280 * gcm_calib_reference_kind_combobox_cb:
1281 **/
1282static void
1283gcm_calib_reference_kind_combobox_cb (GtkComboBox *combo_box,
1284 GcmCalibratePriv *priv)
1285{
1286 const gchar *filename;
1287 gchar *path;
1288 GcmCalibrateReferenceKind reference_kind;
1289
1290 /* not sorted so we can just use the index */
1291 reference_kind = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
1292 g_object_set (priv->calibrate,
1293 "reference-kind", reference_kind,
1294 NULL);
1295 filename = gcm_calib_reference_kind_to_image_filename (reference_kind);
1296
1297 /* fallback */
1298 if (filename == NULL)
1299 filename = "unknown.png";
1300
1301 path = g_build_filename (GCM_DATA, "targets", filename, NULL);
1302 gtk_image_set_from_file (GTK_IMAGE (priv->reference_preview), path);
1303 g_free (path);
1304}
1305
1306/**
1307 * gcm_calib_setup_page_target_kind:
1308 **/
1309static void
1310gcm_calib_setup_page_target_kind (GcmCalibratePriv *priv)
1311{
1312 GtkWidget *vbox;
1313 GtkWidget *content;
1314 GtkWidget *combo;
1315 GString *string;
1316 guint i;
1317 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1318
1319 string = g_string_new ("");
1320
1321 /* TRANSLATORS: dialog message, preface. A calibration target looks like
1322 * this: http://www.colorreference.de/targets/target.jpg */
1323 g_string_append_printf (string, "%s\n", _("Before profiling the device, you have to manually capture an image of a calibration target and save it as a TIFF image file."));
1324
1325 /* scanner specific options */
1326 if (priv->device_kind == CD_DEVICE_KIND_SCANNER) {
1327 /* TRANSLATORS: dialog message, preface */
1328 g_string_append_printf (string, "%s\n", _("Ensure that the contrast and brightness are not changed and color correction profiles have not been applied."));
1329
1330 /* TRANSLATORS: dialog message, suffix */
1331 g_string_append_printf (string, "%s\n", _("The device sensor should have been cleaned prior to scanning and the output file resolution should be at least 200dpi."));
1332 }
1333
1334 /* camera specific options */
1335 if (priv->device_kind == CD_DEVICE_KIND_CAMERA) {
1336 /* TRANSLATORS: dialog message, preface */
1337 g_string_append_printf (string, "%s\n", _("Ensure that the white-balance has not been modified by the camera and that the lens is clean."));
1338 }
1339
1340 /* TRANSLATORS: this is the message body for the chart selection */
1341 g_string_append_printf (string, "\n%s", _("Please select the calibration target type."));
1342
1343 /* TRANSLATORS: this is the page title */
1344 vbox = gcm_calib_add_page_title (priv, _("What target type do you have?"));
1345
1346 /* main contents */
1347 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1348 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1349
1350 /* TRANSLATORS: this is intro page text */
1351 gcm_calib_add_page_para (content, string->str);
1352
1353 /* pack in a preview image */
1354 priv->reference_preview = gtk_image_new ();
1355 gtk_box_pack_start (GTK_BOX (vbox), priv->reference_preview, FALSE, FALSE, 0);
1356
1357 combo = gtk_combo_box_text_new ();
1358 for (i=0; i<GCM_CALIBRATE_REFERENCE_KIND_UNKNOWN; i++) {
1359 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo),
1360 gcm_calib_reference_kind_to_localised_string (i));
1361 }
1362 g_signal_connect (combo, "changed",
1363 G_CALLBACK (gcm_calib_reference_kind_combobox_cb),
1364 priv);
1365
1366 /* use IT8 by default */
1367 gtk_combo_box_set_active (GTK_COMBO_BOX (combo), GCM_CALIBRATE_REFERENCE_KIND_IT8);
1368
1369 gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
1370
1371 /* add to assistant */
1372 gtk_assistant_append_page (assistant, vbox);
1373 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1374 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1375 /* TRANSLATORS: this is the calibration wizard page title */
1376 gtk_assistant_set_page_title (assistant, vbox, _("Select Target"));
1377 g_ptr_array_add (priv->pages, vbox);
1378 g_object_set_data (G_OBJECT (vbox),
1379 "GcmCalibrateMain::Index",
1380 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_TARGET_KIND));
1381 g_string_free (string, TRUE);
1382
1383 /* show page */
1384 gtk_widget_show_all (vbox);
1385}
1386
1387static void
1388gcm_calib_display_kind_toggled_cb (GtkToggleButton *togglebutton,
1389 GcmCalibratePriv *priv)
1390{
1391 GcmCalibrateDisplayKind display_kind;
1392
1393 if (!gtk_toggle_button_get_active (togglebutton))
1394 return;
1395 display_kind = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1396 "GcmCalib::display-kind"));
1397 g_object_set (priv->calibrate,
1398 "display-kind", display_kind,
1399 NULL);
1400}
1401
1402/**
1403 * gcm_calib_setup_page_display_kind:
1404 **/
1405static void
1406gcm_calib_setup_page_display_kind (GcmCalibratePriv *priv)
1407{
1408 GtkWidget *vbox;
1409 GtkWidget *content;
1410 GtkWidget *widget;
1411 GSList *list;
1412 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1413
1414 /* TRANSLATORS: this is the page title */
1415 vbox = gcm_calib_add_page_title (priv, _("Choose your display type"));
1416
1417 /* main contents */
1418 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1419 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1420
1421 /* TRANSLATORS: this is intro page text */
1422 gcm_calib_add_page_para (content, _("Select the monitor type that is attached to your computer."));
1423
1424 widget = gtk_radio_button_new_with_label (NULL, _("LCD"));
1425 g_object_set_data (G_OBJECT (widget),
1426 "GcmCalib::display-kind",
1427 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_LCD));
1428 g_signal_connect (widget, "toggled",
1429 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1430 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1431
1432 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1433 widget = gtk_radio_button_new_with_label (list, _("CRT"));
1434 g_object_set_data (G_OBJECT (widget),
1435 "GcmCalib::display-kind",
1436 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_CRT));
1437 g_signal_connect (widget, "toggled",
1438 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1439 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1440
1441 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1442 widget = gtk_radio_button_new_with_label (list, _("Plasma"));
1443 g_object_set_data (G_OBJECT (widget),
1444 "GcmCalib::display-kind",
1445 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_CRT));
1446 g_signal_connect (widget, "toggled",
1447 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1448 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1449
1450 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1451 widget = gtk_radio_button_new_with_label (list, _("Projector"));
1452 g_object_set_data (G_OBJECT (widget),
1453 "GcmCalib::display-kind",
1454 GUINT_TO_POINTER (GCM_CALIBRATE_DEVICE_KIND_PROJECTOR));
1455 g_signal_connect (widget, "toggled",
1456 G_CALLBACK (gcm_calib_display_kind_toggled_cb), priv);
1457 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1458
1459 /* add to assistant */
1460 gtk_assistant_append_page (assistant, vbox);
1461 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1462 /* TRANSLATORS: this is the calibration wizard page title */
1463 gtk_assistant_set_page_title (assistant, vbox, _("Choose Display Type"));
1464 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1465 g_ptr_array_add (priv->pages, vbox);
1466 g_object_set_data (G_OBJECT (vbox),
1467 "GcmCalibrateMain::Index",
1468 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_KIND));
1469
1470 /* show page */
1471 gtk_widget_show_all (vbox);
1472}
1473
1474static void
1475gcm_calib_display_temp_toggled_cb (GtkToggleButton *togglebutton,
1476 GcmCalibratePriv *priv)
1477{
1478 guint display_temp;
1479 if (!gtk_toggle_button_get_active (togglebutton))
1480 return;
1481 display_temp = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1482 "GcmCalib::display-temp"));
1483 g_object_set (priv->calibrate,
1484 "target-whitepoint", display_temp,
1485 NULL);
1486}
1487
1488/**
1489 * gcm_calib_setup_page_display_temp:
1490 **/
1491static void
1492gcm_calib_setup_page_display_temp (GcmCalibratePriv *priv)
1493{
1494 GtkWidget *vbox;
1495 GtkWidget *content;
1496 GtkWidget *widget;
1497 GSList *list;
1498 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1499
1500 /* TRANSLATORS: this is the page title */
1501 vbox = gcm_calib_add_page_title (priv, _("Choose your display target white point"));
1502
1503 /* main contents */
1504 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1505 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1506
1507 /* TRANSLATORS: this is intro page text */
1508 gcm_calib_add_page_para (content, _("Most displays should be calibrated to a CIE D65 illuminant for general usage."));
1509
1510 widget = gtk_radio_button_new_with_label (NULL, _("CIE D50 (Printing and publishing)"));
1511 g_object_set_data (G_OBJECT (widget),
1512 "GcmCalib::display-temp",
1513 GUINT_TO_POINTER (5000));
1514 g_signal_connect (widget, "toggled",
1515 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1516 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1517
1518 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1519 widget = gtk_radio_button_new_with_label (list, _("CIE D55"));
1520 g_object_set_data (G_OBJECT (widget),
1521 "GcmCalib::display-temp",
1522 GUINT_TO_POINTER (5500));
1523 g_signal_connect (widget, "toggled",
1524 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1525 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1526
1527 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1528 widget = gtk_radio_button_new_with_label (list, _("CIE D65 (Photography and graphics)"));
1529 g_object_set_data (G_OBJECT (widget),
1530 "GcmCalib::display-temp",
1531 GUINT_TO_POINTER (6500));
1532 g_signal_connect (widget, "toggled",
1533 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1534 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1535 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
1536
1537 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1538 widget = gtk_radio_button_new_with_label (list, _("CIE D75"));
1539 g_object_set_data (G_OBJECT (widget),
1540 "GcmCalib::display-temp",
1541 GUINT_TO_POINTER (7500));
1542 g_signal_connect (widget, "toggled",
1543 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1544 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1545
1546 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1547 widget = gtk_radio_button_new_with_label (list, _("Native (Already set manually)"));
1548 g_object_set_data (G_OBJECT (widget),
1549 "GcmCalib::display-temp",
1550 GUINT_TO_POINTER (0));
1551 g_signal_connect (widget, "toggled",
1552 G_CALLBACK (gcm_calib_display_temp_toggled_cb), priv);
1553 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1554
1555 /* add to assistant */
1556 gtk_assistant_append_page (assistant, vbox);
1557 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1558 /* TRANSLATORS: this is the calibration wizard page title */
1559 gtk_assistant_set_page_title (assistant, vbox, _("Choose Display Whitepoint"));
1560 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1561 g_ptr_array_add (priv->pages, vbox);
1562 g_object_set_data (G_OBJECT (vbox),
1563 "GcmCalibrateMain::Index",
1564 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE));
1565
1566 /* show page */
1567 gtk_widget_show_all (vbox);
1568}
1569
1570static void
1571gcm_calib_print_kind_toggled_cb (GtkToggleButton *togglebutton,
1572 GcmCalibratePriv *priv)
1573{
1574 GcmCalibratePrintKind print_kind;
1575 if (!gtk_toggle_button_get_active (togglebutton))
1576 return;
1577 print_kind = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1578 "GcmCalib::print-kind"));
1579 g_object_set (priv->calibrate,
1580 "print-kind", print_kind,
1581 NULL);
1582}
1583
1584/**
1585 * gcm_calib_setup_page_print_kind:
1586 **/
1587static void
1588gcm_calib_setup_page_print_kind (GcmCalibratePriv *priv)
1589{
1590 GtkWidget *vbox;
1591 GtkWidget *content;
1592 GtkWidget *widget;
1593 GSList *list;
1594 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1595
1596 /* TRANSLATORS: this is the page title */
1597 vbox = gcm_calib_add_page_title (priv, _("Choose profiling mode"));
1598
1599 /* main contents */
1600 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1601 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1602
1603 /* TRANSLATORS: this is intro page text */
1604 gcm_calib_add_page_para (content, _("Please indicate if you want to profile a local printer, generate some test patches, or profile using existing test patches."));
1605
1606 widget = gtk_radio_button_new_with_label (NULL, "Local printer");
1607 g_object_set_data (G_OBJECT (widget),
1608 "GcmCalib::print-kind",
1609 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_LOCAL));
1610 g_signal_connect (widget, "toggled",
1611 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1612 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1613
1614 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1615 widget = gtk_radio_button_new_with_label (list, "Generate patches for remote printer");
1616 g_object_set_data (G_OBJECT (widget),
1617 "GcmCalib::print-kind",
1618 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_GENERATE));
1619 g_signal_connect (widget, "toggled",
1620 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1621 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1622
1623 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1624 widget = gtk_radio_button_new_with_label (list, "Generate profile from existing test patches");
1625 g_object_set_data (G_OBJECT (widget),
1626 "GcmCalib::print-kind",
1627 GUINT_TO_POINTER (GCM_CALIBRATE_PRINT_KIND_ANALYZE));
1628 g_signal_connect (widget, "toggled",
1629 G_CALLBACK (gcm_calib_print_kind_toggled_cb), priv);
1630 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1631
1632 /* sync the default */
1633 g_object_set (priv->calibrate,
1634 "print-kind", GCM_CALIBRATE_PRINT_KIND_LOCAL,
1635 NULL);
1636
1637 /* add to assistant */
1638 gtk_assistant_append_page (assistant, vbox);
1639 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1640 /* TRANSLATORS: this is the calibration wizard page title */
1641 gtk_assistant_set_page_title (assistant, vbox, _("Calibration Mode"));
1642 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1643 g_ptr_array_add (priv->pages, vbox);
1644 g_object_set_data (G_OBJECT (vbox),
1645 "GcmCalibrateMain::Index",
1646 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_PRINT_KIND));
1647
1648 /* show page */
1649 gtk_widget_show_all (vbox);
1650}
1651
1652static void
1653gcm_calib_precision_toggled_cb (GtkToggleButton *togglebutton,
1654 GcmCalibratePriv *priv)
1655{
1656 GcmCalibratePrecision precision;
1657 if (!gtk_toggle_button_get_active (togglebutton))
1658 return;
1659 precision = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (togglebutton),
1660 "GcmCalib::precision"));
1661 g_object_set (priv->calibrate,
1662 "precision", precision,
1663 NULL);
1664}
1665
1666/**
1667 * gcm_calib_setup_page_precision:
1668 **/
1669static void
1670gcm_calib_setup_page_precision (GcmCalibratePriv *priv)
1671{
1672 GtkWidget *vbox;
1673 GtkWidget *content;
1674 GtkWidget *widget;
1675 GSList *list;
1676 GString *labels[3];
1677 guint i;
1678 guint values_printer[] = { 6, 4, 2}; /* sheets */
1679 guint values_display[] = { 30, 20, 10}; /* minutes */
1680 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1681
1682 /* TRANSLATORS: this is the page title */
1683 vbox = gcm_calib_add_page_title (priv, _("Choose calibration quality"));
1684
1685 /* main contents */
1686 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1687 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1688
1689 /* TRANSLATORS: this is intro page text */
1690 gcm_calib_add_page_para (content, _("Higher quality calibration requires many color samples and more time."));
1691
1692#if 0
1693 /* TRANSLATORS: this is the message body for the chart selection */
1694 g_string_append (string, _("A higher precision profile provides higher accuracy in color matching but requires more time for reading the color patches."));
1695
1696 /* TRANSLATORS: this is the message body for the chart selection */
1697 g_string_append_printf (string, "\n%s", _("For a typical workflow, a normal precision profile is sufficient."));
1698
1699 /* printer specific options */
1700 if (priv->device_kind == CD_DEVICE_KIND_PRINTER) {
1701 /* TRANSLATORS: dialog message, preface */
1702 g_string_append_printf (string, "\n%s", _("The high precision profile also requires more paper and printer ink."));
1703 }
1704#endif
1705
1706 /* TRANSLATORS: radio options for calibration precision */
1707 labels[0] = g_string_new (_("Accurate"));
1708 labels[1] = g_string_new (_("Normal"));
1709 labels[2] = g_string_new (_("Quick"));
1710 switch (priv->device_kind) {
1711 case CD_DEVICE_KIND_PRINTER:
1712 for (i=0; i<3; i++) {
1713 g_string_append (labels[i], " ");
1714 /* TRANSLATORS: radio options for calibration precision */
1715 g_string_append_printf (labels[i], ngettext (
1716 "(about %i sheet of paper)",
1717 "(about %i sheets of paper)",
1718 values_printer[i]),
1719 values_printer[i]);
1720 }
1721 break;
1722 case CD_DEVICE_KIND_DISPLAY:
1723 for (i=0; i<3; i++) {
1724 g_string_append (labels[i], " ");
1725 /* TRANSLATORS: radio options for calibration precision */
1726 g_string_append_printf (labels[i], ngettext (
1727 "(about %i minute)",
1728 "(about %i minutes)",
1729 values_display[i]),
1730 values_display[i]);
1731 }
1732 break;
1733 default:
1734 break;
1735 }
1736
1737 widget = gtk_radio_button_new_with_label (NULL, labels[0]->str);
1738 g_object_set_data (G_OBJECT (widget),
1739 "GcmCalib::precision",
1740 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_LONG));
1741 g_signal_connect (widget, "toggled",
1742 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1743 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1744
1745 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1746 widget = gtk_radio_button_new_with_label (list, labels[1]->str);
1747 g_object_set_data (G_OBJECT (widget),
1748 "GcmCalib::precision",
1749 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_NORMAL));
1750 g_signal_connect (widget, "toggled",
1751 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1752 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1753 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
1754
1755 list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
1756 widget = gtk_radio_button_new_with_label (list, labels[2]->str);
1757 g_object_set_data (G_OBJECT (widget),
1758 "GcmCalib::precision",
1759 GUINT_TO_POINTER (GCM_CALIBRATE_PRECISION_SHORT));
1760 g_signal_connect (widget, "toggled",
1761 G_CALLBACK (gcm_calib_precision_toggled_cb), priv);
1762 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1763
1764 /* add to assistant */
1765 gtk_assistant_append_page (assistant, vbox);
1766 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1767 /* TRANSLATORS: this is the calibration wizard page title */
1768 gtk_assistant_set_page_title (assistant, vbox, _("Calibration Quality"));
1769 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1770 g_ptr_array_add (priv->pages, vbox);
1771 g_object_set_data (G_OBJECT (vbox),
1772 "GcmCalibrateMain::Index",
1773 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_PRECISION));
1774
1775 for (i=0; i<3; i++)
1776 g_string_free (labels[i], TRUE);
1777
1778 /* show page */
1779 gtk_widget_show_all (vbox);
1780}
1781
1782static void
1783gcm_calib_text_changed_cb (GtkEntry *entry,
1784 GcmCalibratePriv *priv)
1785{
1786 g_object_set (priv->calibrate,
1787 "description", gtk_entry_get_text (entry),
1788 NULL);
1789}
1790
1791/**
1792 * gcm_calib_setup_page_profile_title:
1793 **/
1794static void
1795gcm_calib_setup_page_profile_title (GcmCalibratePriv *priv)
1796{
1797 GtkWidget *vbox;
1798 GtkWidget *content;
1799 GtkWidget *widget;
1800 gchar *tmp = NULL;
1801 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1802
1803 /* TRANSLATORS: this is the page title */
1804 vbox = gcm_calib_add_page_title (priv, _("Profile title"));
1805
1806 /* main contents */
1807 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1808 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1809
1810 /* TRANSLATORS: this is intro page text */
1811 gcm_calib_add_page_para (content, _("Choose a title to identify the profile on your system."));
1812
1813 widget = gtk_entry_new ();
1814 gtk_box_pack_start (GTK_BOX (content), widget, FALSE, FALSE, 0);
1815 gtk_entry_set_max_length (GTK_ENTRY (widget), 128);
1816
1817 /* set the current title */
1818 g_object_get (priv->calibrate,
1819 "description", &tmp,
1820 NULL);
1821 gtk_entry_set_text (GTK_ENTRY (widget), tmp);
1822 g_free (tmp);
1823
1824 /* watch for changes */
1825 g_signal_connect (GTK_EDITABLE (widget), "changed",
1826 G_CALLBACK (gcm_calib_text_changed_cb), priv);
1827
1828 /* add to assistant */
1829 gtk_assistant_append_page (assistant, vbox);
1830 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1831 /* TRANSLATORS: this is the calibration wizard page title */
1832 gtk_assistant_set_page_title (assistant, vbox, _("Profile Title"));
1833 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1834 g_ptr_array_add (priv->pages, vbox);
1835 g_object_set_data (G_OBJECT (vbox),
1836 "GcmCalibrateMain::Index",
1837 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_TITLE));
1838
1839 /* show page */
1840 gtk_widget_show_all (vbox);
1841}
1842
1843/**
1844 * gcm_calib_setup_page_sensor:
1845 **/
1846static void
1847gcm_calib_setup_page_sensor (GcmCalibratePriv *priv)
1848{
1849 GtkWidget *vbox;
1850 GtkWidget *content;
1851 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1852
1853 /* TRANSLATORS: this is the page title */
1854 vbox = gcm_calib_add_page_title (priv, _("Insert sensor hardware"));
1855
1856 /* main contents */
1857 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1858 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1859
1860 /* TRANSLATORS: this is intro page text */
1861 gcm_calib_add_page_para (content, _("You need to insert sensor hardware to continue."));
1862
1863 /* add to assistant */
1864 gtk_assistant_append_page (assistant, vbox);
1865 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_CONTENT);
1866 /* TRANSLATORS: this is the calibration wizard page title */
1867 gtk_assistant_set_page_title (assistant, vbox, _("Sensor Check"));
1868 gtk_assistant_set_page_complete (assistant, vbox, FALSE);
1869 g_ptr_array_add (priv->pages, vbox);
1870 g_object_set_data (G_OBJECT (vbox),
1871 "GcmCalibrateMain::Index",
1872 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_SENSOR));
1873
1874 /* show page */
1875 gtk_widget_show_all (vbox);
1876}
1877
1878/**
1879 * gcm_calib_setup_page_failure:
1880 **/
1881static void
1882gcm_calib_setup_page_failure (GcmCalibratePriv *priv)
1883{
1884 GtkWidget *vbox;
1885 GtkWidget *content;
1886 GtkAssistant *assistant = GTK_ASSISTANT (priv->main_window);
1887
1888 /* TRANSLATORS: this is the page title */
1889 vbox = gcm_calib_add_page_title (priv, _("Failed to calibrate"));
1890
1891 /* main contents */
1892 content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
1893 gtk_box_pack_start (GTK_BOX (vbox), content, FALSE, FALSE, 0);
1894
1895 /* TRANSLATORS: this is intro page text */
1896 gcm_calib_add_page_para (content, _("The device could not be found. Ensure it is plugged in and turned on."));
1897
1898 /* add to assistant */
1899 gtk_assistant_append_page (assistant, vbox);
1900 gtk_assistant_set_page_type (assistant, vbox, GTK_ASSISTANT_PAGE_SUMMARY);
1901 /* TRANSLATORS: this is the calibration wizard page title */
1902 gtk_assistant_set_page_title (assistant, vbox, _("Summary"));
1903 gtk_assistant_set_page_complete (assistant, vbox, TRUE);
1904 g_ptr_array_add (priv->pages, vbox);
1905 g_object_set_data (G_OBJECT (vbox),
1906 "GcmCalibrateMain::Index",
1907 GUINT_TO_POINTER (GCM_CALIBRATE_PAGE_FAILURE));
1908
1909 /* show page */
1910 gtk_widget_show_all (vbox);
1911}
1912
1913/**
1914 * gcm_calib_got_sensor:
1915 **/
1916static void
1917gcm_calib_got_sensor (GcmCalibratePriv *priv, CdSensor *sensor)
1918{
1919 gboolean is_lowend = FALSE;
1920 gboolean ret;
1921 GError *error = NULL;
1922 GtkWidget *vbox;
1923
1924 /* connect to sensor */
1925 ret = cd_sensor_connect_sync (sensor, NULL, &error);
1926 if (!ret) {
1927 g_warning ("failed to connect to sensor: %s",
1928 error->message);
1929 g_error_free (error);
1930 goto out;
1931 }
1932 gcm_calibrate_set_sensor (priv->calibrate, sensor);
1933
1934 /* hide the prompt for the user to insert a sensor */
1935 vbox = gcm_calib_get_vbox_for_page (priv,
1936 GCM_CALIBRATE_PAGE_SENSOR);
1937 gtk_widget_hide (vbox);
1938
1939 /* if the device is a simple colorimeter, hide the temperature
1940 * chooser. Only expensive accurate spectrophotometers are
1941 * accurate enough to do a good job without a color cast */
1942 if (cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_COLORHUG) {
1943 is_lowend = TRUE;
1944 }
1945 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
1946 vbox = gcm_calib_get_vbox_for_page (priv,
1947 GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE);
1948 gtk_widget_set_visible (vbox, !is_lowend);
1949 }
1950out:
1951 return;
1952}
1953
1954/**
1955 * gcm_calib_get_sensors_cb:
1956 **/
1957static void
1958gcm_calib_get_sensors_cb (GObject *object,
1959 GAsyncResult *res,
1960 gpointer user_data)
1961{
1962 CdClient *client = CD_CLIENT (object);
1963 CdSensor *sensor_tmp;
1964 GcmCalibratePriv *priv = (GcmCalibratePriv *) user_data;
1965 GError *error = NULL;
1966 GPtrArray *sensors;
1967
1968 /* get the result */
1969 sensors = cd_client_get_sensors_finish (client, res, &error);
1970 if (sensors == NULL) {
1971 g_warning ("failed to get sensors: %s",
1972 error->message);
1973 g_error_free (error);
1974 goto out;
1975 }
1976
1977 /* we've got a sensor */
1978 if (sensors->len != 0) {
1979 sensor_tmp = g_ptr_array_index (sensors, 0);
1980 gcm_calib_got_sensor (priv, sensor_tmp);
1981 }
1982out:
1983 if (sensors != NULL)
1984 g_ptr_array_unref (sensors);
1985}
1986
1987/**
1988 * gcm_calib_add_pages:
1989 **/
1990static void
1991gcm_calib_add_pages (GcmCalibratePriv *priv)
1992{
1993 gboolean ret;
1994 const gchar *xrandr_name;
1995
1996 /* device not found */
1997 if (priv->device_kind == CD_DEVICE_KIND_UNKNOWN) {
1998 gcm_calib_setup_page_failure (priv);
1999 gtk_widget_show_all (GTK_WIDGET (priv->main_window));
2000 return;
2001 }
2002
2003 gcm_calib_setup_page_intro (priv);
2004
2005 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY ||
2006 priv->device_kind == CD_DEVICE_KIND_PRINTER)
2007 gcm_calib_setup_page_sensor (priv);
2008
2009 /* find whether argyllcms is installed using a tool which should exist */
2010 ret = gcm_calibrate_get_enabled (priv->calibrate);
2011 if (!ret)
2012 gcm_calib_setup_page_install_argyllcms (priv);
2013
2014 xrandr_name = cd_device_get_metadata_item (priv->device,
2015 CD_DEVICE_METADATA_XRANDR_NAME);
2016 if (xrandr_name != NULL)
2017 priv->internal_lcd = gcm_utils_output_is_lcd_internal (xrandr_name);
2018 if (!priv->internal_lcd && priv->device_kind == CD_DEVICE_KIND_DISPLAY)
2019 gcm_calib_setup_page_display_configure_wait (priv);
2020
2021 gcm_calib_setup_page_precision (priv);
2022
2023 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2024 if (!priv->internal_lcd) {
2025 gcm_calib_setup_page_display_kind (priv);
2026 } else {
2027 g_object_set (priv->calibrate,
2028 "display-kind", GCM_CALIBRATE_DEVICE_KIND_LCD,
2029 NULL);
2030 }
2031 gcm_calib_setup_page_display_temp (priv);
2032 } else if (priv->device_kind == CD_DEVICE_KIND_PRINTER) {
2033 gcm_calib_setup_page_print_kind (priv);
2034 } else {
2035 gcm_calib_setup_page_target_kind (priv);
2036 ret = g_file_test ("/usr/share/shared-color-targets", G_FILE_TEST_IS_DIR);
2037 if (!ret)
2038 gcm_calib_setup_page_install_targets (priv);
2039 }
2040
2041 gcm_calib_setup_page_profile_title (priv);
2042 gcm_calib_setup_page_action (priv);
2043
2044 gcm_calib_setup_page_summary (priv);
2045
2046 /* see if we can hide the sensor check */
2047 cd_client_get_sensors (priv->client,
2048 NULL,
2049 gcm_calib_get_sensors_cb,
2050 priv);
2051}
2052
2053/**
2054 * gcm_calib_sensor_added_cb:
2055 **/
2056static void
2057gcm_calib_sensor_added_cb (CdClient *client, CdSensor *sensor, GcmCalibratePriv *priv)
2058{
2059 g_debug ("sensor inserted");
2060 gcm_calib_got_sensor (priv, sensor);
2061 gtk_assistant_next_page (GTK_ASSISTANT (priv->main_window));
2062}
2063
2064/**
2065 * gcm_calib_startup_cb:
2066 **/
2067static void
2068gcm_calib_startup_cb (GApplication *application, GcmCalibratePriv *priv)
2069{
2070 const gint window_width = 640;
2071 const gint window_height = 440;
2072
2073 const gchar *description;
2074 const gchar *manufacturer;
2075 const gchar *model;
2076 const gchar *native_device;
2077 const gchar *serial;
2078 gchar *copyright = NULL;
2079 gboolean ret;
2080 GDateTime *dt = NULL;
2081 GError *error = NULL;
2082
2083 /* add application specific icons to search path */
2084 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
2085 GCM_DATA G_DIR_SEPARATOR_S "icons");
2086
2087 /* connect to colord */
2088 priv->client = cd_client_new ();
2089 g_signal_connect (priv->client, "sensor-added",
2090 G_CALLBACK (gcm_calib_sensor_added_cb), priv);
2091 ret = cd_client_connect_sync (priv->client,
2092 NULL,
2093 &error);
2094 if (!ret) {
2095 g_warning ("failed to connect to colord: %s",
2096 error->message);
2097 g_error_free (error);
2098 goto out;
2099 }
2100
2101 /* show main UI */
2102 priv->main_window = GTK_WINDOW (gtk_assistant_new ());
2103 gtk_window_set_default_size (priv->main_window, window_width, window_height);
2104 gtk_window_set_resizable (priv->main_window, TRUE);
2105 gtk_window_set_title (priv->main_window, "");
2106 gtk_container_set_border_width (GTK_CONTAINER (priv->main_window), 12);
2107 g_signal_connect (priv->main_window, "delete_event",
2108 G_CALLBACK (gcm_calib_delete_event_cb), priv);
2109 g_signal_connect (priv->main_window, "close",
2110 G_CALLBACK (gcm_calib_assistant_close_cb), priv);
2111 g_signal_connect (priv->main_window, "cancel",
2112 G_CALLBACK (gcm_calib_assistant_cancel_cb), priv);
2113 g_signal_connect (priv->main_window, "prepare",
2114 G_CALLBACK (gcm_calib_assistant_prepare_cb), priv);
2115 gtk_application_add_window (priv->application,
2116 priv->main_window);
2117
2118 /* set the parent window if it is specified */
2119 if (priv->xid != 0) {
2120 g_debug ("Setting xid %i", priv->xid);
2121 gcm_window_set_parent_xid (GTK_WINDOW (priv->main_window), priv->xid);
2122 }
2123
2124 /* select a specific profile only */
2125 priv->device = cd_client_find_device_sync (priv->client,
2126 priv->device_id,
2127 NULL,
2128 &error);
2129 if (priv->device == NULL) {
2130 g_warning ("failed to get device %s: %s",
2131 priv->device_id,
2132 error->message);
2133 g_error_free (error);
2134 goto out;
2135 }
2136
2137 /* connect to the device */
2138 ret = cd_device_connect_sync (priv->device,
2139 NULL,
2140 &error);
2141 if (!ret) {
2142 g_warning ("failed to connect to device: %s",
2143 error->message);
2144 g_error_free (error);
2145 goto out;
2146 }
2147
2148 /* get the device properties */
2149 priv->device_kind = cd_device_get_kind (priv->device);
2150
2151 /* for display calibration move the window to lower right area to
2152 * limit argyll from obscuring the window (too much) */
2153 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2154 gtk_window_set_gravity (priv->main_window, GDK_GRAVITY_SOUTH_EAST);
2155 gtk_window_move (priv->main_window, gdk_screen_width() - window_width,
2156 gdk_screen_height() - window_height);
2157 }
2158
2159 /* set, with fallbacks */
2160 serial = cd_device_get_serial (priv->device);
2161 if (serial == NULL) {
2162 /* TRANSLATORS: this is saved in the profile */
2163 serial = _("Unknown serial");
2164 }
2165 model = cd_device_get_model (priv->device);
2166 if (model == NULL) {
2167 /* TRANSLATORS: this is saved in the profile */
2168 model = _("Unknown model");
2169 }
2170 description = cd_device_get_model (priv->device);
2171 if (description == NULL) {
2172 /* TRANSLATORS: this is saved in the profile */
2173 description = _("Unknown description");
2174 }
2175 manufacturer = cd_device_get_vendor (priv->device);
2176 if (manufacturer == NULL) {
2177 /* TRANSLATORS: this is saved in the profile */
2178 manufacturer = _("Unknown manufacturer");
2179 }
2180
2181 dt = g_date_time_new_now_local ();
2182 /* TRANSLATORS: this is the copyright string, where it might be
2183 * "Copyright (c) 2009 Edward Scissorhands"
2184 * BIG RED FLASHING NOTE: YOU NEED TO USE ASCII ONLY */
2185 copyright = g_strdup_printf ("%s %04i %s", _("Copyright (c)"),
2186 g_date_time_get_year (dt),
2187 g_get_real_name ());
2188
2189 /* set the proper values */
2190 g_object_set (priv->calibrate,
2191 "device-kind", priv->device_kind,
2192 "model", model,
2193 "description", description,
2194 "manufacturer", manufacturer,
2195 "serial", serial,
2196 "copyright", copyright,
2197 NULL);
2198
2199 /* display specific properties */
2200 if (priv->device_kind == CD_DEVICE_KIND_DISPLAY) {
2201 native_device = cd_device_get_metadata_item (priv->device,
2202 CD_DEVICE_METADATA_XRANDR_NAME);
2203 if (native_device == NULL) {
2204 g_warning ("failed to get output");
2205 goto out;
2206 }
2207 g_object_set (priv->calibrate,
2208 "output-name", native_device,
2209 NULL);
2210 }
2211out:
2212 /* add different pages depending on the device kind */
2213 gcm_calib_add_pages (priv);
2214 gtk_assistant_set_current_page (GTK_ASSISTANT (priv->main_window), 0);
2215 if (dt != NULL)
2216 g_date_time_unref (dt);
2217 g_free (copyright);
2218}
2219
2220static void
2221gcm_calib_title_changed_cb (GcmCalibrate *calibrate,
2222 const gchar *title,
2223 GcmCalibratePriv *priv)
2224{
2225 gchar *markup;
2226
2227 markup = g_strdup_printf ("<span size=\"large\" font_weight=\"bold\">%s</span>", title);
2228 gtk_label_set_markup (GTK_LABEL (priv->action_title), markup);
2229 g_free (markup);
2230}
2231
2232static void
2233gcm_calib_message_changed_cb (GcmCalibrate *calibrate,
2234 const gchar *title,
2235 GcmCalibratePriv *priv)
2236{
2237 gtk_label_set_label (GTK_LABEL (priv->action_message), title);
2238}
2239
2240static void
2241gcm_calib_progress_changed_cb (GcmCalibrate *calibrate,
2242 guint percentage,
2243 GcmCalibratePriv *priv)
2244{
2245 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->action_progress),
2246 percentage / 100.0f);
2247}
2248
2249static void
2250gcm_calib_image_changed_cb (GcmCalibrate *calibrate,
2251 const gchar *filename,
2252 GcmCalibratePriv *priv)
2253{
2254 GdkPixbuf *pixbuf;
2255 GError *error = NULL;
2256
2257 if (filename != NULL) {
2258 pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 200, 400, &error);
2259 if (pixbuf == NULL) {
2260 g_warning ("failed to load image: %s", error->message);
2261 g_error_free (error);
2262 gtk_widget_hide (priv->action_image);
2263 } else {
2264 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->action_image), pixbuf);
2265 gtk_widget_show (priv->action_image);
2266 }
2267 } else {
2268 gtk_widget_hide (priv->action_image);
2269 }
2270}
2271
2272static void
2273gcm_calib_interaction_required_cb (GcmCalibrate *calibrate,
2274 const gchar *button_text,
2275 GcmCalibratePriv *priv)
2276{
2277 GtkWidget *vbox;
2278 vbox = gcm_calib_get_vbox_for_page (priv,
2279 GCM_CALIBRATE_PAGE_ACTION);
2280 gtk_assistant_set_page_complete (GTK_ASSISTANT (priv->main_window),
2281 vbox, TRUE);
2282 priv->has_pending_interaction = TRUE;
2283}
2284
2285/**
2286 * main:
2287 **/
2288int
2289main (int argc, char **argv)
2290{
2291 gchar *device_id = NULL;
2292 GcmCalibratePriv *priv;
2293 GOptionContext *context;
2294 guint xid = 0;
2295 int status = 0;
2296
2297 const GOptionEntry options[] = {
2298 { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid,
2299 /* TRANSLATORS: we can make this modal (stay on top of) another window */
2300 _("Set the parent window to make this modal"), NULL },
2301 { "device", 'd', 0, G_OPTION_ARG_STRING, &device_id,
2302 /* TRANSLATORS: show just the one profile, rather than all */
2303 _("Set the specific device to calibrate"), NULL },
2304 { NULL}
2305 };
2306
2307 setlocale (LC_ALL, "");
2308
2309 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
2310 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
2311 textdomain (GETTEXT_PACKAGE);
2312
2313 gtk_init (&argc, &argv);
2314
2315 context = g_option_context_new ("gnome-color-manager calibration tool");
2316 g_option_context_add_main_entries (context, options, NULL);
2317 g_option_context_add_group (context, gcm_debug_get_option_group ());
2318 g_option_context_add_group (context, gtk_get_option_group (TRUE));
2319 g_option_context_parse (context, &argc, &argv, NULL);
2320 g_option_context_free (context);
2321
2322 priv = g_new0 (GcmCalibratePriv, 1);
2323 priv->pages = g_ptr_array_new ();
2324 priv->xid = xid;
2325 priv->device_id = device_id;
2326 priv->calibrate = gcm_calibrate_argyll_new ();
2327 g_object_set (priv->calibrate,
2328 "precision", GCM_CALIBRATE_PRECISION_LONG,
2329 NULL);
2330 priv->device_kind = CD_DEVICE_KIND_UNKNOWN;
2331 g_signal_connect (priv->calibrate, "title-changed",
2332 G_CALLBACK (gcm_calib_title_changed_cb), priv);
2333 g_signal_connect (priv->calibrate, "message-changed",
2334 G_CALLBACK (gcm_calib_message_changed_cb), priv);
2335 g_signal_connect (priv->calibrate, "image-changed",
2336 G_CALLBACK (gcm_calib_image_changed_cb), priv);
2337 g_signal_connect (priv->calibrate, "progress-changed",
2338 G_CALLBACK (gcm_calib_progress_changed_cb), priv);
2339 g_signal_connect (priv->calibrate, "interaction-required",
2340 G_CALLBACK (gcm_calib_interaction_required_cb), priv);
2341
2342 /* nothing specified */
2343 if (priv->device_id == NULL) {
2344 g_print ("%s\n", _("No device was specified!"));
2345 goto out;
2346 }
2347
2348 /* ensure single instance */
2349 priv->application = gtk_application_new ("org.gnome.ColorManager.Calibration", 0);
2350 g_signal_connect (priv->application, "startup",
2351 G_CALLBACK (gcm_calib_startup_cb), priv);
2352 g_signal_connect (priv->application, "activate",
2353 G_CALLBACK (gcm_calib_activate_cb), priv);
2354
2355 /* wait */
2356 status = g_application_run (G_APPLICATION (priv->application), argc, argv);
2357
2358 g_ptr_array_unref (priv->pages);
2359 g_object_unref (priv->application);
2360 g_object_unref (priv->calibrate);
2361 if (priv->client != NULL)
2362 g_object_unref (priv->client);
2363 if (priv->device_id != NULL)
2364 g_free (priv->device_id);
2365 if (priv->device != NULL)
2366 g_object_unref (priv->device);
2367 g_free (priv);
2368out:
2369 return status;
2370}
23710
=== added file '.pc/applied-patches'
--- .pc/applied-patches 1970-01-01 00:00:00 +0000
+++ .pc/applied-patches 2015-01-02 20:29:31 +0000
@@ -0,0 +1,1 @@
101_unity_control_center.patch
02
=== removed file '.pc/applied-patches'
--- .pc/applied-patches 2014-01-15 16:15:06 +0000
+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
101_unity_control_center.patch
20
=== modified file 'ChangeLog'
--- ChangeLog 2013-09-21 20:59:17 +0000
+++ ChangeLog 2015-01-02 20:29:31 +0000
@@ -1,12 +1,1489 @@
1commit 1372f2ad40edf6859be7164e7105c96963a4821b1commit 5d41872e5e61c7163e4f576c8adc6f1f7714c9e6
2Author: Richard Hughes <richard@hughsie.com>2Author: Richard Hughes <richard@hughsie.com>
3Date: 2013-09-133Date: 2014-11-10
44
5 Release version 3.8.35 Release version 3.14.2
66
7M NEWS7M NEWS
88
9commit 210739aa088a2771adc4b69fa5c718b6819088ef9commit 638f1518dd5ec3454b545ba660a08dc8d3809f76
10Author: Baurzhan Muftakhidinov <baurthefirst@gmail.com>
11Date: 2014-11-05
12
13 Updated Kazakh translation
14
15M po/kk.po
16
17commit 5c2a1495a67a6b33432fc14af76542530e035c80
18Author: Richard Hughes <richard@hughsie.com>
19Date: 2014-10-12
20
21 trivial: Fix up the homepage address
22
23M gnome-color-manager.doap
24
25commit 7186351d915ad1772675911603c2c5e9f386b0b2
26Author: Richard Hughes <richard@hughsie.com>
27Date: 2014-10-12
28
29 trivial: Post release version bump
30
31M RELEASE
32M configure.ac
33
34commit 18d192ad31f9ce77debb4236e12d4fc31a4f76b3
35Author: Richard Hughes <richard@hughsie.com>
36Date: 2014-10-12
37
38 trivial: Fix a small compile warning
39
40M src/gcm-utils.c
41
42commit f83a0c12a83642816ec914f44c2294c4103a45e7
43Author: Richard Hughes <richard@hughsie.com>
44Date: 2014-10-12
45
46 Release version 3.14.1
47
48M NEWS
49
50commit f9ce2a35d95d3a64d7d6c3a6899e519b7a8f9af3
51Author: Fabio Tomat <f.t.public@gmail.com>
52Date: 2014-10-11
53
54 Added Friulian translation
55
56M po/LINGUAS
57A po/fur.po
58
59commit a1dba885f84f3a3779e93944aca6fa66893c0d72
60Author: Arash Mousavi <mousavi.arash@gmail.com>
61Date: 2014-10-10
62
63 Updates Persian Translations
64
65M po/fa.po
66
67commit 53bcec7250cb72e45d00383486fbbeba0ff74df8
68Author: Richard Hughes <richard@hughsie.com>
69Date: 2014-10-08
70
71 Prevent a crash when profiling a printer
72
73 Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=732869
74
75M src/gcm-print.c
76
77commit 9938cf72ca5830bae5021fd1d22bcf464992cfb2
78Author: Changwoo Ryu <cwryu@debian.org>
79Date: 2014-10-05
80
81 Updated Korean translation
82
83M po/ko.po
84
85commit 1754afbfebbe620c22355d9cff7dd97fafb7a238
86Author: Saibal Ray <sray@redhat.com>
87Date: 2014-09-24
88
89 Updated Bengali (India) translation
90
91M po/bn_IN.po
92
93commit c72571357088722695e0fa061d6784257bf2e831
94Author: Krishnababu Krothapalli <k.meetme@gmail.com>
95Date: 2014-09-23
96
97 Updated Telugu translation
98
99M po/te.po
100
101commit beddd6071ff59714553f3f585345c9ce9b19195d
102Author: Richard Hughes <richard@hughsie.com>
103Date: 2014-09-23
104
105 trivial: Post release version bump
106
107M RELEASE
108M configure.ac
109
110commit df8185ae82d92f23bb70c605f6769d72b00ee0f2
111Author: Richard Hughes <richard@hughsie.com>
112Date: 2014-09-23
113
114 Release version 3.14.0
115
116M NEWS
117M RELEASE
118M configure.ac
119
120commit 18771b62c3bf943ef5cb1fc3c7cc26e23849892e
121Author: Rajesh Ranjan <rajeshkajha@yahoo.com>
122Date: 2014-09-22
123
124 Updated Hindi translation
125
126M po/hi.po
127
128commit aebc4009ba48670ebb5c02f6022363765889b9fb
129Author: Мирослав Николић <miroslavnikolic@rocketmail.com>
130Date: 2014-09-19
131
132 Updated Serbian translation
133
134M po/sr.po
135M po/sr@latin.po
136
137commit fcc132f54021efd009ab32055e263b0dd7ee90ae
138Author: Manoj Kumar Giri <mgiri@redhat.com>
139Date: 2014-09-19
140
141 Updated Oriya translation
142
143M po/or.po
144
145commit 81cd70429a207fe3df20dd16baa38abbbdbc4e56
146Author: Pawan Chitrakar <chautari@gmail.com>
147Date: 2014-09-17
148
149 Updated Nepali translation
150
151M po/ne.po
152
153commit d38229f6e21e5aa48ece3d9b796464748ab32d6c
154Author: Changwoo Ryu <cwryu@debian.org>
155Date: 2014-09-18
156
157 Updated Korean translation
158
159M po/ko.po
160
161commit 70f788c46f55fc0b620e65058974dd2f6eeaff75
162Author: Saibal Ray <sray@redhat.com>
163Date: 2014-09-17
164
165 Updated Bengali (India) translation
166
167M po/bn_IN.po
168
169commit fa5333274adf7a029c0f9c9521faf186b025186b
170Author: Shantha kumar <shantha.thamizh@gmail.com>
171Date: 2014-09-15
172
173 Updated Tamil translation
174
175M po/ta.po
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: