[gimp] pdb, plug-ins: remove two procedures from lcms.c and add PDB compat procs
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, plug-ins: remove two procedures from lcms.c and add PDB compat procs
- Date: Sun, 7 Jun 2015 10:54:32 +0000 (UTC)
commit d1102d2be972443261430d93fe0fd3cc81cd3031
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 7 12:52:37 2015 +0200
pdb, plug-ins: remove two procedures from lcms.c and add PDB compat procs
The lcms plug-in is on its way out: add compat procedures implementing
plug-in-icc-profile-info and plug-in-icc-profile-file-info and remove
that code from lcms.c.
app/pdb/internal-procs.c | 2 +-
app/pdb/plug-in-compat-cmds.c | 189 +++++++++++++++++++++++++++++++++++
plug-ins/common/lcms.c | 176 +-------------------------------
tools/pdbgen/pdb/plug_in_compat.pdb | 100 ++++++++++++++++++
4 files changed, 295 insertions(+), 172 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 3cc35b6..25c8b3a 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 758 procedures registered total */
+/* 760 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index afd5155..a4d26c2 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -1498,6 +1498,106 @@ plug_in_hsv_noise_invoker (GimpProcedure *procedure,
}
static GimpValueArray *
+plug_in_icc_profile_info_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpValueArray *return_vals;
+ GimpImage *image;
+ gchar *profile_name = NULL;
+ gchar *profile_desc = NULL;
+ gchar *profile_info = NULL;
+
+ image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
+
+ if (success)
+ {
+ GimpColorProfile profile;
+
+ profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
+
+ profile_name = gimp_color_profile_get_model (profile);
+ profile_desc = gimp_color_profile_get_description (profile);
+ profile_info = gimp_color_profile_get_summary (profile);
+
+ gimp_color_profile_close (profile);
+
+ }
+
+ return_vals = gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+
+ if (success)
+ {
+ g_value_take_string (gimp_value_array_index (return_vals, 1), profile_name);
+ g_value_take_string (gimp_value_array_index (return_vals, 2), profile_desc);
+ g_value_take_string (gimp_value_array_index (return_vals, 3), profile_info);
+ }
+
+ return return_vals;
+}
+
+static GimpValueArray *
+plug_in_icc_profile_file_info_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpValueArray *return_vals;
+ const gchar *profile;
+ gchar *profile_name = NULL;
+ gchar *profile_desc = NULL;
+ gchar *profile_info = NULL;
+
+ profile = g_value_get_string (gimp_value_array_index (args, 0));
+
+ if (success)
+ {
+ GFile *file = g_file_new_for_path (profile);
+
+ if (file)
+ {
+ GimpColorProfile p;
+
+ p = gimp_color_profile_open_from_file (file, error);
+ g_object_unref (file);
+
+ if (p)
+ {
+ profile_name = gimp_color_profile_get_model (p);
+ profile_desc = gimp_color_profile_get_description (p);
+ profile_info = gimp_color_profile_get_summary (p);
+
+ gimp_color_profile_close (p);
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+ }
+
+ return_vals = gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+
+ if (success)
+ {
+ g_value_take_string (gimp_value_array_index (return_vals, 1), profile_name);
+ g_value_take_string (gimp_value_array_index (return_vals, 2), profile_desc);
+ g_value_take_string (gimp_value_array_index (return_vals, 3), profile_info);
+ }
+
+ return return_vals;
+}
+
+static GimpValueArray *
plug_in_illusion_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -4896,6 +4996,95 @@ register_plug_in_compat_procs (GimpPDB *pdb)
g_object_unref (procedure);
/*
+ * gimp-plug-in-icc-profile-info
+ */
+ procedure = gimp_procedure_new (plug_in_icc_profile_info_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-icc-profile-info");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-icc-profile-info",
+ "Retrieve information about an image's color profile",
+ "This procedure returns information about the RGB color profile
attached to an image. If no RGB color profile is attached, sRGB is assumed.",
+ "Sven Neumann <sven gimp org>",
+ "Sven Neumann",
+ "2015",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_image_id ("image",
+ "image",
+ "Input image",
+ pdb->gimp, FALSE,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-name",
+ "profile name",
+ "Name",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-desc",
+ "profile desc",
+ "Description",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-info",
+ "profile info",
+ "Info",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
+ * gimp-plug-in-icc-profile-file-info
+ */
+ procedure = gimp_procedure_new (plug_in_icc_profile_file_info_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-icc-profile-file-info");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-icc-profile-file-info",
+ "Retrieve information about a color profile",
+ "This procedure returns information about an ICC color profile on
disk.",
+ "Sven Neumann <sven gimp org>",
+ "Sven Neumann",
+ "2015",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_string ("profile",
+ "profile",
+ "Filename of an ICC color profile",
+ TRUE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-name",
+ "profile name",
+ "Name",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-desc",
+ "profile desc",
+ "Description",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_string ("profile-info",
+ "profile info",
+ "Info",
+ FALSE, FALSE, FALSE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
* gimp-plug-in-illusion
*/
procedure = gimp_procedure_new (plug_in_illusion_invoker);
diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c
index 0ec9941..3df03a9 100644
--- a/plug-ins/common/lcms.c
+++ b/plug-ins/common/lcms.c
@@ -39,18 +39,6 @@
#define PLUG_IN_PROC_APPLY "plug-in-icc-profile-apply"
#define PLUG_IN_PROC_APPLY_RGB "plug-in-icc-profile-apply-rgb"
-#define PLUG_IN_PROC_INFO "plug-in-icc-profile-info"
-#define PLUG_IN_PROC_FILE_INFO "plug-in-icc-profile-file-info"
-
-
-enum
-{
- STATUS,
- PROFILE_NAME,
- PROFILE_DESC,
- PROFILE_INFO,
- NUM_RETURN_VALS
-};
enum
{
@@ -58,8 +46,6 @@ enum
PROC_SET_RGB,
PROC_APPLY,
PROC_APPLY_RGB,
- PROC_INFO,
- PROC_FILE_INFO,
NONE
};
@@ -93,16 +79,6 @@ static GimpPDBStatusType lcms_icc_apply (GimpColorConfig *config,
GimpColorRenderingIntent intent,
gboolean bpc,
gboolean *dont_ask);
-static GimpPDBStatusType lcms_icc_info (GimpColorConfig *config,
- gint32 image,
- gchar **name,
- gchar **desc,
- gchar **info);
-static GimpPDBStatusType lcms_icc_file_info (GFile *file,
- gchar **name,
- gchar **desc,
- gchar **info,
- GError **error);
static gboolean lcms_image_set_profile (gint32 image,
GFile *file);
@@ -166,23 +142,13 @@ static const GimpParamDef apply_rgb_args[] =
{ GIMP_PDB_INT32, "intent", "Rendering intent (enum GimpColorRenderingIntent)" },
{ GIMP_PDB_INT32, "bpc", "Black point compensation" }
};
-static const GimpParamDef info_args[] =
-{
- { GIMP_PDB_IMAGE, "image", "Input image" },
-};
-static const GimpParamDef file_info_args[] =
-{
- { GIMP_PDB_STRING, "profile", "Filename of an ICC color profile" }
-};
static const Procedure procedures[] =
{
{ PLUG_IN_PROC_SET, 2 },
{ PLUG_IN_PROC_SET_RGB, 2 },
{ PLUG_IN_PROC_APPLY, 2 },
- { PLUG_IN_PROC_APPLY_RGB, 2 },
- { PLUG_IN_PROC_INFO, 1 },
- { PLUG_IN_PROC_FILE_INFO, 1 }
+ { PLUG_IN_PROC_APPLY_RGB, 2 }
};
const GimpPlugInInfo PLUG_IN_INFO =
@@ -198,13 +164,6 @@ MAIN ()
static void
query (void)
{
- static const GimpParamDef info_return_vals[] =
- {
- { GIMP_PDB_STRING, "profile-name", "Name" },
- { GIMP_PDB_STRING, "profile-desc", "Description" },
- { GIMP_PDB_STRING, "profile-info", "Info" }
- };
-
gimp_install_procedure (PLUG_IN_PROC_SET,
N_("Set a color profile on the image"),
"This procedure sets an ICC color profile on an "
@@ -270,35 +229,6 @@ query (void)
G_N_ELEMENTS (apply_rgb_args), 0,
apply_rgb_args, NULL);
- gimp_install_procedure (PLUG_IN_PROC_INFO,
- "Retrieve information about an image's color profile",
- "This procedure returns information about the RGB "
- "color profile attached to an image. If no RGB "
- "color profile is attached, sRGB is assumed.",
- "Sven Neumann",
- "Sven Neumann",
- "2006, 2007",
- N_("Image Color Profile Information"),
- "*",
- GIMP_PLUGIN,
- G_N_ELEMENTS (info_args),
- G_N_ELEMENTS (info_return_vals),
- info_args, info_return_vals);
-
- gimp_install_procedure (PLUG_IN_PROC_FILE_INFO,
- "Retrieve information about a color profile",
- "This procedure returns information about an ICC "
- "color profile on disk.",
- "Sven Neumann",
- "Sven Neumann",
- "2006, 2007",
- N_("Color Profile Information"),
- "*",
- GIMP_PLUGIN,
- G_N_ELEMENTS (file_info_args),
- G_N_ELEMENTS (info_return_vals),
- file_info_args, info_return_vals);
-
gimp_plugin_menu_register (PLUG_IN_PROC_SET,
"<Image>/Image/Mode/Color Profile");
gimp_plugin_menu_register (PLUG_IN_PROC_APPLY,
@@ -343,17 +273,11 @@ run (const gchar *name,
if (nparams < procedures[proc].min_params)
goto done;
- if (proc != PROC_FILE_INFO)
- {
- config = gimp_get_color_configuration ();
- /* Later code relies on config != NULL if proc != PROC_FILE_INFO */
- g_return_if_fail (config != NULL);
- intent = config->display_intent;
- }
- else
- intent = GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL;
+ config = gimp_get_color_configuration ();
+ g_return_if_fail (config != NULL);
- bpc = (intent == GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
+ intent = config->display_intent;
+ bpc = (intent == GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
switch (proc)
{
@@ -388,14 +312,6 @@ run (const gchar *name,
if (nparams > 3)
bpc = param[3].data.d_int32 ? TRUE : FALSE;
break;
-
- case PROC_INFO:
- image = param[0].data.d_image;
- break;
-
- case PROC_FILE_INFO:
- file = g_file_new_for_path (param[0].data.d_string);
- break;
}
if (run_mode == GIMP_RUN_INTERACTIVE)
@@ -443,42 +359,6 @@ run (const gchar *name,
values[1].data.d_int32 = dont_ask;
}
break;
-
- case PROC_INFO:
- case PROC_FILE_INFO:
- {
- gchar *name = NULL;
- gchar *desc = NULL;
- gchar *info = NULL;
- GError *error = NULL;
-
- if (proc == PROC_INFO)
- status = lcms_icc_info (config, image, &name, &desc, &info);
- else
- status = lcms_icc_file_info (file, &name, &desc, &info, &error);
-
- if (status == GIMP_PDB_SUCCESS)
- {
- *nreturn_vals = NUM_RETURN_VALS;
-
- values[PROFILE_NAME].type = GIMP_PDB_STRING;
- values[PROFILE_NAME].data.d_string = name;
-
- values[PROFILE_DESC].type = GIMP_PDB_STRING;
- values[PROFILE_DESC].data.d_string = desc;
-
- values[PROFILE_INFO].type = GIMP_PDB_STRING;
- values[PROFILE_INFO].data.d_string = info;
- }
- else if (error)
- {
- *nreturn_vals = 2;
-
- values[1].type = GIMP_PDB_STRING;
- values[1].data.d_string = error->message;
- }
- }
- break;
}
done:
@@ -612,52 +492,6 @@ lcms_icc_apply (GimpColorConfig *config,
return status;
}
-static GimpPDBStatusType
-lcms_icc_info (GimpColorConfig *config,
- gint32 image,
- gchar **name,
- gchar **desc,
- gchar **info)
-{
- GimpColorProfile profile;
-
- g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), GIMP_PDB_CALLING_ERROR);
- g_return_val_if_fail (image != -1, GIMP_PDB_CALLING_ERROR);
-
- profile = gimp_image_get_effective_color_profile (image);
-
- if (name) *name = gimp_color_profile_get_model (profile);
- if (desc) *desc = gimp_color_profile_get_description (profile);
- if (info) *info = gimp_color_profile_get_summary (profile);
-
- gimp_color_profile_close (profile);
-
- return GIMP_PDB_SUCCESS;
-}
-
-static GimpPDBStatusType
-lcms_icc_file_info (GFile *file,
- gchar **name,
- gchar **desc,
- gchar **info,
- GError **error)
-{
- cmsHPROFILE profile;
-
- profile = gimp_color_profile_open_from_file (file, error);
-
- if (! profile)
- return GIMP_PDB_EXECUTION_ERROR;
-
- *name = gimp_color_profile_get_model (profile);
- *desc = gimp_color_profile_get_description (profile);
- *info = gimp_color_profile_get_summary (profile);
-
- gimp_color_profile_close (profile);
-
- return GIMP_PDB_SUCCESS;
-}
-
static gboolean
lcms_image_set_profile (gint32 image,
GFile *file)
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 4ba395a..4c92b43 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -1500,6 +1500,104 @@ CODE
);
}
+sub plug_in_icc_profile_info {
+ $blurb = "Retrieve information about an image's color profile";
+
+ $help = <<'HELP';
+This procedure returns information about the RGB color profile
+attached to an image. If no RGB color profile is attached, sRGB is
+assumed.
+HELP
+
+ &neo_pdb_misc;
+ $date = '2015';
+
+ @inargs = (
+ { name => 'image', type => 'image',
+ desc => 'Input image' }
+ );
+
+ @outargs = (
+ { name => 'profile_name', type => 'string',
+ desc => 'Name' },
+ { name => 'profile_desc', type => 'string',
+ desc => 'Description' },
+ { name => 'profile_info', type => 'string',
+ desc => 'Info' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ GimpColorProfile profile;
+
+ profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
+
+ profile_name = gimp_color_profile_get_model (profile);
+ profile_desc = gimp_color_profile_get_description (profile);
+ profile_info = gimp_color_profile_get_summary (profile);
+
+ gimp_color_profile_close (profile);
+
+}
+CODE
+ );
+}
+
+sub plug_in_icc_profile_file_info {
+ $blurb = "Retrieve information about a color profile";
+
+ $help = <<'HELP';
+This procedure returns information about an ICC color profile on disk.
+HELP
+
+ &neo_pdb_misc;
+ $date = '2015';
+
+ @inargs = (
+ { name => 'profile', type => 'string',
+ desc => 'Filename of an ICC color profile', allow_non_utf8 => 1 }
+ );
+
+ @outargs = (
+ { name => 'profile_name', type => 'string',
+ desc => 'Name' },
+ { name => 'profile_desc', type => 'string',
+ desc => 'Description' },
+ { name => 'profile_info', type => 'string',
+ desc => 'Info' }
+ );
+
+ %invoke = (
+ code => <<'CODE'
+{
+ GFile *file = g_file_new_for_path (profile);
+
+ if (file)
+ {
+ GimpColorProfile p;
+
+ p = gimp_color_profile_open_from_file (file, error);
+ g_object_unref (file);
+
+ if (p)
+ {
+ profile_name = gimp_color_profile_get_model (p);
+ profile_desc = gimp_color_profile_get_description (p);
+ profile_info = gimp_color_profile_get_summary (p);
+
+ gimp_color_profile_close (p);
+ }
+ else
+ success = FALSE;
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
sub plug_in_illusion {
$blurb = 'Superimpose many altered copies of the image';
@@ -3942,6 +4040,8 @@ CODE
plug_in_gauss_rle2
plug_in_glasstile
plug_in_hsv_noise
+ plug_in_icc_profile_info
+ plug_in_icc_profile_file_info
plug_in_illusion
plug_in_laplace
plug_in_lens_distortion
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]