Commit 40e3406b authored by Ell's avatar Ell

pdb: add gimp-image-{freeze,thaw}-{layers,channels,vectors}

These procedures freeze/thaw the corresponding containers of the
image, allowing plug-ins that perform many changes affecting any of
these containers to suppress updates to the corresponding dialogs,
significantly improving performance.
parent 88c63420
......@@ -895,6 +895,57 @@ image_remove_layer_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
image_freeze_layers_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_layers (image);
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_thaw_layers_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_layers (image);
if (gimp_container_frozen (container))
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_add_channel_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -998,6 +1049,57 @@ image_remove_channel_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
image_freeze_channels_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_channels (image);
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_thaw_channels_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_channels (image);
if (gimp_container_frozen (container))
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_add_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -1101,6 +1203,57 @@ image_remove_vectors_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
image_freeze_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_vectors (image);
gimp_container_freeze (container);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_thaw_vectors_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpContainer *container = gimp_image_get_vectors (image);
if (gimp_container_frozen (container))
gimp_container_thaw (container);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
image_get_item_position_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -3562,6 +3715,56 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-freeze-layers
*/
procedure = gimp_procedure_new (image_freeze_layers_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-freeze-layers");
gimp_procedure_set_static_strings (procedure,
"gimp-image-freeze-layers",
"Freeze the image's layer list.",
"This procedure freezes the layer list of the image, supressing any updates to the Layers dialog in response to changes to the image's layers. This can significantly improve performance while applying changes affecting the layer list.\n"
"\n"
"Each call to 'gimp-image-freeze-layers' should be matched by a corresponding call to 'gimp-image-thaw-layers', undoing its effects.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-thaw-layers
*/
procedure = gimp_procedure_new (image_thaw_layers_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-thaw-layers");
gimp_procedure_set_static_strings (procedure,
"gimp-image-thaw-layers",
"Thaw the image's layer list.",
"This procedure thaws the layer list of the image, re-enabling updates to the Layers dialog.\n"
"\n"
"This procedure should match a corresponding call to 'gimp-image-freeze-layers'.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-add-channel
*/
......@@ -3667,6 +3870,56 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-freeze-channels
*/
procedure = gimp_procedure_new (image_freeze_channels_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-freeze-channels");
gimp_procedure_set_static_strings (procedure,
"gimp-image-freeze-channels",
"Freeze the image's channel list.",
"This procedure freezes the channel list of the image, supressing any updates to the Channels dialog in response to changes to the image's channels. This can significantly improve performance while applying changes affecting the channel list.\n"
"\n"
"Each call to 'gimp-image-freeze-channels' should be matched by a corresponding call to 'gimp-image-thaw-channels', undoing its effects.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-thaw-channels
*/
procedure = gimp_procedure_new (image_thaw_channels_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-thaw-channels");
gimp_procedure_set_static_strings (procedure,
"gimp-image-thaw-channels",
"Thaw the image's channel list.",
"This procedure thaws the channel list of the image, re-enabling updates to the Channels dialog.\n"
"\n"
"This procedure should match a corresponing call to 'gimp-image-freeze-channels'.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-add-vectors
*/
......@@ -3772,6 +4025,56 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-freeze-vectors
*/
procedure = gimp_procedure_new (image_freeze_vectors_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-freeze-vectors");
gimp_procedure_set_static_strings (procedure,
"gimp-image-freeze-vectors",
"Freeze the image's vectors list.",
"This procedure freezes the vectors list of the image, supressing any updates to the Paths dialog in response to changes to the image's vectors. This can significantly improve performance while applying changes affecting the vectors list.\n"
"\n"
"Each call to 'gimp-image-freeze-vectors' should be matched by a corresponding call to 'gimp-image-thaw-vectors', undoing its effects.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-thaw-vectors
*/
procedure = gimp_procedure_new (image_thaw_vectors_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-thaw-vectors");
gimp_procedure_set_static_strings (procedure,
"gimp-image-thaw-vectors",
"Thaw the image's vectors list.",
"This procedure thaws the vectors list of the image, re-enabling updates to the Paths dialog.\n"
"\n"
"This procedure should match a corresponding call to 'gimp-image-freeze-vectors'.",
"Ell",
"Ell",
"2018",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-get-item-position
*/
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 834 procedures registered total */
/* 840 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -445,6 +445,9 @@ EXPORTS
gimp_image_flip
gimp_image_floating_sel_attached_to
gimp_image_free_shadow
gimp_image_freeze_channels
gimp_image_freeze_layers
gimp_image_freeze_vectors
gimp_image_get_active_channel
gimp_image_get_active_drawable
gimp_image_get_active_layer
......@@ -560,6 +563,9 @@ EXPORTS
gimp_image_set_resolution
gimp_image_set_tattoo_state
gimp_image_set_unit
gimp_image_thaw_channels
gimp_image_thaw_layers
gimp_image_thaw_vectors
gimp_image_undo_disable
gimp_image_undo_enable
gimp_image_undo_freeze
......
......@@ -927,6 +927,74 @@ gimp_image_remove_layer (gint32 image_ID,
return success;
}
/**
* gimp_image_freeze_layers:
* @image_ID: The image.
*
* Freeze the image's layer list.
*
* This procedure freezes the layer list of the image, supressing any
* updates to the Layers dialog in response to changes to the image's
* layers. This can significantly improve performance while applying
* changes affecting the layer list.
*
* Each call to gimp_image_freeze_layers() should be matched by a
* corresponding call to gimp_image_thaw_layers(), undoing its effects.
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_freeze_layers (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-freeze-layers",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_thaw_layers:
* @image_ID: The image.
*
* Thaw the image's layer list.
*
* This procedure thaws the layer list of the image, re-enabling
* updates to the Layers dialog.
*
* This procedure should match a corresponding call to
* gimp_image_freeze_layers().
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_thaw_layers (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-thaw-layers",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_add_channel:
* @image_ID: The image.
......@@ -1036,6 +1104,75 @@ gimp_image_remove_channel (gint32 image_ID,
return success;
}
/**
* gimp_image_freeze_channels:
* @image_ID: The image.
*
* Freeze the image's channel list.
*
* This procedure freezes the channel list of the image, supressing any
* updates to the Channels dialog in response to changes to the image's
* channels. This can significantly improve performance while applying
* changes affecting the channel list.
*
* Each call to gimp_image_freeze_channels() should be matched by a
* corresponding call to gimp_image_thaw_channels(), undoing its
* effects.
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_freeze_channels (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-freeze-channels",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_thaw_channels:
* @image_ID: The image.
*
* Thaw the image's channel list.
*
* This procedure thaws the channel list of the image, re-enabling
* updates to the Channels dialog.
*
* This procedure should match a corresponing call to
* gimp_image_freeze_channels().
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_thaw_channels (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-thaw-channels",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_add_vectors:
* @image_ID: The image.
......@@ -1147,6 +1284,75 @@ gimp_image_remove_vectors (gint32 image_ID,
return success;
}
/**
* gimp_image_freeze_vectors:
* @image_ID: The image.
*
* Freeze the image's vectors list.
*
* This procedure freezes the vectors list of the image, supressing any
* updates to the Paths dialog in response to changes to the image's
* vectors. This can significantly improve performance while applying
* changes affecting the vectors list.
*
* Each call to gimp_image_freeze_vectors() should be matched by a
* corresponding call to gimp_image_thaw_vectors(), undoing its
* effects.
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_freeze_vectors (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-freeze-vectors",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_thaw_vectors:
* @image_ID: The image.
*
* Thaw the image's vectors list.
*
* This procedure thaws the vectors list of the image, re-enabling
* updates to the Paths dialog.
*
* This procedure should match a corresponding call to
* gimp_image_freeze_vectors().
*
* Returns: TRUE on success.
**/
gboolean
gimp_image_thaw_vectors (gint32 image_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-thaw-vectors",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_image_get_item_position:
* @image_ID: The image.
......
......@@ -81,6 +81,8 @@ gboolean gimp_image_insert_layer (gint32
gint position);
gboolean gimp_image_remove_layer (gint32 image_ID,
gint32 layer_ID);
gboolean gimp_image_freeze_layers (gint32 image_ID);
gboolean gimp_image_thaw_layers (gint32 image_ID);
GIMP_DEPRECATED_FOR(gimp_image_insert_channel)
gboolean gimp_image_add_channel (gint32 image_ID,
gint32 channel_ID,
......@@ -91,6 +93,8 @@ gboolean gimp_image_insert_channel (gint32
gint position);
gboolean gimp_image_remove_channel (gint32 image_ID,
gint32 channel_ID);
gboolean gimp_image_freeze_channels (gint32 image_ID);
gboolean gimp_image_thaw_channels (gint32 image_ID);
GIMP_DEPRECATED_FOR(gimp_image_insert_vectors)
gboolean gimp_image_add_vectors (gint32 image_ID,
gint32 vectors_ID,
......@@ -101,6 +105,8 @@ gboolean gimp_image_insert_vectors (gint32
gint position);
gboolean gimp_image_remove_vectors (gint32 image_ID,
gint32 vectors_ID);
gboolean gimp_image_freeze_vectors (gint32 image_ID);
gboolean gimp_image_thaw_vectors (gint32 image_ID);
gint gimp_image_get_item_position (gint32 image_ID,
gint32 item_ID);
gboolean gimp_image_raise_item (gint32 image_ID,
......
......@@ -1019,6 +1019,72 @@ CODE
);
}
sub image_freeze_layers {
$blurb = "Freeze the image's layer list.";
$help = <<'HELP';
This procedure freezes the layer list of the image, supressing any
updates to the Layers dialog in response to changes to the image's
layers. This can significantly improve performance while applying
changes affecting the layer list.
Each call to gimp_image_freeze_layers() should be matched by a
corresponding call to gimp_image_thaw_layers(), undoing its
effects.
HELP
&ell_pdb_misc('2018');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' }
);
%invoke = (
code => <<'CODE'
{
GimpContainer *container = gimp_image_get_layers (image);
gimp_container_freeze (container);
}
CODE
);
}
sub image_thaw_layers {
$blurb = "Thaw the image's layer list.";
$help = <<'HELP';
This procedure thaws the layer list of the image, re-enabling
updates to the Layers dialog.
This procedure should match a corresponding call to
gimp_image_freeze_layers().
HELP
&ell_pdb_misc('2018');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' }
);
%invoke = (
code => <<'CODE'
{
GimpContainer *container = gimp_image_get_layers (image);
if (gimp_container_frozen (container))
gimp_container_thaw (container);
else
success = FALSE;
}
CODE
);
}
sub image_add_channel {
&std_pdb_deprecated ('gimp-image-insert-channel');
......@@ -1123,6 +1189,72 @@ CODE
);
}
sub image_freeze_channels {
$blurb = "Freeze the image's channel list.";
&ell_pdb_misc('2018');
$help = <<'HELP';
This procedure freezes the channel list of the image, supressing any
updates to the Channels dialog in response to changes to the image's
channels. This can significantly improve performance while applying
changes affecting the channel list.
Each call to gimp_image_freeze_channels() should be matched by a
corresponding call to gimp_image_thaw_channels(), undoing its
effects.
HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' }
);
%invoke = (
code => <<'CODE'
{
GimpContainer *container = gimp_image_get_channels (image);
gimp_container_freeze (container);
}
CODE
);
}
sub image_thaw_channels {
$blurb = "Thaw the image's channel list.";
&ell_pdb_misc('2018');
$help = <<'HELP';
This procedure thaws the channel list of the image, re-enabling
updates to the Channels dialog.
This procedure should match a corresponing call to
gimp_image_freeze_channels().
HELP
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' }
);
%invoke = (