1999-04-05 20:48:48 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
1999-03-17 04:14:07 +08:00
|
|
|
*
|
|
|
|
* gimpunit.c
|
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
|
|
|
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
1999-03-17 04:14:07 +08:00
|
|
|
*
|
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
|
|
|
* 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.
|
1999-03-17 04:14:07 +08:00
|
|
|
*
|
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
|
|
|
* This program is distributed in the hope that it will be useful,
|
1999-03-17 04:14:07 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
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
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
1999-03-17 04:14:07 +08:00
|
|
|
*
|
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
|
|
|
* 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.
|
1999-03-17 04:14:07 +08:00
|
|
|
*/
|
|
|
|
|
1999-05-30 00:35:47 +08:00
|
|
|
#include "config.h"
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <glib.h>
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "apptypes.h"
|
2000-05-31 07:38:46 +08:00
|
|
|
|
|
|
|
#include "app_procs.h"
|
|
|
|
#include "gimprc.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "unitrc.h"
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
/* NOTE:
|
|
|
|
*
|
|
|
|
* one of our header files is in libgimp/ (see the note there)
|
|
|
|
*/
|
|
|
|
#include "libgimp/gimpunit.h"
|
2000-05-31 07:38:46 +08:00
|
|
|
#include "libgimp/gimpenv.h"
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
/* internal structures */
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gboolean delete_on_exit;
|
|
|
|
gdouble factor;
|
|
|
|
gint digits;
|
|
|
|
gchar *identifier;
|
|
|
|
gchar *symbol;
|
|
|
|
gchar *abbreviation;
|
|
|
|
gchar *singular;
|
|
|
|
gchar *plural;
|
1999-03-17 04:14:07 +08:00
|
|
|
} GimpUnitDef;
|
|
|
|
|
|
|
|
/* these are the built-in units
|
|
|
|
*/
|
2000-02-08 04:35:13 +08:00
|
|
|
static GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
|
|
|
/* pseudo unit */
|
|
|
|
{ FALSE, 0.0, 0, "pixels", "px", "px", N_("pixel"), N_("pixels") },
|
|
|
|
|
|
|
|
/* standard units */
|
|
|
|
{ FALSE, 1.0, 2, "inches", "''", "in", N_("inch"), N_("inches") },
|
|
|
|
{ FALSE, 25.4, 1, "millimeters", "mm", "mm", N_("millimeter"), N_("millimeters") },
|
|
|
|
|
|
|
|
/* professional units */
|
|
|
|
{ FALSE, 72.0, 0, "points", "pt", "pt", N_("point"), N_("points") },
|
|
|
|
{ FALSE, 6.0, 1, "picas", "pc", "pc", N_("pica"), N_("picas") },
|
|
|
|
};
|
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
/* not a unit at all but kept here to have the strings in one place
|
|
|
|
*/
|
|
|
|
static GimpUnitDef gimp_unit_percent =
|
|
|
|
{
|
|
|
|
FALSE, 0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
|
|
|
|
};
|
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
static GSList* user_units = NULL;
|
|
|
|
static gint number_of_user_units = 0;
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static GimpUnitDef *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_user_unit (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
return g_slist_nth_data (user_units, unit - GIMP_UNIT_END);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_unit_get_number_of_units (void)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
return GIMP_UNIT_END + number_of_user_units;
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_unit_get_number_of_built_in_units (void)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
return GIMP_UNIT_END;
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit
|
1999-05-23 01:56:35 +08:00
|
|
|
gimp_unit_new (gchar *identifier,
|
|
|
|
gdouble factor,
|
|
|
|
gint digits,
|
|
|
|
gchar *symbol,
|
|
|
|
gchar *abbreviation,
|
|
|
|
gchar *singular,
|
|
|
|
gchar *plural)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
|
|
|
GimpUnitDef *user_unit;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
user_unit = g_new (GimpUnitDef, 1);
|
1999-03-17 04:14:07 +08:00
|
|
|
user_unit->delete_on_exit = TRUE;
|
2000-02-08 04:35:13 +08:00
|
|
|
user_unit->factor = factor;
|
|
|
|
user_unit->digits = digits;
|
|
|
|
user_unit->identifier = g_strdup (identifier);
|
|
|
|
user_unit->symbol = g_strdup (symbol);
|
|
|
|
user_unit->abbreviation = g_strdup (abbreviation);
|
|
|
|
user_unit->singular = g_strdup (singular);
|
|
|
|
user_unit->plural = g_strdup (plural);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
user_units = g_slist_append (user_units, user_unit);
|
|
|
|
number_of_user_units++;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
return GIMP_UNIT_END + number_of_user_units - 1;
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
gboolean
|
|
|
|
gimp_unit_get_deletion_flag (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)), FALSE);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gimp_unit_get_user_unit (unit)->delete_on_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_set_deletion_flag (GimpUnit unit,
|
|
|
|
gboolean deletion_flag)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_if_fail ((unit >= GIMP_UNIT_END) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)));
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
gimp_unit_get_user_unit (unit)->delete_on_exit =
|
|
|
|
deletion_flag ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-23 01:56:35 +08:00
|
|
|
gdouble
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_factor (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)),
|
|
|
|
gimp_unit_defs[GIMP_UNIT_INCH].factor);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_defs[unit].factor;
|
|
|
|
|
|
|
|
return gimp_unit_get_user_unit (unit)->factor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_digits (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)),
|
|
|
|
gimp_unit_defs[GIMP_UNIT_INCH].digits);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_defs[unit].digits;
|
|
|
|
|
|
|
|
return gimp_unit_get_user_unit (unit)->digits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_identifier (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT),
|
|
|
|
gimp_unit_defs[GIMP_UNIT_INCH].identifier);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_defs[unit].identifier;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit == GIMP_UNIT_PERCENT)
|
1999-04-06 20:13:54 +08:00
|
|
|
return gimp_unit_percent.identifier;
|
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_get_user_unit (unit)->identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_symbol (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT),
|
|
|
|
gimp_unit_defs[GIMP_UNIT_INCH].symbol);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_defs[unit].symbol;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit == GIMP_UNIT_PERCENT)
|
1999-04-06 20:13:54 +08:00
|
|
|
return gimp_unit_percent.symbol;
|
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_get_user_unit (unit)->symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_abbreviation (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT),
|
|
|
|
gimp_unit_defs[GIMP_UNIT_INCH].abbreviation);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_defs[unit].abbreviation;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit == GIMP_UNIT_PERCENT)
|
1999-04-06 20:13:54 +08:00
|
|
|
return gimp_unit_percent.abbreviation;
|
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
return gimp_unit_get_user_unit (unit)->abbreviation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_singular (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT),
|
|
|
|
gettext (gimp_unit_defs[GIMP_UNIT_INCH].singular));
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gettext (gimp_unit_defs[unit].singular);
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit == GIMP_UNIT_PERCENT)
|
1999-04-06 20:13:54 +08:00
|
|
|
return gettext (gimp_unit_percent.singular);
|
|
|
|
|
1999-06-07 10:21:31 +08:00
|
|
|
return gettext (gimp_unit_get_user_unit (unit)->singular);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_unit_get_plural (GimpUnit unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_val_if_fail ((unit >= GIMP_UNIT_PIXEL) &&
|
|
|
|
(unit < (GIMP_UNIT_END + number_of_user_units)) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT),
|
|
|
|
gettext (gimp_unit_defs[GIMP_UNIT_INCH].plural));
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit < GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
return gettext (gimp_unit_defs[unit].plural);
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if (unit == GIMP_UNIT_PERCENT)
|
1999-04-06 20:13:54 +08:00
|
|
|
return gettext (gimp_unit_percent.plural);
|
|
|
|
|
1999-06-07 10:21:31 +08:00
|
|
|
return gettext (gimp_unit_get_user_unit (unit)->plural);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* unitrc functions **********/
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
void
|
|
|
|
parse_unitrc (void)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
gchar *filename;
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("unitrc");
|
|
|
|
parse_gimprc_file (filename);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
void
|
|
|
|
save_unitrc (void)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
gint i;
|
|
|
|
gchar *filename;
|
|
|
|
FILE *fp;
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("unitrc");
|
|
|
|
|
|
|
|
fp = fopen (filename, "w");
|
|
|
|
g_free (filename);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
fprintf (fp,
|
|
|
|
"# GIMP unitrc\n"
|
|
|
|
"# This file contains your user unit database. You can\n"
|
|
|
|
"# modify this list with the unit editor. You are not\n"
|
|
|
|
"# supposed to edit it manually, but of course you can do.\n"
|
|
|
|
"# This file will be entirely rewritten every time you\n"
|
|
|
|
"# quit the gimp.\n\n");
|
2000-02-08 04:35:13 +08:00
|
|
|
|
1999-04-05 20:48:48 +08:00
|
|
|
/* save user defined units */
|
2000-02-08 04:35:13 +08:00
|
|
|
for (i = gimp_unit_get_number_of_built_in_units ();
|
1999-03-17 04:14:07 +08:00
|
|
|
i < gimp_unit_get_number_of_units ();
|
|
|
|
i++)
|
|
|
|
if (gimp_unit_get_deletion_flag (i) == FALSE)
|
|
|
|
{
|
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
|
|
|
fprintf (fp,
|
|
|
|
"(unit-info \"%s\"\n"
|
|
|
|
" (factor %f)\n"
|
|
|
|
" (digits %d)\n"
|
|
|
|
" (symbol \"%s\")\n"
|
|
|
|
" (abbreviation \"%s\")\n"
|
|
|
|
" (singular \"%s\")\n"
|
|
|
|
" (plural \"%s\"))\n\n",
|
|
|
|
gimp_unit_get_identifier (i),
|
|
|
|
gimp_unit_get_factor (i),
|
|
|
|
gimp_unit_get_digits (i),
|
|
|
|
gimp_unit_get_symbol (i),
|
|
|
|
gimp_unit_get_abbreviation (i),
|
|
|
|
gimp_unit_get_singular (i),
|
|
|
|
gimp_unit_get_plural (i));
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
2000-02-08 04:35:13 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
fclose (fp);
|
|
|
|
}
|