color: Replace GObject boilerplace with G_DECLARE_TYPE
This commit is contained in:
parent
6d3ed43e74
commit
770a3b1df6
10 changed files with 515 additions and 705 deletions
|
@ -35,12 +35,12 @@
|
||||||
|
|
||||||
#include "cc-color-calibrate.h"
|
#include "cc-color-calibrate.h"
|
||||||
|
|
||||||
#define CC_COLOR_CALIBRATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_COLOR_CALIBRATE, CcColorCalibratePrivate))
|
|
||||||
|
|
||||||
#define CALIBRATE_WINDOW_OPACITY 0.9
|
#define CALIBRATE_WINDOW_OPACITY 0.9
|
||||||
|
|
||||||
struct _CcColorCalibratePrivate
|
struct _CcColorCalibrate
|
||||||
{
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
CdDevice *device;
|
CdDevice *device;
|
||||||
CdSensorCap device_kind;
|
CdSensorCap device_kind;
|
||||||
CdSensor *sensor;
|
CdSensor *sensor;
|
||||||
|
@ -82,71 +82,71 @@ void
|
||||||
cc_color_calibrate_set_kind (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_kind (CcColorCalibrate *calibrate,
|
||||||
CdSensorCap kind)
|
CdSensorCap kind)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
calibrate->priv->device_kind = kind;
|
calibrate->device_kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_calibrate_set_temperature (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_temperature (CcColorCalibrate *calibrate,
|
||||||
guint temperature)
|
guint temperature)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
g_return_if_fail (temperature < 10000);
|
g_return_if_fail (temperature < 10000);
|
||||||
calibrate->priv->target_whitepoint = temperature;
|
calibrate->target_whitepoint = temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_calibrate_set_quality (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_quality (CcColorCalibrate *calibrate,
|
||||||
CdProfileQuality quality)
|
CdProfileQuality quality)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
calibrate->priv->quality = quality;
|
calibrate->quality = quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
CdProfileQuality
|
CdProfileQuality
|
||||||
cc_color_calibrate_get_quality (CcColorCalibrate *calibrate)
|
cc_color_calibrate_get_quality (CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_CALIB (calibrate), 0);
|
g_return_val_if_fail (CC_IS_COLOR_CALIBRATE (calibrate), 0);
|
||||||
return calibrate->priv->quality;
|
return calibrate->quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_calibrate_set_device (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_device (CcColorCalibrate *calibrate,
|
||||||
CdDevice *device)
|
CdDevice *device)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
g_return_if_fail (CD_IS_DEVICE (device));
|
g_return_if_fail (CD_IS_DEVICE (device));
|
||||||
if (calibrate->priv->device != NULL)
|
if (calibrate->device != NULL)
|
||||||
g_object_unref (calibrate->priv->device);
|
g_object_unref (calibrate->device);
|
||||||
calibrate->priv->device = g_object_ref (device);
|
calibrate->device = g_object_ref (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_calibrate_set_sensor (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_sensor (CcColorCalibrate *calibrate,
|
||||||
CdSensor *sensor)
|
CdSensor *sensor)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
g_return_if_fail (CD_IS_SENSOR (sensor));
|
g_return_if_fail (CD_IS_SENSOR (sensor));
|
||||||
if (calibrate->priv->sensor != NULL)
|
if (calibrate->sensor != NULL)
|
||||||
g_object_unref (calibrate->priv->sensor);
|
g_object_unref (calibrate->sensor);
|
||||||
calibrate->priv->sensor = g_object_ref (sensor);
|
calibrate->sensor = g_object_ref (sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_calibrate_set_title (CcColorCalibrate *calibrate,
|
cc_color_calibrate_set_title (CcColorCalibrate *calibrate,
|
||||||
const gchar *title)
|
const gchar *title)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_CALIB (calibrate));
|
g_return_if_fail (CC_IS_COLOR_CALIBRATE (calibrate));
|
||||||
g_return_if_fail (title != NULL);
|
g_return_if_fail (title != NULL);
|
||||||
g_free (calibrate->priv->title);
|
g_free (calibrate->title);
|
||||||
calibrate->priv->title = g_strdup (title);
|
calibrate->title = g_strdup (title);
|
||||||
}
|
}
|
||||||
|
|
||||||
CdProfile *
|
CdProfile *
|
||||||
cc_color_calibrate_get_profile (CcColorCalibrate *calibrate)
|
cc_color_calibrate_get_profile (CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_CALIB (calibrate), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_CALIBRATE (calibrate), NULL);
|
||||||
return calibrate->priv->profile;
|
return calibrate->profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
|
@ -169,21 +169,20 @@ cc_color_calibrate_calib_setup_screen (CcColorCalibrate *calibrate,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
/* get screen */
|
/* get screen */
|
||||||
priv->x11_screen = gnome_rr_screen_new (gdk_screen_get_default (), error);
|
calibrate->x11_screen = gnome_rr_screen_new (gdk_screen_get_default (), error);
|
||||||
if (priv->x11_screen == NULL)
|
if (calibrate->x11_screen == NULL)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the output */
|
/* get the output */
|
||||||
priv->output = gnome_rr_screen_get_output_by_name (priv->x11_screen,
|
calibrate->output = gnome_rr_screen_get_output_by_name (calibrate->x11_screen,
|
||||||
name);
|
name);
|
||||||
if (priv->output == NULL)
|
if (calibrate->output == NULL)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
|
@ -194,8 +193,8 @@ cc_color_calibrate_calib_setup_screen (CcColorCalibrate *calibrate,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a lookup table */
|
/* create a lookup table */
|
||||||
priv->gamma_size = _gnome_rr_output_get_gamma_size (priv->output);
|
calibrate->gamma_size = _gnome_rr_output_get_gamma_size (calibrate->output);
|
||||||
if (priv->gamma_size == 0)
|
if (calibrate->gamma_size == 0)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
|
@ -224,7 +223,6 @@ cc_color_calibrate_calib_set_output_gamma (CcColorCalibrate *calibrate,
|
||||||
GPtrArray *array,
|
GPtrArray *array,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
CdColorRGB *p1;
|
CdColorRGB *p1;
|
||||||
CdColorRGB *p2;
|
CdColorRGB *p2;
|
||||||
CdColorRGB result;
|
CdColorRGB result;
|
||||||
|
@ -248,14 +246,14 @@ cc_color_calibrate_calib_set_output_gamma (CcColorCalibrate *calibrate,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert to a type X understands of the right size */
|
/* convert to a type X understands of the right size */
|
||||||
red = g_new (guint16, priv->gamma_size);
|
red = g_new (guint16, calibrate->gamma_size);
|
||||||
green = g_new (guint16, priv->gamma_size);
|
green = g_new (guint16, calibrate->gamma_size);
|
||||||
blue = g_new (guint16, priv->gamma_size);
|
blue = g_new (guint16, calibrate->gamma_size);
|
||||||
cd_color_rgb_set (&result, 1.0, 1.0, 1.0);
|
cd_color_rgb_set (&result, 1.0, 1.0, 1.0);
|
||||||
for (i = 0; i < priv->gamma_size; i++)
|
for (i = 0; i < calibrate->gamma_size; i++)
|
||||||
{
|
{
|
||||||
mix = (gdouble) (array->len - 1) /
|
mix = (gdouble) (array->len - 1) /
|
||||||
(gdouble) (priv->gamma_size - 1) *
|
(gdouble) (calibrate->gamma_size - 1) *
|
||||||
(gdouble) i;
|
(gdouble) i;
|
||||||
p1 = g_ptr_array_index (array, (guint) floor (mix));
|
p1 = g_ptr_array_index (array, (guint) floor (mix));
|
||||||
p2 = g_ptr_array_index (array, (guint) ceil (mix));
|
p2 = g_ptr_array_index (array, (guint) ceil (mix));
|
||||||
|
@ -269,7 +267,7 @@ cc_color_calibrate_calib_set_output_gamma (CcColorCalibrate *calibrate,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send to LUT */
|
/* send to LUT */
|
||||||
crtc = gnome_rr_output_get_crtc (priv->output);
|
crtc = gnome_rr_output_get_crtc (calibrate->output);
|
||||||
if (crtc == NULL)
|
if (crtc == NULL)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
@ -277,10 +275,10 @@ cc_color_calibrate_calib_set_output_gamma (CcColorCalibrate *calibrate,
|
||||||
CD_SESSION_ERROR,
|
CD_SESSION_ERROR,
|
||||||
CD_SESSION_ERROR_INTERNAL,
|
CD_SESSION_ERROR_INTERNAL,
|
||||||
"failed to get ctrc for %s",
|
"failed to get ctrc for %s",
|
||||||
gnome_rr_output_get_name (priv->output));
|
gnome_rr_output_get_name (calibrate->output));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
gnome_rr_crtc_set_gamma (crtc, priv->gamma_size,
|
gnome_rr_crtc_set_gamma (crtc, calibrate->gamma_size,
|
||||||
red, green, blue);
|
red, green, blue);
|
||||||
out:
|
out:
|
||||||
g_free (red);
|
g_free (red);
|
||||||
|
@ -295,7 +293,6 @@ cc_color_calibrate_property_changed_cb (GDBusProxy *proxy,
|
||||||
GStrv invalidated_properties,
|
GStrv invalidated_properties,
|
||||||
CcColorCalibrate *calibrate)
|
CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
guint value;
|
guint value;
|
||||||
|
@ -305,7 +302,7 @@ cc_color_calibrate_property_changed_cb (GDBusProxy *proxy,
|
||||||
"u", &value);
|
"u", &value);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"progressbar_status"));
|
"progressbar_status"));
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget),
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget),
|
||||||
value / 100.0f);
|
value / 100.0f);
|
||||||
|
@ -318,7 +315,6 @@ cc_color_calibrate_interaction_required (CcColorCalibrate *calibrate,
|
||||||
const gchar *message,
|
const gchar *message,
|
||||||
const gchar *image_path)
|
const gchar *image_path)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
const gchar *message_transl;
|
const gchar *message_transl;
|
||||||
gboolean show_button_start = FALSE;
|
gboolean show_button_start = FALSE;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
@ -331,7 +327,7 @@ cc_color_calibrate_interaction_required (CcColorCalibrate *calibrate,
|
||||||
image_path = "preferences-color-symbolic";
|
image_path = "preferences-color-symbolic";
|
||||||
|
|
||||||
/* set image */
|
/* set image */
|
||||||
img = GTK_IMAGE (gtk_builder_get_object (priv->builder,
|
img = GTK_IMAGE (gtk_builder_get_object (calibrate->builder,
|
||||||
"image_status"));
|
"image_status"));
|
||||||
if (image_path != NULL && image_path[0] != '\0')
|
if (image_path != NULL && image_path[0] != '\0')
|
||||||
{
|
{
|
||||||
|
@ -345,13 +341,13 @@ cc_color_calibrate_interaction_required (CcColorCalibrate *calibrate,
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
gtk_widget_set_visible (GTK_WIDGET (img), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (img), TRUE);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (priv->sample_widget), FALSE);
|
gtk_widget_set_visible (GTK_WIDGET (calibrate->sample_widget), FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_debug ("hiding image");
|
g_debug ("hiding image");
|
||||||
gtk_widget_set_visible (GTK_WIDGET (img), FALSE);
|
gtk_widget_set_visible (GTK_WIDGET (img), FALSE);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (priv->sample_widget), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (calibrate->sample_widget), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set new status */
|
/* set new status */
|
||||||
|
@ -384,15 +380,15 @@ cc_color_calibrate_interaction_required (CcColorCalibrate *calibrate,
|
||||||
message_transl = message;
|
message_transl = message;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
label = GTK_LABEL (gtk_builder_get_object (priv->builder,
|
label = GTK_LABEL (gtk_builder_get_object (calibrate->builder,
|
||||||
"label_status"));
|
"label_status"));
|
||||||
gtk_label_set_label (label, message_transl);
|
gtk_label_set_label (label, message_transl);
|
||||||
|
|
||||||
/* show the correct button */
|
/* show the correct button */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_start"));
|
"button_start"));
|
||||||
gtk_widget_set_visible (widget, show_button_start);
|
gtk_widget_set_visible (widget, show_button_start);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_resume"));
|
"button_resume"));
|
||||||
gtk_widget_set_visible (widget, !show_button_start);
|
gtk_widget_set_visible (widget, !show_button_start);
|
||||||
}
|
}
|
||||||
|
@ -442,22 +438,21 @@ cc_color_calibrate_finished (CcColorCalibrate *calibrate,
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GString *str;
|
GString *str;
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
|
|
||||||
/* save failure so we can get this after we've quit the loop */
|
/* save failure so we can get this after we've quit the loop */
|
||||||
calibrate->priv->session_error_code = code;
|
calibrate->session_error_code = code;
|
||||||
|
|
||||||
/* show correct buttons */
|
/* show correct buttons */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_cancel"));
|
"button_cancel"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_start"));
|
"button_start"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_resume"));
|
"button_resume"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_done"));
|
"button_done"));
|
||||||
gtk_widget_set_visible (widget, TRUE);
|
gtk_widget_set_visible (widget, TRUE);
|
||||||
|
|
||||||
|
@ -483,7 +478,7 @@ cc_color_calibrate_finished (CcColorCalibrate *calibrate,
|
||||||
/* TRANSLATORS: The user can now remove the sensor from the screen */
|
/* TRANSLATORS: The user can now remove the sensor from the screen */
|
||||||
g_string_append (str, _("You can remove the calibration device."));
|
g_string_append (str, _("You can remove the calibration device."));
|
||||||
|
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"label_status"));
|
"label_status"));
|
||||||
gtk_label_set_label (GTK_LABEL (widget), str->str);
|
gtk_label_set_label (GTK_LABEL (widget), str->str);
|
||||||
g_string_free (str, TRUE);
|
g_string_free (str, TRUE);
|
||||||
|
@ -496,7 +491,6 @@ cc_color_calibrate_signal_cb (GDBusProxy *proxy,
|
||||||
GVariant *parameters,
|
GVariant *parameters,
|
||||||
CcColorCalibrate *calibrate)
|
CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
CdColorRGB color;
|
CdColorRGB color;
|
||||||
CdColorRGB *color_tmp;
|
CdColorRGB *color_tmp;
|
||||||
const gchar *image = NULL;
|
const gchar *image = NULL;
|
||||||
|
@ -521,7 +515,7 @@ cc_color_calibrate_signal_cb (GDBusProxy *proxy,
|
||||||
g_variant_lookup (dict, "ErrorDetails", "&s", &str);
|
g_variant_lookup (dict, "ErrorDetails", "&s", &str);
|
||||||
ret = g_variant_lookup (dict, "ProfilePath", "&s", &profile_path);
|
ret = g_variant_lookup (dict, "ProfilePath", "&s", &profile_path);
|
||||||
if (ret)
|
if (ret)
|
||||||
priv->profile = cd_profile_new_with_object_path (profile_path);
|
calibrate->profile = cd_profile_new_with_object_path (profile_path);
|
||||||
cc_color_calibrate_finished (calibrate, error_code, str);
|
cc_color_calibrate_finished (calibrate, error_code, str);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -531,24 +525,24 @@ cc_color_calibrate_signal_cb (GDBusProxy *proxy,
|
||||||
&color.R,
|
&color.R,
|
||||||
&color.G,
|
&color.G,
|
||||||
&color.B);
|
&color.B);
|
||||||
img = GTK_IMAGE (gtk_builder_get_object (priv->builder,
|
img = GTK_IMAGE (gtk_builder_get_object (calibrate->builder,
|
||||||
"image_status"));
|
"image_status"));
|
||||||
gtk_widget_set_visible (GTK_WIDGET (img), FALSE);
|
gtk_widget_set_visible (GTK_WIDGET (img), FALSE);
|
||||||
gtk_widget_set_visible (GTK_WIDGET (priv->sample_widget), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (calibrate->sample_widget), TRUE);
|
||||||
cd_sample_widget_set_color (CD_SAMPLE_WIDGET (priv->sample_widget),
|
cd_sample_widget_set_color (CD_SAMPLE_WIDGET (calibrate->sample_widget),
|
||||||
&color);
|
&color);
|
||||||
|
|
||||||
/* for Lenovo W700 and W520 laptops we almost fullscreen the
|
/* for Lenovo W700 and W520 laptops we almost fullscreen the
|
||||||
* sample widget as the device is actually embedded in the
|
* sample widget as the device is actually embedded in the
|
||||||
* palmrest! */
|
* palmrest! */
|
||||||
if (cd_sensor_get_embedded (priv->sensor))
|
if (cd_sensor_get_embedded (calibrate->sensor))
|
||||||
{
|
{
|
||||||
g_debug ("Making sample window larger for embedded sensor");
|
g_debug ("Making sample window larger for embedded sensor");
|
||||||
gtk_widget_set_size_request (priv->sample_widget, 1000, 600);
|
gtk_widget_set_size_request (calibrate->sample_widget, 1000, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the generic label too */
|
/* set the generic label too */
|
||||||
label = GTK_LABEL (gtk_builder_get_object (priv->builder,
|
label = GTK_LABEL (gtk_builder_get_object (calibrate->builder,
|
||||||
"label_status"));
|
"label_status"));
|
||||||
/* TRANSLATORS: The user has to be careful not to knock the
|
/* TRANSLATORS: The user has to be careful not to knock the
|
||||||
* display off the screen (although we do cope if this is
|
* display off the screen (although we do cope if this is
|
||||||
|
@ -613,7 +607,7 @@ cc_color_calibrate_cancel (CcColorCalibrate *calibrate)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* cancel the calibration to ensure the helper quits */
|
/* cancel the calibration to ensure the helper quits */
|
||||||
retval = g_dbus_proxy_call_sync (calibrate->priv->proxy_helper,
|
retval = g_dbus_proxy_call_sync (calibrate->proxy_helper,
|
||||||
"Cancel",
|
"Cancel",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
@ -627,7 +621,7 @@ cc_color_calibrate_cancel (CcColorCalibrate *calibrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return */
|
/* return */
|
||||||
g_main_loop_quit (calibrate->priv->loop);
|
g_main_loop_quit (calibrate->loop);
|
||||||
if (retval != NULL)
|
if (retval != NULL)
|
||||||
g_variant_unref (retval);
|
g_variant_unref (retval);
|
||||||
}
|
}
|
||||||
|
@ -708,7 +702,7 @@ cc_color_calibrate_window_state_cb (GtkWidget *widget,
|
||||||
|
|
||||||
/* resize to the correct screen */
|
/* resize to the correct screen */
|
||||||
ret = cc_color_calibrate_move_and_resize_window (window,
|
ret = cc_color_calibrate_move_and_resize_window (window,
|
||||||
calibrate->priv->device,
|
calibrate->device,
|
||||||
&error);
|
&error);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
@ -722,27 +716,26 @@ static void
|
||||||
cc_color_calibrate_button_done_cb (GtkWidget *widget,
|
cc_color_calibrate_button_done_cb (GtkWidget *widget,
|
||||||
CcColorCalibrate *calibrate)
|
CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
g_main_loop_quit (calibrate->priv->loop);
|
g_main_loop_quit (calibrate->loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_color_calibrate_button_start_cb (GtkWidget *widget,
|
cc_color_calibrate_button_start_cb (GtkWidget *widget,
|
||||||
CcColorCalibrate *calibrate)
|
CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GVariant *retval;
|
GVariant *retval;
|
||||||
|
|
||||||
/* set correct buttons */
|
/* set correct buttons */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_start"));
|
"button_start"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_resume"));
|
"button_resume"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
|
|
||||||
/* continue */
|
/* continue */
|
||||||
retval = g_dbus_proxy_call_sync (calibrate->priv->proxy_helper,
|
retval = g_dbus_proxy_call_sync (calibrate->proxy_helper,
|
||||||
"Resume",
|
"Resume",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
@ -799,20 +792,19 @@ cc_color_calibrate_alpha_screen_changed_cb (GtkWindow *window,
|
||||||
static void
|
static void
|
||||||
cc_color_calibrate_uninhibit (CcColorCalibrate *calibrate)
|
cc_color_calibrate_uninhibit (CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
GtkApplication *application;
|
GtkApplication *application;
|
||||||
|
|
||||||
if (priv->inhibit_fd != -1)
|
if (calibrate->inhibit_fd != -1)
|
||||||
{
|
{
|
||||||
close (priv->inhibit_fd);
|
close (calibrate->inhibit_fd);
|
||||||
priv->inhibit_fd = -1;
|
calibrate->inhibit_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->inhibit_cookie != 0)
|
if (calibrate->inhibit_cookie != 0)
|
||||||
{
|
{
|
||||||
application = GTK_APPLICATION (g_application_get_default ());
|
application = GTK_APPLICATION (g_application_get_default ());
|
||||||
gtk_application_uninhibit (application, priv->inhibit_cookie);
|
gtk_application_uninhibit (application, calibrate->inhibit_cookie);
|
||||||
priv->inhibit_cookie = 0;
|
calibrate->inhibit_cookie = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,11 +816,10 @@ cc_color_calibrate_inhibit (CcColorCalibrate *calibrate, GtkWindow *window)
|
||||||
GUnixFDList *fd_list = NULL;
|
GUnixFDList *fd_list = NULL;
|
||||||
GVariant *retval;
|
GVariant *retval;
|
||||||
GtkApplication *application;
|
GtkApplication *application;
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
|
|
||||||
/* inhibit basically everything we can */
|
/* inhibit basically everything we can */
|
||||||
application = GTK_APPLICATION (g_application_get_default ());
|
application = GTK_APPLICATION (g_application_get_default ());
|
||||||
priv->inhibit_cookie = gtk_application_inhibit (application,
|
calibrate->inhibit_cookie = gtk_application_inhibit (application,
|
||||||
window,
|
window,
|
||||||
GTK_APPLICATION_INHIBIT_LOGOUT |
|
GTK_APPLICATION_INHIBIT_LOGOUT |
|
||||||
GTK_APPLICATION_INHIBIT_SWITCH |
|
GTK_APPLICATION_INHIBIT_SWITCH |
|
||||||
|
@ -837,7 +828,7 @@ cc_color_calibrate_inhibit (CcColorCalibrate *calibrate, GtkWindow *window)
|
||||||
"Display calibration in progress");
|
"Display calibration in progress");
|
||||||
|
|
||||||
/* tell logind to disallow the lid switch */
|
/* tell logind to disallow the lid switch */
|
||||||
retval = g_dbus_proxy_call_with_unix_fd_list_sync (priv->proxy_inhibit,
|
retval = g_dbus_proxy_call_with_unix_fd_list_sync (calibrate->proxy_inhibit,
|
||||||
"Inhibit",
|
"Inhibit",
|
||||||
g_variant_new ("(ssss)",
|
g_variant_new ("(ssss)",
|
||||||
"shutdown:"
|
"shutdown:"
|
||||||
|
@ -860,14 +851,14 @@ cc_color_calibrate_inhibit (CcColorCalibrate *calibrate, GtkWindow *window)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
g_variant_get (retval, "(h)", &idx);
|
g_variant_get (retval, "(h)", &idx);
|
||||||
priv->inhibit_fd = g_unix_fd_list_get (fd_list, idx, &error);
|
calibrate->inhibit_fd = g_unix_fd_list_get (fd_list, idx, &error);
|
||||||
if (priv->inhibit_fd == -1)
|
if (calibrate->inhibit_fd == -1)
|
||||||
{
|
{
|
||||||
g_warning ("Failed to receive system inhibitor fd: %s", error->message);
|
g_warning ("Failed to receive system inhibitor fd: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
g_debug ("System inhibitor fd is %d", priv->inhibit_fd);
|
g_debug ("System inhibitor fd is %d", calibrate->inhibit_fd);
|
||||||
out:
|
out:
|
||||||
if (fd_list != NULL)
|
if (fd_list != NULL)
|
||||||
g_object_unref (fd_list);
|
g_object_unref (fd_list);
|
||||||
|
@ -879,44 +870,43 @@ gboolean
|
||||||
cc_color_calibrate_setup (CcColorCalibrate *calibrate,
|
cc_color_calibrate_setup (CcColorCalibrate *calibrate,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
g_return_val_if_fail (CC_IS_COLOR_CALIB (calibrate), FALSE);
|
g_return_val_if_fail (CC_IS_COLOR_CALIBRATE (calibrate), FALSE);
|
||||||
g_return_val_if_fail (calibrate->priv->device_kind != CD_SENSOR_CAP_UNKNOWN, FALSE);
|
g_return_val_if_fail (calibrate->device_kind != CD_SENSOR_CAP_UNKNOWN, FALSE);
|
||||||
|
|
||||||
/* use logind to disable system state idle */
|
/* use logind to disable system state idle */
|
||||||
priv->proxy_inhibit = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM,
|
calibrate->proxy_inhibit = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SYSTEM,
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
"org.freedesktop.login1",
|
"org.freedesktop.login1",
|
||||||
"/org/freedesktop/login1",
|
"/org/freedesktop/login1",
|
||||||
"org.freedesktop.login1.Manager",
|
"org.freedesktop.login1.Manager",
|
||||||
NULL,
|
NULL,
|
||||||
error);
|
error);
|
||||||
if (priv->proxy_inhibit == NULL)
|
if (calibrate->proxy_inhibit == NULL)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start the calibration session daemon */
|
/* start the calibration session daemon */
|
||||||
priv->proxy_helper = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
|
calibrate->proxy_helper = cc_object_storage_create_dbus_proxy_sync (G_BUS_TYPE_SESSION,
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
CD_SESSION_DBUS_SERVICE,
|
CD_SESSION_DBUS_SERVICE,
|
||||||
CD_SESSION_DBUS_PATH,
|
CD_SESSION_DBUS_PATH,
|
||||||
CD_SESSION_DBUS_INTERFACE_DISPLAY,
|
CD_SESSION_DBUS_INTERFACE_DISPLAY,
|
||||||
NULL,
|
NULL,
|
||||||
error);
|
error);
|
||||||
if (priv->proxy_helper == NULL)
|
if (calibrate->proxy_helper == NULL)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
g_signal_connect_object (priv->proxy_helper,
|
g_signal_connect_object (calibrate->proxy_helper,
|
||||||
"g-properties-changed",
|
"g-properties-changed",
|
||||||
G_CALLBACK (cc_color_calibrate_property_changed_cb),
|
G_CALLBACK (cc_color_calibrate_property_changed_cb),
|
||||||
calibrate, 0);
|
calibrate, 0);
|
||||||
g_signal_connect_object (priv->proxy_helper,
|
g_signal_connect_object (calibrate->proxy_helper,
|
||||||
"g-signal",
|
"g-signal",
|
||||||
G_CALLBACK (cc_color_calibrate_signal_cb),
|
G_CALLBACK (cc_color_calibrate_signal_cb),
|
||||||
calibrate, 0);
|
calibrate, 0);
|
||||||
|
@ -929,7 +919,6 @@ cc_color_calibrate_start (CcColorCalibrate *calibrate,
|
||||||
GtkWindow *parent,
|
GtkWindow *parent,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
@ -937,10 +926,10 @@ cc_color_calibrate_start (CcColorCalibrate *calibrate,
|
||||||
GVariantBuilder builder;
|
GVariantBuilder builder;
|
||||||
GVariant *retval = NULL;
|
GVariant *retval = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (CC_IS_COLOR_CALIB (calibrate), FALSE);
|
g_return_val_if_fail (CC_IS_COLOR_CALIBRATE (calibrate), FALSE);
|
||||||
|
|
||||||
/* get screen */
|
/* get screen */
|
||||||
name = cd_device_get_metadata_item (priv->device,
|
name = cd_device_get_metadata_item (calibrate->device,
|
||||||
CD_DEVICE_METADATA_XRANDR_NAME);
|
CD_DEVICE_METADATA_XRANDR_NAME);
|
||||||
ret = cc_color_calibrate_calib_setup_screen (calibrate, name, error);
|
ret = cc_color_calibrate_calib_setup_screen (calibrate, name, error);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -950,28 +939,28 @@ cc_color_calibrate_start (CcColorCalibrate *calibrate,
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
"Quality",
|
"Quality",
|
||||||
g_variant_new_uint32 (priv->quality));
|
g_variant_new_uint32 (calibrate->quality));
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
"Whitepoint",
|
"Whitepoint",
|
||||||
g_variant_new_uint32 (priv->target_whitepoint));
|
g_variant_new_uint32 (calibrate->target_whitepoint));
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
"Gamma",
|
"Gamma",
|
||||||
g_variant_new_double (priv->target_gamma));
|
g_variant_new_double (calibrate->target_gamma));
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
"Title",
|
"Title",
|
||||||
g_variant_new_string (priv->title));
|
g_variant_new_string (calibrate->title));
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
"DeviceKind",
|
"DeviceKind",
|
||||||
g_variant_new_uint32 (priv->device_kind));
|
g_variant_new_uint32 (calibrate->device_kind));
|
||||||
retval = g_dbus_proxy_call_sync (priv->proxy_helper,
|
retval = g_dbus_proxy_call_sync (calibrate->proxy_helper,
|
||||||
"Start",
|
"Start",
|
||||||
g_variant_new ("(ssa{sv})",
|
g_variant_new ("(ssa{sv})",
|
||||||
cd_device_get_id (priv->device),
|
cd_device_get_id (calibrate->device),
|
||||||
cd_sensor_get_id (priv->sensor),
|
cd_sensor_get_id (calibrate->sensor),
|
||||||
&builder),
|
&builder),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
|
@ -984,36 +973,36 @@ cc_color_calibrate_start (CcColorCalibrate *calibrate,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set this above our parent */
|
/* set this above our parent */
|
||||||
window = GTK_WINDOW (gtk_builder_get_object (priv->builder,
|
window = GTK_WINDOW (gtk_builder_get_object (calibrate->builder,
|
||||||
"dialog_calibrate"));
|
"dialog_calibrate"));
|
||||||
gtk_window_set_modal (window, TRUE);
|
gtk_window_set_modal (window, TRUE);
|
||||||
gtk_widget_show (GTK_WIDGET (window));
|
gtk_widget_show (GTK_WIDGET (window));
|
||||||
|
|
||||||
/* show correct buttons */
|
/* show correct buttons */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_cancel"));
|
"button_cancel"));
|
||||||
gtk_widget_set_visible (widget, TRUE);
|
gtk_widget_set_visible (widget, TRUE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_start"));
|
"button_start"));
|
||||||
gtk_widget_set_visible (widget, TRUE);
|
gtk_widget_set_visible (widget, TRUE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_resume"));
|
"button_resume"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_done"));
|
"button_done"));
|
||||||
gtk_widget_set_visible (widget, FALSE);
|
gtk_widget_set_visible (widget, FALSE);
|
||||||
|
|
||||||
/* stop the computer from auto-suspending or turning off the screen */
|
/* stop the computer from auto-suspending or turning off the screen */
|
||||||
cc_color_calibrate_inhibit (calibrate, parent);
|
cc_color_calibrate_inhibit (calibrate, parent);
|
||||||
|
|
||||||
g_main_loop_run (priv->loop);
|
g_main_loop_run (calibrate->loop);
|
||||||
gtk_widget_hide (GTK_WIDGET (window));
|
gtk_widget_hide (GTK_WIDGET (window));
|
||||||
|
|
||||||
/* we can go idle now */
|
/* we can go idle now */
|
||||||
cc_color_calibrate_uninhibit (calibrate);
|
cc_color_calibrate_uninhibit (calibrate);
|
||||||
|
|
||||||
/* see if we failed */
|
/* see if we failed */
|
||||||
if (calibrate->priv->session_error_code != CD_SESSION_ERROR_NONE)
|
if (calibrate->session_error_code != CD_SESSION_ERROR_NONE)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
|
@ -1041,17 +1030,16 @@ static void
|
||||||
cc_color_calibrate_finalize (GObject *object)
|
cc_color_calibrate_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcColorCalibrate *calibrate = CC_COLOR_CALIBRATE (object);
|
CcColorCalibrate *calibrate = CC_COLOR_CALIBRATE (object);
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
|
|
||||||
g_clear_pointer (&priv->window, gtk_widget_destroy);
|
g_clear_pointer (&calibrate->window, gtk_widget_destroy);
|
||||||
g_clear_object (&priv->builder);
|
g_clear_object (&calibrate->builder);
|
||||||
g_clear_object (&priv->device);
|
g_clear_object (&calibrate->device);
|
||||||
g_clear_object (&priv->proxy_helper);
|
g_clear_object (&calibrate->proxy_helper);
|
||||||
g_clear_object (&priv->proxy_inhibit);
|
g_clear_object (&calibrate->proxy_inhibit);
|
||||||
g_clear_object (&priv->sensor);
|
g_clear_object (&calibrate->sensor);
|
||||||
g_clear_object (&priv->x11_screen);
|
g_clear_object (&calibrate->x11_screen);
|
||||||
g_free (priv->title);
|
g_free (calibrate->title);
|
||||||
g_main_loop_unref (priv->loop);
|
g_main_loop_unref (calibrate->loop);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_color_calibrate_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cc_color_calibrate_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -1061,14 +1049,11 @@ cc_color_calibrate_class_init (CcColorCalibrateClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
object_class->finalize = cc_color_calibrate_finalize;
|
object_class->finalize = cc_color_calibrate_finalize;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcColorCalibratePrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_color_calibrate_init (CcColorCalibrate *calibrate)
|
cc_color_calibrate_init (CcColorCalibrate *calibrate)
|
||||||
{
|
{
|
||||||
CcColorCalibratePrivate *priv = calibrate->priv;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint retval;
|
gint retval;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
|
@ -1076,13 +1061,12 @@ cc_color_calibrate_init (CcColorCalibrate *calibrate)
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkWindow *window;
|
GtkWindow *window;
|
||||||
|
|
||||||
calibrate->priv = priv = CC_COLOR_CALIBRATE_GET_PRIVATE (calibrate);
|
calibrate->loop = g_main_loop_new (NULL, FALSE);
|
||||||
calibrate->priv->loop = g_main_loop_new (NULL, FALSE);
|
calibrate->inhibit_fd = -1;
|
||||||
calibrate->priv->inhibit_fd = -1;
|
|
||||||
|
|
||||||
/* load UI */
|
/* load UI */
|
||||||
priv->builder = gtk_builder_new ();
|
calibrate->builder = gtk_builder_new ();
|
||||||
retval = gtk_builder_add_from_resource (priv->builder,
|
retval = gtk_builder_add_from_resource (calibrate->builder,
|
||||||
"/org/gnome/control-center/color/color-calibrate.ui",
|
"/org/gnome/control-center/color/color-calibrate.ui",
|
||||||
&error);
|
&error);
|
||||||
if (retval == 0)
|
if (retval == 0)
|
||||||
|
@ -1092,42 +1076,42 @@ cc_color_calibrate_init (CcColorCalibrate *calibrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add sample widget */
|
/* add sample widget */
|
||||||
box = GTK_BOX (gtk_builder_get_object (priv->builder,
|
box = GTK_BOX (gtk_builder_get_object (calibrate->builder,
|
||||||
"vbox_status"));
|
"vbox_status"));
|
||||||
priv->sample_widget = cd_sample_widget_new ();
|
calibrate->sample_widget = cd_sample_widget_new ();
|
||||||
gtk_widget_set_size_request (priv->sample_widget, 400, 400);
|
gtk_widget_set_size_request (calibrate->sample_widget, 400, 400);
|
||||||
gtk_box_pack_start (box, priv->sample_widget, FALSE, FALSE, 0);
|
gtk_box_pack_start (box, calibrate->sample_widget, FALSE, FALSE, 0);
|
||||||
gtk_box_reorder_child (box, priv->sample_widget, 0);
|
gtk_box_reorder_child (box, calibrate->sample_widget, 0);
|
||||||
gtk_widget_set_vexpand (priv->sample_widget, FALSE);
|
gtk_widget_set_vexpand (calibrate->sample_widget, FALSE);
|
||||||
gtk_widget_set_hexpand (priv->sample_widget, FALSE);
|
gtk_widget_set_hexpand (calibrate->sample_widget, FALSE);
|
||||||
|
|
||||||
/* get defaults */
|
/* get defaults */
|
||||||
settings = g_settings_new (COLORD_SETTINGS_SCHEMA);
|
settings = g_settings_new (COLORD_SETTINGS_SCHEMA);
|
||||||
calibrate->priv->target_whitepoint = g_settings_get_int (settings, "display-whitepoint");
|
calibrate->target_whitepoint = g_settings_get_int (settings, "display-whitepoint");
|
||||||
calibrate->priv->target_gamma = g_settings_get_double (settings, "display-gamma");
|
calibrate->target_gamma = g_settings_get_double (settings, "display-gamma");
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
/* connect to buttons */
|
/* connect to buttons */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_start"));
|
"button_start"));
|
||||||
g_signal_connect (widget, "clicked",
|
g_signal_connect (widget, "clicked",
|
||||||
G_CALLBACK (cc_color_calibrate_button_start_cb), calibrate);
|
G_CALLBACK (cc_color_calibrate_button_start_cb), calibrate);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_resume"));
|
"button_resume"));
|
||||||
g_signal_connect (widget, "clicked",
|
g_signal_connect (widget, "clicked",
|
||||||
G_CALLBACK (cc_color_calibrate_button_start_cb), calibrate);
|
G_CALLBACK (cc_color_calibrate_button_start_cb), calibrate);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_done"));
|
"button_done"));
|
||||||
g_signal_connect (widget, "clicked",
|
g_signal_connect (widget, "clicked",
|
||||||
G_CALLBACK (cc_color_calibrate_button_done_cb), calibrate);
|
G_CALLBACK (cc_color_calibrate_button_done_cb), calibrate);
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (calibrate->builder,
|
||||||
"button_cancel"));
|
"button_cancel"));
|
||||||
g_signal_connect (widget, "clicked",
|
g_signal_connect (widget, "clicked",
|
||||||
G_CALLBACK (cc_color_calibrate_button_cancel_cb), calibrate);
|
G_CALLBACK (cc_color_calibrate_button_cancel_cb), calibrate);
|
||||||
gtk_widget_show (widget);
|
gtk_widget_show (widget);
|
||||||
|
|
||||||
/* setup the specialist calibration window */
|
/* setup the specialist calibration window */
|
||||||
window = GTK_WINDOW (gtk_builder_get_object (priv->builder,
|
window = GTK_WINDOW (gtk_builder_get_object (calibrate->builder,
|
||||||
"dialog_calibrate"));
|
"dialog_calibrate"));
|
||||||
g_signal_connect (window, "draw",
|
g_signal_connect (window, "draw",
|
||||||
G_CALLBACK (cc_color_calibrate_alpha_window_draw), calibrate);
|
G_CALLBACK (cc_color_calibrate_alpha_window_draw), calibrate);
|
||||||
|
@ -1142,7 +1126,7 @@ cc_color_calibrate_init (CcColorCalibrate *calibrate)
|
||||||
cc_color_calibrate_alpha_screen_changed_cb (GTK_WINDOW (window), NULL, calibrate);
|
cc_color_calibrate_alpha_screen_changed_cb (GTK_WINDOW (window), NULL, calibrate);
|
||||||
g_signal_connect (window, "screen-changed",
|
g_signal_connect (window, "screen-changed",
|
||||||
G_CALLBACK (cc_color_calibrate_alpha_screen_changed_cb), calibrate);
|
G_CALLBACK (cc_color_calibrate_alpha_screen_changed_cb), calibrate);
|
||||||
priv->window = window;
|
calibrate->window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
CcColorCalibrate *
|
CcColorCalibrate *
|
||||||
|
|
|
@ -28,30 +28,10 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_COLOR_CALIBRATE (cc_color_calibrate_get_type ())
|
#define CC_TYPE_COLOR_CALIBRATE (cc_color_calibrate_get_type ())
|
||||||
#define CC_COLOR_CALIBRATE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrate))
|
G_DECLARE_FINAL_TYPE (CcColorCalibrate, cc_color_calibrate, CC, COLOR_CALIBRATE, GObject)
|
||||||
#define CC_COLOR_CALIBRATE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrateClass))
|
|
||||||
#define CC_IS_COLOR_CALIB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_COLOR_CALIBRATE))
|
|
||||||
#define CC_IS_COLOR_CALIB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_COLOR_CALIBRATE))
|
|
||||||
#define CC_COLOR_CALIBRATE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_COLOR_CALIBRATE, CcColorCalibrateClass))
|
|
||||||
|
|
||||||
typedef struct _CcColorCalibratePrivate CcColorCalibratePrivate;
|
|
||||||
typedef struct _CcColorCalibrate CcColorCalibrate;
|
|
||||||
typedef struct _CcColorCalibrateClass CcColorCalibrateClass;
|
|
||||||
|
|
||||||
struct _CcColorCalibrate
|
|
||||||
{
|
|
||||||
GObject parent;
|
|
||||||
CcColorCalibratePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcColorCalibrateClass
|
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
CcColorCalibrate *cc_color_calibrate_new (void);
|
CcColorCalibrate *cc_color_calibrate_new (void);
|
||||||
GType cc_color_calibrate_get_type (void);
|
|
||||||
void cc_color_calibrate_set_kind (CcColorCalibrate *calibrate,
|
void cc_color_calibrate_set_kind (CcColorCalibrate *calibrate,
|
||||||
CdSensorCap kind);
|
CdSensorCap kind);
|
||||||
void cc_color_calibrate_set_temperature (CcColorCalibrate *calibrate,
|
void cc_color_calibrate_set_temperature (CcColorCalibrate *calibrate,
|
||||||
|
|
|
@ -31,6 +31,13 @@ enum {
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _CcColorCellRendererText
|
||||||
|
{
|
||||||
|
GtkCellRendererText parent_instance;
|
||||||
|
|
||||||
|
gboolean is_dim_label;
|
||||||
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CcColorCellRendererText, cc_color_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT)
|
G_DEFINE_TYPE (CcColorCellRendererText, cc_color_cell_renderer_text, GTK_TYPE_CELL_RENDERER_TEXT)
|
||||||
|
|
||||||
static gpointer parent_class = NULL;
|
static gpointer parent_class = NULL;
|
||||||
|
|
|
@ -24,31 +24,10 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#define CC_COLOR_TYPE_CELL_RENDERER_TEXT (cc_color_cell_renderer_text_get_type())
|
#define CC_COLOR_TYPE_CELL_RENDERER_TEXT (cc_color_cell_renderer_text_get_type ())
|
||||||
#define CC_COLOR_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererText))
|
G_DECLARE_FINAL_TYPE (CcColorCellRendererText, cc_color_cell_renderer_text, CC_COLOR, CELL_RENDERER_TEXT, GtkCellRendererText)
|
||||||
#define CC_COLOR_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererTextClass))
|
|
||||||
#define CC_COLOR_IS_CELL_RENDERER_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT))
|
|
||||||
#define CC_COLOR_IS_CELL_RENDERER_TEXT_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), CC_COLOR_TYPE_CELL_RENDERER_TEXT))
|
|
||||||
#define CC_COLOR_CELL_RENDERER_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CC_COLOR_TYPE_CELL_RENDERER_TEXT, CcColorCellRendererTextClass))
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
GtkCellRenderer *cc_color_cell_renderer_text_new (void);
|
||||||
|
|
||||||
typedef struct _CcColorCellRendererText CcColorCellRendererText;
|
|
||||||
typedef struct _CcColorCellRendererTextClass CcColorCellRendererTextClass;
|
|
||||||
|
|
||||||
struct _CcColorCellRendererText
|
|
||||||
{
|
|
||||||
GtkCellRendererText parent;
|
|
||||||
gboolean is_dim_label;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcColorCellRendererTextClass
|
|
||||||
{
|
|
||||||
GtkCellRendererTextClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_color_cell_renderer_text_get_type (void);
|
|
||||||
GtkCellRenderer *cc_color_cell_renderer_text_new (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
#include "cc-color-common.h"
|
#include "cc-color-common.h"
|
||||||
#include "cc-color-device.h"
|
#include "cc-color-device.h"
|
||||||
|
|
||||||
struct _CcColorDevicePrivate
|
struct _CcColorDevice
|
||||||
{
|
{
|
||||||
|
GtkListBoxRow parent_instance;
|
||||||
|
|
||||||
CdDevice *device;
|
CdDevice *device;
|
||||||
gboolean expanded;
|
gboolean expanded;
|
||||||
gchar *sortable;
|
gchar *sortable;
|
||||||
|
@ -60,38 +62,37 @@ static guint signals [SIGNAL_LAST] = { 0 };
|
||||||
static void
|
static void
|
||||||
cc_color_device_refresh (CcColorDevice *color_device)
|
cc_color_device_refresh (CcColorDevice *color_device)
|
||||||
{
|
{
|
||||||
CcColorDevicePrivate *priv = color_device->priv;
|
|
||||||
gchar *title = NULL;
|
gchar *title = NULL;
|
||||||
GPtrArray *profiles = NULL;
|
GPtrArray *profiles = NULL;
|
||||||
AtkObject *accessible;
|
AtkObject *accessible;
|
||||||
gchar *name = NULL;
|
gchar *name = NULL;
|
||||||
|
|
||||||
/* add switch and expander if there are profiles, otherwise use a label */
|
/* add switch and expander if there are profiles, otherwise use a label */
|
||||||
profiles = cd_device_get_profiles (priv->device);
|
profiles = cd_device_get_profiles (color_device->device);
|
||||||
if (profiles == NULL)
|
if (profiles == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
title = cc_color_device_get_title (priv->device);
|
title = cc_color_device_get_title (color_device->device);
|
||||||
gtk_label_set_label (GTK_LABEL (priv->widget_description), title);
|
gtk_label_set_label (GTK_LABEL (color_device->widget_description), title);
|
||||||
gtk_widget_set_visible (priv->widget_description, TRUE);
|
gtk_widget_set_visible (color_device->widget_description, TRUE);
|
||||||
|
|
||||||
gtk_widget_set_visible (priv->widget_switch, profiles->len > 0);
|
gtk_widget_set_visible (color_device->widget_switch, profiles->len > 0);
|
||||||
gtk_widget_set_visible (priv->widget_button, profiles->len > 0);
|
gtk_widget_set_visible (color_device->widget_button, profiles->len > 0);
|
||||||
gtk_image_set_from_icon_name (GTK_IMAGE (priv->widget_arrow),
|
gtk_image_set_from_icon_name (GTK_IMAGE (color_device->widget_arrow),
|
||||||
priv->expanded ? "pan-down-symbolic" : "pan-end-symbolic",
|
color_device->expanded ? "pan-down-symbolic" : "pan-end-symbolic",
|
||||||
GTK_ICON_SIZE_BUTTON);
|
GTK_ICON_SIZE_BUTTON);
|
||||||
gtk_widget_set_visible (priv->widget_nocalib, profiles->len == 0);
|
gtk_widget_set_visible (color_device->widget_nocalib, profiles->len == 0);
|
||||||
gtk_widget_set_sensitive (priv->widget_button, cd_device_get_enabled (priv->device));
|
gtk_widget_set_sensitive (color_device->widget_button, cd_device_get_enabled (color_device->device));
|
||||||
gtk_switch_set_active (GTK_SWITCH (priv->widget_switch),
|
gtk_switch_set_active (GTK_SWITCH (color_device->widget_switch),
|
||||||
cd_device_get_enabled (priv->device));
|
cd_device_get_enabled (color_device->device));
|
||||||
|
|
||||||
accessible = gtk_widget_get_accessible (priv->widget_switch);
|
accessible = gtk_widget_get_accessible (color_device->widget_switch);
|
||||||
name = g_strdup_printf (_("Enable color management for %s"), title);
|
name = g_strdup_printf (_("Enable color management for %s"), title);
|
||||||
atk_object_set_name (accessible, name);
|
atk_object_set_name (accessible, name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
name = g_strdup_printf (_("Show color profiles for %s"), title);
|
name = g_strdup_printf (_("Show color profiles for %s"), title);
|
||||||
accessible = gtk_widget_get_accessible (priv->widget_button);
|
accessible = gtk_widget_get_accessible (color_device->widget_button);
|
||||||
atk_object_set_name (accessible, name);
|
atk_object_set_name (accessible, name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
@ -105,14 +106,14 @@ CdDevice *
|
||||||
cc_color_device_get_device (CcColorDevice *color_device)
|
cc_color_device_get_device (CcColorDevice *color_device)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_DEVICE (color_device), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_DEVICE (color_device), NULL);
|
||||||
return color_device->priv->device;
|
return color_device->device;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
cc_color_device_get_sortable (CcColorDevice *color_device)
|
cc_color_device_get_sortable (CcColorDevice *color_device)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_DEVICE (color_device), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_DEVICE (color_device), NULL);
|
||||||
return color_device->priv->sortable;
|
return color_device->sortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -123,7 +124,7 @@ cc_color_device_get_property (GObject *object, guint param_id,
|
||||||
switch (param_id)
|
switch (param_id)
|
||||||
{
|
{
|
||||||
case PROP_DEVICE:
|
case PROP_DEVICE:
|
||||||
g_value_set_object (value, color_device->priv->device);
|
g_value_set_object (value, color_device->device);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@ -140,7 +141,7 @@ cc_color_device_set_property (GObject *object, guint param_id,
|
||||||
switch (param_id)
|
switch (param_id)
|
||||||
{
|
{
|
||||||
case PROP_DEVICE:
|
case PROP_DEVICE:
|
||||||
color_device->priv->device = g_value_dup_object (value);
|
color_device->device = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@ -152,13 +153,12 @@ static void
|
||||||
cc_color_device_finalize (GObject *object)
|
cc_color_device_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcColorDevice *color_device = CC_COLOR_DEVICE (object);
|
CcColorDevice *color_device = CC_COLOR_DEVICE (object);
|
||||||
CcColorDevicePrivate *priv = color_device->priv;
|
|
||||||
|
|
||||||
if (priv->device_changed_id > 0)
|
if (color_device->device_changed_id > 0)
|
||||||
g_signal_handler_disconnect (priv->device, priv->device_changed_id);
|
g_signal_handler_disconnect (color_device->device, color_device->device_changed_id);
|
||||||
|
|
||||||
g_free (priv->sortable);
|
g_free (color_device->sortable);
|
||||||
g_object_unref (priv->device);
|
g_object_unref (color_device->device);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_color_device_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cc_color_device_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -167,17 +167,15 @@ void
|
||||||
cc_color_device_set_expanded (CcColorDevice *color_device,
|
cc_color_device_set_expanded (CcColorDevice *color_device,
|
||||||
gboolean expanded)
|
gboolean expanded)
|
||||||
{
|
{
|
||||||
CcColorDevicePrivate *priv = color_device->priv;
|
|
||||||
|
|
||||||
/* same as before */
|
/* same as before */
|
||||||
if (priv->expanded == expanded)
|
if (color_device->expanded == expanded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* refresh */
|
/* refresh */
|
||||||
priv->expanded = expanded;
|
color_device->expanded = expanded;
|
||||||
g_signal_emit (color_device,
|
g_signal_emit (color_device,
|
||||||
signals[SIGNAL_EXPANDED_CHANGED], 0,
|
signals[SIGNAL_EXPANDED_CHANGED], 0,
|
||||||
priv->expanded);
|
color_device->expanded);
|
||||||
cc_color_device_refresh (color_device);
|
cc_color_device_refresh (color_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,14 +185,13 @@ cc_color_device_notify_enable_device_cb (GtkSwitch *sw,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcColorDevice *color_device = CC_COLOR_DEVICE (user_data);
|
CcColorDevice *color_device = CC_COLOR_DEVICE (user_data);
|
||||||
CcColorDevicePrivate *priv = color_device->priv;
|
|
||||||
gboolean enable;
|
gboolean enable;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
enable = gtk_switch_get_active (sw);
|
enable = gtk_switch_get_active (sw);
|
||||||
g_debug ("Set %s to %i", cd_device_get_id (priv->device), enable);
|
g_debug ("Set %s to %i", cd_device_get_id (color_device->device), enable);
|
||||||
ret = cd_device_set_enabled_sync (priv->device,
|
ret = cd_device_set_enabled_sync (color_device->device,
|
||||||
enable, NULL, &error);
|
enable, NULL, &error);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
|
@ -218,25 +215,24 @@ static void
|
||||||
cc_color_device_constructed (GObject *object)
|
cc_color_device_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
CcColorDevice *color_device = CC_COLOR_DEVICE (object);
|
CcColorDevice *color_device = CC_COLOR_DEVICE (object);
|
||||||
CcColorDevicePrivate *priv = color_device->priv;
|
|
||||||
gchar *sortable_tmp;
|
gchar *sortable_tmp;
|
||||||
|
|
||||||
/* watch the device for changes */
|
/* watch the device for changes */
|
||||||
priv->device_changed_id =
|
color_device->device_changed_id =
|
||||||
g_signal_connect (priv->device, "changed",
|
g_signal_connect (color_device->device, "changed",
|
||||||
G_CALLBACK (cc_color_device_changed_cb), color_device);
|
G_CALLBACK (cc_color_device_changed_cb), color_device);
|
||||||
|
|
||||||
/* calculate sortable -- FIXME: we have to hack this as EggListBox
|
/* calculate sortable -- FIXME: we have to hack this as EggListBox
|
||||||
* does not let us specify a GtkSortType:
|
* does not let us specify a GtkSortType:
|
||||||
* https://bugzilla.gnome.org/show_bug.cgi?id=691341 */
|
* https://bugzilla.gnome.org/show_bug.cgi?id=691341 */
|
||||||
sortable_tmp = cc_color_device_get_sortable_base (priv->device);
|
sortable_tmp = cc_color_device_get_sortable_base (color_device->device);
|
||||||
priv->sortable = g_strdup_printf ("%sXX", sortable_tmp);
|
color_device->sortable = g_strdup_printf ("%sXX", sortable_tmp);
|
||||||
g_free (sortable_tmp);
|
g_free (sortable_tmp);
|
||||||
|
|
||||||
cc_color_device_refresh (color_device);
|
cc_color_device_refresh (color_device);
|
||||||
|
|
||||||
/* watch to see if the user flicked the switch */
|
/* watch to see if the user flicked the switch */
|
||||||
g_signal_connect (priv->widget_switch, "notify::active",
|
g_signal_connect (color_device->widget_switch, "notify::active",
|
||||||
G_CALLBACK (cc_color_device_notify_enable_device_cb),
|
G_CALLBACK (cc_color_device_notify_enable_device_cb),
|
||||||
color_device);
|
color_device);
|
||||||
}
|
}
|
||||||
|
@ -259,11 +255,9 @@ cc_color_device_class_init (CcColorDeviceClass *klass)
|
||||||
signals [SIGNAL_EXPANDED_CHANGED] =
|
signals [SIGNAL_EXPANDED_CHANGED] =
|
||||||
g_signal_new ("expanded-changed",
|
g_signal_new ("expanded-changed",
|
||||||
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (CcColorDeviceClass, expanded_changed),
|
0,
|
||||||
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
|
NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
|
||||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcColorDevicePrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -271,60 +265,54 @@ cc_color_device_clicked_expander_cb (GtkButton *button,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CcColorDevice *color_device = CC_COLOR_DEVICE (user_data);
|
CcColorDevice *color_device = CC_COLOR_DEVICE (user_data);
|
||||||
color_device->priv->expanded = !color_device->priv->expanded;
|
color_device->expanded = !color_device->expanded;
|
||||||
cc_color_device_refresh (color_device);
|
cc_color_device_refresh (color_device);
|
||||||
g_signal_emit (color_device, signals[SIGNAL_EXPANDED_CHANGED], 0,
|
g_signal_emit (color_device, signals[SIGNAL_EXPANDED_CHANGED], 0,
|
||||||
color_device->priv->expanded);
|
color_device->expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_color_device_init (CcColorDevice *color_device)
|
cc_color_device_init (CcColorDevice *color_device)
|
||||||
{
|
{
|
||||||
CcColorDevicePrivate *priv;
|
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
|
|
||||||
color_device->priv = G_TYPE_INSTANCE_GET_PRIVATE (color_device,
|
|
||||||
CC_TYPE_COLOR_DEVICE,
|
|
||||||
CcColorDevicePrivate);
|
|
||||||
priv = color_device->priv;
|
|
||||||
|
|
||||||
/* description */
|
/* description */
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 9);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 9);
|
||||||
priv->widget_description = gtk_label_new ("");
|
color_device->widget_description = gtk_label_new ("");
|
||||||
gtk_widget_set_margin_start (priv->widget_description, 20);
|
gtk_widget_set_margin_start (color_device->widget_description, 20);
|
||||||
gtk_widget_set_margin_top (priv->widget_description, 12);
|
gtk_widget_set_margin_top (color_device->widget_description, 12);
|
||||||
gtk_widget_set_margin_bottom (priv->widget_description, 12);
|
gtk_widget_set_margin_bottom (color_device->widget_description, 12);
|
||||||
gtk_widget_set_halign (priv->widget_description, GTK_ALIGN_START);
|
gtk_widget_set_halign (color_device->widget_description, GTK_ALIGN_START);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_description, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_device->widget_description, TRUE, TRUE, 0);
|
||||||
|
|
||||||
/* switch */
|
/* switch */
|
||||||
priv->widget_switch = gtk_switch_new ();
|
color_device->widget_switch = gtk_switch_new ();
|
||||||
gtk_widget_set_valign (priv->widget_switch, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (color_device->widget_switch, GTK_ALIGN_CENTER);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_switch, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_device->widget_switch, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* arrow button */
|
/* arrow button */
|
||||||
priv->widget_arrow = gtk_image_new_from_icon_name ("pan-end-symbolic",
|
color_device->widget_arrow = gtk_image_new_from_icon_name ("pan-end-symbolic",
|
||||||
GTK_ICON_SIZE_BUTTON);
|
GTK_ICON_SIZE_BUTTON);
|
||||||
priv->widget_button = gtk_button_new ();
|
color_device->widget_button = gtk_button_new ();
|
||||||
g_signal_connect (priv->widget_button, "clicked",
|
g_signal_connect (color_device->widget_button, "clicked",
|
||||||
G_CALLBACK (cc_color_device_clicked_expander_cb),
|
G_CALLBACK (cc_color_device_clicked_expander_cb),
|
||||||
color_device);
|
color_device);
|
||||||
gtk_widget_set_valign (priv->widget_button, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (color_device->widget_button, GTK_ALIGN_CENTER);
|
||||||
gtk_button_set_relief (GTK_BUTTON (priv->widget_button), GTK_RELIEF_NONE);
|
gtk_button_set_relief (GTK_BUTTON (color_device->widget_button), GTK_RELIEF_NONE);
|
||||||
gtk_container_add (GTK_CONTAINER (priv->widget_button), priv->widget_arrow);
|
gtk_container_add (GTK_CONTAINER (color_device->widget_button), color_device->widget_arrow);
|
||||||
gtk_widget_set_visible (priv->widget_arrow, TRUE);
|
gtk_widget_set_visible (color_device->widget_arrow, TRUE);
|
||||||
gtk_widget_set_margin_top (priv->widget_button, 9);
|
gtk_widget_set_margin_top (color_device->widget_button, 9);
|
||||||
gtk_widget_set_margin_bottom (priv->widget_button, 9);
|
gtk_widget_set_margin_bottom (color_device->widget_button, 9);
|
||||||
gtk_widget_set_margin_end (priv->widget_button, 12);
|
gtk_widget_set_margin_end (color_device->widget_button, 12);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_device->widget_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* not calibrated */
|
/* not calibrated */
|
||||||
priv->widget_nocalib = gtk_label_new (_("Not calibrated"));
|
color_device->widget_nocalib = gtk_label_new (_("Not calibrated"));
|
||||||
context = gtk_widget_get_style_context (priv->widget_nocalib);
|
context = gtk_widget_get_style_context (color_device->widget_nocalib);
|
||||||
gtk_style_context_add_class (context, "dim-label");
|
gtk_style_context_add_class (context, "dim-label");
|
||||||
gtk_widget_set_margin_end (priv->widget_nocalib, 18);
|
gtk_widget_set_margin_end (color_device->widget_nocalib, 18);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_nocalib, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_device->widget_nocalib, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* refresh */
|
/* refresh */
|
||||||
gtk_container_add (GTK_CONTAINER (color_device), box);
|
gtk_container_add (GTK_CONTAINER (color_device), box);
|
||||||
|
|
|
@ -25,35 +25,11 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <colord.h>
|
#include <colord.h>
|
||||||
|
|
||||||
#define CC_TYPE_COLOR_DEVICE (cc_color_device_get_type())
|
|
||||||
#define CC_COLOR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CC_TYPE_COLOR_DEVICE, CcColorDevice))
|
|
||||||
#define CC_COLOR_DEVICE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), CC_TYPE_COLOR_DEVICE, CcColorDeviceClass))
|
|
||||||
#define CC_IS_COLOR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CC_TYPE_COLOR_DEVICE))
|
|
||||||
#define CC_IS_COLOR_DEVICE_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), CC_TYPE_COLOR_DEVICE))
|
|
||||||
#define CC_COLOR_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CC_TYPE_COLOR_DEVICE, CcColorDeviceClass))
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _CcColorDevice CcColorDevice;
|
#define CC_TYPE_COLOR_DEVICE (cc_color_device_get_type ())
|
||||||
typedef struct _CcColorDeviceClass CcColorDeviceClass;
|
G_DECLARE_FINAL_TYPE (CcColorDevice, cc_color_device, CC, COLOR_DEVICE, GtkListBoxRow)
|
||||||
typedef struct _CcColorDevicePrivate CcColorDevicePrivate;
|
|
||||||
|
|
||||||
struct _CcColorDevice
|
|
||||||
{
|
|
||||||
GtkListBoxRow parent;
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
CcColorDevicePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcColorDeviceClass
|
|
||||||
{
|
|
||||||
GtkListBoxRowClass parent_class;
|
|
||||||
void (*expanded_changed) (CcColorDevice *color_device,
|
|
||||||
gboolean expanded);
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_color_device_get_type (void);
|
|
||||||
GtkWidget *cc_color_device_new (CdDevice *device);
|
GtkWidget *cc_color_device_new (CdDevice *device);
|
||||||
CdDevice *cc_color_device_get_device (CcColorDevice *color_device);
|
CdDevice *cc_color_device_get_device (CcColorDevice *color_device);
|
||||||
const gchar *cc_color_device_get_sortable (CcColorDevice *color_device);
|
const gchar *cc_color_device_get_sortable (CcColorDevice *color_device);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,45 +26,8 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CC_TYPE_COLOR_PANEL cc_color_panel_get_type()
|
#define CC_TYPE_COLOR_PANEL (cc_color_panel_get_type ())
|
||||||
|
G_DECLARE_FINAL_TYPE (CcColorPanel, cc_color_panel, CC, COLOR_PANEL, CcPanel)
|
||||||
#define CC_COLOR_PANEL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
||||||
CC_TYPE_COLOR_PANEL, CcColorPanel))
|
|
||||||
|
|
||||||
#define CC_COLOR_PANEL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
||||||
CC_TYPE_COLOR_PANEL, CcColorPanelClass))
|
|
||||||
|
|
||||||
#define CC_IS_COLOR_PANEL(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
||||||
CC_TYPE_COLOR_PANEL))
|
|
||||||
|
|
||||||
#define CC_IS_COLOR_PANEL_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
||||||
CC_TYPE_COLOR_PANEL))
|
|
||||||
|
|
||||||
#define CC_COLOR_PANEL_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
||||||
CC_TYPE_COLOR_PANEL, CcColorPanelClass))
|
|
||||||
|
|
||||||
typedef struct _CcColorPanel CcColorPanel;
|
|
||||||
typedef struct _CcColorPanelClass CcColorPanelClass;
|
|
||||||
typedef struct _CcColorPanelPrivate CcColorPanelPrivate;
|
|
||||||
|
|
||||||
struct _CcColorPanel
|
|
||||||
{
|
|
||||||
CcPanel parent;
|
|
||||||
|
|
||||||
CcColorPanelPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcColorPanelClass
|
|
||||||
{
|
|
||||||
CcPanelClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_color_panel_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
#include "cc-color-common.h"
|
#include "cc-color-common.h"
|
||||||
#include "cc-color-profile.h"
|
#include "cc-color-profile.h"
|
||||||
|
|
||||||
struct _CcColorProfilePrivate
|
struct _CcColorProfile
|
||||||
{
|
{
|
||||||
|
GtkListBoxRow parent_instance;
|
||||||
|
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
CdDevice *device;
|
CdDevice *device;
|
||||||
CdProfile *profile;
|
CdProfile *profile;
|
||||||
|
@ -181,41 +183,40 @@ out:
|
||||||
static const gchar *
|
static const gchar *
|
||||||
cc_color_profile_get_warnings (CcColorProfile *color_profile)
|
cc_color_profile_get_warnings (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
CcColorProfilePrivate *priv = color_profile->priv;
|
|
||||||
const gchar *tooltip = NULL;
|
const gchar *tooltip = NULL;
|
||||||
const guint seconds_in_one_day = 60 * 60 * 24;
|
const guint seconds_in_one_day = 60 * 60 * 24;
|
||||||
gint num_days;
|
gint num_days;
|
||||||
guint threshold_days = 0;
|
guint threshold_days = 0;
|
||||||
|
|
||||||
/* autogenerated printer defaults */
|
/* autogenerated printer defaults */
|
||||||
if (cd_device_get_kind (priv->device) == CD_DEVICE_KIND_PRINTER &&
|
if (cd_device_get_kind (color_profile->device) == CD_DEVICE_KIND_PRINTER &&
|
||||||
cd_profile_get_filename (priv->profile) == NULL)
|
cd_profile_get_filename (color_profile->profile) == NULL)
|
||||||
{
|
{
|
||||||
tooltip = _("Vendor supplied factory calibration data");
|
tooltip = _("Vendor supplied factory calibration data");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* autogenerated profiles are crap */
|
/* autogenerated profiles are crap */
|
||||||
if (cd_device_get_kind (priv->device) == CD_DEVICE_KIND_DISPLAY &&
|
if (cd_device_get_kind (color_profile->device) == CD_DEVICE_KIND_DISPLAY &&
|
||||||
cd_profile_get_kind (priv->profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
|
cd_profile_get_kind (color_profile->profile) == CD_PROFILE_KIND_DISPLAY_DEVICE &&
|
||||||
!cd_profile_get_has_vcgt (priv->profile))
|
!cd_profile_get_has_vcgt (color_profile->profile))
|
||||||
{
|
{
|
||||||
tooltip = _("Full-screen display correction not possible with this profile");
|
tooltip = _("Full-screen display correction not possible with this profile");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* greater than the calibration threshold for the device type */
|
/* greater than the calibration threshold for the device type */
|
||||||
num_days = cd_profile_get_age (priv->profile) / seconds_in_one_day;
|
num_days = cd_profile_get_age (color_profile->profile) / seconds_in_one_day;
|
||||||
if (cd_device_get_kind (priv->device) == CD_DEVICE_KIND_DISPLAY)
|
if (cd_device_get_kind (color_profile->device) == CD_DEVICE_KIND_DISPLAY)
|
||||||
{
|
{
|
||||||
g_settings_get (priv->settings,
|
g_settings_get (color_profile->settings,
|
||||||
GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD,
|
GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD,
|
||||||
"u",
|
"u",
|
||||||
&threshold_days);
|
&threshold_days);
|
||||||
}
|
}
|
||||||
else if (cd_device_get_kind (priv->device) == CD_DEVICE_KIND_DISPLAY)
|
else if (cd_device_get_kind (color_profile->device) == CD_DEVICE_KIND_DISPLAY)
|
||||||
{
|
{
|
||||||
g_settings_get (priv->settings,
|
g_settings_get (color_profile->settings,
|
||||||
GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD,
|
GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD,
|
||||||
"u",
|
"u",
|
||||||
&threshold_days);
|
&threshold_days);
|
||||||
|
@ -232,59 +233,58 @@ out:
|
||||||
static void
|
static void
|
||||||
cc_color_profile_refresh (CcColorProfile *color_profile)
|
cc_color_profile_refresh (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
CcColorProfilePrivate *priv = color_profile->priv;
|
|
||||||
const gchar *warnings;
|
const gchar *warnings;
|
||||||
gchar *title = NULL;
|
gchar *title = NULL;
|
||||||
|
|
||||||
/* show the image if the profile is default */
|
/* show the image if the profile is default */
|
||||||
gtk_widget_set_visible (priv->widget_image, priv->is_default);
|
gtk_widget_set_visible (color_profile->widget_image, color_profile->is_default);
|
||||||
gtk_widget_set_margin_start (priv->widget_description,
|
gtk_widget_set_margin_start (color_profile->widget_description,
|
||||||
priv->is_default ? 0 : IMAGE_WIDGET_PADDING * 4);
|
color_profile->is_default ? 0 : IMAGE_WIDGET_PADDING * 4);
|
||||||
|
|
||||||
/* set the title */
|
/* set the title */
|
||||||
title = gcm_prefs_get_profile_title (priv->profile);
|
title = gcm_prefs_get_profile_title (color_profile->profile);
|
||||||
gtk_label_set_markup (GTK_LABEL (priv->widget_description), title);
|
gtk_label_set_markup (GTK_LABEL (color_profile->widget_description), title);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
|
|
||||||
/* show any information */
|
/* show any information */
|
||||||
warnings = cc_color_profile_get_warnings (color_profile);
|
warnings = cc_color_profile_get_warnings (color_profile);
|
||||||
gtk_widget_set_visible (priv->widget_info, warnings != NULL);
|
gtk_widget_set_visible (color_profile->widget_info, warnings != NULL);
|
||||||
gtk_widget_set_tooltip_text (priv->widget_info, warnings);
|
gtk_widget_set_tooltip_text (color_profile->widget_info, warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
CdDevice *
|
CdDevice *
|
||||||
cc_color_profile_get_device (CcColorProfile *color_profile)
|
cc_color_profile_get_device (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
||||||
return color_profile->priv->device;
|
return color_profile->device;
|
||||||
}
|
}
|
||||||
|
|
||||||
CdProfile *
|
CdProfile *
|
||||||
cc_color_profile_get_profile (CcColorProfile *color_profile)
|
cc_color_profile_get_profile (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
||||||
return color_profile->priv->profile;
|
return color_profile->profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
cc_color_profile_get_sortable (CcColorProfile *color_profile)
|
cc_color_profile_get_sortable (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), NULL);
|
||||||
return color_profile->priv->sortable;
|
return color_profile->sortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cc_color_profile_get_is_default (CcColorProfile *color_profile)
|
cc_color_profile_get_is_default (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), 0);
|
g_return_val_if_fail (CC_IS_COLOR_PROFILE (color_profile), 0);
|
||||||
return color_profile->priv->is_default;
|
return color_profile->is_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cc_color_profile_set_is_default (CcColorProfile *color_profile, gboolean is_default)
|
cc_color_profile_set_is_default (CcColorProfile *color_profile, gboolean is_default)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CC_IS_COLOR_PROFILE (color_profile));
|
g_return_if_fail (CC_IS_COLOR_PROFILE (color_profile));
|
||||||
color_profile->priv->is_default = is_default;
|
color_profile->is_default = is_default;
|
||||||
cc_color_profile_refresh (color_profile);
|
cc_color_profile_refresh (color_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,13 +296,13 @@ cc_color_profile_get_property (GObject *object, guint param_id,
|
||||||
switch (param_id)
|
switch (param_id)
|
||||||
{
|
{
|
||||||
case PROP_DEVICE:
|
case PROP_DEVICE:
|
||||||
g_value_set_object (value, color_profile->priv->device);
|
g_value_set_object (value, color_profile->device);
|
||||||
break;
|
break;
|
||||||
case PROP_PROFILE:
|
case PROP_PROFILE:
|
||||||
g_value_set_object (value, color_profile->priv->profile);
|
g_value_set_object (value, color_profile->profile);
|
||||||
break;
|
break;
|
||||||
case PROP_IS_DEFAULT:
|
case PROP_IS_DEFAULT:
|
||||||
g_value_set_boolean (value, color_profile->priv->is_default);
|
g_value_set_boolean (value, color_profile->is_default);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@ -319,13 +319,13 @@ cc_color_profile_set_property (GObject *object, guint param_id,
|
||||||
switch (param_id)
|
switch (param_id)
|
||||||
{
|
{
|
||||||
case PROP_DEVICE:
|
case PROP_DEVICE:
|
||||||
color_profile->priv->device = g_value_dup_object (value);
|
color_profile->device = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PROFILE:
|
case PROP_PROFILE:
|
||||||
color_profile->priv->profile = g_value_dup_object (value);
|
color_profile->profile = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
case PROP_IS_DEFAULT:
|
case PROP_IS_DEFAULT:
|
||||||
color_profile->priv->is_default = g_value_get_boolean (value);
|
color_profile->is_default = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||||
|
@ -337,17 +337,16 @@ static void
|
||||||
cc_color_profile_finalize (GObject *object)
|
cc_color_profile_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CcColorProfile *color_profile = CC_COLOR_PROFILE (object);
|
CcColorProfile *color_profile = CC_COLOR_PROFILE (object);
|
||||||
CcColorProfilePrivate *priv = color_profile->priv;
|
|
||||||
|
|
||||||
if (priv->device_changed_id > 0)
|
if (color_profile->device_changed_id > 0)
|
||||||
g_signal_handler_disconnect (priv->device, priv->device_changed_id);
|
g_signal_handler_disconnect (color_profile->device, color_profile->device_changed_id);
|
||||||
if (priv->profile_changed_id > 0)
|
if (color_profile->profile_changed_id > 0)
|
||||||
g_signal_handler_disconnect (priv->profile, priv->profile_changed_id);
|
g_signal_handler_disconnect (color_profile->profile, color_profile->profile_changed_id);
|
||||||
|
|
||||||
g_free (priv->sortable);
|
g_free (color_profile->sortable);
|
||||||
g_object_unref (priv->device);
|
g_object_unref (color_profile->device);
|
||||||
g_object_unref (priv->profile);
|
g_object_unref (color_profile->profile);
|
||||||
g_object_unref (priv->settings);
|
g_object_unref (color_profile->settings);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cc_color_profile_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cc_color_profile_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -357,14 +356,13 @@ cc_color_profile_changed_cb (CdDevice *device,
|
||||||
CcColorProfile *color_profile)
|
CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
CdProfile *profile;
|
CdProfile *profile;
|
||||||
CcColorProfilePrivate *priv = color_profile->priv;
|
|
||||||
|
|
||||||
/* check to see if the default has changed */
|
/* check to see if the default has changed */
|
||||||
profile = cd_device_get_default_profile (device);
|
profile = cd_device_get_default_profile (device);
|
||||||
if (profile != NULL)
|
if (profile != NULL)
|
||||||
{
|
{
|
||||||
priv->is_default = g_strcmp0 (cd_profile_get_object_path (profile),
|
color_profile->is_default = g_strcmp0 (cd_profile_get_object_path (profile),
|
||||||
cd_profile_get_object_path (priv->profile)) == 0;
|
cd_profile_get_object_path (color_profile->profile)) == 0;
|
||||||
g_object_unref (profile);
|
g_object_unref (profile);
|
||||||
}
|
}
|
||||||
cc_color_profile_refresh (color_profile);
|
cc_color_profile_refresh (color_profile);
|
||||||
|
@ -390,17 +388,16 @@ static void
|
||||||
cc_color_profile_constructed (GObject *object)
|
cc_color_profile_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
CcColorProfile *color_profile = CC_COLOR_PROFILE (object);
|
CcColorProfile *color_profile = CC_COLOR_PROFILE (object);
|
||||||
CcColorProfilePrivate *priv = color_profile->priv;
|
|
||||||
const gchar *sortable_data_source;
|
const gchar *sortable_data_source;
|
||||||
gchar *sortable_device;
|
gchar *sortable_device;
|
||||||
gchar *title;
|
gchar *title;
|
||||||
|
|
||||||
/* watch to see if the default changes */
|
/* watch to see if the default changes */
|
||||||
priv->device_changed_id =
|
color_profile->device_changed_id =
|
||||||
g_signal_connect (priv->device, "changed",
|
g_signal_connect (color_profile->device, "changed",
|
||||||
G_CALLBACK (cc_color_profile_changed_cb), color_profile);
|
G_CALLBACK (cc_color_profile_changed_cb), color_profile);
|
||||||
priv->profile_changed_id =
|
color_profile->profile_changed_id =
|
||||||
g_signal_connect (priv->profile, "changed",
|
g_signal_connect (color_profile->profile, "changed",
|
||||||
G_CALLBACK (cc_color_profile_changed_cb), color_profile);
|
G_CALLBACK (cc_color_profile_changed_cb), color_profile);
|
||||||
|
|
||||||
/* sort the profiles in the list by:
|
/* sort the profiles in the list by:
|
||||||
|
@ -409,13 +406,13 @@ cc_color_profile_constructed (GObject *object)
|
||||||
* 3. the date the profiles were created (newest first)
|
* 3. the date the profiles were created (newest first)
|
||||||
* 4. the alpha sorting of the filename
|
* 4. the alpha sorting of the filename
|
||||||
*/
|
*/
|
||||||
title = gcm_prefs_get_profile_title (priv->profile);
|
title = gcm_prefs_get_profile_title (color_profile->profile);
|
||||||
sortable_device = cc_color_device_get_sortable_base (priv->device);
|
sortable_device = cc_color_device_get_sortable_base (color_profile->device);
|
||||||
sortable_data_source = cc_color_profile_get_profile_sort_data_source (priv->profile);
|
sortable_data_source = cc_color_profile_get_profile_sort_data_source (color_profile->profile);
|
||||||
priv->sortable = g_strdup_printf ("%s-%s-%012" G_GINT64_FORMAT "-%s",
|
color_profile->sortable = g_strdup_printf ("%s-%s-%012" G_GINT64_FORMAT "-%s",
|
||||||
sortable_device,
|
sortable_device,
|
||||||
sortable_data_source,
|
sortable_data_source,
|
||||||
cd_profile_get_created (priv->profile),
|
cd_profile_get_created (color_profile->profile),
|
||||||
title);
|
title);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
g_free (sortable_device);
|
g_free (sortable_device);
|
||||||
|
@ -447,43 +444,36 @@ cc_color_profile_class_init (CcColorProfileClass *klass)
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcColorProfilePrivate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_color_profile_init (CcColorProfile *color_profile)
|
cc_color_profile_init (CcColorProfile *color_profile)
|
||||||
{
|
{
|
||||||
CcColorProfilePrivate *priv;
|
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
|
|
||||||
color_profile->priv = G_TYPE_INSTANCE_GET_PRIVATE (color_profile,
|
color_profile->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
|
||||||
CC_TYPE_COLOR_PROFILE,
|
|
||||||
CcColorProfilePrivate);
|
|
||||||
priv = color_profile->priv;
|
|
||||||
priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
|
|
||||||
|
|
||||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 9);
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 9);
|
||||||
|
|
||||||
/* default tick */
|
/* default tick */
|
||||||
priv->widget_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
|
color_profile->widget_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
|
||||||
gtk_widget_set_margin_start (priv->widget_image, IMAGE_WIDGET_PADDING);
|
gtk_widget_set_margin_start (color_profile->widget_image, IMAGE_WIDGET_PADDING);
|
||||||
gtk_widget_set_margin_end (priv->widget_image, IMAGE_WIDGET_PADDING);
|
gtk_widget_set_margin_end (color_profile->widget_image, IMAGE_WIDGET_PADDING);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_image, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_profile->widget_image, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* description */
|
/* description */
|
||||||
priv->widget_description = gtk_label_new ("");
|
color_profile->widget_description = gtk_label_new ("");
|
||||||
gtk_widget_set_margin_top (priv->widget_description, 9);
|
gtk_widget_set_margin_top (color_profile->widget_description, 9);
|
||||||
gtk_widget_set_margin_bottom (priv->widget_description, 9);
|
gtk_widget_set_margin_bottom (color_profile->widget_description, 9);
|
||||||
gtk_widget_set_halign (priv->widget_description, GTK_ALIGN_START);
|
gtk_widget_set_halign (color_profile->widget_description, GTK_ALIGN_START);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_description, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_profile->widget_description, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->widget_description);
|
gtk_widget_show (color_profile->widget_description);
|
||||||
|
|
||||||
/* profile warnings/info */
|
/* profile warnings/info */
|
||||||
priv->widget_info = gtk_image_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_MENU);
|
color_profile->widget_info = gtk_image_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_MENU);
|
||||||
gtk_widget_set_margin_start (priv->widget_info, IMAGE_WIDGET_PADDING);
|
gtk_widget_set_margin_start (color_profile->widget_info, IMAGE_WIDGET_PADDING);
|
||||||
gtk_widget_set_margin_end (priv->widget_info, IMAGE_WIDGET_PADDING);
|
gtk_widget_set_margin_end (color_profile->widget_info, IMAGE_WIDGET_PADDING);
|
||||||
gtk_box_pack_start (GTK_BOX (box), priv->widget_info, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (box), color_profile->widget_info, FALSE, FALSE, 0);
|
||||||
|
|
||||||
/* refresh */
|
/* refresh */
|
||||||
gtk_container_add (GTK_CONTAINER (color_profile), box);
|
gtk_container_add (GTK_CONTAINER (color_profile), box);
|
||||||
|
|
|
@ -25,33 +25,11 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <colord.h>
|
#include <colord.h>
|
||||||
|
|
||||||
#define CC_TYPE_COLOR_PROFILE (cc_color_profile_get_type())
|
|
||||||
#define CC_COLOR_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CC_TYPE_COLOR_PROFILE, CcColorProfile))
|
|
||||||
#define CC_COLOR_PROFILE_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), CC_TYPE_COLOR_PROFILE, CcColorProfileClass))
|
|
||||||
#define CC_IS_COLOR_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CC_TYPE_COLOR_PROFILE))
|
|
||||||
#define CC_IS_COLOR_PROFILE_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), CC_TYPE_COLOR_PROFILE))
|
|
||||||
#define CC_COLOR_PROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CC_TYPE_COLOR_PROFILE, CcColorProfileClass))
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _CcColorProfile CcColorProfile;
|
#define CC_TYPE_COLOR_PROFILE (cc_color_profile_get_type ())
|
||||||
typedef struct _CcColorProfileClass CcColorProfileClass;
|
G_DECLARE_FINAL_TYPE (CcColorProfile, cc_color_profile, CC, COLOR_PROFILE, GtkListBoxRow)
|
||||||
typedef struct _CcColorProfilePrivate CcColorProfilePrivate;
|
|
||||||
|
|
||||||
struct _CcColorProfile
|
|
||||||
{
|
|
||||||
GtkListBoxRow parent;
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
CcColorProfilePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _CcColorProfileClass
|
|
||||||
{
|
|
||||||
GtkListBoxRowClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType cc_color_profile_get_type (void);
|
|
||||||
GtkWidget *cc_color_profile_new (CdDevice *device,
|
GtkWidget *cc_color_profile_new (CdDevice *device,
|
||||||
CdProfile *profile,
|
CdProfile *profile,
|
||||||
gboolean is_default);
|
gboolean is_default);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue