18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
22
20
sub plugins_query {
23
21
$blurb = 'Queries the plugin database for its contents.';
25
$help = 'This procedure queries the contents of the plugin database.';
27
$author = $copyright = 'Andy Thomas';
22
$help = 'This procedure queries the contents of the plugin database.';
24
&andy_pdb_misc('1998');
31
{ name => 'search_string', type => 'string',
32
desc => 'If not an empty string then use this as a search pattern',
33
alias => 'search_str', no_success => 1 }
27
{ name => 'search_string', type => 'string', no_success => 1,
28
desc => 'If not an empty string then use this as a search pattern' }
37
32
{ name => 'menu_path', type => 'stringarray',
38
33
desc => 'The menu path of the plugin',
39
alias => 'menu_strs', init => 1 },
34
array => { name => 'num_plugins',
35
desc => 'The number of plugins' } },
40
36
{ name => 'plugin_accelerator', type => 'stringarray',
41
37
desc => 'String representing keyboard accelerator (could be empty
43
alias => 'accel_strs', init => 1 },
39
array => { name => 'num_plugins', no_declare => 1,
40
desc => 'The number of plugins' } },
44
41
{ name => 'plugin_location', type => 'stringarray',
45
42
desc => 'Location of the plugin program',
46
alias => 'prog_strs', init => 1 },
43
array => { name => 'num_plugins', no_declare => 1,
44
desc => 'The number of plugins' } },
47
45
{ name => 'plugin_image_type', type => 'stringarray',
48
46
desc => 'Type of image that this plugin will work on',
49
alias => 'types_strs', init => 1 },
47
array => { name => 'num_plugins', no_declare => 1,
48
desc => 'The number of plugins' } },
50
49
{ name => 'plugin_install_time', type => 'int32array',
51
50
desc => 'Time that the plugin was installed',
52
alias => 'time_ints', init => 1 },
51
array => { name => 'num_plugins', no_declare => 1,
52
desc => 'The number of plugins' } },
53
53
{ name => 'plugin_real_name', type => 'stringarray',
54
54
desc => 'The internal name of the plugin',
55
alias => 'realname_strs', init => 1 }
55
array => { name => 'num_plugins', no_declare => 1,
56
desc => 'The number of plugins' } }
59
$_->{array} = { name => 'num_plugins', no_declare => 1,
60
desc => 'The number of plugins' }
63
$outargs[0]->{array}->{init} = 1;
64
delete $outargs[0]->{array}->{no_declare};
67
headers => [ qw("libgimpbase/gimpbase.h") ],
68
vars => [ 'GSList *list', 'GSList *matched = NULL', 'gint i = 0',
72
if (search_str && ! strlen (search_str))
75
if (! (search_str && regcomp (&sregex, search_str, REG_ICASE)))
77
/* count number of plugin entries, then allocate arrays of correct size
78
* where we can store the strings.
81
for (list = gimp->plug_in_proc_defs; list; list = g_slist_next (list))
83
PlugInProcDef *proc_def = list->data;
85
if (proc_def->prog && proc_def->menu_paths)
89
if (proc_def->menu_label)
91
name = proc_def->menu_label;
95
name = strrchr (proc_def->menu_paths->data, '/');
100
name = proc_def->menu_paths->data;
103
name = gimp_strip_uline (name);
105
if (! search_str || ! match_strings (&sregex, name))
108
matched = g_slist_prepend (matched, proc_def);
115
menu_strs = g_new (gchar *, num_plugins);
116
accel_strs = g_new (gchar *, num_plugins);
117
prog_strs = g_new (gchar *, num_plugins);
118
types_strs = g_new (gchar *, num_plugins);
119
realname_strs = g_new (gchar *, num_plugins);
120
time_ints = g_new (gint , num_plugins);
122
matched = g_slist_reverse (matched);
124
for (list = matched; list; list = g_slist_next (list))
126
PlugInProcDef *proc_def = list->data;
127
ProcRecord *proc_rec = &proc_def->db_info;
130
if (proc_def->menu_label)
131
name = g_strdup_printf ("%s/%s",
132
(gchar *) proc_def->menu_paths->data,
133
proc_def->menu_label);
135
name = g_strdup (proc_def->menu_paths->data);
137
menu_strs[i] = gimp_strip_uline (name);
138
accel_strs[i] = NULL;
139
prog_strs[i] = g_strdup (proc_def->prog);
140
types_strs[i] = g_strdup (proc_def->image_types);
141
realname_strs[i] = g_strdup (proc_rec->name);
142
time_ints[i] = proc_def->mtime;
149
g_slist_free (matched);
62
num_plugins = gimp_plug_in_manager_query (gimp->plug_in_manager,
69
&plugin_install_time);
259
if (gimp->current_plug_in)
261
PlugInProcDef *proc_def = NULL;
264
if (gimp->current_plug_in->plug_in_def)
266
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
268
list = g_slist_next (list))
270
PlugInProcDef *pd = list->data;
272
if (! strcmp (procedure_name, pd->db_info.name))
282
for (list = gimp->current_plug_in->temp_proc_defs;
284
list = g_slist_next (list))
286
PlugInProcDef *pd = list->data;
288
if (! strcmp (procedure_name, pd->db_info.name))
298
if (proc_def->menu_label)
300
GError *error = NULL;
302
if (! plug_in_proc_args_check (gimp->current_plug_in->name,
303
gimp->current_plug_in->prog,
306
proc_def->db_info.args,
307
proc_def->db_info.num_args,
308
proc_def->db_info.values,
309
proc_def->db_info.num_values,
312
g_message (error->message);
313
g_clear_error (&error);
319
switch (proc_def->db_info.proc_type)
327
if (! gimp->current_plug_in->query &&
328
! gimp->current_plug_in->init)
338
proc_def->menu_paths = g_list_append (proc_def->menu_paths,
339
g_strdup (menu_path));
341
if (! gimp->no_interface &&
342
proc_def->db_info.proc_type == GIMP_TEMPORARY)
344
gimp_menus_create_entry (gimp, proc_def, menu_path);
351
g_message ("Plug-In \"%s\"\n(%s)\n\n"
352
"attempted to install additional menu_path \"%s\"\n"
353
"for procedure \"%s\".\n"
354
"However the menu_path given in "
355
"gimp_install_procedure() already contained "
356
"a path. To make this work, pass just the menu's "
357
"label to gimp_install_procedure().",
358
gimp_filename_to_utf8 (gimp->current_plug_in->name),
359
gimp_filename_to_utf8 (gimp->current_plug_in->prog),
360
menu_path, procedure_name);
170
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
174
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
175
success = gimp_plug_in_menu_register (plug_in, canonical, menu_path);
187
sub plugin_menu_branch_register {
188
$blurb = "Register a sub-menu.";
191
This procedure installs an sub-menu which does not belong to any procedure.
194
&mitch_pdb_misc('2005', '2.4');
197
{ name => 'menu_path', type => 'string',
198
desc => "The sub-menu's menu path" },
199
{ name => 'menu_name', type => 'string',
200
desc => 'The name of the sub-menu' }
206
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
210
gimp_plug_in_manager_add_menu_branch (gimp->plug_in_manager,
211
plug_in->prog, menu_path, menu_name);
389
232
{ name => 'icon_type', type => 'enum GimpIconType',
390
233
desc => 'The type of the icon' },
391
234
{ name => 'icon_data', type => 'int8array',
392
desc => "The procedure's icon. The format depends on the 'icon_type' parameter",
393
array => { name => 'icon_data_length', type => '0 < int32',
394
desc => "The length of 'icon_data': %%desc%%" } }
235
desc => "The procedure's icon. The format depends on the
236
'icon_type' parameter",
237
array => { name => 'icon_data_length', type => '1 <= int32',
238
desc => "The length of 'icon-data'" } }
400
if (gimp->current_plug_in && gimp->current_plug_in->query)
244
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
246
if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
404
for (list = gimp->current_plug_in->plug_in_def->proc_defs;
406
list = g_slist_next (list))
408
PlugInProcDef *proc_def = list->data;
410
if (! strcmp (procedure_name, proc_def->db_info.name))
412
if (proc_def->icon_data)
414
g_free (proc_def->icon_data);
415
proc_def->icon_data_length = -1;
416
proc_def->icon_data = NULL;
419
proc_def->icon_type = icon_type;
421
switch (proc_def->icon_type)
423
case GIMP_ICON_TYPE_STOCK_ID:
424
case GIMP_ICON_TYPE_IMAGE_FILE:
425
proc_def->icon_data_length = -1;
426
proc_def->icon_data = g_strdup (icon_data);
429
case GIMP_ICON_TYPE_INLINE_PIXBUF:
430
proc_def->icon_data_length = icon_data_length;
431
proc_def->icon_data = g_memdup (icon_data,
248
GimpPlugInProcedure *proc;
251
canonical = gimp_canonicalize_identifier (procedure_name);
253
proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
259
gimp_plug_in_procedure_set_icon (proc, icon_type,
260
icon_data, icon_data_length);
451
$extra{app}->{code} = <<'CODE';
453
match_strings (regex_t *preg,
456
return regexec (preg, a, 0, NULL, 0);
460
@headers = qw(<string.h> <stdlib.h> "regexrepl/regex.h"
461
"libgimpbase/gimpprotocol.h" "core/gimp.h"
462
"plug-in/plug-in.h" "plug-in/plug-ins.h"
463
"plug-in/plug-in-def.h" "plug-in/plug-in-params.h"
464
"plug-in/plug-in-proc-def.h");
272
@headers = qw(<string.h>
274
"libgimpbase/gimpbase.h"
276
"plug-in/gimpplugin.h"
277
"plug-in/gimpplugindef.h"
278
"plug-in/gimppluginmanager.h"
279
"plug-in/gimppluginmanager-menu-branch.h"
280
"plug-in/gimppluginmanager-query.h"
281
"plug-in/gimppluginprocedure.h");
466
283
@procs = qw(plugins_query
467
284
plugin_domain_register plugin_help_register
468
plugin_menu_register plugin_icon_register);
469
%exports = (app => [@procs], lib => [@procs[1,2,3,4]]);
285
plugin_menu_register plugin_menu_branch_register
286
plugin_icon_register);
288
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5]]);
471
290
$desc = 'Plug-in';