home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpgradientselect_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  4.9 KB  |  170 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpgradientselect_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_gradients_popup:
  28.  * @gradients_callback: The callback PDB proc to call when gradient selection is made.
  29.  * @popup_title: Title to give the gradient popup window.
  30.  * @initial_gradient: The name of the pattern to set as the first selected.
  31.  * @sample_size: Size of the sample to return when the gradient is changed.
  32.  *
  33.  * Invokes the Gimp gradients selection.
  34.  *
  35.  * This procedure popups the gradients selection dialog.
  36.  *
  37.  * Returns: TRUE on success.
  38.  */
  39. gboolean
  40. gimp_gradients_popup (gchar *gradients_callback,
  41.               gchar *popup_title,
  42.               gchar *initial_gradient,
  43.               gint   sample_size)
  44. {
  45.   GimpParam *return_vals;
  46.   gint nreturn_vals;
  47.   gboolean success = TRUE;
  48.  
  49.   return_vals = gimp_run_procedure ("gimp_gradients_popup",
  50.                     &nreturn_vals,
  51.                     GIMP_PDB_STRING, gradients_callback,
  52.                     GIMP_PDB_STRING, popup_title,
  53.                     GIMP_PDB_STRING, initial_gradient,
  54.                     GIMP_PDB_INT32, sample_size,
  55.                     GIMP_PDB_END);
  56.  
  57.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  58.  
  59.   gimp_destroy_params (return_vals, nreturn_vals);
  60.  
  61.   return success;
  62. }
  63.  
  64. /**
  65.  * gimp_gradients_close_popup:
  66.  * @gradients_callback: The name of the callback registered for this popup.
  67.  *
  68.  * Popdown the Gimp gradient selection.
  69.  *
  70.  * This procedure closes an opened gradient selection dialog.
  71.  *
  72.  * Returns: TRUE on success.
  73.  */
  74. gboolean
  75. gimp_gradients_close_popup (gchar *gradients_callback)
  76. {
  77.   GimpParam *return_vals;
  78.   gint nreturn_vals;
  79.   gboolean success = TRUE;
  80.  
  81.   return_vals = gimp_run_procedure ("gimp_gradients_close_popup",
  82.                     &nreturn_vals,
  83.                     GIMP_PDB_STRING, gradients_callback,
  84.                     GIMP_PDB_END);
  85.  
  86.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  87.  
  88.   gimp_destroy_params (return_vals, nreturn_vals);
  89.  
  90.   return success;
  91. }
  92.  
  93. /**
  94.  * gimp_gradients_set_popup:
  95.  * @gradients_callback: The name of the callback registered for this popup.
  96.  * @gradient_name: The name of the gradient to set as selected.
  97.  *
  98.  * Sets the current gradient selection in a popup.
  99.  *
  100.  * Sets the current gradient selection in a popup.
  101.  *
  102.  * Returns: TRUE on success.
  103.  */
  104. gboolean
  105. gimp_gradients_set_popup (gchar *gradients_callback,
  106.               gchar *gradient_name)
  107. {
  108.   GimpParam *return_vals;
  109.   gint nreturn_vals;
  110.   gboolean success = TRUE;
  111.  
  112.   return_vals = gimp_run_procedure ("gimp_gradients_set_popup",
  113.                     &nreturn_vals,
  114.                     GIMP_PDB_STRING, gradients_callback,
  115.                     GIMP_PDB_STRING, gradient_name,
  116.                     GIMP_PDB_END);
  117.  
  118.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  119.  
  120.   gimp_destroy_params (return_vals, nreturn_vals);
  121.  
  122.   return success;
  123. }
  124.  
  125. /**
  126.  * _gimp_gradients_get_gradient_data:
  127.  * @name: The gradient name (\"\" means current active gradient).
  128.  * @sample_size: Size of the sample to return when the gradient is changed.
  129.  * @width: The gradient sample width (r,g,b,a).
  130.  * @grad_data: The gradient sample data.
  131.  *
  132.  * Retrieve information about the specified gradient (including data).
  133.  *
  134.  * This procedure retrieves information about the gradient. This
  135.  * includes the gradient name, and the sample data for the gradient.
  136.  *
  137.  * Returns: The gradient name.
  138.  */
  139. gchar *
  140. _gimp_gradients_get_gradient_data (gchar    *name,
  141.                    gint      sample_size,
  142.                    gint     *width,
  143.                    gdouble **grad_data)
  144. {
  145.   GimpParam *return_vals;
  146.   gint nreturn_vals;
  147.   gchar *ret_name = NULL;
  148.  
  149.   return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data",
  150.                     &nreturn_vals,
  151.                     GIMP_PDB_STRING, name,
  152.                     GIMP_PDB_INT32, sample_size,
  153.                     GIMP_PDB_END);
  154.  
  155.   *width = 0;
  156.  
  157.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  158.     {
  159.       ret_name = g_strdup (return_vals[1].data.d_string);
  160.       *width = return_vals[2].data.d_int32;
  161.       *grad_data = g_new (gdouble, *width);
  162.       memcpy (*grad_data, return_vals[3].data.d_floatarray,
  163.           *width * sizeof (gdouble));
  164.     }
  165.  
  166.   gimp_destroy_params (return_vals, nreturn_vals);
  167.  
  168.   return ret_name;
  169. }
  170.