gimp.h 10.9 KB
Newer Older
1 2
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
Manish Singh's avatar
Manish Singh committed
3
 *
4 5
 * gimp.h
 *
Manish Singh's avatar
Manish Singh committed
6
 * This library is free software; you can redistribute it and/or
Marc Lehmann's avatar
Marc Lehmann committed
7
 * modify it under the terms of the GNU Lesser General Public
Manish Singh's avatar
Manish Singh committed
8
 * License as published by the Free Software Foundation; either
9 10 11 12 13
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
Manish Singh's avatar
Manish Singh committed
15
 *
Marc Lehmann's avatar
Marc Lehmann committed
16
 * You should have received a copy of the GNU Lesser General Public
17 18 19
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
20 21
 */

Elliot Lee's avatar
Elliot Lee committed
22 23 24
#ifndef __GIMP_H__
#define __GIMP_H__

25
#include <glib-object.h>
26

27
#include <libgimpcolor/gimpcolor.h>
28
#include <libgimpmath/gimpmath.h>
29
#include <libgimpbase/gimpbase.h>
30

31
#include <libgimp/gimpenums.h>
32 33
#include <libgimp/gimptypes.h>

34
#include <libgimp/gimpbrushes.h>
35
#include <libgimp/gimpbrushselect.h>
36
#include <libgimp/gimpchannel.h>
37
#include <libgimp/gimpdrawable.h>
38
#include <libgimp/gimpfontselect.h>
39
#include <libgimp/gimpgradients.h>
40
#include <libgimp/gimpgradientselect.h>
41
#include <libgimp/gimpimage.h>
42
#include <libgimp/gimplayer.h>
43
#include <libgimp/gimppalette.h>
44
#include <libgimp/gimppalettes.h>
45
#include <libgimp/gimppaletteselect.h>
46
#include <libgimp/gimppatterns.h>
47
#include <libgimp/gimppatternselect.h>
48
#include <libgimp/gimppixelfetcher.h>
49
#include <libgimp/gimppixelrgn.h>
50
#include <libgimp/gimpplugin.h>
51
#include <libgimp/gimpproceduraldb.h>
52
#include <libgimp/gimpprogress.h>
53
#include <libgimp/gimpregioniterator.h>
54
#include <libgimp/gimpselection.h>
55
#include <libgimp/gimptile.h>
56

57
#include <libgimp/gimp_pdb.h>
58

59
#ifdef G_OS_WIN32
60
#  include <stdlib.h>		/* For __argc and __argv */
61 62 63 64 65
#  ifdef LIBGIMP_COMPILATION
#    define GIMPVAR __declspec(dllexport)
#  else  /* !LIBGIMP_COMPILATION */
#    define GIMPVAR extern __declspec(dllimport)
#  endif /* !LIBGIMP_COMPILATION */
66
#else  /* !G_OS_WIN32 */
67 68
#  define GIMPVAR extern
#endif
Elliot Lee's avatar
Elliot Lee committed
69

70
G_BEGIN_DECLS
Elliot Lee's avatar
Elliot Lee committed
71

72

73 74 75
#define gimp_get_data         gimp_procedural_db_get_data
#define gimp_get_data_size    gimp_procedural_db_get_data_size
#define gimp_set_data         gimp_procedural_db_set_data
76

Elliot Lee's avatar
Elliot Lee committed
77

78 79 80
GIMPVAR const guint gimp_major_version;
GIMPVAR const guint gimp_minor_version;
GIMPVAR const guint gimp_micro_version;
81

Manish Singh's avatar
Manish Singh committed
82

83 84 85
typedef void (* GimpInitProc)  (void);
typedef void (* GimpQuitProc)  (void);
typedef void (* GimpQueryProc) (void);
86 87 88 89 90
typedef void (* GimpRunProc)   (const gchar      *name,
				gint              n_params,
				const GimpParam  *param,
				gint             *n_return_vals,
				GimpParam       **return_vals);
91 92 93


struct _GimpPlugInInfo
Elliot Lee's avatar
Elliot Lee committed
94 95
{
  /* called when the gimp application initially starts up */
96
  GimpInitProc  init_proc;
Elliot Lee's avatar
Elliot Lee committed
97 98

  /* called when the gimp application exits */
99
  GimpQuitProc  quit_proc;
Elliot Lee's avatar
Elliot Lee committed
100 101 102 103 104

  /* called by the gimp so that the plug-in can inform the
   *  gimp of what it does. (ie. installing a procedure database
   *  procedure).
   */
105
  GimpQueryProc query_proc;
Elliot Lee's avatar
Elliot Lee committed
106 107 108 109

  /* called to run a procedure the plug-in installed in the
   *  procedure database.
   */
110
  GimpRunProc   run_proc;
Elliot Lee's avatar
Elliot Lee committed
111 112
};

113
struct _GimpParamDef
Elliot Lee's avatar
Elliot Lee committed
114
{
115 116 117
  GimpPDBArgType  type;
  gchar          *name;
  gchar          *description;
Elliot Lee's avatar
Elliot Lee committed
118 119
};

120
struct _GimpParamRegion
121 122 123 124 125 126 127
{
  gint32 x;
  gint32 y;
  gint32 width;
  gint32 height;
};

128
union _GimpParamData
129
{
130 131 132 133 134 135 136 137 138 139
  gint32            d_int32;
  gint16            d_int16;
  gint8             d_int8;
  gdouble           d_float;
  gchar            *d_string;
  gint32           *d_int32array;
  gint16           *d_int16array;
  gint8            *d_int8array;
  gdouble          *d_floatarray;
  gchar           **d_stringarray;
140
  GimpRGB           d_color;
141 142 143 144
  GimpParamRegion   d_region;
  gint32            d_display;
  gint32            d_image;
  gint32            d_layer;
145
  gint32            d_layer_mask;
146 147 148 149 150
  gint32            d_channel;
  gint32            d_drawable;
  gint32            d_selection;
  gint32            d_boundary;
  gint32            d_path;
151
  gint32            d_unit;
152
  GimpParasite      d_parasite;
153
  gint32            d_tattoo;
154
  GimpPDBStatusType d_status;
155 156
};

157
struct _GimpParam
Elliot Lee's avatar
Elliot Lee committed
158
{
159 160
  GimpPDBArgType type;
  GimpParamData  data;
Elliot Lee's avatar
Elliot Lee committed
161 162 163
};


164

165 166 167 168 169 170 171
/**
 * MAIN():
 *
 * A macro that expands to the appropriate main() function for the
 * platform being compiled for.
 *
 * To use this macro, simply place a line that contains just the code
172
 * MAIN() at the toplevel of your file.  No semicolon should be used.
173 174 175
 *
 */

176
#ifdef G_OS_WIN32
177

Tor Lillqvist's avatar
Tor Lillqvist committed
178
/* Define WinMain() because plug-ins are built as GUI applications. Also
179 180 181
 * define a main() in case some plug-in still is built as a console
 * application.
 */
182
#  ifdef __GNUC__
183 184 185
#    ifndef _stdcall
#      define _stdcall __attribute__((stdcall))
#    endif
186 187
#  endif

188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
#  define MAIN()					\
   struct HINSTANCE__;					\
   int _stdcall						\
   WinMain (struct HINSTANCE__ *hInstance, 		\
	    struct HINSTANCE__ *hPrevInstance,		\
	    char *lpszCmdLine,				\
	    int   nCmdShow)				\
   {							\
     return gimp_main (&PLUG_IN_INFO, __argc, __argv);	\
   }							\
							\
   int							\
   main (int argc, char *argv[])			\
   {							\
     return gimp_main (&PLUG_IN_INFO, argc, argv);	\
203
   }
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
204
#else
205 206 207 208 209
#  define MAIN()					\
   int							\
   main (int argc, char *argv[])			\
   {							\
     return gimp_main (&PLUG_IN_INFO, argc, argv);	\
Asbjørn Pettersen's avatar
Asbjørn Pettersen committed
210 211
   }
#endif
Elliot Lee's avatar
Elliot Lee committed
212 213


214
/* The main procedure that must be called with the PLUG_IN_INFO structure
215
 * and the 'argc' and 'argv' that are passed to "main".
Elliot Lee's avatar
Elliot Lee committed
216
 */
217 218 219
gint          gimp_main                (const GimpPlugInInfo *info,
                                        gint                  argc,
                                        gchar                *argv[]);
Elliot Lee's avatar
Elliot Lee committed
220 221 222 223

/* Forcefully causes the gimp library to exit and
 *  close down its connection to main gimp application.
 */
224
void          gimp_quit                (void) G_GNUC_NORETURN;
Marc Lehmann's avatar
Marc Lehmann committed
225

Elliot Lee's avatar
Elliot Lee committed
226 227 228

/* Install a procedure in the procedure database.
 */
229 230 231 232 233 234
void          gimp_install_procedure   (const gchar        *name,
                                        const gchar        *blurb,
                                        const gchar        *help,
                                        const gchar        *author,
                                        const gchar        *copyright,
                                        const gchar        *date,
235
                                        const gchar        *menu_label,
236 237 238 239 240 241
                                        const gchar        *image_types,
                                        GimpPDBProcType     type,
                                        gint                n_params,
                                        gint                n_return_vals,
                                        const GimpParamDef *params,
                                        const GimpParamDef *return_vals);
Elliot Lee's avatar
Elliot Lee committed
242 243 244

/* Install a temporary procedure in the procedure database.
 */
245 246 247 248 249 250
void          gimp_install_temp_proc   (const gchar        *name,
                                        const gchar        *blurb,
                                        const gchar        *help,
                                        const gchar        *author,
                                        const gchar        *copyright,
                                        const gchar        *date,
251
                                        const gchar        *menu_label,
252 253 254 255 256 257 258
                                        const gchar        *image_types,
                                        GimpPDBProcType     type,
                                        gint                n_params,
                                        gint                n_return_vals,
                                        const GimpParamDef *params,
                                        const GimpParamDef *return_vals,
                                        GimpRunProc         run_proc);
Elliot Lee's avatar
Elliot Lee committed
259 260 261

/* Uninstall a temporary procedure
 */
262 263 264 265 266 267 268 269 270 271 272 273 274
void          gimp_uninstall_temp_proc (const gchar     *name);

/* Notify the main GIMP application that the extension is ready to run
 */
void          gimp_extension_ack       (void);

/* Enable asynchronous processing of temp_procs
 */
void          gimp_extension_enable    (void);

/* Process one temp_proc and return
 */
void          gimp_extension_process   (guint            timeout);
Elliot Lee's avatar
Elliot Lee committed
275 276 277

/* Run a procedure in the procedure database. The parameters are
 *  specified via the variable length argument list. The return
278
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
279
 */
280
GimpParam   * gimp_run_procedure       (const gchar     *name,
Sven Neumann's avatar
Sven Neumann committed
281
                                        gint            *n_return_vals,
282
                                        ...);
Elliot Lee's avatar
Elliot Lee committed
283 284

/* Run a procedure in the procedure database. The parameters are
285 286
 *  specified as an array of GimpParam.  The return
 *  values are returned in the 'GimpParam*' array.
Elliot Lee's avatar
Elliot Lee committed
287
 */
288 289 290
GimpParam   * gimp_run_procedure2      (const gchar     *name,
                                        gint            *n_return_vals,
                                        gint             n_params,
291
                                        const GimpParam *params);
Elliot Lee's avatar
Elliot Lee committed
292 293 294 295 296

/* Destroy the an array of parameters. This is useful for
 *  destroying the return values returned by a call to
 *  'gimp_run_procedure'.
 */
297 298
void          gimp_destroy_params      (GimpParam       *params,
                                        gint             n_params);
Elliot Lee's avatar
Elliot Lee committed
299

300
/* Destroy the an array of GimpParamDef's. This is useful for
301 302 303
 *  destroying the return values returned by a call to
 *  'gimp_query_procedure'.
 */
304 305
void          gimp_destroy_paramdefs   (GimpParamDef    *paramdefs,
                                        gint             n_params);
Elliot Lee's avatar
Elliot Lee committed
306 307


308 309 310 311 312 313 314 315 316 317
/* Return various constants given by the GIMP core at plug-in config time.
 */
guint         gimp_tile_width          (void) G_GNUC_CONST;
guint         gimp_tile_height         (void) G_GNUC_CONST;
gint          gimp_shm_ID              (void) G_GNUC_CONST;
guchar      * gimp_shm_addr            (void) G_GNUC_CONST;
gdouble       gimp_gamma               (void) G_GNUC_CONST;
gboolean      gimp_install_cmap        (void) G_GNUC_CONST;
gint          gimp_min_colors          (void) G_GNUC_CONST;
gboolean      gimp_show_tool_tips      (void) G_GNUC_CONST;
318
gboolean      gimp_show_help_button    (void) G_GNUC_CONST;
319 320
GimpCheckSize gimp_check_size          (void) G_GNUC_CONST;
GimpCheckType gimp_check_type          (void) G_GNUC_CONST;
321
gint32        gimp_default_display     (void) G_GNUC_CONST;
322 323 324
const gchar * gimp_wm_class            (void) G_GNUC_CONST;
const gchar * gimp_display_name        (void) G_GNUC_CONST;
gint          gimp_monitor_number      (void) G_GNUC_CONST;
325 326 327 328

const gchar * gimp_get_progname        (void) G_GNUC_CONST;


329
gboolean      gimp_attach_new_parasite (const gchar    *name,
330 331
                                        gint            flags,
                                        gint            size,
332
                                        gconstpointer   data);
Elliot Lee's avatar
Elliot Lee committed
333 334


335
G_END_DECLS
Elliot Lee's avatar
Elliot Lee committed
336 337

#endif /* __GIMP_H__ */