[gimp] app: add member "default_run_mode" to GimpGeglProcedure
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add member "default_run_mode" to GimpGeglProcedure
- Date: Wed, 31 May 2017 22:08:44 +0000 (UTC)
commit 383419926bf1ec380189314dce94ccb40c6ec0a7
Author: Michael Natterer <mitch gimp org>
Date: Wed May 31 23:41:37 2017 +0200
app: add member "default_run_mode" to GimpGeglProcedure
which determines if a filter is applied directly (RUN_NONINTERACTIVE)
or asynchronously using GimpOperationTool (RUN_INTERACTIVE).
Split filter actions in two groups, one for direct apply and one for
interactive apply, which have separate callbacks that create
GimpGeglProcedures with the right default_run_mode set.
(After doing this distinction automatically based on the existance of
editable properties, I figured will might want direct apply also for
filters that do have properties, such as e.g. dilate and erode, which
are just value-propagate with some constant property values)
app/actions/filters-actions.c | 52 +++++++++++++++++--------
app/actions/filters-commands.c | 81 ++++++++++++++++++++++++++++++++------
app/actions/filters-commands.h | 21 ++++++----
app/actions/gimpgeglprocedure.c | 6 ++-
app/actions/gimpgeglprocedure.h | 3 +
5 files changed, 123 insertions(+), 40 deletions(-)
---
diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 813b154..121b1d1 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -97,6 +97,24 @@ static const GimpActionEntry filters_menu_actions[] =
static const GimpStringActionEntry filters_actions[] =
{
+ { "filters-invert-linear", GIMP_ICON_INVERT,
+ NC_("filters-action", "_Linear Invert"), NULL, NULL,
+ "gegl:invert-linear",
+ GIMP_HELP_FILTER_INVERT_LINEAR },
+
+ { "filters-invert-perceptual", GIMP_ICON_INVERT,
+ NC_("filters-action", "In_vert"), NULL, NULL,
+ "gegl:invert-gamma",
+ GIMP_HELP_FILTER_INVERT_PERCEPTUAL },
+
+ { "filters-invert-value", GIMP_ICON_GEGL,
+ NC_("filters-action", "_Value Invert"), NULL, NULL,
+ "gegl:value-invert",
+ GIMP_HELP_FILTER_INVERT_VALUE }
+};
+
+static const GimpStringActionEntry filters_interactive_actions[] =
+{
{ "filters-alien-map", GIMP_ICON_GEGL,
NC_("filters-action", "_Alien Map..."), NULL, NULL,
"gegl:alien-map",
@@ -307,21 +325,6 @@ static const GimpStringActionEntry filters_actions[] =
"gegl:image-gradient",
GIMP_HELP_FILTER_IMAGE_GRADIENT },
- { "filters-invert-linear", GIMP_ICON_INVERT,
- NC_("filters-action", "_Linear Invert"), NULL, NULL,
- "gegl:invert-linear",
- GIMP_HELP_FILTER_INVERT_LINEAR },
-
- { "filters-invert-perceptual", GIMP_ICON_INVERT,
- NC_("filters-action", "In_vert"), NULL, NULL,
- "gegl:invert-gamma",
- GIMP_HELP_FILTER_INVERT_PERCEPTUAL },
-
- { "filters-invert-value", GIMP_ICON_GEGL,
- NC_("filters-action", "_Value Invert"), NULL, NULL,
- "gegl:value-invert",
- GIMP_HELP_FILTER_INVERT_VALUE },
-
{ "filters-kaleidoscope", GIMP_ICON_GEGL,
NC_("filters-action", "_Kaleidoscope..."), NULL, NULL,
"gegl:mirrors",
@@ -639,7 +642,12 @@ filters_actions_setup (GimpActionGroup *group)
gimp_action_group_add_string_actions (group, "filters-action",
filters_actions,
G_N_ELEMENTS (filters_actions),
- G_CALLBACK (filters_filter_cmd_callback));
+ G_CALLBACK (filters_apply_cmd_callback));
+
+ gimp_action_group_add_string_actions (group, "filters-action",
+ filters_interactive_actions,
+ G_N_ELEMENTS (filters_interactive_actions),
+ G_CALLBACK (filters_apply_interactive_cmd_callback));
gimp_action_group_add_enum_actions (group, "filters-action",
filters_repeat_actions,
@@ -658,6 +666,18 @@ filters_actions_setup (GimpActionGroup *group)
description);
}
+ for (i = 0; i < G_N_ELEMENTS (filters_interactive_actions); i++)
+ {
+ const GimpStringActionEntry *entry = &filters_interactive_actions[i];
+ const gchar *description;
+
+ description = gegl_operation_get_key (entry->value, "description");
+
+ if (description)
+ gimp_action_group_set_action_tooltip (group, entry->name,
+ description);
+ }
+
n_entries = gimp_filter_history_size (group->gimp);
entries = g_new0 (GimpProcedureActionEntry, n_entries);
diff --git a/app/actions/filters-commands.c b/app/actions/filters-commands.c
index 168d598..4d1de87 100644
--- a/app/actions/filters-commands.c
+++ b/app/actions/filters-commands.c
@@ -38,15 +38,41 @@
/* public functions */
void
-filters_filter_cmd_callback (GtkAction *action,
- const gchar *operation,
- gpointer data)
+filters_apply_cmd_callback (GtkAction *action,
+ const gchar *operation,
+ gpointer data)
{
GimpDisplay *display;
GimpProcedure *procedure;
return_if_no_display (display, data);
procedure = gimp_gegl_procedure_new (action_data_get_gimp (data),
+ GIMP_RUN_NONINTERACTIVE,
+ operation,
+ gtk_action_get_name (action),
+ gtk_action_get_label (action),
+ gtk_action_get_tooltip (action),
+ gtk_action_get_icon_name (action),
+ g_object_get_qdata (G_OBJECT (action),
+ GIMP_HELP_ID));
+
+ gimp_filter_history_add (action_data_get_gimp (data), procedure);
+ filters_history_cmd_callback (NULL, procedure, data);
+
+ g_object_unref (procedure);
+}
+
+void
+filters_apply_interactive_cmd_callback (GtkAction *action,
+ const gchar *operation,
+ gpointer data)
+{
+ GimpDisplay *display;
+ GimpProcedure *procedure;
+ return_if_no_display (display, data);
+
+ procedure = gimp_gegl_procedure_new (action_data_get_gimp (data),
+ GIMP_RUN_INTERACTIVE,
operation,
gtk_action_get_name (action),
gtk_action_get_label (action),
@@ -80,18 +106,32 @@ filters_repeat_cmd_callback (GtkAction *action,
if (procedure)
{
GimpValueArray *args;
+ gboolean success = FALSE;
args = procedure_commands_get_display_args (procedure, display, NULL);
if (args)
{
- if (procedure_commands_run_procedure_async (procedure, gimp,
- GIMP_PROGRESS (display),
- run_mode, args,
- display))
+ if (GIMP_IS_GEGL_PROCEDURE (procedure) &&
+ GIMP_GEGL_PROCEDURE (procedure)->default_run_mode ==
+ GIMP_RUN_NONINTERACTIVE)
{
- gimp_filter_history_add (gimp, procedure);
+ success =
+ procedure_commands_run_procedure (procedure, gimp,
+ GIMP_PROGRESS (display),
+ args);
}
+ else
+ {
+ success =
+ procedure_commands_run_procedure_async (procedure, gimp,
+ GIMP_PROGRESS (display),
+ run_mode, args,
+ display);
+ }
+
+ if (success)
+ gimp_filter_history_add (gimp, procedure);
gimp_value_array_unref (args);
}
@@ -113,13 +153,28 @@ filters_history_cmd_callback (GtkAction *action,
if (args)
{
- if (procedure_commands_run_procedure_async (procedure, gimp,
- GIMP_PROGRESS (display),
- GIMP_RUN_INTERACTIVE, args,
- display))
+ gboolean success = FALSE;
+
+ if (GIMP_IS_GEGL_PROCEDURE (procedure) &&
+ GIMP_GEGL_PROCEDURE (procedure)->default_run_mode ==
+ GIMP_RUN_NONINTERACTIVE)
{
- gimp_filter_history_add (gimp, procedure);
+ success =
+ procedure_commands_run_procedure (procedure, gimp,
+ GIMP_PROGRESS (display),
+ args);
}
+ else
+ {
+ success =
+ procedure_commands_run_procedure_async (procedure, gimp,
+ GIMP_PROGRESS (display),
+ GIMP_RUN_INTERACTIVE, args,
+ display);
+ }
+
+ if (success)
+ gimp_filter_history_add (gimp, procedure);
gimp_value_array_unref (args);
}
diff --git a/app/actions/filters-commands.h b/app/actions/filters-commands.h
index 53e931c..f98cbc6 100644
--- a/app/actions/filters-commands.h
+++ b/app/actions/filters-commands.h
@@ -19,16 +19,19 @@
#define __FILTERS_COMMANDS_H__
-void filters_filter_cmd_callback (GtkAction *action,
- const gchar *operation,
- gpointer data);
+void filters_apply_cmd_callback (GtkAction *action,
+ const gchar *operation,
+ gpointer data);
+void filters_apply_interactive_cmd_callback (GtkAction *action,
+ const gchar *operation,
+ gpointer data);
-void filters_repeat_cmd_callback (GtkAction *action,
- gint value,
- gpointer data);
-void filters_history_cmd_callback (GtkAction *action,
- GimpProcedure *procedure,
- gpointer data);
+void filters_repeat_cmd_callback (GtkAction *action,
+ gint value,
+ gpointer data);
+void filters_history_cmd_callback (GtkAction *action,
+ GimpProcedure *procedure,
+ gpointer data);
#endif /* __FILTERS_COMMANDS_H__ */
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index 4ab628e..28d6e4e 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -373,6 +373,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
GimpProcedure *
gimp_gegl_procedure_new (Gimp *gimp,
+ GimpRunMode default_run_mode,
const gchar *operation,
const gchar *name,
const gchar *menu_label,
@@ -393,8 +394,9 @@ gimp_gegl_procedure_new (Gimp *gimp,
procedure = g_object_new (GIMP_TYPE_GEGL_PROCEDURE, NULL);
- GIMP_GEGL_PROCEDURE (procedure)->menu_label = g_strdup (menu_label);
- GIMP_GEGL_PROCEDURE (procedure)->help_id = g_strdup (help_id);
+ GIMP_GEGL_PROCEDURE (procedure)->default_run_mode = default_run_mode;
+ GIMP_GEGL_PROCEDURE (procedure)->menu_label = g_strdup (menu_label);
+ GIMP_GEGL_PROCEDURE (procedure)->help_id = g_strdup (help_id);
gimp_object_set_name (GIMP_OBJECT (procedure), name);
gimp_viewable_set_icon_name (GIMP_VIEWABLE (procedure), icon_name);
diff --git a/app/actions/gimpgeglprocedure.h b/app/actions/gimpgeglprocedure.h
index c510b92..62371a7 100644
--- a/app/actions/gimpgeglprocedure.h
+++ b/app/actions/gimpgeglprocedure.h
@@ -40,6 +40,8 @@ struct _GimpGeglProcedure
{
GimpProcedure parent_instance;
+ GimpRunMode default_run_mode;
+
gchar *menu_label;
gchar *label;
gchar *help_id;
@@ -54,6 +56,7 @@ struct _GimpGeglProcedureClass
GType gimp_gegl_procedure_get_type (void) G_GNUC_CONST;
GimpProcedure * gimp_gegl_procedure_new (Gimp *gimp,
+ GimpRunMode default_run_mode,
const gchar *operation,
const gchar *name,
const gchar *menu_label,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]