home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / plug_in.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  6.6 KB  |  195 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #ifndef __PLUG_IN_H__
  20. #define __PLUG_IN_H__
  21.  
  22.  
  23. #include "procedural_db.h"
  24. #include "gimpprogress.h"
  25. #include "drawable.h"
  26.  
  27.  
  28. #define WRITE_BUFFER_SIZE  512
  29.  
  30. #define PLUG_IN_RGB_IMAGE       0x01
  31. #define PLUG_IN_GRAY_IMAGE      0x02
  32. #define PLUG_IN_INDEXED_IMAGE   0x04
  33. #define PLUG_IN_RGBA_IMAGE      0x08
  34. #define PLUG_IN_GRAYA_IMAGE     0x10
  35. #define PLUG_IN_INDEXEDA_IMAGE  0x20
  36.  
  37.  
  38. typedef enum
  39. {
  40.   RUN_INTERACTIVE    = 0,
  41.   RUN_NONINTERACTIVE = 1,
  42.   RUN_WITH_LAST_VALS = 2
  43. } RunModeType;
  44.  
  45.  
  46. struct _PlugIn
  47. {
  48.   guint         open : 1;         /* Is the plug-in open* */
  49.   guint         destroy : 1;      /* Should the plug-in by destroyed* */
  50.   guint         query : 1;        /* Are we querying the plug-in? */
  51.   guint         synchronous : 1;  /* Is the plug-in running synchronously? */
  52.   guint         recurse : 1;      /* Have we called 'gtk_main' recursively? */
  53.   guint         busy : 1;         /* Is the plug-in busy with a temp proc? */
  54.   pid_t         pid;              /* Plug-ins process id */
  55.   gchar        *args[7];          /* Plug-ins command line arguments */
  56.  
  57.   GIOChannel   *my_read;          /* App's read and write channels */
  58.   GIOChannel   *my_write;
  59.   GIOChannel   *his_read;         /* Plug-in's read and write channels */
  60.   GIOChannel   *his_write;
  61. #ifdef G_OS_WIN32
  62.   guint         his_thread_id;    /* Plug-in's thread ID */
  63.   gint          his_read_fd;      /* Plug-in's read pipe fd */
  64. #endif
  65.  
  66.   guint32       input_id;         /* Id of input proc */
  67.  
  68.   gchar         write_buffer[WRITE_BUFFER_SIZE]; /* Buffer for writing */
  69.   gint          write_buffer_index;              /* Buffer index for writing */
  70.  
  71.   GSList       *temp_proc_defs;   /* Temporary procedures  */
  72.  
  73.   gimp_progress *progress;        /* Progress dialog */
  74.  
  75.   gpointer      user_data;        /* Handle for hanging data onto */
  76. };
  77.  
  78. struct _PlugInDef
  79. {
  80.   gchar    *prog;
  81.   GSList   *proc_defs;
  82.   gchar    *locale_domain;
  83.   gchar    *locale_path;
  84.   gchar    *help_path;
  85.   time_t    mtime;
  86.   gboolean  query;
  87. };
  88.  
  89. struct _PlugInProcDef
  90. {
  91.   gchar      *prog;
  92.   gchar      *menu_path;
  93.   gchar      *accelerator;
  94.   gchar      *extensions;
  95.   gchar      *prefixes;
  96.   gchar      *magics;
  97.   gchar      *image_types;
  98.   gint        image_types_val;
  99.   ProcRecord  db_info;
  100.   GSList     *extensions_list;
  101.   GSList     *prefixes_list;
  102.   GSList     *magics_list;
  103.   time_t      mtime;
  104. };
  105.  
  106.  
  107. /* Initialize the plug-ins */
  108. void            plug_in_init                 (void);
  109.  
  110. /* Kill all running plug-ins */
  111. void            plug_in_kill                 (void);
  112.  
  113. /*  Add a plug-in to the list of valid plug-ins and query the plug-in
  114.  *  for information if necessary.
  115.  */
  116. void            plug_in_add                  (gchar         *name,
  117.                           gchar         *menu_path,
  118.                           gchar         *accelerator);
  119.  
  120. /* Get the "image_types" the plug-in works on. */
  121. gchar         * plug_in_image_types          (gchar         *name);
  122.  
  123. /* Add in the file load/save handler fields procedure. */
  124. PlugInProcDef * plug_in_file_handler         (gchar         *name,
  125.                           gchar         *extensions,
  126.                           gchar         *prefixes,
  127.                           gchar         *magics);
  128.  
  129. /* Add a plug-in definition. */
  130. void            plug_in_def_add              (PlugInDef     *plug_in_def);
  131.  
  132. /* Allocate and free a plug-in definition. */
  133. PlugInDef     * plug_in_def_new              (gchar         *prog);
  134. void            plug_in_def_free             (PlugInDef     *plug_in_def, 
  135.                           gboolean       free_proc_defs);
  136.  
  137. /* Retrieve a plug-ins menu path */
  138. gchar         * plug_in_menu_path            (gchar         *name);
  139.  
  140. /* Retrieve a plug-ins help path */
  141. gchar         * plug_in_help_path            (gchar         *prog_name);
  142.  
  143. /* Create a new plug-in structure */
  144. PlugIn        * plug_in_new                  (gchar         *name);
  145.  
  146. /*  Destroy a plug-in structure.
  147.  *  This will close the plug-in first if necessary.
  148.  */
  149. void            plug_in_destroy              (PlugIn        *plug_in);
  150.  
  151. /* Open a plug-in. This cause the plug-in to run.
  152.  * If returns TRUE, you must destroy the plugin.
  153.  * If returns FALSE, you must not destroy the plugin.
  154.  */
  155. gboolean        plug_in_open                 (PlugIn        *plug_in);
  156.  
  157. /* Close a plug-in. This kills the plug-in and releases its resources. */
  158. void            plug_in_close                (PlugIn        *plug_in,
  159.                           gboolean       kill_it);
  160.  
  161. /* Run a plug-in as if it were a procedure database procedure */
  162. Argument      * plug_in_run                  (ProcRecord    *proc_rec,
  163.                           Argument      *args,
  164.                           gint           argc,
  165.                           gboolean       synchronous,
  166.                           gboolean       destroy_values,
  167.                           gint           gdisp_ID);
  168.  
  169. /*  Run the last plug-in again with the same arguments. Extensions
  170.  *  are exempt from this "privelege".
  171.  */
  172. void            plug_in_repeat               (gboolean       with_interface);
  173.  
  174. /* Set the sensitivity for plug-in menu items based on the image type. */
  175. void            plug_in_set_menu_sensitivity (GimpImageType  type);
  176.  
  177. /* Register an internal plug-in.  This is for file load-save
  178.  * handlers, which are organized around the plug-in data structure.
  179.  * This could all be done a little better, but oh well.  -josh
  180.  */
  181. void            plug_in_add_internal         (PlugInProcDef *proc_def);
  182. GSList        * plug_in_extensions_parse     (gchar         *extensions);
  183. gint            plug_in_image_types_parse    (gchar         *image_types);
  184.  
  185. void            plug_in_progress_init        (PlugIn        *plug_in,
  186.                           gchar         *message,
  187.                           gint           gdisp_ID);
  188. void            plug_in_progress_update      (PlugIn        *plug_in,
  189.                           gdouble        percentage);
  190.  
  191. extern PlugIn *current_plug_in;
  192. extern GSList *proc_defs;
  193.  
  194. #endif /* __PLUG_IN_H__ */
  195.