[gimp] app: get rid of one more usage of get_active_item() abstract method.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: get rid of one more usage of get_active_item() abstract method.
- Date: Wed, 12 Oct 2022 20:49:58 +0000 (UTC)
commit 0508148580badb617c6b414089c38180a830baf0
Author: Jehan <jehan girinstud io>
Date: Wed Oct 12 22:37:14 2022 +0200
app: get rid of one more usage of get_active_item() abstract method.
app/actions/plug-in-commands.c | 8 +++----
app/actions/procedure-commands.c | 46 ++++++++++++++++++++++++++++++++--------
app/actions/procedure-commands.h | 4 ++--
3 files changed, 43 insertions(+), 15 deletions(-)
---
diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c
index edba3a9328..7ce5482c4e 100644
--- a/app/actions/plug-in-commands.c
+++ b/app/actions/plug-in-commands.c
@@ -119,16 +119,16 @@ plug_in_run_cmd_callback (GimpAction *action,
{
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
GimpImage *image;
- GimpItem *item;
+ GList *items;
image = gimp_item_tree_view_get_image (view);
if (image)
- item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
+ items = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_selected_items (image);
else
- item = NULL;
+ items = NULL;
- args = procedure_commands_get_item_args (procedure, image, item);
+ args = procedure_commands_get_items_args (procedure, image, items);
}
else
{
diff --git a/app/actions/procedure-commands.c b/app/actions/procedure-commands.c
index 16974493e9..9cb01fe797 100644
--- a/app/actions/procedure-commands.c
+++ b/app/actions/procedure-commands.c
@@ -149,9 +149,9 @@ procedure_commands_get_image_args (GimpProcedure *procedure,
}
GimpValueArray *
-procedure_commands_get_item_args (GimpProcedure *procedure,
- GimpImage *image,
- GimpItem *item)
+procedure_commands_get_items_args (GimpProcedure *procedure,
+ GimpImage *image,
+ GList *items_list)
{
GimpValueArray *args;
gint n_args = 0;
@@ -178,21 +178,49 @@ procedure_commands_get_item_args (GimpProcedure *procedure,
if (gimp_value_array_length (args) > n_args &&
GIMP_IS_PARAM_SPEC_ITEM (procedure->args[n_args]))
{
- if (item &&
- g_type_is_a (G_TYPE_FROM_INSTANCE (item),
- G_PARAM_SPEC_VALUE_TYPE (procedure->args[n_args])))
+ if (items_list)
{
+ g_printerr ("%s: plug-in procedures expecting a single item are deprecated!\n",
+ G_STRFUNC);
g_value_set_object (gimp_value_array_index (args, n_args),
- item);
+ items_list->data);
n_args++;
}
else
{
- g_warning ("Uh-oh, no active item for the plug-in!");
+ g_warning ("Uh-oh, no selected items for the plug-in!");
gimp_value_array_unref (args);
return NULL;
}
}
+ else if (gimp_value_array_length (args) > n_args + 1 &&
+ G_IS_PARAM_SPEC_INT (procedure->args[n_args]) &&
+ GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (procedure->args[n_args + 1]))
+ {
+ GimpItem **items = NULL;
+ gint n_items;
+
+ n_items = g_list_length (items_list);
+
+ g_value_set_int (gimp_value_array_index (args, n_args++),
+ n_items);
+
+ if (items_list)
+ {
+ GList *iter;
+ gint i;
+
+ items = g_new (GimpItem *, n_items);
+ for (iter = items_list, i = 0; iter; iter = iter->next, i++)
+ items[i] = iter->data;
+ }
+
+ gimp_value_set_object_array (gimp_value_array_index (args, n_args++),
+ GIMP_TYPE_ITEM,
+ (GObject **) items, n_items);
+
+ g_free (items);
+ }
}
}
@@ -262,7 +290,7 @@ procedure_commands_get_display_args (GimpProcedure *procedure,
}
else
{
- g_warning ("Uh-oh, no active drawable for the plug-in!");
+ g_warning ("Uh-oh, no selected drawables for the plug-in!");
gimp_value_array_unref (args);
g_list_free (drawables_list);
diff --git a/app/actions/procedure-commands.h b/app/actions/procedure-commands.h
index 13c1109a32..f05dd1aff2 100644
--- a/app/actions/procedure-commands.h
+++ b/app/actions/procedure-commands.h
@@ -24,9 +24,9 @@ GimpValueArray * procedure_commands_get_data_args (GimpProcedure *procedure,
GimpObject *object);
GimpValueArray * procedure_commands_get_image_args (GimpProcedure *procedure,
GimpImage *image);
-GimpValueArray * procedure_commands_get_item_args (GimpProcedure *procedure,
+GimpValueArray * procedure_commands_get_items_args (GimpProcedure *procedure,
GimpImage *image,
- GimpItem *item);
+ GList *items);
GimpValueArray * procedure_commands_get_display_args (GimpProcedure *procedure,
GimpDisplay *display,
GimpObject *settings);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]