Commit 380b1703 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added a boolean flag to the ProcDef struct to identify file procedures.

2005-04-25  Sven Neumann  <sven@gimp.org>

	* app/plug-in/plug-in-proc-def.h: added a boolean flag to the
	ProcDef struct to identify file procedures.

	* app/xcf/xcf.c: changed accordingly.

	* app/plug-in/plug-ins.c: look at the new flag instead of checking
	extensions, prefixes and magics being non-NULL. A file plug-in
	doesn't necessarily have any of these fields set.

	* app/plug-in/plug-in-rc.c: changed pluginrc format to contain an
	extra section for file procedures. Moved all file related info there.
parent 16c86d0d
2005-04-25 Sven Neumann <sven@gimp.org>
* app/plug-in/plug-in-proc-def.h: added a boolean flag to the
ProcDef struct to identify file procedures.
* app/xcf/xcf.c: changed accordingly.
* app/plug-in/plug-ins.c: look at the new flag instead of checking
extensions, prefixes and magics being non-NULL. A file plug-in
doesn't necessarily have any of these fields set.
* app/plug-in/plug-in-rc.c: changed pluginrc format to contain an
extra section for file procedures. Moved all file related info there.
2005-04-25 Manish Singh <yosh@gimp.org>
* plug-in/common/tiff.c: Only store compression types we can actually
......
......@@ -44,6 +44,7 @@ struct _PlugInProcDef
ProcRecord db_info;
/* file proc specific members */
gboolean file_proc;
gchar *extensions;
gchar *prefixes;
gchar *magics;
......
......@@ -427,6 +427,8 @@ plug_ins_file_register_magic (Gimp *gimp,
if (strcmp (proc_def->db_info.name, name) == 0)
{
proc_def->file_proc = TRUE;
if (proc_def->extensions != extensions)
{
if (proc_def->extensions)
......@@ -1041,7 +1043,7 @@ plug_ins_add_to_db (Gimp *gimp,
{
proc_def = list->data;
if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
if (proc_def->file_proc)
{
Argument args[4];
......
......@@ -44,6 +44,7 @@ struct _PlugInProcDef
ProcRecord db_info;
/* file proc specific members */
gboolean file_proc;
gchar *extensions;
gchar *prefixes;
gchar *magics;
......
......@@ -44,6 +44,7 @@ struct _PlugInProcDef
ProcRecord db_info;
/* file proc specific members */
gboolean file_proc;
gchar *extensions;
gchar *prefixes;
gchar *magics;
......
......@@ -52,10 +52,10 @@ static GTokenType plug_in_menu_path_deserialize (GScanner *scanner,
PlugInProcDef *proc_def);
static GTokenType plug_in_icon_deserialize (GScanner *scanner,
PlugInProcDef *proc_def);
static GTokenType plug_in_file_proc_deserialize (GScanner *scanner,
PlugInProcDef *proc_def);
static GTokenType plug_in_proc_arg_deserialize (GScanner *scanner,
ProcArg *arg);
static GTokenType plug_in_extra_deserialize (GScanner *scanner,
PlugInProcDef *proc_def);
static GTokenType plug_in_locale_def_deserialize (GScanner *scanner,
PlugInDef *plug_in_def);
static GTokenType plug_in_help_def_deserialize (GScanner *scanner,
......@@ -75,6 +75,11 @@ enum
PROC_ARG,
MENU_PATH,
ICON,
LOAD_PROC,
SAVE_PROC,
EXTENSION,
PREFIX,
MAGIC,
MIME_TYPE,
THUMB_LOADER
};
......@@ -107,6 +112,7 @@ plug_in_rc_parse (Gimp *gimp,
GINT_TO_POINTER (PROTOCOL_VERSION));
g_scanner_scope_add_symbol (scanner, 0,
"plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF));
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"proc-def", GINT_TO_POINTER (PROC_DEF));
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
......@@ -122,10 +128,28 @@ plug_in_rc_parse (Gimp *gimp,
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"icon", GINT_TO_POINTER (ICON));
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"mime-type", GINT_TO_POINTER (MIME_TYPE));
"load-proc", GINT_TO_POINTER (LOAD_PROC));
g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"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,
"thumb-loader", GINT_TO_POINTER (THUMB_LOADER));
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));
token = G_TOKEN_LEFT_PAREN;
while (version == GIMP_PROTOCOL_VERSION &&
......@@ -318,12 +342,10 @@ plug_in_proc_def_deserialize (GScanner *scanner,
if (token != G_TOKEN_LEFT_PAREN)
return token;
if (! gimp_scanner_parse_string (scanner, &proc_def->extensions))
return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &proc_def->prefixes))
return G_TOKEN_STRING;
if (! gimp_scanner_parse_string_no_validate (scanner, &proc_def->magics))
return G_TOKEN_STRING;
token = plug_in_file_proc_deserialize (scanner, proc_def);
if (token != G_TOKEN_LEFT_PAREN)
return token;
if (! gimp_scanner_parse_string (scanner, &proc_def->image_types))
return G_TOKEN_STRING;
......@@ -357,11 +379,6 @@ plug_in_proc_def_deserialize (GScanner *scanner,
return token;
}
token = plug_in_extra_deserialize (scanner, proc_def);
if (token != G_TOKEN_LEFT_PAREN)
return token;
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN;
......@@ -487,15 +504,28 @@ plug_in_icon_deserialize (GScanner *scanner,
return G_TOKEN_LEFT_PAREN;
}
/* Handle extra info such as mime-type and thumb-loader. */
static GTokenType
plug_in_extra_deserialize (GScanner *scanner,
PlugInProcDef *proc_def)
plug_in_file_proc_deserialize (GScanner *scanner,
PlugInProcDef *proc_def)
{
GTokenType token;
gint symbol;
gchar *value;
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);
while (g_scanner_peek_next_token (scanner) == G_TOKEN_LEFT_PAREN)
{
token = g_scanner_get_next_token (scanner);
......@@ -506,20 +536,42 @@ plug_in_extra_deserialize (GScanner *scanner,
if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL))
return G_TOKEN_SYMBOL;
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
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
{
case MIME_TYPE:
if (! gimp_scanner_parse_string (scanner, &value))
return G_TOKEN_STRING;
}
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:
g_free (proc_def->mime_type);
proc_def->mime_type = value;
break;
case THUMB_LOADER:
if (! gimp_scanner_parse_string (scanner, &value))
return G_TOKEN_STRING;
g_free (proc_def->thumb_loader);
proc_def->thumb_loader = value;
break;
......@@ -527,11 +579,15 @@ plug_in_extra_deserialize (GScanner *scanner,
default:
return G_TOKEN_SYMBOL;
}
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN;
}
if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN;
g_scanner_set_scope (scanner, PLUG_IN_DEF);
return G_TOKEN_LEFT_PAREN;
}
......@@ -720,14 +776,57 @@ plug_in_rc_write (GSList *plug_in_defs,
gimp_config_writer_close (writer);
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);
}
gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->extensions);
gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->prefixes);
gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->magics);
gimp_config_writer_linefeed (writer);
gimp_config_writer_string (writer, proc_def->image_types);
gimp_config_writer_linefeed (writer);
......@@ -763,20 +862,6 @@ plug_in_rc_write (GSList *plug_in_defs,
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);
}
......
......@@ -427,6 +427,8 @@ plug_ins_file_register_magic (Gimp *gimp,
if (strcmp (proc_def->db_info.name, name) == 0)
{
proc_def->file_proc = TRUE;
if (proc_def->extensions != extensions)
{
if (proc_def->extensions)
......@@ -1041,7 +1043,7 @@ plug_ins_add_to_db (Gimp *gimp,
{
proc_def = list->data;
if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
if (proc_def->file_proc)
{
Argument args[4];
......
......@@ -109,6 +109,7 @@ static PlugInProcDef xcf_plug_in_load_proc =
xcf_load_return_vals,
{ { xcf_load_invoker } },
},
TRUE,
"xcf",
"",
"0,string,gimp\\040xcf\\040",
......@@ -166,6 +167,7 @@ static PlugInProcDef xcf_plug_in_save_proc =
NULL,
{ { xcf_save_invoker } },
},
TRUE,
"xcf",
"",
NULL,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment