gimp r26192 - in trunk: . app/pdb libgimp tools/pdbgen/pdb
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26192 - in trunk: . app/pdb libgimp tools/pdbgen/pdb
- Date: Mon, 14 Jul 2008 14:46:50 +0000 (UTC)
Author: neo
Date: Mon Jul 14 14:46:50 2008
New Revision: 26192
URL: http://svn.gnome.org/viewvc/gimp?rev=26192&view=rev
Log:
2008-07-14 Sven Neumann <sven gimp org>
* tools/pdbgen/pdb/palette.pdb: added new PDB function
gimp-palette-get-colors that retrieves all colors from a palette
in a single call. Based on patches from bug #332206.
* app/pdb/palette-cmds.c
* app/pdb/internal-procs.c
* libgimp/gimppalette_pdb.[ch]: regenerated.
* libgimp/gimp.def: updated.
Modified:
trunk/ChangeLog
trunk/app/pdb/internal-procs.c
trunk/app/pdb/palette-cmds.c
trunk/libgimp/gimp.def
trunk/libgimp/gimppalette_pdb.c
trunk/libgimp/gimppalette_pdb.h
trunk/tools/pdbgen/pdb/palette.pdb
Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c (original)
+++ trunk/app/pdb/internal-procs.c Mon Jul 14 14:46:50 2008
@@ -29,7 +29,7 @@
#include "internal-procs.h"
-/* 586 procedures registered total */
+/* 587 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
Modified: trunk/app/pdb/palette-cmds.c
==============================================================================
--- trunk/app/pdb/palette-cmds.c (original)
+++ trunk/app/pdb/palette-cmds.c Mon Jul 14 14:46:50 2008
@@ -248,6 +248,54 @@
}
static GValueArray *
+palette_get_colors_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GValueArray *return_vals;
+ const gchar *name;
+ gint32 num_colors = 0;
+ GimpRGB *colors = NULL;
+
+ name = g_value_get_string (&args->values[0]);
+
+ if (success)
+ {
+ GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
+
+ if (palette)
+ {
+ GList *list = palette->colors;
+ gint i;
+
+ num_colors = palette->n_colors;
+ colors = g_new (GimpRGB, num_colors);
+
+ for (i = 0; i < num_colors; i++, list = g_list_next (list))
+ colors[i] = ((GimpPaletteEntry *)(list->data))->color;
+ }
+ else
+ {
+ success = FALSE;
+ }
+ }
+
+ return_vals = gimp_procedure_get_return_values (procedure, success);
+
+ if (success)
+ {
+ g_value_set_int (&return_vals->values[1], num_colors);
+ gimp_value_take_colorarray (&return_vals->values[2], colors, num_colors);
+ }
+
+ return return_vals;
+}
+
+static GValueArray *
palette_get_columns_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -748,6 +796,41 @@
g_object_unref (procedure);
/*
+ * gimp-palette-get-colors
+ */
+ procedure = gimp_procedure_new (palette_get_colors_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "gimp-palette-get-colors");
+ gimp_procedure_set_static_strings (procedure,
+ "gimp-palette-get-colors",
+ "Gets all colors from the specified palette.",
+ "This procedure retrieves all color entries of the specified palette.",
+ "Sven Neumann <sven gimp org>",
+ "Sven Neumann",
+ "2006",
+ NULL);
+ gimp_procedure_add_argument (procedure,
+ gimp_param_spec_string ("name",
+ "name",
+ "The palette name",
+ FALSE, FALSE, TRUE,
+ NULL,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_int32 ("num-colors",
+ "num colors",
+ "Length of the colors array",
+ 0, G_MAXINT32, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_return_value (procedure,
+ gimp_param_spec_color_array ("colors",
+ "colors",
+ "The colors in the palette",
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
+ /*
* gimp-palette-get-columns
*/
procedure = gimp_procedure_new (palette_get_columns_invoker);
Modified: trunk/libgimp/gimp.def
==============================================================================
--- trunk/libgimp/gimp.def (original)
+++ trunk/libgimp/gimp.def Mon Jul 14 14:46:50 2008
@@ -460,6 +460,7 @@
gimp_palette_entry_set_color
gimp_palette_entry_set_name
gimp_palette_get_background
+ gimp_palette_get_colors
gimp_palette_get_columns
gimp_palette_get_foreground
gimp_palette_get_info
Modified: trunk/libgimp/gimppalette_pdb.c
==============================================================================
--- trunk/libgimp/gimppalette_pdb.c (original)
+++ trunk/libgimp/gimppalette_pdb.c Mon Jul 14 14:46:50 2008
@@ -23,6 +23,8 @@
#include "config.h"
+#include <string.h>
+
#include "gimp.h"
/**
@@ -227,6 +229,48 @@
}
/**
+ * gimp_palette_get_colors:
+ * @name: The palette name.
+ * @num_colors: Length of the colors array.
+ *
+ * Gets all colors from the specified palette.
+ *
+ * This procedure retrieves all color entries of the specified palette.
+ *
+ * Returns: The colors in the palette.
+ *
+ * Since: GIMP 2.6
+ */
+GimpRGB *
+gimp_palette_get_colors (const gchar *name,
+ gint *num_colors)
+{
+ GimpParam *return_vals;
+ gint nreturn_vals;
+ GimpRGB *colors = NULL;
+
+ return_vals = gimp_run_procedure ("gimp-palette-get-colors",
+ &nreturn_vals,
+ GIMP_PDB_STRING, name,
+ GIMP_PDB_END);
+
+ *num_colors = 0;
+
+ if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+ {
+ *num_colors = return_vals[1].data.d_int32;
+ colors = g_new (GimpRGB, *num_colors);
+ memcpy (colors,
+ return_vals[2].data.d_colorarray,
+ *num_colors * sizeof (GimpRGB));
+ }
+
+ gimp_destroy_params (return_vals, nreturn_vals);
+
+ return colors;
+}
+
+/**
* gimp_palette_get_columns:
* @name: The palette name.
*
Modified: trunk/libgimp/gimppalette_pdb.h
==============================================================================
--- trunk/libgimp/gimppalette_pdb.h (original)
+++ trunk/libgimp/gimppalette_pdb.h Mon Jul 14 14:46:50 2008
@@ -37,6 +37,8 @@
gboolean gimp_palette_is_editable (const gchar *name);
gboolean gimp_palette_get_info (const gchar *name,
gint *num_colors);
+GimpRGB* gimp_palette_get_colors (const gchar *name,
+ gint *num_colors);
gint gimp_palette_get_columns (const gchar *name);
gboolean gimp_palette_set_columns (const gchar *name,
gint columns);
Modified: trunk/tools/pdbgen/pdb/palette.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/palette.pdb (original)
+++ trunk/tools/pdbgen/pdb/palette.pdb Mon Jul 14 14:46:50 2008
@@ -212,6 +212,53 @@
);
}
+sub palette_get_colors {
+ $blurb = 'Gets all colors from the specified palette.';
+
+ $help = <<'HELP';
+This procedure retrieves all color entries of the specified palette.
+HELP
+
+ &neo_pdb_misc('2006', '2.6');
+
+ @inargs = (
+ { name => 'name', type => 'string', non_empty => 1,
+ desc => 'The palette name' }
+ );
+
+ @outargs = (
+ { name => 'colors', type => 'colorarray',
+ desc => 'The colors in the palette',
+ array => { name => 'num_colors',
+ desc => 'Length of the colors array' } }
+ );
+
+ %invoke = (
+ vars => [ 'GimpPalette *palette = NULL' ],
+ code => <<'CODE'
+{
+ GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
+
+ if (palette)
+ {
+ GList *list = palette->colors;
+ gint i;
+
+ num_colors = palette->n_colors;
+ colors = g_new (GimpRGB, num_colors);
+
+ for (i = 0; i < num_colors; i++, list = g_list_next (list))
+ colors[i] = ((GimpPaletteEntry *)(list->data))->color;
+ }
+ else
+ {
+ success = FALSE;
+ }
+}
+CODE
+ );
+}
+
sub palette_get_columns {
$blurb = "Retrieves the number of columns to use to display this palette";
$help = <<'HELP';
@@ -551,7 +598,7 @@
palette_rename
palette_delete
palette_is_editable
- palette_get_info
+ palette_get_info palette_get_colors
palette_get_columns palette_set_columns
palette_add_entry palette_delete_entry
palette_entry_get_color palette_entry_set_color
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]