2016-01-04 22:07:30 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpgeglprocedure.c
|
2018-01-14 22:42:29 +08:00
|
|
|
* Copyright (C) 2016-2018 Michael Natterer <mitch@gimp.org>
|
2016-01-04 22:07:30 +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 3 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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-01-04 22:07:30 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2016-01-31 02:30:52 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
2018-04-01 20:41:20 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2017-02-06 03:17:31 +08:00
|
|
|
#include "operations/gimp-operation-config.h"
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 06:37:19 +08:00
|
|
|
#include "operations/gimpoperationsettings.h"
|
2017-02-06 03:17:31 +08:00
|
|
|
|
2016-01-04 22:07:30 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimp-memsize.h"
|
2016-01-05 00:28:48 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2016-01-04 22:07:30 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2019-09-04 20:27:18 +08:00
|
|
|
#include "core/gimpdisplay.h"
|
2016-01-05 00:28:48 +08:00
|
|
|
#include "core/gimpdrawable-operation.h"
|
|
|
|
#include "core/gimpimage.h"
|
2016-01-04 22:07:30 +08:00
|
|
|
#include "core/gimplayermask.h"
|
|
|
|
#include "core/gimpparamspecs.h"
|
2016-01-05 00:28:48 +08:00
|
|
|
#include "core/gimpsettings.h"
|
2016-01-04 22:07:30 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "tools/gimpoperationtool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
|
|
|
#include "gimpgeglprocedure.h"
|
|
|
|
|
2016-01-05 00:28:48 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
static void gimp_gegl_procedure_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gint64 gimp_gegl_procedure_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
static gchar * gimp_gegl_procedure_get_description (GimpViewable *viewable,
|
|
|
|
gchar **tooltip);
|
|
|
|
|
|
|
|
static const gchar * gimp_gegl_procedure_get_menu_label (GimpProcedure *procedure);
|
|
|
|
static gboolean gimp_gegl_procedure_get_sensitive (GimpProcedure *procedure,
|
2018-06-22 19:54:23 +08:00
|
|
|
GimpObject *object,
|
2021-04-24 00:49:29 +08:00
|
|
|
const gchar **reason);
|
2016-01-04 22:07:30 +08:00
|
|
|
static GimpValueArray * gimp_gegl_procedure_execute (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
2019-09-04 20:27:18 +08:00
|
|
|
GimpDisplay *display);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpGeglProcedure, gimp_gegl_procedure,
|
|
|
|
GIMP_TYPE_PROCEDURE)
|
|
|
|
|
|
|
|
#define parent_class gimp_gegl_procedure_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_procedure_class_init (GimpGeglProcedureClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
GimpProcedureClass *proc_class = GIMP_PROCEDURE_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gimp_gegl_procedure_finalize;
|
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_gegl_procedure_get_memsize;
|
|
|
|
|
|
|
|
viewable_class->default_icon_name = "gimp-gegl";
|
|
|
|
viewable_class->get_description = gimp_gegl_procedure_get_description;
|
|
|
|
|
|
|
|
proc_class->get_menu_label = gimp_gegl_procedure_get_menu_label;
|
|
|
|
proc_class->get_sensitive = gimp_gegl_procedure_get_sensitive;
|
|
|
|
proc_class->execute = gimp_gegl_procedure_execute;
|
|
|
|
proc_class->execute_async = gimp_gegl_procedure_execute_async;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_procedure_init (GimpGeglProcedure *proc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_procedure_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpGeglProcedure *proc = GIMP_GEGL_PROCEDURE (object);
|
|
|
|
|
2018-04-01 19:54:47 +08:00
|
|
|
g_clear_object (&proc->default_settings);
|
2017-06-04 03:59:08 +08:00
|
|
|
|
2019-08-18 07:55:47 +08:00
|
|
|
g_clear_pointer (&proc->operation, g_free);
|
2018-04-01 19:54:47 +08:00
|
|
|
g_clear_pointer (&proc->menu_label, g_free);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint64
|
|
|
|
gimp_gegl_procedure_get_memsize (GimpObject *object,
|
2017-02-06 03:22:40 +08:00
|
|
|
gint64 *gui_size)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
|
|
|
GimpGeglProcedure *proc = GIMP_GEGL_PROCEDURE (object);
|
|
|
|
gint64 memsize = 0;
|
|
|
|
|
2019-08-18 07:55:47 +08:00
|
|
|
memsize += gimp_string_get_memsize (proc->operation);
|
2016-01-04 22:07:30 +08:00
|
|
|
memsize += gimp_string_get_memsize (proc->menu_label);
|
|
|
|
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gimp_gegl_procedure_get_description (GimpViewable *viewable,
|
2017-02-06 03:22:40 +08:00
|
|
|
gchar **tooltip)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
|
|
|
GimpProcedure *procedure = GIMP_PROCEDURE (viewable);
|
|
|
|
|
|
|
|
if (tooltip)
|
|
|
|
*tooltip = g_strdup (gimp_procedure_get_blurb (procedure));
|
|
|
|
|
|
|
|
return g_strdup (gimp_procedure_get_label (procedure));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
gimp_gegl_procedure_get_menu_label (GimpProcedure *procedure)
|
|
|
|
{
|
|
|
|
GimpGeglProcedure *proc = GIMP_GEGL_PROCEDURE (procedure);
|
|
|
|
|
|
|
|
if (proc->menu_label)
|
|
|
|
return proc->menu_label;
|
|
|
|
|
|
|
|
return GIMP_PROCEDURE_CLASS (parent_class)->get_menu_label (procedure);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-06-22 19:54:23 +08:00
|
|
|
gimp_gegl_procedure_get_sensitive (GimpProcedure *procedure,
|
|
|
|
GimpObject *object,
|
2021-04-24 00:49:29 +08:00
|
|
|
const gchar **reason)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2021-04-02 05:49:11 +08:00
|
|
|
GimpImage *image = GIMP_IMAGE (object);
|
|
|
|
GList *drawables = NULL;
|
|
|
|
gboolean sensitive = FALSE;
|
2016-01-04 22:07:30 +08:00
|
|
|
|
2021-04-02 05:49:11 +08:00
|
|
|
if (image)
|
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
|
|
|
|
if (g_list_length (drawables) == 1)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2021-04-02 05:49:11 +08:00
|
|
|
GimpDrawable *drawable = drawables->data;
|
|
|
|
GimpItem *item;
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
if (GIMP_IS_LAYER_MASK (drawable))
|
|
|
|
item = GIMP_ITEM (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)));
|
|
|
|
else
|
|
|
|
item = GIMP_ITEM (drawable);
|
|
|
|
|
|
|
|
sensitive = ! gimp_item_is_content_locked (item);
|
|
|
|
|
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
|
|
|
sensitive = FALSE;
|
|
|
|
}
|
2021-04-02 05:49:11 +08:00
|
|
|
g_list_free (drawables);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
return sensitive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpValueArray *
|
2016-01-18 03:08:25 +08:00
|
|
|
gimp_gegl_procedure_execute (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
|
|
|
GError **error)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2017-05-30 05:53:36 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpDrawable *drawable;
|
2017-07-10 01:20:55 +08:00
|
|
|
GObject *config;
|
2017-05-30 05:53:36 +08:00
|
|
|
GeglNode *node;
|
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
image = g_value_get_object (gimp_value_array_index (args, 1));
|
|
|
|
drawable = g_value_get_object (gimp_value_array_index (args, 2));
|
|
|
|
config = g_value_get_object (gimp_value_array_index (args, 3));
|
2017-05-30 05:53:36 +08:00
|
|
|
|
|
|
|
node = gegl_node_new_child (NULL,
|
2019-08-18 07:55:47 +08:00
|
|
|
"operation",
|
|
|
|
GIMP_GEGL_PROCEDURE (procedure)->operation,
|
2017-05-30 05:53:36 +08:00
|
|
|
NULL);
|
|
|
|
|
2020-04-07 23:39:54 +08:00
|
|
|
gimp_drawable_apply_operation_with_config (
|
|
|
|
drawable,
|
|
|
|
progress, gimp_procedure_get_label (procedure),
|
|
|
|
node, config);
|
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
g_object_unref (node);
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
2016-01-04 22:07:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
GimpValueArray *args,
|
2019-09-04 20:27:18 +08:00
|
|
|
GimpDisplay *display)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2019-08-18 07:55:47 +08:00
|
|
|
GimpGeglProcedure *gegl_procedure = GIMP_GEGL_PROCEDURE (procedure);
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpObject *settings;
|
|
|
|
GimpTool *active_tool;
|
|
|
|
const gchar *tool_name;
|
2016-01-05 00:28:48 +08:00
|
|
|
|
app, libgimp, libgimpbase: big plug-in API refactoring part three
- libgimpbase: change GPParam to transfer all information about the
GValues we use, in the same way done for GPParamDef. GPParam is now
different from GimpParam from libgimp, pointers can't be casted any
longer. The protocol is now completely GimpPDBArgType-free. Remove
gp_params_destroy() from the public API.
- libgimp: add API to convert between an array of GPParams and
GimpValueArray, the latter is now the new official API for dealing
with procedure arguments and return values, GimpParam is cruft (the
wire now talks with GimpPlugIn more directly than with the members
of GimpPlugInInfo, which need additional compat conversions).
- libgimp, app: rename gimpgpparamspecs.[ch] to simply
gimpgpparams.[ch] which is also more accurate because they now
contain GValue functions too. The code that used to live in
app/plug-in/plug-in-params.h is now completely in libgimp.
- app: contains no protocol compat code any longer, the only place
that uses GimpPDBArgType is the PDB query procedure implementation,
which also needs to change.
- app: change some forgotten int32 run-modes to enums.
2019-07-29 07:56:58 +08:00
|
|
|
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
|
2017-05-30 05:53:36 +08:00
|
|
|
settings = g_value_get_object (gimp_value_array_index (args, 3));
|
2016-01-05 00:28:48 +08:00
|
|
|
|
2018-04-01 20:41:20 +08:00
|
|
|
if (! settings &&
|
|
|
|
(run_mode != GIMP_RUN_INTERACTIVE ||
|
|
|
|
GIMP_GUI_CONFIG (gimp->config)->filter_tool_use_last_settings))
|
2017-03-24 08:29:50 +08:00
|
|
|
{
|
2017-05-30 05:53:36 +08:00
|
|
|
/* if we didn't get settings passed, get the last used settings */
|
2016-03-21 04:56:51 +08:00
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
GType config_type;
|
|
|
|
GimpContainer *container;
|
2016-01-05 00:28:48 +08:00
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
config_type = G_VALUE_TYPE (gimp_value_array_index (args, 3));
|
2016-01-05 00:28:48 +08:00
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
container = gimp_operation_config_get_container (gimp, config_type,
|
|
|
|
(GCompareFunc)
|
|
|
|
gimp_settings_compare);
|
2016-01-05 00:28:48 +08:00
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
settings = gimp_container_get_child_by_index (container, 0);
|
|
|
|
|
|
|
|
/* only use the settings if they are automatically created
|
|
|
|
* "last used" values, not if they were saved explicitly and
|
|
|
|
* have a zero timestamp; and if they are not a separator.
|
|
|
|
*/
|
|
|
|
if (settings &&
|
|
|
|
(GIMP_SETTINGS (settings)->time == 0 ||
|
|
|
|
! gimp_object_get_name (settings)))
|
|
|
|
{
|
|
|
|
settings = NULL;
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 00:28:48 +08:00
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
if (run_mode == GIMP_RUN_NONINTERACTIVE ||
|
|
|
|
run_mode == GIMP_RUN_WITH_LAST_VALS)
|
|
|
|
{
|
|
|
|
if (settings || run_mode == GIMP_RUN_NONINTERACTIVE)
|
|
|
|
{
|
|
|
|
g_value_set_object (gimp_value_array_index (args, 3), settings);
|
|
|
|
gimp_procedure_execute (procedure, gimp, context, progress,
|
|
|
|
args, NULL);
|
2016-01-05 00:28:48 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_message (gimp,
|
|
|
|
G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
|
|
|
_("There are no last settings for '%s', "
|
|
|
|
"showing the filter dialog instead."),
|
|
|
|
gimp_procedure_get_label (procedure));
|
|
|
|
}
|
|
|
|
|
2019-08-18 07:55:47 +08:00
|
|
|
if (! strcmp (gegl_procedure->operation, "gimp:brightness-contrast"))
|
2018-01-14 22:42:29 +08:00
|
|
|
{
|
|
|
|
tool_name = "gimp-brightness-contrast-tool";
|
|
|
|
}
|
2019-08-18 07:55:47 +08:00
|
|
|
else if (! strcmp (gegl_procedure->operation, "gimp:curves"))
|
2018-01-14 22:42:29 +08:00
|
|
|
{
|
|
|
|
tool_name = "gimp-curves-tool";
|
|
|
|
}
|
2019-08-18 07:55:47 +08:00
|
|
|
else if (! strcmp (gegl_procedure->operation, "gimp:levels"))
|
2018-01-14 22:42:29 +08:00
|
|
|
{
|
|
|
|
tool_name = "gimp-levels-tool";
|
|
|
|
}
|
2019-08-18 07:55:47 +08:00
|
|
|
else if (! strcmp (gegl_procedure->operation, "gimp:threshold"))
|
2018-01-14 22:42:29 +08:00
|
|
|
{
|
|
|
|
tool_name = "gimp-threshold-tool";
|
|
|
|
}
|
2019-08-18 07:55:47 +08:00
|
|
|
else if (! strcmp (gegl_procedure->operation, "gimp:offset"))
|
2019-06-06 06:09:28 +08:00
|
|
|
{
|
|
|
|
tool_name = "gimp-offset-tool";
|
|
|
|
}
|
2018-01-14 22:42:29 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
tool_name = "gimp-operation-tool";
|
|
|
|
}
|
|
|
|
|
2016-01-05 00:28:48 +08:00
|
|
|
active_tool = tool_manager_get_active (gimp);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
/* do not use the passed context because we need to set the active
|
|
|
|
* tool on the global user context
|
|
|
|
*/
|
|
|
|
context = gimp_get_user_context (gimp);
|
|
|
|
|
2018-01-14 22:42:29 +08:00
|
|
|
if (strcmp (gimp_object_get_name (active_tool->tool_info), tool_name))
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2018-01-14 22:42:29 +08:00
|
|
|
GimpToolInfo *tool_info = gimp_get_tool_info (gimp, tool_name);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
gimp_context_set_tool (context, tool_info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_context_tool_changed (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gimp);
|
|
|
|
|
2018-01-14 22:42:29 +08:00
|
|
|
if (! strcmp (gimp_object_get_name (active_tool->tool_info), tool_name))
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2018-08-28 07:21:45 +08:00
|
|
|
/* Remember the procedure that created this tool, because
|
2018-01-14 22:42:29 +08:00
|
|
|
* we can't just switch to an operation tool using
|
2017-01-23 07:00:03 +08:00
|
|
|
* gimp_context_set_tool(), we also have to go through the
|
2018-01-14 22:42:29 +08:00
|
|
|
* initialization code below, otherwise we end up with a
|
|
|
|
* dummy tool that does nothing. See bug #776370.
|
2017-01-23 07:00:03 +08:00
|
|
|
*/
|
|
|
|
g_object_set_data_full (G_OBJECT (active_tool), "gimp-gegl-procedure",
|
|
|
|
g_object_ref (procedure),
|
|
|
|
(GDestroyNotify) g_object_unref);
|
|
|
|
|
2018-01-14 22:42:29 +08:00
|
|
|
if (! strcmp (tool_name, "gimp-operation-tool"))
|
|
|
|
{
|
|
|
|
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
|
2019-08-18 07:55:47 +08:00
|
|
|
gegl_procedure->operation,
|
2018-01-14 22:42:29 +08:00
|
|
|
gimp_procedure_get_label (procedure),
|
|
|
|
gimp_procedure_get_label (procedure),
|
|
|
|
gimp_procedure_get_label (procedure),
|
|
|
|
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
|
|
|
|
gimp_procedure_get_help_id (procedure));
|
|
|
|
}
|
2016-01-04 22:07:30 +08:00
|
|
|
|
2019-09-04 20:27:18 +08:00
|
|
|
tool_manager_initialize_active (gimp, display);
|
2016-01-31 02:30:52 +08:00
|
|
|
|
|
|
|
if (settings)
|
2017-03-31 05:21:46 +08:00
|
|
|
gimp_filter_tool_set_config (GIMP_FILTER_TOOL (active_tool),
|
|
|
|
GIMP_CONFIG (settings));
|
2016-01-04 22:07:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpProcedure *
|
|
|
|
gimp_gegl_procedure_new (Gimp *gimp,
|
2017-06-01 05:41:37 +08:00
|
|
|
GimpRunMode default_run_mode,
|
2017-06-04 03:59:08 +08:00
|
|
|
GimpObject *default_settings,
|
2016-01-04 22:07:30 +08:00
|
|
|
const gchar *operation,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *menu_label,
|
2016-01-18 03:08:25 +08:00
|
|
|
const gchar *tooltip,
|
2016-01-04 22:07:30 +08:00
|
|
|
const gchar *icon_name,
|
2016-01-18 03:08:25 +08:00
|
|
|
const gchar *help_id)
|
2016-01-04 22:07:30 +08:00
|
|
|
{
|
2017-06-04 03:59:08 +08:00
|
|
|
GimpProcedure *procedure;
|
|
|
|
GimpGeglProcedure *gegl_procedure;
|
|
|
|
GType config_type;
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (operation != NULL, NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (menu_label != NULL, NULL);
|
|
|
|
|
2017-05-30 05:53:36 +08:00
|
|
|
config_type = gimp_operation_config_get_type (gimp, operation, icon_name,
|
app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types. The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.
The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object. The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.
Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 06:37:19 +08:00
|
|
|
GIMP_TYPE_OPERATION_SETTINGS);
|
2017-05-30 05:53:36 +08:00
|
|
|
|
2016-01-04 22:07:30 +08:00
|
|
|
procedure = g_object_new (GIMP_TYPE_GEGL_PROCEDURE, NULL);
|
|
|
|
|
2017-06-04 03:59:08 +08:00
|
|
|
gegl_procedure = GIMP_GEGL_PROCEDURE (procedure);
|
|
|
|
|
2019-08-18 07:55:47 +08:00
|
|
|
gegl_procedure->operation = g_strdup (operation);
|
2017-06-04 03:59:08 +08:00
|
|
|
gegl_procedure->default_run_mode = default_run_mode;
|
|
|
|
gegl_procedure->menu_label = g_strdup (menu_label);
|
|
|
|
|
|
|
|
if (default_settings)
|
|
|
|
gegl_procedure->default_settings = g_object_ref (default_settings);
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (procedure), name);
|
|
|
|
gimp_viewable_set_icon_name (GIMP_VIEWABLE (procedure), icon_name);
|
2019-09-09 05:40:34 +08:00
|
|
|
gimp_procedure_set_help (procedure,
|
|
|
|
tooltip,
|
|
|
|
tooltip,
|
2019-09-09 05:44:13 +08:00
|
|
|
help_id);
|
2019-09-09 05:40:34 +08:00
|
|
|
gimp_procedure_set_static_attribution (procedure,
|
|
|
|
"author", "copyright", "date");
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
gimp_procedure_add_argument (procedure,
|
app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
information needed for constructing all GParamSpecs we use, don't
use GimpPDBArgType in GPProcInstall but an enum private to the wire
protocol plus the GParamSpec's GType name. Bump the wire protocol
version.
- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
take care of converting between GPParamDef and GParamSpec. They
share code as far as possible.
- Change pluginrc writing and parsing to re-use GPParamDef and the
utility functions from gimpgpparamspecs.
- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
the entire core uses proper GParamSpecs from the wire protocol now,
the whole file will follow down the drain once we use a GValue
representation on the wire too.
- In gimp_plug_in_handle_proc_install(), change the "run-mode"
parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
already an enum). and change all places in app/ to treat it as an
enum value.
- plug-ins: fix cml-explorer to register correctly, a typo in
"run-mode" was never noticed until now.
- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
between old-style wire communication and using GParamSpec and
GValue, it contains some functions that are subject to change or
even removal in the next steps.
- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
able to actually install procedures the new way.
- plug-ins: change goat-exercise to completely use the new GimpPlugIn
and GimpProcedure API, look here to see how plug-ins will look in
the future, of course subject to change until this is finished.
- Next: changing GPParam to transmit all information about a GValue.
2019-07-27 22:37:55 +08:00
|
|
|
gimp_param_spec_enum ("run-mode",
|
|
|
|
"Run mode",
|
|
|
|
"Run mode",
|
|
|
|
GIMP_TYPE_RUN_MODE,
|
|
|
|
GIMP_RUN_INTERACTIVE,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2016-01-04 22:07:30 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_image ("image",
|
|
|
|
"Image",
|
|
|
|
"Input image",
|
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2016-01-04 22:07:30 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
2019-08-29 17:25:35 +08:00
|
|
|
gimp_param_spec_drawable ("drawable",
|
|
|
|
"Drawable",
|
|
|
|
"Input drawable",
|
|
|
|
TRUE,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2017-05-30 05:53:36 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
g_param_spec_object ("settings",
|
|
|
|
"Settings",
|
|
|
|
"Settings",
|
|
|
|
config_type,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2016-01-04 22:07:30 +08:00
|
|
|
|
|
|
|
return procedure;
|
|
|
|
}
|