static GtkWidget * lcms_icc_combo_box_new (GimpColorConfig *config, const gchar *filename) { GtkWidget *combo; GtkWidget *dialog; gchar *history; gchar *label; gchar *name; const gchar *rgb_filename = NULL; cmsHPROFILE profile = NULL; dialog = gimp_color_profile_chooser_dialog_new (_("Select destination profile")); history = gimp_personal_rc_file ("profilerc"); combo = gimp_color_profile_combo_box_new (dialog, history); g_free (history); if (config->rgb_profile) { GError *error = NULL; profile = gimp_lcms_profile_open_from_file (config->rgb_profile, &error); if (! profile) { g_message ("%s", error->message); g_clear_error (&error); } else if (! gimp_lcms_profile_is_rgb (profile)) { g_message (_("Color profile '%s' is not for RGB color space."), gimp_filename_to_utf8 (config->rgb_profile)); cmsCloseProfile (profile); profile = NULL; } else { rgb_filename = config->rgb_profile; } } if (! profile) profile = gimp_lcms_create_srgb_profile (); name = gimp_lcms_profile_get_label (profile); label = g_strdup_printf (_("RGB workspace (%s)"), name); g_free (name); cmsCloseProfile (profile); gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo), rgb_filename, label); g_free (label); gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), filename, NULL); return combo; }
static void cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo, const gchar *filename) { cmsHPROFILE profile = NULL; gchar *label = NULL; if (filename) profile = cmsOpenProfileFromFile (filename, "r"); if (profile) { cmsUInt32Number descSize; gchar *descData; descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription, "en", "US", NULL, 0); if (descSize > 0) { descData = g_new (gchar, descSize + 1); descSize = cmsGetProfileInfoASCII (profile, cmsInfoDescription, "en", "US", descData, descSize); if (descSize > 0) label = gimp_any_to_utf8 (descData, -1, NULL); g_free (descData); } if (! label) { descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel, "en", "US", NULL, 0); if (descSize > 0) { descData = g_new (gchar, descSize + 1); descSize = cmsGetProfileInfoASCII (profile, cmsInfoModel, "en", "US", descData, descSize); if (descSize > 0) label = gimp_any_to_utf8 (descData, -1, NULL); g_free (descData); } } cmsCloseProfile (profile); } gimp_color_profile_combo_box_set_active (combo, filename, label); g_free (label); }
static GtkWidget * cdisplay_proof_configure (GimpColorDisplay *display) { CdisplayProof *proof = CDISPLAY_PROOF (display); GtkWidget *table; GtkWidget *combo; GtkWidget *toggle; GtkWidget *dialog; gchar *history; table = gtk_table_new (3, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 6); dialog = gimp_color_profile_chooser_dialog_new (_("Choose an ICC Color Profile")); history = gimp_personal_rc_file ("profilerc"); combo = gimp_color_profile_combo_box_new (dialog, history); g_free (history); g_signal_connect (combo, "changed", G_CALLBACK (cdisplay_proof_profile_changed), proof); if (proof->profile) gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), proof->profile, NULL); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Profile:"), 0.0, 0.5, combo, 1, FALSE); combo = gimp_prop_enum_combo_box_new (G_OBJECT (proof), "intent", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Intent:"), 0.0, 0.5, combo, 1, FALSE); toggle = gimp_prop_check_button_new (G_OBJECT (proof), "black-point-compensation", _("_Black Point Compensation")); gtk_table_attach_defaults (GTK_TABLE (table), toggle, 1, 2, 2, 3); gtk_widget_show (toggle); return table; }
static void gimp_color_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog, gint response, GimpColorProfileComboBox *combo) { if (response == GTK_RESPONSE_ACCEPT) { gchar *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if (filename) { gimp_color_profile_combo_box_set_active (combo, filename, NULL); g_free (filename); } } gtk_widget_hide (GTK_WIDGET (dialog)); }
static void cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo, const gchar *filename) { cmsHPROFILE profile = NULL; gchar *label = NULL; if (filename) profile = cmsOpenProfileFromFile (filename, "r"); if (profile) { label = gimp_any_to_utf8 (cmsTakeProductDesc (profile), -1, NULL); if (! label) label = gimp_any_to_utf8 (cmsTakeProductName (profile), -1, NULL); cmsCloseProfile (profile); } gimp_color_profile_combo_box_set_active (combo, filename, label); g_free (label); }
static void lcms_icc_combo_box_set_active (GimpColorProfileComboBox *combo, const gchar *filename) { cmsHPROFILE profile = NULL; gchar *label = NULL; if (filename) profile = lcms_load_profile (filename, NULL); if (profile) { label = lcms_icc_profile_get_desc (profile); if (! label) label = lcms_icc_profile_get_name (profile); cmsCloseProfile (profile); } gimp_color_profile_combo_box_set_active (combo, filename, label); g_free (label); }