1999-06-28 21:28:37 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* The GIMP Help Browser
|
2004-03-09 09:37:56 +08:00
|
|
|
* Copyright (C) 1999-2004 Sven Neumann <sven@gimp.org>
|
2002-05-06 01:01:44 +08:00
|
|
|
* Michael Natterer <mitch@gimp.org>
|
2004-03-09 09:37:56 +08:00
|
|
|
* Henrik Brix Andersen <brix@gimp.org>
|
1999-06-28 21:28:37 +08:00
|
|
|
*
|
|
|
|
* Some code & ideas stolen from the GNOME help browser.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2002-05-06 01:01:44 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
#include "config.h"
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
#include <string.h> /* strlen, strcmp */
|
2000-05-01 02:17:55 +08:00
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
#include <gtk/gtk.h>
|
2002-05-06 01:01:44 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
#include <libgimp/gimp.h>
|
1999-11-23 06:38:02 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
#include "dialog.h"
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
/* defines */
|
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
#define GIMP_HELP_BROWSER_EXT_PROC "extension-gimp-help-browser"
|
|
|
|
#define GIMP_HELP_BROWSER_TEMP_EXT_PROC "extension-gimp-help-browser-temp"
|
2003-08-27 05:24:25 +08:00
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
/* forward declarations */
|
1999-06-28 23:58:09 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
static void temp_proc_install (void);
|
|
|
|
static void temp_proc_run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2002-05-27 02:31:57 +08:00
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
/* local variables */
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
1999-06-28 21:28:37 +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
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
1999-06-28 21:28:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
MAIN ()
|
1999-06-28 21:28:37 +08:00
|
|
|
|
|
|
|
static void
|
2003-08-29 02:49:11 +08:00
|
|
|
query (void)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args[] =
|
2003-08-29 02:49:11 +08:00
|
|
|
{
|
2005-08-12 23:46:46 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "Interactive" },
|
2003-08-29 02:49:11 +08:00
|
|
|
};
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
gimp_install_procedure (GIMP_HELP_BROWSER_EXT_PROC,
|
2003-08-29 02:49:11 +08:00
|
|
|
"Browse the GIMP help pages",
|
|
|
|
"A small and simple HTML browser optimized for "
|
|
|
|
"browsing the GIMP help pages.",
|
|
|
|
"Sven Neumann <sven@gimp.org>, "
|
2004-03-09 09:37:56 +08:00
|
|
|
"Michael Natterer <mitch@gimp.org>"
|
|
|
|
"Henrik Brix Andersen <brix@gimp.org>",
|
|
|
|
"Sven Neumann, Michael Natterer & Henrik Brix Andersen",
|
|
|
|
"1999-2004",
|
2003-08-29 02:49:11 +08:00
|
|
|
NULL,
|
|
|
|
"",
|
|
|
|
GIMP_EXTENSION,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
1999-06-28 21:28:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-08-29 02:49:11 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
GimpRunMode run_mode = param[0].data.d_int32;
|
2003-08-29 02:49:11 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
static GimpParam values[1];
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = status;
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
INIT_I18N ();
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
switch (run_mode)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
|
|
|
/* Make sure all the arguments are there! */
|
|
|
|
if (nparams == 1)
|
2002-06-10 08:07:39 +08:00
|
|
|
{
|
2003-08-29 02:49:11 +08:00
|
|
|
browser_dialog_open ();
|
2002-06-10 08:07:39 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
temp_proc_install ();
|
2002-06-10 08:07:39 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
/* we have installed our temp_proc and are ready to run */
|
|
|
|
gimp_extension_ack ();
|
2002-09-27 02:43:05 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
/* enable asynchronous processing of temp_proc_run requests */
|
|
|
|
gimp_extension_enable ();
|
2002-06-10 08:07:39 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
gtk_main ();
|
2002-06-10 08:07:39 +08:00
|
|
|
}
|
2004-03-09 09:37:56 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-08-29 02:49:11 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2004-03-09 09:37:56 +08:00
|
|
|
break;
|
2002-06-10 08:07:39 +08:00
|
|
|
}
|
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
values[0].data.d_status = status;
|
1999-09-29 22:35:04 +08:00
|
|
|
}
|
|
|
|
|
1999-06-28 21:28:37 +08:00
|
|
|
static void
|
2003-08-29 02:49:11 +08:00
|
|
|
temp_proc_install (void)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args[] =
|
2003-08-29 02:49:11 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
{ GIMP_PDB_STRING, "uri", "Full uri of the file to open" }
|
2003-08-29 02:49:11 +08:00
|
|
|
};
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2005-08-12 23:46:46 +08:00
|
|
|
gimp_install_temp_proc (GIMP_HELP_BROWSER_TEMP_EXT_PROC,
|
2003-08-29 02:49:11 +08:00
|
|
|
"DON'T USE THIS ONE",
|
|
|
|
"(Temporary procedure)",
|
|
|
|
"Sven Neumann <sven@gimp.org>, "
|
2004-03-09 09:37:56 +08:00
|
|
|
"Michael Natterer <mitch@gimp.org>"
|
|
|
|
"Henrik Brix Andersen <brix@gimp.org>",
|
|
|
|
"Sven Neumann, Michael Natterer & Henrik Brix Andersen",
|
|
|
|
"1999-2004",
|
2003-08-29 02:49:11 +08:00
|
|
|
NULL,
|
|
|
|
"",
|
|
|
|
GIMP_TEMPORARY,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL,
|
|
|
|
temp_proc_run);
|
1999-06-28 21:28:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-08-29 02:49:11 +08:00
|
|
|
temp_proc_run (const gchar *name,
|
2003-07-02 08:15:09 +08:00
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
static GimpParam values[1];
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
1999-06-28 21:28:37 +08:00
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
Changed the semantics of GIMP_EXTENSION and (to some extent) of
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
|
|
|
*return_vals = values;
|
1999-06-28 21:28:37 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
/* make sure all the arguments are there */
|
|
|
|
if (nparams == 1)
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
if (param[0].data.d_string && strlen (param[0].data.d_string))
|
1999-06-28 21:28:37 +08:00
|
|
|
{
|
2004-03-09 09:37:56 +08:00
|
|
|
browser_dialog_load (param[0].data.d_string, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1999-06-28 21:28:37 +08:00
|
|
|
}
|
|
|
|
}
|
2004-03-09 09:37:56 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2003-08-29 02:49:11 +08:00
|
|
|
|
2004-03-09 09:37:56 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = status;
|
1999-06-28 21:28:37 +08:00
|
|
|
}
|