app: new profile conversion policy to preferred color profile.
Our Preferences exposes a concept of "Preferred color profile" (for RGB, grayscale and CMYK), which is used in some places to be proposed as default alternative to built-in profiles. But it was not used in the import color profile dialog (only 2 choices were: keep the image profile or convert to built-in RGB). This commit now adds this third choice, which is even made default when hitting the "Convert" button directly, without tweaking with the dialog. Because we can assume that if someone made the explicit choice to label such a profile as "Preferred", this is more likely the one to convert to (if one even wants to convert from an embedded profile anyway). As for the `Preferences > Image Import & Export > Color profile policy`, they now propose 4 choices: Ask, Keep embedded profile, Convert to built-in or preferred profiles.
This commit is contained in:
parent
41c8d19634
commit
09fa321074
7 changed files with 97 additions and 23 deletions
|
|
@ -210,7 +210,8 @@ gimp_color_profile_policy_get_type (void)
|
|||
{
|
||||
{ GIMP_COLOR_PROFILE_POLICY_ASK, "GIMP_COLOR_PROFILE_POLICY_ASK", "ask" },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_KEEP, "GIMP_COLOR_PROFILE_POLICY_KEEP", "keep" },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT, "GIMP_COLOR_PROFILE_POLICY_CONVERT", "convert" },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN, "GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN", "convert-builtin" },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED, "GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED", "convert-preferred" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
@ -218,7 +219,8 @@ gimp_color_profile_policy_get_type (void)
|
|||
{
|
||||
{ GIMP_COLOR_PROFILE_POLICY_ASK, NC_("color-profile-policy", "Ask what to do"), NULL },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_KEEP, NC_("color-profile-policy", "Keep embedded profile"), NULL },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT, NC_("color-profile-policy", "Convert to built-in sRGB or grayscale profile"), NULL },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN, NC_("color-profile-policy", "Convert to built-in sRGB or grayscale profile"), NULL },
|
||||
{ GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED, NC_("color-profile-policy", "Convert to preferred sRGB or grayscale profile (defaulting to built-in)"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -136,9 +136,10 @@ GType gimp_color_profile_policy_get_type (void) G_GNUC_CONST;
|
|||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_COLOR_PROFILE_POLICY_ASK, /*< desc="Ask what to do" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_KEEP, /*< desc="Keep embedded profile" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_CONVERT /*< desc="Convert to built-in sRGB or grayscale profile" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_ASK, /*< desc="Ask what to do" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_KEEP, /*< desc="Keep embedded profile" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN, /*< desc="Convert to built-in sRGB or grayscale profile" >*/
|
||||
GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED, /*< desc="Convert to preferred sRGB or grayscale profile (defaulting to built-in)" >*/
|
||||
} GimpColorProfilePolicy;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -609,12 +609,25 @@ gimp_image_import_color_profile (GimpImage *image,
|
|||
}
|
||||
}
|
||||
|
||||
if (policy == GIMP_COLOR_PROFILE_POLICY_CONVERT)
|
||||
if (policy == GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED ||
|
||||
policy == GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN)
|
||||
{
|
||||
if (! dest_profile)
|
||||
{
|
||||
dest_profile = gimp_image_get_builtin_color_profile (image);
|
||||
g_object_ref (dest_profile);
|
||||
if (policy == GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED)
|
||||
{
|
||||
if (gimp_image_get_base_type (image) == GIMP_GRAY)
|
||||
dest_profile = gimp_color_config_get_gray_color_profile (image->gimp->config->color_management, NULL);
|
||||
else
|
||||
dest_profile = gimp_color_config_get_rgb_color_profile (image->gimp->config->color_management, NULL);
|
||||
}
|
||||
|
||||
if (! dest_profile)
|
||||
{
|
||||
/* Built-in policy or no preferred profile set. */
|
||||
dest_profile = gimp_image_get_builtin_color_profile (image);
|
||||
g_object_ref (dest_profile);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_image_convert_color_profile (image, dest_profile,
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@
|
|||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "dialogs-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
|
@ -60,12 +63,15 @@ color_profile_import_dialog_run (GimpImage *image,
|
|||
GtkWidget *dialog;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *stack;
|
||||
GtkWidget *switcher;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *label;
|
||||
GtkWidget *intent_combo;
|
||||
GtkWidget *bpc_toggle;
|
||||
GtkWidget *dont_ask_toggle;
|
||||
GimpColorProfile *src_profile;
|
||||
GimpColorProfile *pref_profile = NULL;
|
||||
GimpColorProfilePolicy policy;
|
||||
const gchar *title;
|
||||
const gchar *frame_title;
|
||||
|
|
@ -84,11 +90,19 @@ color_profile_import_dialog_run (GimpImage *image,
|
|||
{
|
||||
title = _("Convert to Grayscale Working Space?");
|
||||
frame_title = _("Convert the image to the built-in grayscale color profile?");
|
||||
|
||||
pref_profile = gimp_color_config_get_gray_color_profile (image->gimp->config->color_management, NULL);
|
||||
if (pref_profile && gimp_color_profile_is_equal (pref_profile, *dest_profile))
|
||||
g_clear_object (&pref_profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = _("Convert to RGB Working Space?");
|
||||
frame_title = _("Convert the image to the built-in sRGB color profile?");
|
||||
|
||||
pref_profile = gimp_color_config_get_rgb_color_profile (image->gimp->config->color_management, NULL);
|
||||
if (pref_profile && gimp_color_profile_is_equal (pref_profile, *dest_profile))
|
||||
g_clear_object (&pref_profile);
|
||||
}
|
||||
|
||||
dialog =
|
||||
|
|
@ -130,14 +144,41 @@ color_profile_import_dialog_run (GimpImage *image,
|
|||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
switcher = gtk_stack_switcher_new ();
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), stack, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), switcher, FALSE, FALSE, 0);
|
||||
gtk_widget_show (stack);
|
||||
|
||||
frame = gimp_frame_new (frame_title);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), frame, "builtin", "Built-in Profile");
|
||||
gtk_widget_show (frame);
|
||||
|
||||
label = gimp_color_profile_label_new (*dest_profile);
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
if (pref_profile)
|
||||
{
|
||||
if (gimp_image_get_base_type (image) == GIMP_GRAY)
|
||||
frame_title = _("Convert the image to the preferred grayscale color profile?");
|
||||
else
|
||||
frame_title = _("Convert the image to the preferred sRGB color profile?");
|
||||
|
||||
frame = gimp_frame_new (frame_title);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), frame, "preferred", "Preferred Profile");
|
||||
gtk_widget_show (frame);
|
||||
|
||||
label = gimp_color_profile_label_new (pref_profile);
|
||||
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_widget_show (switcher);
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), "preferred");
|
||||
}
|
||||
|
||||
if (intent && bpc)
|
||||
{
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
|
|
@ -191,8 +232,17 @@ color_profile_import_dialog_run (GimpImage *image,
|
|||
switch (gtk_dialog_run (GTK_DIALOG (dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_OK:
|
||||
policy = GIMP_COLOR_PROFILE_POLICY_CONVERT;
|
||||
g_object_ref (*dest_profile);
|
||||
if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (stack)),
|
||||
"builtin") == 0)
|
||||
{
|
||||
policy = GIMP_COLOR_PROFILE_POLICY_CONVERT_BUILTIN;
|
||||
g_object_ref (*dest_profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
policy = GIMP_COLOR_PROFILE_POLICY_CONVERT_PREFERRED;
|
||||
*dest_profile = g_object_ref (pref_profile);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -211,6 +261,7 @@ color_profile_import_dialog_run (GimpImage *image,
|
|||
*dont_ask = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dont_ask_toggle));
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
g_clear_object (&pref_profile);
|
||||
|
||||
return policy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5623,8 +5623,9 @@ register_image_procs (GimpPDB *pdb)
|
|||
"gimp-image-policy-color-profile");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Execute the color profile conversion policy.",
|
||||
"Process the image according to the color profile policy as set in Preferences. If GIMP is running as a GUI and interactive is TRUE, a dialog may be presented to the user depending on the set policy. Otherwise, if the policy does not mandate the conversion to perform, the conversion to the builtin RGB or grayscale profile will happen.\n"
|
||||
"This function should be used only if you want to follow user settings. If you wish to keep to convert to a specific profile, call preferrably 'gimp-image-convert-color-profile'. And if you wish to leave whatever profile an image has, do not call any of these functions.\n"
|
||||
"Process the image according to the color profile policy as set in Preferences.\n"
|
||||
"If GIMP is running as a GUI and interactive is TRUE, a dialog may be presented to the user depending on the policy. Otherwise, if the policy does not mandate the conversion to perform, the conversion to the preferred RGB or grayscale profile will happen, defaulting to built-in profiles if no preferred profiles were set in `Preferences`.\n"
|
||||
"This function should be used only if you want to follow user settings. If you intend to convert to a specific profile, call preferrably 'gimp-image-convert-color-profile'. And if you wish to leave whatever profile an image has, do not call any of these functions.\n"
|
||||
"Finally it is unnecessary to call this function in a format load procedure because this is called automatically by the core code when loading any image. You should only call this function explicitly when loading an image through a PDB call.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
|
|
|
|||
|
|
@ -3481,12 +3481,15 @@ gimp_image_policy_rotate (GimpImage *image,
|
|||
* Execute the color profile conversion policy.
|
||||
*
|
||||
* Process the image according to the color profile policy as set in
|
||||
* Preferences. If GIMP is running as a GUI and interactive is TRUE, a
|
||||
* dialog may be presented to the user depending on the set policy.
|
||||
* Otherwise, if the policy does not mandate the conversion to perform,
|
||||
* the conversion to the builtin RGB or grayscale profile will happen.
|
||||
* Preferences.
|
||||
* If GIMP is running as a GUI and interactive is TRUE, a dialog may be
|
||||
* presented to the user depending on the policy. Otherwise, if the
|
||||
* policy does not mandate the conversion to perform, the conversion to
|
||||
* the preferred RGB or grayscale profile will happen, defaulting to
|
||||
* built-in profiles if no preferred profiles were set in
|
||||
* `Preferences`.
|
||||
* This function should be used only if you want to follow user
|
||||
* settings. If you wish to keep to convert to a specific profile, call
|
||||
* settings. If you intend to convert to a specific profile, call
|
||||
* preferrably gimp_image_convert_color_profile(). And if you wish to
|
||||
* leave whatever profile an image has, do not call any of these
|
||||
* functions.
|
||||
|
|
|
|||
|
|
@ -3019,14 +3019,17 @@ CODE
|
|||
sub image_policy_color_profile {
|
||||
$blurb = 'Execute the color profile conversion policy.';
|
||||
$help = <<'HELP';
|
||||
Process the image according to the color profile policy as set in Preferences.
|
||||
Process the image according to the color profile policy as set in
|
||||
Preferences.
|
||||
|
||||
If GIMP is running as a GUI and interactive is TRUE, a dialog may be
|
||||
presented to the user depending on the set policy. Otherwise, if the
|
||||
policy does not mandate the conversion to perform, the conversion to the
|
||||
builtin RGB or grayscale profile will happen.
|
||||
presented to the user depending on the policy. Otherwise, if the policy
|
||||
does not mandate the conversion to perform, the conversion to the
|
||||
preferred RGB or grayscale profile will happen, defaulting to built-in
|
||||
profiles if no preferred profiles were set in `Preferences`.
|
||||
|
||||
This function should be used only if you want to follow user settings.
|
||||
If you wish to keep to convert to a specific profile, call preferrably
|
||||
If you intend to convert to a specific profile, call preferrably
|
||||
gimp_image_convert_color_profile(). And if you wish to leave whatever
|
||||
profile an image has, do not call any of these functions.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue