1
# The GIMP -- an image manipulation program
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
23
$blurb = 'Queries the plugin database for its contents.';
25
$help = 'This procedure queries the contents of the plugin database.';
27
$author = $copyright = 'Andy Thomas';
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 }
37
{ name => 'menu_path', type => 'stringarray',
38
desc => 'The menu path of the plugin',
39
alias => 'menu_strs', init => 1 },
40
{ name => 'plugin_accelerator', type => 'stringarray',
41
desc => 'String representing keyboard accelerator (could be empty
43
alias => 'accel_strs', init => 1 },
44
{ name => 'plugin_location', type => 'stringarray',
45
desc => 'Location of the plugin program',
46
alias => 'prog_strs', init => 1 },
47
{ name => 'plugin_image_type', type => 'stringarray',
48
desc => 'Type of image that this plugin will work on',
49
alias => 'types_strs', init => 1 },
50
{ name => 'plugin_install_time', type => 'int32array',
51
desc => 'Time that the plugin was installed',
52
alias => 'time_ints', init => 1 },
53
{ name => 'plugin_real_name', type => 'stringarray',
54
desc => 'The internal name of the plugin',
55
alias => 'realname_strs', init => 1 }
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);
159
sub plugin_domain_register {
160
$blurb = 'Registers a textdomain for localisation.';
163
This procedure adds a textdomain to the list of domains Gimp searches
164
for strings when translating its menu entries. There is no need to
165
call this function for plug-ins that have their strings included in
166
the gimp-std-plugins domain as that is used by default. If the compiled
167
message catalog is not in the standard location, you may specify an
168
absolute path to another location. This procedure can only be called
169
in the query function of a plug-in and it has to be called before any
170
procedure is installed.
173
$author = $copyright = 'Sven Neumann';
177
{ name => 'domain_name', type => 'string',
178
desc => 'The name of the textdomain (must be unique)' },
179
{ name => 'domain_path', type => 'string',
180
desc => 'The absolute path to the compiled message catalog (may be
188
if (gimp->current_plug_in && gimp->current_plug_in->query)
190
plug_in_def_set_locale_domain_name (gimp->current_plug_in->plug_in_def,
192
plug_in_def_set_locale_domain_path (gimp->current_plug_in->plug_in_def,
202
sub plugin_help_register {
203
$blurb = "Register a help path for a plug-in.";
206
This procedure changes the help rootdir for the plug-in which calls it. All
207
subsequent calls of gimp_help from this plug-in will be interpreted relative
211
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
215
{ name => 'domain_name', type => 'string',
216
desc => "The XML namespace of the plug-in's help pages" },
217
{ name => 'domain_uri', type => 'string',
218
desc => "The root URI of the plug-in's help pages" }
224
if (gimp->current_plug_in && gimp->current_plug_in->query)
226
plug_in_def_set_help_domain_name (gimp->current_plug_in->plug_in_def,
228
plug_in_def_set_help_domain_uri (gimp->current_plug_in->plug_in_def,
238
sub plugin_menu_register {
239
$blurb = "Register an additional menu path for a plug-in procedure.";
242
This procedure installs an additional menu entry for the given procedure.
245
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
250
{ name => 'procedure_name', type => 'string',
251
desc => 'The procedure for which to install the menu path' },
252
{ name => 'menu_path', type => 'string',
253
desc => "The procedure's additional menu path" }
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);
375
sub plugin_icon_register {
376
$blurb = "Register an icon for a plug-in procedure.";
379
This procedure installs an icon for the given procedure.
382
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
387
{ name => 'procedure_name', type => 'string', wrap => 1,
388
desc => 'The procedure for which to install the icon' },
389
{ name => 'icon_type', type => 'enum GimpIconType',
390
desc => 'The type of the icon' },
391
{ 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%%" } }
400
if (gimp->current_plug_in && gimp->current_plug_in->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,
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");
466
@procs = qw(plugins_query
467
plugin_domain_register plugin_help_register
468
plugin_menu_register plugin_icon_register);
469
%exports = (app => [@procs], lib => [@procs[1,2,3,4]]);