[gimp] app: new "context-dynamics-toggle" action.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: new "context-dynamics-toggle" action.
- Date: Fri, 4 Feb 2022 14:15:05 +0000 (UTC)
commit 849bd0ac473897cca7762f64e294ccf10402023b
Author: Jehan <jehan girinstud io>
Date: Fri Feb 4 14:50:49 2022 +0100
app: new "context-dynamics-toggle" action.
As the name implies, this is an action to toggle the paint dynamics ON
and OFF which can be a huge time saver when painting and needing to
switch between dynamics and non-dynamics painting.
I have not been adding this action in the "dynamics-action" group
because these are only used for the dynamics dockable menu. Also it
looks like the context actions are not visible in the action search (I
can't recall why, but I think there was a reason), yet you can still set
a shortcut.
Should we create a new "paint-action" group maybe?
app/actions/context-actions.c | 14 ++++++++++++++
app/actions/context-commands.c | 34 ++++++++++++++++++++++++++++++++++
app/actions/context-commands.h | 4 ++++
3 files changed, 52 insertions(+)
---
diff --git a/app/actions/context-actions.c b/app/actions/context-actions.c
index aef16abe4b..5c11ae3d66 100644
--- a/app/actions/context-actions.c
+++ b/app/actions/context-actions.c
@@ -1087,6 +1087,16 @@ static const GimpEnumActionEntry context_brush_angle_actions[] =
NULL }
};
+static const GimpToggleActionEntry context_toggle_actions[] =
+{
+ { "context-dynamics-toggle", NULL,
+ NC_("context-action", "_Enable/Disable Dynamics"), NULL,
+ NC_("context-action", "Apply or ignore the dynamics when painting"),
+ context_toggle_dynamics_cmd_callback,
+ FALSE,
+ NULL },
+};
+
void
context_actions_setup (GimpActionGroup *group)
@@ -1237,6 +1247,10 @@ context_actions_setup (GimpActionGroup *group)
context_brush_angle_actions,
G_N_ELEMENTS (context_brush_angle_actions),
context_brush_angle_cmd_callback);
+
+ gimp_action_group_add_toggle_actions (group, "context-action",
+ context_toggle_actions,
+ G_N_ELEMENTS (context_toggle_actions));
}
void
diff --git a/app/actions/context-commands.c b/app/actions/context-commands.c
index 61d9e90e87..e6c20049b9 100644
--- a/app/actions/context-commands.c
+++ b/app/actions/context-commands.c
@@ -35,6 +35,7 @@
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimplist.h"
+#include "core/gimppaintinfo.h"
#include "core/gimptoolinfo.h"
#include "paint/gimppaintoptions.h"
@@ -797,6 +798,39 @@ context_brush_angle_cmd_callback (GimpAction *action,
}
}
+void
+context_toggle_dynamics_cmd_callback (GimpAction *action,
+ GVariant *value,
+ gpointer data)
+{
+ GimpContext *context;
+ GimpPaintInfo *paint_info;
+ gboolean enabled;
+
+ return_if_no_context (context, data);
+
+ paint_info = gimp_context_get_paint_info (context);
+ if (paint_info)
+ {
+ GimpPaintOptions *paint_options;
+ GimpDisplay *display;
+
+ paint_options = paint_info->paint_options;
+ enabled = gimp_paint_options_are_dynamics_enabled (paint_options);
+
+ gimp_paint_options_enable_dynamics (paint_options, ! enabled);
+
+ display = action_data_get_display (data);
+
+ if (enabled)
+ action_message (display, G_OBJECT (paint_options),
+ _("Dynamics disabled"));
+ else
+ action_message (display, G_OBJECT (paint_options),
+ _("Dynamics enabled"));
+ }
+}
+
/* private functions */
diff --git a/app/actions/context-commands.h b/app/actions/context-commands.h
index 76fe716190..0e486d534b 100644
--- a/app/actions/context-commands.h
+++ b/app/actions/context-commands.h
@@ -136,5 +136,9 @@ void context_brush_angle_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
+void context_toggle_dynamics_cmd_callback (GimpAction *action,
+ GVariant *value,
+ gpointer data);
+
#endif /* __CONTEXT_COMMANDS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]