mirror of https://github.com/GNOME/gimp.git
app: remove last usages of return_if_no_layer macro.
- "Discard Text Information" work on all selected text layers. - "Text to Path" creates as many paths as there are selected text layers. - "Text along Path" still only works with exactly 1 text layer and 1 path selected.
This commit is contained in:
parent
563744934a
commit
ca8f4ef0d3
|
@ -97,12 +97,6 @@ void action_message (GimpDisplay *display,
|
|||
if (! drawables) \
|
||||
return
|
||||
|
||||
#define return_if_no_layer(image,layer,data) \
|
||||
return_if_no_image (image,data); \
|
||||
layer = gimp_image_get_active_layer (image); \
|
||||
if (! layer) \
|
||||
return
|
||||
|
||||
#define return_if_no_layers(image,layers,data) \
|
||||
return_if_no_image (image,data); \
|
||||
layers = gimp_image_get_selected_layers (image); \
|
||||
|
|
|
@ -212,13 +212,13 @@ static const GimpActionEntry layers_actions[] =
|
|||
|
||||
{ "layers-text-discard", GIMP_ICON_TOOL_TEXT,
|
||||
NC_("layers-action", "_Discard Text Information"), NULL,
|
||||
NC_("layers-action", "Turn this text layer into a normal layer"),
|
||||
NC_("layers-action", "Turn these text layers into normal layers"),
|
||||
layers_text_discard_cmd_callback,
|
||||
GIMP_HELP_LAYER_TEXT_DISCARD },
|
||||
|
||||
{ "layers-text-to-vectors", GIMP_ICON_TOOL_TEXT,
|
||||
NC_("layers-action", "Text to _Path"), NULL,
|
||||
NC_("layers-action", "Create a path from this text layer"),
|
||||
NC_("layers-action", "Create paths from text layers"),
|
||||
layers_text_to_vectors_cmd_callback,
|
||||
GIMP_HELP_LAYER_TEXT_TO_PATH },
|
||||
|
||||
|
@ -793,6 +793,7 @@ layers_actions_update (GimpActionGroup *group,
|
|||
|
||||
gint n_selected_layers = 0;
|
||||
gint n_layers = 0;
|
||||
gint n_text_layers = 0;
|
||||
|
||||
if (image)
|
||||
{
|
||||
|
@ -916,19 +917,8 @@ layers_actions_update (GimpActionGroup *group,
|
|||
else
|
||||
have_no_alpha = TRUE;
|
||||
|
||||
if (have_masks && have_no_masks &&
|
||||
have_groups && have_no_groups &&
|
||||
have_writable && ! all_writable &&
|
||||
! all_movable &&
|
||||
! all_masks_shown &&
|
||||
! all_masks_disabled &&
|
||||
! lock_alpha && can_lock_alpha &&
|
||||
! prev_mode && ! next_mode &&
|
||||
have_prev && have_next &&
|
||||
bs_mutable && cs_mutable && cm_mutable &&
|
||||
! all_visible && ! all_next_visible &&
|
||||
have_alpha && have_no_alpha)
|
||||
break;
|
||||
if (GIMP_IS_TEXT_LAYER (iter->data))
|
||||
n_text_layers++;
|
||||
}
|
||||
|
||||
if (n_selected_layers == 1)
|
||||
|
@ -1044,8 +1034,8 @@ layers_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("layers-merge-layers", n_selected_layers > 0 && !fs && !ac);
|
||||
SET_SENSITIVE ("layers-flatten-image", !fs && !ac);
|
||||
|
||||
SET_VISIBLE ("layers-text-discard", text_layer && !ac);
|
||||
SET_VISIBLE ("layers-text-to-vectors", text_layer && !ac);
|
||||
SET_VISIBLE ("layers-text-discard", n_text_layers > 0 && !ac);
|
||||
SET_VISIBLE ("layers-text-to-vectors", n_text_layers > 0 && !ac);
|
||||
SET_VISIBLE ("layers-text-along-vectors", text_layer && !ac);
|
||||
|
||||
SET_SENSITIVE ("layers-resize", n_selected_layers == 1 && all_writable && all_movable && !ac);
|
||||
|
|
|
@ -982,11 +982,16 @@ layers_text_discard_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
return_if_no_layer (image, layer, data);
|
||||
GList *layers;
|
||||
GList *iter;
|
||||
return_if_no_layers (image, layers, data);
|
||||
|
||||
if (GIMP_IS_TEXT_LAYER (layer))
|
||||
gimp_text_layer_discard (GIMP_TEXT_LAYER (layer));
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TEXT,
|
||||
_("Discard Text Information"));
|
||||
for (iter = layers; iter; iter = iter->next)
|
||||
if (GIMP_IS_TEXT_LAYER (iter->data))
|
||||
gimp_text_layer_discard (GIMP_TEXT_LAYER (iter->data));
|
||||
gimp_image_undo_group_end (image);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -995,23 +1000,33 @@ layers_text_to_vectors_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
return_if_no_layer (image, layer, data);
|
||||
GList *layers;
|
||||
GList *iter;
|
||||
return_if_no_layers (image, layers, data);
|
||||
|
||||
if (GIMP_IS_TEXT_LAYER (layer))
|
||||
/* TODO: have the proper undo group. */
|
||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_VECTORS_IMPORT,
|
||||
_("Add Paths"));
|
||||
for (iter = layers; iter; iter = iter->next)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
gint x, y;
|
||||
GimpLayer *layer = iter->data;
|
||||
|
||||
vectors = gimp_text_vectors_new (image, GIMP_TEXT_LAYER (layer)->text);
|
||||
if (GIMP_IS_TEXT_LAYER (layer))
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
gint x, y;
|
||||
|
||||
gimp_item_get_offset (GIMP_ITEM (layer), &x, &y);
|
||||
gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE);
|
||||
vectors = gimp_text_vectors_new (image, GIMP_TEXT_LAYER (layer)->text);
|
||||
|
||||
gimp_image_add_vectors (image, vectors,
|
||||
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
||||
gimp_image_flush (image);
|
||||
gimp_item_get_offset (GIMP_ITEM (layer), &x, &y);
|
||||
gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE);
|
||||
|
||||
gimp_image_add_vectors (image, vectors,
|
||||
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
}
|
||||
gimp_image_undo_group_end (image);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1020,11 +1035,18 @@ layers_text_along_vectors_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GList *layers;
|
||||
GList *paths;
|
||||
GimpLayer *layer;
|
||||
GimpVectors *vectors;
|
||||
return_if_no_layer (image, layer, data);
|
||||
return_if_no_vectors (image, vectors, data);
|
||||
return_if_no_layers (image, layers, data);
|
||||
return_if_no_vectors_list (image, paths, data);
|
||||
|
||||
if (g_list_length (layers) != 1 || g_list_length (paths) != 1)
|
||||
return;
|
||||
|
||||
layer = layers->data;
|
||||
vectors = paths->data;
|
||||
if (GIMP_IS_TEXT_LAYER (layer))
|
||||
{
|
||||
gdouble box_width;
|
||||
|
|
Loading…
Reference in New Issue