~noskcaj/ubuntu/vivid/gnome-color-manager/3.14

« back to all changes in this revision

Viewing changes to src/gcm-calibrate-main.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-05-14 23:22:58 UTC
  • mfrom: (1.3.9) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120514232258-vcsf3zk2whtpbt17
Tags: 3.4.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
481
481
}
482
482
 
483
483
/**
 
484
 * gcm_calibrate_show_profile_location:
 
485
 **/
 
486
static void
 
487
gcm_calibrate_show_profile_location (void)
 
488
{
 
489
        gboolean ret;
 
490
        gchar *command_line;
 
491
        GError *error = NULL;
 
492
 
 
493
        /* just hardcode nautilus to open the folder */
 
494
        command_line = g_strdup_printf ("nautilus %s/%s",
 
495
                                        g_get_user_data_dir (),
 
496
                                        "icc");
 
497
        ret = g_spawn_command_line_async (command_line, &error);
 
498
        if (!ret) {
 
499
                g_warning ("failed to show profile: %s", error->message);
 
500
                g_error_free (error);
 
501
                goto out;
 
502
        }
 
503
out:
 
504
        g_free (command_line);
 
505
}
 
506
 
 
507
/**
 
508
 * gcm_calibrate_is_livecd:
 
509
 **/
 
510
static gboolean
 
511
gcm_calibrate_is_livecd (void)
 
512
{
 
513
        gboolean ret;
 
514
        gchar *data = NULL;
 
515
        GError *error = NULL;
 
516
 
 
517
        /* get the kernel commandline */
 
518
        ret = g_file_get_contents ("/proc/cmdline", &data, NULL, &error);
 
519
        if (!ret) {
 
520
                g_warning ("failed to get kernel command line: %s",
 
521
                           error->message);
 
522
                g_error_free (error);
 
523
                goto out;
 
524
        }
 
525
        ret = g_strstr_len (data, -1, "liveimg") != NULL;
 
526
out:
 
527
        g_free (data);
 
528
        return ret;
 
529
}
 
530
 
 
531
/**
484
532
 * gcm_calib_assistant_prepare_cb:
485
533
 **/
486
534
static gboolean
488
536
                                GtkWidget *page_widget,
489
537
                                GcmCalibratePriv *calib)
490
538
{
 
539
        gboolean ret;
491
540
        calib->current_page = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (page_widget),
492
541
                                                                   "GcmCalibrateMain::Index"));
493
542
        switch (calib->current_page) {
494
543
        case GCM_CALIBRATE_PAGE_LAST:
495
544
                gcm_calib_play_sound (calib);
 
545
 
 
546
                /* show the user the profile to copy off the live system */
 
547
                ret = gcm_calibrate_is_livecd ();
 
548
                if (ret)
 
549
                        gcm_calibrate_show_profile_location ();
496
550
                break;
497
551
        case GCM_CALIBRATE_PAGE_ACTION:
498
552
                g_debug ("lights! camera! action!");
1720
1774
}
1721
1775
 
1722
1776
/**
 
1777
 * gcm_calib_got_sensor:
 
1778
 **/
 
1779
static void
 
1780
gcm_calib_got_sensor (GcmCalibratePriv *calib, CdSensor *sensor)
 
1781
{
 
1782
        gboolean is_photospectrometer = FALSE;
 
1783
        gboolean ret;
 
1784
        GError *error = NULL;
 
1785
        GtkWidget *vbox;
 
1786
 
 
1787
        /* connect to sensor */
 
1788
        ret = cd_sensor_connect_sync (sensor, NULL, &error);
 
1789
        if (!ret) {
 
1790
                g_warning ("failed to connect to sensor: %s",
 
1791
                           error->message);
 
1792
                g_error_free (error);
 
1793
                goto out;
 
1794
        }
 
1795
        gcm_calibrate_set_sensor (calib->calibrate, sensor);
 
1796
 
 
1797
        /* hide the prompt for the user to insert a sensor */
 
1798
        vbox = gcm_calib_get_vbox_for_page (calib,
 
1799
                                            GCM_CALIBRATE_PAGE_SENSOR);
 
1800
        gtk_widget_hide (vbox);
 
1801
 
 
1802
        /* if the device is a simple colorimeter, hide the temperature
 
1803
         * chooser. Only expensive accurate spectrophotometers are
 
1804
         * accurate enough to do a good job without a color cast */
 
1805
        if (cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_I1_PRO ||
 
1806
            cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_COLOR_MUNKI ||
 
1807
            cd_sensor_get_kind (sensor) == CD_SENSOR_KIND_I1_DISPLAY3) {
 
1808
                is_photospectrometer = TRUE;
 
1809
        }
 
1810
        vbox = gcm_calib_get_vbox_for_page (calib,
 
1811
                                            GCM_CALIBRATE_PAGE_DISPLAY_TEMPERATURE);
 
1812
        gtk_widget_set_visible (vbox, is_photospectrometer);
 
1813
out:
 
1814
        return;
 
1815
}
 
1816
 
 
1817
/**
1723
1818
 * gcm_calib_get_sensors_cb:
1724
1819
 **/
1725
1820
static void
1732
1827
        GcmCalibratePriv *calib = (GcmCalibratePriv *) user_data;
1733
1828
        GError *error = NULL;
1734
1829
        GPtrArray *sensors;
1735
 
        GtkWidget *vbox;
1736
 
        gboolean ret;
1737
1830
 
1738
1831
        /* get the result */
1739
1832
        sensors = cd_client_get_sensors_finish (client, res, &error);
1744
1837
                goto out;
1745
1838
        }
1746
1839
 
1747
 
        /* hide the sensors screen */
1748
 
        if (sensors->len > 0) {
 
1840
        /* we've got a sensor */
 
1841
        if (sensors->len != 0) {
1749
1842
                sensor_tmp = g_ptr_array_index (sensors, 0);
1750
 
 
1751
 
                ret = cd_sensor_connect_sync (sensor_tmp, NULL, &error);
1752
 
                if (!ret) {
1753
 
                        g_warning ("failed to connect to sensor: %s",
1754
 
                                   error->message);
1755
 
                        g_error_free (error);
1756
 
                        goto out;
1757
 
                }
1758
 
 
1759
 
                gcm_calibrate_set_sensor (calib->calibrate, sensor_tmp);
1760
 
                vbox = gcm_calib_get_vbox_for_page (calib,
1761
 
                                                    GCM_CALIBRATE_PAGE_SENSOR);
1762
 
                gtk_widget_hide (vbox);
 
1843
                gcm_calib_got_sensor (calib, sensor_tmp);
1763
1844
        }
1764
1845
out:
1765
1846
        if (sensors != NULL)
1838
1919
static void
1839
1920
gcm_calib_sensor_added_cb (CdClient *client, CdSensor *sensor, GcmCalibratePriv *calib)
1840
1921
{
1841
 
        gboolean ret;
1842
 
        GError *error = NULL;
1843
 
        GtkWidget *vbox;
1844
 
 
1845
1922
        g_debug ("sensor inserted");
1846
 
 
1847
 
        /* connect */
1848
 
        ret = cd_sensor_connect_sync (sensor, NULL, &error);
1849
 
        if (!ret) {
1850
 
                g_warning ("failed to connect to sensor: %s",
1851
 
                           error->message);
1852
 
                g_error_free (error);
1853
 
                goto out;
1854
 
        }
1855
 
 
1856
 
        /* fix up UI */
1857
 
        gcm_calibrate_set_sensor (calib->calibrate, sensor);
1858
 
        vbox = gcm_calib_get_vbox_for_page (calib,
1859
 
                                            GCM_CALIBRATE_PAGE_SENSOR);
1860
 
        gtk_assistant_set_page_complete (GTK_ASSISTANT (calib->main_window),
1861
 
                                         vbox, TRUE);
1862
 
        gtk_widget_hide (vbox);
 
1923
        gcm_calib_got_sensor (calib, sensor);
1863
1924
        gtk_assistant_next_page (GTK_ASSISTANT (calib->main_window));
1864
 
out:
1865
 
        return;
1866
1925
}
1867
1926
 
1868
1927
/**