pdb: change the URIs in the color profile API to GFiles

This commit is contained in:
Michael Natterer 2019-09-11 22:44:17 +02:00
parent 14af676b51
commit 77731d1e8e
4 changed files with 34 additions and 48 deletions

View File

@ -191,16 +191,15 @@ image_set_color_profile_from_file_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpImage *image;
const gchar *uri;
GFile *file;
image = g_value_get_object (gimp_value_array_index (args, 0));
uri = g_value_get_string (gimp_value_array_index (args, 1));
file = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
if (uri)
if (file)
{
GFile *file = g_file_new_for_uri (uri);
GimpColorProfile *profile;
profile = gimp_color_profile_new_from_file (file, error);
@ -213,8 +212,6 @@ image_set_color_profile_from_file_invoker (GimpProcedure *procedure,
}
else
success = FALSE;
g_object_unref (file);
}
else
{
@ -286,20 +283,19 @@ image_convert_color_profile_from_file_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpImage *image;
const gchar *uri;
GFile *file;
gint intent;
gboolean bpc;
image = g_value_get_object (gimp_value_array_index (args, 0));
uri = g_value_get_string (gimp_value_array_index (args, 1));
file = g_value_get_object (gimp_value_array_index (args, 1));
intent = g_value_get_enum (gimp_value_array_index (args, 2));
bpc = g_value_get_boolean (gimp_value_array_index (args, 3));
if (success)
{
if (uri)
if (file)
{
GFile *file = g_file_new_for_uri (uri);
GimpColorProfile *profile;
profile = gimp_color_profile_new_from_file (file, error);
@ -313,8 +309,6 @@ image_convert_color_profile_from_file_invoker (GimpProcedure *procedure,
}
else
success = FALSE;
g_object_unref (file);
}
else
success = FALSE;
@ -452,12 +446,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("uri",
"uri",
"The URI of the file containing the new color profile",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
g_param_spec_object ("file",
"file",
"The file containing the new color profile",
G_TYPE_FILE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -516,7 +509,7 @@ register_image_color_profile_procs (GimpPDB *pdb)
"gimp-image-convert-color-profile-from-file");
gimp_procedure_set_static_help (procedure,
"Convert the image's layers to a color profile",
"This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to an ICC profile specified by 'uri'. Only RGB and grayscale color profiles are accepted, according to the image's type.",
"This procedure converts from the image's color profile (or the default RGB or grayscale profile if none is set) to an ICC profile specified by 'file'. Only RGB and grayscale color profiles are accepted, according to the image's type.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
@ -529,12 +522,11 @@ register_image_color_profile_procs (GimpPDB *pdb)
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("uri",
"uri",
"The URI of the file containing the new color profile",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
g_param_spec_object ("file",
"file",
"The file containing the new color profile",
G_TYPE_FILE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("intent",
"intent",

View File

@ -178,7 +178,7 @@ _gimp_image_set_color_profile (GimpImage *image,
/**
* gimp_image_set_color_profile_from_file:
* @image: The image.
* @uri: The URI of the file containing the new color profile.
* @file: The file containing the new color profile.
*
* Sets the image's color profile from an ICC file
*
@ -194,8 +194,8 @@ _gimp_image_set_color_profile (GimpImage *image,
* Since: 2.10
**/
gboolean
gimp_image_set_color_profile_from_file (GimpImage *image,
const gchar *uri)
gimp_image_set_color_profile_from_file (GimpImage *image,
GFile *file)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -203,7 +203,7 @@ gimp_image_set_color_profile_from_file (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_STRING, uri,
G_TYPE_FILE, file,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
@ -272,7 +272,7 @@ _gimp_image_convert_color_profile (GimpImage *image,
/**
* gimp_image_convert_color_profile_from_file:
* @image: The image.
* @uri: The URI of the file containing the new color profile.
* @file: The file containing the new color profile.
* @intent: Rendering intent.
* @bpc: Black point compensation.
*
@ -280,7 +280,7 @@ _gimp_image_convert_color_profile (GimpImage *image,
*
* This procedure converts from the image's color profile (or the
* default RGB or grayscale profile if none is set) to an ICC profile
* specified by 'uri'. Only RGB and grayscale color profiles are
* specified by 'file'. Only RGB and grayscale color profiles are
* accepted, according to the image's type.
*
* Returns: TRUE on success.
@ -289,7 +289,7 @@ _gimp_image_convert_color_profile (GimpImage *image,
**/
gboolean
gimp_image_convert_color_profile_from_file (GimpImage *image,
const gchar *uri,
GFile *file,
GimpColorRenderingIntent intent,
gboolean bpc)
{
@ -299,7 +299,7 @@ gimp_image_convert_color_profile_from_file (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_STRING, uri,
G_TYPE_FILE, file,
GIMP_TYPE_COLOR_RENDERING_INTENT, intent,
G_TYPE_BOOLEAN, bpc,
G_TYPE_NONE);

View File

@ -40,14 +40,14 @@ G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (GimpImage
gint num_bytes,
const guint8 *color_profile);
gboolean gimp_image_set_color_profile_from_file (GimpImage *image,
const gchar *uri);
GFile *file);
G_GNUC_INTERNAL gboolean _gimp_image_convert_color_profile (GimpImage *image,
gint num_bytes,
const guint8 *color_profile,
GimpColorRenderingIntent intent,
gboolean bpc);
gboolean gimp_image_convert_color_profile_from_file (GimpImage *image,
const gchar *uri,
GFile *file,
GimpColorRenderingIntent intent,
gboolean bpc);

View File

@ -181,16 +181,15 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'uri', type => 'string',
desc => 'The URI of the file containing the new color profile' }
{ name => 'file', type => 'file',
desc => 'The file containing the new color profile' }
);
%invoke = (
code => <<'CODE'
{
if (uri)
if (file)
{
GFile *file = g_file_new_for_uri (uri);
GimpColorProfile *profile;
profile = gimp_color_profile_new_from_file (file, error);
@ -203,8 +202,6 @@ HELP
}
else
success = FALSE;
g_object_unref (file);
}
else
{
@ -277,7 +274,7 @@ sub image_convert_color_profile_from_file {
$help = <<'HELP';
This procedure converts from the image's color profile (or the default
RGB or grayscale profile if none is set) to an ICC profile specified by
'uri'. Only RGB and grayscale color profiles are accepted, according to
'file'. Only RGB and grayscale color profiles are accepted, according to
the image's type.
HELP
@ -286,8 +283,8 @@ HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'uri', type => 'string',
desc => 'The URI of the file containing the new color profile' },
{ name => 'file', type => 'file',
desc => 'The file containing the new color profile' },
{ name => 'intent', type => 'enum GimpColorRenderingIntent',
desc => 'Rendering intent' },
{ name => 'bpc', type => 'boolean',
@ -297,9 +294,8 @@ HELP
%invoke = (
code => <<'CODE'
{
if (uri)
if (file)
{
GFile *file = g_file_new_for_uri (uri);
GimpColorProfile *profile;
profile = gimp_color_profile_new_from_file (file, error);
@ -313,8 +309,6 @@ HELP
}
else
success = FALSE;
g_object_unref (file);
}
else
success = FALSE;