static GValueArray *
floating_sel_anchor_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
{
  gboolean success = TRUE;
  GimpLayer *floating_sel;

  floating_sel = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      if (gimp_layer_is_floating_sel (floating_sel))
        {
          floating_sel_anchor (floating_sel);
        }
      else
        {
          g_set_error_literal (error, GIMP_PDB_ERROR,
                               GIMP_PDB_ERROR_INVALID_ARGUMENT,
                               _("Cannot anchor this layer because "
                                 "it is not a floating selection."));
          success = FALSE;
        }
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
static GValueArray *
floating_sel_attach_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
{
  gboolean success = TRUE;
  GimpLayer *layer;
  GimpDrawable *drawable;

  layer = gimp_value_get_layer (&args->values[0], gimp);
  drawable = gimp_value_get_drawable (&args->values[1], gimp);

  if (success)
    {
      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
        floating_sel_attach (layer, drawable);
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Exemple #3
0
static GimpValueArray *
selection_layer_alpha_invoker (GimpProcedure         *procedure,
                               Gimp                  *gimp,
                               GimpContext           *context,
                               GimpProgress          *progress,
                               const GimpValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  GimpLayer *layer;

  layer = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), NULL, 0, error))
        gimp_item_to_selection (GIMP_ITEM (layer),
                                GIMP_CHANNEL_OP_REPLACE,
                                TRUE, FALSE, 0.0, 0.0);
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Exemple #4
0
static GimpValueArray *
floating_sel_remove_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  GimpLayer *floating_sel;

  floating_sel = gimp_value_get_layer (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      if (gimp_layer_is_floating_sel (floating_sel))
        {
          gimp_image_remove_layer (gimp_item_get_image (GIMP_ITEM (floating_sel)),
                                   floating_sel, TRUE, NULL);
        }
      else
        {
          g_set_error_literal (error, GIMP_PDB_ERROR,
                               GIMP_PDB_ERROR_INVALID_ARGUMENT,
                               _("Cannot remove this layer because "
                                 "it is not a floating selection."));
          success = FALSE;
        }
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Exemple #5
0
static GValueArray *
selection_layer_alpha_invoker (GimpProcedure      *procedure,
                               Gimp               *gimp,
                               GimpContext        *context,
                               GimpProgress       *progress,
                               const GValueArray  *args,
                               GError            **error)
{
  gboolean success = TRUE;
  GimpLayer *layer;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));

      gimp_channel_select_alpha (gimp_image_get_mask (image),
                                 GIMP_DRAWABLE (layer),
                                 GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}