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
|
|
|
*/
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2002-03-21 01:46:13 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
1999-10-04 00:54:17 +08:00
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "core/gimp.h"
|
2015-12-30 18:53:52 +08:00
|
|
|
#include "core/gimp-filter-history.h"
|
2006-05-18 01:34:17 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpitem.h"
|
2006-03-30 07:56:07 +08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
1999-10-04 00:54:17 +08:00
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
#include "pdb/gimpprocedure.h"
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "plug-in/gimppluginmanager.h"
|
|
|
|
#include "plug-in/gimppluginmanager-data.h"
|
2000-05-08 06:04:51 +08:00
|
|
|
|
2006-05-18 01:34:17 +08:00
|
|
|
#include "widgets/gimpbufferview.h"
|
|
|
|
#include "widgets/gimpcontainerview.h"
|
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2004-07-27 05:07:15 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2006-06-17 01:02:14 +08:00
|
|
|
#include "widgets/gimpimageeditor.h"
|
|
|
|
#include "widgets/gimpitemtreeview.h"
|
2004-10-13 23:48:44 +08:00
|
|
|
#include "widgets/gimpmessagebox.h"
|
|
|
|
#include "widgets/gimpmessagedialog.h"
|
2004-07-27 05:07:15 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-commands.h"
|
2016-01-02 07:33:45 +08:00
|
|
|
#include "procedure-commands.h"
|
2000-05-08 06:04:51 +08:00
|
|
|
|
2004-07-27 05:07:15 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
static void plug_in_reset_all_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
Gimp *gimp);
|
2004-07-27 05:07:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
2000-02-24 04:25:24 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
void
|
2019-07-04 07:11:48 +08:00
|
|
|
plug_in_run_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
Gimp *gimp;
|
2016-01-02 07:33:45 +08:00
|
|
|
GimpValueArray *args = NULL;
|
|
|
|
GimpDisplay *display = NULL;
|
2019-07-04 07:11:48 +08:00
|
|
|
GimpProcedure *procedure;
|
|
|
|
gsize hack;
|
2006-04-04 04:54:55 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
hack = g_variant_get_uint64 (value);
|
|
|
|
|
|
|
|
procedure = GSIZE_TO_POINTER (hack);
|
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
switch (procedure->proc_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-08-30 18:52:28 +08:00
|
|
|
case GIMP_PDB_PROC_TYPE_EXTENSION:
|
2016-04-26 22:10:08 +08:00
|
|
|
args = procedure_commands_get_run_mode_arg (procedure);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-30 18:52:28 +08:00
|
|
|
case GIMP_PDB_PROC_TYPE_PLUGIN:
|
|
|
|
case GIMP_PDB_PROC_TYPE_TEMPORARY:
|
2006-05-18 01:34:17 +08:00
|
|
|
if (GIMP_IS_DATA_FACTORY_VIEW (data) ||
|
|
|
|
GIMP_IS_BUFFER_VIEW (data))
|
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
|
|
|
{
|
2006-05-18 01:34:17 +08:00
|
|
|
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
|
|
|
|
GimpContainer *container;
|
|
|
|
GimpContext *context;
|
|
|
|
GimpObject *object;
|
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
|
|
|
|
2006-05-18 01:34:17 +08:00
|
|
|
container = gimp_container_view_get_container (editor->view);
|
|
|
|
context = gimp_container_view_get_context (editor->view);
|
2003-06-20 22:05:17 +08:00
|
|
|
|
2006-05-18 01:34:17 +08:00
|
|
|
object = gimp_context_get_by_type (context,
|
2008-11-21 07:43:58 +08:00
|
|
|
gimp_container_get_children_type (container));
|
2006-05-18 01:34:17 +08:00
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
args = procedure_commands_get_data_args (procedure, object);
|
2006-05-18 01:34:17 +08:00
|
|
|
}
|
2006-06-17 01:02:14 +08:00
|
|
|
else if (GIMP_IS_IMAGE_EDITOR (data))
|
|
|
|
{
|
|
|
|
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
|
|
|
|
GimpImage *image;
|
|
|
|
|
|
|
|
image = gimp_image_editor_get_image (editor);
|
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
args = procedure_commands_get_image_args (procedure, image);
|
2006-06-17 01:02:14 +08:00
|
|
|
}
|
|
|
|
else if (GIMP_IS_ITEM_TREE_VIEW (data))
|
|
|
|
{
|
|
|
|
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
|
|
|
|
GimpImage *image;
|
|
|
|
GimpItem *item;
|
|
|
|
|
|
|
|
image = gimp_item_tree_view_get_image (view);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
|
|
|
|
else
|
|
|
|
item = NULL;
|
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
args = procedure_commands_get_item_args (procedure, image, item);
|
2006-06-17 01:02:14 +08:00
|
|
|
}
|
2006-05-18 01:34:17 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
display = action_data_get_display (data);
|
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
args = procedure_commands_get_display_args (procedure, display, NULL);
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-30 18:52:28 +08:00
|
|
|
case GIMP_PDB_PROC_TYPE_INTERNAL:
|
2006-09-06 17:11:55 +08:00
|
|
|
g_warning ("Unhandled procedure type.");
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
if (args)
|
|
|
|
{
|
2017-05-30 06:12:22 +08:00
|
|
|
if (procedure_commands_run_procedure_async (procedure, gimp,
|
|
|
|
GIMP_PROGRESS (display),
|
|
|
|
GIMP_RUN_INTERACTIVE, args,
|
|
|
|
display))
|
2016-01-02 07:33:45 +08:00
|
|
|
{
|
|
|
|
/* remember only image plug-ins */
|
|
|
|
if (procedure->num_args >= 2 &&
|
2019-08-29 17:25:35 +08:00
|
|
|
GIMP_IS_PARAM_SPEC_IMAGE (procedure->args[1]))
|
2016-01-02 07:33:45 +08:00
|
|
|
{
|
|
|
|
gimp_filter_history_add (gimp, procedure);
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2016-01-02 07:33:45 +08:00
|
|
|
gimp_value_array_unref (args);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-07-27 05:07:15 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
plug_in_reset_all_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-07-27 05:07:15 +08:00
|
|
|
{
|
2006-04-04 04:54:55 +08:00
|
|
|
Gimp *gimp;
|
2004-10-13 23:48:44 +08:00
|
|
|
GtkWidget *dialog;
|
2006-04-04 04:54:55 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2004-07-27 05:07:15 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
#define RESET_FILTERS_DIALOG_KEY "gimp-reset-all-filters-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (gimp), RESET_FILTERS_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = gimp_message_dialog_new (_("Reset all Filters"),
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_DIALOG_QUESTION,
|
2016-09-26 02:32:50 +08:00
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func, NULL,
|
|
|
|
|
2017-02-12 23:06:34 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Reset"), GTK_RESPONSE_OK,
|
2004-10-13 23:48:44 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
NULL);
|
2004-10-13 23:48:44 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2016-09-26 02:32:50 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2004-10-13 23:48:44 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (plug_in_reset_all_response),
|
|
|
|
gimp);
|
2005-02-10 19:00:46 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
|
|
|
|
_("Do you really want to reset all "
|
|
|
|
"filters to default values?"));
|
2004-10-13 23:48:44 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
dialogs_attach_dialog (G_OBJECT (gimp), RESET_FILTERS_DIALOG_KEY, dialog);
|
|
|
|
}
|
2004-10-13 23:48:44 +08:00
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-07-27 05:07:15 +08:00
|
|
|
}
|
|
|
|
|
2016-09-26 02:32:50 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2004-07-27 05:07:15 +08:00
|
|
|
static void
|
2004-10-13 23:48:44 +08:00
|
|
|
plug_in_reset_all_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
Gimp *gimp)
|
2004-07-27 05:07:15 +08:00
|
|
|
{
|
2004-10-13 23:48:44 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-07-27 05:07:15 +08:00
|
|
|
|
2004-10-13 23:48:44 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2006-04-29 06:26:51 +08:00
|
|
|
gimp_plug_in_manager_data_free (gimp->plug_in_manager);
|
2004-07-27 05:07:15 +08:00
|
|
|
}
|