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

« back to all changes in this revision

Viewing changes to app/plug-in/plug-in-debug.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
 
/* The GIMP -- an image manipulation program
2
 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
 
 *
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.
8
 
 *
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.
13
 
 *
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.
17
 
 */
18
 
 
19
 
#include "config.h"
20
 
 
21
 
#include <string.h>
22
 
 
23
 
#include <glib-object.h>
24
 
 
25
 
#include "core/core-types.h"
26
 
 
27
 
#include "core/gimp.h"
28
 
 
29
 
#include "plug-in-debug.h"
30
 
 
31
 
 
32
 
struct _GimpPlugInDebug
33
 
{
34
 
  gchar  *name;
35
 
  guint   flags;
36
 
  gchar **args;
37
 
};
38
 
 
39
 
 
40
 
static const GDebugKey gimp_debug_wrap_keys[] = {
41
 
  {"query", GIMP_DEBUG_WRAP_QUERY},
42
 
  {"init",  GIMP_DEBUG_WRAP_INIT},
43
 
  {"run",   GIMP_DEBUG_WRAP_RUN},
44
 
  {"on",    GIMP_DEBUG_WRAP_DEFAULT}
45
 
};
46
 
 
47
 
 
48
 
void
49
 
plug_in_debug_init (Gimp *gimp)
50
 
{
51
 
  GimpPlugInDebug  *dbg;
52
 
  const gchar      *wrap, *wrapper;
53
 
  gchar            *debug_string;
54
 
  gchar           **args;
55
 
  GError           *error = NULL;
56
 
 
57
 
  g_return_if_fail (GIMP_IS_GIMP (gimp));
58
 
 
59
 
  wrap = g_getenv ("GIMP_PLUGIN_DEBUG_WRAP");
60
 
  wrapper = g_getenv ("GIMP_PLUGIN_DEBUG_WRAPPER");
61
 
 
62
 
  if (!(wrap && wrapper))
63
 
    return;
64
 
 
65
 
  if (!g_shell_parse_argv (wrapper, NULL, &args, &error))
66
 
    {
67
 
      g_warning ("Unable to parse debug wrapper: \"%s\"\n%s",
68
 
                 wrapper, error->message);
69
 
      g_error_free (error);
70
 
      return;
71
 
    }
72
 
 
73
 
  dbg = g_new (GimpPlugInDebug, 1);
74
 
 
75
 
  dbg->args  = args;
76
 
 
77
 
  debug_string = strchr (wrap, ',');
78
 
 
79
 
  if (debug_string)
80
 
    {
81
 
      dbg->name = g_strndup (wrap, debug_string - wrap);
82
 
      dbg->flags = g_parse_debug_string (debug_string + 1,
83
 
                                         gimp_debug_wrap_keys,
84
 
                                         G_N_ELEMENTS (gimp_debug_wrap_keys));
85
 
    }
86
 
  else
87
 
    {
88
 
      dbg->name = g_strdup (wrap);
89
 
      dbg->flags = GIMP_DEBUG_WRAP_DEFAULT;
90
 
    }
91
 
  
92
 
  gimp->plug_in_debug = dbg;
93
 
}
94
 
 
95
 
void
96
 
plug_in_debug_exit (Gimp *gimp)
97
 
{
98
 
  GimpPlugInDebug *dbg;
99
 
 
100
 
  g_return_if_fail (GIMP_IS_GIMP (gimp));
101
 
 
102
 
  dbg = gimp->plug_in_debug;
103
 
 
104
 
  if (dbg == NULL)
105
 
    return;
106
 
 
107
 
  if (dbg->name)
108
 
    g_free (dbg->name);
109
 
 
110
 
  if (dbg->args)
111
 
    g_strfreev (dbg->args);
112
 
 
113
 
  g_free (dbg);
114
 
 
115
 
  gimp->plug_in_debug = NULL;
116
 
}
117
 
 
118
 
gchar **
119
 
plug_in_debug_argv (Gimp               *gimp,
120
 
                    const gchar        *name,
121
 
                    GimpDebugWrapFlag   flag,
122
 
                    gchar             **args)
123
 
{
124
 
  GimpPlugInDebug  *dbg;
125
 
  GPtrArray        *argv;
126
 
  gchar           **arg;
127
 
 
128
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
129
 
  g_return_val_if_fail (gimp->plug_in_debug != NULL, NULL);
130
 
  g_return_val_if_fail (args != NULL, NULL);
131
 
 
132
 
  dbg = gimp->plug_in_debug;
133
 
 
134
 
  if (!(dbg->flags & flag) || (strcmp (dbg->name, name) != 0))
135
 
    return NULL;
136
 
 
137
 
  argv = g_ptr_array_sized_new (8);
138
 
 
139
 
  for (arg = gimp->plug_in_debug->args; *arg != NULL; arg++)
140
 
    g_ptr_array_add (argv, *arg);
141
 
 
142
 
  for (arg = args; *arg != NULL; arg++)
143
 
    g_ptr_array_add (argv, *arg);
144
 
 
145
 
  g_ptr_array_add (argv, NULL);
146
 
 
147
 
  return (gchar **) g_ptr_array_free (argv, FALSE);
148
 
}