Beispiel #1
0
static GimpValueArray *
image_select_color_invoker (GimpProcedure         *procedure,
                            Gimp                  *gimp,
                            GimpContext           *context,
                            GimpProgress          *progress,
                            const GimpValueArray  *args,
                            GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 operation;
  GimpDrawable *drawable;
  GimpRGB color;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  operation = g_value_get_enum (gimp_value_array_index (args, 1));
  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
  gimp_value_get_rgb (gimp_value_array_index (args, 3), &color);

  if (success)
    {
      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);

      if (pdb_context->sample_merged ||
          gimp_pdb_item_is_attached (GIMP_ITEM (drawable), image, FALSE, error))
        {
          gimp_channel_select_by_color (gimp_image_get_mask (image), drawable,
                                        pdb_context->sample_merged,
                                        &color,
                                        pdb_context->sample_threshold,
                                        pdb_context->sample_transparent,
                                        pdb_context->sample_criterion,
                                        operation,
                                        pdb_context->antialias,
                                        pdb_context->feather,
                                        pdb_context->feather_radius_x,
                                        pdb_context->feather_radius_y);
        }
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #2
0
static GimpValueArray *
image_set_color_profile_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
                                 GimpProgress          *progress,
                                 const GimpValueArray  *args,
                                 GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 num_bytes;
  const guint8 *color_profile;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  num_bytes = g_value_get_int (gimp_value_array_index (args, 1));
  color_profile = gimp_value_get_int8array (gimp_value_array_index (args, 2));

  if (success)
    {
      if (color_profile)
        {
          GimpColorProfile *profile;

          profile = gimp_color_profile_new_from_icc_profile (color_profile,
                                                             num_bytes,
                                                             error);

          if (profile)
            {
              success = gimp_image_set_color_profile (image, profile, error);
              g_object_unref (profile);
            }
          else
            success = FALSE;
        }
      else
        {
          success = gimp_image_set_color_profile (image, NULL, error);
        }
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #3
0
static GimpValueArray *
edit_copy_invoker (GimpProcedure         *procedure,
                   Gimp                  *gimp,
                   GimpContext           *context,
                   GimpProgress          *progress,
                   const GimpValueArray  *args,
                   GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpDrawable *drawable;
  gboolean non_empty = FALSE;

  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, 0, error))
        {
          GimpImage *image    = gimp_item_get_image (GIMP_ITEM (drawable));
          GError    *my_error = NULL;

          non_empty = gimp_edit_copy (image, drawable, context, &my_error) != NULL;

          if (! non_empty)
            {
              gimp_message_literal (gimp,
                                    G_OBJECT (progress), GIMP_MESSAGE_WARNING,
                                    my_error->message);
              g_clear_error (&my_error);
            }
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (gimp_value_array_index (return_vals, 1), non_empty);

  return return_vals;
}
Beispiel #4
0
static GimpValueArray *
image_set_color_profile_from_file_invoker (GimpProcedure         *procedure,
                                           Gimp                  *gimp,
                                           GimpContext           *context,
                                           GimpProgress          *progress,
                                           const GimpValueArray  *args,
                                           GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  const gchar *uri;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  uri = g_value_get_string (gimp_value_array_index (args, 1));

  if (success)
    {
      if (uri)
        {
          GFile            *file = g_file_new_for_uri (uri);
          GimpColorProfile *profile;

          profile = gimp_color_profile_new_from_file (file, error);

          if (profile)
            {
              success = gimp_image_set_color_profile (image, profile, error);
              g_object_unref (profile);
            }
          else
            success = FALSE;

          g_object_unref (file);
        }
      else
        {
          success = gimp_image_set_color_profile (image, NULL, error);
        }
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #5
0
static GimpValueArray *
image_get_effective_color_profile_invoker (GimpProcedure         *procedure,
                                           Gimp                  *gimp,
                                           GimpContext           *context,
                                           GimpProgress          *progress,
                                           const GimpValueArray  *args,
                                           GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 num_bytes = 0;
  guint8 *profile_data = NULL;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      GimpColorProfile *profile;
      const guint8     *data;
      gsize             length;

      profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));

      data = gimp_color_profile_get_icc_profile (profile, &length);

      profile_data = g_memdup (data, length);
      num_bytes = length;

      g_object_unref (profile);
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
      gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
    }

  return return_vals;
}
static GimpValueArray *
procedural_db_get_data_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *identifier;
  gint32 bytes = 0;
  guint8 *data = NULL;

  identifier = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      gchar        *canonical = gimp_canonicalize_identifier (identifier);
      const guint8 *orig_data;

      orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager,
                                                 canonical, &bytes);

      g_free (canonical);

      if (orig_data)
        data = g_memdup (orig_data, bytes);
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (gimp_value_array_index (return_vals, 1), bytes);
      gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), data, bytes);
    }

  return return_vals;
}
static GimpValueArray *
procedural_db_query_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  const gchar *blurb;
  const gchar *help;
  const gchar *author;
  const gchar *copyright;
  const gchar *date;
  const gchar *proc_type;
  gint32 num_matches = 0;
  gchar **procedure_names = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));
  blurb = g_value_get_string (gimp_value_array_index (args, 1));
  help = g_value_get_string (gimp_value_array_index (args, 2));
  author = g_value_get_string (gimp_value_array_index (args, 3));
  copyright = g_value_get_string (gimp_value_array_index (args, 4));
  date = g_value_get_string (gimp_value_array_index (args, 5));
  proc_type = g_value_get_string (gimp_value_array_index (args, 6));

  if (success)
    {
      success = gimp_pdb_query (gimp->pdb,
                                name, blurb, help, author,
                                copyright, date, proc_type,
                                &num_matches, &procedure_names,
                                error);
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (gimp_value_array_index (return_vals, 1), num_matches);
      gimp_value_take_stringarray (gimp_value_array_index (return_vals, 2), procedure_names, num_matches);
    }

  return return_vals;
}
Beispiel #8
0
static GimpValueArray *
patterns_get_pattern_data_invoker (GimpProcedure         *procedure,
                                   Gimp                  *gimp,
                                   GimpContext           *context,
                                   GimpProgress          *progress,
                                   const GimpValueArray  *args,
                                   GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  gchar *actual_name = NULL;
  gint32 width = 0;
  gint32 height = 0;
  gint32 mask_bpp = 0;
  gint32 length = 0;
  guint8 *mask_data = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      GimpPattern *pattern;

      if (name && strlen (name))
        pattern = gimp_pdb_get_pattern (gimp, name, error);
      else
        pattern = gimp_context_get_pattern (context);

      if (pattern)
        {
          actual_name = g_strdup (gimp_object_get_name (pattern));
          width       = gimp_temp_buf_get_width  (pattern->mask);
          height      = gimp_temp_buf_get_height (pattern->mask);
          mask_bpp    = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
          length      = gimp_temp_buf_get_data_size (pattern->mask);
          mask_data   = g_memdup (gimp_temp_buf_get_data (pattern->mask), length);
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_take_string (gimp_value_array_index (return_vals, 1), actual_name);
      g_value_set_int (gimp_value_array_index (return_vals, 2), width);
      g_value_set_int (gimp_value_array_index (return_vals, 3), height);
      g_value_set_int (gimp_value_array_index (return_vals, 4), mask_bpp);
      g_value_set_int (gimp_value_array_index (return_vals, 5), length);
      gimp_value_take_int8array (gimp_value_array_index (return_vals, 6), mask_data, length);
    }

  return return_vals;
}
Beispiel #9
0
static GimpValueArray *
palette_duplicate_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
                           GimpProgress          *progress,
                           const GimpValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  gchar *copy_name = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);

      if (palette)
        {
          GimpPalette *palette_copy = (GimpPalette *)
            gimp_data_factory_data_duplicate (gimp->palette_factory,
                                              GIMP_DATA (palette));

          if (palette_copy)
            copy_name = g_strdup (gimp_object_get_name (palette_copy));
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (gimp_value_array_index (return_vals, 1), copy_name);

  return return_vals;
}
Beispiel #10
0
static GimpValueArray *
palette_entry_get_name_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  gint32 entry_num;
  gchar *entry_name = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));
  entry_num = g_value_get_int (gimp_value_array_index (args, 1));

  if (success)
    {
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);

      if (palette)
        {
          GimpPaletteEntry *entry = gimp_palette_get_entry (palette, entry_num);

          if (entry)
            entry_name = g_strdup (entry->name);
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (gimp_value_array_index (return_vals, 1), entry_name);

  return return_vals;
}
Beispiel #11
0
static GimpValueArray *
palette_add_entry_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
                           GimpProgress          *progress,
                           const GimpValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  const gchar *entry_name;
  GimpRGB color;
  gint32 entry_num = 0;

  name = g_value_get_string (gimp_value_array_index (args, 0));
  entry_name = g_value_get_string (gimp_value_array_index (args, 1));
  gimp_value_get_rgb (gimp_value_array_index (args, 2), &color);

  if (success)
    {
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);

      if (palette)
        {
          GimpPaletteEntry *entry =
            gimp_palette_add_entry (palette, -1, entry_name, &color);

          entry_num = entry->position;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_int (gimp_value_array_index (return_vals, 1), entry_num);

  return return_vals;
}
static GimpValueArray *
image_add_sample_point_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 position_x;
  gint32 position_y;
  gint32 sample_point = 0;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  position_x = g_value_get_int (gimp_value_array_index (args, 1));
  position_y = g_value_get_int (gimp_value_array_index (args, 2));

  if (success)
    {
      if (position_x <= gimp_image_get_width  (image) &&
          position_y <= gimp_image_get_height (image))
        {
          GimpSamplePoint *sp;

          sp = gimp_image_add_sample_point_at_pos (image, position_x, position_y,
                                                   TRUE);
          sample_point = gimp_sample_point_get_ID (sp);
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_uint (gimp_value_array_index (return_vals, 1), sample_point);

  return return_vals;
}
static GimpValueArray *
image_find_next_sample_point_invoker (GimpProcedure         *procedure,
                                      Gimp                  *gimp,
                                      GimpContext           *context,
                                      GimpProgress          *progress,
                                      const GimpValueArray  *args,
                                      GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 sample_point;
  gint32 next_sample_point = 0;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  sample_point = g_value_get_uint (gimp_value_array_index (args, 1));

  if (success)
    {
      GimpSamplePoint *sp = gimp_image_get_next_sample_point (image, sample_point,
                                                              &success);

      if (sp)
        next_sample_point = gimp_sample_point_get_ID (sp);

      if (! success)
        g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
                     _("Image '%s' (%d) does not contain sample point with ID %d"),
                     gimp_image_get_display_name (image),
                     gimp_image_get_ID (image),
                     sample_point);
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_uint (gimp_value_array_index (return_vals, 1), next_sample_point);

  return return_vals;
}
Beispiel #14
0
static GimpValueArray *
get_parasite_list_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
                           GimpProgress          *progress,
                           const GimpValueArray  *args,
                           GError               **error)
{
  GimpValueArray *return_vals;
  gint32 num_parasites = 0;
  gchar **parasites = NULL;

  parasites = gimp_parasite_list (gimp, &num_parasites);

  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);

  g_value_set_int (gimp_value_array_index (return_vals, 1), num_parasites);
  gimp_value_take_stringarray (gimp_value_array_index (return_vals, 2), parasites, num_parasites);

  return return_vals;
}
static GimpValueArray *
image_get_sample_point_position_invoker (GimpProcedure         *procedure,
                                         Gimp                  *gimp,
                                         GimpContext           *context,
                                         GimpProgress          *progress,
                                         const GimpValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 sample_point;
  gint32 position_x = 0;
  gint32 position_y = 0;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  sample_point = g_value_get_uint (gimp_value_array_index (args, 1));

  if (success)
    {
      GimpSamplePoint *sp = gimp_pdb_image_get_sample_point (image, sample_point,
                                                             error);

      if (sp)
        gimp_sample_point_get_position (sp, &position_x, &position_y);
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (gimp_value_array_index (return_vals, 1), position_x);
      g_value_set_int (gimp_value_array_index (return_vals, 2), position_y);
    }

  return return_vals;
}
Beispiel #16
0
static GimpValueArray *
image_grid_get_spacing_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
                                GimpProgress          *progress,
                                const GimpValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gdouble xspacing = 0.0;
  gdouble yspacing = 0.0;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      GimpGrid *grid = gimp_image_get_grid (image);

      if (grid)
        g_object_get (grid,
                      "xspacing", &xspacing,
                      "yspacing", &yspacing,
                      NULL);
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_double (gimp_value_array_index (return_vals, 1), xspacing);
      g_value_set_double (gimp_value_array_index (return_vals, 2), yspacing);
    }

  return return_vals;
}
Beispiel #17
0
static GimpValueArray *
channel_new_from_component_invoker (GimpProcedure         *procedure,
                                    Gimp                  *gimp,
                                    GimpContext           *context,
                                    GimpProgress          *progress,
                                    const GimpValueArray  *args,
                                    GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 component;
  const gchar *name;
  GimpChannel *channel = NULL;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  component = g_value_get_enum (gimp_value_array_index (args, 1));
  name = g_value_get_string (gimp_value_array_index (args, 2));

  if (success)
    {
      if (gimp_image_get_component_format (image, component) != NULL)
        channel = gimp_channel_new_from_component (image,
                                                   component, name, NULL);

      if (channel)
        gimp_item_set_visible (GIMP_ITEM (channel), FALSE, FALSE);
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    gimp_value_set_channel (gimp_value_array_index (return_vals, 1), channel);

  return return_vals;
}
Beispiel #18
0
static GimpValueArray *
edit_named_paste_as_new_image_invoker (GimpProcedure         *procedure,
                                       Gimp                  *gimp,
                                       GimpContext           *context,
                                       GimpProgress          *progress,
                                       const GimpValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *buffer_name;
  GimpImage *image = NULL;

  buffer_name = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);

      if (buffer)
        {
          image = gimp_edit_paste_as_new_image (gimp, GIMP_OBJECT (buffer));

          if (! image)
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    gimp_value_set_image (gimp_value_array_index (return_vals, 1), image);

  return return_vals;
}
Beispiel #19
0
static GimpValueArray *
palette_rename_invoker (GimpProcedure         *procedure,
                        Gimp                  *gimp,
                        GimpContext           *context,
                        GimpProgress          *progress,
                        const GimpValueArray  *args,
                        GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  const gchar *new_name;
  gchar *actual_name = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));
  new_name = g_value_get_string (gimp_value_array_index (args, 1));

  if (success)
    {
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);

      if (palette)
        {
          gimp_object_set_name (GIMP_OBJECT (palette), new_name);
          actual_name = g_strdup (gimp_object_get_name (palette));
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (gimp_value_array_index (return_vals, 1), actual_name);

  return return_vals;
}
static GimpValueArray *
image_add_vguide_invoker (GimpProcedure         *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
                          GimpProgress          *progress,
                          const GimpValueArray  *args,
                          GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gint32 xposition;
  gint32 guide = 0;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  xposition = g_value_get_int (gimp_value_array_index (args, 1));

  if (success)
    {
      if (xposition <= gimp_image_get_width (image))
        {
          GimpGuide *g;

          g = gimp_image_add_vguide (image, xposition, TRUE);
          guide = gimp_guide_get_ID (g);
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_uint (gimp_value_array_index (return_vals, 1), guide);

  return return_vals;
}
Beispiel #21
0
static GimpValueArray *
edit_copy_visible_invoker (GimpProcedure         *procedure,
                           Gimp                  *gimp,
                           GimpContext           *context,
                           GimpProgress          *progress,
                           const GimpValueArray  *args,
                           GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  GimpImage *image;
  gboolean non_empty = FALSE;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);

  if (success)
    {
      GError *my_error = NULL;

      non_empty = gimp_edit_copy_visible (image, context, &my_error) != NULL;

      if (! non_empty)
        {
          gimp_message_literal (gimp,
                                G_OBJECT (progress), GIMP_MESSAGE_WARNING,
                                my_error->message);
          g_clear_error (&my_error);
        }
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_boolean (gimp_value_array_index (return_vals, 1), non_empty);

  return return_vals;
}
Beispiel #22
0
static gint
plug_in_collect_item_args (GtkAction       *action,
                           GimpImage       *image,
                           GimpItem        *item,
                           GParamSpec     **pspecs,
                           GimpValueArray  *args,
                           gint             n_args)
{
  if (gimp_value_array_length (args) > n_args &&
      GIMP_IS_PARAM_SPEC_IMAGE_ID (pspecs[n_args]))
    {
      if (image)
        {
          gimp_value_set_image (gimp_value_array_index (args, n_args), image);
          n_args++;

          if (gimp_value_array_length (args) > n_args &&
              GIMP_IS_PARAM_SPEC_ITEM_ID (pspecs[n_args]))
            {
              if (item &&
                  g_type_is_a (G_TYPE_FROM_INSTANCE (item),
                               GIMP_PARAM_SPEC_ITEM_ID (pspecs[n_args])->item_type))
                {
                  gimp_value_set_item (gimp_value_array_index (args, n_args),
                                       item);
                  n_args++;
                }
              else
                {
                  g_warning ("Uh-oh, no active item for the plug-in!");
                  return -1;
                }
            }
        }
    }

  return n_args;
}
Beispiel #23
0
static GimpValueArray *
image_select_polygon_invoker (GimpProcedure         *procedure,
                              Gimp                  *gimp,
                              GimpContext           *context,
                              GimpProgress          *progress,
                              const GimpValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 operation;
  gint32 num_segs;
  const gdouble *segs;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  operation = g_value_get_enum (gimp_value_array_index (args, 1));
  num_segs = g_value_get_int (gimp_value_array_index (args, 2));
  segs = gimp_value_get_floatarray (gimp_value_array_index (args, 3));

  if (success)
    {
      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);

      gimp_channel_select_polygon (gimp_image_get_mask (image),
                                   _("Free Select"),
                                   num_segs / 2,
                                   (GimpVector2 *) segs,
                                   operation,
                                   pdb_context->antialias,
                                   pdb_context->feather,
                                   pdb_context->feather_radius_x,
                                   pdb_context->feather_radius_y,
                                   TRUE);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #24
0
static GimpValueArray *
file_save_thumbnail_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  const gchar *filename;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  filename = g_value_get_string (gimp_value_array_index (args, 1));

  if (success)
    {
      success = file_utils_save_thumbnail (image, filename);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #25
0
static GimpValueArray *
image_flip_invoker (GimpProcedure         *procedure,
                    Gimp                  *gimp,
                    GimpContext           *context,
                    GimpProgress          *progress,
                    const GimpValueArray  *args,
                    GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 flip_type;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  flip_type = g_value_get_enum (gimp_value_array_index (args, 1));

  if (success)
    {
      gimp_image_flip (image, context, flip_type, NULL);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #26
0
static GimpValueArray *
channel_set_opacity_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
                             GimpProgress          *progress,
                             const GimpValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  GimpChannel *channel;
  gdouble opacity;

  channel = gimp_value_get_channel (gimp_value_array_index (args, 0), gimp);
  opacity = g_value_get_double (gimp_value_array_index (args, 1));

  if (success)
    {
      gimp_channel_set_opacity (channel, opacity / 100.0, TRUE);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #27
0
static GimpValueArray *
channel_set_show_masked_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
                                 GimpProgress          *progress,
                                 const GimpValueArray  *args,
                                 GError               **error)
{
  gboolean success = TRUE;
  GimpChannel *channel;
  gboolean show_masked;

  channel = gimp_value_get_channel (gimp_value_array_index (args, 0), gimp);
  show_masked = g_value_get_boolean (gimp_value_array_index (args, 1));

  if (success)
    {
      gimp_channel_set_show_masked (channel, show_masked);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #28
0
static GimpValueArray *
image_convert_set_dither_matrix_invoker (GimpProcedure         *procedure,
                                         Gimp                  *gimp,
                                         GimpContext           *context,
                                         GimpProgress          *progress,
                                         const GimpValueArray  *args,
                                         GError               **error)
{
  gboolean success = TRUE;
  gint32 width;
  gint32 height;
  gint32 matrix_length;
  const guint8 *matrix;

  width = g_value_get_int (gimp_value_array_index (args, 0));
  height = g_value_get_int (gimp_value_array_index (args, 1));
  matrix_length = g_value_get_int (gimp_value_array_index (args, 2));
  matrix = gimp_value_get_int8array (gimp_value_array_index (args, 3));

  if (success)
    {
      if (width == 0 || height == 0 || matrix_length == width * height)
        {
          gimp_image_convert_type_set_dither_matrix (matrix, width, height);
        }
      else
        {
          g_set_error_literal (error, GIMP_PDB_ERROR,
                               GIMP_PDB_ERROR_INVALID_ARGUMENT,
                               "Dither matrix length must be width * height");
          success = FALSE;
        }
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #29
0
static GimpValueArray *
image_select_round_rectangle_invoker (GimpProcedure         *procedure,
                                      Gimp                  *gimp,
                                      GimpContext           *context,
                                      GimpProgress          *progress,
                                      const GimpValueArray  *args,
                                      GError               **error)
{
  gboolean success = TRUE;
  GimpImage *image;
  gint32 operation;
  gdouble x;
  gdouble y;
  gdouble width;
  gdouble height;
  gdouble corner_radius_x;
  gdouble corner_radius_y;

  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
  operation = g_value_get_enum (gimp_value_array_index (args, 1));
  x = g_value_get_double (gimp_value_array_index (args, 2));
  y = g_value_get_double (gimp_value_array_index (args, 3));
  width = g_value_get_double (gimp_value_array_index (args, 4));
  height = g_value_get_double (gimp_value_array_index (args, 5));
  corner_radius_x = g_value_get_double (gimp_value_array_index (args, 6));
  corner_radius_y = g_value_get_double (gimp_value_array_index (args, 7));

  if (success)
    {
      GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);

      gimp_channel_select_round_rect (gimp_image_get_mask (image),
                                      (gint) x, (gint) y,
                                      (gint) width, (gint) height,
                                      corner_radius_x,
                                      corner_radius_y,
                                      operation,
                                      pdb_context->antialias,
                                      pdb_context->feather,
                                      pdb_context->feather_radius_x,
                                      pdb_context->feather_radius_y,
                                      TRUE);
    }

  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}
Beispiel #30
0
static GimpValueArray *
patterns_get_pattern_invoker (GimpProcedure         *procedure,
                              Gimp                  *gimp,
                              GimpContext           *context,
                              GimpProgress          *progress,
                              const GimpValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  gchar *name = NULL;
  gint32 width = 0;
  gint32 height = 0;

  GimpPattern *pattern = gimp_context_get_pattern (context);

  if (pattern)
    {
      name   = g_strdup (gimp_object_get_name (pattern));
      width  = gimp_temp_buf_get_width  (pattern->mask);
      height = gimp_temp_buf_get_height (pattern->mask);
    }
  else
    success = FALSE;

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_take_string (gimp_value_array_index (return_vals, 1), name);
      g_value_set_int (gimp_value_array_index (return_vals, 2), width);
      g_value_set_int (gimp_value_array_index (return_vals, 3), height);
    }

  return return_vals;
}