gimp/libgimp/gimppalette_pdb.c

652 lines
18 KiB
C
Raw Normal View History

2004-09-29 06:01:21 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimppalette_pdb.c
*
* This library is free software: you can redistribute it and/or
2004-09-29 06:01:21 +08:00
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
2004-09-29 06:01:21 +08:00
*
* 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, see
* <https://www.gnu.org/licenses/>.
2004-09-29 06:01:21 +08:00
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
2004-09-29 06:01:21 +08:00
#include "config.h"
#include "gimp.h"
/**
* SECTION: gimppalette
* @title: gimppalette
* @short_description: Functions operating on a single palette.
*
* Functions operating on a single palette.
**/
2004-09-29 06:01:21 +08:00
/**
* gimp_palette_new:
* @name: The requested name of the new palette.
*
* Creates a new palette
*
* This procedure creates a new, uninitialized palette
*
* Returns: (transfer full): The actual new palette name.
* The returned value must be freed with g_free().
2004-09-29 06:01:21 +08:00
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gchar *
gimp_palette_new (const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
gchar *actual_name = NULL;
2004-09-29 06:01:21 +08:00
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-new",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
actual_name = g_value_dup_string (gimp_value_array_index (return_vals, 1));
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
return actual_name;
2004-09-29 06:01:21 +08:00
}
/**
* gimp_palette_duplicate:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
*
* Duplicates a palette
*
* This procedure creates an identical palette by a different name
*
* Returns: (transfer full): The name of the palette's copy.
* The returned value must be freed with g_free().
2004-09-29 06:01:21 +08:00
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gchar *
gimp_palette_duplicate (const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
gchar *copy_name = NULL;
2004-09-29 06:01:21 +08:00
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
2004-09-29 06:01:21 +08:00
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-duplicate",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
copy_name = g_value_dup_string (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
return copy_name;
2004-09-29 06:01:21 +08:00
}
/**
* gimp_palette_rename:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @new_name: The new name of the palette.
*
* Rename a palette
*
* This procedure renames a palette
*
* Returns: (transfer full): The actual new name of the palette.
* The returned value must be freed with g_free().
2004-09-29 06:01:21 +08:00
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gchar *
gimp_palette_rename (const gchar *name,
const gchar *new_name)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
gchar *actual_name = NULL;
2004-09-29 06:01:21 +08:00
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_STRING, new_name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-rename",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
actual_name = g_value_dup_string (gimp_value_array_index (return_vals, 1));
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
tools/pdbgen/pdb/brush.pdb tools/pdbgen/pdb/brushes.pdb 2006-03-15 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/context.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/drawable_transform.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/transform_tools.pdb: let pdbgen handle *only* variables for arguments and return values and declare all local variables inside the C code. Removed lots of alias => '<expression>' and no_declare => 1 stuff from return values, instead let pdbgen declare the variables and assign them manually in the C code. More cleanup. * tools/pdbgen/app.pl: removed support for proc->vars. * app/pdb/brush_cmds.c * app/pdb/brushes_cmds.c * app/pdb/context_cmds.c * app/pdb/drawable_cmds.c * app/pdb/drawable_transform_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c * app/pdb/palette_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/pattern_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpbrush_pdb.c * libgimp/gimpbrushes_pdb.c * libgimp/gimpgradient_pdb.c * libgimp/gimpgradients_pdb.c * libgimp/gimppalette_pdb.c * libgimp/gimppalettes_pdb.c * libgimp/gimppatterns_pdb.c: regenerated.
2006-03-15 20:49:25 +08:00
return actual_name;
2004-09-29 06:01:21 +08:00
}
/**
* gimp_palette_delete:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
*
* Deletes a palette
*
* This procedure deletes a palette
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_delete (const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
2004-09-29 06:01:21 +08:00
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-delete",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_is_editable:
* @name: The palette name.
*
* Tests if palette can be edited
*
2006-03-25 05:57:47 +08:00
* Returns TRUE if you have permission to change the palette
*
2006-03-25 05:57:47 +08:00
* Returns: TRUE if the palette can be edited.
*
* Since: 2.4
**/
gboolean
gimp_palette_is_editable (const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean editable = FALSE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-is-editable",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
editable = g_value_get_boolean (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return editable;
}
2004-09-29 06:01:21 +08:00
/**
* gimp_palette_get_info:
* @name: The palette name.
* @num_colors: (out): The number of colors in the palette.
2004-09-29 06:01:21 +08:00
*
* Retrieve information about the specified palette.
*
* This procedure retrieves information about the specified palette.
* This includes the name, and the number of colors.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_get_info (const gchar *name,
gint *num_colors)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-get-info",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
*num_colors = 0;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
if (success)
*num_colors = g_value_get_int (gimp_value_array_index (return_vals, 1));
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_get_colors:
* @name: The palette name.
* @num_colors: (out): Length of the colors array.
*
* Gets all colors from the specified palette.
*
* This procedure retrieves all color entries of the specified palette.
*
* Returns: (array length=num_colors) (element-type GimpRGB) (transfer full):
* The colors in the palette.
* The returned value must be freed with g_free().
*
* Since: 2.6
**/
GimpRGB *
gimp_palette_get_colors (const gchar *name,
gint *num_colors)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpRGB *colors = NULL;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-get-colors",
args);
gimp_value_array_unref (args);
*num_colors = 0;
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
{
*num_colors = g_value_get_int (gimp_value_array_index (return_vals, 1));
colors = gimp_value_dup_rgb_array (gimp_value_array_index (return_vals, 2));
}
gimp_value_array_unref (return_vals);
return colors;
}
/**
* gimp_palette_get_columns:
* @name: The palette name.
*
* Retrieves the number of columns to use to display this palette
*
* This procedures retrieves the preferred number of columns to use
* when the palette is being displayed.
*
* Returns: The number of columns used to display this palette.
*
* Since: 2.4
**/
gint
gimp_palette_get_columns (const gchar *name)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gint num_columns = 0;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-get-columns",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
num_columns = g_value_get_int (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return num_columns;
}
/**
* gimp_palette_set_columns:
* @name: The palette name.
* @columns: The new number of columns.
*
* Sets the number of columns to use when displaying the palette
*
* This procedures controls how many colors are shown per row when the
* palette is being displayed. This value can only be changed if the
* palette is writable. The maximum allowed value is 64.
*
* Returns: TRUE on success.
*
* Since: 2.4
**/
gboolean
gimp_palette_set_columns (const gchar *name,
gint columns)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, columns,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-set-columns",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
gimp_value_array_unref (return_vals);
return success;
}
2004-09-29 06:01:21 +08:00
/**
* gimp_palette_add_entry:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_name: The name of the entry.
* @color: The new entry's color color.
* @entry_num: (out): The index of the added entry.
2004-09-29 06:01:21 +08:00
*
* Adds a palette entry to the specified palette.
*
* This procedure adds an entry to the specified palette. It returns an
2004-09-29 06:01:21 +08:00
* error if the entry palette does not exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_add_entry (const gchar *name,
const gchar *entry_name,
const GimpRGB *color,
gint *entry_num)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_STRING, entry_name,
GIMP_TYPE_RGB, color,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-add-entry",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
*entry_num = 0;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
if (success)
*entry_num = g_value_get_int (gimp_value_array_index (return_vals, 1));
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_delete_entry:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_num: The index of the added entry.
*
* Deletes a palette entry from the specified palette.
*
* This procedure deletes an entry from the specified palette. It
2004-09-29 06:01:21 +08:00
* returns an error if the entry palette does not exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_delete_entry (const gchar *name,
gint entry_num)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, entry_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-delete-entry",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_entry_get_color:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_num: The entry to retrieve.
* @color: (out caller-allocates): The color requested.
2004-09-29 06:01:21 +08:00
*
* Gets the specified palette entry from the specified palette.
*
* This procedure retrieves the color of the zero-based entry specified
2004-09-29 06:01:21 +08:00
* for the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_entry_get_color (const gchar *name,
gint entry_num,
GimpRGB *color)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, entry_num,
G_TYPE_NONE);
2004-09-29 06:01:21 +08:00
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-entry-get-color",
args);
gimp_value_array_unref (args);
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
if (success)
gimp_value_get_rgb (gimp_value_array_index (return_vals, 1), &*color);
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_entry_set_color:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_num: The entry to retrieve.
* @color: The new color.
*
* Sets the specified palette entry in the specified palette.
*
* This procedure sets the color of the zero-based entry specified for
2004-09-29 06:01:21 +08:00
* the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_entry_set_color (const gchar *name,
gint entry_num,
const GimpRGB *color)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, entry_num,
GIMP_TYPE_RGB, color,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-entry-set-color",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_entry_get_name:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_num: The entry to retrieve.
* @entry_name: (out) (transfer full): The name requested.
2004-09-29 06:01:21 +08:00
*
* Gets the specified palette entry from the specified palette.
*
* This procedure retrieves the name of the zero-based entry specified
2004-09-29 06:01:21 +08:00
* for the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_entry_get_name (const gchar *name,
gint entry_num,
gchar **entry_name)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, entry_num,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-entry-get-name",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
*entry_name = NULL;
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
if (success)
*entry_name = g_value_dup_string (gimp_value_array_index (return_vals, 1));
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}
/**
* gimp_palette_entry_set_name:
* @name: The palette name.
2004-09-29 06:01:21 +08:00
* @entry_num: The entry to retrieve.
* @entry_name: The new name.
*
* Sets the specified palette entry in the specified palette.
*
* This procedure sets the name of the zero-based entry specified for
2004-09-29 06:01:21 +08:00
* the specified palette. It returns an error if the entry does not
* exist.
*
* Returns: TRUE on success.
*
* Since: 2.2
**/
2004-09-29 06:01:21 +08:00
gboolean
gimp_palette_entry_set_name (const gchar *name,
gint entry_num,
const gchar *entry_name)
2004-09-29 06:01:21 +08:00
{
GimpValueArray *args;
GimpValueArray *return_vals;
2004-09-29 06:01:21 +08:00
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, name,
G_TYPE_INT, entry_num,
G_TYPE_STRING, entry_name,
G_TYPE_NONE);
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-palette-entry-set-name",
args);
gimp_value_array_unref (args);
2004-09-29 06:01:21 +08:00
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
2004-09-29 06:01:21 +08:00
gimp_value_array_unref (return_vals);
2004-09-29 06:01:21 +08:00
return success;
}