removed gradients_get_gradient_data() here...

2001-10-26  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/gradient_select.pdb: removed
	gradients_get_gradient_data() here...

	* tools/pdbgen/pdb/gradients.pdb: ...and added it here.

	* app/pdb/gradient_select_cmds.c
	* app/pdb/gradients_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpgradients_pdb.[ch]
	* libgimp/gimpgradientselect_pdb.[ch]: regenerated.

	* app/core/gimpgradient.h: added GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE
	here...

	* app/gui/gradient-select.h: ...removed it here.

	* libgimp/Makefile.am
	* libgimp/gimp.h
	* libgimp/gimpgradientselect.[ch]: removed. We don't wrap
	_gradients_get_gradient_data() with gradients_get_gradient_data()
	any more but call the PDB wrapper directly.

	API CHANGE: Arguments 2 and 3 are swapped now!

	* plug-ins/FractalExplorer/Dialogs.c: changed accordingly.
This commit is contained in:
Michael Natterer 2001-10-25 21:59:52 +00:00 committed by Michael Natterer
parent 057ce3f474
commit 552e26715f
16 changed files with 310 additions and 353 deletions

View File

@ -1,3 +1,31 @@
2001-10-26 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/gradient_select.pdb: removed
gradients_get_gradient_data() here...
* tools/pdbgen/pdb/gradients.pdb: ...and added it here.
* app/pdb/gradient_select_cmds.c
* app/pdb/gradients_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpgradients_pdb.[ch]
* libgimp/gimpgradientselect_pdb.[ch]: regenerated.
* app/core/gimpgradient.h: added GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE
here...
* app/gui/gradient-select.h: ...removed it here.
* libgimp/Makefile.am
* libgimp/gimp.h
* libgimp/gimpgradientselect.[ch]: removed. We don't wrap
_gradients_get_gradient_data() with gradients_get_gradient_data()
any more but call the PDB wrapper directly.
API CHANGE: Arguments 2 and 3 are swapped now!
* plug-ins/FractalExplorer/Dialogs.c: changed accordingly.
2001-10-25 Michael Natterer <mitch@gimp.org>
* configure.in: generate app/file/Makefile

View File

@ -25,6 +25,8 @@
#define GIMP_GRADIENT_FILE_EXTENSION ".ggr"
#define GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE 40
typedef enum
{

View File

@ -20,9 +20,6 @@
#define __GRADIENT_SELECT_H__
#define GRADIENT_SAMPLE_SIZE 40
typedef struct _GradientSelect GradientSelect;
struct _GradientSelect

View File

@ -40,7 +40,6 @@
static ProcRecord gradients_popup_proc;
static ProcRecord gradients_close_popup_proc;
static ProcRecord gradients_set_popup_proc;
static ProcRecord gradients_get_gradient_data_proc;
void
register_gradient_select_procs (Gimp *gimp)
@ -48,7 +47,6 @@ register_gradient_select_procs (Gimp *gimp)
procedural_db_register (gimp, &gradients_popup_proc);
procedural_db_register (gimp, &gradients_close_popup_proc);
procedural_db_register (gimp, &gradients_set_popup_proc);
procedural_db_register (gimp, &gradients_get_gradient_data_proc);
}
static Argument *
@ -75,7 +73,7 @@ gradients_popup_invoker (Gimp *gimp,
sample_size = args[3].value.pdb_int;
if (sample_size <= 0 || sample_size > 10000)
sample_size = GRADIENT_SAMPLE_SIZE;
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
if (success)
{
@ -264,126 +262,3 @@ static ProcRecord gradients_set_popup_proc =
NULL,
{ { gradients_set_popup_invoker } }
};
static Argument *
gradients_get_gradient_data_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 sample_size;
gdouble *values = NULL;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
sample_size = args[1].value.pdb_int;
if (sample_size <= 0 || sample_size > 10000)
sample_size = GRADIENT_SAMPLE_SIZE;
if (success)
{
if (strlen (name))
{
success = FALSE;
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
if (gradient)
success = TRUE;
}
else
success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL;
if (success)
{
gdouble *pv;
gdouble pos, delta;
GimpRGB color;
gint i;
i = sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
pv = values = g_new (gdouble, i * 4);
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
}
}
return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success);
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (gradient)->name);
return_args[2].value.pdb_int = sample_size * 4;
return_args[3].value.pdb_pointer = values;
}
return return_args;
}
static ProcArg gradients_get_gradient_data_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The gradient name (\"\" means current active gradient)"
},
{
GIMP_PDB_INT32,
"sample_size",
"Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)"
}
};
static ProcArg gradients_get_gradient_data_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The gradient name"
},
{
GIMP_PDB_INT32,
"width",
"The gradient sample width (r,g,b,a)"
},
{
GIMP_PDB_FLOATARRAY,
"grad_data",
"The gradient sample data"
}
};
static ProcRecord gradients_get_gradient_data_proc =
{
"gimp_gradients_get_gradient_data",
"Retrieve information about the specified gradient (including data).",
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
"Andy Thomas",
"Andy Thomas",
"1998",
GIMP_INTERNAL,
2,
gradients_get_gradient_data_inargs,
3,
gradients_get_gradient_data_outargs,
{ { gradients_get_gradient_data_invoker } }
};

View File

@ -40,6 +40,7 @@ static ProcRecord gradients_get_active_proc;
static ProcRecord gradients_set_active_proc;
static ProcRecord gradients_sample_uniform_proc;
static ProcRecord gradients_sample_custom_proc;
static ProcRecord gradients_get_gradient_data_proc;
void
register_gradients_procs (Gimp *gimp)
@ -49,6 +50,7 @@ register_gradients_procs (Gimp *gimp)
procedural_db_register (gimp, &gradients_set_active_proc);
procedural_db_register (gimp, &gradients_sample_uniform_proc);
procedural_db_register (gimp, &gradients_sample_custom_proc);
procedural_db_register (gimp, &gradients_get_gradient_data_proc);
}
static Argument *
@ -407,3 +409,126 @@ static ProcRecord gradients_sample_custom_proc =
gradients_sample_custom_outargs,
{ { gradients_sample_custom_invoker } }
};
static Argument *
gradients_get_gradient_data_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 sample_size;
gdouble *values = NULL;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
sample_size = args[1].value.pdb_int;
if (sample_size <= 0 || sample_size > 10000)
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
if (success)
{
if (strlen (name))
{
success = FALSE;
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
if (gradient)
success = TRUE;
}
else
success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL;
if (success)
{
gdouble *pv;
gdouble pos, delta;
GimpRGB color;
gint i;
i = sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
pv = values = g_new (gdouble, i * 4);
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
}
}
return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success);
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (gradient)->name);
return_args[2].value.pdb_int = sample_size * 4;
return_args[3].value.pdb_pointer = values;
}
return return_args;
}
static ProcArg gradients_get_gradient_data_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The gradient name (\"\" means current active gradient)"
},
{
GIMP_PDB_INT32,
"sample_size",
"Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)"
}
};
static ProcArg gradients_get_gradient_data_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The gradient name"
},
{
GIMP_PDB_INT32,
"width",
"The gradient sample width (r,g,b,a)"
},
{
GIMP_PDB_FLOATARRAY,
"grad_data",
"The gradient sample data"
}
};
static ProcRecord gradients_get_gradient_data_proc =
{
"gimp_gradients_get_gradient_data",
"Retrieve information about the specified gradient (including data).",
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
"Federico Mena Quintero",
"Federico Mena Quintero",
"1997",
GIMP_INTERNAL,
2,
gradients_get_gradient_data_inargs,
3,
gradients_get_gradient_data_outargs,
{ { gradients_get_gradient_data_invoker } }
};

View File

@ -108,7 +108,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Gradients"), 0.291);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.307);
(* status_callback) (NULL, _("Gradient UI"), 0.31);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.319);

View File

@ -104,8 +104,6 @@ libgimp_1_3_la_SOURCES = @STRIP_BEGIN@ \
gimpchannel.h \
gimpdrawable.c \
gimpdrawable.h \
gimpgradientselect.c \
gimpgradientselect.h \
gimphelp.c \
gimpimage.c \
gimpimage.h \
@ -151,7 +149,6 @@ gimpinclude_HEADERS = @STRIP_BEGIN@ \
gimpchannel.h \
gimpdrawable.h \
gimpenums.h \
gimpgradientselect.h \
gimpimage.h \
gimplayer.h \
gimpmodule.h \

View File

@ -33,7 +33,6 @@
#include <libgimp/gimpchannel.h>
#include <libgimp/gimpdrawable.h>
#include <libgimp/gimpgradientselect.h>
#include <libgimp/gimpimage.h>
#include <libgimp/gimplayer.h>
#include <libgimp/gimppixelrgn.h>

View File

@ -212,3 +212,49 @@ gimp_gradients_sample_custom (gint num_samples,
return color_samples;
}
/**
* gimp_gradients_get_gradient_data:
* @name: The gradient name (\"\" means current active gradient).
* @sample_size: Size of the sample to return when the gradient is changed.
* @width: The gradient sample width (r,g,b,a).
* @grad_data: The gradient sample data.
*
* Retrieve information about the specified gradient (including data).
*
* This procedure retrieves information about the gradient. This
* includes the gradient name, and the sample data for the gradient.
*
* Returns: The gradient name.
*/
gchar *
gimp_gradients_get_gradient_data (gchar *name,
gint sample_size,
gint *width,
gdouble **grad_data)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *ret_name = NULL;
return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, sample_size,
GIMP_PDB_END);
*width = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
ret_name = g_strdup (return_vals[1].data.d_string);
*width = return_vals[2].data.d_int32;
*grad_data = g_new (gdouble, *width);
memcpy (*grad_data, return_vals[3].data.d_floatarray,
*width * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return ret_name;
}

View File

@ -31,12 +31,16 @@ extern "C" {
/* For information look into the C source or the html documentation */
gchar** gimp_gradients_get_list (gint *num_gradients);
gchar* gimp_gradients_get_active (void);
gboolean gimp_gradients_set_active (gchar *name);
gdouble* gimp_gradients_sample_uniform (gint num_samples);
gdouble* gimp_gradients_sample_custom (gint num_samples,
gdouble *positions);
gchar** gimp_gradients_get_list (gint *num_gradients);
gchar* gimp_gradients_get_active (void);
gboolean gimp_gradients_set_active (gchar *name);
gdouble* gimp_gradients_sample_uniform (gint num_samples);
gdouble* gimp_gradients_sample_custom (gint num_samples,
gdouble *positions);
gchar* gimp_gradients_get_gradient_data (gchar *name,
gint sample_size,
gint *width,
gdouble **grad_data);
#ifdef __cplusplus

View File

@ -1,31 +0,0 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpgradientselect.c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gimp.h"
gchar *
gimp_gradients_get_gradient_data (gchar *name,
gint *width,
gint sample_size,
gdouble **grad_data)
{
return _gimp_gradients_get_gradient_data (name, sample_size, width, grad_data);
}

View File

@ -1,42 +0,0 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpgradientselect.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_GRADIENT_SELECT_H__
#define __GIMP_GRADIENT_SELECT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For information look into the C source or the html documentation */
gchar * gimp_gradients_get_gradient_data (gchar *name,
gint *width,
gint sample_size,
gdouble **grad_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_GRADIENT_SELECT_H__ */

View File

@ -21,8 +21,6 @@
/* NOTE: This file is autogenerated by pdbgen.pl */
#include <string.h>
#include "gimp.h"
/**
@ -123,49 +121,3 @@ gimp_gradients_set_popup (gchar *gradients_callback,
return success;
}
/**
* _gimp_gradients_get_gradient_data:
* @name: The gradient name (\"\" means current active gradient).
* @sample_size: Size of the sample to return when the gradient is changed.
* @width: The gradient sample width (r,g,b,a).
* @grad_data: The gradient sample data.
*
* Retrieve information about the specified gradient (including data).
*
* This procedure retrieves information about the gradient. This
* includes the gradient name, and the sample data for the gradient.
*
* Returns: The gradient name.
*/
gchar *
_gimp_gradients_get_gradient_data (gchar *name,
gint sample_size,
gint *width,
gdouble **grad_data)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *ret_name = NULL;
return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, sample_size,
GIMP_PDB_END);
*width = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
ret_name = g_strdup (return_vals[1].data.d_string);
*width = return_vals[2].data.d_int32;
*grad_data = g_new (gdouble, *width);
memcpy (*grad_data, return_vals[3].data.d_floatarray,
*width * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return ret_name;
}

View File

@ -31,17 +31,13 @@ extern "C" {
/* For information look into the C source or the html documentation */
gboolean gimp_gradients_popup (gchar *gradients_callback,
gchar *popup_title,
gchar *initial_gradient,
gint sample_size);
gboolean gimp_gradients_close_popup (gchar *gradients_callback);
gboolean gimp_gradients_set_popup (gchar *gradients_callback,
gchar *gradient_name);
gchar* _gimp_gradients_get_gradient_data (gchar *name,
gint sample_size,
gint *width,
gdouble **grad_data);
gboolean gimp_gradients_popup (gchar *gradients_callback,
gchar *popup_title,
gchar *initial_gradient,
gint sample_size);
gboolean gimp_gradients_close_popup (gchar *gradients_callback);
gboolean gimp_gradients_set_popup (gchar *gradients_callback,
gchar *gradient_name);
#ifdef __cplusplus

View File

@ -27,7 +27,7 @@ sub sample_size_arg {{
type => '0 < int32 <= 10000',
desc => 'Size of the sample to return when the gradient is changed
(%%desc%%)',
on_fail => 'sample_size = GRADIENT_SAMPLE_SIZE;',
on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;',
no_success => 1
}}
@ -144,90 +144,12 @@ CODE
);
}
sub gradients_get_gradient_data {
$blurb = <<'BLURB';
Retrieve information about the specified gradient (including data).
BLURB
$help = <<'HELP';
This procedure retrieves information about the gradient. This includes the
gradient name, and the sample data for the gradient.
HELP
&pdb_misc;
@inargs = (
{ name => 'name', type => 'string',
desc => 'The gradient name ("" means current active gradient)' },
&sample_size_arg
);
@outargs = (
{ name => 'name', type => 'string',
desc => 'The gradient name',
alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 },
{ name => 'grad_data', type => 'floatarray', alias => 'values',
desc => 'The gradient sample data', init => 1, wrap => 1,
array => { name => 'width',
desc => 'The gradient sample width (r,g,b,a)',
alias => 'sample_size * 4', no_declare => 1 } }
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<'CODE'
{
if (strlen (name))
{
success = FALSE;
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
if (gradient)
success = TRUE;
}
else
success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL;
if (success)
{
gdouble *pv;
gdouble pos, delta;
GimpRGB color;
gint i;
i = sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
pv = values = g_new (gdouble, i * 4);
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
}
}
CODE
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"core/gimpgradient.h"
"gui/gui-types.h" "gui/gradient-select.h");
@procs = qw(gradients_popup gradients_close_popup gradients_set_popup
gradients_get_gradient_data);
@procs = qw(gradients_popup gradients_close_popup gradients_set_popup);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gradient UI';

View File

@ -238,12 +238,99 @@ CODE
);
}
sub sample_size_arg {{
name => 'sample_size',
type => '0 < int32 <= 10000',
desc => 'Size of the sample to return when the gradient is changed
(%%desc%%)',
on_fail => 'sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;',
no_success => 1
}}
sub gradients_get_gradient_data {
$blurb = <<'BLURB';
Retrieve information about the specified gradient (including data).
BLURB
$help = <<'HELP';
This procedure retrieves information about the gradient. This includes the
gradient name, and the sample data for the gradient.
HELP
&pdb_misc;
@inargs = (
{ name => 'name', type => 'string',
desc => 'The gradient name ("" means current active gradient)' },
&sample_size_arg
);
@outargs = (
{ name => 'name', type => 'string',
desc => 'The gradient name',
alias => 'g_strdup (GIMP_OBJECT (gradient)->name)', no_declare => 1 },
{ name => 'grad_data', type => 'floatarray', alias => 'values',
desc => 'The gradient sample data', init => 1,
array => { name => 'width',
desc => 'The gradient sample width (r,g,b,a)',
alias => 'sample_size * 4', no_declare => 1 } }
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<'CODE'
{
if (strlen (name))
{
success = FALSE;
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
if (gradient)
success = TRUE;
}
else
success = (gradient = gimp_context_get_gradient (gimp_get_current_context (gimp))) != NULL;
if (success)
{
gdouble *pv;
gdouble pos, delta;
GimpRGB color;
gint i;
i = sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
pv = values = g_new (gdouble, i * 4);
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, &color);
*pv++ = color.r;
*pv++ = color.g;
*pv++ = color.b;
*pv++ = color.a;
pos += delta;
}
}
}
CODE
);
}
@headers = qw("core/gimp.h" "core/gimpcontext.h"
"core/gimpcontainer.h" "core/gimpdatafactory.h"
"core/gimplist.h" "core/gimpgradient.h");
@procs = qw(gradients_get_list gradients_get_active gradients_set_active
gradients_sample_uniform gradients_sample_custom);
gradients_sample_uniform gradients_sample_custom
gradients_get_gradient_data);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gradients';