mirror of https://github.com/GNOME/gimp.git
app: lock contents of items multi-item aware.
This commit is contained in:
parent
7c7c62a1df
commit
a602ea7662
|
@ -501,11 +501,11 @@ channels_lock_content_cmd_callback (GimpAction *action,
|
|||
GVariant *value,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpChannel *channel;
|
||||
return_if_no_channel (image, channel, data);
|
||||
GimpImage *image;
|
||||
GList *channels;
|
||||
return_if_no_channels (image, channels, data);
|
||||
|
||||
items_lock_content_cmd_callback (action, value, image, GIMP_ITEM (channel));
|
||||
items_lock_content_cmd_callback (action, value, image, channels);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -127,24 +127,47 @@ void
|
|||
items_lock_content_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
GimpImage *image,
|
||||
GimpItem *item)
|
||||
GList *items)
|
||||
{
|
||||
gboolean locked = g_variant_get_boolean (value);
|
||||
GList *locked_items = NULL;
|
||||
GList *iter;
|
||||
gchar *undo_label;
|
||||
gboolean locked = g_variant_get_boolean (value);
|
||||
|
||||
if (locked != gimp_item_get_lock_content (item))
|
||||
{
|
||||
GimpUndo *undo;
|
||||
gboolean push_undo = TRUE;
|
||||
for (iter = items; iter; iter = iter->next)
|
||||
if (gimp_item_can_lock_content (iter->data))
|
||||
{
|
||||
if (! locked && ! gimp_item_get_lock_content (iter->data))
|
||||
{
|
||||
/* When unlocking, we expect all selected items to be locked. */
|
||||
g_list_free (locked_items);
|
||||
return;
|
||||
}
|
||||
else if (locked != gimp_item_get_lock_content (iter->data))
|
||||
{
|
||||
locked_items = g_list_prepend (locked_items, iter->data);
|
||||
}
|
||||
}
|
||||
|
||||
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
||||
GIMP_UNDO_ITEM_LOCK_CONTENT);
|
||||
if (! locked_items)
|
||||
return;
|
||||
|
||||
if (undo && GIMP_ITEM_UNDO (undo)->item == item)
|
||||
push_undo = FALSE;
|
||||
if (locked)
|
||||
undo_label = _("Lock content");
|
||||
else
|
||||
undo_label = _("Unlock content");
|
||||
|
||||
gimp_item_set_lock_content (item, locked, push_undo);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
gimp_image_undo_group_start (image,
|
||||
GIMP_UNDO_GROUP_ITEM_LOCK_CONTENTS,
|
||||
undo_label);
|
||||
|
||||
for (iter = locked_items; iter; iter = iter->next)
|
||||
gimp_item_set_lock_content (iter->data, locked, TRUE);
|
||||
|
||||
gimp_image_flush (image);
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
g_list_free (locked_items);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -26,7 +26,7 @@ void items_visible_cmd_callback (GimpAction *action,
|
|||
void items_lock_content_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
GimpImage *image,
|
||||
GimpItem *item);
|
||||
GList *items);
|
||||
void items_lock_position_cmd_callback (GimpAction *action,
|
||||
GVariant *value,
|
||||
GimpImage *image,
|
||||
|
|
|
@ -2033,46 +2033,9 @@ layers_lock_content_cmd_callback (GimpAction *action,
|
|||
{
|
||||
GimpImage *image;
|
||||
GList *layers;
|
||||
GList *iter;
|
||||
GList *locked_layers = NULL;
|
||||
gboolean locked = g_variant_get_boolean (value);
|
||||
gchar *undo_label;
|
||||
return_if_no_layers (image, layers, data);
|
||||
|
||||
for (iter = layers; iter; iter = iter->next)
|
||||
if (gimp_item_can_lock_content (iter->data))
|
||||
{
|
||||
if (! locked && ! gimp_item_get_lock_content (iter->data))
|
||||
{
|
||||
/* When unlocking, we expect all selected layers to be locked. */
|
||||
g_list_free (locked_layers);
|
||||
return;
|
||||
}
|
||||
else if (locked != gimp_item_get_lock_content (iter->data))
|
||||
{
|
||||
locked_layers = g_list_prepend (locked_layers, iter->data);
|
||||
}
|
||||
}
|
||||
|
||||
if (! locked_layers)
|
||||
return;
|
||||
|
||||
if (locked)
|
||||
undo_label = _("Lock content");
|
||||
else
|
||||
undo_label = _("Unlock content");
|
||||
|
||||
gimp_image_undo_group_start (image,
|
||||
GIMP_UNDO_GROUP_ITEM_LOCK_CONTENTS,
|
||||
undo_label);
|
||||
|
||||
for (iter = locked_layers; iter; iter = iter->next)
|
||||
gimp_item_set_lock_content (iter->data, locked, TRUE);
|
||||
|
||||
gimp_image_flush (image);
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
g_list_free (locked_layers);
|
||||
items_lock_content_cmd_callback (action, value, image, layers);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -733,11 +733,11 @@ vectors_lock_content_cmd_callback (GimpAction *action,
|
|||
GVariant *value,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpVectors *vectors;
|
||||
return_if_no_vectors (image, vectors, data);
|
||||
GimpImage *image;
|
||||
GList *vectors;
|
||||
return_if_no_vectors_list (image, vectors, data);
|
||||
|
||||
items_lock_content_cmd_callback (action, value, image, GIMP_ITEM (vectors));
|
||||
items_lock_content_cmd_callback (action, value, image, vectors);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue