2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2004-01-21 01:10:16 +08:00
|
|
|
/*
|
|
|
|
* dbbrowser
|
|
|
|
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
|
2000-02-28 08:45:58 +08:00
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/*
|
2000-02-28 08:45:58 +08:00
|
|
|
* This plugin gives you the list of available procedure, with the
|
|
|
|
* name, description and parameters for each procedure.
|
|
|
|
* You can do regexp search (by name and by description)
|
|
|
|
* Useful for scripts development.
|
|
|
|
*
|
|
|
|
* NOTE :
|
|
|
|
* this is only a exercice for me (my first "plug-in" (extension))
|
2004-01-21 01:10:16 +08:00
|
|
|
* so it's very (very) dirty.
|
2000-02-28 08:45:58 +08:00
|
|
|
* Btw, hope it gives you some ideas about gimp possibilities.
|
|
|
|
*
|
|
|
|
* The core of the plugin is not here. See dbbrowser_utils (shared
|
|
|
|
* with script-fu-console).
|
|
|
|
*
|
|
|
|
* TODO
|
|
|
|
* - bug fixes... (my method : rewrite from scratch :)
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-01 23:38:59 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-02-28 08:45:58 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2000-01-01 23:38:59 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-05-01 02:17:55 +08:00
|
|
|
|
2005-08-15 19:07:27 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-dbbrowser"
|
|
|
|
#define PLUG_IN_BINARY "procedure-browser"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-procedure-browser"
|
2005-08-15 19:07:27 +08:00
|
|
|
|
|
|
|
|
2019-08-06 22:30:03 +08:00
|
|
|
typedef struct _Browser Browser;
|
|
|
|
typedef struct _BrowserClass BrowserClass;
|
|
|
|
|
|
|
|
struct _Browser
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _BrowserClass
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-06 22:30:03 +08:00
|
|
|
GimpPlugInClass parent_class;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-08-06 22:30:03 +08:00
|
|
|
/* Declare local functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BROWSER_TYPE (browser_get_type ())
|
|
|
|
#define BROWSER (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BROWSER_TYPE, Browser))
|
|
|
|
|
|
|
|
GType browser_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
static GList * browser_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * browser_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static GimpValueArray * browser_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data);
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (Browser, browser, GIMP_TYPE_PLUG_IN)
|
|
|
|
|
|
|
|
GIMP_MAIN (BROWSER_TYPE)
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2019-08-06 22:30:03 +08:00
|
|
|
browser_class_init (BrowserClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-06 22:30:03 +08:00
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
|
|
|
|
|
|
|
plug_in_class->query_procedures = browser_query_procedures;
|
|
|
|
plug_in_class->create_procedure = browser_create_procedure;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-08-06 22:30:03 +08:00
|
|
|
browser_init (Browser *browser)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-06 22:30:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-06 22:30:03 +08:00
|
|
|
static GList *
|
|
|
|
browser_query_procedures (GimpPlugIn *plug_in)
|
|
|
|
{
|
|
|
|
return g_list_append (NULL, g_strdup (PLUG_IN_PROC));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-08-06 22:30:03 +08:00
|
|
|
static GimpProcedure *
|
|
|
|
browser_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = NULL;
|
2005-08-15 19:07:27 +08:00
|
|
|
|
2019-08-06 22:30:03 +08:00
|
|
|
if (! strcmp (name, PLUG_IN_PROC))
|
|
|
|
{
|
2019-08-30 18:52:28 +08:00
|
|
|
procedure = gimp_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
2019-08-06 22:30:03 +08:00
|
|
|
browser_run, NULL, NULL);
|
|
|
|
|
|
|
|
gimp_procedure_set_menu_label (procedure, N_("Procedure _Browser"));
|
|
|
|
gimp_procedure_add_menu_path (procedure, "<Image>/Help/Programming");
|
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
|
|
|
N_("List available procedures in the PDB"),
|
|
|
|
NULL,
|
|
|
|
PLUG_IN_PROC);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Thomas Noel",
|
|
|
|
"Thomas Noel",
|
|
|
|
"23th june 1997");
|
|
|
|
|
2019-08-19 16:02:07 +08:00
|
|
|
GIMP_PROC_ARG_ENUM (procedure, "run-mode",
|
|
|
|
"Run mode",
|
|
|
|
"The run mode",
|
|
|
|
GIMP_TYPE_RUN_MODE,
|
|
|
|
GIMP_RUN_INTERACTIVE,
|
|
|
|
G_PARAM_READWRITE);
|
2019-08-06 22:30:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpValueArray *
|
|
|
|
browser_run (GimpProcedure *procedure,
|
|
|
|
const GimpValueArray *args,
|
|
|
|
gpointer run_data)
|
|
|
|
{
|
2019-08-20 07:03:38 +08:00
|
|
|
GimpRunMode run_mode = GIMP_VALUES_GET_ENUM (args, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-21 01:10:16 +08:00
|
|
|
INIT_I18N ();
|
2003-03-26 00:38:19 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (run_mode)
|
|
|
|
{
|
2004-01-21 01:10:16 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-03 00:49:42 +08:00
|
|
|
GtkWidget *dialog;
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2019-09-21 01:39:00 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-28 00:35:48 +08:00
|
|
|
dialog =
|
|
|
|
gimp_proc_browser_dialog_new (_("Procedure Browser"), PLUG_IN_BINARY,
|
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Close"), GTK_RESPONSE_CLOSE,
|
2005-09-28 00:35:48 +08:00
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2005-08-18 21:55:14 +08:00
|
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
2005-08-03 00:49:42 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
break;
|
2004-01-21 01:10:16 +08:00
|
|
|
|
2000-08-22 08:13:56 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2019-08-06 22:30:03 +08:00
|
|
|
g_printerr (PLUG_IN_PROC " allows only interactive invocation");
|
|
|
|
|
|
|
|
return gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_CALLING_ERROR,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-02-28 08:45:58 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
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
|
|
|
}
|
2019-08-06 22:30:03 +08:00
|
|
|
|
|
|
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|