gimpplugin.h 7.02 KB
Newer Older
1 2 3 4
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 *
 * gimpplugin.h
5
 * Copyright (C) 2019 Michael Natterer <mitch@gimp.org>
6
 *
7
 * This library is free software: you can redistribute it and/or
8 9
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 3 of the License, or (at your option) any later version.
11 12 13 14 15 16 17
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library.  If not, see
19
 * <https://www.gnu.org/licenses/>.
20 21
 */

22 23 24 25
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif

26 27 28 29 30 31 32 33
#ifndef __GIMP_PLUG_IN_H__
#define __GIMP_PLUG_IN_H__

G_BEGIN_DECLS

/* For information look into the C source or the html documentation */


34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#define GIMP_TYPE_PLUG_IN            (gimp_plug_in_get_type ())
#define GIMP_PLUG_IN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PLUG_IN, GimpPlugIn))
#define GIMP_PLUG_IN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PLUG_IN, GimpPlugInClass))
#define GIMP_IS_PLUG_IN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PLUG_IN))
#define GIMP_IS_PLUG_IN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PLUG_IN))
#define GIMP_PLUG_IN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PLUG_IN, GimpPlugInClass))


typedef struct _GimpPlugInClass   GimpPlugInClass;
typedef struct _GimpPlugInPrivate GimpPlugInPrivate;

struct _GimpPlugIn
{
  GObject            parent_instance;

  GimpPlugInPrivate *priv;
};

52 53
/**
 * GimpPlugInClass:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
 * @query_procedures: This method can be overridden by all plug-ins to
 *   return a newly allocated #GList of allocated strings naming the
 *   procedures registered by this plug-in. See documentation of
 *   #GimpPlugInClass.init_procedures() for differences.
 * @init_procedures: This method can be overridden by all plug-ins to
 *   return a newly allocated #GList of allocated strings naming
 *   procedures registered by this plug-in.
 *   It is different from #GimpPlugInClass.query_procedures() in that
 *   init happens at every startup, whereas query happens only once in
 *   the life of a plug-in (right after installation or update). Hence
 *   #GimpPlugInClass.init_procedures() typically returns procedures
 *   dependent to runtime conditions (such as the presence of a
 *   third-party tool), whereas #GimpPlugInClass.query_procedures()
 *   would usually return procedures that are always available
 *   unconditionally.
 *   Most of the time, you only want to override
 *   #GimpPlugInClass.query_procedures() and leave
 *   #GimpPlugInClass.init_procedures() untouched.
 * @create_procedure: This method must be overridden by all plug-ins
 *   and return a newly allocated #GimpProcedure named @name. It will
 *   be called for every @name as returned by
 *   #GimpPlugInClass.query_procedures() and
76 77 78 79 80 81
 *   #GimpPlugInClass.init_procedures() so care must be taken to
 *   handle them all.
 *   Upon procedure registration, #GimpPlugInClass.create_procedure()
 *   will be called in the order of the lists returned by
 *   #GimpPlugInClass.query_procedures() and
 *   #GimpPlugInClass.init_procedures()
82 83
 * @quit: This method can be overridden by a plug-in which needs to
 *   perform some actions upon quitting.
84
 *
luzpaz's avatar
luzpaz committed
85
 * A class which every plug-in should subclass, while overriding
86 87 88
 * #GimpPlugInClass.query_procedures() and/or
 * #GimpPlugInClass.init_procedures(), as well as
 * #GimpPlugInClass.create_procedure().
89 90 91
 *
 * Since: 3.0
 **/
92 93 94 95
struct _GimpPlugInClass
{
  GObjectClass  parent_class;

96 97 98 99 100 101
  /**
   * GimpPlugInClass::query_procedures:
   * @plug_in: a #GimpPlugIn.
   *
   * Returns: (element-type gchar*) (transfer full):
   *          the names of the procedures registered by @plug_in.
102
   **/
103
  GList          * (* query_procedures) (GimpPlugIn  *plug_in);
104 105 106 107 108 109 110

  /**
   * GimpPlugInClass::init_procedures:
   * @plug_in: a #GimpPlugIn.
   *
   * Returns: (element-type gchar*) (transfer full):
   *          the names of the procedures registered by @plug_in.
111
   **/
112
  GList          * (* init_procedures)  (GimpPlugIn  *plug_in);
113

114 115 116 117 118 119
  /**
   * GimpPlugInClass::create_procedure:
   * @plug_in:        a #GimpPlugIn.
   * @procedure_name: procedure name.
   *
   * Returns: (transfer full):
120 121
   *          the procedure to be registered or executed by @plug_in.
   **/
122
  GimpProcedure  * (* create_procedure) (GimpPlugIn  *plug_in,
123
                                         const gchar *procedure_name);
124

125 126 127
  /**
   * GimpPlugInClass::quit:
   * @plug_in: a #GimpPlugIn.
128
   **/
129 130
  void             (* quit)             (GimpPlugIn  *plug_in);

131 132 133 134 135 136 137 138 139 140 141 142
  /* Padding for future expansion */
  void (* _gimp_reserved1) (void);
  void (* _gimp_reserved2) (void);
  void (* _gimp_reserved3) (void);
  void (* _gimp_reserved4) (void);
  void (* _gimp_reserved5) (void);
  void (* _gimp_reserved6) (void);
  void (* _gimp_reserved7) (void);
  void (* _gimp_reserved8) (void);
};


143 144 145 146 147 148 149 150 151 152 153 154 155
GType           gimp_plug_in_get_type               (void) G_GNUC_CONST;

void            gimp_plug_in_set_translation_domain (GimpPlugIn    *plug_in,
                                                     const gchar   *domain_name,
                                                     GFile         *domain_path);
void            gimp_plug_in_set_help_domain        (GimpPlugIn    *plug_in,
                                                     const gchar   *domain_name,
                                                     GFile         *domain_uri);

void            gimp_plug_in_add_menu_branch        (GimpPlugIn    *plug_in,
                                                     const gchar   *menu_path,
                                                     const gchar   *menu_label);

156
void            gimp_plug_in_add_temp_procedure     (GimpPlugIn    *plug_in,
157
                                                     GimpProcedure *procedure);
158
void            gimp_plug_in_remove_temp_procedure  (GimpPlugIn    *plug_in,
159
                                                     const gchar   *procedure_name);
160

161 162
GList         * gimp_plug_in_get_temp_procedures    (GimpPlugIn    *plug_in);
GimpProcedure * gimp_plug_in_get_temp_procedure     (GimpPlugIn    *plug_in,
163
                                                     const gchar   *procedure_name);
164

165 166 167 168
void            gimp_plug_in_extension_enable       (GimpPlugIn    *plug_in);
void            gimp_plug_in_extension_process      (GimpPlugIn    *plug_in,
                                                     guint          timeout);

169 170 171 172 173
void            gimp_plug_in_set_pdb_error_handler  (GimpPlugIn    *plug_in,
                                                     GimpPDBErrorHandler  handler);
GimpPDBErrorHandler
                gimp_plug_in_get_pdb_error_handler  (GimpPlugIn    *plug_in);

174

175 176 177
G_END_DECLS

#endif /* __GIMP_PLUG_IN_H__ */