plug_in.pdb 8.65 KB
Newer Older
1
# GIMP - The GNU Image Manipulation Program
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 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 plugins_query {
    $blurb = 'Queries the plugin database for its contents.';
22
    $help  = 'This procedure queries the contents of the plugin database.';
23

24
    &andy_pdb_misc('1998');
25 26

    @inargs = (
27
	{ name  => 'search_string', type => 'string', no_validate => 1,
28
	  desc  => 'If not an empty string then use this as a search pattern' }
29 30 31 32
    );

    @outargs = (
	{ name => 'menu_path', type => 'stringarray',
33 34 35
	  desc => 'The menu path of the plugin',
	  array => { name => 'num_plugins',
		     desc => 'The number of plugins' } },
36 37
	{ name => 'plugin_accelerator', type => 'stringarray',
	  desc => 'String representing keyboard accelerator (could be empty
38 39 40
		   string)',
	  array => { name => 'num_plugins', no_declare => 1,
		     desc => 'The number of plugins' } },
41
	{ name => 'plugin_location', type => 'stringarray',
42 43 44
	  desc => 'Location of the plugin program',
	  array => { name => 'num_plugins', no_declare => 1,
		     desc => 'The number of plugins' } },
45
	{ name => 'plugin_image_type', type => 'stringarray',
46 47 48
	  desc => 'Type of image that this plugin will work on',
	  array => { name => 'num_plugins', no_declare => 1,
		     desc => 'The number of plugins' } },
49
	{ name => 'plugin_install_time', type => 'int32array',
50 51 52
	  desc => 'Time that the plugin was installed',
	  array => { name => 'num_plugins', no_declare => 1,
		     desc => 'The number of plugins' } },
53
	{ name => 'plugin_real_name', type => 'stringarray',
54 55 56
	  desc => 'The internal name of the plugin',
	  array => { name => 'num_plugins', no_declare => 1,
		     desc => 'The number of plugins' } }
57 58 59 60 61
    );

    %invoke = (
	code => <<'CODE'
{
62 63 64 65 66 67 68 69
  num_plugins = gimp_plug_in_manager_query (gimp->plug_in_manager,
                                            search_string,
                                            &menu_path,
                                            &plugin_accelerator,
                                            &plugin_location,
                                            &plugin_image_type,
                                            &plugin_real_name,
                                            &plugin_install_time);
70 71 72 73 74
}
CODE
    );
}

75 76
sub plugin_domain_register {
    $blurb = 'Registers a textdomain for localisation.';
77 78 79 80 81

    $help = <<'HELP';
This procedure adds a textdomain to the list of domains Gimp searches 
for strings when translating its menu entries. There is no need to 
call this function for plug-ins that have their strings included in 
82
the gimp-std-plugins domain as that is used by default. If the compiled 
83 84
message catalog is not in the standard location, you may specify an 
absolute path to another location. This procedure can only be called 
85
in the query function of a plug-in and it has to be called before any
86 87 88
procedure is installed.
HELP

89
    &neo_pdb_misc('2000');
90 91 92

    @inargs = (
	{ name => 'domain_name', type => 'string',
93
	  desc => 'The name of the textdomain (must be unique)' },
94
	{ name => 'domain_path', type => 'string', no_validate => 1,
95
	  desc => 'The absolute path to the compiled message catalog (may be
96
		   NULL)' }
97
    );
98

99
    %invoke = (
100
	code => <<'CODE'
101
{
102
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
103

104
  if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
105
    {
106 107
      gimp_plug_in_def_set_locale_domain (plug_in->plug_in_def,
                                          domain_name, domain_path);
108
    }
109 110
  else
    success = FALSE;
111 112 113 114 115
}
CODE
    );
}

116 117 118 119 120
sub plugin_help_register {
    $blurb = "Register a help path for a plug-in.";

    $help = <<HELP;
This procedure changes the help rootdir for the plug-in which calls it. All
121
subsequent calls of gimp_help() from this plug-in will be interpreted relative
122
to this rootdir.
123 124
HELP

125
    &mitch_pdb_misc('2000');
126 127

    @inargs = (
128
	{ name => 'domain_name', type => 'string',
129
	  desc => "The XML namespace of the plug-in's help pages" },
130
	{ name => 'domain_uri', type => 'string',
131
	  desc => "The root URI of the plug-in's help pages" }
132 133 134
    );

    %invoke = (
135
        code => <<'CODE'
136
{
137
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
138

139
  if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
140
    {
141 142
      gimp_plug_in_def_set_help_domain (plug_in->plug_in_def,
                                        domain_name, domain_uri);
143
    }
144 145
  else
    success = FALSE;
146 147 148 149
}
CODE
    );
}
150

151
sub plugin_menu_register {
152 153 154 155 156 157
    $blurb = "Register an additional menu path for a plug-in procedure.";

    $help = <<HELP;
This procedure installs an additional menu entry for the given procedure.
HELP

158
    &mitch_pdb_misc('2004', '2.2');
159 160

    @inargs = (
161
	{ name => 'procedure_name', type => 'string', non_empty => 1,
162 163
	  desc => 'The procedure for which to install the menu path' },
	{ name => 'menu_path', type => 'string',
164
	  desc => "The procedure's additional menu path" }
165 166 167
    );

    %invoke = (
168
        code => <<'CODE'
169
{
170
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
171 172

  if (plug_in)
173
    {
174
      gchar *canonical = gimp_canonicalize_identifier (procedure_name);
175
      success = gimp_plug_in_menu_register (plug_in, canonical, menu_path);
176
      g_free (canonical);
177
    }
178
  else
179 180 181
    {
      success = FALSE;
    }
182 183 184 185 186
}
CODE
    );
}

187 188 189 190 191 192 193
sub plugin_menu_branch_register {
    $blurb = "Register a sub-menu.";

    $help = <<HELP;
This procedure installs an sub-menu which does not belong to any procedure.
HELP

194
    &mitch_pdb_misc('2005', '2.4');
195 196 197 198 199 200 201 202 203

    @inargs = (
	{ name => 'menu_path', type => 'string',
	  desc => "The sub-menu's menu path" },
	{ name => 'menu_name', type => 'string',
	  desc => 'The name of the sub-menu' }
    );

    %invoke = (
204
        code => <<'CODE'
205
{
206
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
207 208

  if (plug_in)
209
    {
210 211
      gimp_plug_in_manager_add_menu_branch (gimp->plug_in_manager,
                                            plug_in->prog, menu_path, menu_name);
212 213 214 215 216 217 218 219
    }
  else
    success = FALSE;
}
CODE
    );
}

220 221 222 223 224 225 226
sub plugin_icon_register {
    $blurb = "Register an icon for a plug-in procedure.";

    $help = <<HELP;
This procedure installs an icon for the given procedure.
HELP

227
    &mitch_pdb_misc('2004', '2.2');
228 229

    @inargs = (
230
	{ name => 'procedure_name', type => 'string', wrap => 1, non_empty => 1,
231 232
	  desc => 'The procedure for which to install the icon' },
        { name => 'icon_type', type => 'enum GimpIconType',
233
          desc => 'The type of the icon' },
234
	{ name => 'icon_data', type => 'int8array',
235 236
	  desc => "The procedure's icon. The format depends on the
                   'icon_type' parameter",
237
	  array => { name => 'icon_data_length', type => '1 <= int32',
238
                     desc => "The length of 'icon-data'" } }
239 240 241
    );

    %invoke = (
242
        code => <<'CODE'
243
{
244
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
245

246
  if (plug_in && plug_in->call_mode == GIMP_PLUG_IN_CALL_QUERY)
247
    {
248 249
      GimpPlugInProcedure *proc;
      gchar               *canonical;
250 251

      canonical = gimp_canonicalize_identifier (procedure_name);
252

253
      proc = gimp_plug_in_procedure_find (plug_in->plug_in_def->procedures,
254
                                          canonical);
255 256

      g_free (canonical);
257

258 259 260
      if (proc)
        gimp_plug_in_procedure_set_icon (proc, icon_type,
                                         icon_data, icon_data_length);
261
      else
262 263
        success = FALSE;
    }
264 265
  else
    success = FALSE;
266 267 268 269 270
}
CODE
    );
}

271

272 273 274 275
@headers = qw(<string.h>
              <stdlib.h>
              "libgimpbase/gimpbase.h"
              "core/gimp.h"
276
              "plug-in/gimpplugin.h"
277
              "plug-in/gimpplugindef.h"
278 279 280
              "plug-in/gimppluginmanager.h"
              "plug-in/gimppluginmanager-menu-branch.h"
              "plug-in/gimppluginmanager-query.h"
281
              "plug-in/gimppluginprocedure.h");
Michael Natterer's avatar
Michael Natterer committed
282

283
@procs = qw(plugins_query
284
	    plugin_domain_register plugin_help_register
285 286
            plugin_menu_register plugin_menu_branch_register
            plugin_icon_register);
287

288
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5]]);
289 290 291 292

$desc = 'Plug-in';

1;