[gimp] app: make the "vectors-select-*" actions multi-selection aware.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make the "vectors-select-*" actions multi-selection aware.
- Date: Wed, 12 Oct 2022 19:45:48 +0000 (UTC)
commit 2835e85950a3ababbdc9d000d289027c085e1fb6
Author: Jehan <jehan girinstud io>
Date: Wed Oct 12 21:21:22 2022 +0200
app: make the "vectors-select-*" actions multi-selection aware.
app/actions/vectors-actions.c | 45 +++++++++++++++++++++++++-----------------
app/actions/vectors-commands.c | 40 ++++++++++++++++++++++++++-----------
2 files changed, 55 insertions(+), 30 deletions(-)
---
diff --git a/app/actions/vectors-actions.c b/app/actions/vectors-actions.c
index 7e34fe851f..4b4a616654 100644
--- a/app/actions/vectors-actions.c
+++ b/app/actions/vectors-actions.c
@@ -366,30 +366,39 @@ vectors_actions_update (GimpActionGroup *group,
gboolean mask_empty = TRUE;
gboolean dr_writable = FALSE;
gboolean dr_children = FALSE;
- GList *next = NULL;
- GList *prev = NULL;
+
+ gboolean have_prev = FALSE; /* At least 1 selected path has a previous sibling. */
+ gboolean have_next = FALSE; /* At least 1 selected path has a next sibling. */
if (image)
{
+ GList *iter;
+
n_vectors = gimp_image_get_n_vectors (image);
mask_empty = gimp_channel_is_empty (gimp_image_get_mask (image));
selected_vectors = gimp_image_get_selected_vectors (image);
n_selected_vectors = g_list_length (selected_vectors);
- if (n_selected_vectors == 1)
+
+ for (iter = selected_vectors; iter; iter = iter->next)
{
GList *vectors_list;
- GList *list;
+ GList *iter2;
- vectors_list = gimp_item_get_container_iter (GIMP_ITEM (selected_vectors->data));
+ vectors_list = gimp_item_get_container_iter (GIMP_ITEM (iter->data));
+ iter2 = g_list_find (vectors_list, iter->data);
- list = g_list_find (vectors_list, selected_vectors->data);
-
- if (list)
+ if (iter2)
{
- prev = g_list_previous (list);
- next = g_list_next (list);
+ if (g_list_previous (iter2))
+ have_prev = TRUE;
+
+ if (g_list_next (iter2))
+ have_next = TRUE;
}
+
+ if (have_prev && have_next)
+ break;
}
drawable = gimp_image_get_active_drawable (image);
@@ -417,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 && prev);
- SET_SENSITIVE ("vectors-raise-to-top", n_selected_vectors == 1 && prev);
- SET_SENSITIVE ("vectors-lower", n_selected_vectors == 1 && next);
- SET_SENSITIVE ("vectors-lower-to-bottom", n_selected_vectors == 1 && next);
+ 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-copy", n_selected_vectors == 1);
SET_SENSITIVE ("vectors-paste", image);
@@ -449,10 +458,10 @@ vectors_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("vectors-selection-subtract", n_selected_vectors == 1);
SET_SENSITIVE ("vectors-selection-intersect", n_selected_vectors == 1);
- SET_SENSITIVE ("vectors-select-top", n_selected_vectors == 1 && prev);
- SET_SENSITIVE ("vectors-select-bottom", n_selected_vectors == 1 && next);
- SET_SENSITIVE ("vectors-select-previous", n_selected_vectors == 1 && prev);
- SET_SENSITIVE ("vectors-select-next", n_selected_vectors == 1 && next);
+ SET_SENSITIVE ("vectors-select-top", n_selected_vectors > 0 && have_prev);
+ SET_SENSITIVE ("vectors-select-bottom", n_selected_vectors > 0 && have_next);
+ SET_SENSITIVE ("vectors-select-previous", n_selected_vectors > 0 && have_prev);
+ SET_SENSITIVE ("vectors-select-next", n_selected_vectors > 0 && have_next);
#undef SET_SENSITIVE
#undef SET_ACTIVE
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index 6dd7845afa..eb54d5375d 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -838,28 +838,44 @@ vectors_select_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
- GimpVectors *vectors;
- GimpContainer *container;
- GimpVectors *new_vectors;
+ GList *new_vectors = NULL;
+ GList *vectors;
+ GList *iter;
GimpActionSelectType select_type;
+ gboolean run_once;
return_if_no_image (image, data);
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
- vectors = gimp_image_get_active_vectors (image);
+ vectors = gimp_image_get_selected_vectors (image);
+ run_once = (g_list_length (vectors) == 0);
- if (vectors)
- container = gimp_item_get_container (GIMP_ITEM (vectors));
- else
- container = gimp_image_get_vectors (image);
+ for (iter = vectors; iter || run_once; iter = iter ? iter->next : NULL)
+ {
+ GimpVectors *new_vec;
+ GimpContainer *container;
- new_vectors = (GimpVectors *) action_select_object (select_type,
+ if (iter)
+ {
+ container = gimp_item_get_container (GIMP_ITEM (iter->data));
+ }
+ else /* run_once */
+ {
+ container = gimp_image_get_vectors (image);
+ run_once = FALSE;
+ }
+ new_vec = (GimpVectors *) action_select_object (select_type,
container,
- (GimpObject *) vectors);
+ iter ? iter->data : NULL);
+ if (new_vec)
+ new_vectors = g_list_prepend (new_vectors, new_vec);
+ }
- if (new_vectors && new_vectors != vectors)
+ if (new_vectors)
{
- gimp_image_set_active_vectors (image, new_vectors);
+ gimp_image_set_selected_vectors (image, new_vectors);
gimp_image_flush (image);
}
+
+ g_list_free (new_vectors);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]