2006-12-10 05:33:38 +08:00
|
|
|
# GIMP - The GNU Image Manipulation Program
|
2002-03-13 05:02:10 +08:00
|
|
|
# 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 palettes_refresh {
|
2003-12-08 19:58:45 +08:00
|
|
|
$blurb = 'Refreshes current palettes. This function always succeeds.';
|
2002-03-13 05:02:10 +08:00
|
|
|
|
|
|
|
$help = <<'HELP';
|
2004-09-23 23:05:48 +08:00
|
|
|
This procedure retrieves all palettes currently in the user's palette path
|
|
|
|
and updates the palette dialogs accordingly.
|
2002-03-13 05:02:10 +08:00
|
|
|
HELP
|
|
|
|
|
2006-03-15 05:35:50 +08:00
|
|
|
&adrian_pdb_misc('1998');
|
2002-03-13 05:02:10 +08:00
|
|
|
|
|
|
|
%invoke = (
|
2006-03-22 17:58:08 +08:00
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
gimp_data_factory_data_refresh (gimp->palette_factory);
|
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
2002-03-13 05:02:10 +08:00
|
|
|
}
|
|
|
|
|
2002-03-13 23:29:59 +08:00
|
|
|
sub palettes_get_list {
|
|
|
|
$blurb = 'Retrieves a list of all of the available palettes';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure returns a complete listing of available palettes. Each name
|
2006-06-14 16:32:08 +08:00
|
|
|
returned can be used as input to the command gimp_context_set_palette().
|
2002-03-13 23:29:59 +08:00
|
|
|
HELP
|
|
|
|
|
2006-03-15 05:35:50 +08:00
|
|
|
&rock_pdb_misc('2001');
|
2002-03-13 23:29:59 +08:00
|
|
|
|
2003-09-05 01:04:36 +08:00
|
|
|
@inargs = (
|
2004-09-23 23:05:48 +08:00
|
|
|
{ name => 'filter', type => 'string', null_ok => 1,
|
2003-09-05 01:04:36 +08:00
|
|
|
desc => 'An optional regular expression used to filter the list' }
|
|
|
|
);
|
|
|
|
|
2002-03-13 23:29:59 +08:00
|
|
|
@outargs = (
|
|
|
|
{ name => 'palette_list', type => 'stringarray',
|
|
|
|
desc => 'The list of palette names',
|
|
|
|
array => { name => 'num_palettes',
|
2006-03-15 23:32:39 +08:00
|
|
|
desc => 'The number of palettes in the list' } }
|
2002-03-13 23:29:59 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
2003-09-05 01:04:36 +08:00
|
|
|
headers => [ qw("core/gimpcontainer-filter.h") ],
|
2006-03-22 17:58:08 +08:00
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container,
|
|
|
|
filter, &num_palettes);
|
|
|
|
}
|
|
|
|
CODE
|
2002-03-13 23:29:59 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2002-03-13 05:02:10 +08:00
|
|
|
sub palettes_get_palette {
|
2005-08-03 06:52:23 +08:00
|
|
|
&std_pdb_deprecated ('gimp-context-get-palette');
|
2004-09-23 23:05:48 +08:00
|
|
|
|
2002-03-13 05:02:10 +08:00
|
|
|
@outargs = (
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'name', type => 'string',
|
2006-03-15 20:49:25 +08:00
|
|
|
desc => 'The palette name', null_ok => '1' },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'num_colors', type => 'int32',
|
2006-03-15 20:49:25 +08:00
|
|
|
desc => 'The palette num_colors' }
|
2002-03-13 05:02:10 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
2006-03-15 20:49:25 +08:00
|
|
|
code => <<'CODE'
|
|
|
|
{
|
|
|
|
GimpPalette *palette = gimp_context_get_palette (context);
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
{
|
2006-03-25 05:57:47 +08:00
|
|
|
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
|
2006-03-15 20:49:25 +08:00
|
|
|
num_colors = palette->n_colors;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
CODE
|
2002-03-13 05:02:10 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub palettes_get_palette_entry {
|
2005-08-03 06:52:23 +08:00
|
|
|
&std_pdb_deprecated ('gimp-palette-entry-get-color');
|
2002-03-13 05:02:10 +08:00
|
|
|
|
|
|
|
@inargs = (
|
2006-03-22 17:58:08 +08:00
|
|
|
{ name => 'name', type => 'string', null_ok => 1,
|
|
|
|
desc => 'The palette name ("" means currently active palette)' },
|
2002-03-13 05:02:10 +08:00
|
|
|
{ name => 'entry_num', type => 'int32',
|
|
|
|
desc => 'The entry to retrieve' }
|
|
|
|
);
|
|
|
|
|
|
|
|
@outargs = (
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'actual_name', type => 'string',
|
2006-03-15 20:49:25 +08:00
|
|
|
desc => 'The palette name' },
|
2006-03-15 23:32:39 +08:00
|
|
|
{ name => 'num_colors', type => 'int32',
|
2006-03-15 20:49:25 +08:00
|
|
|
desc => 'The palette num_colors' },
|
2006-03-15 05:35:50 +08:00
|
|
|
{ name => 'color', type => 'color', void_ret => 1,
|
|
|
|
desc => 'The color requested' }
|
2002-03-13 05:02:10 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
%invoke = (
|
2006-03-22 17:58:08 +08:00
|
|
|
code => <<'CODE'
|
2002-03-13 05:02:10 +08:00
|
|
|
{
|
2006-03-15 20:49:25 +08:00
|
|
|
GimpPalette *palette;
|
|
|
|
|
2006-03-15 05:35:50 +08:00
|
|
|
if (name && strlen (name))
|
|
|
|
{
|
|
|
|
palette = (GimpPalette *)
|
|
|
|
gimp_container_get_child_by_name (gimp->palette_factory->container,
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
palette = gimp_context_get_palette (context);
|
|
|
|
}
|
2002-03-13 05:02:10 +08:00
|
|
|
|
2003-12-08 19:58:45 +08:00
|
|
|
if (palette)
|
2002-03-13 05:02:10 +08:00
|
|
|
{
|
2006-03-15 20:49:25 +08:00
|
|
|
if (entry_num >= 0 && entry_num < palette->n_colors)
|
2002-03-13 05:02:10 +08:00
|
|
|
{
|
2006-03-15 20:49:25 +08:00
|
|
|
GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num);
|
2002-03-13 05:02:10 +08:00
|
|
|
|
2006-03-25 05:57:47 +08:00
|
|
|
actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
|
2006-03-15 20:49:25 +08:00
|
|
|
num_colors = palette->n_colors;
|
|
|
|
color = entry->color;
|
2002-03-13 05:02:10 +08:00
|
|
|
}
|
2006-03-15 20:49:25 +08:00
|
|
|
else
|
|
|
|
success = FALSE;
|
2002-03-13 05:02:10 +08:00
|
|
|
}
|
2003-12-08 19:58:45 +08:00
|
|
|
else
|
|
|
|
success = FALSE;
|
2002-03-13 05:02:10 +08:00
|
|
|
}
|
|
|
|
CODE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
|
2006-06-14 16:32:08 +08:00
|
|
|
@headers = qw(<string.h>
|
|
|
|
"core/gimp.h"
|
|
|
|
"core/gimpcontext.h"
|
|
|
|
"core/gimpdatafactory.h"
|
|
|
|
"core/gimplist.h"
|
|
|
|
"core/gimppalette.h");
|
2002-03-13 05:02:10 +08:00
|
|
|
|
2004-09-29 06:01:21 +08:00
|
|
|
@procs = qw(palettes_refresh palettes_get_list
|
|
|
|
palettes_get_palette palettes_get_palette_entry);
|
2006-03-24 05:17:16 +08:00
|
|
|
|
2002-03-13 05:02:10 +08:00
|
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
|
|
|
|
$desc = 'Palettes';
|
|
|
|
|
|
|
|
1;
|