~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/plug_in.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# The GIMP -- an image manipulation program
 
1
# GIMP - The GNU Image Manipulation Program
2
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
# The defs
21
 
 
22
20
sub plugins_query {
23
21
    $blurb = 'Queries the plugin database for its contents.';
24
 
 
25
 
    $help = 'This procedure queries the contents of the plugin database.';
26
 
 
27
 
    $author = $copyright = 'Andy Thomas';
28
 
    $date = '1998';
 
22
    $help  = 'This procedure queries the contents of the plugin database.';
 
23
 
 
24
    &andy_pdb_misc('1998');
29
25
 
30
26
    @inargs = (
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' }
34
29
    );
35
30
 
36
31
    @outargs = (
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
42
38
                   string)',
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' } }
56
57
    );
57
58
 
58
 
    foreach (@outargs) {
59
 
        $_->{array} = { name => 'num_plugins', no_declare => 1,
60
 
                        desc => 'The number of plugins' }
61
 
    }
62
 
 
63
 
    $outargs[0]->{array}->{init} = 1;
64
 
    delete $outargs[0]->{array}->{no_declare};
65
 
 
66
59
    %invoke = (
67
 
        headers => [ qw("libgimpbase/gimpbase.h") ],
68
 
        vars => [ 'GSList *list', 'GSList *matched = NULL', 'gint i = 0',
69
 
                  'regex_t sregex' ],
70
60
        code => <<'CODE'
71
61
{
72
 
  if (search_str && ! strlen (search_str))
73
 
    search_str = NULL;
74
 
 
75
 
  if (! (search_str && regcomp (&sregex, search_str, REG_ICASE)))
76
 
    {
77
 
      /* count number of plugin entries, then allocate arrays of correct size
78
 
       * where we can store the strings.
79
 
       */
80
 
 
81
 
      for (list = gimp->plug_in_proc_defs; list; list = g_slist_next (list))
82
 
        {
83
 
          PlugInProcDef *proc_def = list->data;
84
 
 
85
 
          if (proc_def->prog && proc_def->menu_paths)
86
 
            {
87
 
              gchar *name;
88
 
 
89
 
              if (proc_def->menu_label)
90
 
                {
91
 
                  name = proc_def->menu_label;
92
 
                }
93
 
              else
94
 
                {
95
 
                  name = strrchr (proc_def->menu_paths->data, '/');
96
 
 
97
 
                  if (name)
98
 
                    name = name + 1;
99
 
                  else
100
 
                    name = proc_def->menu_paths->data;
101
 
                }
102
 
 
103
 
              name = gimp_strip_uline (name);
104
 
 
105
 
              if (! search_str || ! match_strings (&sregex, name))
106
 
                {
107
 
                  num_plugins++;
108
 
                  matched = g_slist_prepend (matched, proc_def);
109
 
                }
110
 
 
111
 
              g_free (name);
112
 
            }
113
 
        }
114
 
 
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);
121
 
 
122
 
      matched = g_slist_reverse (matched);
123
 
 
124
 
      for (list = matched; list; list = g_slist_next (list))
125
 
        {
126
 
          PlugInProcDef *proc_def = list->data;
127
 
          ProcRecord    *proc_rec = &proc_def->db_info;
128
 
          gchar         *name;
129
 
 
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);
134
 
          else
135
 
            name = g_strdup (proc_def->menu_paths->data);
136
 
 
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;
143
 
 
144
 
          g_free (name);
145
 
 
146
 
          i++;
147
 
        }
148
 
 
149
 
      g_slist_free (matched);
150
 
 
151
 
      if (search_str)
152
 
        regfree (&sregex);
153
 
   }
 
62
  num_plugins = gimp_plug_in_manager_query (gimp->plug_in_manager,
 
63
                                            search_string,
 
64
                                            &menu_path,
 
65
                                            &plugin_accelerator,
 
66
                                            &plugin_location,
 
67
                                            &plugin_image_type,
 
68
                                            &plugin_real_name,
 
69
                                            &plugin_install_time);
154
70
}
155
71
CODE
156
72
    );
170
86
procedure is installed.
171
87
HELP
172
88
 
173
 
    $author = $copyright = 'Sven Neumann';
174
 
    $date = '2000';
 
89
    &neo_pdb_misc('2000');
175
90
 
176
91
    @inargs = (
177
92
        { name => 'domain_name', type => 'string',
178
93
          desc => 'The name of the textdomain (must be unique)' },
179
 
        { name => 'domain_path', type => 'string',
 
94
        { name => 'domain_path', type => 'string', no_success => 1,
180
95
          desc => 'The absolute path to the compiled message catalog (may be
181
 
                   NULL)',
182
 
          no_success => 1 },
 
96
                   NULL)' }
183
97
    );
184
98
 
185
99
    %invoke = (
186
 
        code => <<'CODE',
 
100
        code => <<'CODE'
187
101
{
188
 
  if (gimp->current_plug_in && gimp->current_plug_in->query)
 
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)
189
105
    {
190
 
      plug_in_def_set_locale_domain_name (gimp->current_plug_in->plug_in_def,
191
 
                                          domain_name);
192
 
      plug_in_def_set_locale_domain_path (gimp->current_plug_in->plug_in_def,
193
 
                                          domain_path);
 
106
      gimp_plug_in_def_set_locale_domain (plug_in->plug_in_def,
 
107
                                          domain_name, domain_path);
194
108
    }
195
109
  else
196
110
    success = FALSE;
204
118
 
205
119
    $help = <<HELP;
206
120
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
 
121
subsequent calls of gimp_help() from this plug-in will be interpreted relative
208
122
to this rootdir.
209
123
HELP
210
124
 
211
 
    $author = $copyright = 'Michael Natterer <mitch@gimp.org>';
212
 
    $date = '2000';
 
125
    &mitch_pdb_misc('2000');
213
126
 
214
127
    @inargs = (
215
128
        { name => 'domain_name', type => 'string',
219
132
    );
220
133
 
221
134
    %invoke = (
222
 
        code => <<'CODE',
 
135
        code => <<'CODE'
223
136
{
224
 
  if (gimp->current_plug_in && gimp->current_plug_in->query)
 
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)
225
140
    {
226
 
      plug_in_def_set_help_domain_name (gimp->current_plug_in->plug_in_def,
227
 
                                        domain_name);
228
 
      plug_in_def_set_help_domain_uri (gimp->current_plug_in->plug_in_def,
229
 
                                       domain_uri);
 
141
      gimp_plug_in_def_set_help_domain (plug_in->plug_in_def,
 
142
                                        domain_name, domain_uri);
230
143
    }
231
144
  else
232
145
    success = FALSE;
242
155
This procedure installs an additional menu entry for the given procedure.
243
156
HELP
244
157
 
245
 
    $author = $copyright = 'Michael Natterer <mitch@gimp.org>';
246
 
    $date = '2004';
247
 
    $since = '2.2';
 
158
    &mitch_pdb_misc('2004', '2.2');
248
159
 
249
160
    @inargs = (
250
161
        { name => 'procedure_name', type => 'string',
254
165
    );
255
166
 
256
167
    %invoke = (
257
 
        code => <<'CODE',
258
 
{
259
 
  if (gimp->current_plug_in)
260
 
    {
261
 
      PlugInProcDef *proc_def = NULL;
262
 
      GSList        *list;
263
 
 
264
 
      if (gimp->current_plug_in->plug_in_def)
265
 
        {
266
 
          for (list = gimp->current_plug_in->plug_in_def->proc_defs;
267
 
               list;
268
 
               list = g_slist_next (list))
269
 
            {
270
 
              PlugInProcDef *pd = list->data;
271
 
 
272
 
              if (! strcmp (procedure_name, pd->db_info.name))
273
 
                {
274
 
                  proc_def = pd;
275
 
                  break;
276
 
                }
277
 
            }
278
 
        }
279
 
 
280
 
      if (! proc_def)
281
 
        {
282
 
          for (list = gimp->current_plug_in->temp_proc_defs;
283
 
               list;
284
 
               list = g_slist_next (list))
285
 
            {
286
 
              PlugInProcDef *pd = list->data;
287
 
 
288
 
              if (! strcmp (procedure_name, pd->db_info.name))
289
 
                {
290
 
                  proc_def = pd;
291
 
                  break;
292
 
                }
293
 
            }
294
 
        }
295
 
 
296
 
      if (proc_def)
297
 
        {
298
 
          if (proc_def->menu_label)
299
 
            {
300
 
              GError *error = NULL;
301
 
 
302
 
              if (! plug_in_proc_args_check (gimp->current_plug_in->name,
303
 
                                             gimp->current_plug_in->prog,
304
 
                                             procedure_name,
305
 
                                             menu_path,
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,
310
 
                                             &error))
311
 
                {
312
 
                  g_message (error->message);
313
 
                  g_clear_error (&error);
314
 
 
315
 
                  success = FALSE;
316
 
                }
317
 
              else
318
 
                {
319
 
                  switch (proc_def->db_info.proc_type)
320
 
                    {
321
 
                    case GIMP_INTERNAL:
322
 
                      success = FALSE;
323
 
                      break;
324
 
 
325
 
                    case GIMP_PLUGIN:
326
 
                    case GIMP_EXTENSION:
327
 
                      if (! gimp->current_plug_in->query &&
328
 
                          ! gimp->current_plug_in->init)
329
 
                        success = FALSE;
330
 
                      break;
331
 
 
332
 
                    case GIMP_TEMPORARY:
333
 
                      break;
334
 
                    }
335
 
 
336
 
                  if (success)
337
 
                    {
338
 
                      proc_def->menu_paths = g_list_append (proc_def->menu_paths,
339
 
                                                            g_strdup (menu_path));
340
 
 
341
 
                      if (! gimp->no_interface &&
342
 
                          proc_def->db_info.proc_type == GIMP_TEMPORARY)
343
 
                        {
344
 
                          gimp_menus_create_entry (gimp, proc_def, menu_path);
345
 
                        }
346
 
                    }
347
 
                }
348
 
            }
349
 
          else
350
 
            {
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);
361
 
 
362
 
              success = FALSE;
363
 
            }
364
 
        }
365
 
      else
366
 
        success = FALSE;
 
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
      success = FALSE;
 
181
    }
 
182
}
 
183
CODE
 
184
    );
 
185
}
 
186
 
 
187
sub plugin_menu_branch_register {
 
188
    $blurb = "Register a sub-menu.";
 
189
 
 
190
    $help = <<HELP;
 
191
This procedure installs an sub-menu which does not belong to any procedure.
 
192
HELP
 
193
 
 
194
    &mitch_pdb_misc('2005', '2.4');
 
195
 
 
196
    @inargs = (
 
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' }
 
201
    );
 
202
 
 
203
    %invoke = (
 
204
        code => <<'CODE'
 
205
{
 
206
  GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
 
207
 
 
208
  if (plug_in)
 
209
    {
 
210
      gimp_plug_in_manager_add_menu_branch (gimp->plug_in_manager,
 
211
                                            plug_in->prog, menu_path, menu_name);
367
212
    }
368
213
  else
369
214
    success = FALSE;
379
224
This procedure installs an icon for the given procedure.
380
225
HELP
381
226
 
382
 
    $author = $copyright = 'Michael Natterer <mitch@gimp.org>';
383
 
    $date = '2004';
384
 
    $since = '2.2';
 
227
    &mitch_pdb_misc('2004', '2.2');
385
228
 
386
229
    @inargs = (
387
230
        { name => 'procedure_name', type => 'string', wrap => 1,
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'" } }
395
239
    );
396
240
 
397
241
    %invoke = (
398
 
        code => <<'CODE',
 
242
        code => <<'CODE'
399
243
{
400
 
  if (gimp->current_plug_in && gimp->current_plug_in->query)
 
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)
401
247
    {
402
 
      GSList *list;
403
 
 
404
 
      for (list = gimp->current_plug_in->plug_in_def->proc_defs;
405
 
           list;
406
 
           list = g_slist_next (list))
407
 
        {
408
 
          PlugInProcDef *proc_def = list->data;
409
 
 
410
 
          if (! strcmp (procedure_name, proc_def->db_info.name))
411
 
            {
412
 
              if (proc_def->icon_data)
413
 
                {
414
 
                  g_free (proc_def->icon_data);
415
 
                  proc_def->icon_data_length = -1;
416
 
                  proc_def->icon_data        = NULL;
417
 
                }
418
 
 
419
 
              proc_def->icon_type = icon_type;
420
 
 
421
 
              switch (proc_def->icon_type)
422
 
                {
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);
427
 
                  break;
428
 
 
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,
432
 
                                                         icon_data_length);
433
 
                  break;
434
 
                }
435
 
 
436
 
              break;
437
 
            }
438
 
        }
439
 
 
440
 
      if (! list)
 
248
      GimpPlugInProcedure *proc;
 
249
      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
      if (proc)
 
259
        gimp_plug_in_procedure_set_icon (proc, icon_type,
 
260
                                         icon_data, icon_data_length);
 
261
      else
441
262
        success = FALSE;
442
263
    }
443
264
  else
448
269
}
449
270
 
450
271
 
451
 
$extra{app}->{code} = <<'CODE';
452
 
static int
453
 
match_strings (regex_t *preg,
454
 
               gchar   *a)
455
 
{
456
 
  return regexec (preg, a, 0, NULL, 0);
457
 
}
458
 
CODE
459
 
 
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>
 
273
              <stdlib.h>
 
274
              "libgimpbase/gimpbase.h"
 
275
              "core/gimp.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");
465
282
 
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);
 
287
 
 
288
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5]]);
470
289
 
471
290
$desc = 'Plug-in';
472
291