gimpsignal.c 4.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

19 20
#include "gimpsignal.h"

21 22 23 24 25 26
struct _GimpSignalType
{
  GtkSignalMarshaller  marshaller;
  GtkType              return_type;
  guint                nparams;
  const GtkType       *param_types;
27 28 29 30
};

typedef const GtkType TypeArr[];

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
GimpSignalID gimp_signal_new (const gchar      *name,
			      GtkSignalRunType  signal_flags,
			      GtkType           object_type,
			      guint             function_offset,
			      GimpSignalType   *sig_type)
{
  return gtk_signal_newv (name,
			  signal_flags,
			  object_type,
			  function_offset,
			  sig_type->marshaller,
			  sig_type->return_type,
			  sig_type->nparams,
			  /* Bah. We try to be const correct, but 
			     gtk isn't.. */
			  (GtkType *) sig_type->param_types);
47 48
}

49 50 51 52 53 54
static GimpSignalType sigtype_void = 
{
  gtk_signal_default_marshaller,
  GTK_TYPE_NONE,
  0,
  NULL
55 56
};

57
GimpSignalType* const gimp_sigtype_void = &sigtype_void;
58 59

static void
60
gimp_marshaller_pointer (GtkObject     *object,
61
			 GtkSignalFunc	func,
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
			 gpointer       func_data,
			 GtkArg        *args)
{
  (* (GimpHandlerPointer) func) (object,
				 GTK_VALUE_POINTER (args[0]),
				 func_data);
}

static TypeArr pointer_types =
{
  GTK_TYPE_POINTER
};

static GimpSignalType sigtype_pointer =
{
  gimp_marshaller_pointer,
  GTK_TYPE_NONE,
  1,
  pointer_types
};

GimpSignalType* const gimp_sigtype_pointer = &sigtype_pointer;

static void
gimp_marshaller_int (GtkObject     *object,
		     GtkSignalFunc  func,
		     gpointer       func_data,
		     GtkArg        *args)
90
{
91 92 93
  (* (GimpHandlerInt) func) (object,
			     GTK_VALUE_INT (args[0]),
			     func_data);
94 95
}

96 97 98
static TypeArr int_types =
{
  GTK_TYPE_INT
99 100
};

101 102 103 104 105 106
static GimpSignalType sigtype_int =
{
  gimp_marshaller_int,
  GTK_TYPE_NONE,
  1,
  int_types
107 108
};

109
GimpSignalType* const gimp_sigtype_int = &sigtype_int;
110 111

static void
112 113 114 115
gimp_marshaller_double (GtkObject     *object,
			GtkSignalFunc  func,
			gpointer       func_data,
			GtkArg        *args)
116
{
117 118 119
  (* (GimpHandlerDouble) func) (object,
				GTK_VALUE_DOUBLE (args[0]),
				func_data);
120 121
}

122 123 124
static TypeArr double_types =
{
  GTK_TYPE_DOUBLE
125 126
};

127 128 129 130 131 132
static GimpSignalType sigtype_double =
{
  gimp_marshaller_double,
  GTK_TYPE_NONE,
  1,
  double_types
133 134
};

135
GimpSignalType* const gimp_sigtype_double = &sigtype_double;
136

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
static void
gimp_marshaller_int_int_int (GtkObject     *object,
			     GtkSignalFunc  func,
			     gpointer       func_data,
			     GtkArg        *args)
{
  (* (GimpHandlerIntIntInt) func) (object,
				   GTK_VALUE_INT (args[0]),
				   GTK_VALUE_INT (args[1]),
				   GTK_VALUE_INT (args[2]),
				   func_data);
}

static TypeArr int_int_int_types =
{
  GTK_TYPE_INT,
  GTK_TYPE_INT,
  GTK_TYPE_INT
};

static GimpSignalType sigtype_int_int_int =
{
  gimp_marshaller_int_int_int,
  GTK_TYPE_NONE,
  3,
  int_int_int_types
};

GimpSignalType* const gimp_sigtype_int_int_int = &sigtype_int_int_int;

167
static void
168 169 170 171
gimp_marshaller_int_int_int_int (GtkObject     *object,
				 GtkSignalFunc  func,
				 gpointer       func_data,
				 GtkArg        *args)
172
{
173 174 175 176 177 178
  (* (GimpHandlerIntIntIntInt) func) (object,
				      GTK_VALUE_INT (args[0]),
				      GTK_VALUE_INT (args[1]),
				      GTK_VALUE_INT (args[2]),
				      GTK_VALUE_INT (args[3]),
				      func_data);
179 180
}

181 182 183 184 185 186
static TypeArr int_int_int_int_types =
{
  GTK_TYPE_INT,
  GTK_TYPE_INT,
  GTK_TYPE_INT,
  GTK_TYPE_INT
187
};
188 189 190 191 192 193 194

static GimpSignalType sigtype_int_int_int_int =
{
  gimp_marshaller_int_int_int_int,
  GTK_TYPE_NONE,
  4,
  int_int_int_int_types
195 196
};

197
GimpSignalType* const gimp_sigtype_int_int_int_int = &sigtype_int_int_int_int;