gimp/app/gimprc.c

3202 lines
78 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* 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.
1997-11-25 06:05:25 +08:00
*/
1999-03-07 20:56:03 +08:00
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdlib.h>
#include <stdio.h>
1999-03-07 20:56:03 +08:00
#ifdef HAVE_UNISTD_H
1997-11-25 06:05:25 +08:00
#include <unistd.h>
1999-03-07 20:56:03 +08:00
#endif
1997-11-25 06:05:25 +08:00
#include <string.h>
#include <errno.h>
1999-04-28 22:34:44 +08:00
#include <sys/types.h>
1997-11-25 06:05:25 +08:00
#include <sys/stat.h>
1999-03-07 20:56:03 +08:00
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
1999-03-07 20:56:03 +08:00
#endif
#include <gtk/gtk.h>
Makefile.am configure.in added new directory libgimpbase/ 2001-05-21 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool-1.4.in: added new directory libgimpbase/ * app/Makefile.am: link against the new lib. * app/appenums.h: removed the PDB enums which are in libgimpbase/gimpbasetypes.h now. They are all "Gimp" prefixed. * app/apptypes.h: #include "libgimpbase/gimpbasetypes.h" * app/[lots] * app/core/[of] * app/gui/[files] * app/tools/: changed includes and all PDB types. * app/pdb/*: regenerated. * libgimp/Makefile.am: don't build libgimpi.a uglyness any more. * libgimp/gimpenv.[ch] * libgimp/gimplimits.[hh] * libgimp/gimpparasite.[ch] * libgimp/gimpparasiteio.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimpsignal.[ch] * libgimp/gimpunit.h * libgimp/gimputils.[ch] * libgimp/gimpwire.[ch]: removed... * libgimpbase/*: ...and added here as new library. * libgimp/gimp.[ch] * libgimp/gimpdrawable.[ch] * libgimp/gimpenums.h * libgimp/gimpimage.[ch] * libgimp/gimptile.c * libgimp/gimptypes.h * libgimp/gimpunit.c: changed accordingly. Added the gimp_*_add_new_parasite to gimp.[ch], gimpdrawable.[ch] and gimpimage.[ch]. * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpsizeentry.c * libgimpwidgets/gimpunitmenu.c * libgimpwidgets/gimpwidgets.c * libgimpwidgets/gimpwidgetstypes.h: changed includes accordingly. * plug-ins/*/Makefile.am * plug-ins/common/mkgen.pl: link against libgimpbase. * tools/pdbgen/Makefile.am: scan libgimpbase/gimpbasetypes.h, so the enums are known to pdbgen... * tools/pdbgen/enumcode.pl: ...but don't write them out to libgimp/gimpenums.h * tools/pdbgen/app.pl: include libgimp/gimpbase.h in all *_cmds.c files. Added GIMP_ to the type names ganerated in app/. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/unit.pdb: changed includes.
2001-05-21 21:58:46 +08:00
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimputils.h"
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "libgimpcolor/gimpcolor.h"
#include "core/core-types.h"
#include "tools/tools-types.h"
#include "widgets/widgets-types.h"
1997-11-25 06:05:25 +08:00
#include "base/base-config.c"
#include "core/gimptoolinfo.h"
#include "tools/gimptool.h"
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
#include "widgets/gimpdialogfactory.h"
app/Makefile.am app/gui/Makefile.am app/about_dialog.[ch] 2001-04-17 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gui/Makefile.am * app/about_dialog.[ch] * app/brush_edit.[ch] * app/brush_select.[ch] * app/channels_dialog.[ch] * app/color_area.[ch] * app/color_notebook.[ch] * app/color_select.[ch] * app/colormap_dialog.[ch] * app/commands.[ch] * app/file_new_dialog.[ch] * app/gradient_editor.[ch] * app/gradient_select.[ch] * app/indicator_area.[ch] * app/info_dialog.[ch] * app/info_window.[ch] * app/layer_select.[ch] * app/layers_dialog.[ch] * app/menus.[ch] * app/palette.[ch] * app/palette_import.[ch] * app/palette_select.[ch] * app/paths_dialog.[ch] * app/pattern_select.[ch] * app/preferences_dialog.[ch] * app/session.[ch] * app/test_commands.[ch] * app/tips_dialog.[ch] * app/toolbox.[ch]: moved to gui/ (s/_/-/ and some more useful filenames on the way). * app/app_procs.c * app/context_manager.c * app/convert.c * app/disp_callbacks.c * app/errorconsole.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/gdisplay.c * app/gimage.c * app/gimprc.c * app/image_new.c * app/interface.c * app/nav_window.c * app/path.c * app/plug_in.c * app/gui/dialogs-constructors.c * app/pdb/brush_select_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpscaletool.c * app/tools/gimptransformtool.c * app/widgets/gimpcolorpanel.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * po/POTFILES.in: changed accordingly.
2001-04-18 05:43:29 +08:00
#include "gui/color-notebook.h"
#include "gui/menus.h"
#include "app_procs.h"
1997-11-25 06:05:25 +08:00
#include "appenv.h"
#include "devices.h"
1997-11-25 06:05:25 +08:00
#include "errors.h"
#include "general.h"
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimphelp.h"
#include "gimpparasite.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
#include "plug_in.h"
#include "libgimp/gimpintl.h"
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
#define ERROR 0
#define DONE 1
#define OK 2
#define LOCALE_DEF 3
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
#define HELP_DEF 4
1997-11-25 06:05:25 +08:00
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
#define DEFAULT_IMAGE_TITLE_FORMAT "%f-%p.%i (%t)"
#define DEFAULT_COMMENT "Created with The GIMP"
typedef enum
{
1997-11-25 06:05:25 +08:00
TT_STRING,
TT_PATH,
TT_DOUBLE,
TT_FLOAT,
1997-11-25 06:05:25 +08:00
TT_INT,
TT_BOOLEAN,
TT_POSITION,
TT_MEMSIZE,
TT_IMAGETYPE,
TT_INTERP,
1997-11-25 06:05:25 +08:00
TT_XPREVSIZE,
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
TT_XUNIT,
1997-11-25 06:05:25 +08:00
TT_XPLUGIN,
TT_XPLUGINDEF,
TT_XMENUPATH,
TT_XDEVICE,
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
TT_XSESSIONINFO,
TT_XCOLORHISTORY,
1999-04-12 06:28:51 +08:00
TT_XUNITINFO,
TT_XPARASITE,
TT_XNAVPREVSIZE,
TT_XHELPBROWSER,
TT_XCURSORMODE,
TT_XCOMMENT
1997-11-25 06:05:25 +08:00
} TokenType;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
1997-11-25 06:05:25 +08:00
typedef struct _ParseFunc ParseFunc;
struct _ParseFunc
{
gchar *name;
TokenType type;
gpointer val1p;
gpointer val2p;
1997-11-25 06:05:25 +08:00
};
typedef struct _UnknownToken UnknownToken;
struct _UnknownToken
{
gchar *token;
gchar *value;
1997-11-25 06:05:25 +08:00
};
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static gint get_next_token (void);
static gint peek_next_token (void);
static gint parse_statement (void);
static gint parse_string (gpointer val1p, gpointer val2p);
static gint parse_path (gpointer val1p, gpointer val2p);
static gint parse_double (gpointer val1p, gpointer val2p);
static gint parse_float (gpointer val1p, gpointer val2p);
static gint parse_int (gpointer val1p, gpointer val2p);
static gint parse_boolean (gpointer val1p, gpointer val2p);
static gint parse_position (gpointer val1p, gpointer val2p);
static gint parse_mem_size (gpointer val1p, gpointer val2p);
static gint parse_image_type (gpointer val1p, gpointer val2p);
static gint parse_interpolation_type (gpointer val1p, gpointer val2p);
static gint parse_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_plug_in (gpointer val1p, gpointer val2p);
static gint parse_plug_in_def (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_unit_info (gpointer val1p, gpointer val2p);
static gint parse_parasite (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_color_history (gpointer val1p, gpointer val2p);
static gint parse_locale_def (PlugInDef *plug_in_def);
static gint parse_help_def (PlugInDef *plug_in_def);
static gint parse_proc_def (PlugInProcDef **proc_def);
static gint parse_proc_arg (ProcArg *arg);
static gint parse_color (GimpRGB *color);
static gint parse_unknown (gchar *token_sym);
gchar * gimprc_value_to_str (gchar *name);
static gchar * value_to_str (gchar *name);
static inline gchar * string_to_str (gpointer val1p, gpointer val2p);
static inline gchar * path_to_str (gpointer val1p, gpointer val2p);
static inline gchar * double_to_str (gpointer val1p, gpointer val2p);
static inline gchar * float_to_str (gpointer val1p, gpointer val2p);
static inline gchar * int_to_str (gpointer val1p, gpointer val2p);
static inline gchar * boolean_to_str (gpointer val1p, gpointer val2p);
static inline gchar * position_to_str (gpointer val1p, gpointer val2p);
static inline gchar * mem_size_to_str (gpointer val1p, gpointer val2p);
static inline gchar * image_type_to_str (gpointer val1p, gpointer val2p);
static inline gchar * interpolation_type_to_str (gpointer val1p, gpointer val2p);
static inline gchar * preview_size_to_str (gpointer val1p, gpointer val2p);
static inline gchar * nav_preview_size_to_str (gpointer val1p, gpointer val2p);
static inline gchar * units_to_str (gpointer val1p, gpointer val2p);
static inline gchar * help_browser_to_str (gpointer val1p, gpointer val2p);
static inline gchar * cursor_mode_to_str (gpointer val1p, gpointer val2p);
static inline gchar * comment_to_str (gpointer val1p, gpointer val2p);
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static gchar * transform_path (gchar *path,
gboolean destroy);
static void gimprc_set_token (gchar *token,
gchar *value);
static void add_gimp_directory_token (const gchar *gimp_dir);
1999-04-28 22:34:44 +08:00
#ifdef __EMX__
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static void add_x11root_token (gchar *x11root);
1999-04-28 22:34:44 +08:00
#endif
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static gchar * open_backup_file (gchar *filename,
gchar *secondary_filename,
gchar **name_used,
FILE **fp_new,
FILE **fp_old);
1997-11-25 06:05:25 +08:00
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
/* global gimprc variables */
gchar *plug_in_path = NULL;
gchar *brush_path = NULL;
gchar *default_brush = NULL;
gchar *pattern_path = NULL;
gchar *default_pattern = NULL;
gchar *palette_path = NULL;
gchar *default_palette = NULL;
gchar *gradient_path = NULL;
gchar *default_gradient = NULL;
gchar *pluginrc_path = NULL;
gchar *module_path = NULL;
gint marching_speed = 300; /* 300 ms */
gdouble gamma_val = 1.0;
gint transparency_type = 1; /* Mid-Tone Checks */
gboolean perfectmouse = FALSE; /* off (fast and sloppy) */
gint transparency_size = 1; /* Medium sized */
gint levels_of_undo = 5;
gint last_opened_size = 4;
gint min_colors = 144; /* 6*6*4 */
gboolean install_cmap = FALSE;
gint cycled_marching_ants = 0;
gint default_threshold = 15;
gboolean allow_resize_windows = FALSE;
gboolean no_cursor_updating = FALSE;
gint preview_size = 32;
gint nav_preview_size = 112;
gboolean show_rulers = TRUE;
gboolean show_statusbar = TRUE;
GimpUnit default_units = GIMP_UNIT_INCH;
gboolean auto_save = TRUE;
gboolean confirm_on_close = TRUE;
gboolean save_session_info = TRUE;
gboolean save_device_status = FALSE;
gboolean always_restore_session = TRUE;
gint default_width = 256;
gint default_height = 256;
gint default_type = RGB;
gdouble default_xresolution = 72.0;
gdouble default_yresolution = 72.0;
GimpUnit default_resolution_units = GIMP_UNIT_INCH;
gchar *default_comment = NULL;
gboolean default_dot_for_dot = TRUE;
gboolean show_tips = TRUE;
gint last_tip = -1;
gboolean show_tool_tips = TRUE;
gdouble monitor_xres = 72.0;
gdouble monitor_yres = 72.0;
gboolean using_xserver_resolution = FALSE;
gchar *image_title_format = NULL;
gboolean global_paint_options = FALSE;
gchar *module_db_load_inhibit = NULL;
gboolean show_indicators = TRUE;
guint max_new_image_size = 33554432; /* 32 MB */
gint thumbnail_mode = 1;
gboolean trust_dirty_flag = FALSE;
gboolean use_help = TRUE;
gboolean nav_window_per_display = FALSE;
gboolean info_window_follows_mouse = TRUE;
gint help_browser = HELP_BROWSER_GIMP;
gint cursor_mode = CURSOR_MODE_TOOL_ICON;
gboolean disable_tearoff_menus = FALSE;
1997-11-25 06:05:25 +08:00
static GHashTable *parse_func_hash = NULL;
1997-11-25 06:05:25 +08:00
static ParseFunc funcs[] =
{
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
{ "brush-path", TT_PATH, &brush_path, NULL },
{ "pattern-path", TT_PATH, &pattern_path, NULL },
{ "plug-in-path", TT_PATH, &plug_in_path, NULL },
{ "palette-path", TT_PATH, &palette_path, NULL },
{ "gradient-path", TT_PATH, &gradient_path, NULL },
{ "pluginrc-path", TT_PATH, &pluginrc_path, NULL },
{ "module-path", TT_PATH, &module_path, NULL },
{ "default-brush", TT_STRING, &default_brush, NULL },
{ "default-pattern", TT_STRING, &default_pattern, NULL },
{ "default-palette", TT_STRING, &default_palette, NULL },
{ "default-gradient", TT_STRING, &default_gradient, NULL },
{ "gamma-correction", TT_DOUBLE, &gamma_val, NULL },
{ "marching-ants-speed", TT_INT, &marching_speed, NULL },
{ "last-opened-size", TT_INT, &last_opened_size, NULL },
{ "undo-levels", TT_INT, &levels_of_undo, NULL },
{ "transparency-type", TT_INT, &transparency_type, NULL },
{ "perfect-mouse", TT_BOOLEAN, &perfectmouse, NULL },
{ "transparency-size", TT_INT, &transparency_size, NULL },
{ "min-colors", TT_INT, &min_colors, NULL },
{ "install-colormap", TT_BOOLEAN, &install_cmap, NULL },
{ "colormap-cycling", TT_BOOLEAN, &cycled_marching_ants, NULL },
{ "default-threshold", TT_INT, &default_threshold, NULL },
{ "allow-resize-windows", TT_BOOLEAN, &allow_resize_windows, NULL },
{ "dont-allow-resize-windows", TT_BOOLEAN, NULL, &allow_resize_windows },
{ "cursor-updating", TT_BOOLEAN, NULL, &no_cursor_updating },
{ "no-cursor-updating", TT_BOOLEAN, &no_cursor_updating, NULL },
{ "preview-size", TT_XPREVSIZE, NULL, NULL },
{ "nav-preview-size", TT_XNAVPREVSIZE, NULL, NULL },
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
{ "show-rulers", TT_BOOLEAN, &show_rulers, NULL },
{ "dont-show-rulers", TT_BOOLEAN, NULL, &show_rulers },
{ "show-statusbar", TT_BOOLEAN, &show_statusbar, NULL },
{ "dont-show-statusbar", TT_BOOLEAN, NULL, &show_statusbar },
{ "default-units", TT_XUNIT, &default_units, NULL },
{ "auto-save", TT_BOOLEAN, &auto_save, NULL },
{ "dont-auto-save", TT_BOOLEAN, NULL, &auto_save },
{ "confirm-on-close", TT_BOOLEAN, &confirm_on_close, NULL },
{ "dont-confirm-on-close", TT_BOOLEAN, NULL, &confirm_on_close },
{ "save-session-info", TT_BOOLEAN, &save_session_info, NULL },
{ "dont-save-session-info", TT_BOOLEAN, NULL, &save_session_info},
{ "save-device-status", TT_BOOLEAN, &save_device_status, NULL },
{ "dont-save-device-status", TT_BOOLEAN, NULL, &save_device_status},
{ "always-restore-session", TT_BOOLEAN, &always_restore_session, NULL },
{ "show-tips", TT_BOOLEAN, &show_tips, NULL },
{ "dont-show-tips", TT_BOOLEAN, NULL, &show_tips },
{ "last-tip-shown", TT_INT, &last_tip, NULL },
{ "show-tool-tips", TT_BOOLEAN, &show_tool_tips, NULL },
{ "dont-show-tool-tips", TT_BOOLEAN, NULL, &show_tool_tips },
{ "default-image-size", TT_POSITION, &default_width, &default_height },
{ "default-image-type", TT_IMAGETYPE, &default_type, NULL },
{ "default-xresolution", TT_DOUBLE, &default_xresolution, NULL },
{ "default-yresolution", TT_DOUBLE, &default_yresolution, NULL },
{ "default-resolution-units", TT_XUNIT, &default_resolution_units, NULL },
{ "default-comment", TT_XCOMMENT, &default_comment, NULL },
{ "default-dot-for-dot", TT_BOOLEAN, &default_dot_for_dot, NULL },
{ "plug-in", TT_XPLUGIN, NULL, NULL },
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL },
{ "color-history", TT_XCOLORHISTORY, NULL, NULL },
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
{ "unit-info", TT_XUNITINFO, NULL, NULL },
{ "monitor-xresolution", TT_DOUBLE, &monitor_xres, NULL },
{ "monitor-yresolution", TT_DOUBLE, &monitor_yres, NULL },
{ "image-title-format", TT_STRING, &image_title_format, NULL },
{ "parasite", TT_XPARASITE, NULL, NULL },
{ "global-paint-options", TT_BOOLEAN, &global_paint_options, NULL },
{ "show-indicators", TT_BOOLEAN, &show_indicators, NULL },
{ "dont-show-indicators", TT_BOOLEAN, NULL, &show_indicators },
{ "no-global-paint-options", TT_BOOLEAN, NULL, &global_paint_options },
{ "module-load-inhibit", TT_PATH, &module_db_load_inhibit, NULL },
{ "max-new-image-size", TT_MEMSIZE, &max_new_image_size, NULL },
{ "thumbnail-mode", TT_INT, &thumbnail_mode, NULL },
{ "trust-dirty-flag", TT_BOOLEAN, &trust_dirty_flag, NULL },
{ "dont-trust-dirty-flag", TT_BOOLEAN, NULL, &trust_dirty_flag },
{ "use-help", TT_BOOLEAN, &use_help, NULL },
{ "dont-use-help", TT_BOOLEAN, NULL, &use_help },
{ "nav-window-per-display", TT_BOOLEAN, &nav_window_per_display, NULL },
{ "nav-window-follows-auto", TT_BOOLEAN, NULL, &nav_window_per_display },
{ "info-window-follows-mouse", TT_BOOLEAN, &info_window_follows_mouse, NULL },
{ "info-window-per-display", TT_BOOLEAN, NULL, &info_window_follows_mouse },
{ "help-browser", TT_XHELPBROWSER, &help_browser, NULL },
{ "cursor-mode", TT_XCURSORMODE, &cursor_mode, NULL },
{ "disable-tearoff-menus", TT_BOOLEAN, &disable_tearoff_menus, NULL }
1997-11-25 06:05:25 +08:00
};
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static gint n_funcs = (sizeof (funcs) /
sizeof (funcs[0]));
1997-11-25 06:05:25 +08:00
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static ParseInfo parse_info = { NULL };
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
static GList *unknown_tokens = NULL;
static gint cur_token;
static gint next_token;
/* extern variables */
extern gchar *alternate_gimprc;
extern gchar *alternate_system_gimprc;
static gchar *
1999-10-27 02:27:27 +08:00
gimp_system_rc_file (void)
1997-11-25 06:05:25 +08:00
{
static gchar *value = NULL;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
if (! value)
{
value = g_strconcat (gimp_sysconf_directory (), G_DIR_SEPARATOR_S,
"gimprc", NULL);
}
1997-11-25 06:05:25 +08:00
1999-03-07 20:56:03 +08:00
return value;
1997-11-25 06:05:25 +08:00
}
gboolean
new directory app/base/ 2001-05-15 Michael Natterer <mitch@gimp.org> * configure.in: new directory app/base/ * app/Makefile.am * app/boundary.[ch] * app/brush_scale.[ch] * app/gimpchecks.h * app/gimplut.[ch] * app/pixel_processor.[ch] * app/pixel_region.[ch] * app/pixel_surround.[ch] * app/temp_buf.[ch] * app/tile.[ch] * app/tile_cache.[ch] * app/tile_manager.[ch] * app/tile_manager_pvt.h * app/tile_pvt.h * app/tile_swap.[ch]: moved to base/ * app/base/Makefile.am * app/base/base-types.h * app/base/*: new directory for the sub-object pixel maniplation and storage stuff. Does not include Gtk+ or anything outside base/. Did some cleanup in all files. * app/appenums.h * app/apptypes.h * app/core/gimpimage.h: removed types which are now in base/base-types.h. * app/base/base-config.[ch] * app/gimprc.[ch]: put the config variables for base/ to their own file so base/ doesn not have to include gimprc.h (does not yet work, i.e. the variables are un-configurable right now) * app/main.c: set a log handler for "Gimp-Base". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs.[ch]: removed the color hash which maps RGB to color indices because it's a totally standalone system which has nothing to do with the paint-funcs and introduced a GimpImage dependency. paint-funcs/ should be considered on the same sub-object (glib-only) level as base/, only in a different directory. * app/core/Makefile.am * app/core/gimpimage-colorhash.[ch]: put the color hash here. * app/gimage.c: don't invalidate the color hash here... * app/core/gimpimage.c: ... but in the colormap_changed() default inplementation. Initialize the hash in class_init(). * tools/pdbgen/Makefile.am: scan app/base/base-types.h for enums. * tools/pdbgen/enums.pl: regenerated. * app/[lots] * app/core/[of] * app/gui/[files] * app/pdb/[all] * app/tools/[over] * app/widgets/[the] * tools/pdbgen/pdb/[place]: changed #includes accordingly. And use base_config->value instead of the stuff from gimprc.h.
2001-05-15 19:25:25 +08:00
gimprc_init (void)
1997-11-25 06:05:25 +08:00
{
if (! parse_info.buffer)
{
gint i;
static ParseFunc base_funcs[] =
{
{ "temp-path", TT_PATH, NULL, NULL },
{ "swap-path", TT_PATH, NULL, NULL },
{ "tile-cache-size", TT_MEMSIZE, NULL, NULL },
{ "stingy-memory-use", TT_BOOLEAN, NULL, NULL },
{ "interpolation-type", TT_INTERP, NULL, NULL },
{ "num-processors", TT_INT, NULL, NULL }
};
static gint n_base_funcs = (sizeof (base_funcs) /
sizeof (base_funcs[0]));
/* this hurts badly */
base_funcs[0].val1p = &base_config->temp_path;
base_funcs[1].val1p = &base_config->swap_path;
base_funcs[2].val1p = &base_config->tile_cache_size;
base_funcs[3].val1p = &base_config->stingy_memory_use;
base_funcs[4].val1p = &base_config->interpolation_type;
base_funcs[4].val1p = &base_config->num_processors;
parse_func_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < n_base_funcs; i++)
g_hash_table_insert (parse_func_hash,
base_funcs[i].name,
&base_funcs[i]);
for (i = 0; i < n_funcs; i++)
g_hash_table_insert (parse_func_hash,
funcs[i].name,
&funcs[i]);
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
parse_info.buffer = g_new (gchar, 4096);
parse_info.tokenbuf = parse_info.buffer + 2048;
parse_info.buffer_size = 2048;
parse_info.tokenbuf_size = 2048;
return TRUE;
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
return FALSE;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
}
static GList *
parse_add_directory_tokens (void)
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
{
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
const gchar *gimp_dir;
1997-11-25 06:05:25 +08:00
gimp_dir = gimp_directory ();
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
1997-11-25 06:05:25 +08:00
add_gimp_directory_token (gimp_dir);
1999-04-28 22:34:44 +08:00
#ifdef __EMX__
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
add_x11root_token (getenv ("X11ROOT"));
1999-04-28 22:34:44 +08:00
#endif
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
1999-09-27 23:23:58 +08:00
/* the real output is unknown_tokens list ! */
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
return unknown_tokens;
1999-09-27 23:23:58 +08:00
}
void
1999-10-27 02:27:27 +08:00
parse_gimprc (void)
1999-09-27 23:23:58 +08:00
{
gchar *libfilename;
gchar *filename;
1999-09-27 23:23:58 +08:00
parse_add_directory_tokens ();
1997-11-25 06:05:25 +08:00
if (alternate_system_gimprc != NULL)
libfilename = g_strdup (alternate_system_gimprc);
else
libfilename = g_strdup (gimp_system_rc_file ());
if (! parse_gimprc_file (libfilename))
g_message ("Can't open '%s' for reading.", libfilename);
1999-03-07 20:56:03 +08:00
if (alternate_gimprc != NULL)
filename = g_strdup (alternate_gimprc);
1999-03-07 20:56:03 +08:00
else
filename = gimp_personal_rc_file ("gimprc");
1999-03-07 20:56:03 +08:00
if (g_strcasecmp (filename, libfilename) != 0)
gimprc.in replaced "color-cube" by "min-colors". 2000-04-30 Michael Natterer <mitch@gimp.org> * gimprc.in * app/gimprc.[ch]: replaced "color-cube" by "min-colors". * app/app_procs.c: read unitrc/gimprc before displaying the splash. * app/colormaps.c: set min_colors and install_cmap before initializing GdkRGB. * app/gimprc.[ch] * app/gimpunit.c: don't call the splash's progress_update function. * app/plug_in.c: pass min_colors instead of color_cube to plugins. * app/preferences_dialog.c: widget for min_colors. * libgimp/gimp.[ch]: s/color_cube/min_colors/ but left gimp_color_cube() there for source level compatibility. * libgimp/gimpprotocol.[ch]: changed the GPConfig message accordinly and increased the gimp protocol version number because the change breaks binary compatibility. Also actually pass the use_xshm variable over the wire (was only in the GPConfig struct before). Was it the right thing to do to increase the version number?? * libgimp/gimpui.c (gimp_ui_init): use the same code as the app for initializing GdkRGB. Never explicitly activate Gdk's SHM usage (only switch it off). * app/main.c * libgimp/gimp.c: reverted the handling of all signals except SIGCHLD back to plain old signal() because those signals are fatal anyway and sigaction() as used by gimp_signal_*() made debugging (stacktrace) impossible. * plug-ins/AlienMap/AlienMap.c * plug-ins/AlienMap2/AlienMap2.c * plug-ins/FractalExplorer/Dialogs.c * plug-ins/bmp/bmp.c * plug-ins/borderaverage/borderaverage.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/faxg3/faxg3.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp.c * plug-ins/fp/fp_gtk.c * plug-ins/gdyntext/Makefile.am * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/gimpressionist.c * plug-ins/helpbrowser/helpbrowser.c * plug-ins/ifscompose/ifscompose.c * plug-ins/imagemap/Makefile.am * plug-ins/imagemap/imap_main.c * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print.c * plug-ins/rcm/rcm_dialog.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/Makefile.am * plug-ins/sel2path/sel2path.c * plug-ins/sgi/sgi.c * plug-ins/sinus/sinus.c * plug-ins/struc/struc.c * plug-ins/webbrowser/webbrowser.c * plug-ins/winsnap/winsnap.c * plug-ins/xjt/xjt.c: use gimp_ui_init(). * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c: only switch Gdk SHM usage off, never on. Don't use gimp_ui_init() here because of libgck.
2000-05-01 02:17:55 +08:00
parse_gimprc_file (filename);
g_free (filename);
g_free (libfilename);
if (!image_title_format)
image_title_format = g_strdup (DEFAULT_IMAGE_TITLE_FORMAT);
if (!default_comment)
default_comment = g_strdup (DEFAULT_COMMENT);
1997-11-25 06:05:25 +08:00
}
gboolean
1999-09-28 23:02:04 +08:00
parse_absolute_gimprc_file (char *filename)
1997-11-25 06:05:25 +08:00
{
gint status;
1997-11-25 06:05:25 +08:00
1999-04-28 22:34:44 +08:00
parse_info.fp = fopen (filename, "rt");
1997-11-25 06:05:25 +08:00
if (!parse_info.fp)
return FALSE;
1997-11-25 06:05:25 +08:00
if (be_verbose)
g_print (_("parsing \"%s\"\n"), filename);
1997-11-25 06:05:25 +08:00
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
cur_token = -1;
1997-11-25 06:05:25 +08:00
next_token = -1;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
parse_info.position = -1;
parse_info.linenum = 1;
parse_info.charnum = 1;
1997-11-25 06:05:25 +08:00
parse_info.inc_linenum = FALSE;
parse_info.inc_charnum = FALSE;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
while ((status = parse_statement ()) == OK);
1997-11-25 06:05:25 +08:00
fclose (parse_info.fp);
if (status == ERROR)
{
g_print (_("error parsing: \"%s\"\n"), filename);
g_print (_(" at line %d column %d\n"), parse_info.linenum, parse_info.charnum);
g_print (_(" unexpected token: %s\n"), token_sym);
return FALSE;
1997-11-25 06:05:25 +08:00
}
return TRUE;
1997-11-25 06:05:25 +08:00
}
1999-09-28 23:02:04 +08:00
gboolean
parse_gimprc_file (gchar *filename)
1999-09-28 23:02:04 +08:00
{
gchar *rfilename;
gboolean parsed;
1999-09-28 23:02:04 +08:00
if (!g_path_is_absolute (filename))
{
gchar *home_dir = g_get_home_dir ();
gchar *home_dir_sep;
if (home_dir != NULL)
1999-09-28 23:02:04 +08:00
{
if (home_dir[strlen (home_dir) -1] != G_DIR_SEPARATOR)
home_dir_sep = G_DIR_SEPARATOR_S;
else
home_dir_sep = "";
rfilename = g_strdup_printf ("%s%s%s", home_dir, home_dir_sep,
filename);
parsed = parse_absolute_gimprc_file (rfilename);
g_free (rfilename);
return parsed;
1999-09-28 23:02:04 +08:00
}
}
parsed = parse_absolute_gimprc_file (filename);
return parsed;
1999-09-28 23:02:04 +08:00
}
1997-11-25 06:05:25 +08:00
static GList *
g_list_findstr (GList *list,
gchar *str)
1997-11-25 06:05:25 +08:00
{
1999-10-27 02:27:27 +08:00
for (; list; list = g_list_next (list))
1997-11-25 06:05:25 +08:00
{
if (! strcmp ((char *) list->data, str))
break;
}
return list;
}
void
save_gimprc_strings (gchar *token,
gchar *value)
{
gchar timestamp[40]; /* variables for parsing and updating gimprc */
gchar *name;
gchar tokname[51];
FILE *fp_new;
FILE *fp_old;
gchar *cur_line;
gchar *prev_line;
gchar *error_msg;
gboolean found = FALSE;
gchar *personal_gimprc;
gchar *str;
UnknownToken *ut; /* variables to modify unknown_tokens */
UnknownToken *tmp;
GList *list;
g_assert (token != NULL);
g_assert (value != NULL);
/* get the name of the backup file, and the file pointers. 'name'
is reused in another context later, disregard it here */
1999-11-07 02:19:41 +08:00
personal_gimprc = gimp_personal_rc_file ("gimprc");
error_msg = open_backup_file (personal_gimprc,
gimp_system_rc_file (),
&name, &fp_new, &fp_old);
1999-11-07 02:19:41 +08:00
g_free (personal_gimprc);
if (error_msg != NULL)
{
g_message (error_msg);
1999-11-07 02:19:41 +08:00
g_free (error_msg);
return;
}
strcpy (timestamp, "by GIMP on ");
iso_8601_date_format (timestamp + strlen (timestamp), FALSE);
/* copy the old .gimprc into the new one, modifying it as needed */
prev_line = NULL;
cur_line = g_new (char, 1024);
while (!feof (fp_old))
{
if (!fgets (cur_line, 1024, fp_old))
continue;
/* special case: save lines starting with '#-' (added by GIMP) */
if ((cur_line[0] == '#') && (cur_line[1] == '-'))
1999-10-27 02:27:27 +08:00
{
if (prev_line != NULL)
{
1999-10-27 02:27:27 +08:00
fputs (prev_line, fp_new);
g_free (prev_line);
}
1999-10-27 02:27:27 +08:00
prev_line = g_strdup (cur_line);
continue;
}
/* see if the line contains something that we can use
and place that into 'name' if its found */
if (find_token (cur_line, tokname, 50))
1999-10-27 02:27:27 +08:00
{
/* check if that entry should be updated */
if (!g_strcasecmp (token, tokname)) /* if they match */
1999-10-27 02:27:27 +08:00
{
if (prev_line == NULL)
{
fprintf (fp_new, "#- Next line commented out %s\n",
timestamp);
fprintf (fp_new, "# %s\n", cur_line);
fprintf (fp_new, "#- Next line added %s\n",
timestamp);
}
else
{
g_free (prev_line);
prev_line = NULL;
fprintf (fp_new, "#- Next line modified %s\n",
timestamp);
}
str = gimp_strescape (value, NULL);
if (!found)
{
fprintf (fp_new, "(%s \"%s\")\n", token, str);
1999-10-27 02:27:27 +08:00
}
else
fprintf (fp_new, "#- (%s \"%s\")\n", token, str);
g_free (str);
1999-10-27 02:27:27 +08:00
found = TRUE;
continue;
} /* end if token and name match */
} /* end if token is found */
/* all lines that did not match the tests above are simply copied */
if (prev_line != NULL)
1999-10-27 02:27:27 +08:00
{
fputs (prev_line, fp_new);
g_free (prev_line);
prev_line = NULL;
}
fputs (cur_line, fp_new);
} /* end of while(!feof) */
g_free (cur_line);
if (prev_line != NULL)
g_free (prev_line);
fclose (fp_old);
/* append the options that were not in the old .gimprc */
if (!found)
{
fprintf (fp_new, "#- Next line added %s\n",
timestamp);
str = gimp_strescape (value, NULL);
fprintf (fp_new, "(%s \"%s\")\n\n", token, str);
g_free (str);
}
/* update unknown_tokens to reflect new token value */
1999-10-27 02:27:27 +08:00
ut = g_new (UnknownToken, 1);
ut->token = g_strdup (token);
ut->value = g_strdup (value);
list = unknown_tokens;
while (list)
{
tmp = (UnknownToken *) list->data;
list = list->next;
if (strcmp (tmp->token, ut->token) == 0)
{
unknown_tokens = g_list_remove (unknown_tokens, tmp);
g_free (tmp->token);
g_free (tmp->value);
g_free (tmp);
}
}
unknown_tokens = g_list_append (unknown_tokens, ut);
fclose (fp_new);
}
1997-11-25 06:05:25 +08:00
void
save_gimprc (GList **updated_options,
GList **conflicting_options)
{
gchar timestamp[40];
gchar *name;
gchar tokname[51];
FILE *fp_new;
FILE *fp_old;
1997-11-25 06:05:25 +08:00
GList *option;
gchar *cur_line;
gchar *prev_line;
gchar *str;
1999-11-07 02:19:41 +08:00
gchar *error_msg;
gchar *personal_gimprc;
1997-11-25 06:05:25 +08:00
g_assert (updated_options != NULL);
g_assert (conflicting_options != NULL);
1997-11-25 06:05:25 +08:00
1999-11-07 02:19:41 +08:00
personal_gimprc = gimp_personal_rc_file ("gimprc");
error_msg = open_backup_file (personal_gimprc,
1999-03-07 20:56:03 +08:00
gimp_system_rc_file (),
&name, &fp_new, &fp_old);
1999-11-07 02:19:41 +08:00
g_free (personal_gimprc);
1997-11-25 06:05:25 +08:00
if (error_msg != NULL)
1997-11-25 06:05:25 +08:00
{
g_message (error_msg);
1999-11-07 02:19:41 +08:00
g_free (error_msg);
1997-11-25 06:05:25 +08:00
return;
}
strcpy (timestamp, "by GIMP on ");
iso_8601_date_format (timestamp + strlen (timestamp), FALSE);
/* copy the old .gimprc into the new one, modifying it as needed */
prev_line = NULL;
cur_line = g_new (char, 1024);
while (!feof (fp_old))
{
if (!fgets (cur_line, 1024, fp_old))
continue;
/* special case: save lines starting with '#-' (added by GIMP) */
if ((cur_line[0] == '#') && (cur_line[1] == '-'))
{
if (prev_line != NULL)
{
fputs (prev_line, fp_new);
g_free (prev_line);
}
prev_line = g_strdup (cur_line);
continue;
}
/* see if the line contains something that we can use */
if (find_token (cur_line, tokname, 50))
1997-11-25 06:05:25 +08:00
{
/* check if that entry should be updated */
option = g_list_findstr (*updated_options, tokname);
1997-11-25 06:05:25 +08:00
if (option != NULL)
{
if (prev_line == NULL)
{
fprintf (fp_new, "#- Next line commented out %s\n",
timestamp);
fprintf (fp_new, "# %s\n", cur_line);
fprintf (fp_new, "#- Next line added %s\n",
timestamp);
}
else
{
g_free (prev_line);
prev_line = NULL;
fprintf (fp_new, "#- Next line modified %s\n",
timestamp);
}
str = value_to_str (tokname);
fprintf (fp_new, "(%s %s)\n", tokname, str);
1997-11-25 06:05:25 +08:00
g_free (str);
*updated_options = g_list_remove_link (*updated_options, option);
*conflicting_options = g_list_concat (*conflicting_options,
option);
1997-11-25 06:05:25 +08:00
continue;
}
/* check if that entry should be commented out */
option = g_list_findstr (*conflicting_options, tokname);
1997-11-25 06:05:25 +08:00
if (option != NULL)
{
if (prev_line != NULL)
{
g_free (prev_line);
prev_line = NULL;
}
fprintf (fp_new, "#- Next line commented out %s\n",
timestamp);
fprintf (fp_new, "# %s\n", cur_line);
continue;
}
}
/* all lines that did not match the tests above are simply copied */
if (prev_line != NULL)
{
fputs (prev_line, fp_new);
g_free (prev_line);
prev_line = NULL;
}
fputs (cur_line, fp_new);
}
g_free (cur_line);
if (prev_line != NULL)
g_free (prev_line);
fclose (fp_old);
/* append the options that were not in the old .gimprc */
option = *updated_options;
while (option)
{
fprintf (fp_new, "#- Next line added %s\n",
timestamp);
str = value_to_str ((char *) option->data);
fprintf (fp_new, "(%s %s)\n\n", (char *) option->data, str);
g_free (str);
option = option->next;
}
fclose (fp_new);
}
static gint
1999-10-27 02:27:27 +08:00
get_next_token (void)
1997-11-25 06:05:25 +08:00
{
if (next_token != -1)
{
cur_token = next_token;
next_token = -1;
}
else
{
cur_token = get_token (&parse_info);
}
return cur_token;
}
static gint
1999-10-27 02:27:27 +08:00
peek_next_token (void)
1997-11-25 06:05:25 +08:00
{
if (next_token == -1)
next_token = get_token (&parse_info);
return next_token;
}
static gint
1999-10-27 02:27:27 +08:00
parse_statement (void)
1997-11-25 06:05:25 +08:00
{
ParseFunc *func;
gint token;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token)
return DONE;
if (token != TOKEN_LEFT_PAREN)
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
func = g_hash_table_lookup (parse_func_hash, token_sym);
if (func)
{
switch (func->type)
1997-11-25 06:05:25 +08:00
{
case TT_STRING:
return parse_string (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_PATH:
return parse_path (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_DOUBLE:
return parse_double (func->val1p, func->val2p);
case TT_FLOAT:
return parse_float (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_INT:
return parse_int (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_BOOLEAN:
return parse_boolean (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_POSITION:
return parse_position (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_MEMSIZE:
return parse_mem_size (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_IMAGETYPE:
return parse_image_type (func->val1p, func->val2p);
case TT_INTERP:
return parse_interpolation_type (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XPREVSIZE:
return parse_preview_size (func->val1p, func->val2p);
case TT_XNAVPREVSIZE:
return parse_nav_preview_size (func->val1p, func->val2p);
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
case TT_XUNIT:
return parse_units (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XPLUGIN:
return parse_plug_in (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XPLUGINDEF:
return parse_plug_in_def (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XMENUPATH:
return parse_menu_path (func->val1p, func->val2p);
case TT_XDEVICE:
return parse_device (func->val1p, func->val2p);
case TT_XSESSIONINFO:
return parse_session_info (func->val1p, func->val2p);
case TT_XCOLORHISTORY:
return parse_color_history (func->val1p, func->val2p);
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
case TT_XUNITINFO:
return parse_unit_info (func->val1p, func->val2p);
1999-04-12 06:28:51 +08:00
case TT_XPARASITE:
return parse_parasite (func->val1p, func->val2p);
case TT_XHELPBROWSER:
return parse_help_browser (func->val1p, func->val2p);
case TT_XCURSORMODE:
return parse_cursor_mode (func->val1p, func->val2p);
case TT_XCOMMENT:
return parse_string (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
}
}
1997-11-25 06:05:25 +08:00
return parse_unknown (token_sym);
}
static gint
1997-11-25 06:05:25 +08:00
parse_path (gpointer val1p,
gpointer val2p)
{
gint token;
gchar **pathp;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
pathp = (char **)val1p;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
if (*pathp)
g_free (*pathp);
*pathp = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
{
g_free (*pathp);
*pathp = NULL;
return ERROR;
}
token = get_next_token ();
*pathp = transform_path (*pathp, TRUE);
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_string (gpointer val1p,
gpointer val2p)
{
gint token;
gchar **strp;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
strp = (gchar **)val1p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
if (*strp)
g_free (*strp);
*strp = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
{
g_free (*strp);
*strp = NULL;
return ERROR;
}
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_double (gpointer val1p,
gpointer val2p)
{
gint token;
gdouble *nump;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
nump = (gdouble *) val1p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*nump = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_float (gpointer val1p,
gpointer val2p)
{
gint token;
gfloat *nump;
g_assert (val1p != NULL);
nump = (gfloat *) val1p;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*nump = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_int (gpointer val1p,
gpointer val2p)
{
gint token;
gint *nump;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
nump = (gint *) val1p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*nump = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_boolean (gpointer val1p,
gpointer val2p)
{
gint token;
gint *boolp;
1997-11-25 06:05:25 +08:00
/* The variable to be set should be passed in the first or second
* pointer. If the pointer is in val2p, then the opposite value is
* stored in the pointer. This is useful for "dont-xxx" or "no-xxx"
* type of options.
* If the expression to be parsed is written as "(option)" instead
* of "(option yes)" or "(option no)", then the default value is
* TRUE if the variable is passed in val1p, or FALSE if in val2p.
*/
g_assert (val1p != NULL || val2p != NULL);
if (val1p != NULL)
boolp = (gint *) val1p;
1997-11-25 06:05:25 +08:00
else
boolp = (gint *) val2p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token)
return ERROR;
switch (token)
{
case TOKEN_RIGHT_PAREN:
*boolp = TRUE;
break;
case TOKEN_NUMBER:
token = get_next_token ();
*boolp = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
break;
case TOKEN_SYMBOL:
token = get_next_token ();
if (!strcmp (token_sym, "true") || !strcmp (token_sym, "on")
|| !strcmp (token_sym, "yes"))
*boolp = TRUE;
else if (!strcmp (token_sym, "false") || !strcmp (token_sym, "off")
|| !strcmp (token_sym, "no"))
*boolp = FALSE;
else
return ERROR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
break;
default:
return ERROR;
}
if (val1p == NULL)
*boolp = !*boolp;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_position (gpointer val1p,
gpointer val2p)
{
gint token;
gint *xp;
gint *yp;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL && val2p != NULL);
xp = (gint *) val1p;
yp = (gint *) val2p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*xp = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
*yp = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_mem_size (gpointer val1p,
gpointer val2p)
{
gint suffix;
gint token;
guint mult;
guint *sizep;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
sizep = (guint *) val1p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || ((token != TOKEN_NUMBER) &&
(token != TOKEN_SYMBOL)))
return ERROR;
token = get_next_token ();
if (token == TOKEN_NUMBER)
{
*sizep = token_num * 1024;
}
else
{
*sizep = atoi (token_sym);
suffix = token_sym[strlen (token_sym) - 1];
if ((suffix == 'm') || (suffix == 'M'))
mult = 1024 * 1024;
else if ((suffix == 'k') || (suffix == 'K'))
mult = 1024;
else if ((suffix == 'b') || (suffix == 'B'))
mult = 1;
else
return FALSE;
*sizep *= mult;
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_image_type (gpointer val1p,
gpointer val2p)
{
gint token;
gint *typep;
1997-11-25 06:05:25 +08:00
g_assert (val1p != NULL);
typep = (gint *) val1p;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (!strcmp (token_sym, "rgb"))
*typep = RGB;
else if ((!strcmp (token_sym, "gray")) || (!strcmp (token_sym, "grey")))
*typep = GRAY;
else
return ERROR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_interpolation_type (gpointer val1p,
gpointer val2p)
{
gint token;
InterpolationType *typep;
g_assert (val1p != NULL);
typep = (InterpolationType *) val1p;
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (strcmp (token_sym, "nearest-neighbor") == 0)
*typep = NEAREST_NEIGHBOR_INTERPOLATION;
else if (strcmp (token_sym, "linear") == 0)
*typep = LINEAR_INTERPOLATION;
else if (strcmp (token_sym, "cubic") == 0)
*typep = CUBIC_INTERPOLATION;
else
return ERROR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_preview_size (gpointer val1p,
gpointer val2p)
{
gint token;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL && token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
if (token == TOKEN_SYMBOL)
{
if (strcmp (token_sym, "none") == 0)
preview_size = 0;
1999-10-09 21:37:34 +08:00
else if (strcmp (token_sym, "tiny") == 0)
preview_size = 24;
1997-11-25 06:05:25 +08:00
else if (strcmp (token_sym, "small") == 0)
preview_size = 32;
else if (strcmp (token_sym, "medium") == 0)
1999-10-09 21:37:34 +08:00
preview_size = 48;
1997-11-25 06:05:25 +08:00
else if (strcmp (token_sym, "large") == 0)
1999-10-09 21:37:34 +08:00
preview_size = 64;
else if (strcmp (token_sym, "huge") == 0)
1997-11-25 06:05:25 +08:00
preview_size = 128;
else
preview_size = 0;
}
else if (token == TOKEN_NUMBER)
preview_size = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_nav_preview_size (gpointer val1p,
gpointer val2p)
{
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL && token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
if (token == TOKEN_SYMBOL)
{
/* if (strcmp (token_sym, "none") == 0) */
/* preview_size = 0; */
/* else */
if (strcmp (token_sym, "small") == 0)
nav_preview_size = 48;
else if (strcmp (token_sym, "medium") == 0)
nav_preview_size = 80;
else if (strcmp (token_sym, "large") == 0)
nav_preview_size = 112;
else
nav_preview_size = 112;
}
else if (token == TOKEN_NUMBER)
nav_preview_size = token_num;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_units (gpointer val1p,
gpointer val2p)
1997-11-25 06:05:25 +08:00
{
gint token;
gint i;
g_assert (val1p != NULL);
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
*((GimpUnit *) val1p) = GIMP_UNIT_INCH;
for (i = GIMP_UNIT_INCH; i < gimp_unit_get_number_of_units (); i++)
if (strcmp (token_sym, gimp_unit_get_identifier (i)) == 0)
{
*((GimpUnit *) val1p) = i;
break;
}
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_plug_in (gpointer val1p,
gpointer val2p)
{
gchar *name = NULL;
gchar *menu_path = NULL;
gchar *accelerator = NULL;
gint token;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
name = g_strdup (token_str);
token = peek_next_token ();
if (token == TOKEN_STRING)
{
menu_path = g_strdup (token_str);
token = get_next_token ();
}
token = peek_next_token ();
if (token == TOKEN_STRING)
{
accelerator = g_strdup (token_str);
token = get_next_token ();
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
{
g_free (name);
g_free (menu_path);
g_free (accelerator);
return ERROR;
}
token = get_next_token ();
if (name && menu_path)
plug_in_add (name, menu_path, accelerator);
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_plug_in_def (gpointer val1p,
gpointer val2p)
{
PlugInDef *plug_in_def;
1997-11-25 06:05:25 +08:00
PlugInProcDef *proc_def;
gint token;
gint success;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
plug_in_def = plug_in_def_new (token_str);
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
plug_in_def->mtime = token_int;
success = OK;
while (success == OK)
1997-11-25 06:05:25 +08:00
{
success = parse_proc_def (&proc_def);
if (success == OK)
{
proc_def->mtime = plug_in_def->mtime;
proc_def->prog = g_strdup (plug_in_def->prog);
plug_in_def->proc_defs = g_slist_append (plug_in_def->proc_defs,
proc_def);
}
else if (success == LOCALE_DEF)
success = parse_locale_def (plug_in_def);
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
else if (success == HELP_DEF)
success = parse_help_def (plug_in_def);
1997-11-25 06:05:25 +08:00
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
plug_in_def_add (plug_in_def);
return OK;
1999-10-27 02:27:27 +08:00
error:
g_message (_("error parsing pluginrc"));
plug_in_def_free (plug_in_def, TRUE);
return ERROR;
}
static gint
parse_locale_def (PlugInDef *plug_in_def)
{
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
if (plug_in_def->locale_domain)
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = g_strdup (token_str);
token = peek_next_token ();
if (token && token == TOKEN_STRING)
1997-11-25 06:05:25 +08:00
{
token = get_next_token ();
if (plug_in_def->locale_path)
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = g_strdup (token_str);
token = peek_next_token ();
1997-11-25 06:05:25 +08:00
}
if (!token || token != TOKEN_RIGHT_PAREN)
goto error;
token = get_next_token ();
return OK;
error:
g_free (plug_in_def->locale_domain);
plug_in_def->locale_domain = NULL;
g_free (plug_in_def->locale_path);
plug_in_def->locale_path = NULL;
1997-11-25 06:05:25 +08:00
return ERROR;
}
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
static gint
parse_help_def (PlugInDef *plug_in_def)
{
gint token;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
if (plug_in_def->help_path)
g_free (plug_in_def->help_path);
plug_in_def->help_path = 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 (plug_in_def->help_path);
plug_in_def->help_path = NULL;
return ERROR;
}
static gint
1997-11-25 06:05:25 +08:00
parse_proc_def (PlugInProcDef **proc_def)
{
PlugInProcDef *pd;
gint token;
gint i;
1997-11-25 06:05:25 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_LEFT_PAREN))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
1997-11-25 06:05:25 +08:00
return ERROR;
if ((strcmp ("locale-def", token_sym) == 0))
{
token = get_next_token ();
/* it's a locale_def, let parse_locale_def do the rest */
return LOCALE_DEF;
}
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
if ((strcmp ("help-def", token_sym) == 0))
{
token = get_next_token ();
/* it's a help_def, let parse_help_def do the rest */
return HELP_DEF;
These changes enable help support for 3rd party plug-ins which install 2000-05-21 Michael Natterer <mitch@gimp.org> These changes enable help support for 3rd party plug-ins which install their help files outside GIMP's main help dir. Instead of calling gimp_help(), gimp_plugin_help_func() etc., all help callbacks now have to call gimp_standard_help_func() which has different implementations in the app and in libgimp. There is a new function gimp_plugin_help_register() which can be called during plug-in query. plug_in.c keeps a list of executable_name/help_path pairs. Plug-ins have to pass their exec. name to gimp_help() which uses the list to find the plug-in's help directory. * app/gimphelp.[ch]: gimp_help() now takes a help_path parameter. help_path == NULL means the standard help directory. Various changes to pass the help_path to the help browser. * app/gimprc.c: save the plug-in's help_path in the pluginrc file. * app/menus.c: ugly hack to enable help_paths in the "F1" callback. * app/plug_in.[ch]: many help_path related changes. Use g_basename() instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups. * app/internal_procs.c * app/gimphelp_cmds.c * tools/pdbgen/pdb/gimphelp.pdb: new procedure gimp_plugin_help_register(). gimp_help() takes a second parameter which is the executable name (not the help_path). * app/color_notebook.c * app/commands.c * app/lc_dialog.c * app/preferences_dialog.c * app/tools.c: call gimp_standard_help_func() instead of gimp_help(). * libgimp/gimp.c: new function gimp_get_progname() which returns the full path of the plug-in's executable. * libgimp/gimp.h: export the new function, removed gimp_plugin_help_func(), gimp_help() takes the executable name as second parameter. * libgimp/gimpcompat.h: added gimp_plugin_help_func(). * libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(), changed the calls to gimp_help. * libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead of gimp_help(). * plug-ins/helpbrowser/helpbrowser.c: now called with an additional help_path parameter. Various changes to enable help_path != gimp_standard_help_path. Unrelated stuff: * app/batch.h: added missing GPL header. * app/gimpunit.c: had a LGPL header, merged some fprintf's into one call. * app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/, prototypes, indentation. * app/resize.c: use less packing widgets. didn't find the "offset" redraw bug :(
2000-05-22 01:41:02 +08:00
}
else if (strcmp ("proc-def", token_sym) != 0)
return ERROR;
1997-11-25 06:05:25 +08:00
token = get_next_token ();
pd = g_new0 (PlugInProcDef, 1);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.name = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.proc_type = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.blurb = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.help = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.author = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.copyright = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pd->db_info.date = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->menu_path = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->extensions = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->prefixes = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
pd->magics = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
if (token_str[0] != '\0')
{
pd->image_types = g_strdup (token_str);
pd->image_types_val = plug_in_image_types_parse (token_str);
}
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.num_args = token_int;
pd->db_info.args = g_new0 (ProcArg, pd->db_info.num_args);
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
pd->db_info.num_values = token_int;
pd->db_info.values = NULL;
if (pd->db_info.num_values > 0)
pd->db_info.values = g_new (ProcArg, pd->db_info.num_values);
for (i = 0; i < pd->db_info.num_args; i++)
if (!parse_proc_arg (&pd->db_info.args[i]))
goto error;
for (i = 0; i < pd->db_info.num_values; i++)
if (!parse_proc_arg (&pd->db_info.values[i]))
goto error;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
*proc_def = pd;
1997-11-25 06:05:25 +08:00
return OK;
1999-10-27 02:27:27 +08:00
error:
1997-11-25 06:05:25 +08:00
g_free (pd->db_info.name);
g_free (pd->db_info.blurb);
g_free (pd->db_info.help);
g_free (pd->db_info.author);
g_free (pd->db_info.copyright);
g_free (pd->db_info.date);
g_free (pd->menu_path);
g_free (pd->extensions);
g_free (pd->prefixes);
g_free (pd->magics);
g_free (pd->image_types);
for (i = 0; i < pd->db_info.num_args; i++)
{
g_free (pd->db_info.args[i].name);
g_free (pd->db_info.args[i].description);
}
for (i = 0; i < pd->db_info.num_values; i++)
{
g_free (pd->db_info.values[i].name);
g_free (pd->db_info.values[i].description);
}
g_free (pd->db_info.args);
g_free (pd->db_info.values);
g_free (pd);
1997-11-25 06:05:25 +08:00
return ERROR;
}
static gint
1997-11-25 06:05:25 +08:00
parse_proc_arg (ProcArg *arg)
{
gint token;
1997-11-25 06:05:25 +08:00
arg->arg_type = -1;
arg->name = NULL;
1997-11-25 06:05:25 +08:00
arg->description = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_LEFT_PAREN))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL) ||
(strcmp ("proc-arg", token_sym) != 0))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
arg->arg_type = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
arg->name = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
arg->description = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
return OK;
1999-10-27 02:27:27 +08:00
error:
1997-11-25 06:05:25 +08:00
g_free (arg->name);
g_free (arg->description);
return ERROR;
}
static gint
parse_color (GimpRGB *color)
{
gdouble col[4] = { 0.0, 0.0, 0.0, 1.0 };
gint token;
gint i;
gint n_channels;
gboolean is_hsv;
g_return_val_if_fail (color != NULL, ERROR);
token = peek_next_token ();
if (!token || (token != TOKEN_LEFT_PAREN))
return ERROR;
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (! strcmp ("color-rgb", token_sym))
{
is_hsv = FALSE;
n_channels = 3;
}
else if (! strcmp ("color-rgba", token_sym))
{
is_hsv = FALSE;
n_channels = 4;
}
else if (! strcmp ("color-hsv", token_sym))
{
is_hsv = TRUE;
n_channels = 3;
}
else if (! strcmp ("color-hsva", token_sym))
{
is_hsv = TRUE;
n_channels = 4;
}
else
{
return ERROR;
}
for (i = 0; i < n_channels; i++)
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
col[i] = token_num;
}
if (is_hsv)
{
GimpHSV hsv;
gimp_hsva_set (&hsv, col[0], col[1], col[2], col[3]);
gimp_hsv_clamp (&hsv);
gimp_hsv_to_rgb (&hsv, color);
}
else
{
gimp_rgba_set (color, col[0], col[1], col[2], col[3]);
gimp_rgb_clamp (color);
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
1997-11-25 06:05:25 +08:00
parse_menu_path (gpointer val1p,
gpointer val2p)
{
gchar *menu_path = NULL;
gchar *accelerator = NULL;
gint token;
1997-11-25 06:05:25 +08:00
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;
1999-10-27 02:27:27 +08:00
error:
1997-11-25 06:05:25 +08:00
g_free (menu_path);
g_free (accelerator);
return ERROR;
}
static gchar *
transform_path (gchar *path,
gboolean destroy)
1997-11-25 06:05:25 +08:00
{
gint length = 0;
gchar *new_path;
gchar *home;
gchar *token;
gchar *tmp;
gchar *tmp2;
gboolean substituted = FALSE;
gboolean is_env = FALSE;
UnknownToken *ut;
1997-11-25 06:05:25 +08:00
home = g_get_home_dir ();
1997-11-25 06:05:25 +08:00
tmp = path;
1997-11-25 06:05:25 +08:00
while (*tmp)
{
#ifndef G_OS_WIN32
1997-11-25 06:05:25 +08:00
if (*tmp == '~')
{
length += strlen (home);
tmp += 1;
}
else
#endif
if (*tmp == '$')
1997-11-25 06:05:25 +08:00
{
tmp += 1;
if (!*tmp || (*tmp != '{'))
return path;
tmp += 1;
token = tmp;
while (*tmp && (*tmp != '}'))
tmp += 1;
if (!*tmp)
return path;
*tmp = '\0';
tmp2 = gimprc_find_token (token);
if (tmp2 == NULL)
{
/* maybe token is an environment variable */
1999-03-07 20:56:03 +08:00
tmp2 = g_getenv (token);
#ifdef G_OS_WIN32
/* The default user gimprc on Windows references
* ${TEMP}, but not all Windows installations have that
* environment variable, even if it should be kinda
* standard. So special-case it.
*/
if (tmp2 == NULL &&
(g_strcasecmp (token, "temp") == 0 ||
g_strcasecmp (token, "tmp") == 0))
{
tmp2 = g_get_tmp_dir ();
}
#endif
if (tmp2 != NULL)
{
is_env = TRUE;
}
else
{
1999-12-28 22:09:20 +08:00
gimp_terminate ("transform_path(): gimprc token referenced but not defined: %s", token);
}
}
1997-11-25 06:05:25 +08:00
tmp2 = transform_path (tmp2, FALSE);
if (is_env)
{
/* then add to list of unknown tokens */
/* but only if it isn't already in list */
if (gimprc_find_token (token) == NULL)
{
ut = g_new (UnknownToken, 1);
ut->token = g_strdup (token);
ut->value = g_strdup (tmp2);
unknown_tokens = g_list_append (unknown_tokens, ut);
}
}
else
{
gimprc_set_token (token, tmp2);
}
1997-11-25 06:05:25 +08:00
length += strlen (tmp2);
*tmp = '}';
tmp += 1;
substituted = TRUE;
}
else
{
length += 1;
tmp += 1;
}
}
if ((length == strlen (path)) && !substituted)
return path;
new_path = g_new (char, length + 1);
tmp = path;
tmp2 = new_path;
while (*tmp)
{
#ifndef G_OS_WIN32
1997-11-25 06:05:25 +08:00
if (*tmp == '~')
{
*tmp2 = '\0';
strcat (tmp2, home);
tmp2 += strlen (home);
tmp += 1;
}
else
#endif
if (*tmp == '$')
1997-11-25 06:05:25 +08:00
{
tmp += 1;
if (!*tmp || (*tmp != '{'))
{
g_free (new_path);
return path;
}
tmp += 1;
token = tmp;
while (*tmp && (*tmp != '}'))
tmp += 1;
if (!*tmp)
{
g_free (new_path);
return path;
}
*tmp = '\0';
token = gimprc_find_token (token);
*tmp = '}';
*tmp2 = '\0';
strcat (tmp2, token);
tmp2 += strlen (token);
tmp += 1;
}
else
{
*tmp2++ = *tmp++;
}
}
*tmp2 = '\0';
if (destroy)
g_free (path);
return new_path;
}
/* Copied from gtk_menu_factory_parse_accelerator() */
static void
parse_device_accelerator (const gchar *accelerator,
GdkDeviceKey *key)
{
gboolean done = FALSE;
g_return_if_fail (accelerator != NULL);
g_return_if_fail (key != NULL);
key->modifiers = 0;
while (!done)
{
if (strncmp (accelerator, "<shift>", 7) == 0)
{
accelerator += 7;
key->modifiers |= GDK_SHIFT_MASK;
}
else if (strncmp (accelerator, "<alt>", 5) == 0)
{
accelerator += 5;
key->modifiers |= GDK_MOD1_MASK;
}
else if (strncmp (accelerator, "<control>", 9) == 0)
{
accelerator += 9;
key->modifiers |= GDK_CONTROL_MASK;
}
else
{
done = TRUE;
/* Tricky, but works... ("" => keyval = 0, or no translation) */
key->keyval = accelerator[0];
}
}
}
1999-10-27 02:27:27 +08:00
static gint
parse_device (gpointer val1p,
gpointer val2p)
{
DeviceValues values = 0;
gint i;
gint token;
/* The initialized values here are meaningless */
gchar *name = NULL;
GdkInputMode mode = GDK_MODE_DISABLED;
gint num_axes = 0;
GdkAxisUse *axes = NULL;
gint num_keys = 0;
GdkDeviceKey *keys = NULL;
1999-10-27 02:27:27 +08:00
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
gchar *tool_name = NULL;
GimpRGB foreground = { 1.0, 1.0, 1.0, 1.0 };
GimpRGB background = { 0.0, 0.0, 0.0, 1.0 };
gchar *brush_name = NULL;
gchar *pattern_name = NULL;
gchar *gradient_name = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
name = g_strdup (token_str);
/* Parse options for device */
1999-10-27 02:27:27 +08:00
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 ("mode", token_sym))
{
values |= DEVICE_MODE;
1999-10-27 02:27:27 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
goto error;
token = get_next_token ();
if (!strcmp ("disabled", token_sym))
mode = GDK_MODE_DISABLED;
else if (!strcmp ("window", token_sym))
mode = GDK_MODE_WINDOW;
else if (!strcmp ("screen", token_sym))
mode = GDK_MODE_SCREEN;
else
goto error;
}
else if (!strcmp ("axes", token_sym))
{
values |= DEVICE_AXES;
1999-10-27 02:27:27 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
num_axes = token_int;
axes = g_new (GdkAxisUse, num_axes);
1999-10-27 02:27:27 +08:00
for (i = 0; i < num_axes; i++)
{
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
goto error;
token = get_next_token ();
1999-10-27 02:27:27 +08:00
if (!strcmp ("ignore", token_sym))
axes[i] = GDK_AXIS_IGNORE;
else if (!strcmp ("x", token_sym))
axes[i] = GDK_AXIS_X;
else if (!strcmp ("y", token_sym))
axes[i] = GDK_AXIS_Y;
else if (!strcmp ("pressure", token_sym))
axes[i] = GDK_AXIS_PRESSURE;
else if (!strcmp ("xtilt", token_sym))
axes[i] = GDK_AXIS_XTILT;
else if (!strcmp ("ytilt", token_sym))
axes[i] = GDK_AXIS_YTILT;
else
goto error;
}
}
else if (!strcmp ("keys", token_sym))
{
values |= DEVICE_KEYS;
1999-10-27 02:27:27 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
num_keys = token_int;
keys = g_new (GdkDeviceKey, num_keys);
1999-10-27 02:27:27 +08:00
for (i=0; i<num_keys; i++)
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
1999-10-27 02:27:27 +08:00
parse_device_accelerator (token_str, &keys[i]);
}
}
else if (!strcmp ("tool", token_sym))
{
values |= DEVICE_TOOL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
tool_name = g_strdup (token_str);
}
else if (!strcmp ("foreground", token_sym))
{
values |= DEVICE_FOREGROUND;
1999-10-27 02:27:27 +08:00
if (parse_color (&foreground) == ERROR)
goto error;
foreground.a = 1.0;
}
1999-10-27 02:27:27 +08:00
else if (!strcmp ("background", token_sym))
{
values |= DEVICE_BACKGROUND;
if (parse_color (&background) == ERROR)
goto error;
background.a = 1.0;
1999-10-27 02:27:27 +08:00
}
else if (!strcmp ("brush", token_sym))
{
values |= DEVICE_BRUSH;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
brush_name = g_strdup (token_str);
}
else if (!strcmp ("pattern", token_sym))
{
values |= DEVICE_PATTERN;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
pattern_name = g_strdup (token_str);
}
else if (!strcmp ("gradient", token_sym))
{
values |= DEVICE_GRADIENT;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
gradient_name = 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 ();
devices_rc_update (name, values, mode, num_axes, axes, num_keys, keys,
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
tool_name,
&foreground,
&background,
1999-10-27 02:27:27 +08:00
brush_name,
pattern_name,
gradient_name);
Made the tool system work again and integrated it back with the 2001-02-21 Michael Natterer <mitch@gimp.org> Made the tool system work again and integrated it back with the GimpContext. It's a hack between old, new and freshly hacked stuff. There are still lots of warnings but at least we can switch tools again. * app/tools/Makefile.am * app/tools/gimptoolinfo.[ch]: resurrected as real object. The GimpToolInfo objects are derived from GimpData, which gives us the tool icon stuff for free. Also, we need a list of _objects_ which is allocated all the time. All tools are required to have a "register" function which registers themselves with the list of GimpToolInfo objects which is maintained by the tool manager. * app/tools/tool.[ch]: made a real GtkObject with properly named functions out of it. The former "active_tool_control" is of course not the default implementation of the tool's "control" method but a hack _around_ it, so it went to the tool manager. * app/tools/color_picker.[ch] * app/tools/measure.[ch]: ditto. Added "register" functions and "destroy" implementations so the tools go away after use. * app/tools/tool_manager.[ch]: badly hacked at the moment to keep both the list of class structures _and_ the tool info list. * app/tools/tools.c: call the tools' register functions. * app/gimpcontext.[ch]: store a pointer to a GimpToolInfo object as "active_tool" in the context, so we're independent of tools being allocated or not. It's treated just like a brush or pattern now. * app/gimpdnd.[ch]: made tool DND work like all other DND types. * app/devices.[ch]: also here: the tool is just a normal data object now, resulting in removal of lots of code. * app/commands.c * app/context_manager.c: updated the tool select and context stuff to work again. * app/toolbox.c: removed the old pixmap buttons and put GimpPreviews inside the tool buttons. Still needs an own preview type to look nice. * app/disp_callbacks.c * app/about_dialog.c * app/app_procs.c * app/appenums.h * app/apptypes.h * app/gimage.c * app/gimppalette.c * app/gimppreview.c * app/gimprc.c * app/info_window.c * app/menus.c * app/palette_select.h * app/scale.c * app/scroll.c: lots of changes to make it work again.
2001-02-21 20:18:09 +08:00
g_free (tool_name);
g_free (brush_name);
g_free (pattern_name);
1999-10-27 02:27:27 +08:00
g_free (gradient_name);
g_free (name);
g_free (axes);
g_free (keys);
return OK;
1999-10-27 02:27:27 +08:00
error:
g_free (brush_name);
1999-10-27 02:27:27 +08:00
g_free (pattern_name);
g_free (gradient_name);
g_free (name);
g_free (axes);
g_free (keys);
return ERROR;
}
static gint
parse_session_info (gpointer val1p,
gpointer val2p)
{
gint token;
GimpDialogFactory *factory;
GimpSessionInfo *info = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
factory = gimp_dialog_factory_from_name (token_str);
if (! factory)
goto error;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
info = g_new0 (GimpSessionInfo, 1);
if (strcmp (token_str, "dock"))
{
info->toplevel_entry = gimp_dialog_factory_find_entry (factory, token_str);
if (! info->toplevel_entry)
goto error;
}
/* Parse options for session 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 ("position", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->x = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->y = token_int;
}
else if (!strcmp ("size", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->width = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->height = token_int;
}
else if (!strcmp ("open-on-exit", token_sym))
{
info->open = TRUE;
}
else if (!strcmp ("dock", token_sym))
{
if (info->toplevel_entry)
goto error;
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
token = get_next_token ();
info->sub_dialogs = g_list_prepend (info->sub_dialogs, NULL);
while (peek_next_token () == TOKEN_STRING)
{
token = get_next_token ();
info->sub_dialogs->data =
g_list_append (info->sub_dialogs->data,
g_strdup (token_str));
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
if (! g_list_length (info->sub_dialogs->data))
{
info->sub_dialogs = g_list_remove (info->sub_dialogs,
info->sub_dialogs->data);
}
}
info->sub_dialogs = g_list_reverse (info->sub_dialogs);
}
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 ();
factory->session_infos = g_list_append (factory->session_infos, info);
return OK;
error:
if (info)
{
GList *list;
for (list = info->sub_dialogs; list; list = g_list_next (list))
{
g_list_foreach (list->data, (GFunc) g_free, NULL);
g_list_free (list->data);
}
g_list_free (info->sub_dialogs);
g_free (info);
}
return ERROR;
}
static gint
parse_color_history (gpointer val1p,
gpointer val2p)
{
gint token = 0;
GimpRGB color;
/* Parse one color per line: (color r g b a) */
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
if (parse_color (&color) == ERROR)
return ERROR;
color_history_add_color_from_rc (&color);
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
parse_unit_info (gpointer val1p,
gpointer val2p)
{
gint token;
GimpUnit unit;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
gchar *identifier = NULL;
gdouble factor = 1.0;
gint digits = 2.0;
gchar *symbol = NULL;
gchar *abbreviation = NULL;
gchar *singular = NULL;
gchar *plural = NULL;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
identifier = g_strdup (token_str);
/* Parse options for unit info */
1999-10-27 02:27:27 +08:00
while (peek_next_token () == TOKEN_LEFT_PAREN)
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
{
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
if (!strcmp ("factor", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
factor = token_num;
}
else if (!strcmp ("digits", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
digits = token_int;
}
else if (!strcmp ("symbol", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
symbol = g_strdup (token_str);
}
else if (!strcmp ("abbreviation", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
abbreviation = g_strdup (token_str);
}
else if (!strcmp ("singular", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
singular = g_strdup (token_str);
}
else if (!strcmp ("plural", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
plural = g_strdup (token_str);
}
else
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
}
if (!token || (token != TOKEN_RIGHT_PAREN))
1999-10-27 02:27:27 +08:00
goto error;
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
token = get_next_token ();
unit = gimp_unit_new (identifier, factor, digits,
symbol, abbreviation, singular, plural);
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
/* 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;
1999-10-27 02:27:27 +08:00
error:
g_free (identifier);
g_free (symbol);
g_free (abbreviation);
g_free (singular);
g_free (plural);
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
return ERROR;
}
static gint
parse_parasite (gpointer val1p,
gpointer val2p)
1999-04-12 06:28:51 +08:00
{
gint token;
gint res = ERROR;
gchar *identifier = NULL;
gulong flags = 0;
GimpParasite *parasite;
1999-04-12 06:28:51 +08:00
token = get_next_token ();
if (token != TOKEN_STRING)
goto error;
identifier = g_strdup (token_str);
token = get_next_token ();
/* possible future extension: allow flags as symbolic strings. */
if (token == TOKEN_NUMBER)
flags |= token_int;
token = get_next_token ();
if (token != TOKEN_STRING)
goto error;
parasite = gimp_parasite_new (identifier, flags, token_int, token_str);
2000-02-24 09:21:04 +08:00
gimp_parasite_attach (parasite); /* attaches a copy */
gimp_parasite_free (parasite);
1999-04-12 06:28:51 +08:00
token = get_next_token ();
if (token != TOKEN_RIGHT_PAREN)
goto error;
res = OK;
error:
1999-04-12 06:28:51 +08:00
g_free (identifier);
1999-04-12 06:28:51 +08:00
return res;
}
static gint
parse_help_browser (gpointer val1p,
gpointer val2p)
{
gint token;
token = peek_next_token ();
if (!token || token != TOKEN_SYMBOL)
return ERROR;
token = get_next_token ();
if (strcmp (token_sym, "gimp") == 0)
help_browser = HELP_BROWSER_GIMP;
else if (strcmp (token_sym, "netscape") == 0)
help_browser = HELP_BROWSER_NETSCAPE;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_cursor_mode (gpointer val1p,
gpointer val2p)
{
gint token;
token = peek_next_token ();
if (!token || token != TOKEN_SYMBOL)
return ERROR;
token = get_next_token ();
if (strcmp (token_sym, "tool-icon") == 0)
cursor_mode = CURSOR_MODE_TOOL_ICON;
else if (strcmp (token_sym, "tool-crosshair") == 0)
cursor_mode = CURSOR_MODE_TOOL_CROSSHAIR;
else if (strcmp (token_sym, "crosshair") == 0)
cursor_mode = CURSOR_MODE_CROSSHAIR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
return OK;
}
static gint
parse_unknown (gchar *token_sym)
1997-11-25 06:05:25 +08:00
{
gint token;
UnknownToken *ut;
UnknownToken *tmp;
GList *list;
1997-11-25 06:05:25 +08:00
ut = g_new (UnknownToken, 1);
ut->token = g_strdup (token_sym);
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
{
g_free (ut->token);
g_free (ut);
return ERROR;
}
token = get_next_token ();
ut->value = g_strdup (token_str);
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
{
g_free (ut->token);
g_free (ut->value);
g_free (ut);
return ERROR;
}
token = get_next_token ();
/* search through the list of unknown tokens and replace an existing entry */
list = unknown_tokens;
while (list)
{
tmp = (UnknownToken *) list->data;
list = list->next;
if (strcmp (tmp->token, ut->token) == 0)
{
unknown_tokens = g_list_remove (unknown_tokens, tmp);
g_free (tmp->token);
g_free (tmp->value);
g_free (tmp);
}
}
ut->value = transform_path (ut->value, TRUE);
unknown_tokens = g_list_append (unknown_tokens, ut);
return OK;
}
gchar *
gimprc_value_to_str (gchar *name)
{
return value_to_str (name); /* had a namespace collision */
}
static gchar *
value_to_str (gchar *name)
1997-11-25 06:05:25 +08:00
{
ParseFunc *func;
func = g_hash_table_lookup (parse_func_hash, name);
if (func)
{
switch (func->type)
1997-11-25 06:05:25 +08:00
{
case TT_STRING:
return string_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_PATH:
return path_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_DOUBLE:
return double_to_str (func->val1p, func->val2p);
case TT_FLOAT:
return float_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_INT:
return int_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_BOOLEAN:
return boolean_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_POSITION:
return position_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_MEMSIZE:
return mem_size_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_IMAGETYPE:
return image_type_to_str (func->val1p, func->val2p);
case TT_INTERP:
return interpolation_type_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XPREVSIZE:
return preview_size_to_str (func->val1p, func->val2p);
case TT_XNAVPREVSIZE:
return nav_preview_size_to_str (func->val1p, func->val2p);
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
case TT_XUNIT:
return units_to_str (func->val1p, func->val2p);
case TT_XHELPBROWSER:
return help_browser_to_str (func->val1p, func->val2p);
case TT_XCURSORMODE:
return cursor_mode_to_str (func->val1p, func->val2p);
case TT_XCOMMENT:
return comment_to_str (func->val1p, func->val2p);
1997-11-25 06:05:25 +08:00
case TT_XPLUGIN:
case TT_XPLUGINDEF:
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONINFO:
case TT_XCOLORHISTORY:
This implements the rest of the unit system (unitrc loading and saving and 1999-03-16 Michael Natterer <mitschel@cs.tu-berlin.de> This implements the rest of the unit system (unitrc loading and saving and full PDB interface) * Makefile.am * gimp.1 * user_install * user_install.bat * unitrc: new file (default unit database) and some documentation * app/Makefile.am * app/gimpunit.c * app/gimpunit_cmds.h * app/unitrc.h: new files enabling the unit database and PDB access to the unit system * app/app_procs.c: parse and save unitrc * app/gimprc.[ch]: enable unit parsing. New function init_parse_buffers() to enable unitrc to be loaded before gimprc * app/gimage_cmds.[ch]: new PDB procedures which set/return an image's unit * app/install.c: mention unitrc installation * app/xcf.c: new xcf property for user defined units. An image's unit is saved as either an integer ID (built in units) or as a full unit definition without any ID * libgimp/Makefile.am: moved gimpunit.o from libgimpi.a to libgimp.a * libgimp/gimp.h * libgimp/gimpimage.c: get/set an image's unit with PDB calls * libgimp/gimpunit.h: this file is now the header for both app/gimpunit.c and libgimp/gimpunit.c * libgimp/gimpunit.c: does the unit calls as PDB calls now * libgimp/gimpunitmenu.[ch]: enable user unit functionality and a unit selection dialog * libgimp/gimpsizeentry.c: disble hilighting on focus_in_event and minor bugfixes * plug-ins/tiff/tiff.c: set image unit to "mm" if tiff unit is "cm", save "cm" if image unit is metric
1999-03-17 04:14:07 +08:00
case TT_XUNITINFO:
1999-04-12 06:28:51 +08:00
case TT_XPARASITE:
1997-11-25 06:05:25 +08:00
return NULL;
}
}
1997-11-25 06:05:25 +08:00
return NULL;
}
static inline gchar *
1997-11-25 06:05:25 +08:00
string_to_str (gpointer val1p,
gpointer val2p)
{
gchar *str = gimp_strescape (*((char **)val1p), NULL);
1999-03-07 20:56:03 +08:00
gchar *retval;
retval = g_strdup_printf ("%c%s%c", '"', str, '"');
g_free (str);
return retval;
1997-11-25 06:05:25 +08:00
}
static inline gchar *
1997-11-25 06:05:25 +08:00
path_to_str (gpointer val1p,
gpointer val2p)
{
return string_to_str (val1p, val2p);
1997-11-25 06:05:25 +08:00
}
static inline gchar *
1997-11-25 06:05:25 +08:00
double_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%f", *((gdouble *)val1p));
1997-11-25 06:05:25 +08:00
}
static inline gchar *
float_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%f", (gdouble)(*((float *)val1p)));
}
static inline gchar *
1997-11-25 06:05:25 +08:00
int_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%d", *((gint *)val1p));
1997-11-25 06:05:25 +08:00
}
static inline gchar *
1997-11-25 06:05:25 +08:00
boolean_to_str (gpointer val1p,
gpointer val2p)
{
int v;
if (val1p != NULL)
v = *((int *)val1p);
else
v = !*((int *)val2p);
if (v)
return g_strdup ("yes");
else
return g_strdup ("no");
}
static inline gchar *
1997-11-25 06:05:25 +08:00
position_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%d %d", *((int *)val1p), *((int *)val2p));
1997-11-25 06:05:25 +08:00
}
static inline gchar *
1997-11-25 06:05:25 +08:00
mem_size_to_str (gpointer val1p,
gpointer val2p)
{
guint size;
1997-11-25 06:05:25 +08:00
size = *((guint *)val1p);
1997-11-25 06:05:25 +08:00
if (size % 1048576 == 0)
return g_strdup_printf ("%dM", size / 1048576);
1997-11-25 06:05:25 +08:00
else if (size % 1024 == 0)
return g_strdup_printf ("%dK", size / 1024);
1997-11-25 06:05:25 +08:00
else
return g_strdup_printf ("%dB", size);
1997-11-25 06:05:25 +08:00
}
static inline gchar *
1997-11-25 06:05:25 +08:00
image_type_to_str (gpointer val1p,
gpointer val2p)
{
gint type;
1997-11-25 06:05:25 +08:00
type = *((gint *)val1p);
1997-11-25 06:05:25 +08:00
if (type == GRAY)
return g_strdup ("gray");
else
return g_strdup ("rgb");
}
static inline gchar *
interpolation_type_to_str (gpointer val1p,
gpointer val2p)
{
InterpolationType type;
type = *((InterpolationType *)val1p);
switch (type)
{
case LINEAR_INTERPOLATION:
return g_strdup ("linear");
case CUBIC_INTERPOLATION:
return g_strdup ("cubic");
case NEAREST_NEIGHBOR_INTERPOLATION:
return g_strdup ("nearest-neighbor");
default:
return g_strdup ("bad interpolation type");
}
}
static inline gchar *
1997-11-25 06:05:25 +08:00
preview_size_to_str (gpointer val1p,
gpointer val2p)
{
if (preview_size >= 128)
return g_strdup ("huge");
1997-11-25 06:05:25 +08:00
else if (preview_size >= 64)
return g_strdup ("large");
else if (preview_size >= 48)
1997-11-25 06:05:25 +08:00
return g_strdup ("medium");
else if (preview_size >= 32)
return g_strdup ("small");
else if (preview_size >= 24)
return g_strdup ("tiny");
1997-11-25 06:05:25 +08:00
else
return g_strdup ("none");
}
static inline gchar *
nav_preview_size_to_str (gpointer val1p,
gpointer val2p)
{
if (nav_preview_size >= 112)
return g_strdup ("large");
else if (nav_preview_size >= 80)
return g_strdup ("medium");
else if (nav_preview_size >= 48)
return g_strdup ("small");
else
return g_strdup ("large");
}
static inline gchar *
units_to_str (gpointer val1p,
gpointer val2p)
1997-11-25 06:05:25 +08:00
{
return g_strdup (gimp_unit_get_identifier (*((GimpUnit*)val1p)));
1997-11-25 06:05:25 +08:00
}
static inline gchar *
help_browser_to_str (gpointer val1p,
gpointer val2p)
{
if (help_browser == HELP_BROWSER_NETSCAPE)
return g_strdup ("netscape");
else
return g_strdup ("gimp");
}
static inline gchar *
cursor_mode_to_str (gpointer val1p,
gpointer val2p)
{
if (cursor_mode == CURSOR_MODE_TOOL_ICON)
return g_strdup ("tool-icon");
else if (cursor_mode == CURSOR_MODE_TOOL_CROSSHAIR)
return g_strdup ("tool-crosshair");
else
return g_strdup ("crosshair");
}
static inline gchar *
comment_to_str (gpointer val1p,
gpointer val2p)
{
gchar **str_array;
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
gchar *retval;
gchar *str = gimp_strescape (*((gchar **) val1p), NULL);
str_array = g_strsplit (str, "\n", 0);
g_free (str);
str = g_strjoinv ("\\n", str_array);
g_strfreev (str_array);
retval = g_strdup_printf ("%c%s%c", '"', str, '"');
g_free (str);
return retval;
}
1997-11-25 06:05:25 +08:00
static void
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
add_gimp_directory_token (const gchar *gimp_dir)
1997-11-25 06:05:25 +08:00
{
UnknownToken *ut;
/* The token holds data from a static buffer which is initialized
* once. There should be no need to change an already-existing
* value.
*/
1997-11-25 06:05:25 +08:00
if (NULL != gimprc_find_token ("gimp_dir"))
return;
ut = g_new (UnknownToken, 1);
ut->token = g_strdup ("gimp_dir");
ut->value = g_strdup (gimp_dir);
/* Similarly, transforming the path should be silly. */
unknown_tokens = g_list_append (unknown_tokens, ut);
1999-03-07 20:56:03 +08:00
/* While we're at it, also add the token gimp_install_dir */
ut = g_new (UnknownToken, 1);
ut->token = g_strdup ("gimp_install_dir");
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
ut->value = (gchar *) gimp_data_directory ();
1999-03-07 20:56:03 +08:00
unknown_tokens = g_list_append (unknown_tokens, ut);
1997-11-25 06:05:25 +08:00
}
1999-04-28 22:34:44 +08:00
#ifdef __EMX__
static void
add_x11root_token (gchar *x11root)
1999-04-28 22:34:44 +08:00
{
UnknownToken *ut;
if (x11root == NULL)
return;
/*
The token holds data from a static buffer which is initialized
once. There should be no need to change an already-existing
value.
*/
if (gimprc_find_token ("x11root") != NULL)
return;
ut = g_new (UnknownToken, 1);
ut->token = g_strdup ("x11root");
ut->value = g_strdup (x11root);
unknown_tokens = g_list_append (unknown_tokens, ut);
}
#endif
/* Try to:
1999-03-07 20:56:03 +08:00
1. Open the personal file for reading.
1999-03-07 20:56:03 +08:00
1b. If that fails, try to open the system (overriding) file
1999-03-07 20:56:03 +08:00
2. If we could open the personal file, rename it to file.old.
3. Open personal file for writing.
On success, return NULL. On failure, return a string in English
explaining the problem.
*/
static gchar *
open_backup_file (gchar *filename,
gchar *secondary_filename,
gchar **name_used,
FILE **fp_new,
FILE **fp_old)
1997-11-25 06:05:25 +08:00
{
gchar *oldfilename = NULL;
1997-11-25 06:05:25 +08:00
1999-03-07 20:56:03 +08:00
/* Rename the file to *.old, open it for reading and create the new file. */
1999-04-28 22:34:44 +08:00
if ((*fp_old = fopen (filename, "rt")) == NULL)
{
1999-04-28 22:34:44 +08:00
if ((*fp_old = fopen (secondary_filename, "rt")) == NULL)
1999-03-07 20:56:03 +08:00
{
return g_strdup_printf (_("Can't open %s; %s"),
secondary_filename, g_strerror (errno));
1999-03-07 20:56:03 +08:00
}
else
*name_used = secondary_filename;
}
1999-03-07 20:56:03 +08:00
else
1997-11-25 06:05:25 +08:00
{
1999-03-07 20:56:03 +08:00
*name_used = filename;
oldfilename = g_strdup_printf ("%s.old", filename);
#if defined(G_OS_WIN32) || defined(__EMX__)
1999-03-07 20:56:03 +08:00
/* Can't rename open files... */
fclose (*fp_old);
/* Also, can't rename to an existing file name */
unlink (oldfilename);
#endif
if (rename (filename, oldfilename) < 0)
{
g_free (oldfilename);
return g_strdup_printf (_("Can't rename %s to %s.old; %s"),
filename, filename, g_strerror (errno));
}
#if defined(G_OS_WIN32) || defined(__EMX__)
1999-03-07 20:56:03 +08:00
/* Can't rename open files... */
1999-04-28 22:34:44 +08:00
if ((*fp_old = fopen (oldfilename, "rt")) == NULL)
1999-03-07 20:56:03 +08:00
g_error (_("Couldn't reopen %s\n"), oldfilename);
#endif
1997-11-25 06:05:25 +08:00
}
1999-03-07 20:56:03 +08:00
if ((*fp_new = fopen (filename, "w")) == NULL)
1997-11-25 06:05:25 +08:00
{
1999-03-07 20:56:03 +08:00
if (oldfilename != NULL)
{
/* Undo the renaming... */
(void) rename (oldfilename, filename);
g_free (oldfilename);
}
return g_strdup_printf (_("Can't write to %s; %s"),
filename, g_strerror (errno));
1997-11-25 06:05:25 +08:00
}
1999-03-07 20:56:03 +08:00
if (oldfilename != NULL)
g_free (oldfilename);
return NULL;
1997-11-25 06:05:25 +08:00
}
gchar *
gimprc_find_token (gchar *token)
1997-11-25 06:05:25 +08:00
{
GList *list;
1997-11-25 06:05:25 +08:00
UnknownToken *ut;
1999-10-27 02:27:27 +08:00
for (list = unknown_tokens; list; list = g_list_next (list))
1997-11-25 06:05:25 +08:00
{
ut = (UnknownToken *) list->data;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
if (strcmp (ut->token, token) == 0)
return ut->value;
}
return NULL;
}
static void
gimprc_set_token (gchar *token,
gchar *value)
1997-11-25 06:05:25 +08:00
{
GList *list;
1997-11-25 06:05:25 +08:00
UnknownToken *ut;
1999-10-27 02:27:27 +08:00
for (list = unknown_tokens; list; list = g_list_next (list))
1997-11-25 06:05:25 +08:00
{
ut = (UnknownToken *) list->data;
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
if (strcmp (ut->token, token) == 0)
{
if (ut->value != value)
{
if (ut->value)
g_free (ut->value);
ut->value = value;
}
break;
}
}
}