Commit f363ffff authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added accessors for the context's brush, pattern, gradient, palette and

2004-09-23  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/context.pdb: added accessors for the context's
	brush, pattern, gradient, palette and brush. Deprecation of old
	functions will follow. Fixes gimp-context-set-background wrapper.
	Cleanup.

	* tools/pdbgen/pdb/patterns.pdb
	* libgimp/gimpbrushes.h: minor fixes.

	* app/pdb/context_cmds.c
	* app/pdb/internal_procs.c
	* app/pdb/patterns_cmds.c
	* libgimp/gimpcontext_pdb.[ch]: regenerated.
parent 0e91274e
2004-09-23 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/context.pdb: added accessors for the context's
brush, pattern, gradient, palette and brush. Deprecation of old
functions will follow. Fixes gimp-context-set-background wrapper.
Cleanup.
* tools/pdbgen/pdb/patterns.pdb
* libgimp/gimpbrushes.h: minor fixes.
* app/pdb/context_cmds.c
* app/pdb/internal_procs.c
* app/pdb/patterns_cmds.c
* libgimp/gimpcontext_pdb.[ch]: regenerated.
2004-09-23 Sven Neumann <sven@gimp.org>
* plug-ins/common/bumpmap.c (bumpmap_dialog): cosmetics.
......
......@@ -29,7 +29,9 @@
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "plug-in/plug-in-context.h"
#include "plug-in/plug-in.h"
......@@ -45,6 +47,16 @@ static ProcRecord context_get_opacity_proc;
static ProcRecord context_set_opacity_proc;
static ProcRecord context_get_paint_mode_proc;
static ProcRecord context_set_paint_mode_proc;
static ProcRecord context_get_brush_proc;
static ProcRecord context_set_brush_proc;
static ProcRecord context_get_pattern_proc;
static ProcRecord context_set_pattern_proc;
static ProcRecord context_get_gradient_proc;
static ProcRecord context_set_gradient_proc;
static ProcRecord context_get_palette_proc;
static ProcRecord context_set_palette_proc;
static ProcRecord context_get_font_proc;
static ProcRecord context_set_font_proc;
void
register_context_procs (Gimp *gimp)
......@@ -61,6 +73,16 @@ register_context_procs (Gimp *gimp)
procedural_db_register (gimp, &context_set_opacity_proc);
procedural_db_register (gimp, &context_get_paint_mode_proc);
procedural_db_register (gimp, &context_set_paint_mode_proc);
procedural_db_register (gimp, &context_get_brush_proc);
procedural_db_register (gimp, &context_set_brush_proc);
procedural_db_register (gimp, &context_get_pattern_proc);
procedural_db_register (gimp, &context_set_pattern_proc);
procedural_db_register (gimp, &context_get_gradient_proc);
procedural_db_register (gimp, &context_set_gradient_proc);
procedural_db_register (gimp, &context_get_palette_proc);
procedural_db_register (gimp, &context_set_palette_proc);
procedural_db_register (gimp, &context_get_font_proc);
procedural_db_register (gimp, &context_set_font_proc);
}
static Argument *
......@@ -157,7 +179,7 @@ static ProcRecord context_get_foreground_proc =
{
"gimp_context_get_foreground",
"Get the current GIMP foreground color.",
"This procedure retrieves the current GIMP foreground color. The foreground color is used in a variety of tools such as paint tools, blending, and bucket fill.",
"This procedure returns the current GIMP foreground color. The foreground color is used in a variety of tools such as paint tools, blending, and bucket fill.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
......@@ -231,8 +253,8 @@ static ProcArg context_get_background_outargs[] =
{
{
GIMP_PDB_COLOR,
"foreground",
"The foreground color"
"background",
"The background color"
}
};
......@@ -240,7 +262,7 @@ static ProcRecord context_get_background_proc =
{
"gimp_context_get_background",
"Get the current GIMP background color.",
"This procedure retrieves the current GIMP background color. The background color is used in a variety of tools such as blending, erasing (with non-alpha images), and image filling.",
"This procedure returns the current GIMP background color. The background color is used in a variety of tools such as blending, erasing (with non-alpha images), and image filling.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
......@@ -263,7 +285,7 @@ context_set_background_invoker (Gimp *gimp,
color = args[0].value.pdb_color;
gimp_rgb_set_alpha (&color, 1.0);
gimp_context_set_foreground (context, &color);
gimp_context_set_background (context, &color);
return procedural_db_return_args (&context_set_background_proc, TRUE);
}
......@@ -510,3 +532,493 @@ static ProcRecord context_set_paint_mode_proc =
NULL,
{ { context_set_paint_mode_invoker } }
};
static Argument *
context_get_brush_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpBrush *brush;
success = (brush = gimp_context_get_brush (context)) != NULL;
return_args = procedural_db_return_args (&context_get_brush_proc, success);
if (success)
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush)));
return return_args;
}
static ProcArg context_get_brush_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the active brush"
}
};
static ProcRecord context_get_brush_proc =
{
"gimp_context_get_brush",
"Retrieve the currently active brush.",
"This procedure returns the nme of the currently active brush. All paint operations and stroke operations use this brush to control the application of paint to the image.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
0,
NULL,
1,
context_get_brush_outargs,
{ { context_get_brush_invoker } }
};
static Argument *
context_set_brush_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
GimpBrush *brush;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
if (brush)
gimp_context_set_brush (context, brush);
else
success = FALSE;
}
return procedural_db_return_args (&context_set_brush_proc, success);
}
static ProcArg context_set_brush_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name o the brush"
}
};
static ProcRecord context_set_brush_proc =
{
"gimp_context_set_brush",
"Set the specified brush as the active brush.",
"This procedure allows the active brush 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.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
1,
context_set_brush_inargs,
0,
NULL,
{ { context_set_brush_invoker } }
};
static Argument *
context_get_pattern_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpPattern *pattern;
success = (pattern = gimp_context_get_pattern (context)) != NULL;
return_args = procedural_db_return_args (&context_get_pattern_proc, success);
if (success)
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (pattern)));
return return_args;
}
static ProcArg context_get_pattern_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the active pattern"
}
};
static ProcRecord context_get_pattern_proc =
{
"gimp_context_get_pattern",
"Retrieve the currently active pattern.",
"This procedure returns name of the the currently active pattern. All clone and bucket-fill operations with patterns will use this pattern to control the application of paint to the image.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
0,
NULL,
1,
context_get_pattern_outargs,
{ { context_get_pattern_invoker } }
};
static Argument *
context_set_pattern_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
GimpPattern *pattern;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
if (pattern)
gimp_context_set_pattern (context, pattern);
else
success = FALSE;
}
return procedural_db_return_args (&context_set_pattern_proc, success);
}
static ProcArg context_set_pattern_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the pattern"
}
};
static ProcRecord context_set_pattern_proc =
{
"gimp_context_set_pattern",
"Set the specified pattern as the active pattern.",
"This procedure allows the active pattern to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed patterns. If there is no matching pattern found, this procedure will return an error. Otherwise, the specified pattern becomes active and will be used in all subsequent paint operations.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
1,
context_set_pattern_inargs,
0,
NULL,
{ { context_set_pattern_invoker } }
};
static Argument *
context_get_gradient_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpGradient *gradient;
success = (gradient = gimp_context_get_gradient (context)) != NULL;
return_args = procedural_db_return_args (&context_get_gradient_proc, success);
if (success)
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (gradient)));
return return_args;
}
static ProcArg context_get_gradient_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the active gradient"
}
};
static ProcRecord context_get_gradient_proc =
{
"gimp_context_get_gradient",
"Retrieve the currently active gradient.",
"This procedure returns the name of the currently active gradient.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
0,
NULL,
1,
context_get_gradient_outargs,
{ { context_get_gradient_invoker } }
};
static Argument *
context_set_gradient_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
GimpGradient *gradient;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
if (gradient)
gimp_context_set_gradient (context, gradient);
else
success = FALSE;
}
return procedural_db_return_args (&context_set_gradient_proc, success);
}
static ProcArg context_set_gradient_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient"
}
};
static ProcRecord context_set_gradient_proc =
{
"gimp_context_set_gradient",
"Sets the specified gradient as the active gradient.",
"This procedure lets you set the specified gradient as the active or \"current\" one. The name is simply a string which corresponds to one of the loaded gradients. If no matching gradient is found, this procedure will return an error. Otherwise, the specified gradient will become active and will be used for subsequent custom gradient operations.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
1,
context_set_gradient_inargs,
0,
NULL,
{ { context_set_gradient_invoker } }
};
static Argument *
context_get_palette_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpPalette *palette;
success = (palette = gimp_context_get_palette (context)) != NULL;
return_args = procedural_db_return_args (&context_get_palette_proc, success);
if (success)
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
return return_args;
}
static ProcArg context_get_palette_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the active palette"
}
};
static ProcRecord context_get_palette_proc =
{
"gimp_context_get_palette",
"Retrieve the currently active palette.",
"This procedure returns the name of the the currently active palette.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
0,
NULL,
1,
context_get_palette_outargs,
{ { context_get_palette_invoker } }
};
static Argument *
context_set_palette_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
GimpPalette *palette;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
if (palette)
gimp_context_set_palette (context, palette);
else
success = FALSE;
}
return procedural_db_return_args (&context_set_palette_proc, success);
}
static ProcArg context_set_palette_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the palette"
}
};
static ProcRecord context_set_palette_proc =
{
"gimp_context_set_palette",
"Set the specified palette as the active palette.",
"This procedure allows the active palette to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed palettes. If no matching palette is found, this procedure will return an error. Otherwise, the specified palette becomes active and will be used in all subsequent palette operations.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
1,
context_set_palette_inargs,
0,
NULL,
{ { context_set_palette_invoker } }
};
static Argument *
context_get_font_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpFont *font;
success = (font = gimp_context_get_font (context)) != NULL;
return_args = procedural_db_return_args (&context_get_font_proc, success);
if (success)
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (font)));
return return_args;
}
static ProcArg context_get_font_outargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the active font"
}
};
static ProcRecord context_get_font_proc =
{
"gimp_context_get_font",
"Retrieve the currently active font.",
"This procedure returns the name of the currently active font.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
0,
NULL,
1,
context_get_font_outargs,
{ { context_get_font_invoker } }
};
static Argument *
context_set_font_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
GimpFont *font;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
if (success)
{
font = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, name);
if (font)
gimp_context_set_font (context, font);
else
success = FALSE;
}
return procedural_db_return_args (&context_set_font_proc, success);
}
static ProcArg context_set_font_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the font"
}
};
static ProcRecord context_set_font_proc =
{
"gimp_context_set_font",
"Set the specified font as the active font.",
"This procedure allows the active font to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed fonts. If no matching font is found, this procedure will return an error. Otherwise, the specified font becomes active and will be used in all subsequent font operations.",
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
"Michael Natterer & Sven Neumann",
"2004",
GIMP_INTERNAL,
1,
context_set_font_inargs,
0,
NULL,
{ { context_set_font_invoker } }
};
......@@ -70,7 +70,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 383 procedures registered total */
/* 393 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -85,112 +85,112 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Brushes"), 0.008);
register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.026);
(* status_callback) (NULL, _("Channel"), 0.025);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.05);
(* status_callback) (NULL, _("Color"), 0.048);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.084);
(* status_callback) (NULL, _("Context"), 0.081);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.115);
(* status_callback) (NULL, _("Convert"), 0.137);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.123);
(* status_callback) (NULL, _("Display procedures"), 0.145);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.133);
(* status_callback) (NULL, _("Drawable procedures"), 0.155);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.217);
(* status_callback) (NULL, _("Edit procedures"), 0.237);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.238);
(* status_callback) (NULL, _("File Operations"), 0.257);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.261);
(* status_callback) (NULL, _("Floating selections"), 0.28);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.277);
(* status_callback) (NULL, _("Font UI"), 0.295);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.285);
(* status_callback) (NULL, _("Fonts"), 0.303);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.29);
(* status_callback) (NULL, _("Gimprc procedures"), 0.308);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.305);
(* status_callback) (NULL, _("Gradient"), 0.323);
register_gradient_edit_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.366);
(* status_callback) (NULL, _("Gradient UI"), 0.382);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.373);
(* status_callback) (NULL, _("Gradients"), 0.389);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.402);
(* status_callback) (NULL, _("Guide procedures"), 0.417);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.418);
(* status_callback) (NULL, _("Help procedures"), 0.433);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.42);
(* status_callback) (NULL, _("Image"), 0.435);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.582);
(* status_callback) (NULL, _("Layer"), 0.593);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.65);
(* status_callback) (NULL, _("Message procedures"), 0.659);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.658);
(* status_callback) (NULL, _("Miscellaneous"), 0.667);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.663);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.672);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.702);
(* status_callback) (NULL, _("Palette UI"), 0.71);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.71);
(* status_callback) (NULL, _("Palettes"), 0.718);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.723);
(* status_callback) (NULL, _("Parasite procedures"), 0.73);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.755);
(* status_callback) (NULL, _("Paths"), 0.761);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.794);
(* status_callback) (NULL, _("Pattern UI"), 0.799);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.802);
(* status_callback) (NULL, _("Patterns"), 0.807);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.815);
(* status_callback) (NULL, _("Plug-in"), 0.819);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.828);
(* status_callback) (NULL, _("Procedural database"), 0.832);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.851);
(* status_callback) (NULL, _("Progress"), 0.855);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.864);
(* status_callback) (NULL, _("Image mask"), 0.868);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.911);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.913);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.924);