36
38
#include "core/gimplist.h"
37
39
#include "core/gimppalette.h"
39
static ProcRecord palettes_refresh_proc;
40
static ProcRecord palettes_get_list_proc;
41
static ProcRecord palettes_get_palette_proc;
42
static ProcRecord palettes_get_palette_entry_proc;
45
register_palettes_procs (Gimp *gimp)
47
procedural_db_register (gimp, &palettes_refresh_proc);
48
procedural_db_register (gimp, &palettes_get_list_proc);
49
procedural_db_register (gimp, &palettes_get_palette_proc);
50
procedural_db_register (gimp, &palettes_get_palette_entry_proc);
54
palettes_refresh_invoker (Gimp *gimp,
56
GimpProgress *progress,
59
gimp_data_factory_data_save (gimp->palette_factory);
60
gimp_data_factory_data_init (gimp->palette_factory, FALSE);
61
return procedural_db_return_args (&palettes_refresh_proc, TRUE);
64
static ProcRecord palettes_refresh_proc =
66
"gimp_palettes_refresh",
67
"Refreshes current palettes. This function always succeeds.",
68
"This procedure retrieves all palettes currently in the user's palette path and updates the palette dialogs accordingly.",
69
"Adrian Likins <adrian@gimp.org>",
78
{ { palettes_refresh_invoker } }
82
palettes_get_list_invoker (Gimp *gimp,
84
GimpProgress *progress,
41
#include "internal_procs.h"
45
palettes_refresh_invoker (GimpProcedure *procedure,
48
GimpProgress *progress,
49
const GValueArray *args)
51
gimp_data_factory_data_refresh (gimp->palette_factory);
52
return gimp_procedure_get_return_values (procedure, TRUE);
56
palettes_get_list_invoker (GimpProcedure *procedure,
59
GimpProgress *progress,
60
const GValueArray *args)
87
62
gboolean success = TRUE;
88
Argument *return_args;
63
GValueArray *return_vals;
65
gint32 num_palettes = 0;
91
66
gchar **palette_list = NULL;
93
filter = (gchar *) args[0].value.pdb_pointer;
94
if (filter && !g_utf8_validate (filter, -1, NULL))
68
filter = g_value_get_string (&args->values[0]);
72
palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container,
73
filter, &num_palettes);
76
return_vals = gimp_procedure_get_return_values (procedure, success);
80
g_value_set_int (&return_vals->values[1], num_palettes);
81
gimp_value_take_stringarray (&return_vals->values[2], palette_list, num_palettes);
88
palettes_get_palette_invoker (GimpProcedure *procedure,
91
GimpProgress *progress,
92
const GValueArray *args)
94
gboolean success = TRUE;
95
GValueArray *return_vals;
97
gint32 num_colors = 0;
99
GimpPalette *palette = gimp_context_get_palette (context);
103
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
104
num_colors = palette->n_colors;
98
palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container, filter, &num_palettes);
100
return_args = procedural_db_return_args (&palettes_get_list_proc, success);
104
return_args[1].value.pdb_int = num_palettes;
105
return_args[2].value.pdb_pointer = palette_list;
111
static ProcArg palettes_get_list_inargs[] =
116
"An optional regular expression used to filter the list"
120
static ProcArg palettes_get_list_outargs[] =
125
"The number of palettes in the list"
128
GIMP_PDB_STRINGARRAY,
130
"The list of palette names"
134
static ProcRecord palettes_get_list_proc =
136
"gimp_palettes_get_list",
137
"Retrieves a list of all of the available palettes",
138
"This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'gimp_context_set_palette'.",
139
"Nathan Summers <rock@gimp.org>",
145
palettes_get_list_inargs,
147
palettes_get_list_outargs,
148
{ { palettes_get_list_invoker } }
152
palettes_get_palette_invoker (Gimp *gimp,
153
GimpContext *context,
154
GimpProgress *progress,
157
gboolean success = TRUE;
158
Argument *return_args;
159
GimpPalette *palette;
161
success = (palette = gimp_context_get_palette (context)) != NULL;
163
return_args = procedural_db_return_args (&palettes_get_palette_proc, success);
167
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (palette)->name);
168
return_args[2].value.pdb_int = palette->n_colors;
174
static ProcArg palettes_get_palette_outargs[] =
184
"The palette num_colors"
188
static ProcRecord palettes_get_palette_proc =
190
"gimp_palettes_get_palette",
191
"This procedure is deprecated! Use 'gimp_context_get_palette' instead.",
192
"This procedure is deprecated! Use 'gimp_context_get_palette' instead.",
196
"gimp_context_get_palette",
201
palettes_get_palette_outargs,
202
{ { palettes_get_palette_invoker } }
206
palettes_get_palette_entry_invoker (Gimp *gimp,
207
GimpContext *context,
208
GimpProgress *progress,
211
gboolean success = TRUE;
212
Argument *return_args;
109
return_vals = gimp_procedure_get_return_values (procedure, success);
113
g_value_take_string (&return_vals->values[1], name);
114
g_value_set_int (&return_vals->values[2], num_colors);
121
palettes_get_palette_entry_invoker (GimpProcedure *procedure,
123
GimpContext *context,
124
GimpProgress *progress,
125
const GValueArray *args)
127
gboolean success = TRUE;
128
GValueArray *return_vals;
214
130
gint32 entry_num;
216
GimpPalette *palette = NULL;
218
name = (gchar *) args[0].value.pdb_pointer;
219
if (name && !g_utf8_validate (name, -1, NULL))
222
entry_num = args[1].value.pdb_int;
131
gchar *actual_name = NULL;
132
gint32 num_colors = 0;
133
GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
135
name = g_value_get_string (&args->values[0]);
136
entry_num = g_value_get_int (&args->values[1]);
140
GimpPalette *palette;
226
142
if (name && strlen (name))
228
palette = (GimpPalette *)
229
gimp_container_get_child_by_name (gimp->palette_factory->container,
234
palette = gimp_context_get_palette (context);
144
palette = (GimpPalette *)
145
gimp_container_get_child_by_name (gimp->palette_factory->container,
150
palette = gimp_context_get_palette (context);
239
if (entry_num < 0 || entry_num >= palette->n_colors)
155
if (entry_num >= 0 && entry_num < palette->n_colors)
157
GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num);
159
actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette)));
160
num_colors = palette->n_colors;
161
color = entry->color;
245
GimpPaletteEntry *entry;
247
entry = (GimpPaletteEntry *)
248
g_list_nth_data (palette->colors, entry_num);
250
color = entry->color;
257
return_args = procedural_db_return_args (&palettes_get_palette_entry_proc, success);
170
return_vals = gimp_procedure_get_return_values (procedure, success);
261
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (palette)->name);
262
return_args[2].value.pdb_int = palette->n_colors;
263
return_args[3].value.pdb_color = color;
174
g_value_take_string (&return_vals->values[1], actual_name);
175
g_value_set_int (&return_vals->values[2], num_colors);
176
gimp_value_set_rgb (&return_vals->values[3], &color);
269
static ProcArg palettes_get_palette_entry_inargs[] =
274
"The palette name (\"\" means currently active palette)"
279
"The entry to retrieve"
283
static ProcArg palettes_get_palette_entry_outargs[] =
293
"The palette num_colors"
298
"The color requested"
302
static ProcRecord palettes_get_palette_entry_proc =
304
"gimp_palettes_get_palette_entry",
305
"This procedure is deprecated! Use 'gimp_palette_entry_get_color' instead.",
306
"This procedure is deprecated! Use 'gimp_palette_entry_get_color' instead.",
310
"gimp_palette_entry_get_color",
313
palettes_get_palette_entry_inargs,
315
palettes_get_palette_entry_outargs,
316
{ { palettes_get_palette_entry_invoker } }
183
register_palettes_procs (GimpPDB *pdb)
185
GimpProcedure *procedure;
188
* gimp-palettes-refresh
190
procedure = gimp_procedure_new (palettes_refresh_invoker);
191
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-refresh");
192
gimp_procedure_set_static_strings (procedure,
193
"gimp-palettes-refresh",
194
"Refreshes current palettes. This function always succeeds.",
195
"This procedure retrieves all palettes currently in the user's palette path and updates the palette dialogs accordingly.",
196
"Adrian Likins <adrian@gimp.org>",
200
gimp_pdb_register_procedure (pdb, procedure);
201
g_object_unref (procedure);
204
* gimp-palettes-get-list
206
procedure = gimp_procedure_new (palettes_get_list_invoker);
207
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-list");
208
gimp_procedure_set_static_strings (procedure,
209
"gimp-palettes-get-list",
210
"Retrieves a list of all of the available palettes",
211
"This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'gimp-context-set-palette'.",
212
"Nathan Summers <rock@gimp.org>",
216
gimp_procedure_add_argument (procedure,
217
gimp_param_spec_string ("filter",
219
"An optional regular expression used to filter the list",
222
GIMP_PARAM_READWRITE));
223
gimp_procedure_add_return_value (procedure,
224
gimp_param_spec_int32 ("num-palettes",
226
"The number of palettes in the list",
228
GIMP_PARAM_READWRITE));
229
gimp_procedure_add_return_value (procedure,
230
gimp_param_spec_string_array ("palette-list",
232
"The list of palette names",
233
GIMP_PARAM_READWRITE));
234
gimp_pdb_register_procedure (pdb, procedure);
235
g_object_unref (procedure);
238
* gimp-palettes-get-palette
240
procedure = gimp_procedure_new (palettes_get_palette_invoker);
241
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-palette");
242
gimp_procedure_set_static_strings (procedure,
243
"gimp-palettes-get-palette",
244
"This procedure is deprecated! Use 'gimp-context-get-palette' instead.",
245
"This procedure is deprecated! Use 'gimp-context-get-palette' instead.",
249
"gimp-context-get-palette");
250
gimp_procedure_add_return_value (procedure,
251
gimp_param_spec_string ("name",
256
GIMP_PARAM_READWRITE));
257
gimp_procedure_add_return_value (procedure,
258
gimp_param_spec_int32 ("num-colors",
260
"The palette num_colors",
261
G_MININT32, G_MAXINT32, 0,
262
GIMP_PARAM_READWRITE));
263
gimp_pdb_register_procedure (pdb, procedure);
264
g_object_unref (procedure);
267
* gimp-palettes-get-palette-entry
269
procedure = gimp_procedure_new (palettes_get_palette_entry_invoker);
270
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-palettes-get-palette-entry");
271
gimp_procedure_set_static_strings (procedure,
272
"gimp-palettes-get-palette-entry",
273
"This procedure is deprecated! Use 'gimp-palette-entry-get-color' instead.",
274
"This procedure is deprecated! Use 'gimp-palette-entry-get-color' instead.",
278
"gimp-palette-entry-get-color");
279
gimp_procedure_add_argument (procedure,
280
gimp_param_spec_string ("name",
282
"The palette name (\"\" means currently active palette)",
285
GIMP_PARAM_READWRITE));
286
gimp_procedure_add_argument (procedure,
287
gimp_param_spec_int32 ("entry-num",
289
"The entry to retrieve",
290
G_MININT32, G_MAXINT32, 0,
291
GIMP_PARAM_READWRITE));
292
gimp_procedure_add_return_value (procedure,
293
gimp_param_spec_string ("actual-name",
298
GIMP_PARAM_READWRITE));
299
gimp_procedure_add_return_value (procedure,
300
gimp_param_spec_int32 ("num-colors",
302
"The palette num_colors",
303
G_MININT32, G_MAXINT32, 0,
304
GIMP_PARAM_READWRITE));
305
gimp_procedure_add_return_value (procedure,
306
gimp_param_spec_rgb ("color",
308
"The color requested",
311
GIMP_PARAM_READWRITE));
312
gimp_pdb_register_procedure (pdb, procedure);
313
g_object_unref (procedure);