mirror of https://github.com/GNOME/gimp.git
libgimpwidgets, modules: display the exact space/profile name for…
… relevant color selectors.
This commit is contained in:
parent
3c3f3030f1
commit
4d2acac506
|
@ -111,6 +111,8 @@ struct _GimpColorScales
|
||||||
GtkWidget *dummy_u8_toggle;
|
GtkWidget *dummy_u8_toggle;
|
||||||
GtkWidget *toggles[14];
|
GtkWidget *toggles[14];
|
||||||
GtkWidget *scales[14];
|
GtkWidget *scales[14];
|
||||||
|
|
||||||
|
GList *profile_labels;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpColorScalesClass
|
struct _GimpColorScalesClass
|
||||||
|
@ -244,6 +246,8 @@ create_group (GimpColorScales *scales,
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||||
GtkWidget *grid;
|
GtkWidget *grid;
|
||||||
GEnumClass *enum_class;
|
GEnumClass *enum_class;
|
||||||
|
GtkWidget *label = NULL;
|
||||||
|
gboolean add_label = FALSE;
|
||||||
gint row;
|
gint row;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
@ -259,6 +263,12 @@ create_group (GimpColorScales *scales,
|
||||||
gint enum_value = i;
|
gint enum_value = i;
|
||||||
gboolean is_u8 = FALSE;
|
gboolean is_u8 = FALSE;
|
||||||
|
|
||||||
|
if ((enum_value >= GIMP_COLOR_SELECTOR_RED_U8 &&
|
||||||
|
enum_value <= GIMP_COLOR_SELECTOR_BLUE_U8) ||
|
||||||
|
(enum_value >= GIMP_COLOR_SELECTOR_HUE &&
|
||||||
|
enum_value <= GIMP_COLOR_SELECTOR_BLUE))
|
||||||
|
add_label = TRUE;
|
||||||
|
|
||||||
if (enum_value >= GIMP_COLOR_SELECTOR_RED_U8 &&
|
if (enum_value >= GIMP_COLOR_SELECTOR_RED_U8 &&
|
||||||
enum_value <= GIMP_COLOR_SELECTOR_ALPHA_U8)
|
enum_value <= GIMP_COLOR_SELECTOR_ALPHA_U8)
|
||||||
{
|
{
|
||||||
|
@ -344,6 +354,18 @@ create_group (GimpColorScales *scales,
|
||||||
scales);
|
scales);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (add_label)
|
||||||
|
{
|
||||||
|
label = gtk_label_new (NULL);
|
||||||
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_label_set_text (GTK_LABEL (label), _("Profile: sRGB"));
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), label, 1, row, 3, 1);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
scales->profile_labels = g_list_prepend (scales->profile_labels, label);
|
||||||
|
}
|
||||||
|
|
||||||
g_type_class_unref (enum_class);
|
g_type_class_unref (enum_class);
|
||||||
|
|
||||||
return grid;
|
return grid;
|
||||||
|
@ -378,6 +400,8 @@ gimp_color_scales_init (GimpColorScales *scales)
|
||||||
main_group = NULL;
|
main_group = NULL;
|
||||||
u8_group = NULL;
|
u8_group = NULL;
|
||||||
|
|
||||||
|
scales->profile_labels = NULL;
|
||||||
|
|
||||||
scales->dummy_u8_toggle = gtk_radio_button_new (NULL);
|
scales->dummy_u8_toggle = gtk_radio_button_new (NULL);
|
||||||
g_object_ref_sink (scales->dummy_u8_toggle);
|
g_object_ref_sink (scales->dummy_u8_toggle);
|
||||||
u8_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->dummy_u8_toggle));
|
u8_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->dummy_u8_toggle));
|
||||||
|
@ -495,6 +519,7 @@ gimp_color_scales_dispose (GObject *object)
|
||||||
|
|
||||||
g_clear_pointer (&scales->show_rgb_u8_binding, g_binding_unbind);
|
g_clear_pointer (&scales->show_rgb_u8_binding, g_binding_unbind);
|
||||||
g_clear_pointer (&scales->show_hsv_binding, g_binding_unbind);
|
g_clear_pointer (&scales->show_hsv_binding, g_binding_unbind);
|
||||||
|
g_clear_pointer (&scales->profile_labels, g_list_free);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -662,6 +687,49 @@ gimp_color_scales_set_format (GimpColorSelector *selector,
|
||||||
|
|
||||||
scales->format = format;
|
scales->format = format;
|
||||||
|
|
||||||
|
if (format == NULL || babl_format_get_space (format) == babl_space ("sRGB"))
|
||||||
|
{
|
||||||
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (iter->data), _("Profile: sRGB"));
|
||||||
|
gimp_help_set_help_data (iter->data, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GimpColorProfile *profile = NULL;
|
||||||
|
const gchar *icc;
|
||||||
|
gint icc_len;
|
||||||
|
|
||||||
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_len);
|
||||||
|
profile = gimp_color_profile_new_from_icc_profile ((const guint8 *) icc, icc_len, NULL);
|
||||||
|
|
||||||
|
if (profile != NULL)
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf (_("Profile: %s"), gimp_color_profile_get_label (profile));
|
||||||
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (iter->data), text);
|
||||||
|
gimp_help_set_help_data (iter->data,
|
||||||
|
gimp_color_profile_get_summary (profile),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
gtk_label_set_markup (GTK_LABEL (iter->data), _("Profile: <i>unknown</i>"));
|
||||||
|
gimp_help_set_help_data (iter->data, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_object (&profile);
|
||||||
|
}
|
||||||
|
|
||||||
gimp_color_scales_update_scales (scales, -1);
|
gimp_color_scales_update_scales (scales, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ struct _GimpColorSelect
|
||||||
GimpColorSelector parent_instance;
|
GimpColorSelector parent_instance;
|
||||||
|
|
||||||
GtkWidget *toggle_box[3];
|
GtkWidget *toggle_box[3];
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
GtkWidget *xy_color;
|
GtkWidget *xy_color;
|
||||||
ColorSelectFillType xy_color_fill;
|
ColorSelectFillType xy_color_fill;
|
||||||
|
@ -489,6 +490,14 @@ gimp_color_select_init (GimpColorSelect *select)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select->label = gtk_label_new (NULL);
|
||||||
|
gtk_widget_set_halign (select->label, GTK_ALIGN_START);
|
||||||
|
gtk_widget_set_vexpand (select->label, FALSE);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (select->label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_label_set_text (GTK_LABEL (select->label), _("Profile: sRGB"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (select), select->label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (select->label);
|
||||||
|
|
||||||
g_type_class_unref (model_class);
|
g_type_class_unref (model_class);
|
||||||
g_type_class_unref (channel_class);
|
g_type_class_unref (channel_class);
|
||||||
}
|
}
|
||||||
|
@ -633,6 +642,40 @@ gimp_color_select_set_format (GimpColorSelector *selector,
|
||||||
fish_lch_to_rgb_u8 = babl_fish (babl_format ("CIE LCH(ab) double"),
|
fish_lch_to_rgb_u8 = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||||
babl_format_with_space ("R'G'B' u8", format));
|
babl_format_with_space ("R'G'B' u8", format));
|
||||||
|
|
||||||
|
if (format == NULL || babl_format_get_space (format) == babl_space ("sRGB"))
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (select->label), _("Profile: sRGB"));
|
||||||
|
gimp_help_set_help_data (select->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GimpColorProfile *profile = NULL;
|
||||||
|
const gchar *icc;
|
||||||
|
gint icc_len;
|
||||||
|
|
||||||
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_len);
|
||||||
|
profile = gimp_color_profile_new_from_icc_profile ((const guint8 *) icc, icc_len, NULL);
|
||||||
|
|
||||||
|
if (profile != NULL)
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf (_("Profile: %s"), gimp_color_profile_get_label (profile));
|
||||||
|
gtk_label_set_text (GTK_LABEL (select->label), text);
|
||||||
|
gimp_help_set_help_data (select->label,
|
||||||
|
gimp_color_profile_get_summary (profile),
|
||||||
|
NULL);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_label_set_markup (GTK_LABEL (select->label), _("Profile: <i>unknown</i>"));
|
||||||
|
gimp_help_set_help_data (select->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_object (&profile);
|
||||||
|
}
|
||||||
|
|
||||||
select->xy_needs_render = TRUE;
|
select->xy_needs_render = TRUE;
|
||||||
select->z_needs_render = TRUE;
|
select->z_needs_render = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct _ColorselWater
|
||||||
GimpColorSelector parent_instance;
|
GimpColorSelector parent_instance;
|
||||||
|
|
||||||
GtkWidget *area;
|
GtkWidget *area;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
gdouble last_x;
|
gdouble last_x;
|
||||||
gdouble last_y;
|
gdouble last_y;
|
||||||
|
@ -197,6 +198,14 @@ colorsel_water_init (ColorselWater *water)
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
|
||||||
|
|
||||||
gtk_widget_show_all (hbox);
|
gtk_widget_show_all (hbox);
|
||||||
|
|
||||||
|
water->label = gtk_label_new (NULL);
|
||||||
|
gtk_widget_set_halign (water->label, GTK_ALIGN_START);
|
||||||
|
gtk_widget_set_vexpand (water->label, FALSE);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (water->label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_label_set_text (GTK_LABEL (water->label), _("Profile: sRGB"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (water), water->label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (water->label);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gdouble
|
static gdouble
|
||||||
|
@ -227,6 +236,40 @@ colorsel_water_set_format (GimpColorSelector *selector,
|
||||||
if (water->format != format)
|
if (water->format != format)
|
||||||
{
|
{
|
||||||
water->format = format;
|
water->format = format;
|
||||||
|
|
||||||
|
if (format == NULL || babl_format_get_space (format) == babl_space ("sRGB"))
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (water->label), _("Profile: sRGB"));
|
||||||
|
gimp_help_set_help_data (water->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GimpColorProfile *profile = NULL;
|
||||||
|
const gchar *icc;
|
||||||
|
gint icc_len;
|
||||||
|
|
||||||
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_len);
|
||||||
|
profile = gimp_color_profile_new_from_icc_profile ((const guint8 *) icc, icc_len, NULL);
|
||||||
|
|
||||||
|
if (profile != NULL)
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf (_("Profile: %s"), gimp_color_profile_get_label (profile));
|
||||||
|
gtk_label_set_text (GTK_LABEL (water->label), text);
|
||||||
|
gimp_help_set_help_data (water->label,
|
||||||
|
gimp_color_profile_get_summary (profile),
|
||||||
|
NULL);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_label_set_markup (GTK_LABEL (water->label), _("Profile: <i>unknown</i>"));
|
||||||
|
gimp_help_set_help_data (water->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_object (&profile);
|
||||||
|
}
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (water));
|
gtk_widget_queue_draw (GTK_WIDGET (water));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ struct _ColorselWheel
|
||||||
GimpColorSelector parent_instance;
|
GimpColorSelector parent_instance;
|
||||||
|
|
||||||
GtkWidget *hsv;
|
GtkWidget *hsv;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
const Babl *format;
|
const Babl *format;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,6 +129,14 @@ colorsel_wheel_init (ColorselWheel *wheel)
|
||||||
gtk_box_pack_start (GTK_BOX (wheel), wheel->hsv, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (wheel), wheel->hsv, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (wheel->hsv);
|
gtk_widget_show (wheel->hsv);
|
||||||
|
|
||||||
|
wheel->label = gtk_label_new (NULL);
|
||||||
|
gtk_widget_set_halign (wheel->label, GTK_ALIGN_START);
|
||||||
|
gtk_widget_set_vexpand (wheel->label, FALSE);
|
||||||
|
gtk_label_set_justify (GTK_LABEL (wheel->label), GTK_JUSTIFY_LEFT);
|
||||||
|
gtk_label_set_text (GTK_LABEL (wheel->label), _("Profile: sRGB"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (wheel), wheel->label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (wheel->label);
|
||||||
|
|
||||||
g_signal_connect (wheel->hsv, "changed",
|
g_signal_connect (wheel->hsv, "changed",
|
||||||
G_CALLBACK (colorsel_wheel_changed),
|
G_CALLBACK (colorsel_wheel_changed),
|
||||||
wheel);
|
wheel);
|
||||||
|
@ -159,6 +169,40 @@ colorsel_wheel_set_format (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
wheel->format = format;
|
wheel->format = format;
|
||||||
gimp_color_wheel_set_format (GIMP_COLOR_WHEEL (wheel->hsv), format);
|
gimp_color_wheel_set_format (GIMP_COLOR_WHEEL (wheel->hsv), format);
|
||||||
|
|
||||||
|
if (format == NULL || babl_format_get_space (format) == babl_space ("sRGB"))
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (wheel->label), _("Profile: sRGB"));
|
||||||
|
gimp_help_set_help_data (wheel->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GimpColorProfile *profile = NULL;
|
||||||
|
const gchar *icc;
|
||||||
|
gint icc_len;
|
||||||
|
|
||||||
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_len);
|
||||||
|
profile = gimp_color_profile_new_from_icc_profile ((const guint8 *) icc, icc_len, NULL);
|
||||||
|
|
||||||
|
if (profile != NULL)
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf (_("Profile: %s"), gimp_color_profile_get_label (profile));
|
||||||
|
gtk_label_set_text (GTK_LABEL (wheel->label), text);
|
||||||
|
gimp_help_set_help_data (wheel->label,
|
||||||
|
gimp_color_profile_get_summary (profile),
|
||||||
|
NULL);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_label_set_markup (GTK_LABEL (wheel->label), _("Profile: <i>unknown</i>"));
|
||||||
|
gimp_help_set_help_data (wheel->label, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_object (&profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue