1 | /* Copyright (C) 1997, 1998, 1999 Marius Vollmer |
---|
2 | * Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk> |
---|
3 | * |
---|
4 | * $Id: rep-gtk.h,v 1.2 2004-12-28 17:30:00 ghudson Exp $ |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2, or (at your option) |
---|
9 | * any later version. |
---|
10 | * |
---|
11 | * This program 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 |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this software; see the file COPYING. If not, write to |
---|
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef REP_GTK_H |
---|
22 | #define REP_GTK_H |
---|
23 | |
---|
24 | #ifdef HAVE_CONFIG_H |
---|
25 | #include <config.h> |
---|
26 | #endif |
---|
27 | |
---|
28 | #include <rep.h> |
---|
29 | #include <gtk/gtk.h> |
---|
30 | |
---|
31 | typedef struct _sgtk_type_info { |
---|
32 | char *name; |
---|
33 | GType type; |
---|
34 | repv (*conversion) (repv); |
---|
35 | } sgtk_type_info; |
---|
36 | |
---|
37 | typedef struct _sgtk_enum_literal { |
---|
38 | char *name; |
---|
39 | int value; |
---|
40 | } sgtk_enum_literal; |
---|
41 | |
---|
42 | typedef struct _sgtk_enum_info { |
---|
43 | sgtk_type_info header; |
---|
44 | int n_literals; |
---|
45 | sgtk_enum_literal *literals; |
---|
46 | } sgtk_enum_info; |
---|
47 | |
---|
48 | /* This is like an _sgtk_enum_literal, but the values are strings. |
---|
49 | This is used in Gnome. */ |
---|
50 | typedef struct _sgtk_senum_literal { |
---|
51 | char *name; |
---|
52 | char *value; |
---|
53 | } sgtk_senum_literal; |
---|
54 | |
---|
55 | typedef struct _sgtk_senum_info { |
---|
56 | sgtk_type_info header; |
---|
57 | int n_literals; |
---|
58 | sgtk_senum_literal *literals; |
---|
59 | } sgtk_senum_info; |
---|
60 | |
---|
61 | typedef struct _sgtk_boxed_info { |
---|
62 | sgtk_type_info header; |
---|
63 | void *(*copy) (void *); |
---|
64 | void (*destroy) (void *); |
---|
65 | size_t size; |
---|
66 | } sgtk_boxed_info; |
---|
67 | |
---|
68 | typedef struct _sgtk_object_info { |
---|
69 | sgtk_type_info header; |
---|
70 | GType (*init_func) (); |
---|
71 | |
---|
72 | struct _sgtk_object_info *parent; |
---|
73 | } sgtk_object_info; |
---|
74 | |
---|
75 | void sgtk_register_type_infos (sgtk_type_info **infos); |
---|
76 | sgtk_type_info *sgtk_get_type_info (GType type_seqno); |
---|
77 | void sgtk_register_type_infos_gtk (GTypeInfo **infos); |
---|
78 | sgtk_type_info* sgtk_maybe_find_type_info (GType type); |
---|
79 | sgtk_type_info *sgtk_find_type_info (GType type); |
---|
80 | |
---|
81 | int sgtk_valid_int (repv obj); |
---|
82 | int sgtk_valid_uint (repv obj); |
---|
83 | int sgtk_valid_long (repv obj); |
---|
84 | int sgtk_valid_ulong (repv obj); |
---|
85 | int sgtk_valid_char (repv obj); |
---|
86 | repv sgtk_uint_to_rep (u_long x); |
---|
87 | repv sgtk_int_to_rep (long x); |
---|
88 | repv sgtk_long_to_rep (long x); |
---|
89 | repv sgtk_ulong_to_rep (u_long x); |
---|
90 | guint sgtk_rep_to_uint (repv obj); |
---|
91 | gint sgtk_rep_to_int (repv obj); |
---|
92 | gulong sgtk_rep_to_ulong (repv obj); |
---|
93 | glong sgtk_rep_to_long (repv obj); |
---|
94 | gchar sgtk_rep_to_char (repv obj); |
---|
95 | repv sgtk_char_to_rep (gchar c); |
---|
96 | char *sgtk_rep_to_string (repv obj); |
---|
97 | repv sgtk_string_to_rep (char *x); |
---|
98 | repv sgtk_static_string_to_rep (const char *x); |
---|
99 | int sgtk_valid_string (repv obj); |
---|
100 | repv sgtk_bool_to_rep (int x); |
---|
101 | int sgtk_rep_to_bool (repv obj); |
---|
102 | int sgtk_valid_function (repv obj); |
---|
103 | int sgtk_valid_fd (repv obj); |
---|
104 | int sgtk_rep_to_fd (repv obj); |
---|
105 | repv sgtk_fd_to_rep (int fd); |
---|
106 | |
---|
107 | repv sgtk_wrap_gobj (GObject *obj); |
---|
108 | int sgtk_is_a_gobj (guint type, repv obj); |
---|
109 | GObject *sgtk_get_gobj (repv obj); |
---|
110 | |
---|
111 | /* compatibility */ |
---|
112 | repv sgtk_wrap_gtkobj (GtkObject *obj); |
---|
113 | int sgtk_is_a_gtkobj (guint type, repv obj); |
---|
114 | GtkObject *sgtk_get_gtkobj (repv obj); |
---|
115 | |
---|
116 | int sgtk_valid_enum (repv obj, sgtk_enum_info*); |
---|
117 | repv sgtk_enum_to_rep (gint val, sgtk_enum_info*); |
---|
118 | gint sgtk_rep_to_enum (repv obj, sgtk_enum_info*); |
---|
119 | |
---|
120 | int sgtk_valid_flags (repv obj, sgtk_enum_info*); |
---|
121 | repv sgtk_flags_to_rep (gint val, sgtk_enum_info*); |
---|
122 | gint sgtk_rep_to_flags (repv obj, sgtk_enum_info*); |
---|
123 | |
---|
124 | int sgtk_valid_senum (repv obj, sgtk_senum_info*); |
---|
125 | repv sgtk_senum_to_rep (char *val, sgtk_senum_info*); |
---|
126 | char *sgtk_rep_to_senum (repv obj, sgtk_senum_info*); |
---|
127 | |
---|
128 | repv sgtk_boxed_to_rep (gpointer ptr, sgtk_boxed_info*, int copyp); |
---|
129 | void *sgtk_rep_to_boxed (repv obj); |
---|
130 | int sgtk_valid_boxed (repv obj, sgtk_boxed_info*); |
---|
131 | |
---|
132 | int sgtk_valid_float (repv obj); |
---|
133 | gfloat sgtk_rep_to_float (repv obj); |
---|
134 | repv sgtk_float_to_rep (gfloat f); |
---|
135 | |
---|
136 | int sgtk_valid_double (repv obj); |
---|
137 | double sgtk_rep_to_double (repv obj); |
---|
138 | repv sgtk_double_to_rep (double f); |
---|
139 | |
---|
140 | int sgtk_valid_pointer (repv obj); |
---|
141 | void *sgtk_rep_to_pointer (repv obj); |
---|
142 | repv sgtk_pointer_to_rep (void *ptr); |
---|
143 | |
---|
144 | GType gobject_get_type (void); |
---|
145 | |
---|
146 | int sgtk_valid_point (repv obj); |
---|
147 | GdkPoint sgtk_rep_to_point (repv obj); |
---|
148 | repv sgtk_point_to_rep (GdkPoint p); |
---|
149 | |
---|
150 | int sgtk_valid_rect (repv obj); |
---|
151 | GdkRectangle sgtk_rep_to_rect (repv obj); |
---|
152 | repv sgtk_rect_to_rep (GdkRectangle p); |
---|
153 | |
---|
154 | GType sgtk_type_from_name (char *name); |
---|
155 | int sgtk_valid_type (repv obj); |
---|
156 | GType sgtk_rep_to_type (repv obj); |
---|
157 | repv sgtk_type_to_rep (GType t); |
---|
158 | |
---|
159 | int sgtk_valid_composite (repv obj, int (*predicate)(repv)); |
---|
160 | int sgtk_valid_complen (repv obj, int (*predicate)(repv), int len); |
---|
161 | |
---|
162 | repv sgtk_slist_to_rep (GSList *list, repv (*torep)(void*)); |
---|
163 | GSList *sgtk_rep_to_slist (repv obj, void (*fromrep)(repv, void*)); |
---|
164 | void sgtk_slist_finish (GSList *list, repv obj, repv (*torep)(void*)); |
---|
165 | |
---|
166 | repv sgtk_list_to_rep (GList *list, repv (*torep)(void*)); |
---|
167 | GList *sgtk_rep_to_list (repv obj, void (*fromrep)(repv, void*)); |
---|
168 | void sgtk_list_finish (GList *list, repv obj, repv (*torep)(void*)); |
---|
169 | |
---|
170 | typedef struct { |
---|
171 | int count; |
---|
172 | void *vec; |
---|
173 | } sgtk_cvec; |
---|
174 | |
---|
175 | sgtk_cvec sgtk_rep_to_cvec (repv obj, void (*fromrep)(repv, void*), size_t sz); |
---|
176 | void sgtk_cvec_finish (sgtk_cvec *, repv obj, repv (*torep)(void*), size_t sz); |
---|
177 | repv sgtk_cvec_to_rep (sgtk_cvec *cvec, repv (*toscm)(void *), size_t sz); |
---|
178 | |
---|
179 | typedef struct sgtk_protshell sgtk_protshell; |
---|
180 | |
---|
181 | void sgtk_set_protect (repv protector, sgtk_protshell *prot); |
---|
182 | sgtk_protshell *sgtk_new_protect (repv obj); |
---|
183 | sgtk_protshell *sgtk_protect (repv protector, repv obj); |
---|
184 | void sgtk_unprotect (sgtk_protshell *); |
---|
185 | repv sgtk_get_protect (sgtk_protshell *prot); |
---|
186 | |
---|
187 | void sgtk_set_gclosure (repv protector, GClosure *closure); |
---|
188 | repv sgtk_get_gclosure (GClosure *closure); |
---|
189 | GClosure *sgtk_new_gclosure (repv obj); |
---|
190 | GClosure *sgtk_gclosure (repv protector, repv obj); |
---|
191 | |
---|
192 | void sgtk_gclosure_callback_marshal (GClosure *closure, |
---|
193 | GValue *return_value, |
---|
194 | guint n_param_values, |
---|
195 | const GValue *param_values, |
---|
196 | gpointer invocation_hint, |
---|
197 | gpointer marshal_data); |
---|
198 | void sgtk_gclosure_callback_destroy (gpointer data, GClosure *closure); |
---|
199 | |
---|
200 | void sgtk_callback_marshal (GtkObject *obj, |
---|
201 | gpointer data, |
---|
202 | guint n_args, |
---|
203 | GtkArg *args); |
---|
204 | void sgtk_callback_destroy (gpointer data); |
---|
205 | |
---|
206 | repv sgtk_callback_trampoline (repv new_trampoline); |
---|
207 | void sgtk_callback_postfix (void); |
---|
208 | |
---|
209 | int sgtk_valid_arg_type (GType, repv val); |
---|
210 | repv sgtk_arg_to_rep (GtkArg *a, int free_mem); |
---|
211 | void sgtk_rep_to_arg (GtkArg *a, repv obj, repv protector); |
---|
212 | void sgtk_rep_to_ret (GtkArg *a, repv obj); |
---|
213 | |
---|
214 | repv sgtk_gvalue_to_rep (const GValue *a); |
---|
215 | int sgtk_valid_gvalue (const GValue *a, repv obj); |
---|
216 | void sgtk_rep_to_gvalue (GValue *a, repv obj); |
---|
217 | |
---|
218 | sgtk_object_info *sgtk_find_object_info_from_type (GType type); |
---|
219 | sgtk_object_info *sgtk_find_object_info (const char *name); |
---|
220 | void sgtk_free_args (GParameter *args, int n_args); |
---|
221 | GParameter *sgtk_build_args (GObjectClass *objclass, int *n_argsp, |
---|
222 | repv rep_args, char *subr); |
---|
223 | |
---|
224 | repv sgtk_color_conversion (repv color); |
---|
225 | repv sgtk_font_conversion (repv color); |
---|
226 | |
---|
227 | void sgtk_set_standalone (int flag); |
---|
228 | int sgtk_is_standalone (void); |
---|
229 | repv sgtk_standalone_p (void); |
---|
230 | |
---|
231 | void sgtk_init (void); |
---|
232 | void sgtk_init_with_args (int *argcp, char ***argvp); |
---|
233 | |
---|
234 | /* Additional useful Gdk routines. */ |
---|
235 | |
---|
236 | /* The following two do their magic with type conversions that are |
---|
237 | automatically generated by build-guile-gtk. */ |
---|
238 | |
---|
239 | GdkColor *gdk_color_intern (GdkColor *); |
---|
240 | GdkFont *gdk_font_intern (GdkFont *); |
---|
241 | |
---|
242 | GdkEventType gdk_event_type (GdkEvent *event); |
---|
243 | GdkWindow *gdk_event_window (GdkEvent *event); |
---|
244 | gboolean gdk_event_send_event (GdkEvent *event); |
---|
245 | GdkRectangle *gdk_event_area (GdkEvent *event); |
---|
246 | GdkVisibilityState gdk_event_visibility_state (GdkEvent *event); |
---|
247 | guint32 gdk_event_time (GdkEvent *event); |
---|
248 | gdouble gdk_event_x (GdkEvent *event); |
---|
249 | gdouble gdk_event_y (GdkEvent *event); |
---|
250 | gdouble gdk_event_pressure (GdkEvent *event); |
---|
251 | gdouble gdk_event_xtilt (GdkEvent *event); |
---|
252 | gdouble gdk_event_ytilt (GdkEvent *event); |
---|
253 | gint gdk_event_button (GdkEvent *event); |
---|
254 | gboolean gdk_event_button_state (GdkEvent *event); |
---|
255 | gboolean gdk_event_is_hint (GdkEvent *event); |
---|
256 | GdkInputSource gdk_event_source (GdkEvent *event); |
---|
257 | guint32 gdk_event_deviceid (GdkEvent *event); |
---|
258 | gdouble gdk_event_x_root (GdkEvent *event); |
---|
259 | gdouble gdk_event_y_root (GdkEvent *event); |
---|
260 | gboolean gdk_event_key_state (GdkEvent *event); |
---|
261 | guint gdk_event_keyval (GdkEvent *event); |
---|
262 | gchar *gdk_event_string (GdkEvent *event); |
---|
263 | GdkWindow *gdk_event_subwindow (GdkEvent *event); |
---|
264 | GdkNotifyType gdk_event_notify_detail (GdkEvent *event); |
---|
265 | gboolean gdk_event_in (GdkEvent *event); |
---|
266 | gint16 gdk_event_configure_x (GdkEvent *event); |
---|
267 | gint16 gdk_event_configure_y (GdkEvent *event); |
---|
268 | gint16 gdk_event_configure_width (GdkEvent *event); |
---|
269 | gint16 gdk_event_configure_height (GdkEvent *event); |
---|
270 | |
---|
271 | guint32 gdk_get_leader_window_id (void); |
---|
272 | |
---|
273 | guint32 gdk_window_xid (GdkWindow *win); |
---|
274 | |
---|
275 | GdkGC *gtk_style_fg_gc (GtkStyle *style, GtkStateType state); |
---|
276 | GdkGC *gtk_style_bg_gc (GtkStyle *style, GtkStateType state); |
---|
277 | |
---|
278 | /* Gtk stuff that wouldn't be here in an ideal world. */ |
---|
279 | |
---|
280 | #if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 0 |
---|
281 | typedef int GtkWidgetFlags; |
---|
282 | #endif |
---|
283 | |
---|
284 | gchar *gtk_label_get_interp (GtkLabel *label); |
---|
285 | void gtk_menu_popup_interp (GtkMenu *menu, |
---|
286 | GtkWidget *parent_menu_shell, |
---|
287 | GtkWidget *parent_menu_item, |
---|
288 | gint button, |
---|
289 | guint32 activate_time, |
---|
290 | repv position); |
---|
291 | |
---|
292 | GtkWidget* |
---|
293 | gtk_radio_menu_item_new_with_label_from_widget (GtkRadioMenuItem *group, |
---|
294 | const gchar *label); |
---|
295 | GtkWidget* |
---|
296 | gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group, |
---|
297 | const gchar *label); |
---|
298 | GtkWidget* gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group); |
---|
299 | GtkWidget* gtk_pixmap_new_interp (char *file, GtkWidget *intended_parent); |
---|
300 | |
---|
301 | #ifndef HAVE_GDK_COLOR_COPY |
---|
302 | GdkColor* gdk_color_copy (GdkColor *); |
---|
303 | void gdk_color_free (GdkColor *); |
---|
304 | #endif |
---|
305 | |
---|
306 | GdkColor *gdk_color_parse_interp (char *spec); |
---|
307 | GdkColor *gtk_style_get_white_interp (GtkStyle *style); |
---|
308 | |
---|
309 | #ifndef HAVE_GTK_WIDGET_PEEK_COLORMAP |
---|
310 | GdkColormap *gtk_widget_peek_colormap (void); |
---|
311 | #endif |
---|
312 | |
---|
313 | void gtk_list_append_item (GtkList *list, GtkListItem *item); |
---|
314 | void gtk_list_prepend_item (GtkList *list, GtkListItem *item); |
---|
315 | |
---|
316 | #ifndef HAVE_GTK_TYPE_GET_INFO |
---|
317 | gboolean gtk_type_get_info (GtkType type, GtkTypeInfo *info); |
---|
318 | #endif |
---|
319 | |
---|
320 | GtkType gtk_class_new (GtkType parent_type, gchar *name); |
---|
321 | guint |
---|
322 | gtk_signal_new_generic (const gchar *name, |
---|
323 | GtkSignalRunType signal_flags, |
---|
324 | GtkType type, |
---|
325 | GtkType return_type, |
---|
326 | guint nparams, |
---|
327 | GtkType *params); |
---|
328 | void sgtk_signal_emit (GtkObject *obj, char *name, repv rep_args); |
---|
329 | |
---|
330 | #ifndef HAVE_GTK_SIGNAL_SET_CLASS_FUNCTION_FULL |
---|
331 | void gtk_signal_set_class_function_full (GtkType type, |
---|
332 | const gchar *signal, |
---|
333 | GtkSignalFunc func, |
---|
334 | GtkCallbackMarshal marshal, |
---|
335 | gpointer data, |
---|
336 | GtkDestroyNotify destroy_func); |
---|
337 | #endif |
---|
338 | |
---|
339 | void gtk_color_selection_set_color_interp (GtkColorSelection *sel, GdkColor *color); |
---|
340 | GdkColor *gtk_color_selection_get_color_interp (GtkColorSelection *sel); |
---|
341 | extern void gtk_widget_draw_interp (GtkWidget *widget); |
---|
342 | |
---|
343 | GtkTextIter *gtk_text_iter_new (void); |
---|
344 | repv sgtk_gtk_widget_get_allocation (GtkWidget *w); |
---|
345 | |
---|
346 | extern rep_xsubr *sgtk_subrs[]; |
---|
347 | extern sgtk_type_info *sgtk_type_infos[]; |
---|
348 | |
---|
349 | #endif /* !REP_GTK_H */ |
---|