mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
18d9161eea
2004-04-15 Michael Natterer <mitch@gimp.org> Get rid of the "current_context" which was in fact just a bunch of global variables. Instead, pass the needed context all the way from the GUI and the PDB to the core. This is a prerequisite for macro recording and generally helps separating the various subsystems from each other. Work in progress... * app/core/gimp.[ch]: removed member "current_context" and gimp_[get|set]_current_context(). * app/core/gimp-edit.[ch] * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-bucket-fill.[ch] * app/core/gimpdrawable-offset.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-crop.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-merge.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage.[ch] * app/core/gimpimagefile.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimplayer.[ch] * app/core/gimpselection.[ch] * app/core/gimptemplate.[ch] * app/file/file-open.[ch] * app/file/file-save.[ch] * app/pdb/procedural_db.[ch] * app/text/gimptext-compat.[ch] * app/text/gimptextlayer-transform.[ch] * app/gui/brush-select.[ch] * app/gui/font-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: added tons of "GimpContext *context" parameters and use the passed context instead of gimp_get_current_context(). * app/app_procs.c * app/batch.c * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/plug-in/plug-in-message.c * app/plug-in/plug-ins.c * app/text/gimptextlayer.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpinktool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors.c * app/gui/convert-dialog.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/offset-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c: pass gimp_get_user_context() or GIMP_CONTEXT(tool_options) or whatever is the right context to the changed core functions. * tools/pdbgen/app.pl: pass "GimpContext *context" to all generated PDB invokers. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/font_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/paint_tools.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palette_select.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: pass the new context parameter to the changed core functions. * app/pdb/*_cmds.c: regenerated.
349 lines
9.1 KiB
Plaintext
349 lines
9.1 KiB
Plaintext
# The GIMP -- an image manipulation program
|
|
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program 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 General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
sub brush_arg () {{
|
|
name => 'name',
|
|
type => 'string',
|
|
desc => 'The brush name'
|
|
}}
|
|
|
|
sub dim_args () {
|
|
my @args;
|
|
foreach (qw(width height)) {
|
|
push @args, { name => $_, type => 'int32', desc => "The brush $_" };
|
|
}
|
|
@args;
|
|
}
|
|
|
|
sub opacity_arg () {{
|
|
name => 'opacity',
|
|
type => '0 <= float <= 100',
|
|
desc => 'The brush opacity: %%desc%%'
|
|
}}
|
|
|
|
sub spacing_arg () {{
|
|
name => 'spacing',
|
|
type => '0 <= int32 <= 1000',
|
|
desc => 'The brush spacing: %%desc%%'
|
|
}}
|
|
|
|
sub paint_mode_arg () {{
|
|
name => 'paint_mode', type => 'enum GimpLayerModeEffects',
|
|
desc => 'The paint mode: { %%desc%% }'
|
|
}}
|
|
|
|
|
|
sub brush_outargs {
|
|
foreach (@outargs) {
|
|
my $alias = ($_->{type} eq 'string') ?
|
|
"GIMP_OBJECT (brush)->$_->{name}" : "brush->$_->{name}";
|
|
$alias = "g_strdup ($alias)" if $_->{type} eq 'string';
|
|
$alias =~ s/brush/brush->mask/ if $_->{name} =~ /width|height/;
|
|
$_->{alias} = $alias;
|
|
$_->{no_declare} = 1;
|
|
}
|
|
}
|
|
|
|
# The defs
|
|
|
|
sub brushes_refresh {
|
|
$blurb = 'Refresh current brushes. This function always succeeds.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure retrieves all brushes currently in the user's brush path
|
|
and updates the brush dialog accordingly.
|
|
HELP
|
|
|
|
$author = $copyright = 'Seth Burgess';
|
|
$date = '1997';
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
gimp_data_factory_data_save (gimp->brush_factory);
|
|
gimp_data_factory_data_init (gimp->brush_factory, FALSE);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub brushes_get_list {
|
|
$blurb = 'Retrieve a complete listing of the available brushes.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure returns a complete listing of available GIMP brushes. Each name
|
|
returned can be used as input to the 'gimp_brushes_set_brush'.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = (
|
|
{ name => 'filter',
|
|
type => 'string', null_ok => 1,
|
|
desc => 'An optional regular expression used to filter the list' }
|
|
);
|
|
|
|
@outargs = (
|
|
{ name => 'brush_list', type => 'stringarray',
|
|
desc => 'The list of brush names',
|
|
array => { name => 'num_brushes',
|
|
desc => 'The number of brushes in the brush list' },
|
|
init => 1 }
|
|
);
|
|
|
|
%invoke = (
|
|
headers => [ qw("core/gimpcontainer-filter.h") ],
|
|
code => 'brush_list = gimp_container_get_filtered_name_array (gimp->brush_factory->container, filter, &num_brushes);'
|
|
);
|
|
}
|
|
|
|
sub brushes_get_brush {
|
|
$blurb = 'Retrieve information about the currently active brush mask.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure retrieves information about the currently active brush mask.
|
|
This includes the brush name, the width and height, and the brush spacing
|
|
paramter. All paint operations and stroke operations use this mask to control
|
|
the application of paint to the image.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@outargs = (
|
|
&brush_arg,
|
|
&dim_args,
|
|
&spacing_arg
|
|
);
|
|
|
|
&brush_outargs;
|
|
|
|
%invoke = (
|
|
vars => [ 'GimpBrush *brush' ],
|
|
code => 'success = (brush = gimp_context_get_brush (context)) != NULL;'
|
|
);
|
|
}
|
|
|
|
sub brushes_set_brush {
|
|
$blurb = 'Set the specified brush as the active brush.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure allows the active brush mask to be set by specifying its name.
|
|
The name is simply a string which corresponds to one of the names of the
|
|
installed brushes. If there is no matching brush found, this procedure will
|
|
return an error. Otherwise, the specified brush becomes active and will be
|
|
used in all subsequent paint operations.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = ( &brush_arg );
|
|
|
|
%invoke = (
|
|
vars => [ 'GimpBrush *brush' ],
|
|
code => <<'CODE'
|
|
{
|
|
brush = (GimpBrush *)
|
|
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
|
|
|
|
if (brush)
|
|
gimp_context_set_brush (context, brush);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub brushes_get_opacity {
|
|
$blurb = 'Get the brush opacity.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure returns the opacity setting for brushes. This value is set
|
|
globally and will remain the same even if the brush mask is changed. The return
|
|
value is a floating point number between 0 and 100.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@outargs = ( &opacity_arg );
|
|
$outargs[0]->{alias} = 'gimp_context_get_opacity (context) * 100.0';
|
|
$outargs[0]->{no_declare} = 1;
|
|
}
|
|
|
|
sub brushes_set_opacity {
|
|
$blurb = 'Set the brush opacity.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure modifies the opacity setting for brushes. This value is set
|
|
globally and will remain the same even if the brush mask is changed. The value
|
|
should be a floating point number between 0 and 100.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = ( &opacity_arg );
|
|
|
|
%invoke = ( code => 'gimp_context_set_opacity (context, opacity / 100.0);' );
|
|
}
|
|
|
|
sub brushes_get_spacing {
|
|
$blurb = 'Get the brush spacing.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure returns the spacing setting for brushes. This value is set per
|
|
brush and will change if a different brush is selected. The return value is an
|
|
integer between 0 and 1000 which represents percentage of the maximum of the
|
|
width and height of the mask.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@outargs = ( &spacing_arg );
|
|
$outargs[0]->{alias} = 'gimp_brush_get_spacing (gimp_context_get_brush (context))';
|
|
$outargs[0]->{no_declare} = 1;
|
|
}
|
|
|
|
sub brushes_set_spacing {
|
|
$blurb = 'Set the brush spacing.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure modifies the spacing setting for the current brush. This value
|
|
is set on a per-brush basis and will change if a different brush mask is
|
|
selected. The value should be a integer between 0 and 1000.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = ( &spacing_arg );
|
|
|
|
%invoke = (
|
|
code => 'gimp_brush_set_spacing (gimp_context_get_brush (context), spacing);'
|
|
);
|
|
}
|
|
|
|
sub brushes_get_paint_mode {
|
|
$blurb = 'Get the brush paint mode.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure returns the paint-mode setting for brushes. This value is set
|
|
globally and will not change if a different brush is selected. The return value
|
|
is an integer which corresponds to the values listed in the argument
|
|
description.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@outargs = ( &paint_mode_arg );
|
|
$outargs[0]->{alias} = 'gimp_context_get_paint_mode (context)';
|
|
$outargs[0]->{no_declare} = 1;
|
|
}
|
|
|
|
sub brushes_set_paint_mode {
|
|
$blurb = 'Set the brush paint mode.';
|
|
|
|
$help = <<'HELP';
|
|
This procedure modifies the paint_mode setting for the current brush. This
|
|
value is set globally and will not change if a different brush mask is
|
|
selected.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
|
|
@inargs = ( &paint_mode_arg );
|
|
|
|
%invoke = ( code => 'gimp_context_set_paint_mode (context, paint_mode);' );
|
|
}
|
|
|
|
sub brushes_get_brush_data {
|
|
$blurb = <<'BLURB';
|
|
Retrieve information about the currently active brush (including data).
|
|
BLURB
|
|
|
|
$help = <<'HELP';
|
|
This procedure retrieves information about the currently active brush. This
|
|
includes the brush name, and the brush extents (width and height). It also
|
|
returns the brush data.
|
|
HELP
|
|
|
|
$author = $copyright = 'Andy Thomas';
|
|
$date = '1998';
|
|
|
|
@inargs = ( &brush_arg );
|
|
$inargs[0]->{desc} = 'The brush name ("" means current active brush)';
|
|
|
|
@outargs = (
|
|
&brush_arg,
|
|
&opacity_arg,
|
|
&spacing_arg,
|
|
&paint_mode_arg,
|
|
&dim_args,
|
|
);
|
|
|
|
&brush_outargs;
|
|
|
|
$outargs[1]->{alias} = '1.0';
|
|
$outargs[3]->{alias} = '0';
|
|
|
|
push @outargs, { name => 'mask_data', type => 'int8array', init => 1,
|
|
desc => 'The brush mask data',
|
|
array => { name => 'length', init => 1,
|
|
desc => 'Length of brush mask data' } };
|
|
|
|
%invoke = (
|
|
headers => [ qw(<string.h>) ],
|
|
vars => [ 'GimpBrush *brush = NULL' ],
|
|
code => <<'CODE'
|
|
{
|
|
if (strlen (name))
|
|
{
|
|
brush = (GimpBrush *)
|
|
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
|
|
}
|
|
else
|
|
{
|
|
brush = gimp_context_get_brush (context);
|
|
}
|
|
|
|
if (brush)
|
|
{
|
|
length = brush->mask->height * brush->mask->width;
|
|
mask_data = g_memdup (temp_buf_data (brush->mask), length);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
@headers = qw("core/gimp.h" "core/gimplist.h" "core/gimpbrush.h"
|
|
"core/gimpcontext.h" "core/gimpdatafactory.h" "base/temp-buf.h");
|
|
|
|
@procs = qw(brushes_refresh brushes_get_list
|
|
brushes_get_brush brushes_set_brush
|
|
brushes_get_opacity brushes_set_opacity
|
|
brushes_get_spacing brushes_set_spacing
|
|
brushes_get_paint_mode brushes_set_paint_mode
|
|
brushes_get_brush_data);
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
$desc = 'Brushes';
|
|
|
|
1;
|