Commit 770a3b1d authored by Robert Ancell's avatar Robert Ancell

color: Replace GObject boilerplace with G_DECLARE_TYPE

parent 6d3ed43e
This diff is collapsed.
......@@ -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;
struct _CcColorDevice
{
GtkListBoxRow parent;
/*< private >*/
CcColorDevicePrivate *priv;
};
struct _CcColorDeviceClass
{
GtkListBoxRowClass parent_class;
void (*expanded_changed) (CcColorDevice *color_device,
gboolean expanded);
};
#define CC_TYPE_COLOR_DEVICE (cc_color_device_get_type ())
G_DECLARE_FINAL_TYPE (CcColorDevice, cc_color_device, CC, COLOR_DEVICE, GtkListBoxRow)
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);
......
This diff is collapsed.
......@@ -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;