2001-12-28 07:45:12 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2004-09-22 23:12:24 +08:00
|
|
|
* plug-in-rc.c
|
2001-12-28 07:45:12 +08:00
|
|
|
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpbase/gimpprotocol.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-11-08 07:47:35 +08:00
|
|
|
|
2001-12-28 07:45:12 +08:00
|
|
|
#include "plug-in-types.h"
|
|
|
|
|
2003-02-11 20:07:31 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-ins.h"
|
|
|
|
#include "plug-in-def.h"
|
2004-09-22 23:12:24 +08:00
|
|
|
#include "plug-in-proc-def.h"
|
2001-12-28 07:45:12 +08:00
|
|
|
#include "plug-in-rc.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-12-28 07:45:12 +08:00
|
|
|
|
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
/*
|
2002-03-28 07:15:00 +08:00
|
|
|
* All deserialize functions return G_TOKEN_LEFT_PAREN on success,
|
2001-12-29 06:58:14 +08:00
|
|
|
* or the GTokenType they would have expected but didn't get.
|
|
|
|
*/
|
|
|
|
|
2003-02-11 20:07:31 +08:00
|
|
|
static GTokenType plug_in_def_deserialize (Gimp *gimp,
|
|
|
|
GScanner *scanner);
|
2001-12-28 07:45:12 +08:00
|
|
|
static GTokenType plug_in_proc_def_deserialize (GScanner *scanner,
|
2006-03-29 03:58:00 +08:00
|
|
|
Gimp *gimp,
|
2001-12-28 07:45:12 +08:00
|
|
|
PlugInProcDef *proc_def);
|
2004-05-06 21:51:56 +08:00
|
|
|
static GTokenType plug_in_menu_path_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def);
|
2004-05-19 05:19:43 +08:00
|
|
|
static GTokenType plug_in_icon_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def);
|
2005-04-25 20:42:26 +08:00
|
|
|
static GTokenType plug_in_file_proc_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def);
|
2001-12-28 07:45:12 +08:00
|
|
|
static GTokenType plug_in_proc_arg_deserialize (GScanner *scanner,
|
2006-03-29 03:58:00 +08:00
|
|
|
Gimp *gimp,
|
|
|
|
ProcRecord *proc,
|
|
|
|
gboolean return_value);
|
2001-12-28 07:45:12 +08:00
|
|
|
static GTokenType plug_in_locale_def_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def);
|
|
|
|
static GTokenType plug_in_help_def_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def);
|
2002-02-12 15:59:16 +08:00
|
|
|
static GTokenType plug_in_has_init_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2003-11-08 07:47:35 +08:00
|
|
|
PROTOCOL_VERSION = 1,
|
|
|
|
PLUG_IN_DEF,
|
2001-12-28 07:45:12 +08:00
|
|
|
PROC_DEF,
|
|
|
|
LOCALE_DEF,
|
2001-12-29 06:58:14 +08:00
|
|
|
HELP_DEF,
|
2002-02-12 15:59:16 +08:00
|
|
|
HAS_INIT,
|
2004-05-06 21:51:56 +08:00
|
|
|
PROC_ARG,
|
2004-05-14 08:01:11 +08:00
|
|
|
MENU_PATH,
|
2004-05-19 05:19:43 +08:00
|
|
|
ICON,
|
2005-04-25 20:42:26 +08:00
|
|
|
LOAD_PROC,
|
|
|
|
SAVE_PROC,
|
|
|
|
EXTENSION,
|
|
|
|
PREFIX,
|
|
|
|
MAGIC,
|
2004-11-14 01:06:06 +08:00
|
|
|
MIME_TYPE,
|
|
|
|
THUMB_LOADER
|
2001-12-28 07:45:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
gboolean
|
2003-11-08 07:47:35 +08:00
|
|
|
plug_in_rc_parse (Gimp *gimp,
|
|
|
|
const gchar *filename,
|
|
|
|
GError **error)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
|
|
|
GScanner *scanner;
|
2004-05-19 05:19:43 +08:00
|
|
|
GEnumClass *enum_class;
|
2001-12-28 07:45:12 +08:00
|
|
|
GTokenType token;
|
2003-11-08 07:47:35 +08:00
|
|
|
gboolean retval = FALSE;
|
|
|
|
gint version = GIMP_PROTOCOL_VERSION;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2003-02-11 20:07:31 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
2001-12-28 07:45:12 +08:00
|
|
|
g_return_val_if_fail (filename != NULL, FALSE);
|
2003-11-08 07:47:35 +08:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
scanner = gimp_scanner_new_file (filename, error);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! scanner)
|
2004-02-09 02:49:58 +08:00
|
|
|
return FALSE;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE);
|
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0,
|
|
|
|
"protocol-version",
|
|
|
|
GINT_TO_POINTER (PROTOCOL_VERSION));
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0,
|
2001-12-29 06:58:14 +08:00
|
|
|
"plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF));
|
2005-04-25 20:42:26 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2001-12-28 07:45:12 +08:00
|
|
|
"proc-def", GINT_TO_POINTER (PROC_DEF));
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2001-12-28 07:45:12 +08:00
|
|
|
"locale-def", GINT_TO_POINTER (LOCALE_DEF));
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2001-12-28 07:45:12 +08:00
|
|
|
"help-def", GINT_TO_POINTER (HELP_DEF));
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2002-02-12 15:59:16 +08:00
|
|
|
"has-init", GINT_TO_POINTER (HAS_INIT));
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2001-12-29 06:58:14 +08:00
|
|
|
"proc-arg", GINT_TO_POINTER (PROC_ARG));
|
2004-05-06 21:51:56 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
|
|
|
"menu-path", GINT_TO_POINTER (MENU_PATH));
|
2004-05-19 05:19:43 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
|
|
|
"icon", GINT_TO_POINTER (ICON));
|
2004-05-14 08:01:11 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2005-04-25 20:42:26 +08:00
|
|
|
"load-proc", GINT_TO_POINTER (LOAD_PROC));
|
2004-11-14 01:06:06 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
|
2005-04-25 20:42:26 +08:00
|
|
|
"save-proc", GINT_TO_POINTER (SAVE_PROC));
|
|
|
|
|
|
|
|
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
|
|
|
|
"extension", GINT_TO_POINTER (EXTENSION));
|
|
|
|
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
|
|
|
|
"prefix", GINT_TO_POINTER (PREFIX));
|
|
|
|
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
|
|
|
|
"magic", GINT_TO_POINTER (MAGIC));
|
|
|
|
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
|
|
|
|
"mime-type", GINT_TO_POINTER (MIME_TYPE));
|
|
|
|
g_scanner_scope_add_symbol (scanner, LOAD_PROC,
|
2004-11-14 01:06:06 +08:00
|
|
|
"thumb-loader", GINT_TO_POINTER (THUMB_LOADER));
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
|
|
|
|
"extension", GINT_TO_POINTER (EXTENSION));
|
|
|
|
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
|
|
|
|
"prefix", GINT_TO_POINTER (PREFIX));
|
|
|
|
g_scanner_scope_add_symbol (scanner, SAVE_PROC,
|
|
|
|
"mime-type", GINT_TO_POINTER (MIME_TYPE));
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
while (version == GIMP_PROTOCOL_VERSION &&
|
|
|
|
g_scanner_peek_next_token (scanner) == token)
|
2002-05-31 21:58:18 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
token = g_scanner_get_next_token (scanner);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
switch (token)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
case G_TOKEN_LEFT_PAREN:
|
2001-12-28 07:45:12 +08:00
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
break;
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
case G_TOKEN_SYMBOL:
|
2003-11-08 07:47:35 +08:00
|
|
|
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
2002-03-28 07:15:00 +08:00
|
|
|
{
|
2003-11-08 07:47:35 +08:00
|
|
|
case PROTOCOL_VERSION:
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
if (gimp_scanner_parse_int (scanner, &version))
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
break;
|
|
|
|
case PLUG_IN_DEF:
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_set_scope (scanner, PLUG_IN_DEF);
|
2003-02-11 20:07:31 +08:00
|
|
|
token = plug_in_def_deserialize (gimp, scanner);
|
2002-03-28 07:15:00 +08:00
|
|
|
g_scanner_set_scope (scanner, 0);
|
2003-11-08 07:47:35 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-03-28 07:15:00 +08:00
|
|
|
}
|
2003-11-08 07:47:35 +08:00
|
|
|
break;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
default: /* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
if (version != GIMP_PROTOCOL_VERSION)
|
|
|
|
{
|
|
|
|
g_set_error (error,
|
|
|
|
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION,
|
2004-01-14 10:03:37 +08:00
|
|
|
_("Skipping '%s': wrong GIMP protocol version."),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename));
|
2003-11-08 07:47:35 +08:00
|
|
|
}
|
|
|
|
else if (token != G_TOKEN_LEFT_PAREN)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
|
|
_("fatal parse error"), TRUE);
|
2003-11-08 07:47:35 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
g_type_class_unref (enum_class);
|
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
gimp_scanner_destroy (scanner);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
return retval;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GTokenType
|
2003-02-11 20:07:31 +08:00
|
|
|
plug_in_def_deserialize (Gimp *gimp,
|
|
|
|
GScanner *scanner)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
gchar *name;
|
|
|
|
PlugInDef *plug_in_def;
|
|
|
|
PlugInProcDef *proc_def;
|
|
|
|
GTokenType token;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &name))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
|
|
|
plug_in_def = plug_in_def_new (name);
|
2002-03-22 23:21:18 +08:00
|
|
|
g_free (name);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, (gint *) &plug_in_def->mtime))
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
plug_in_def_free (plug_in_def, TRUE);
|
|
|
|
return G_TOKEN_INT;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-05-31 21:58:18 +08:00
|
|
|
while (g_scanner_peek_next_token (scanner) == token)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
switch (token)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
token = G_TOKEN_SYMBOL;
|
2001-12-28 07:45:12 +08:00
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
case G_TOKEN_SYMBOL:
|
|
|
|
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
|
|
|
{
|
|
|
|
case PROC_DEF:
|
2003-01-18 02:07:37 +08:00
|
|
|
proc_def = plug_in_proc_def_new ();
|
2006-03-29 03:58:00 +08:00
|
|
|
token = plug_in_proc_def_deserialize (scanner, gimp, proc_def);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
if (token == G_TOKEN_LEFT_PAREN)
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def_add_proc_def (plug_in_def, proc_def);
|
2001-12-29 06:58:14 +08:00
|
|
|
else
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_proc_def_free (proc_def);
|
2001-12-29 06:58:14 +08:00
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
case LOCALE_DEF:
|
|
|
|
token = plug_in_locale_def_deserialize (scanner, plug_in_def);
|
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
case HELP_DEF:
|
|
|
|
token = plug_in_help_def_deserialize (scanner, plug_in_def);
|
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
case HAS_INIT:
|
|
|
|
token = plug_in_has_init_deserialize (scanner, plug_in_def);
|
|
|
|
break;
|
2001-12-29 06:58:14 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
}
|
2001-12-29 06:58:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
break;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2001-12-28 07:45:12 +08:00
|
|
|
default:
|
2001-12-29 06:58:14 +08:00
|
|
|
break;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
if (token == G_TOKEN_LEFT_PAREN)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2001-12-29 06:58:14 +08:00
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (gimp_scanner_parse_token (scanner, token))
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-02-11 20:07:31 +08:00
|
|
|
plug_ins_def_add_from_rc (gimp, plug_in_def);
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
|
|
|
}
|
2001-12-28 07:45:12 +08:00
|
|
|
|
|
|
|
plug_in_def_free (plug_in_def, TRUE);
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2001-12-28 07:45:12 +08:00
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GTokenType
|
|
|
|
plug_in_proc_def_deserialize (GScanner *scanner,
|
2006-03-29 03:58:00 +08:00
|
|
|
Gimp *gimp,
|
2001-12-28 07:45:12 +08:00
|
|
|
PlugInProcDef *proc_def)
|
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
ProcRecord *procedure;
|
|
|
|
GTokenType token;
|
|
|
|
gint n_args;
|
|
|
|
gint n_return_vals;
|
|
|
|
gint n_menu_paths;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
procedure = proc_def->procedure;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->original_name))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2005-08-03 06:52:23 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->name = gimp_canonicalize_identifier (procedure->original_name);
|
2005-08-03 06:52:23 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, (gint *) &procedure->proc_type))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_INT;
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->blurb))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->help))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->author))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->copyright))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2006-03-31 19:49:22 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &procedure->date))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2004-05-07 08:30:24 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &proc_def->menu_label))
|
|
|
|
return G_TOKEN_STRING;
|
2004-05-06 21:51:56 +08:00
|
|
|
|
|
|
|
if (! gimp_scanner_parse_int (scanner, &n_menu_paths))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2004-05-06 21:51:56 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_menu_paths; i++)
|
|
|
|
{
|
|
|
|
token = plug_in_menu_path_deserialize (scanner, proc_def);
|
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
token = plug_in_icon_deserialize (scanner, proc_def);
|
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
return token;
|
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
token = plug_in_file_proc_deserialize (scanner, proc_def);
|
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
return token;
|
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
if (! gimp_scanner_parse_string (scanner, &proc_def->image_types))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_STRING;
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
proc_def->image_types_val =
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_ins_image_types_parse (proc_def->image_types);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, (gint *) &n_args))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_INT;
|
2006-03-29 03:58:00 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, (gint *) &n_return_vals))
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_INT;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_procedure_init (procedure, n_args, n_return_vals);
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
for (i = 0; i < n_args; i++)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
token = plug_in_proc_arg_deserialize (scanner, gimp, procedure, FALSE);
|
2001-12-29 06:58:14 +08:00
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
2001-12-28 07:45:12 +08:00
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
for (i = 0; i < n_return_vals; i++)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
token = plug_in_proc_arg_deserialize (scanner, gimp, procedure, TRUE);
|
2001-12-29 06:58:14 +08:00
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
2001-12-28 07:45:12 +08:00
|
|
|
return token;
|
|
|
|
}
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
2001-12-28 07:45:12 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
2004-05-06 21:51:56 +08:00
|
|
|
static GTokenType
|
|
|
|
plug_in_menu_path_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def)
|
|
|
|
{
|
|
|
|
gchar *menu_path;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) ||
|
|
|
|
GPOINTER_TO_INT (scanner->value.v_symbol) != MENU_PATH)
|
|
|
|
return G_TOKEN_SYMBOL;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &menu_path))
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
|
|
|
proc_def->menu_paths = g_list_append (proc_def->menu_paths, menu_path);
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
static GTokenType
|
|
|
|
plug_in_icon_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def)
|
|
|
|
{
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
GEnumValue *enum_value;
|
|
|
|
GimpIconType icon_type;
|
|
|
|
gint icon_data_length;
|
2004-07-06 06:28:09 +08:00
|
|
|
gchar *icon_name;
|
|
|
|
guint8 *icon_data;
|
2004-05-19 05:19:43 +08:00
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) ||
|
|
|
|
GPOINTER_TO_INT (scanner->value.v_symbol) != ICON)
|
|
|
|
return G_TOKEN_SYMBOL;
|
|
|
|
|
|
|
|
enum_class = g_type_class_peek (GIMP_TYPE_ICON_TYPE);
|
|
|
|
|
|
|
|
switch (g_scanner_peek_next_token (scanner))
|
|
|
|
{
|
|
|
|
case G_TOKEN_IDENTIFIER:
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
|
|
|
|
scanner->value.v_identifier);
|
|
|
|
if (!enum_value)
|
|
|
|
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
|
|
|
|
scanner->value.v_identifier);
|
|
|
|
|
|
|
|
if (!enum_value)
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
_("invalid value '%s' for icon type"),
|
|
|
|
scanner->value.v_identifier);
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_INT:
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
enum_value = g_enum_get_value (enum_class,
|
|
|
|
(gint) scanner->value.v_int64);
|
|
|
|
|
|
|
|
if (!enum_value)
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner,
|
|
|
|
_("invalid value '%ld' for icon type"),
|
|
|
|
(glong) scanner->value.v_int64);
|
|
|
|
return G_TOKEN_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return G_TOKEN_IDENTIFIER;
|
|
|
|
}
|
|
|
|
|
|
|
|
icon_type = enum_value->value;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_int (scanner, &icon_data_length))
|
|
|
|
return G_TOKEN_INT;
|
|
|
|
|
|
|
|
switch (icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_STOCK_ID:
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
|
|
|
icon_data_length = -1;
|
|
|
|
|
2004-07-06 06:28:09 +08:00
|
|
|
if (! gimp_scanner_parse_string_no_validate (scanner, &icon_name))
|
2004-05-19 05:19:43 +08:00
|
|
|
return G_TOKEN_STRING;
|
2004-07-06 06:28:09 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
icon_data = (guint8 *) icon_name;
|
2004-05-19 05:19:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_INLINE_PIXBUF:
|
|
|
|
if (icon_data_length < 0)
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_data (scanner, icon_data_length, &icon_data))
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc_def->icon_type = icon_type;
|
|
|
|
proc_def->icon_data_length = icon_data_length;
|
2006-03-31 22:34:02 +08:00
|
|
|
proc_def->icon_data = icon_data;
|
2004-05-19 05:19:43 +08:00
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
|
|
|
|
2004-05-14 08:01:11 +08:00
|
|
|
static GTokenType
|
2005-04-25 20:42:26 +08:00
|
|
|
plug_in_file_proc_deserialize (GScanner *scanner,
|
|
|
|
PlugInProcDef *proc_def)
|
2004-05-14 08:01:11 +08:00
|
|
|
{
|
2004-11-14 01:06:06 +08:00
|
|
|
GTokenType token;
|
2005-04-25 20:42:26 +08:00
|
|
|
gint symbol;
|
2004-11-14 01:06:06 +08:00
|
|
|
gchar *value;
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL))
|
|
|
|
return G_TOKEN_SYMBOL;
|
|
|
|
|
|
|
|
symbol = GPOINTER_TO_INT (scanner->value.v_symbol);
|
|
|
|
if (symbol != LOAD_PROC && symbol != SAVE_PROC)
|
|
|
|
return G_TOKEN_SYMBOL;
|
|
|
|
|
|
|
|
proc_def->file_proc = TRUE;
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, symbol);
|
|
|
|
|
2004-11-14 01:06:06 +08:00
|
|
|
while (g_scanner_peek_next_token (scanner) == G_TOKEN_LEFT_PAREN)
|
|
|
|
{
|
2004-11-14 10:50:33 +08:00
|
|
|
token = g_scanner_get_next_token (scanner);
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2004-11-14 01:06:06 +08:00
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
return token;
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2004-11-14 01:06:06 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL))
|
|
|
|
return G_TOKEN_SYMBOL;
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
symbol = GPOINTER_TO_INT (scanner->value.v_symbol);
|
|
|
|
|
|
|
|
if (symbol == MAGIC)
|
|
|
|
{
|
|
|
|
if (! gimp_scanner_parse_string_no_validate (scanner, &value))
|
|
|
|
return G_TOKEN_STRING;
|
|
|
|
}
|
|
|
|
else
|
2004-11-14 01:06:06 +08:00
|
|
|
{
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &value))
|
|
|
|
return G_TOKEN_STRING;
|
2005-04-25 20:42:26 +08:00
|
|
|
}
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
switch (symbol)
|
|
|
|
{
|
|
|
|
case EXTENSION:
|
|
|
|
g_free (proc_def->extensions);
|
|
|
|
proc_def->extensions = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PREFIX:
|
|
|
|
g_free (proc_def->prefixes);
|
|
|
|
proc_def->prefixes = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAGIC:
|
|
|
|
g_free (proc_def->magics);
|
|
|
|
proc_def->magics = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MIME_TYPE:
|
2004-11-14 01:06:06 +08:00
|
|
|
g_free (proc_def->mime_type);
|
|
|
|
proc_def->mime_type = value;
|
|
|
|
break;
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2004-11-14 01:06:06 +08:00
|
|
|
case THUMB_LOADER:
|
|
|
|
g_free (proc_def->thumb_loader);
|
|
|
|
proc_def->thumb_loader = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return G_TOKEN_SYMBOL;
|
|
|
|
}
|
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
}
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, PLUG_IN_DEF);
|
|
|
|
|
2004-05-14 08:01:11 +08:00
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
|
|
|
|
2001-12-28 07:45:12 +08:00
|
|
|
static GTokenType
|
2006-03-29 03:58:00 +08:00
|
|
|
plug_in_proc_arg_deserialize (GScanner *scanner,
|
|
|
|
Gimp *gimp,
|
|
|
|
ProcRecord *proc,
|
|
|
|
gboolean return_value)
|
2001-12-28 07:45:12 +08:00
|
|
|
{
|
2006-03-29 03:58:00 +08:00
|
|
|
GTokenType token;
|
|
|
|
gint arg_type;
|
|
|
|
gchar *name = NULL;
|
|
|
|
gchar *desc = NULL;
|
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
goto error;
|
|
|
|
}
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) ||
|
2001-12-29 06:58:14 +08:00
|
|
|
GPOINTER_TO_INT (scanner->value.v_symbol) != PROC_ARG)
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
goto error;
|
|
|
|
}
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, (gint *) &arg_type))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &name))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &desc))
|
|
|
|
{
|
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
goto error;
|
|
|
|
}
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
2006-03-29 03:58:00 +08:00
|
|
|
{
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
goto error;
|
|
|
|
}
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2006-03-29 03:58:00 +08:00
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
if (return_value)
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_compat_value (proc, gimp, arg_type, name, desc);
|
2006-03-29 03:58:00 +08:00
|
|
|
else
|
2006-03-31 17:15:08 +08:00
|
|
|
gimp_procedure_add_compat_arg (proc, gimp, arg_type, name, desc);
|
2006-03-29 03:58:00 +08:00
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_free (desc);
|
|
|
|
|
|
|
|
return token;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GTokenType
|
|
|
|
plug_in_locale_def_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def)
|
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
gchar *string;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &string))
|
2001-12-28 07:45:12 +08:00
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def_set_locale_domain_name (plug_in_def, string);
|
|
|
|
g_free (string);
|
|
|
|
|
|
|
|
if (gimp_scanner_parse_string (scanner, &string))
|
|
|
|
{
|
|
|
|
plug_in_def_set_locale_domain_path (plug_in_def, string);
|
|
|
|
g_free (string);
|
|
|
|
}
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
2001-12-28 07:45:12 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
static GTokenType
|
2001-12-28 07:45:12 +08:00
|
|
|
plug_in_help_def_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def)
|
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
gchar *string;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &string))
|
2001-12-28 07:45:12 +08:00
|
|
|
return G_TOKEN_STRING;
|
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
plug_in_def_set_help_domain_name (plug_in_def, string);
|
2003-01-18 02:07:37 +08:00
|
|
|
g_free (string);
|
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (gimp_scanner_parse_string (scanner, &string))
|
|
|
|
{
|
|
|
|
plug_in_def_set_help_domain_uri (plug_in_def, string);
|
|
|
|
g_free (string);
|
|
|
|
}
|
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
2001-12-28 07:45:12 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
return G_TOKEN_LEFT_PAREN;
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|
|
|
|
|
2003-09-11 06:06:45 +08:00
|
|
|
static GTokenType
|
2002-02-12 15:59:16 +08:00
|
|
|
plug_in_has_init_deserialize (GScanner *scanner,
|
|
|
|
PlugInDef *plug_in_def)
|
|
|
|
{
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_def_set_has_init (plug_in_def, TRUE);
|
2002-02-12 15:59:16 +08:00
|
|
|
|
2002-03-28 07:15:00 +08:00
|
|
|
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
|
2002-02-12 15:59:16 +08:00
|
|
|
return G_TOKEN_RIGHT_PAREN;
|
|
|
|
|
|
|
|
return G_TOKEN_LEFT_PAREN;
|
|
|
|
}
|
|
|
|
|
2001-12-28 07:45:12 +08:00
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
/* serialize functions */
|
|
|
|
|
|
|
|
gboolean
|
2003-03-10 23:48:16 +08:00
|
|
|
plug_in_rc_write (GSList *plug_in_defs,
|
|
|
|
const gchar *filename,
|
|
|
|
GError **error)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
GimpConfigWriter *writer;
|
2004-05-19 05:19:43 +08:00
|
|
|
GEnumClass *enum_class;
|
2003-03-10 23:48:16 +08:00
|
|
|
GSList *list;
|
|
|
|
|
2003-06-24 06:02:56 +08:00
|
|
|
writer = gimp_config_writer_new_file (filename,
|
|
|
|
FALSE,
|
2004-12-09 18:11:43 +08:00
|
|
|
"GIMP pluginrc\n\n"
|
2003-06-24 06:02:56 +08:00
|
|
|
"This file can safely be removed and "
|
|
|
|
"will be automatically regenerated by "
|
|
|
|
"querying the installed plugins.",
|
|
|
|
error);
|
2003-03-10 23:48:16 +08:00
|
|
|
if (!writer)
|
2001-12-29 06:58:14 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE);
|
|
|
|
|
2003-11-08 07:47:35 +08:00
|
|
|
gimp_config_writer_open (writer, "protocol-version");
|
|
|
|
gimp_config_writer_printf (writer, "%d", GIMP_PROTOCOL_VERSION);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
gimp_config_writer_linefeed (writer);
|
|
|
|
|
2001-12-29 06:58:14 +08:00
|
|
|
for (list = plug_in_defs; list; list = list->next)
|
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
PlugInDef *plug_in_def = list->data;
|
2001-12-29 06:58:14 +08:00
|
|
|
|
|
|
|
if (plug_in_def->proc_defs)
|
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
GSList *list2;
|
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "plug-in-def");
|
|
|
|
gimp_config_writer_string (writer, plug_in_def->prog);
|
|
|
|
gimp_config_writer_printf (writer, "%ld", plug_in_def->mtime);
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
for (list2 = plug_in_def->proc_defs; list2; list2 = list2->next)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2006-03-31 19:49:22 +08:00
|
|
|
PlugInProcDef *proc_def = list2->data;
|
|
|
|
ProcRecord *procedure = proc_def->procedure;
|
|
|
|
GEnumValue *enum_value;
|
|
|
|
GList *list3;
|
|
|
|
gint i;
|
2003-03-10 23:48:16 +08:00
|
|
|
|
2004-04-16 06:16:21 +08:00
|
|
|
if (proc_def->installed_during_init)
|
|
|
|
continue;
|
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "proc-def");
|
|
|
|
gimp_config_writer_printf (writer, "\"%s\" %d",
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->original_name,
|
|
|
|
procedure->proc_type);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_config_writer_string (writer, procedure->blurb);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_config_writer_string (writer, procedure->help);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_config_writer_string (writer, procedure->author);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_config_writer_string (writer, procedure->copyright);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2006-03-31 19:49:22 +08:00
|
|
|
gimp_config_writer_string (writer, procedure->date);
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2004-05-07 08:30:24 +08:00
|
|
|
gimp_config_writer_string (writer, proc_def->menu_label);
|
|
|
|
gimp_config_writer_linefeed (writer);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
|
|
|
g_list_length (proc_def->menu_paths));
|
|
|
|
for (list3 = proc_def->menu_paths; list3; list3 = list3->next)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "menu-path");
|
|
|
|
gimp_config_writer_string (writer, list3->data);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
2004-05-19 05:19:43 +08:00
|
|
|
|
|
|
|
gimp_config_writer_open (writer, "icon");
|
|
|
|
enum_value = g_enum_get_value (enum_class, proc_def->icon_type);
|
|
|
|
gimp_config_writer_identifier (writer, enum_value->value_nick);
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
|
|
|
proc_def->icon_data_length);
|
|
|
|
|
|
|
|
switch (proc_def->icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_STOCK_ID:
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
2006-03-31 22:34:02 +08:00
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
(gchar *) proc_def->icon_data);
|
2004-05-19 05:19:43 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_INLINE_PIXBUF:
|
|
|
|
gimp_config_writer_data (writer, proc_def->icon_data_length,
|
2006-03-31 22:34:02 +08:00
|
|
|
proc_def->icon_data);
|
2004-05-19 05:19:43 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
|
2005-04-25 20:42:26 +08:00
|
|
|
if (proc_def->file_proc)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer,
|
|
|
|
proc_def->image_types ?
|
|
|
|
"save-proc" : "load-proc");
|
|
|
|
|
|
|
|
if (proc_def->extensions && *proc_def->extensions)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "extension");
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
proc_def->extensions);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proc_def->prefixes && *proc_def->prefixes)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "prefix");
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
proc_def->prefixes);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proc_def->magics && *proc_def->magics)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "magic");
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
proc_def->magics);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proc_def->mime_type)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "mime-type");
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
proc_def->mime_type);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proc_def->thumb_loader)
|
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, "thumb-loader");
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
proc_def->thumb_loader);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
|
|
|
|
2004-05-06 21:51:56 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_string (writer, proc_def->image_types);
|
|
|
|
gimp_config_writer_linefeed (writer);
|
|
|
|
|
|
|
|
gimp_config_writer_printf (writer, "%d %d",
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->num_args,
|
|
|
|
procedure->num_values);
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
for (i = 0; i < procedure->num_args; i++)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "proc-arg");
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->args[i].type);
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_string (writer,
|
2006-03-31 19:49:22 +08:00
|
|
|
g_param_spec_get_name (procedure->args[i].pspec));
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_string (writer,
|
2006-03-31 19:49:22 +08:00
|
|
|
g_param_spec_get_blurb (procedure->args[i].pspec));
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_close (writer);
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
|
|
|
|
2006-03-31 19:49:22 +08:00
|
|
|
for (i = 0; i < procedure->num_values; i++)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "proc-arg");
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
2006-03-31 19:49:22 +08:00
|
|
|
procedure->values[i].type);
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_string (writer,
|
2006-03-31 19:49:22 +08:00
|
|
|
g_param_spec_get_name (procedure->values[i].pspec));
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_string (writer,
|
2006-03-31 19:49:22 +08:00
|
|
|
g_param_spec_get_blurb (procedure->values[i].pspec));
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_close (writer);
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_close (writer);
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->locale_domain_name)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "locale-def");
|
2003-08-29 02:49:11 +08:00
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
plug_in_def->locale_domain_name);
|
2003-03-10 23:48:16 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->locale_domain_path)
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
plug_in_def->locale_domain_path);
|
2003-03-10 23:48:16 +08:00
|
|
|
|
|
|
|
gimp_config_writer_close (writer);
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->help_domain_name)
|
2001-12-29 06:58:14 +08:00
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "help-def");
|
2003-08-29 02:49:11 +08:00
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
plug_in_def->help_domain_name);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (plug_in_def->help_domain_uri)
|
|
|
|
gimp_config_writer_string (writer,
|
|
|
|
plug_in_def->help_domain_uri);
|
|
|
|
|
|
|
|
gimp_config_writer_close (writer);
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2002-02-12 15:59:16 +08:00
|
|
|
if (plug_in_def->has_init)
|
|
|
|
{
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_open (writer, "has-init");
|
|
|
|
gimp_config_writer_close (writer);
|
2002-02-12 15:59:16 +08:00
|
|
|
}
|
2001-12-29 06:58:14 +08:00
|
|
|
|
2003-03-10 23:48:16 +08:00
|
|
|
gimp_config_writer_close (writer);
|
2003-09-11 06:06:45 +08:00
|
|
|
}
|
2001-12-29 06:58:14 +08:00
|
|
|
}
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
g_type_class_unref (enum_class);
|
|
|
|
|
2004-12-09 18:11:43 +08:00
|
|
|
return gimp_config_writer_finish (writer, "end of pluginrc", error);
|
2001-12-28 07:45:12 +08:00
|
|
|
}
|