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.
23
#include <glib-object.h>
25
#include "core/core-types.h"
27
#include "core/gimp.h"
29
#include "plug-in-debug.h"
32
struct _GimpPlugInDebug
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}
49
plug_in_debug_init (Gimp *gimp)
52
const gchar *wrap, *wrapper;
57
g_return_if_fail (GIMP_IS_GIMP (gimp));
59
wrap = g_getenv ("GIMP_PLUGIN_DEBUG_WRAP");
60
wrapper = g_getenv ("GIMP_PLUGIN_DEBUG_WRAPPER");
62
if (!(wrap && wrapper))
65
if (!g_shell_parse_argv (wrapper, NULL, &args, &error))
67
g_warning ("Unable to parse debug wrapper: \"%s\"\n%s",
68
wrapper, error->message);
73
dbg = g_new (GimpPlugInDebug, 1);
77
debug_string = strchr (wrap, ',');
81
dbg->name = g_strndup (wrap, debug_string - wrap);
82
dbg->flags = g_parse_debug_string (debug_string + 1,
84
G_N_ELEMENTS (gimp_debug_wrap_keys));
88
dbg->name = g_strdup (wrap);
89
dbg->flags = GIMP_DEBUG_WRAP_DEFAULT;
92
gimp->plug_in_debug = dbg;
96
plug_in_debug_exit (Gimp *gimp)
100
g_return_if_fail (GIMP_IS_GIMP (gimp));
102
dbg = gimp->plug_in_debug;
111
g_strfreev (dbg->args);
115
gimp->plug_in_debug = NULL;
119
plug_in_debug_argv (Gimp *gimp,
121
GimpDebugWrapFlag flag,
124
GimpPlugInDebug *dbg;
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);
132
dbg = gimp->plug_in_debug;
134
if (!(dbg->flags & flag) || (strcmp (dbg->name, name) != 0))
137
argv = g_ptr_array_sized_new (8);
139
for (arg = gimp->plug_in_debug->args; *arg != NULL; arg++)
140
g_ptr_array_add (argv, *arg);
142
for (arg = args; *arg != NULL; arg++)
143
g_ptr_array_add (argv, *arg);
145
g_ptr_array_add (argv, NULL);
147
return (gchar **) g_ptr_array_free (argv, FALSE);