app: get rid of return_if_no_drawable() macro and…
… gimp_image_get_active_drawable() function! Also fixing some memory leaks from previous usages of the multi version return_if_no_drawables().
This commit is contained in:
parent
5d75c79c89
commit
f6dd7f9b3a
6 changed files with 27 additions and 49 deletions
|
|
@ -91,13 +91,6 @@ void action_message (GimpDisplay *display,
|
|||
if (! widget) \
|
||||
return
|
||||
|
||||
|
||||
#define return_if_no_drawable(image,drawable,data) \
|
||||
return_if_no_image (image,data); \
|
||||
drawable = gimp_image_get_active_drawable (image); \
|
||||
if (! drawable) \
|
||||
return
|
||||
|
||||
#define return_if_no_drawables(image,drawables,data) \
|
||||
return_if_no_image (image,data); \
|
||||
drawables = gimp_image_get_selected_drawables (image); \
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ drawable_equalize_cmd_callback (GimpAction *action,
|
|||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -108,6 +109,7 @@ drawable_levels_stretch_cmd_callback (GimpAction *action,
|
|||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -317,6 +319,7 @@ drawable_lock_position_cmd_callback (GimpAction *action,
|
|||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -372,6 +375,7 @@ drawable_flip_cmd_callback (GimpAction *action,
|
|||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -417,4 +421,5 @@ drawable_rotate_cmd_callback (GimpAction *action,
|
|||
gimp_image_undo_group_end (image);
|
||||
|
||||
gimp_image_flush (image);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,12 +65,20 @@ filters_apply_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpDrawable *drawable;
|
||||
GList *drawables;
|
||||
gchar *operation;
|
||||
GimpObject *settings;
|
||||
GimpProcedure *procedure;
|
||||
GVariant *variant;
|
||||
return_if_no_drawable (image, drawable, data);
|
||||
|
||||
return_if_no_drawables (image, drawables, data);
|
||||
|
||||
if (g_list_length (drawables) != 1)
|
||||
{
|
||||
/* We only support running filters on single drawable for now. */
|
||||
g_list_free (drawables);
|
||||
return;
|
||||
}
|
||||
|
||||
operation = filters_parse_operation (image->gimp,
|
||||
g_variant_get_string (value, NULL),
|
||||
|
|
@ -99,6 +107,7 @@ filters_apply_cmd_callback (GimpAction *action,
|
|||
|
||||
g_variant_unref (variant);
|
||||
g_object_unref (procedure);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -107,10 +116,18 @@ filters_apply_interactive_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpDrawable *drawable;
|
||||
GList *drawables;
|
||||
GimpProcedure *procedure;
|
||||
GVariant *variant;
|
||||
return_if_no_drawable (image, drawable, data);
|
||||
|
||||
return_if_no_drawables (image, drawables, data);
|
||||
|
||||
if (g_list_length (drawables) != 1)
|
||||
{
|
||||
/* We only support running filters on single drawable for now. */
|
||||
g_list_free (drawables);
|
||||
return;
|
||||
}
|
||||
|
||||
procedure = gimp_gegl_procedure_new (image->gimp,
|
||||
GIMP_RUN_INTERACTIVE, NULL,
|
||||
|
|
@ -129,6 +146,7 @@ filters_apply_interactive_cmd_callback (GimpAction *action,
|
|||
|
||||
g_variant_unref (variant);
|
||||
g_object_unref (procedure);
|
||||
g_list_free (drawables);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -4680,41 +4680,6 @@ gimp_image_get_vectors_list (GimpImage *image)
|
|||
|
||||
/* active drawable, layer, channel, vectors */
|
||||
|
||||
GimpDrawable *
|
||||
gimp_image_get_active_drawable (GimpImage *image)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
GimpItem *active_channel;
|
||||
GimpItem *active_layer;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
active_channel = gimp_item_tree_get_active_item (private->channels);
|
||||
active_layer = gimp_item_tree_get_active_item (private->layers);
|
||||
|
||||
/* If there is an active channel (a saved selection, etc.),
|
||||
* we ignore the active layer
|
||||
*/
|
||||
if (active_channel)
|
||||
{
|
||||
return GIMP_DRAWABLE (active_channel);
|
||||
}
|
||||
else if (active_layer)
|
||||
{
|
||||
GimpLayer *layer = GIMP_LAYER (active_layer);
|
||||
GimpLayerMask *mask = gimp_layer_get_mask (layer);
|
||||
|
||||
if (mask && gimp_layer_get_edit_mask (layer))
|
||||
return GIMP_DRAWABLE (mask);
|
||||
else
|
||||
return GIMP_DRAWABLE (layer);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpLayer *
|
||||
gimp_image_get_active_layer (GimpImage *image)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -372,7 +372,6 @@ GList * gimp_image_get_layer_list (GimpImage *image);
|
|||
GList * gimp_image_get_channel_list (GimpImage *image);
|
||||
GList * gimp_image_get_vectors_list (GimpImage *image);
|
||||
|
||||
GimpDrawable * gimp_image_get_active_drawable (GimpImage *image);
|
||||
GimpLayer * gimp_image_get_active_layer (GimpImage *image);
|
||||
GimpChannel * gimp_image_get_active_channel (GimpImage *image);
|
||||
GimpVectors * gimp_image_get_active_vectors (GimpImage *image);
|
||||
|
|
|
|||
|
|
@ -878,8 +878,6 @@ tile_swap_exit
|
|||
gimp_image_parasite_attach
|
||||
gimp_image_parasite_detach
|
||||
|
||||
gimp_image_get_active_drawable
|
||||
|
||||
gimp_image_get_load_proc
|
||||
|
||||
gimp_log
|
||||
|
|
|
|||
Loading…
Reference in a new issue