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

« back to all changes in this revision

Viewing changes to app/plug-in/gimppluginmanager-restore.c

  • 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
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995-2002 Spencer Kimball, Peter Mattis, and others
 
3
 *
 
4
 * gimppluginmanager-restore.c
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include <string.h>
 
24
 
 
25
#include <glib-object.h>
 
26
 
 
27
#include "libgimpbase/gimpbase.h"
 
28
#include "libgimpconfig/gimpconfig.h"
 
29
 
 
30
#include "plug-in-types.h"
 
31
 
 
32
#include "config/gimpcoreconfig.h"
 
33
 
 
34
#include "core/gimp.h"
 
35
#include "core/gimpcontext.h"
 
36
 
 
37
#include "pdb/gimppdb.h"
 
38
 
 
39
#include "gimpinterpreterdb.h"
 
40
#include "gimpplugindef.h"
 
41
#include "gimppluginmanager.h"
 
42
#define __YES_I_NEED_GIMP_PLUG_IN_MANAGER_CALL__
 
43
#include "gimppluginmanager-call.h"
 
44
#include "gimppluginmanager-help-domain.h"
 
45
#include "gimppluginmanager-locale-domain.h"
 
46
#include "gimppluginmanager-restore.h"
 
47
#include "gimppluginprocedure.h"
 
48
#include "plug-in-rc.h"
 
49
 
 
50
#include "gimp-intl.h"
 
51
 
 
52
 
 
53
static void    gimp_plug_in_manager_search            (GimpPlugInManager      *manager,
 
54
                                                       GimpInitStatusFunc      status_callback);
 
55
static gchar * gimp_plug_in_manager_get_pluginrc      (GimpPlugInManager      *manager);
 
56
static void    gimp_plug_in_manager_read_pluginrc     (GimpPlugInManager      *manager,
 
57
                                                       const gchar            *pluginrc,
 
58
                                                       GimpInitStatusFunc      status_callback);
 
59
static void    gimp_plug_in_manager_query_new         (GimpPlugInManager      *manager,
 
60
                                                       GimpContext            *context,
 
61
                                                       GimpInitStatusFunc      status_callback);
 
62
static void    gimp_plug_in_manager_init_plug_ins     (GimpPlugInManager      *manager,
 
63
                                                       GimpContext            *context,
 
64
                                                       GimpInitStatusFunc      status_callback);
 
65
static void    gimp_plug_in_manager_run_extensions    (GimpPlugInManager      *manager,
 
66
                                                       GimpContext            *context,
 
67
                                                       GimpInitStatusFunc      status_callback);
 
68
static void    gimp_plug_in_manager_bind_text_domains (GimpPlugInManager      *manager);
 
69
static void    gimp_plug_in_manager_add_from_file     (const GimpDatafileData *file_data,
 
70
                                                       gpointer                data);
 
71
static void    gimp_plug_in_manager_add_from_rc       (GimpPlugInManager      *manager,
 
72
                                                       GimpPlugInDef          *plug_in_def);
 
73
static void     gimp_plug_in_manager_add_to_db         (GimpPlugInManager      *manager,
 
74
                                                        GimpContext            *context,
 
75
                                                        GimpPlugInProcedure    *proc);
 
76
static gint     gimp_plug_in_manager_file_proc_compare (gconstpointer           a,
 
77
                                                        gconstpointer           b,
 
78
                                                        gpointer                data);
 
79
 
 
80
 
 
81
 
 
82
void
 
83
gimp_plug_in_manager_restore (GimpPlugInManager  *manager,
 
84
                              GimpContext        *context,
 
85
                              GimpInitStatusFunc  status_callback)
 
86
{
 
87
  Gimp   *gimp;
 
88
  gchar  *pluginrc;
 
89
  GSList *list;
 
90
  GError *error = NULL;
 
91
 
 
92
  g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
 
93
  g_return_if_fail (GIMP_IS_CONTEXT (context));
 
94
  g_return_if_fail (status_callback != NULL);
 
95
 
 
96
  gimp = manager->gimp;
 
97
 
 
98
  /* search for binaries in the plug-in directory path */
 
99
  gimp_plug_in_manager_search (manager, status_callback);
 
100
 
 
101
  /* read the pluginrc file for cached data */
 
102
  pluginrc = gimp_plug_in_manager_get_pluginrc (manager);
 
103
 
 
104
  gimp_plug_in_manager_read_pluginrc (manager, pluginrc, status_callback);
 
105
 
 
106
  /* query any plug-ins that changed since we last wrote out pluginrc */
 
107
  gimp_plug_in_manager_query_new (manager, context, status_callback);
 
108
 
 
109
  /* initialize the plug-ins */
 
110
  gimp_plug_in_manager_init_plug_ins (manager, context, status_callback);
 
111
 
 
112
  /* add the procedures to manager->plug_in_procedures */
 
113
  for (list = manager->plug_in_defs; list; list = list->next)
 
114
    {
 
115
      GimpPlugInDef *plug_in_def = list->data;
 
116
      GSList        *list2;
 
117
 
 
118
      for (list2 = plug_in_def->procedures; list2; list2 = list2->next)
 
119
        {
 
120
          gimp_plug_in_manager_add_procedure (manager, list2->data);
 
121
        }
 
122
    }
 
123
 
 
124
  /* write the pluginrc file if necessary */
 
125
  if (manager->write_pluginrc)
 
126
    {
 
127
      if (gimp->be_verbose)
 
128
        g_print ("Writing '%s'\n", gimp_filename_to_utf8 (pluginrc));
 
129
 
 
130
      if (! plug_in_rc_write (manager->plug_in_defs, pluginrc, &error))
 
131
        {
 
132
          gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
 
133
          g_clear_error (&error);
 
134
        }
 
135
 
 
136
      manager->write_pluginrc = FALSE;
 
137
    }
 
138
 
 
139
  g_free (pluginrc);
 
140
 
 
141
  /* create locale and help domain lists */
 
142
  for (list = manager->plug_in_defs; list; list = list->next)
 
143
    {
 
144
      GimpPlugInDef *plug_in_def = list->data;
 
145
 
 
146
      if (plug_in_def->locale_domain_name)
 
147
        gimp_plug_in_manager_add_locale_domain (manager,
 
148
                                                plug_in_def->prog,
 
149
                                                plug_in_def->locale_domain_name,
 
150
                                                plug_in_def->locale_domain_path);
 
151
      else
 
152
        /* set the default plug-in locale domain */
 
153
        gimp_plug_in_def_set_locale_domain (plug_in_def,
 
154
                                            gimp_plug_in_manager_get_locale_domain (manager,
 
155
                                                                                    plug_in_def->prog,
 
156
                                                                                    NULL),
 
157
                                            NULL);
 
158
 
 
159
      if (plug_in_def->help_domain_name)
 
160
        gimp_plug_in_manager_add_help_domain (manager,
 
161
                                              plug_in_def->prog,
 
162
                                              plug_in_def->help_domain_name,
 
163
                                              plug_in_def->help_domain_uri);
 
164
    }
 
165
 
 
166
  /* we're done with the plug-in-defs */
 
167
  g_slist_foreach (manager->plug_in_defs, (GFunc) g_object_unref, NULL);
 
168
  g_slist_free (manager->plug_in_defs);
 
169
  manager->plug_in_defs = NULL;
 
170
 
 
171
  /* bind plug-in text domains  */
 
172
  gimp_plug_in_manager_bind_text_domains (manager);
 
173
 
 
174
  /* add the plug-in procs to the procedure database */
 
175
  for (list = manager->plug_in_procedures; list; list = list->next)
 
176
    {
 
177
      gimp_plug_in_manager_add_to_db (manager, context, list->data);
 
178
    }
 
179
 
 
180
  /* sort the load and save procedures  */
 
181
  manager->load_procs =
 
182
    g_slist_sort_with_data (manager->load_procs,
 
183
                            gimp_plug_in_manager_file_proc_compare, manager);
 
184
  manager->save_procs =
 
185
    g_slist_sort_with_data (manager->save_procs,
 
186
                            gimp_plug_in_manager_file_proc_compare, manager);
 
187
 
 
188
  gimp_plug_in_manager_run_extensions (manager, context, status_callback);
 
189
}
 
190
 
 
191
 
 
192
/* search for binaries in the plug-in directory path */
 
193
static void
 
194
gimp_plug_in_manager_search (GimpPlugInManager  *manager,
 
195
                             GimpInitStatusFunc  status_callback)
 
196
{
 
197
  gchar       *path;
 
198
  const gchar *pathext = g_getenv ("PATHEXT");
 
199
 
 
200
  /*  If PATHEXT is set, we are likely on Windows and need to add
 
201
   *  the known file extensions.
 
202
   */
 
203
  if (pathext)
 
204
    {
 
205
      gchar *exts;
 
206
 
 
207
      exts = gimp_interpreter_db_get_extensions (manager->interpreter_db);
 
208
 
 
209
      if (exts)
 
210
        {
 
211
          gchar *value;
 
212
 
 
213
          value = g_strconcat (pathext, G_SEARCHPATH_SEPARATOR_S, exts, NULL);
 
214
 
 
215
          g_setenv ("PATHEXT", value, TRUE);
 
216
 
 
217
          g_free (value);
 
218
          g_free (exts);
 
219
        }
 
220
    }
 
221
 
 
222
  status_callback (_("Searching Plug-Ins"), "", 0.0);
 
223
 
 
224
  path = gimp_config_path_expand (manager->gimp->config->plug_in_path,
 
225
                                  TRUE, NULL);
 
226
 
 
227
  gimp_datafiles_read_directories (path,
 
228
                                   G_FILE_TEST_IS_EXECUTABLE,
 
229
                                   gimp_plug_in_manager_add_from_file,
 
230
                                   manager);
 
231
 
 
232
  g_free (path);
 
233
}
 
234
 
 
235
static gchar *
 
236
gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager)
 
237
{
 
238
  Gimp  *gimp = manager->gimp;
 
239
  gchar *pluginrc;
 
240
 
 
241
  if (gimp->config->plug_in_rc_path)
 
242
    {
 
243
      pluginrc = gimp_config_path_expand (gimp->config->plug_in_rc_path,
 
244
                                          TRUE, NULL);
 
245
 
 
246
      if (! g_path_is_absolute (pluginrc))
 
247
        {
 
248
          gchar *str = g_build_filename (gimp_directory (), pluginrc, NULL);
 
249
 
 
250
          g_free (pluginrc);
 
251
          pluginrc = str;
 
252
        }
 
253
    }
 
254
  else
 
255
    {
 
256
      pluginrc = gimp_personal_rc_file ("pluginrc");
 
257
    }
 
258
 
 
259
  return pluginrc;
 
260
}
 
261
 
 
262
/* read the pluginrc file for cached data */
 
263
static void
 
264
gimp_plug_in_manager_read_pluginrc (GimpPlugInManager  *manager,
 
265
                                    const gchar        *pluginrc,
 
266
                                    GimpInitStatusFunc  status_callback)
 
267
{
 
268
  GSList *rc_defs;
 
269
  GError *error = NULL;
 
270
 
 
271
  status_callback (_("Resource configuration"),
 
272
                   gimp_filename_to_utf8 (pluginrc), 0.0);
 
273
 
 
274
  if (manager->gimp->be_verbose)
 
275
    g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (pluginrc));
 
276
 
 
277
  rc_defs = plug_in_rc_parse (manager->gimp, pluginrc, &error);
 
278
 
 
279
  if (rc_defs)
 
280
    {
 
281
      GSList *list;
 
282
 
 
283
      for (list = rc_defs; list; list = g_slist_next (list))
 
284
        gimp_plug_in_manager_add_from_rc (manager, list->data); /* consumes list->data */
 
285
 
 
286
      g_slist_free (rc_defs);
 
287
    }
 
288
  else if (error)
 
289
    {
 
290
      if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
 
291
        gimp_message (manager->gimp, NULL, GIMP_MESSAGE_ERROR,
 
292
                      "%s", error->message);
 
293
 
 
294
      g_clear_error (&error);
 
295
    }
 
296
}
 
297
 
 
298
/* query any plug-ins that changed since we last wrote out pluginrc */
 
299
static void
 
300
gimp_plug_in_manager_query_new (GimpPlugInManager  *manager,
 
301
                                GimpContext        *context,
 
302
                                GimpInitStatusFunc  status_callback)
 
303
{
 
304
  GSList *list;
 
305
  gint    n_plugins;
 
306
 
 
307
  status_callback (_("Querying new Plug-ins"), "", 0.0);
 
308
 
 
309
  for (list = manager->plug_in_defs, n_plugins = 0; list; list = list->next)
 
310
    {
 
311
      GimpPlugInDef *plug_in_def = list->data;
 
312
 
 
313
      if (plug_in_def->needs_query)
 
314
        n_plugins++;
 
315
    }
 
316
 
 
317
  if (n_plugins)
 
318
    {
 
319
      gint nth;
 
320
 
 
321
      manager->write_pluginrc = TRUE;
 
322
 
 
323
      for (list = manager->plug_in_defs, nth = 0; list; list = list->next)
 
324
        {
 
325
          GimpPlugInDef *plug_in_def = list->data;
 
326
 
 
327
          if (plug_in_def->needs_query)
 
328
            {
 
329
              gchar *basename;
 
330
 
 
331
              basename = g_filename_display_basename (plug_in_def->prog);
 
332
              status_callback (NULL, basename,
 
333
                               (gdouble) nth++ / (gdouble) n_plugins);
 
334
              g_free (basename);
 
335
 
 
336
              if (manager->gimp->be_verbose)
 
337
                g_print ("Querying plug-in: '%s'\n",
 
338
                         gimp_filename_to_utf8 (plug_in_def->prog));
 
339
 
 
340
              gimp_plug_in_manager_call_query (manager, context, plug_in_def);
 
341
            }
 
342
        }
 
343
    }
 
344
 
 
345
  status_callback (NULL, "", 1.0);
 
346
}
 
347
 
 
348
/* initialize the plug-ins */
 
349
static void
 
350
gimp_plug_in_manager_init_plug_ins (GimpPlugInManager  *manager,
 
351
                                    GimpContext        *context,
 
352
                                    GimpInitStatusFunc  status_callback)
 
353
{
 
354
  GSList *list;
 
355
  gint    n_plugins;
 
356
 
 
357
  status_callback (_("Initializing Plug-ins"), "", 0.0);
 
358
 
 
359
  for (list = manager->plug_in_defs, n_plugins = 0; list; list = list->next)
 
360
    {
 
361
      GimpPlugInDef *plug_in_def = list->data;
 
362
 
 
363
      if (plug_in_def->has_init)
 
364
        n_plugins++;
 
365
    }
 
366
 
 
367
  if (n_plugins)
 
368
    {
 
369
      gint nth;
 
370
 
 
371
      for (list = manager->plug_in_defs, nth = 0; list; list = list->next)
 
372
        {
 
373
          GimpPlugInDef *plug_in_def = list->data;
 
374
 
 
375
          if (plug_in_def->has_init)
 
376
            {
 
377
              gchar *basename;
 
378
 
 
379
              basename = g_filename_display_basename (plug_in_def->prog);
 
380
              status_callback (NULL, basename,
 
381
                               (gdouble) nth++ / (gdouble) n_plugins);
 
382
              g_free (basename);
 
383
 
 
384
              if (manager->gimp->be_verbose)
 
385
                g_print ("Initializing plug-in: '%s'\n",
 
386
                         gimp_filename_to_utf8 (plug_in_def->prog));
 
387
 
 
388
              gimp_plug_in_manager_call_init (manager, context, plug_in_def);
 
389
            }
 
390
        }
 
391
    }
 
392
 
 
393
  status_callback (NULL, "", 1.0);
 
394
}
 
395
 
 
396
/* run automatically started extensions */
 
397
static void
 
398
gimp_plug_in_manager_run_extensions (GimpPlugInManager  *manager,
 
399
                                     GimpContext        *context,
 
400
                                     GimpInitStatusFunc  status_callback)
 
401
{
 
402
  Gimp   *gimp = manager->gimp;
 
403
  GSList *list;
 
404
  GList  *extensions = NULL;
 
405
  gint    n_extensions;
 
406
 
 
407
  /* build list of automatically started extensions */
 
408
  for (list = manager->plug_in_procedures; list; list = list->next)
 
409
    {
 
410
      GimpPlugInProcedure *proc = list->data;
 
411
 
 
412
      if (proc->prog                                         &&
 
413
          GIMP_PROCEDURE (proc)->proc_type == GIMP_EXTENSION &&
 
414
          GIMP_PROCEDURE (proc)->num_args  == 0)
 
415
        {
 
416
          extensions = g_list_prepend (extensions, proc);
 
417
        }
 
418
    }
 
419
 
 
420
  extensions   = g_list_reverse (extensions);
 
421
  n_extensions = g_list_length (extensions);
 
422
 
 
423
  /* run the available extensions */
 
424
  if (extensions)
 
425
    {
 
426
      GList *list;
 
427
      gint   nth;
 
428
 
 
429
      status_callback (_("Starting Extensions"), "", 0.0);
 
430
 
 
431
      for (list = extensions, nth = 0; list; list = g_list_next (list), nth++)
 
432
        {
 
433
          GimpPlugInProcedure *proc = list->data;
 
434
          GValueArray         *args;
 
435
 
 
436
          if (gimp->be_verbose)
 
437
            g_print ("Starting extension: '%s'\n", GIMP_OBJECT (proc)->name);
 
438
 
 
439
          status_callback (NULL, GIMP_OBJECT (proc)->name,
 
440
                           (gdouble) nth / (gdouble) n_extensions);
 
441
 
 
442
          args = g_value_array_new (0);
 
443
 
 
444
          gimp_procedure_execute_async (GIMP_PROCEDURE (proc),
 
445
                                        gimp, context, NULL, args, NULL);
 
446
 
 
447
          g_value_array_free (args);
 
448
        }
 
449
 
 
450
      g_list_free (extensions);
 
451
 
 
452
      status_callback (NULL, "", 1.0);
 
453
    }
 
454
}
 
455
 
 
456
static void
 
457
gimp_plug_in_manager_bind_text_domains (GimpPlugInManager *manager)
 
458
{
 
459
  gchar **locale_domains;
 
460
  gchar **locale_paths;
 
461
  gint    n_domains;
 
462
  gint    i;
 
463
 
 
464
  n_domains = gimp_plug_in_manager_get_locale_domains (manager,
 
465
                                                       &locale_domains,
 
466
                                                       &locale_paths);
 
467
 
 
468
  for (i = 0; i < n_domains; i++)
 
469
    {
 
470
      bindtextdomain (locale_domains[i], locale_paths[i]);
 
471
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
 
472
      bind_textdomain_codeset (locale_domains[i], "UTF-8");
 
473
#endif
 
474
    }
 
475
 
 
476
  g_strfreev (locale_domains);
 
477
  g_strfreev (locale_paths);
 
478
}
 
479
 
 
480
static void
 
481
gimp_plug_in_manager_add_from_file (const GimpDatafileData *file_data,
 
482
                                    gpointer                data)
 
483
{
 
484
  GimpPlugInManager *manager = data;
 
485
  GimpPlugInDef     *plug_in_def;
 
486
  GSList            *list;
 
487
 
 
488
  for (list = manager->plug_in_defs; list; list = list->next)
 
489
    {
 
490
      gchar *plug_in_name;
 
491
 
 
492
      plug_in_def  = list->data;
 
493
      plug_in_name = g_path_get_basename (plug_in_def->prog);
 
494
 
 
495
      if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0)
 
496
        {
 
497
          g_printerr ("Skipping duplicate plug-in: '%s'\n",
 
498
                      gimp_filename_to_utf8 (file_data->filename));
 
499
 
 
500
          g_free (plug_in_name);
 
501
 
 
502
          return;
 
503
        }
 
504
 
 
505
      g_free (plug_in_name);
 
506
    }
 
507
 
 
508
  plug_in_def = gimp_plug_in_def_new (file_data->filename);
 
509
 
 
510
  gimp_plug_in_def_set_mtime (plug_in_def, file_data->mtime);
 
511
  gimp_plug_in_def_set_needs_query (plug_in_def, TRUE);
 
512
 
 
513
  manager->plug_in_defs = g_slist_prepend (manager->plug_in_defs, plug_in_def);
 
514
}
 
515
 
 
516
static void
 
517
gimp_plug_in_manager_add_from_rc (GimpPlugInManager *manager,
 
518
                                  GimpPlugInDef     *plug_in_def)
 
519
{
 
520
  GSList *list;
 
521
  gchar  *basename1;
 
522
 
 
523
  g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
 
524
  g_return_if_fail (plug_in_def != NULL);
 
525
  g_return_if_fail (plug_in_def->prog != NULL);
 
526
 
 
527
  if (! g_path_is_absolute (plug_in_def->prog))
 
528
    {
 
529
      g_warning ("plug_ins_def_add_from_rc: filename not absolute (skipping)");
 
530
      g_object_unref (plug_in_def);
 
531
      return;
 
532
    }
 
533
 
 
534
  basename1 = g_path_get_basename (plug_in_def->prog);
 
535
 
 
536
  /*  If this is a file load or save plugin, make sure we have
 
537
   *  something for one of the extensions, prefixes, or magic number.
 
538
   *  Other bits of code rely on detecting file plugins by the
 
539
   *  presence of one of these things, but the raw plug-in needs to be
 
540
   *  able to register no extensions, prefixes or magics.
 
541
   */
 
542
  for (list = plug_in_def->procedures; list; list = list->next)
 
543
    {
 
544
      GimpPlugInProcedure *proc = list->data;
 
545
 
 
546
      if (! proc->extensions &&
 
547
          ! proc->prefixes   &&
 
548
          ! proc->magics     &&
 
549
          proc->menu_paths   &&
 
550
          (g_str_has_prefix (proc->menu_paths->data, "<Load>") ||
 
551
           g_str_has_prefix (proc->menu_paths->data, "<Save>")))
 
552
        {
 
553
          proc->extensions = g_strdup ("");
 
554
        }
 
555
    }
 
556
 
 
557
  /*  Check if the entry mentioned in pluginrc matches an executable
 
558
   *  found in the plug_in_path.
 
559
   */
 
560
  for (list = manager->plug_in_defs; list; list = list->next)
 
561
    {
 
562
      GimpPlugInDef *ondisk_plug_in_def = list->data;
 
563
      gchar         *basename2;
 
564
 
 
565
      basename2 = g_path_get_basename (ondisk_plug_in_def->prog);
 
566
 
 
567
      if (! strcmp (basename1, basename2))
 
568
        {
 
569
          if (! g_ascii_strcasecmp (plug_in_def->prog,
 
570
                                    ondisk_plug_in_def->prog) &&
 
571
              (plug_in_def->mtime == ondisk_plug_in_def->mtime))
 
572
            {
 
573
              /* Use pluginrc entry, deleting ondisk entry */
 
574
              list->data = plug_in_def;
 
575
              g_object_unref (ondisk_plug_in_def);
 
576
            }
 
577
          else
 
578
            {
 
579
              /* Use ondisk entry, deleting pluginrc entry */
 
580
              g_object_unref (plug_in_def);
 
581
            }
 
582
 
 
583
          g_free (basename2);
 
584
          g_free (basename1);
 
585
 
 
586
          return;
 
587
        }
 
588
 
 
589
      g_free (basename2);
 
590
    }
 
591
 
 
592
  g_free (basename1);
 
593
 
 
594
  manager->write_pluginrc = TRUE;
 
595
  g_printerr ("Executable not found: '%s'\n",
 
596
              gimp_filename_to_utf8 (plug_in_def->prog));
 
597
  g_object_unref (plug_in_def);
 
598
}
 
599
 
 
600
 
 
601
static void
 
602
gimp_plug_in_manager_add_to_db (GimpPlugInManager   *manager,
 
603
                                GimpContext         *context,
 
604
                                GimpPlugInProcedure *proc)
 
605
{
 
606
  gimp_pdb_register_procedure (manager->gimp->pdb, GIMP_PROCEDURE (proc));
 
607
 
 
608
  if (proc->file_proc)
 
609
    {
 
610
      GValueArray *return_vals;
 
611
 
 
612
      if (proc->image_types)
 
613
        {
 
614
          return_vals =
 
615
            gimp_pdb_execute_procedure_by_name (manager->gimp->pdb,
 
616
                                                context, NULL,
 
617
                                                "gimp-register-save-handler",
 
618
                                                G_TYPE_STRING, GIMP_OBJECT (proc)->name,
 
619
                                                G_TYPE_STRING, proc->extensions,
 
620
                                                G_TYPE_STRING, proc->prefixes,
 
621
                                                G_TYPE_NONE);
 
622
        }
 
623
      else
 
624
        {
 
625
          return_vals =
 
626
            gimp_pdb_execute_procedure_by_name (manager->gimp->pdb,
 
627
                                                context, NULL,
 
628
                                                "gimp-register-magic-load-handler",
 
629
                                                G_TYPE_STRING, GIMP_OBJECT (proc)->name,
 
630
                                                G_TYPE_STRING, proc->extensions,
 
631
                                                G_TYPE_STRING, proc->prefixes,
 
632
                                                G_TYPE_STRING, proc->magics,
 
633
                                                G_TYPE_NONE);
 
634
        }
 
635
 
 
636
      g_value_array_free (return_vals);
 
637
    }
 
638
}
 
639
 
 
640
static gint
 
641
gimp_plug_in_manager_file_proc_compare (gconstpointer a,
 
642
                                        gconstpointer b,
 
643
                                        gpointer      data)
 
644
{
 
645
  GimpPlugInProcedure *proc_a = GIMP_PLUG_IN_PROCEDURE (a);
 
646
  GimpPlugInProcedure *proc_b = GIMP_PLUG_IN_PROCEDURE (b);
 
647
  const gchar         *label_a;
 
648
  const gchar         *label_b;
 
649
  gint                 retval = 0;
 
650
 
 
651
  if (g_str_has_prefix (proc_a->prog, "gimp-xcf"))
 
652
    return -1;
 
653
 
 
654
  if (g_str_has_prefix (proc_b->prog, "gimp-xcf"))
 
655
    return 1;
 
656
 
 
657
  label_a = gimp_plug_in_procedure_get_label (proc_a);
 
658
  label_b = gimp_plug_in_procedure_get_label (proc_b);
 
659
 
 
660
  if (label_a && label_b)
 
661
    retval = g_utf8_collate (label_a, label_b);
 
662
 
 
663
  return retval;
 
664
}