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