[gimp] app: "vectors-(raise|lower)*" actions now multi-paths aware.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: "vectors-(raise|lower)*" actions now multi-paths aware.
- Date: Wed, 12 Oct 2022 19:45:48 +0000 (UTC)
commit fde780daebb5d255a9927377a6abb36f6b7f68bc
Author: Jehan <jehan girinstud io>
Date: Wed Oct 12 21:45:13 2022 +0200
app: "vectors-(raise|lower)*" actions now multi-paths aware.
app/actions/actions.h | 6 ++
app/actions/vectors-actions.c | 8 +--
app/actions/vectors-commands.c | 141 +++++++++++++++++++++++++++++++++++------
3 files changed, 131 insertions(+), 24 deletions(-)
---
diff --git a/app/actions/actions.h b/app/actions/actions.h
index b34636c828..86ae2b6ca7 100644
--- a/app/actions/actions.h
+++ b/app/actions/actions.h
@@ -134,5 +134,11 @@ void action_message (GimpDisplay *display,
if (! vectors) \
return
+#define return_if_no_vectors_list(image,list,data) \
+ return_if_no_image (image,data); \
+ list = gimp_image_get_selected_vectors (image); \
+ if (! list) \
+ return
+
#endif /* __ACTIONS_H__ */
diff --git a/app/actions/vectors-actions.c b/app/actions/vectors-actions.c
index 4b4a616654..7d3fff2d32 100644
--- a/app/actions/vectors-actions.c
+++ b/app/actions/vectors-actions.c
@@ -426,10 +426,10 @@ vectors_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("vectors-delete", n_selected_vectors > 0);
SET_SENSITIVE ("vectors-merge-visible", n_vectors > 1);
- SET_SENSITIVE ("vectors-raise", n_selected_vectors == 1 && have_prev);
- SET_SENSITIVE ("vectors-raise-to-top", n_selected_vectors == 1 && have_prev);
- SET_SENSITIVE ("vectors-lower", n_selected_vectors == 1 && have_next);
- SET_SENSITIVE ("vectors-lower-to-bottom", n_selected_vectors == 1 && have_next);
+ SET_SENSITIVE ("vectors-raise", n_selected_vectors > 0 && have_prev);
+ SET_SENSITIVE ("vectors-raise-to-top", n_selected_vectors > 0 && have_prev);
+ SET_SENSITIVE ("vectors-lower", n_selected_vectors > 0 && have_next);
+ SET_SENSITIVE ("vectors-lower-to-bottom", n_selected_vectors > 0 && have_next);
SET_SENSITIVE ("vectors-copy", n_selected_vectors == 1);
SET_SENSITIVE ("vectors-paste", image);
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index eb54d5375d..0699fd9279 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -242,12 +242,35 @@ vectors_raise_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
- GimpImage *image;
- GimpVectors *vectors;
- return_if_no_vectors (image, vectors, data);
+ GimpImage *image;
+ GList *list;
+ GList *iter;
+ GList *moved_list = NULL;
+ return_if_no_vectors_list (image, list, data);
- gimp_image_raise_item (image, GIMP_ITEM (vectors), NULL);
- gimp_image_flush (image);
+ for (iter = list; iter; iter = iter->next)
+ {
+ gint index;
+
+ index = gimp_item_get_index (iter->data);
+ if (index > 0)
+ moved_list = g_list_prepend (moved_list, iter->data);
+ }
+
+ if (moved_list)
+ {
+ gimp_image_undo_group_start (image,
+ GIMP_UNDO_GROUP_ITEM_DISPLACE,
+ ngettext ("Raise Path",
+ "Raise Paths",
+ g_list_length (moved_list)));
+ for (iter = moved_list; iter; iter = iter->next)
+ gimp_image_raise_item (image, GIMP_ITEM (iter->data), NULL);
+
+ gimp_image_flush (image);
+ gimp_image_undo_group_end (image);
+ g_list_free (moved_list);
+ }
}
void
@@ -255,12 +278,36 @@ vectors_raise_to_top_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
- GimpImage *image;
- GimpVectors *vectors;
- return_if_no_vectors (image, vectors, data);
+ GimpImage *image;
+ GList *list;
+ GList *iter;
+ GList *moved_list = NULL;
+ return_if_no_vectors_list (image, list, data);
- gimp_image_raise_item_to_top (image, GIMP_ITEM (vectors));
- gimp_image_flush (image);
+ for (iter = list; iter; iter = iter->next)
+ {
+ gint index;
+
+ index = gimp_item_get_index (iter->data);
+ if (index > 0)
+ moved_list = g_list_prepend (moved_list, iter->data);
+ }
+
+ if (moved_list)
+ {
+ gimp_image_undo_group_start (image,
+ GIMP_UNDO_GROUP_ITEM_DISPLACE,
+ ngettext ("Raise Path to Top",
+ "Raise Paths to Top",
+ g_list_length (moved_list)));
+
+ for (iter = moved_list; iter; iter = iter->next)
+ gimp_image_raise_item_to_top (image, GIMP_ITEM (iter->data));
+
+ gimp_image_flush (image);
+ gimp_image_undo_group_end (image);
+ g_list_free (moved_list);
+ }
}
void
@@ -268,12 +315,39 @@ vectors_lower_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
- GimpImage *image;
- GimpVectors *vectors;
- return_if_no_vectors (image, vectors, data);
+ GimpImage *image;
+ GList *list;
+ GList *iter;
+ GList *moved_list = NULL;
+ return_if_no_vectors_list (image, list, data);
- gimp_image_lower_item (image, GIMP_ITEM (vectors), NULL);
- gimp_image_flush (image);
+ for (iter = list; iter; iter = iter->next)
+ {
+ GList *vectors_list;
+ gint index;
+
+ vectors_list = gimp_item_get_container_iter (GIMP_ITEM (iter->data));
+ index = gimp_item_get_index (iter->data);
+ if (index < g_list_length (vectors_list) - 1)
+ moved_list = g_list_prepend (moved_list, iter->data);
+ }
+
+ if (moved_list)
+ {
+ moved_list = g_list_reverse (moved_list);
+ gimp_image_undo_group_start (image,
+ GIMP_UNDO_GROUP_ITEM_DISPLACE,
+ ngettext ("Lower Path",
+ "Lower Paths",
+ g_list_length (moved_list)));
+
+ for (iter = moved_list; iter; iter = iter->next)
+ gimp_image_lower_item (image, GIMP_ITEM (iter->data), NULL);
+
+ gimp_image_flush (image);
+ gimp_image_undo_group_end (image);
+ g_list_free (moved_list);
+ }
}
void
@@ -281,12 +355,39 @@ vectors_lower_to_bottom_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
- GimpImage *image;
- GimpVectors *vectors;
- return_if_no_vectors (image, vectors, data);
+ GimpImage *image;
+ GList *list;
+ GList *iter;
+ GList *moved_list = NULL;
+ return_if_no_vectors_list (image, list, data);
- gimp_image_lower_item_to_bottom (image, GIMP_ITEM (vectors));
- gimp_image_flush (image);
+ for (iter = list; iter; iter = iter->next)
+ {
+ GList *vectors_list;
+ gint index;
+
+ vectors_list = gimp_item_get_container_iter (GIMP_ITEM (iter->data));
+ index = gimp_item_get_index (iter->data);
+ if (index < g_list_length (vectors_list) - 1)
+ moved_list = g_list_prepend (moved_list, iter->data);
+ }
+
+ if (moved_list)
+ {
+ moved_list = g_list_reverse (moved_list);
+ gimp_image_undo_group_start (image,
+ GIMP_UNDO_GROUP_ITEM_DISPLACE,
+ ngettext ("Lower Path to Bottom",
+ "Lower Paths to Bottom",
+ g_list_length (moved_list)));
+
+ for (iter = moved_list; iter; iter = iter->next)
+ gimp_image_lower_item_to_bottom (image, GIMP_ITEM (iter->data));
+
+ gimp_image_flush (image);
+ gimp_image_undo_group_end (image);
+ g_list_free (moved_list);
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]