app/config/Makefile.am new files containing a convenience constructor for

2002-03-28  Michael Natterer  <mitch@gimp.org>

	* app/config/Makefile.am
	* app/config/gimpscanner.[ch]: new files containing a convenience
	constructor for GScanner and some parse utility functions, mostly
	cut out of app/plug-in/plug-in-rc.c

	* app/plug-in/plug-in-rc.c: removed the stuff here, added scopes
	to the scanner symbols.

	* app/core/Makefile.am
	* app/core/gimpunits.[ch]: moved the user_unit list handling and
	unitrc stuff to this file. Parse unitrc here, using the new
	utility functions instead of using gimprc.

	* app/core/gimpunit.[ch]: removed here.

	* app/core/gimpdocuments.c: same here: added a scanner for the
	document history instead of using gimprc.

	* app/gimprc.c: removed unitrc and document history parsing stuff
	along with some old unused cruft.

	* app/app_procs.c
	* app/core/gimp.c
	* app/gui/user-install-dialog.c: #include "core/gimpunits.h".

	* app/core/gimpdrawable-bucket-fill.c: don't include "gimprc.h".
This commit is contained in:
Michael Natterer 2002-03-27 23:15:00 +00:00 committed by Michael Natterer
parent acfaacc1fa
commit 75c63ee334
23 changed files with 1420 additions and 473 deletions

View file

@ -1,3 +1,32 @@
2002-03-28 Michael Natterer <mitch@gimp.org>
* app/config/Makefile.am
* app/config/gimpscanner.[ch]: new files containing a convenience
constructor for GScanner and some parse utility functions, mostly
cut out of app/plug-in/plug-in-rc.c
* app/plug-in/plug-in-rc.c: removed the stuff here, added scopes
to the scanner symbols.
* app/core/Makefile.am
* app/core/gimpunits.[ch]: moved the user_unit list handling and
unitrc stuff to this file. Parse unitrc here, using the new
utility functions instead of using gimprc.
* app/core/gimpunit.[ch]: removed here.
* app/core/gimpdocuments.c: same here: added a scanner for the
document history instead of using gimprc.
* app/gimprc.c: removed unitrc and document history parsing stuff
along with some old unused cruft.
* app/app_procs.c
* app/core/gimp.c
* app/gui/user-install-dialog.c: #include "core/gimpunits.h".
* app/core/gimpdrawable-bucket-fill.c: don't include "gimprc.h".
2002-03-27 Sven Neumann <sven@gimp.org> 2002-03-27 Sven Neumann <sven@gimp.org>
* autogen.sh: bail out if one of the required tools is not found * autogen.sh: bail out if one of the required tools is not found
@ -29,7 +58,7 @@
* app/widgets/gimppreview.c: gimp_preview_set_viewable: never * app/widgets/gimppreview.c: gimp_preview_set_viewable: never
unset the drag source if the viewable is set to NULL (fixes dock unset the drag source if the viewable is set to NULL (fixes dock
tabs, thanks to sjburges), also check the passed viweable's type. tabs, thanks to sjburges), also check the passed viewable's type.
* themes/Default/gtkrc: set the paned handle_size to 6 pixels, so * themes/Default/gtkrc: set the paned handle_size to 6 pixels, so
it has the same size as the dock_separator. it has the same size as the dock_separator.

View file

@ -40,7 +40,7 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdatafactory.h" #include "core/gimpdatafactory.h"
#include "core/gimpunit.h" #include "core/gimpunits.h"
#include "plug-in/plug-ins.h" #include "plug-in/plug-ins.h"

View file

@ -28,6 +28,8 @@ libappconfig_a_SOURCES = @STRIP_BEGIN@ \
gimpguiconfig.h \ gimpguiconfig.h \
gimprc.c \ gimprc.c \
gimprc.h \ gimprc.h \
gimpscanner.c \
gimpscanner.h \
@STRIP_END@ @STRIP_END@
AM_CPPFLAGS = @STRIP_BEGIN@ \ AM_CPPFLAGS = @STRIP_BEGIN@ \

154
app/config/gimpscanner.c Normal file
View file

@ -0,0 +1,154 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.c
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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 <fcntl.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "gimpscanner.h"
#include "libgimp/gimpintl.h"
GScanner *
gimp_scanner_new (const gchar *filename)
{
gint fd;
GScanner *scanner;
g_return_val_if_fail (filename != NULL, NULL);
fd = open (filename, O_RDONLY);
if (fd == -1)
return NULL;
scanner = g_scanner_new (NULL);
scanner->config->cset_identifier_first = ( G_CSET_a_2_z );
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-_" );
g_scanner_input_file (scanner, fd);
scanner->input_name = g_strdup (filename);
return scanner;
}
void
gimp_scanner_destroy (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
close (scanner->input_fd);
g_free ((gchar *) scanner->input_name);
g_scanner_destroy (scanner);
}
gboolean
gimp_scanner_parse_token (GScanner *scanner,
GTokenType token)
{
if (g_scanner_peek_next_token (scanner) != token)
return FALSE;
g_scanner_get_next_token (scanner);
return TRUE;
}
gboolean
gimp_scanner_parse_string (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
{
if (! g_utf8_validate (scanner->value.v_string, -1, NULL))
{
g_scanner_warn (scanner, _("invalid UTF-8 string"));
return FALSE;
}
*dest = g_strdup (scanner->value.v_string);
}
return TRUE;
}
gboolean
gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
return TRUE;
}
gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_int;
return TRUE;
}
gboolean
gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_FLOAT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_float;
return TRUE;
}

42
app/config/gimpscanner.h Normal file
View file

@ -0,0 +1,42 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.h
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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.
*/
#ifndef __GIMP_SCANNER_H__
#define __GIMP_SCANNER_H__
GScanner * gimp_scanner_new (const gchar *filename);
void gimp_scanner_destroy (GScanner *scanner);
gboolean gimp_scanner_parse_token (GScanner *scanner,
GTokenType token);
gboolean gimp_scanner_parse_string (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_int (GScanner *scanner,
gint *dest);
gboolean gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest);
#endif /* __GIMP_SCANNER_H__ */

View file

@ -152,6 +152,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimptoolinfo.h \ gimptoolinfo.h \
gimpunit.c \ gimpunit.c \
gimpunit.h \ gimpunit.h \
gimpunits.c \
gimpunits.h \
gimpundo.c \ gimpundo.c \
gimpundo.h \ gimpundo.h \
gimpundostack.c \ gimpundostack.c \

View file

@ -29,12 +29,14 @@
#include "core-types.h" #include "core-types.h"
#include "config/gimpscanner.h"
#include "gimp.h" #include "gimp.h"
#include "gimpdocuments.h" #include "gimpdocuments.h"
#include "gimpimagefile.h" #include "gimpimagefile.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimprc.h" #include "libgimp/gimpintl.h"
void void
@ -63,13 +65,79 @@ gimp_documents_exit (Gimp *gimp)
void void
gimp_documents_load (Gimp *gimp) gimp_documents_load (Gimp *gimp)
{ {
gchar *filename; gchar *filename;
GScanner *scanner;
GTokenType token;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("documents"); filename = gimp_personal_rc_file ("documents");
gimprc_parse_file (filename); scanner = gimp_scanner_new (filename);
g_free (filename); g_free (filename);
if (! scanner)
return;
g_scanner_scope_add_symbol (scanner, 0,
"document", GINT_TO_POINTER (1));
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = G_TOKEN_RIGHT_PAREN;
if (scanner->value.v_symbol == GINT_TO_POINTER (1))
{
gchar *uri;
GimpImagefile *imagefile;
if (! gimp_scanner_parse_string (scanner, &uri))
{
token = G_TOKEN_STRING;
break;
}
imagefile = gimp_imagefile_new (uri);
g_free (uri);
GIMP_LIST (gimp->documents)->list =
g_list_append (GIMP_LIST (gimp->documents)->list, imagefile);
gimp->documents->num_children++;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
gimp_scanner_destroy (scanner);
} }
static void static void

333
app/core/gimp-units.c Normal file
View file

@ -0,0 +1,333 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpunit.c
* Copyright (C) 1999-2000 Michael Natterer <mitch@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 <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "gimp.h"
#include "gimpunit.h"
#include "gimpunits.h"
#include "config/gimpscanner.h"
#include "libgimp/gimpintl.h"
/*
* All deserialize functions return G_TOKEN_LEFT_PAREN on success,
* or the GTokenType they would have expected but didn't get.
*/
static GTokenType gimp_unitrc_unit_info_deserialize (GScanner *scanner,
Gimp *gimp);
void
gimp_units_init (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
void
gimp_units_exit (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->user_units)
{
g_list_foreach (gimp->user_units, (GFunc) g_free, NULL);
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
}
/* unitrc functions **********/
enum
{
UNIT_INFO = 1,
UNIT_FACTOR,
UNIT_DIGITS,
UNIT_SYMBOL,
UNIT_ABBREV,
UNIT_SINGULAR,
UNIT_PLURAL
};
void
gimp_unitrc_load (Gimp *gimp)
{
gchar *filename;
GScanner *scanner;
GTokenType token;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
scanner = gimp_scanner_new (filename);
g_free (filename);
if (! scanner)
return;
g_scanner_scope_add_symbol (scanner, 0,
"unit-info", GINT_TO_POINTER (UNIT_INFO));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"factor", GINT_TO_POINTER (UNIT_FACTOR));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"digits", GINT_TO_POINTER (UNIT_DIGITS));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"symbol", GINT_TO_POINTER (UNIT_SYMBOL));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"abbreviation", GINT_TO_POINTER (UNIT_ABBREV));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"singular", GINT_TO_POINTER (UNIT_SINGULAR));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"plural", GINT_TO_POINTER (UNIT_PLURAL));
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
if (scanner->value.v_symbol == GINT_TO_POINTER (UNIT_INFO))
{
g_scanner_set_scope (scanner, UNIT_INFO);
token = gimp_unitrc_unit_info_deserialize (scanner, gimp);
g_scanner_set_scope (scanner, 0);
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
gimp_scanner_destroy (scanner);
}
void
gimp_unitrc_save (Gimp *gimp)
{
gint i;
gchar *filename;
FILE *fp;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
fp = fopen (filename, "w");
g_free (filename);
if (!fp)
return;
fprintf (fp,
"# GIMP unitrc\n"
"# This file contains your user unit database. You can\n"
"# modify this list with the unit editor. You are not\n"
"# supposed to edit it manually, but of course you can do.\n"
"# This file will be entirely rewritten every time you\n"
"# quit the gimp.\n\n");
/* save user defined units */
for (i = gimp_unit_get_number_of_built_in_units ();
i < gimp_unit_get_number_of_units ();
i++)
{
if (gimp_unit_get_deletion_flag (i) == FALSE)
{
fprintf (fp,
"(unit-info \"%s\"\n"
" (factor %f)\n"
" (digits %d)\n"
" (symbol \"%s\")\n"
" (abbreviation \"%s\")\n"
" (singular \"%s\")\n"
" (plural \"%s\"))\n\n",
gimp_unit_get_identifier (i),
gimp_unit_get_factor (i),
gimp_unit_get_digits (i),
gimp_unit_get_symbol (i),
gimp_unit_get_abbreviation (i),
gimp_unit_get_singular (i),
gimp_unit_get_plural (i));
}
}
fclose (fp);
}
/* private functions */
static GTokenType
gimp_unitrc_unit_info_deserialize (GScanner *scanner,
Gimp *gimp)
{
gchar *identifier = NULL;
gdouble factor = 1.0;
gint digits = 2.0;
gchar *symbol = NULL;
gchar *abbreviation = NULL;
gchar *singular = NULL;
gchar *plural = NULL;
GTokenType token;
GimpUnit unit;
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &identifier))
return G_TOKEN_STRING;
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = G_TOKEN_RIGHT_PAREN;
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
{
case UNIT_FACTOR:
if (! gimp_scanner_parse_float (scanner, &factor))
return G_TOKEN_FLOAT;
break;
case UNIT_DIGITS:
if (! gimp_scanner_parse_int (scanner, &digits))
return G_TOKEN_INT;
break;
case UNIT_SYMBOL:
if (! gimp_scanner_parse_string (scanner, &symbol))
return G_TOKEN_STRING;
break;
case UNIT_ABBREV:
if (! gimp_scanner_parse_string (scanner, &abbreviation))
return G_TOKEN_STRING;
break;
case UNIT_SINGULAR:
if (! gimp_scanner_parse_string (scanner, &singular))
return G_TOKEN_STRING;
break;
case UNIT_PLURAL:
if (! gimp_scanner_parse_string (scanner, &plural))
return G_TOKEN_STRING;
break;
default:
break;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default:
break;
}
}
while (token != G_TOKEN_EOF);
if (token == G_TOKEN_LEFT_PAREN)
{
token = G_TOKEN_RIGHT_PAREN;
if (gimp_scanner_parse_token (scanner, token))
{
unit = _gimp_unit_new (gimp, identifier, factor, digits,
symbol, abbreviation, singular, plural);
/* make the unit definition persistent */
gimp_unit_set_deletion_flag (unit, FALSE);
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return G_TOKEN_LEFT_PAREN;
}
}
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return token;
}

30
app/core/gimp-units.h Normal file
View file

@ -0,0 +1,30 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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.
*/
#ifndef __GIMP_UNITS_H__
#define __GIMP_UNITS_H__
void gimp_units_init (Gimp *gimp);
void gimp_units_exit (Gimp *gimp);
void gimp_unitrc_load (Gimp *gimp);
void gimp_unitrc_save (Gimp *gimp);
#endif /* __GIMP_UNITS_H__ */

View file

@ -52,7 +52,7 @@
#include "gimppattern.h" #include "gimppattern.h"
#include "gimpparasite.h" #include "gimpparasite.h"
#include "gimptoolinfo.h" #include "gimptoolinfo.h"
#include "gimpunit.h" #include "gimpunits.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"

View file

@ -29,12 +29,14 @@
#include "core-types.h" #include "core-types.h"
#include "config/gimpscanner.h"
#include "gimp.h" #include "gimp.h"
#include "gimpdocuments.h" #include "gimpdocuments.h"
#include "gimpimagefile.h" #include "gimpimagefile.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimprc.h" #include "libgimp/gimpintl.h"
void void
@ -63,13 +65,79 @@ gimp_documents_exit (Gimp *gimp)
void void
gimp_documents_load (Gimp *gimp) gimp_documents_load (Gimp *gimp)
{ {
gchar *filename; gchar *filename;
GScanner *scanner;
GTokenType token;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("documents"); filename = gimp_personal_rc_file ("documents");
gimprc_parse_file (filename); scanner = gimp_scanner_new (filename);
g_free (filename); g_free (filename);
if (! scanner)
return;
g_scanner_scope_add_symbol (scanner, 0,
"document", GINT_TO_POINTER (1));
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = G_TOKEN_RIGHT_PAREN;
if (scanner->value.v_symbol == GINT_TO_POINTER (1))
{
gchar *uri;
GimpImagefile *imagefile;
if (! gimp_scanner_parse_string (scanner, &uri))
{
token = G_TOKEN_STRING;
break;
}
imagefile = gimp_imagefile_new (uri);
g_free (uri);
GIMP_LIST (gimp->documents)->list =
g_list_append (GIMP_LIST (gimp->documents)->list, imagefile);
gimp->documents->num_children++;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
gimp_scanner_destroy (scanner);
} }
static void static void

View file

@ -29,12 +29,14 @@
#include "core-types.h" #include "core-types.h"
#include "config/gimpscanner.h"
#include "gimp.h" #include "gimp.h"
#include "gimpdocuments.h" #include "gimpdocuments.h"
#include "gimpimagefile.h" #include "gimpimagefile.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimprc.h" #include "libgimp/gimpintl.h"
void void
@ -63,13 +65,79 @@ gimp_documents_exit (Gimp *gimp)
void void
gimp_documents_load (Gimp *gimp) gimp_documents_load (Gimp *gimp)
{ {
gchar *filename; gchar *filename;
GScanner *scanner;
GTokenType token;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("documents"); filename = gimp_personal_rc_file ("documents");
gimprc_parse_file (filename); scanner = gimp_scanner_new (filename);
g_free (filename); g_free (filename);
if (! scanner)
return;
g_scanner_scope_add_symbol (scanner, 0,
"document", GINT_TO_POINTER (1));
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = G_TOKEN_RIGHT_PAREN;
if (scanner->value.v_symbol == GINT_TO_POINTER (1))
{
gchar *uri;
GimpImagefile *imagefile;
if (! gimp_scanner_parse_string (scanner, &uri))
{
token = G_TOKEN_STRING;
break;
}
imagefile = gimp_imagefile_new (uri);
g_free (uri);
GIMP_LIST (gimp->documents)->list =
g_list_append (GIMP_LIST (gimp->documents)->list, imagefile);
gimp->documents->num_children++;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
gimp_scanner_destroy (scanner);
} }
static void static void

View file

@ -40,7 +40,6 @@
#include "gimpimage-mask.h" #include "gimpimage-mask.h"
#include "gimppattern.h" #include "gimppattern.h"
#include "gimprc.h"
#include "undo.h" #include "undo.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"

View file

@ -21,9 +21,6 @@
#include "config.h" #include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h> #include <glib-object.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
@ -33,8 +30,6 @@
#include "gimp.h" #include "gimp.h"
#include "gimpunit.h" #include "gimpunit.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
@ -271,96 +266,3 @@ _gimp_unit_get_plural (Gimp *gimp,
return gettext (_gimp_unit_get_user_unit (gimp, unit)->plural); return gettext (_gimp_unit_get_user_unit (gimp, unit)->plural);
} }
/* unitrc functions **********/
void
gimp_units_init (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
void
gimp_units_exit (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->user_units)
{
g_list_foreach (gimp->user_units, (GFunc) g_free, NULL);
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
}
void
gimp_unitrc_load (Gimp *gimp)
{
gchar *filename;
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
gimprc_parse_file (filename);
g_free (filename);
}
void
gimp_unitrc_save (Gimp *gimp)
{
gint i;
gchar *filename;
FILE *fp;
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
fp = fopen (filename, "w");
g_free (filename);
if (!fp)
return;
fprintf (fp,
"# GIMP unitrc\n"
"# This file contains your user unit database. You can\n"
"# modify this list with the unit editor. You are not\n"
"# supposed to edit it manually, but of course you can do.\n"
"# This file will be entirely rewritten every time you\n"
"# quit the gimp.\n\n");
/* save user defined units */
for (i = gimp_unit_get_number_of_built_in_units ();
i < gimp_unit_get_number_of_units ();
i++)
if (gimp_unit_get_deletion_flag (i) == FALSE)
{
fprintf (fp,
"(unit-info \"%s\"\n"
" (factor %f)\n"
" (digits %d)\n"
" (symbol \"%s\")\n"
" (abbreviation \"%s\")\n"
" (singular \"%s\")\n"
" (plural \"%s\"))\n\n",
gimp_unit_get_identifier (i),
gimp_unit_get_factor (i),
gimp_unit_get_digits (i),
gimp_unit_get_symbol (i),
gimp_unit_get_abbreviation (i),
gimp_unit_get_singular (i),
gimp_unit_get_plural (i));
}
fclose (fp);
}

View file

@ -20,12 +20,6 @@
#define __APP_GIMP_UNIT_H__ #define __APP_GIMP_UNIT_H__
void gimp_units_init (Gimp *gimp);
void gimp_units_exit (Gimp *gimp);
void gimp_unitrc_load (Gimp *gimp);
void gimp_unitrc_save (Gimp *gimp);
gint _gimp_unit_get_number_of_units (Gimp *gimp); gint _gimp_unit_get_number_of_units (Gimp *gimp);
gint _gimp_unit_get_number_of_built_in_units (Gimp *gimp) G_GNUC_CONST; gint _gimp_unit_get_number_of_built_in_units (Gimp *gimp) G_GNUC_CONST;

333
app/core/gimpunits.c Normal file
View file

@ -0,0 +1,333 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpunit.c
* Copyright (C) 1999-2000 Michael Natterer <mitch@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 <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "gimp.h"
#include "gimpunit.h"
#include "gimpunits.h"
#include "config/gimpscanner.h"
#include "libgimp/gimpintl.h"
/*
* All deserialize functions return G_TOKEN_LEFT_PAREN on success,
* or the GTokenType they would have expected but didn't get.
*/
static GTokenType gimp_unitrc_unit_info_deserialize (GScanner *scanner,
Gimp *gimp);
void
gimp_units_init (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
void
gimp_units_exit (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->user_units)
{
g_list_foreach (gimp->user_units, (GFunc) g_free, NULL);
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
}
/* unitrc functions **********/
enum
{
UNIT_INFO = 1,
UNIT_FACTOR,
UNIT_DIGITS,
UNIT_SYMBOL,
UNIT_ABBREV,
UNIT_SINGULAR,
UNIT_PLURAL
};
void
gimp_unitrc_load (Gimp *gimp)
{
gchar *filename;
GScanner *scanner;
GTokenType token;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
scanner = gimp_scanner_new (filename);
g_free (filename);
if (! scanner)
return;
g_scanner_scope_add_symbol (scanner, 0,
"unit-info", GINT_TO_POINTER (UNIT_INFO));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"factor", GINT_TO_POINTER (UNIT_FACTOR));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"digits", GINT_TO_POINTER (UNIT_DIGITS));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"symbol", GINT_TO_POINTER (UNIT_SYMBOL));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"abbreviation", GINT_TO_POINTER (UNIT_ABBREV));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"singular", GINT_TO_POINTER (UNIT_SINGULAR));
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
"plural", GINT_TO_POINTER (UNIT_PLURAL));
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
if (scanner->value.v_symbol == GINT_TO_POINTER (UNIT_INFO))
{
g_scanner_set_scope (scanner, UNIT_INFO);
token = gimp_unitrc_unit_info_deserialize (scanner, gimp);
g_scanner_set_scope (scanner, 0);
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
gimp_scanner_destroy (scanner);
}
void
gimp_unitrc_save (Gimp *gimp)
{
gint i;
gchar *filename;
FILE *fp;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("unitrc");
fp = fopen (filename, "w");
g_free (filename);
if (!fp)
return;
fprintf (fp,
"# GIMP unitrc\n"
"# This file contains your user unit database. You can\n"
"# modify this list with the unit editor. You are not\n"
"# supposed to edit it manually, but of course you can do.\n"
"# This file will be entirely rewritten every time you\n"
"# quit the gimp.\n\n");
/* save user defined units */
for (i = gimp_unit_get_number_of_built_in_units ();
i < gimp_unit_get_number_of_units ();
i++)
{
if (gimp_unit_get_deletion_flag (i) == FALSE)
{
fprintf (fp,
"(unit-info \"%s\"\n"
" (factor %f)\n"
" (digits %d)\n"
" (symbol \"%s\")\n"
" (abbreviation \"%s\")\n"
" (singular \"%s\")\n"
" (plural \"%s\"))\n\n",
gimp_unit_get_identifier (i),
gimp_unit_get_factor (i),
gimp_unit_get_digits (i),
gimp_unit_get_symbol (i),
gimp_unit_get_abbreviation (i),
gimp_unit_get_singular (i),
gimp_unit_get_plural (i));
}
}
fclose (fp);
}
/* private functions */
static GTokenType
gimp_unitrc_unit_info_deserialize (GScanner *scanner,
Gimp *gimp)
{
gchar *identifier = NULL;
gdouble factor = 1.0;
gint digits = 2.0;
gchar *symbol = NULL;
gchar *abbreviation = NULL;
gchar *singular = NULL;
gchar *plural = NULL;
GTokenType token;
GimpUnit unit;
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return G_TOKEN_STRING;
if (! gimp_scanner_parse_string (scanner, &identifier))
return G_TOKEN_STRING;
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = G_TOKEN_RIGHT_PAREN;
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
{
case UNIT_FACTOR:
if (! gimp_scanner_parse_float (scanner, &factor))
return G_TOKEN_FLOAT;
break;
case UNIT_DIGITS:
if (! gimp_scanner_parse_int (scanner, &digits))
return G_TOKEN_INT;
break;
case UNIT_SYMBOL:
if (! gimp_scanner_parse_string (scanner, &symbol))
return G_TOKEN_STRING;
break;
case UNIT_ABBREV:
if (! gimp_scanner_parse_string (scanner, &abbreviation))
return G_TOKEN_STRING;
break;
case UNIT_SINGULAR:
if (! gimp_scanner_parse_string (scanner, &singular))
return G_TOKEN_STRING;
break;
case UNIT_PLURAL:
if (! gimp_scanner_parse_string (scanner, &plural))
return G_TOKEN_STRING;
break;
default:
break;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default:
break;
}
}
while (token != G_TOKEN_EOF);
if (token == G_TOKEN_LEFT_PAREN)
{
token = G_TOKEN_RIGHT_PAREN;
if (gimp_scanner_parse_token (scanner, token))
{
unit = _gimp_unit_new (gimp, identifier, factor, digits,
symbol, abbreviation, singular, plural);
/* make the unit definition persistent */
gimp_unit_set_deletion_flag (unit, FALSE);
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return G_TOKEN_LEFT_PAREN;
}
}
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return token;
}

30
app/core/gimpunits.h Normal file
View file

@ -0,0 +1,30 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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.
*/
#ifndef __GIMP_UNITS_H__
#define __GIMP_UNITS_H__
void gimp_units_init (Gimp *gimp);
void gimp_units_exit (Gimp *gimp);
void gimp_unitrc_load (Gimp *gimp);
void gimp_unitrc_save (Gimp *gimp);
#endif /* __GIMP_UNITS_H__ */

View file

@ -38,7 +38,7 @@
#include "base/base-config.h" #include "base/base-config.h"
#include "core/gimpunit.h" #include "core/gimpunits.h"
#include "gui.h" #include "gui.h"
#include "resolution-calibrate-dialog.h" #include "resolution-calibrate-dialog.h"

View file

@ -42,8 +42,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcoreconfig.h" #include "core/gimpcoreconfig.h"
#include "core/gimpimagefile.h"
#include "core/gimplist.h"
#include "core/gimpparasite.h" #include "core/gimpparasite.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
@ -87,17 +85,14 @@ typedef enum
TT_INTERP, TT_INTERP,
TT_XPREVSIZE, TT_XPREVSIZE,
TT_XUNIT, TT_XUNIT,
TT_XMENUPATH,
TT_XDEVICE, TT_XDEVICE,
TT_XSESSIONINFO, TT_XSESSIONINFO,
TT_XCOLORHISTORY, TT_XCOLORHISTORY,
TT_XUNITINFO,
TT_XPARASITE, TT_XPARASITE,
TT_XNAVPREVSIZE, TT_XNAVPREVSIZE,
TT_XHELPBROWSER, TT_XHELPBROWSER,
TT_XCURSORMODE, TT_XCURSORMODE,
TT_XCOMMENT, TT_XCOMMENT
TT_XDOCUMENT
} TokenType; } TokenType;
@ -138,14 +133,11 @@ static gint parse_preview_size (gpointer val1p, gpointer val2p)
static gint parse_nav_preview_size (gpointer val1p, gpointer val2p); static gint parse_nav_preview_size (gpointer val1p, gpointer val2p);
static gint parse_units (gpointer val1p, gpointer val2p); static gint parse_units (gpointer val1p, gpointer val2p);
static gint parse_device (gpointer val1p, gpointer val2p); static gint parse_device (gpointer val1p, gpointer val2p);
static gint parse_menu_path (gpointer val1p, gpointer val2p);
static gint parse_session_info (gpointer val1p, gpointer val2p); static gint parse_session_info (gpointer val1p, gpointer val2p);
static gint parse_unit_info (gpointer val1p, gpointer val2p);
static gint parse_parasite (gpointer val1p, gpointer val2p); static gint parse_parasite (gpointer val1p, gpointer val2p);
static gint parse_help_browser (gpointer val1p, gpointer val2p); static gint parse_help_browser (gpointer val1p, gpointer val2p);
static gint parse_cursor_mode (gpointer val1p, gpointer val2p); static gint parse_cursor_mode (gpointer val1p, gpointer val2p);
static gint parse_color_history (gpointer val1p, gpointer val2p); static gint parse_color_history (gpointer val1p, gpointer val2p);
static gint parse_document (gpointer val1p, gpointer val2p);
static gint parse_color (GimpRGB *color); static gint parse_color (GimpRGB *color);
static gint parse_unknown (gchar *token_sym); static gint parse_unknown (gchar *token_sym);
@ -289,12 +281,9 @@ static ParseFunc funcs[] =
{ "theme", TT_STRING, &gimprc.theme, NULL }, { "theme", TT_STRING, &gimprc.theme, NULL },
{ "parasite", TT_XPARASITE, NULL, NULL }, { "parasite", TT_XPARASITE, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL }, { "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL }, { "session-info", TT_XSESSIONINFO, NULL, NULL },
{ "color-history", TT_XCOLORHISTORY, NULL, NULL }, { "color-history", TT_XCOLORHISTORY, NULL, NULL }
{ "unit-info", TT_XUNITINFO, NULL, NULL },
{ "document", TT_XDOCUMENT, NULL, NULL }
}; };
@ -907,16 +896,12 @@ parse_statement (void)
return parse_nav_preview_size (func->val1p, func->val2p); return parse_nav_preview_size (func->val1p, func->val2p);
case TT_XUNIT: case TT_XUNIT:
return parse_units (func->val1p, func->val2p); return parse_units (func->val1p, func->val2p);
case TT_XMENUPATH:
return parse_menu_path (func->val1p, func->val2p);
case TT_XDEVICE: case TT_XDEVICE:
return parse_device (func->val1p, func->val2p); return parse_device (func->val1p, func->val2p);
case TT_XSESSIONINFO: case TT_XSESSIONINFO:
return parse_session_info (func->val1p, func->val2p); return parse_session_info (func->val1p, func->val2p);
case TT_XCOLORHISTORY: case TT_XCOLORHISTORY:
return parse_color_history (func->val1p, func->val2p); return parse_color_history (func->val1p, func->val2p);
case TT_XUNITINFO:
return parse_unit_info (func->val1p, func->val2p);
case TT_XPARASITE: case TT_XPARASITE:
return parse_parasite (func->val1p, func->val2p); return parse_parasite (func->val1p, func->val2p);
case TT_XHELPBROWSER: case TT_XHELPBROWSER:
@ -925,8 +910,6 @@ parse_statement (void)
return parse_cursor_mode (func->val1p, func->val2p); return parse_cursor_mode (func->val1p, func->val2p);
case TT_XCOMMENT: case TT_XCOMMENT:
return parse_string (func->val1p, func->val2p); return parse_string (func->val1p, func->val2p);
case TT_XDOCUMENT:
return parse_document (func->val1p, func->val2p);
} }
} }
@ -1468,42 +1451,6 @@ parse_color (GimpRGB *color)
return OK; return OK;
} }
static gint
parse_menu_path (gpointer val1p,
gpointer val2p)
{
gchar *menu_path = NULL;
gchar *accelerator = NULL;
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
menu_path = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
accelerator = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
return OK;
error:
g_free (menu_path);
g_free (accelerator);
return ERROR;
}
static gchar * static gchar *
transform_path (gchar *path, transform_path (gchar *path,
gboolean destroy) gboolean destroy)
@ -2123,124 +2070,6 @@ parse_color_history (gpointer val1p,
return OK; return OK;
} }
static gint
parse_unit_info (gpointer val1p,
gpointer val2p)
{
gint token;
GimpUnit unit;
gchar *identifier = NULL;
gdouble factor = 1.0;
gint digits = 2.0;
gchar *symbol = NULL;
gchar *abbreviation = NULL;
gchar *singular = NULL;
gchar *plural = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
identifier = g_strdup (token_str);
/* Parse options for unit info */
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
goto error;
token = get_next_token ();
if (!strcmp ("factor", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
factor = token_num;
}
else if (!strcmp ("digits", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
digits = token_int;
}
else if (!strcmp ("symbol", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
symbol = g_strdup (token_str);
}
else if (!strcmp ("abbreviation", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
abbreviation = g_strdup (token_str);
}
else if (!strcmp ("singular", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
singular = g_strdup (token_str);
}
else if (!strcmp ("plural", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
plural = g_strdup (token_str);
}
else
goto error;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
}
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
unit = gimp_unit_new (identifier, factor, digits,
symbol, abbreviation, singular, plural);
/* make the unit definition persistent */
gimp_unit_set_deletion_flag (unit, FALSE);
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return OK;
error:
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
return ERROR;
}
static gint static gint
parse_parasite (gpointer val1p, parse_parasite (gpointer val1p,
gpointer val2p) gpointer val2p)
@ -2333,43 +2162,6 @@ parse_cursor_mode (gpointer val1p,
return OK; return OK;
} }
static gint
parse_document (gpointer val1p,
gpointer val2p)
{
gint token = 0;
gchar *filename = NULL;
GimpImagefile *imagefile;
token = peek_next_token ();
if (!token || token != TOKEN_STRING)
goto error;
token = get_next_token ();
filename = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
imagefile = gimp_imagefile_new (filename);
g_free (filename);
GIMP_LIST (the_gimp->documents)->list =
g_list_append (GIMP_LIST (the_gimp->documents)->list, imagefile);
the_gimp->documents->num_children++;
return OK;
error:
g_free (filename);
return ERROR;
}
static gint static gint
parse_unknown (gchar *token_sym) parse_unknown (gchar *token_sym)
{ {
@ -2466,13 +2258,10 @@ gimprc_value_to_str (const gchar *name)
return cursor_mode_to_str (func->val1p, func->val2p); return cursor_mode_to_str (func->val1p, func->val2p);
case TT_XCOMMENT: case TT_XCOMMENT:
return comment_to_str (func->val1p, func->val2p); return comment_to_str (func->val1p, func->val2p);
case TT_XMENUPATH:
case TT_XDEVICE: case TT_XDEVICE:
case TT_XSESSIONINFO: case TT_XSESSIONINFO:
case TT_XCOLORHISTORY: case TT_XCOLORHISTORY:
case TT_XUNITINFO:
case TT_XPARASITE: case TT_XPARASITE:
case TT_XDOCUMENT:
return NULL; return NULL;
} }
} }

View file

@ -38,7 +38,7 @@
#include "base/base-config.h" #include "base/base-config.h"
#include "core/gimpunit.h" #include "core/gimpunits.h"
#include "gui.h" #include "gui.h"
#include "resolution-calibrate-dialog.h" #include "resolution-calibrate-dialog.h"

View file

@ -21,22 +21,14 @@
#include "config.h" #include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h> #include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "plug-in-types.h" #include "plug-in-types.h"
#include "config/gimpscanner.h"
#include "plug-in.h" #include "plug-in.h"
#include "plug-ins.h" #include "plug-ins.h"
#include "plug-in-def.h" #include "plug-in-def.h"
@ -47,7 +39,7 @@
/* /*
* All functions return G_TOKEN_LEFT_PAREN on success, * All deserialize functions return G_TOKEN_LEFT_PAREN on success,
* or the GTokenType they would have expected but didn't get. * or the GTokenType they would have expected but didn't get.
*/ */
@ -63,19 +55,10 @@ static GTokenType plug_in_help_def_deserialize (GScanner *scanner,
static GTokenType plug_in_has_init_deserialize (GScanner *scanner, static GTokenType plug_in_has_init_deserialize (GScanner *scanner,
PlugInDef *plug_in_def); PlugInDef *plug_in_def);
static inline gboolean parse_token (GScanner *scanner,
GTokenType token);
static inline gboolean parse_string (GScanner *scanner,
gchar **dest);
static inline gboolean parse_string_no_validate (GScanner *scanner,
gchar **dest);
static inline gboolean parse_int (GScanner *scanner,
gint *dest);
enum enum
{ {
PLUG_IN_DEF, PLUG_IN_DEF = 1,
PROC_DEF, PROC_DEF,
LOCALE_DEF, LOCALE_DEF,
HELP_DEF, HELP_DEF,
@ -87,36 +70,27 @@ enum
gboolean gboolean
plug_in_rc_parse (const gchar *filename) plug_in_rc_parse (const gchar *filename)
{ {
gint fd;
GScanner *scanner; GScanner *scanner;
GTokenType token; GTokenType token;
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
fd = open (filename, O_RDONLY); scanner = gimp_scanner_new (filename);
if (fd == -1) if (! scanner)
return TRUE; return TRUE;
scanner = g_scanner_new (NULL); g_scanner_scope_add_symbol (scanner, 0,
scanner->config->cset_identifier_first = ( G_CSET_a_2_z );
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-_" );
g_scanner_input_file (scanner, fd);
scanner->input_name = filename;
g_scanner_scope_add_symbol (scanner, 0,
"plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF)); "plug-in-def", GINT_TO_POINTER (PLUG_IN_DEF));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"proc-def", GINT_TO_POINTER (PROC_DEF)); "proc-def", GINT_TO_POINTER (PROC_DEF));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"locale-def", GINT_TO_POINTER (LOCALE_DEF)); "locale-def", GINT_TO_POINTER (LOCALE_DEF));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"help-def", GINT_TO_POINTER (HELP_DEF)); "help-def", GINT_TO_POINTER (HELP_DEF));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"has-init", GINT_TO_POINTER (HAS_INIT)); "has-init", GINT_TO_POINTER (HAS_INIT));
g_scanner_scope_add_symbol (scanner, 0, g_scanner_scope_add_symbol (scanner, PLUG_IN_DEF,
"proc-arg", GINT_TO_POINTER (PROC_ARG)); "proc-arg", GINT_TO_POINTER (PROC_ARG));
token = G_TOKEN_LEFT_PAREN; token = G_TOKEN_LEFT_PAREN;
@ -135,8 +109,12 @@ plug_in_rc_parse (const gchar *filename)
break; break;
case G_TOKEN_SYMBOL: case G_TOKEN_SYMBOL:
if (scanner->value.v_symbol == PLUG_IN_DEF) if (scanner->value.v_symbol == GINT_TO_POINTER (PLUG_IN_DEF))
token = plug_in_def_deserialize (scanner); {
g_scanner_set_scope (scanner, PLUG_IN_DEF);
token = plug_in_def_deserialize (scanner);
g_scanner_set_scope (scanner, 0);
}
break; break;
case G_TOKEN_RIGHT_PAREN: case G_TOKEN_RIGHT_PAREN:
@ -156,8 +134,7 @@ plug_in_rc_parse (const gchar *filename)
_("fatal parse error"), TRUE); _("fatal parse error"), TRUE);
} }
g_scanner_destroy (scanner); gimp_scanner_destroy (scanner);
close (fd);
return (token != G_TOKEN_EOF); return (token != G_TOKEN_EOF);
} }
@ -170,13 +147,13 @@ plug_in_def_deserialize (GScanner *scanner)
PlugInProcDef *proc_def; PlugInProcDef *proc_def;
GTokenType token; GTokenType token;
if (!parse_string (scanner, &name)) if (! gimp_scanner_parse_string (scanner, &name))
return G_TOKEN_STRING; return G_TOKEN_STRING;
plug_in_def = plug_in_def_new (name); plug_in_def = plug_in_def_new (name);
g_free (name); g_free (name);
if (!parse_int (scanner, (gint *) &plug_in_def->mtime)) if (! gimp_scanner_parse_int (scanner, (gint *) &plug_in_def->mtime))
{ {
plug_in_def_free (plug_in_def, TRUE); plug_in_def_free (plug_in_def, TRUE);
return G_TOKEN_INT; return G_TOKEN_INT;
@ -245,7 +222,7 @@ plug_in_def_deserialize (GScanner *scanner)
{ {
token = G_TOKEN_RIGHT_PAREN; token = G_TOKEN_RIGHT_PAREN;
if (parse_token (scanner, token)) if (gimp_scanner_parse_token (scanner, token))
{ {
plug_ins_def_add (plug_in_def); plug_ins_def_add (plug_in_def);
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
@ -264,37 +241,37 @@ plug_in_proc_def_deserialize (GScanner *scanner,
GTokenType token; GTokenType token;
gint i; gint i;
if (!parse_string (scanner, &proc_def->db_info.name)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.name))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_int (scanner, (gint *) &proc_def->db_info.proc_type)) if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.proc_type))
return G_TOKEN_INT; return G_TOKEN_INT;
if (!parse_string (scanner, &proc_def->db_info.blurb)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.blurb))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->db_info.help)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.help))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->db_info.author)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.author))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->db_info.copyright)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.copyright))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->db_info.date)) if (! gimp_scanner_parse_string (scanner, &proc_def->db_info.date))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->menu_path)) if (! gimp_scanner_parse_string (scanner, &proc_def->menu_path))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->extensions)) if (! gimp_scanner_parse_string (scanner, &proc_def->extensions))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->prefixes)) if (! gimp_scanner_parse_string (scanner, &proc_def->prefixes))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string_no_validate (scanner, &proc_def->magics)) if (! gimp_scanner_parse_string_no_validate (scanner, &proc_def->magics))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &proc_def->image_types)) if (! gimp_scanner_parse_string (scanner, &proc_def->image_types))
return G_TOKEN_STRING; return G_TOKEN_STRING;
proc_def->image_types_val = proc_def->image_types_val =
plug_ins_image_types_parse (proc_def->image_types); plug_ins_image_types_parse (proc_def->image_types);
if (!parse_int (scanner, (gint *) &proc_def->db_info.num_args)) if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.num_args))
return G_TOKEN_INT; return G_TOKEN_INT;
if (!parse_int (scanner, (gint *) &proc_def->db_info.num_values)) if (! gimp_scanner_parse_int (scanner, (gint *) &proc_def->db_info.num_values))
return G_TOKEN_INT; return G_TOKEN_INT;
if (proc_def->db_info.num_args > 0) if (proc_def->db_info.num_args > 0)
@ -319,7 +296,7 @@ plug_in_proc_def_deserialize (GScanner *scanner,
return token; return token;
} }
if (!parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
@ -329,21 +306,21 @@ static GTokenType
plug_in_proc_arg_deserialize (GScanner *scanner, plug_in_proc_arg_deserialize (GScanner *scanner,
ProcArg *arg) ProcArg *arg)
{ {
if (!parse_token (scanner, G_TOKEN_LEFT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_LEFT_PAREN))
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
if (!parse_token (scanner, G_TOKEN_SYMBOL) || if (! gimp_scanner_parse_token (scanner, G_TOKEN_SYMBOL) ||
GPOINTER_TO_INT (scanner->value.v_symbol) != PROC_ARG) GPOINTER_TO_INT (scanner->value.v_symbol) != PROC_ARG)
return G_TOKEN_SYMBOL; return G_TOKEN_SYMBOL;
if (!parse_int (scanner, (gint *) &arg->arg_type)) if (! gimp_scanner_parse_int (scanner, (gint *) &arg->arg_type))
return G_TOKEN_INT; return G_TOKEN_INT;
if (!parse_string (scanner, &arg->name)) if (! gimp_scanner_parse_string (scanner, &arg->name))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_string (scanner, &arg->description)) if (! gimp_scanner_parse_string (scanner, &arg->description))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
@ -353,12 +330,12 @@ static GTokenType
plug_in_locale_def_deserialize (GScanner *scanner, plug_in_locale_def_deserialize (GScanner *scanner,
PlugInDef *plug_in_def) PlugInDef *plug_in_def)
{ {
if (!parse_string (scanner, &plug_in_def->locale_domain)) if (! gimp_scanner_parse_string (scanner, &plug_in_def->locale_domain))
return G_TOKEN_STRING; return G_TOKEN_STRING;
parse_string (scanner, &plug_in_def->locale_path); gimp_scanner_parse_string (scanner, &plug_in_def->locale_path);
if (!parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
@ -368,10 +345,10 @@ static GTokenType
plug_in_help_def_deserialize (GScanner *scanner, plug_in_help_def_deserialize (GScanner *scanner,
PlugInDef *plug_in_def) PlugInDef *plug_in_def)
{ {
if (!parse_string (scanner, &plug_in_def->help_path)) if (! gimp_scanner_parse_string (scanner, &plug_in_def->help_path))
return G_TOKEN_STRING; return G_TOKEN_STRING;
if (!parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
@ -383,81 +360,13 @@ plug_in_has_init_deserialize (GScanner *scanner,
{ {
plug_in_def->has_init = TRUE; plug_in_def->has_init = TRUE;
if (!parse_token (scanner, G_TOKEN_RIGHT_PAREN)) if (! gimp_scanner_parse_token (scanner, G_TOKEN_RIGHT_PAREN))
return G_TOKEN_RIGHT_PAREN; return G_TOKEN_RIGHT_PAREN;
return G_TOKEN_LEFT_PAREN; return G_TOKEN_LEFT_PAREN;
} }
/* helper functions */
static inline gboolean
parse_token (GScanner *scanner,
GTokenType token)
{
if (g_scanner_peek_next_token (scanner) != token)
return FALSE;
g_scanner_get_next_token (scanner);
return TRUE;
}
static inline gboolean
parse_string (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
{
if (!g_utf8_validate (scanner->value.v_string, -1, NULL))
{
g_scanner_warn (scanner, _("invalid UTF-8 string"));
return FALSE;
}
*dest = g_strdup (scanner->value.v_string);
}
return TRUE;
}
static inline gboolean
parse_string_no_validate (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
return TRUE;
}
static inline gboolean
parse_int (GScanner *scanner,
gint *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_int;
return TRUE;
}
/* serialize functions */ /* serialize functions */
static void static void
@ -618,4 +527,3 @@ plug_in_rc_write (GSList *plug_in_defs,
return TRUE; return TRUE;
} }

154
libgimpconfig/gimpscanner.c Normal file
View file

@ -0,0 +1,154 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.c
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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 <fcntl.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "gimpscanner.h"
#include "libgimp/gimpintl.h"
GScanner *
gimp_scanner_new (const gchar *filename)
{
gint fd;
GScanner *scanner;
g_return_val_if_fail (filename != NULL, NULL);
fd = open (filename, O_RDONLY);
if (fd == -1)
return NULL;
scanner = g_scanner_new (NULL);
scanner->config->cset_identifier_first = ( G_CSET_a_2_z );
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-_" );
g_scanner_input_file (scanner, fd);
scanner->input_name = g_strdup (filename);
return scanner;
}
void
gimp_scanner_destroy (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
close (scanner->input_fd);
g_free ((gchar *) scanner->input_name);
g_scanner_destroy (scanner);
}
gboolean
gimp_scanner_parse_token (GScanner *scanner,
GTokenType token)
{
if (g_scanner_peek_next_token (scanner) != token)
return FALSE;
g_scanner_get_next_token (scanner);
return TRUE;
}
gboolean
gimp_scanner_parse_string (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
{
if (! g_utf8_validate (scanner->value.v_string, -1, NULL))
{
g_scanner_warn (scanner, _("invalid UTF-8 string"));
return FALSE;
}
*dest = g_strdup (scanner->value.v_string);
}
return TRUE;
}
gboolean
gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
return TRUE;
}
gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_int;
return TRUE;
}
gboolean
gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_FLOAT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_float;
return TRUE;
}

View file

@ -0,0 +1,42 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.h
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@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.
*/
#ifndef __GIMP_SCANNER_H__
#define __GIMP_SCANNER_H__
GScanner * gimp_scanner_new (const gchar *filename);
void gimp_scanner_destroy (GScanner *scanner);
gboolean gimp_scanner_parse_token (GScanner *scanner,
GTokenType token);
gboolean gimp_scanner_parse_string (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_int (GScanner *scanner,
gint *dest);
gboolean gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest);
#endif /* __GIMP_SCANNER_H__ */