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

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpfileops_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_file_load:
  28.  * @run_mode: The run mode.
  29.  * @filename: The name of the file to load.
  30.  * @raw_filename: The name entered.
  31.  *
  32.  * Loads a file by extension.
  33.  *
  34.  * This procedure invokes the correct file load handler according to
  35.  * the file's extension and/or prefix. The name of the file to load is
  36.  * typically a full pathname, and the name entered is what the user
  37.  * actually typed before prepending a directory path. The reason for
  38.  * this is that if the user types http://www.xcf/~gimp/ he wants to
  39.  * fetch a URL, and the full pathname will not look like a URL.
  40.  *
  41.  * Returns: The output image.
  42.  */
  43. gint32
  44. gimp_file_load (GimpRunModeType  run_mode,
  45.         gchar           *filename,
  46.         gchar           *raw_filename)
  47. {
  48.   GimpParam *return_vals;
  49.   gint nreturn_vals;
  50.   gint32 image_ID = -1;
  51.  
  52.   return_vals = gimp_run_procedure ("gimp_file_load",
  53.                     &nreturn_vals,
  54.                     GIMP_PDB_INT32, run_mode,
  55.                     GIMP_PDB_STRING, filename,
  56.                     GIMP_PDB_STRING, raw_filename,
  57.                     GIMP_PDB_END);
  58.  
  59.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  60.     image_ID = return_vals[1].data.d_image;
  61.  
  62.   gimp_destroy_params (return_vals, nreturn_vals);
  63.  
  64.   return image_ID;
  65. }
  66.  
  67. /**
  68.  * gimp_file_save:
  69.  * @run_mode: The run mode.
  70.  * @image_ID: Input image.
  71.  * @drawable_ID: Drawable to save.
  72.  * @filename: The name of the file to save the image in.
  73.  * @raw_filename: The name of the file to save the image in.
  74.  *
  75.  * Saves a file by extension.
  76.  *
  77.  * This procedure invokes the correct file save handler according to
  78.  * the file's extension and/or prefix. The name of the file to save is
  79.  * typically a full pathname, and the name entered is what the user
  80.  * actually typed before prepending a directory path. The reason for
  81.  * this is that if the user types http://www.xcf/~gimp/ she wants to
  82.  * fetch a URL, and the full pathname will not look like a URL.
  83.  *
  84.  * Returns: TRUE on success.
  85.  */
  86. gboolean
  87. gimp_file_save (GimpRunModeType  run_mode,
  88.         gint32           image_ID,
  89.         gint32           drawable_ID,
  90.         gchar           *filename,
  91.         gchar           *raw_filename)
  92. {
  93.   GimpParam *return_vals;
  94.   gint nreturn_vals;
  95.   gboolean success = TRUE;
  96.  
  97.   return_vals = gimp_run_procedure ("gimp_file_save",
  98.                     &nreturn_vals,
  99.                     GIMP_PDB_INT32, run_mode,
  100.                     GIMP_PDB_IMAGE, image_ID,
  101.                     GIMP_PDB_DRAWABLE, drawable_ID,
  102.                     GIMP_PDB_STRING, filename,
  103.                     GIMP_PDB_STRING, raw_filename,
  104.                     GIMP_PDB_END);
  105.  
  106.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  107.  
  108.   gimp_destroy_params (return_vals, nreturn_vals);
  109.  
  110.   return success;
  111. }
  112.  
  113. /**
  114.  * gimp_temp_name:
  115.  * @extension: The extension the file will have.
  116.  *
  117.  * Generates a unique filename.
  118.  *
  119.  * Generates a unique filename using the temp path supplied in the
  120.  * user's gimprc.
  121.  *
  122.  * Returns: The new temp filename.
  123.  */
  124. gchar *
  125. gimp_temp_name (gchar *extension)
  126. {
  127.   GimpParam *return_vals;
  128.   gint nreturn_vals;
  129.   gchar *name = NULL;
  130.  
  131.   return_vals = gimp_run_procedure ("gimp_temp_name",
  132.                     &nreturn_vals,
  133.                     GIMP_PDB_STRING, extension,
  134.                     GIMP_PDB_END);
  135.  
  136.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  137.     name = g_strdup (return_vals[1].data.d_string);
  138.  
  139.   gimp_destroy_params (return_vals, nreturn_vals);
  140.  
  141.   return name;
  142. }
  143.  
  144. /**
  145.  * gimp_register_magic_load_handler:
  146.  * @procedure_name: The name of the procedure to be used for loading.
  147.  * @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
  148.  * @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
  149.  * @magics: comma separated list of magic file information this handler can load (i.e. \"0,string,GIF\").
  150.  *
  151.  * Registers a file load handler procedure.
  152.  *
  153.  * Registers a procedural database procedure to be called to load files
  154.  * of a particular file format using magic file information.
  155.  *
  156.  * Returns: TRUE on success.
  157.  */
  158. gboolean
  159. gimp_register_magic_load_handler (gchar *procedure_name,
  160.                   gchar *extensions,
  161.                   gchar *prefixes,
  162.                   gchar *magics)
  163. {
  164.   GimpParam *return_vals;
  165.   gint nreturn_vals;
  166.   gboolean success = TRUE;
  167.  
  168.   return_vals = gimp_run_procedure ("gimp_register_magic_load_handler",
  169.                     &nreturn_vals,
  170.                     GIMP_PDB_STRING, procedure_name,
  171.                     GIMP_PDB_STRING, extensions,
  172.                     GIMP_PDB_STRING, prefixes,
  173.                     GIMP_PDB_STRING, magics,
  174.                     GIMP_PDB_END);
  175.  
  176.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  177.  
  178.   gimp_destroy_params (return_vals, nreturn_vals);
  179.  
  180.   return success;
  181. }
  182.  
  183. /**
  184.  * gimp_register_load_handler:
  185.  * @procedure_name: The name of the procedure to be used for loading.
  186.  * @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
  187.  * @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
  188.  *
  189.  * Registers a file load handler procedure.
  190.  *
  191.  * Registers a procedural database procedure to be called to load files
  192.  * of a particular file format.
  193.  *
  194.  * Returns: TRUE on success.
  195.  */
  196. gboolean
  197. gimp_register_load_handler (gchar *procedure_name,
  198.                 gchar *extensions,
  199.                 gchar *prefixes)
  200. {
  201.   GimpParam *return_vals;
  202.   gint nreturn_vals;
  203.   gboolean success = TRUE;
  204.  
  205.   return_vals = gimp_run_procedure ("gimp_register_load_handler",
  206.                     &nreturn_vals,
  207.                     GIMP_PDB_STRING, procedure_name,
  208.                     GIMP_PDB_STRING, extensions,
  209.                     GIMP_PDB_STRING, prefixes,
  210.                     GIMP_PDB_END);
  211.  
  212.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  213.  
  214.   gimp_destroy_params (return_vals, nreturn_vals);
  215.  
  216.   return success;
  217. }
  218.  
  219. /**
  220.  * gimp_register_save_handler:
  221.  * @procedure_name: The name of the procedure to be used for saving.
  222.  * @extensions: comma separated list of extensions this handler can save (i.e. \"jpg,jpeg\").
  223.  * @prefixes: comma separated list of prefixes this handler can save (i.e. \"http:,ftp:\").
  224.  *
  225.  * Registers a file save handler procedure.
  226.  *
  227.  * Registers a procedural database procedure to be called to save files
  228.  * in a particular file format.
  229.  *
  230.  * Returns: TRUE on success.
  231.  */
  232. gboolean
  233. gimp_register_save_handler (gchar *procedure_name,
  234.                 gchar *extensions,
  235.                 gchar *prefixes)
  236. {
  237.   GimpParam *return_vals;
  238.   gint nreturn_vals;
  239.   gboolean success = TRUE;
  240.  
  241.   return_vals = gimp_run_procedure ("gimp_register_save_handler",
  242.                     &nreturn_vals,
  243.                     GIMP_PDB_STRING, procedure_name,
  244.                     GIMP_PDB_STRING, extensions,
  245.                     GIMP_PDB_STRING, prefixes,
  246.                     GIMP_PDB_END);
  247.  
  248.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  249.  
  250.   gimp_destroy_params (return_vals, nreturn_vals);
  251.  
  252.   return success;
  253. }
  254.