mirror of https://github.com/GNOME/gimp.git
app: "drawable-linked" multi-drawable aware.
This commit is contained in:
parent
84e587d255
commit
e50f522d5b
|
@ -161,8 +161,8 @@ drawable_actions_update (GimpActionGroup *group,
|
|||
GimpDrawable *drawable = NULL;
|
||||
GList *drawables = NULL;
|
||||
gboolean has_visible = FALSE;
|
||||
gboolean has_linked = FALSE;
|
||||
gboolean is_rgb = FALSE;
|
||||
gboolean linked = FALSE;
|
||||
gboolean locked = FALSE;
|
||||
gboolean can_lock = FALSE;
|
||||
gboolean locked_pos = FALSE;
|
||||
|
@ -184,7 +184,10 @@ drawable_actions_update (GimpActionGroup *group,
|
|||
if (gimp_item_get_visible (iter->data))
|
||||
has_visible = TRUE;
|
||||
|
||||
if (has_visible)
|
||||
if (gimp_item_get_linked (iter->data))
|
||||
has_linked = TRUE;
|
||||
|
||||
if (has_visible && has_linked)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -199,7 +202,6 @@ drawable_actions_update (GimpActionGroup *group,
|
|||
else
|
||||
item = GIMP_ITEM (drawable);
|
||||
|
||||
linked = gimp_item_get_linked (item);
|
||||
locked = gimp_item_get_lock_content (item);
|
||||
can_lock = gimp_item_can_lock_content (item);
|
||||
writable = ! gimp_item_is_content_locked (item);
|
||||
|
@ -221,12 +223,12 @@ drawable_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("drawable-levels-stretch", writable && !children && is_rgb);
|
||||
|
||||
SET_SENSITIVE ("drawable-visible", drawables);
|
||||
SET_SENSITIVE ("drawable-linked", drawable);
|
||||
SET_SENSITIVE ("drawable-linked", drawables);
|
||||
SET_SENSITIVE ("drawable-lock-content", can_lock);
|
||||
SET_SENSITIVE ("drawable-lock-position", can_lock_pos);
|
||||
|
||||
SET_ACTIVE ("drawable-visible", has_visible);
|
||||
SET_ACTIVE ("drawable-linked", linked);
|
||||
SET_ACTIVE ("drawable-linked", has_linked);
|
||||
SET_ACTIVE ("drawable-lock-content", locked);
|
||||
SET_ACTIVE ("drawable-lock-position", locked_pos);
|
||||
|
||||
|
|
|
@ -90,30 +90,72 @@ drawable_linked_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpDrawable *drawable;
|
||||
GList *drawables;
|
||||
GList *iter;
|
||||
GimpUndo *undo = NULL;
|
||||
gboolean push_undo = TRUE;
|
||||
gboolean linked;
|
||||
return_if_no_drawable (image, drawable, data);
|
||||
|
||||
return_if_no_drawables (image, drawables, data);
|
||||
|
||||
linked = g_variant_get_boolean (value);
|
||||
|
||||
if (GIMP_IS_LAYER_MASK (drawable))
|
||||
drawable =
|
||||
GIMP_DRAWABLE (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)));
|
||||
|
||||
if (linked != gimp_item_get_linked (GIMP_ITEM (drawable)))
|
||||
if (GIMP_IS_LAYER_MASK (drawables->data))
|
||||
{
|
||||
GimpUndo *undo;
|
||||
gboolean push_undo = TRUE;
|
||||
GimpLayerMask *mask = GIMP_LAYER_MASK (drawables->data);
|
||||
|
||||
g_list_free (drawables);
|
||||
drawables = g_list_prepend (NULL, gimp_layer_mask_get_layer (mask));
|
||||
}
|
||||
|
||||
for (iter = drawables; iter; iter = iter->next)
|
||||
{
|
||||
if (linked && gimp_item_get_linked (iter->data))
|
||||
{
|
||||
/* If any of the drawables are already linked, we don't
|
||||
* toggle the link. This prevents the SET_ACTIVE() in
|
||||
* drawables-actions.c to toggle links unexpectedly.
|
||||
*/
|
||||
g_list_free (drawables);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (iter = drawables; iter; iter = iter->next)
|
||||
if (linked != gimp_item_get_linked (iter->data))
|
||||
break;
|
||||
|
||||
if (! iter)
|
||||
{
|
||||
g_list_free (drawables);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_list_length (drawables) == 1)
|
||||
{
|
||||
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
||||
GIMP_UNDO_ITEM_LINKED);
|
||||
|
||||
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
|
||||
push_undo = FALSE;
|
||||
|
||||
gimp_item_set_linked (GIMP_ITEM (drawable), linked, push_undo);
|
||||
gimp_image_flush (image);
|
||||
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawables->data))
|
||||
push_undo = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: undo groups cannot be compressed so far. */
|
||||
gimp_image_undo_group_start (image,
|
||||
GIMP_UNDO_GROUP_ITEM_LINKED,
|
||||
"Link/Unlink items");
|
||||
}
|
||||
|
||||
for (; iter; iter = iter->next)
|
||||
if (linked != gimp_item_get_linked (iter->data))
|
||||
gimp_item_set_linked (iter->data, linked, push_undo);
|
||||
|
||||
if (g_list_length (drawables) != 1)
|
||||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue