From 4d2acac5066024004e53348a4ec64d7b5ec1a70c Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 17 Dec 2023 23:22:18 +0900 Subject: [PATCH] =?UTF-8?q?libgimpwidgets,=20modules:=20display=20the=20ex?= =?UTF-8?q?act=20space/profile=20name=20for=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … relevant color selectors. --- libgimpwidgets/gimpcolorscales.c | 68 ++++++++++++++++++++++++++++++++ libgimpwidgets/gimpcolorselect.c | 43 ++++++++++++++++++++ modules/color-selector-water.c | 43 ++++++++++++++++++++ modules/color-selector-wheel.c | 44 +++++++++++++++++++++ 4 files changed, 198 insertions(+) diff --git a/libgimpwidgets/gimpcolorscales.c b/libgimpwidgets/gimpcolorscales.c index 7adb543f66..ea93099e50 100644 --- a/libgimpwidgets/gimpcolorscales.c +++ b/libgimpwidgets/gimpcolorscales.c @@ -111,6 +111,8 @@ struct _GimpColorScales GtkWidget *dummy_u8_toggle; GtkWidget *toggles[14]; GtkWidget *scales[14]; + + GList *profile_labels; }; struct _GimpColorScalesClass @@ -244,6 +246,8 @@ create_group (GimpColorScales *scales, GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales); GtkWidget *grid; GEnumClass *enum_class; + GtkWidget *label = NULL; + gboolean add_label = FALSE; gint row; gint i; @@ -259,6 +263,12 @@ create_group (GimpColorScales *scales, gint enum_value = i; 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 && enum_value <= GIMP_COLOR_SELECTOR_ALPHA_U8) { @@ -344,6 +354,18 @@ create_group (GimpColorScales *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); return grid; @@ -378,6 +400,8 @@ gimp_color_scales_init (GimpColorScales *scales) main_group = NULL; u8_group = NULL; + scales->profile_labels = NULL; + scales->dummy_u8_toggle = gtk_radio_button_new (NULL); g_object_ref_sink (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_hsv_binding, g_binding_unbind); + g_clear_pointer (&scales->profile_labels, g_list_free); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -662,6 +687,49 @@ gimp_color_scales_set_format (GimpColorSelector *selector, 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: unknown")); + gimp_help_set_help_data (iter->data, NULL, NULL); + } + } + + g_clear_object (&profile); + } + gimp_color_scales_update_scales (scales, -1); } diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c index 75f8c98c2f..7e784db5ad 100644 --- a/libgimpwidgets/gimpcolorselect.c +++ b/libgimpwidgets/gimpcolorselect.c @@ -129,6 +129,7 @@ struct _GimpColorSelect GimpColorSelector parent_instance; GtkWidget *toggle_box[3]; + GtkWidget *label; GtkWidget *xy_color; 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 (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"), 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: unknown")); + gimp_help_set_help_data (select->label, NULL, NULL); + } + + g_clear_object (&profile); + } + select->xy_needs_render = TRUE; select->z_needs_render = TRUE; diff --git a/modules/color-selector-water.c b/modules/color-selector-water.c index 06e0fd4a4b..8d82188e5a 100644 --- a/modules/color-selector-water.c +++ b/modules/color-selector-water.c @@ -47,6 +47,7 @@ struct _ColorselWater GimpColorSelector parent_instance; GtkWidget *area; + GtkWidget *label; gdouble last_x; gdouble last_y; @@ -197,6 +198,14 @@ colorsel_water_init (ColorselWater *water) gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0); 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 @@ -227,6 +236,40 @@ colorsel_water_set_format (GimpColorSelector *selector, if (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: unknown")); + gimp_help_set_help_data (water->label, NULL, NULL); + } + + g_clear_object (&profile); + } gtk_widget_queue_draw (GTK_WIDGET (water)); } } diff --git a/modules/color-selector-wheel.c b/modules/color-selector-wheel.c index 787ffc4790..afc1d003f8 100644 --- a/modules/color-selector-wheel.c +++ b/modules/color-selector-wheel.c @@ -48,6 +48,8 @@ struct _ColorselWheel GimpColorSelector parent_instance; GtkWidget *hsv; + GtkWidget *label; + 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_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_CALLBACK (colorsel_wheel_changed), wheel); @@ -159,6 +169,40 @@ colorsel_wheel_set_format (GimpColorSelector *selector, { wheel->format = 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: unknown")); + gimp_help_set_help_data (wheel->label, NULL, NULL); + } + + g_clear_object (&profile); + } } }