5 #include <caml/mlvalues.h>
6 #include <caml/alloc.h>
7 #include <caml/memory.h>
8 #include <caml/callback.h>
17 void ml_raise_gtk (const char *errmsg)
19 static value * exn = NULL;
21 exn = caml_named_value ("gtkerror");
22 raise_with_string (*exn, (char*)errmsg);
25 value copy_string_and_free (char *str)
28 res = copy_string_check (str);
33 value *ml_gtk_root_new (value v)
35 value *p = stat_alloc(sizeof(value));
37 register_global_root (p);
41 void ml_gtk_root_destroy (gpointer data)
43 remove_global_root ((value *)data);
47 /* conversion functions */
51 ML_1 (Val_direction_type, Int_val, Id)
52 ML_1 (Val_orientation, Int_val, Id)
53 ML_1 (Val_toolbar_style, Int_val, Id)
54 ML_1 (Val_state_type, Int_val, Id)
55 ML_1 (Val_scroll_type, Int_val, Id)
57 Make_Flags_val (Attach_options_val)
58 Make_Flags_val (Button_action_val)
59 Make_Flags_val (Dest_defaults_val)
60 Make_Flags_val (Target_flags_val)
61 Make_Flags_val (Font_type_val)
65 Make_Val_final_pointer(GtkObject, gtk_object_ref, gtk_object_unref, 0)
67 #define gtk_object_ref_and_sink(w) (gtk_object_ref(w), gtk_object_sink(w))
68 Make_Val_final_pointer_ext(GtkObject, _sink , gtk_object_ref_and_sink,
73 #define GtkAccelGroup_val(val) ((GtkAccelGroup*)Pointer_val(val))
74 Make_Val_final_pointer (GtkAccelGroup, gtk_accel_group_ref,
75 gtk_accel_group_unref, 0)
76 Make_Val_final_pointer_ext (GtkAccelGroup, _no_ref, Ignore,
77 gtk_accel_group_unref, 20)
78 Make_OptFlags_val (Accel_flag_val)
80 #define Signal_name_val(val) String_val(Field(val,0))
82 ML_0 (gtk_accel_group_new, Val_GtkAccelGroup_no_ref)
83 ML_0 (gtk_accel_group_get_default, Val_GtkAccelGroup)
84 ML_3 (gtk_accel_group_activate, GtkAccelGroup_val, Int_val,
85 OptFlags_GdkModifier_val, Val_bool)
86 ML_3 (gtk_accel_groups_activate, GtkObject_val, Int_val,
87 OptFlags_GdkModifier_val, Val_bool)
88 ML_2 (gtk_accel_group_attach, GtkAccelGroup_val, GtkObject_val, Unit)
89 ML_2 (gtk_accel_group_detach, GtkAccelGroup_val, GtkObject_val, Unit)
90 ML_1 (gtk_accel_group_lock, GtkAccelGroup_val, Unit)
91 ML_1 (gtk_accel_group_unlock, GtkAccelGroup_val, Unit)
92 ML_3 (gtk_accel_group_lock_entry, GtkAccelGroup_val, Int_val,
93 OptFlags_GdkModifier_val, Unit)
94 ML_3 (gtk_accel_group_unlock_entry, GtkAccelGroup_val, Int_val,
95 OptFlags_GdkModifier_val, Unit)
96 ML_6 (gtk_accel_group_add, GtkAccelGroup_val, Int_val,
97 OptFlags_GdkModifier_val, OptFlags_Accel_flag_val,
98 GtkObject_val, Signal_name_val, Unit)
99 ML_bc6 (ml_gtk_accel_group_add)
100 ML_4 (gtk_accel_group_remove, GtkAccelGroup_val, Int_val,
101 OptFlags_GdkModifier_val, GtkObject_val, Unit)
102 ML_2 (gtk_accelerator_valid, Int_val, OptFlags_GdkModifier_val, Val_bool)
103 ML_1 (gtk_accelerator_set_default_mod_mask, OptFlags_GdkModifier_val, Unit)
107 #define GtkStyle_val(val) ((GtkStyle*)Pointer_val(val))
108 Make_Val_final_pointer (GtkStyle, gtk_style_ref, gtk_style_unref, 0)
109 Make_Val_final_pointer_ext (GtkStyle, _no_ref, Ignore, gtk_style_unref, 20)
110 ML_0 (gtk_style_new, Val_GtkStyle_no_ref)
111 ML_1 (gtk_style_copy, GtkStyle_val, Val_GtkStyle_no_ref)
112 ML_2 (gtk_style_attach, GtkStyle_val, GdkWindow_val, Val_GtkStyle)
113 ML_1 (gtk_style_detach, GtkStyle_val, Unit)
114 ML_3 (gtk_style_set_background, GtkStyle_val, GdkWindow_val, State_type_val, Unit)
115 ML_6 (gtk_draw_hline, GtkStyle_val, GdkWindow_val, State_type_val,
116 Int_val, Int_val, Int_val, Unit)
117 ML_bc6 (ml_gtk_draw_hline)
118 ML_6 (gtk_draw_vline, GtkStyle_val, GdkWindow_val, State_type_val,
119 Int_val, Int_val, Int_val, Unit)
120 ML_bc6 (ml_gtk_draw_vline)
121 Make_Array_Extractor (gtk_style_get, GtkStyle_val, State_type_val, bg, Val_copy)
122 Make_Array_Setter (gtk_style_set, GtkStyle_val, State_type_val, *GdkColor_val, bg)
123 Make_Extractor (gtk_style_get, GtkStyle_val, colormap, Val_GdkColormap)
124 Make_Extractor (gtk_style_get, GtkStyle_val, depth, Val_int)
125 Make_Extractor (gtk_style_get, GtkStyle_val, font, Val_GdkFont)
126 /* Make_Setter (gtk_style_set, GtkStyle_val, GdkFont_val, font) */
127 value ml_gtk_style_set_font (value st, value font)
129 GtkStyle *style = GtkStyle_val(st);
130 if (style->font) gdk_font_unref(style->font);
131 style->font = GdkFont_val(font);
132 gdk_font_ref(style->font);
135 Make_Array_Extractor (gtk_style_get, GtkStyle_val, State_type_val, dark_gc, Val_GdkGC)
136 Make_Array_Extractor (gtk_style_get, GtkStyle_val, State_type_val, light_gc, Val_GdkGC)
140 ML_1 (gtk_type_name, Int_val, Val_string)
141 ML_1 (gtk_type_from_name, String_val, Val_int)
142 ML_1 (gtk_type_parent, Int_val, Val_int)
143 ML_1 (gtk_type_class, Int_val, (value))
144 ML_1 (gtk_type_parent_class, Int_val, (value))
145 ML_2 (gtk_type_is_a, Int_val, Int_val, Val_bool)
146 value ml_gtk_type_fundamental (value type)
148 return Val_fundamental_type (GTK_FUNDAMENTAL_TYPE (Int_val(type)));
153 /* ML_1 (GTK_OBJECT_TYPE, GtkObject_val, Val_int) */
154 value ml_gtk_object_type (value val)
156 return Val_int (GtkObject_val(val)->klass->type);
159 ML_1 (gtk_object_destroy, GtkObject_val, Unit)
160 ML_1 (gtk_object_ref, GtkObject_val, Unit)
161 ML_1 (gtk_object_unref, GtkObject_val, Unit)
162 ML_1 (gtk_object_sink, GtkObject_val, Unit)
164 Make_Extractor (gtk_class,(GtkObjectClass *),type,Val_int)
168 /* gtkadjustment.h */
170 #define GtkAdjustment_val(val) check_cast(GTK_ADJUSTMENT,val)
171 ML_6 (gtk_adjustment_new, Float_val, Float_val, Float_val, Float_val,
172 Float_val, Float_val, Val_GtkObject_sink)
173 ML_bc6 (ml_gtk_adjustment_new)
174 ML_2 (gtk_adjustment_set_value, GtkAdjustment_val, Float_val, Unit)
175 ML_3 (gtk_adjustment_clamp_page, GtkAdjustment_val,
176 Float_val, Float_val, Unit)
177 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, lower, copy_double)
178 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, upper, copy_double)
179 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, value, copy_double)
180 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, step_increment,
182 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, page_increment,
184 Make_Extractor (gtk_adjustment_get, GtkAdjustment_val, page_size, copy_double)
188 #define GtkWidget_val(val) check_cast(GTK_WIDGET,val)
189 #define GtkTooltips_val(val) check_cast(GTK_TOOLTIPS,val)
190 ML_0 (gtk_tooltips_new, Val_GtkAny)
191 ML_1 (gtk_tooltips_enable, GtkTooltips_val, Unit)
192 ML_1 (gtk_tooltips_disable, GtkTooltips_val, Unit)
193 ML_2 (gtk_tooltips_set_delay, GtkTooltips_val, Int_val, Unit)
194 ML_4 (gtk_tooltips_set_tip, GtkTooltips_val, GtkWidget_val,
195 String_option_val, String_option_val, Unit)
196 ML_3 (gtk_tooltips_set_colors, GtkTooltips_val,
197 Option_val(arg2, GdkColor_val, NULL) Ignore,
198 Option_val(arg3, GdkColor_val, NULL) Ignore,
203 value ml_gtk_widget_set_can_default (value val, value bool)
205 GtkWidget *w = GtkWidget_val(val);
206 guint32 saved_flags = GTK_WIDGET_FLAGS(w);
207 if (Bool_val(bool)) GTK_WIDGET_SET_FLAGS(w, GTK_CAN_DEFAULT);
208 else GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_DEFAULT);
209 if (saved_flags != GTK_WIDGET_FLAGS(w))
210 gtk_widget_queue_resize (w);
213 value ml_gtk_widget_set_can_focus (value val, value bool)
215 GtkWidget *w = GtkWidget_val(val);
216 guint32 saved_flags = GTK_WIDGET_FLAGS(w);
217 if (Bool_val(bool)) GTK_WIDGET_SET_FLAGS(w, GTK_CAN_FOCUS);
218 else GTK_WIDGET_UNSET_FLAGS(w, GTK_CAN_FOCUS);
219 if (saved_flags != GTK_WIDGET_FLAGS(w))
220 gtk_widget_queue_resize (w);
223 ML_1 (gtk_widget_unparent, GtkWidget_val, Unit)
224 ML_1 (gtk_widget_show, GtkWidget_val, Unit)
225 ML_1 (gtk_widget_show_now, GtkWidget_val, Unit)
226 ML_1 (gtk_widget_show_all, GtkWidget_val, Unit)
227 ML_1 (gtk_widget_hide, GtkWidget_val, Unit)
228 ML_1 (gtk_widget_hide_all, GtkWidget_val, Unit)
229 ML_1 (gtk_widget_map, GtkWidget_val, Unit)
230 ML_1 (gtk_widget_unmap, GtkWidget_val, Unit)
231 ML_1 (gtk_widget_realize, GtkWidget_val, Unit)
232 ML_1 (gtk_widget_unrealize, GtkWidget_val, Unit)
233 ML_1 (gtk_widget_queue_draw, GtkWidget_val, Unit)
234 ML_1 (gtk_widget_queue_resize, GtkWidget_val, Unit)
235 ML_2 (gtk_widget_draw, GtkWidget_val,
236 Option_val(arg2,GdkRectangle_val,NULL) Ignore, Unit)
237 ML_1 (gtk_widget_draw_focus, GtkWidget_val, Unit)
238 ML_1 (gtk_widget_draw_default, GtkWidget_val, Unit)
239 /* ML_1 (gtk_widget_draw_children, GtkWidget_val, Unit) */
240 ML_2 (gtk_widget_event, GtkWidget_val, GdkEvent_val, Val_bool)
241 ML_1 (gtk_widget_activate, GtkWidget_val, Val_bool)
242 ML_2 (gtk_widget_reparent, GtkWidget_val, GtkWidget_val, Unit)
243 ML_3 (gtk_widget_popup, GtkWidget_val, Int_val, Int_val, Unit)
244 value ml_gtk_widget_intersect (value w, value area)
247 if (gtk_widget_intersect(GtkWidget_val(w), GdkRectangle_val(area), &inter))
248 return ml_some (Val_copy (inter));
251 /* ML_1 (gtk_widget_basic, GtkWidget_val, Val_bool) */
252 ML_1 (gtk_widget_grab_focus, GtkWidget_val, Unit)
253 ML_1 (gtk_widget_grab_default, GtkWidget_val, Unit)
254 ML_2 (gtk_widget_set_name, GtkWidget_val, String_val, Unit)
255 ML_1 (gtk_widget_get_name, GtkWidget_val, Val_string)
256 ML_2 (gtk_widget_set_state, GtkWidget_val, State_type_val, Unit)
257 ML_2 (gtk_widget_set_sensitive, GtkWidget_val, Bool_val, Unit)
258 ML_3 (gtk_widget_set_uposition, GtkWidget_val, Int_val, Int_val, Unit)
259 ML_3 (gtk_widget_set_usize, GtkWidget_val, Int_val, Int_val, Unit)
260 ML_2 (gtk_widget_add_events, GtkWidget_val, Flags_Event_mask_val, Unit)
261 ML_2 (gtk_widget_set_events, GtkWidget_val, Flags_Event_mask_val, Unit)
262 ML_2 (gtk_widget_set_extension_events, GtkWidget_val, Extension_events_val,
264 ML_1 (gtk_widget_get_toplevel, GtkWidget_val, Val_GtkWidget)
265 ML_2 (gtk_widget_get_ancestor, GtkWidget_val, Int_val, Val_GtkWidget)
266 ML_1 (gtk_widget_get_colormap, GtkWidget_val, Val_GdkColormap)
267 ML_1 (gtk_widget_get_visual, GtkWidget_val, (value))
268 value ml_gtk_widget_get_pointer (value w)
272 gtk_widget_get_pointer (GtkWidget_val(w), &x, &y);
273 ret = alloc_small (2,0);
274 Field(ret,0) = Val_int(x);
275 Field(ret,1) = Val_int(y);
278 ML_2 (gtk_widget_is_ancestor, GtkWidget_val, GtkWidget_val, Val_bool)
279 /* ML_2 (gtk_widget_is_child, GtkWidget_val, GtkWidget_val, Val_bool) */
280 ML_2 (gtk_widget_set_style, GtkWidget_val, GtkStyle_val, Unit)
281 ML_1 (gtk_widget_set_rc_style, GtkWidget_val, Unit)
282 ML_1 (gtk_widget_ensure_style, GtkWidget_val, Unit)
283 ML_1 (gtk_widget_get_style, GtkWidget_val, Val_GtkStyle)
284 ML_1 (gtk_widget_restore_default_style, GtkWidget_val, Unit)
286 ML_6 (gtk_widget_add_accelerator, GtkWidget_val, Signal_name_val,
287 GtkAccelGroup_val, Char_val, OptFlags_GdkModifier_val,
288 OptFlags_Accel_flag_val, Unit)
289 ML_bc6 (ml_gtk_widget_add_accelerator)
290 ML_4 (gtk_widget_remove_accelerator, GtkWidget_val, GtkAccelGroup_val,
291 Char_val, OptFlags_GdkModifier_val, Unit)
292 ML_1 (gtk_widget_lock_accelerators, GtkWidget_val, Unit)
293 ML_1 (gtk_widget_unlock_accelerators, GtkWidget_val, Unit)
294 ML_1 (gtk_widget_accelerators_locked, GtkWidget_val, Val_bool)
296 ML_1 (GTK_WIDGET_VISIBLE, GtkWidget_val, Val_bool)
297 ML_1 (GTK_WIDGET_HAS_FOCUS, GtkWidget_val, Val_bool)
299 Make_Extractor (GtkWidget, GtkWidget_val, window, Val_GdkWindow)
300 Make_Extractor (gtk_widget, GtkWidget_val, parent, Val_GtkWidget)
301 static value Val_GtkAllocation (GtkAllocation allocation)
303 value ret = alloc_small (4, 0);
304 Field(ret,0) = Val_int(allocation.x);
305 Field(ret,1) = Val_int(allocation.y);
306 Field(ret,2) = Val_int(allocation.width);
307 Field(ret,3) = Val_int(allocation.height);
310 Make_Extractor (gtk_widget, GtkWidget_val, allocation, Val_GtkAllocation)
312 #define GtkAllocation_val(val) ((GtkAllocation*)Pointer_val(val))
313 Make_Extractor (gtk_allocation, GtkAllocation_val, x, Val_int)
314 Make_Extractor (gtk_allocation, GtkAllocation_val, y, Val_int)
315 Make_Extractor (gtk_allocation, GtkAllocation_val, width, Val_int)
316 Make_Extractor (gtk_allocation, GtkAllocation_val, height, Val_int)
319 ML_2 (gtk_widget_set_app_paintable, GtkWidget_val, Bool_val, Unit)
321 ML_2 (gtk_widget_set_visual, GtkWidget_val, GdkVisual_val, Unit)
322 ML_2 (gtk_widget_set_colormap, GtkWidget_val, GdkColormap_val, Unit)
323 ML_1 (gtk_widget_set_default_visual, GdkVisual_val, Unit)
324 ML_1 (gtk_widget_set_default_colormap, GdkColormap_val, Unit)
325 ML_0 (gtk_widget_get_default_visual, Val_GdkVisual)
326 ML_0 (gtk_widget_get_default_colormap, Val_GdkColormap)
327 ML_1 (gtk_widget_push_visual, GdkVisual_val, Unit)
328 ML_1 (gtk_widget_push_colormap, GdkColormap_val, Unit)
329 ML_0 (gtk_widget_pop_visual, Unit)
330 ML_0 (gtk_widget_pop_colormap, Unit)
334 value ml_gtk_drag_dest_set (value w, value f, value t, value a)
336 GtkTargetEntry *targets = (GtkTargetEntry *)Val_unit;
339 CAMLparam4 (w,f,t,a);
340 n_targets = Wosize_val(t);
342 targets = (GtkTargetEntry *)
343 alloc (Wosize_asize(n_targets * sizeof(GtkTargetEntry)),
345 for (i=0; i<n_targets; i++) {
346 targets[i].target = String_val(Field(Field(t, i), 0));
347 targets[i].flags = Flags_Target_flags_val(Field(Field(t, i), 1));
348 targets[i].info = Int_val(Field(Field(t, i), 2));
350 gtk_drag_dest_set (GtkWidget_val(w), Flags_Dest_defaults_val(f),
351 targets, n_targets, Flags_GdkDragAction_val(a));
352 CAMLreturn(Val_unit);
354 ML_1 (gtk_drag_dest_unset, GtkWidget_val, Unit)
355 ML_4 (gtk_drag_finish, GdkDragContext_val, Bool_val, Bool_val, Int_val, Unit)
356 ML_4 (gtk_drag_get_data, GtkWidget_val, GdkDragContext_val, Int_val, Int_val, Unit)
357 ML_1 (gtk_drag_get_source_widget, GdkDragContext_val, Val_GtkWidget)
358 ML_1 (gtk_drag_highlight, GtkWidget_val, Unit)
359 ML_1 (gtk_drag_unhighlight, GtkWidget_val, Unit)
360 ML_4 (gtk_drag_set_icon_widget, GdkDragContext_val, GtkWidget_val,
361 Int_val, Int_val, Unit)
362 ML_6 (gtk_drag_set_icon_pixmap, GdkDragContext_val, GdkColormap_val,
363 GdkPixmap_val, Option_val(arg4, GdkBitmap_val, NULL) Ignore,
364 Int_val, Int_val, Unit)
365 ML_bc6 (ml_gtk_drag_set_icon_pixmap)
366 ML_1 (gtk_drag_set_icon_default, GdkDragContext_val, Unit)
367 ML_5 (gtk_drag_set_default_icon, GdkColormap_val,
368 GdkPixmap_val, Option_val(arg3, GdkBitmap_val, NULL) Ignore,
369 Int_val, Int_val, Unit)
370 value ml_gtk_drag_source_set (value w, value m, value t, value a)
372 GtkTargetEntry *targets = (GtkTargetEntry *)Val_unit;
374 CAMLparam4 (w,m,t,a);
376 n_targets = Wosize_val(t);
378 targets = (GtkTargetEntry *)
379 alloc (Wosize_asize(n_targets * sizeof(GtkTargetEntry)),
381 for (i=0; i<n_targets; i++) {
382 targets[i].target = String_val(Field(Field(t, i), 0));
383 targets[i].flags = Flags_Target_flags_val(Field(Field(t, i), 1));
384 targets[i].info = Int_val(Field(Field(t, i), 2));
386 gtk_drag_source_set (GtkWidget_val(w), OptFlags_GdkModifier_val(m),
387 targets, n_targets, Flags_GdkDragAction_val(a));
388 CAMLreturn(Val_unit);
390 ML_4 (gtk_drag_source_set_icon, GtkWidget_val, GdkColormap_val,
391 GdkPixmap_val, Option_val(arg4, GdkBitmap_val, NULL) Ignore, Unit)
392 ML_1 (gtk_drag_source_unset, GtkWidget_val, Unit)
394 /* gtkwidget.h / gtkselection.h */
396 #define GtkSelectionData_val(val) ((GtkSelectionData *)Pointer_val(val))
398 Make_Extractor (gtk_selection_data, GtkSelectionData_val, selection, Val_int)
399 Make_Extractor (gtk_selection_data, GtkSelectionData_val, target, Val_int)
400 Make_Extractor (gtk_selection_data, GtkSelectionData_val, type, Val_int)
401 Make_Extractor (gtk_selection_data, GtkSelectionData_val, format, Val_int)
402 value ml_gtk_selection_data_get_data (value val)
405 GtkSelectionData *data = GtkSelectionData_val(val);
407 if (data->length < 0) ml_raise_null_pointer();
408 ret = alloc_string (data->length);
409 if (data->length) memcpy ((void*)ret, data->data, data->length);
413 ML_4 (gtk_selection_data_set, GtkSelectionData_val, Int_val, Int_val,
414 Insert((guchar*)String_option_val(arg4))
415 Option_val(arg4, string_length, -1) Ignore,
420 #define GtkContainer_val(val) check_cast(GTK_CONTAINER,val)
421 ML_2 (gtk_container_set_border_width, GtkContainer_val, Int_val, Unit)
422 ML_2 (gtk_container_set_resize_mode, GtkContainer_val, Resize_mode_val, Unit)
423 ML_2 (gtk_container_add, GtkContainer_val, GtkWidget_val, Unit)
424 ML_2 (gtk_container_remove, GtkContainer_val, GtkWidget_val, Unit)
425 static void ml_gtk_simple_callback (GtkWidget *w, gpointer data)
427 value val, *clos = (value*)data;
428 val = Val_GtkWidget(w);
429 callback (*clos, val);
431 value ml_gtk_container_foreach (value w, value clos)
434 gtk_container_foreach (GtkContainer_val(w), ml_gtk_simple_callback,
436 CAMLreturn(Val_unit);
438 ML_1 (gtk_container_register_toplevel, GtkContainer_val, Unit)
439 ML_1 (gtk_container_unregister_toplevel, GtkContainer_val, Unit)
440 ML_2 (gtk_container_focus, GtkContainer_val, Direction_type_val, Val_bool)
441 ML_2 (gtk_container_set_focus_child, GtkContainer_val, GtkWidget_val, Unit)
442 ML_2 (gtk_container_set_focus_vadjustment, GtkContainer_val,
443 GtkAdjustment_val, Unit)
444 ML_2 (gtk_container_set_focus_hadjustment, GtkContainer_val,
445 GtkAdjustment_val, Unit)
451 #define GtkAlignment_val(val) check_cast(GTK_ALIGNMENT,val)
452 ML_4 (gtk_alignment_new, Float_val, Float_val, Float_val, Float_val,
454 value ml_gtk_alignment_set (value x, value y,
455 value xscale, value yscale, value val)
457 GtkAlignment *alignment = GtkAlignment_val(val);
458 gtk_alignment_set (alignment,
459 Option_val(x, Float_val, alignment->xalign),
460 Option_val(y, Float_val, alignment->yalign),
461 Option_val(xscale, Float_val, alignment->xscale),
462 Option_val(yscale, Float_val, alignment->xscale));
468 ML_0 (gtk_event_box_new, Val_GtkWidget_sink)
472 #define GtkFrame_val(val) check_cast(GTK_FRAME,val)
473 ML_1 (gtk_frame_new, Optstring_val, Val_GtkWidget_sink)
474 ML_2 (gtk_frame_set_label, GtkFrame_val, Optstring_val, Unit)
475 ML_3 (gtk_frame_set_label_align, GtkFrame_val, Float_val, Float_val, Unit)
476 ML_2 (gtk_frame_set_shadow_type, GtkFrame_val, Shadow_type_val, Unit)
477 Make_Extractor (gtk_frame_get, GtkFrame_val, label_xalign, copy_double)
478 Make_Extractor (gtk_frame_get, GtkFrame_val, label_yalign, copy_double)
480 /* gtkaspectframe.h */
482 #define GtkAspectFrame_val(val) check_cast(GTK_ASPECT_FRAME,val)
483 ML_5 (gtk_aspect_frame_new, Optstring_val,
484 Float_val, Float_val, Float_val, Bool_val, Val_GtkWidget_sink)
485 ML_5 (gtk_aspect_frame_set, GtkAspectFrame_val, Float_val, Float_val,
486 Float_val, Bool_val, Unit)
487 Make_Extractor (gtk_aspect_frame_get, GtkAspectFrame_val, xalign, copy_double)
488 Make_Extractor (gtk_aspect_frame_get, GtkAspectFrame_val, yalign, copy_double)
489 Make_Extractor (gtk_aspect_frame_get, GtkAspectFrame_val, ratio, copy_double)
490 Make_Extractor (gtk_aspect_frame_get, GtkAspectFrame_val, obey_child, Val_bool)
494 #define GtkHandleBox_val(val) check_cast(GTK_HANDLE_BOX,val)
495 ML_0 (gtk_handle_box_new, Val_GtkWidget_sink)
496 ML_2 (gtk_handle_box_set_shadow_type, GtkHandleBox_val, Shadow_type_val, Unit)
497 ML_2 (gtk_handle_box_set_handle_position, GtkHandleBox_val, Position_val, Unit)
498 ML_2 (gtk_handle_box_set_snap_edge, GtkHandleBox_val, Position_val, Unit)
502 ML_0 (gtk_invisible_new, Val_GtkWidget_sink)
507 #define GtkItem_val(val) check_cast(GTK_ITEM,val)
508 ML_1 (gtk_item_select, GtkItem_val, Unit)
509 ML_1 (gtk_item_deselect, GtkItem_val, Unit)
510 ML_1 (gtk_item_toggle, GtkItem_val, Unit)
514 ML_0 (gtk_list_item_new, Val_GtkWidget_sink)
515 ML_1 (gtk_list_item_new_with_label, String_val, Val_GtkWidget_sink)
519 #define GtkMenuItem_val(val) check_cast(GTK_MENU_ITEM,val)
520 ML_0 (gtk_menu_item_new, Val_GtkWidget_sink)
521 ML_0 (gtk_tearoff_menu_item_new, Val_GtkWidget_sink)
522 ML_1 (gtk_menu_item_new_with_label, String_val, Val_GtkWidget_sink)
523 ML_2 (gtk_menu_item_set_submenu, GtkMenuItem_val, GtkWidget_val, Unit)
524 ML_1 (gtk_menu_item_remove_submenu, GtkMenuItem_val, Unit)
525 ML_2 (gtk_menu_item_set_placement, GtkMenuItem_val,
526 Submenu_placement_val, Unit)
527 ML_3 (gtk_menu_item_configure, GtkMenuItem_val, Bool_val, Bool_val, Unit)
528 ML_1 (gtk_menu_item_activate, GtkMenuItem_val, Unit)
529 ML_1 (gtk_menu_item_right_justify, GtkMenuItem_val, Unit)
531 /* gtkcheckmenuitem.h */
533 #define GtkCheckMenuItem_val(val) check_cast(GTK_CHECK_MENU_ITEM,val)
534 ML_0 (gtk_check_menu_item_new, Val_GtkWidget_sink)
535 ML_1 (gtk_check_menu_item_new_with_label, String_val, Val_GtkWidget_sink)
536 ML_2 (gtk_check_menu_item_set_active, GtkCheckMenuItem_val, Bool_val, Unit)
537 ML_2 (gtk_check_menu_item_set_show_toggle, GtkCheckMenuItem_val,
539 ML_1 (gtk_check_menu_item_toggled, GtkCheckMenuItem_val, Unit)
540 Make_Extractor (gtk_check_menu_item_get, GtkCheckMenuItem_val,
543 /* gtkradiomenuitem.h */
545 #define GtkRadioMenuItem_val(val) check_cast(GTK_RADIO_MENU_ITEM,val)
546 static GSList* item_group_val(value val)
548 return (val == Val_unit ? NULL :
549 gtk_radio_menu_item_group(GtkRadioMenuItem_val(Field(val,0))));
551 ML_1 (gtk_radio_menu_item_new, item_group_val, Val_GtkWidget_sink)
552 ML_2 (gtk_radio_menu_item_new_with_label, item_group_val,
553 String_val, Val_GtkWidget_sink)
554 ML_2 (gtk_radio_menu_item_set_group, GtkRadioMenuItem_val,
555 item_group_val, Unit)
559 #define GtkTreeItem_val(val) check_cast(GTK_TREE_ITEM,val)
560 ML_0 (gtk_tree_item_new, Val_GtkWidget_sink)
561 ML_1 (gtk_tree_item_new_with_label, String_val, Val_GtkWidget_sink)
562 ML_2 (gtk_tree_item_set_subtree, GtkTreeItem_val, GtkWidget_val, Unit)
563 ML_1 (gtk_tree_item_remove_subtree, GtkTreeItem_val, Unit)
564 ML_1 (gtk_tree_item_expand, GtkTreeItem_val, Unit)
565 ML_1 (gtk_tree_item_collapse, GtkTreeItem_val, Unit)
566 ML_1 (GTK_TREE_ITEM_SUBTREE, GtkTreeItem_val, Val_GtkWidget)
570 #define GtkViewport_val(val) check_cast(GTK_VIEWPORT,val)
571 ML_2 (gtk_viewport_new, GtkAdjustment_val, GtkAdjustment_val,
573 ML_1 (gtk_viewport_get_hadjustment, GtkViewport_val, Val_GtkWidget_sink)
574 ML_1 (gtk_viewport_get_vadjustment, GtkViewport_val, Val_GtkWidget)
575 ML_2 (gtk_viewport_set_hadjustment, GtkViewport_val, GtkAdjustment_val, Unit)
576 ML_2 (gtk_viewport_set_vadjustment, GtkViewport_val, GtkAdjustment_val, Unit)
577 ML_2 (gtk_viewport_set_shadow_type, GtkViewport_val, Shadow_type_val, Unit)
581 static void window_unref (GtkObject *w)
583 /* If the window exists and is still not visible, then unreference twice.
584 This should be enough to destroy it. */
585 if (!GTK_OBJECT_DESTROYED(w) && !GTK_WIDGET_VISIBLE(w))
586 gtk_object_unref (w);
587 gtk_object_unref (w);
589 Make_Val_final_pointer_ext (GtkObject, _window, gtk_object_ref, window_unref,
591 #define Val_GtkWidget_window(w) Val_GtkObject_window((GtkObject*)w)
593 #define GtkDialog_val(val) check_cast(GTK_DIALOG,val)
594 ML_0 (gtk_dialog_new, Val_GtkWidget_window)
595 Make_Extractor (GtkDialog, GtkDialog_val, action_area, Val_GtkWidget)
596 Make_Extractor (GtkDialog, GtkDialog_val, vbox, Val_GtkWidget)
598 /* gtkinputdialog.h */
600 ML_0 (gtk_input_dialog_new, Val_GtkWidget_window)
602 /* gtkfileselection.h */
604 #define GtkFileSelection_val(val) check_cast(GTK_FILE_SELECTION,val)
605 ML_1 (gtk_file_selection_new, String_val, Val_GtkWidget_window)
606 ML_2 (gtk_file_selection_set_filename, GtkFileSelection_val, String_val, Unit)
607 ML_1 (gtk_file_selection_get_filename, GtkFileSelection_val, Val_string)
608 ML_1 (gtk_file_selection_show_fileop_buttons, GtkFileSelection_val, Unit)
609 ML_1 (gtk_file_selection_hide_fileop_buttons, GtkFileSelection_val, Unit)
610 Make_Extractor (gtk_file_selection_get, GtkFileSelection_val, ok_button,
612 Make_Extractor (gtk_file_selection_get, GtkFileSelection_val, cancel_button,
614 Make_Extractor (gtk_file_selection_get, GtkFileSelection_val, help_button,
619 #define GtkWindow_val(val) check_cast(GTK_WINDOW,val)
620 ML_1 (gtk_window_new, Window_type_val, Val_GtkWidget_window)
621 ML_2 (gtk_window_set_title, GtkWindow_val, String_val, Unit)
622 ML_3 (gtk_window_set_wmclass, GtkWindow_val, String_val, String_val, Unit)
623 Make_Extractor (gtk_window_get, GtkWindow_val, wmclass_name, Val_optstring)
624 Make_Extractor (gtk_window_get, GtkWindow_val, wmclass_class, Val_optstring)
625 ML_2 (gtk_window_set_focus, GtkWindow_val, GtkWidget_val, Unit)
626 ML_2 (gtk_window_set_default, GtkWindow_val, GtkWidget_val, Unit)
627 ML_4 (gtk_window_set_policy, GtkWindow_val, Bool_val, Bool_val, Bool_val, Unit)
628 Make_Extractor (gtk_window_get, GtkWindow_val, allow_shrink, Val_bool)
629 Make_Extractor (gtk_window_get, GtkWindow_val, allow_grow, Val_bool)
630 Make_Extractor (gtk_window_get, GtkWindow_val, auto_shrink, Val_bool)
631 ML_2 (gtk_window_add_accel_group, GtkWindow_val,
632 GtkAccelGroup_val, Unit)
633 ML_2 (gtk_window_remove_accel_group, GtkWindow_val,
634 GtkAccelGroup_val, Unit)
635 ML_1 (gtk_window_activate_focus, GtkWindow_val, Val_bool)
636 ML_1 (gtk_window_activate_default, GtkWindow_val, Val_bool)
637 ML_2 (gtk_window_set_modal, GtkWindow_val, Bool_val, Unit)
638 ML_3 (gtk_window_set_default_size, GtkWindow_val, Int_val, Int_val, Unit)
639 ML_2 (gtk_window_set_position, GtkWindow_val, Window_position_val, Unit)
640 ML_2 (gtk_window_set_transient_for, GtkWindow_val, GtkWindow_val, Unit)
644 #define GtkColorSelection_val(val) check_cast(GTK_COLOR_SELECTION,val)
645 #define GtkColorSelectionDialog_val(val) check_cast(GTK_COLOR_SELECTION_DIALOG,val)
646 ML_0 (gtk_color_selection_new, Val_GtkWidget_sink)
647 ML_2 (gtk_color_selection_set_update_policy, GtkColorSelection_val,
648 Update_type_val, Unit)
649 ML_2 (gtk_color_selection_set_opacity, GtkColorSelection_val,
651 value ml_gtk_color_selection_set_color (value w, value red, value green,
652 value blue, value opacity)
655 color[0] = Double_val(red);
656 color[1] = Double_val(green);
657 color[2] = Double_val(blue);
658 color[3] = Option_val(opacity,Double_val,0.0);
659 gtk_color_selection_set_color (GtkColorSelection_val(w), color);
662 value ml_gtk_color_selection_get_color (value w)
667 gtk_color_selection_get_color (GtkColorSelection_val(w), color);
668 ret = alloc (4*Double_wosize, Double_array_tag);
669 Store_double_field (ret, 0, color[0]);
670 Store_double_field (ret, 1, color[1]);
671 Store_double_field (ret, 2, color[2]);
672 Store_double_field (ret, 3, color[3]);
675 ML_1 (gtk_color_selection_dialog_new, String_val, Val_GtkWidget_window)
676 Make_Extractor (gtk_color_selection_dialog, GtkColorSelectionDialog_val, ok_button, Val_GtkWidget)
677 Make_Extractor (gtk_color_selection_dialog, GtkColorSelectionDialog_val, cancel_button, Val_GtkWidget)
678 Make_Extractor (gtk_color_selection_dialog, GtkColorSelectionDialog_val, help_button, Val_GtkWidget)
679 Make_Extractor (gtk_color_selection_dialog, GtkColorSelectionDialog_val, colorsel, Val_GtkWidget)
683 #define GtkFontSelection_val(val) \
684 check_cast(GTK_FONT_SELECTION,val)
685 ML_0 (gtk_font_selection_new, Val_GtkWidget_sink)
686 ML_1 (gtk_font_selection_get_font, GtkFontSelection_val,
688 ML_1 (gtk_font_selection_get_font_name, GtkFontSelection_val,
690 ML_2 (gtk_font_selection_set_font_name, GtkFontSelection_val,
691 String_val, Val_bool)
692 ML_9 (gtk_font_selection_set_filter, GtkFontSelection_val,
693 Font_filter_type_val, Flags_Font_type_val,
694 (gchar**), (gchar**), (gchar**),
695 (gchar**), (gchar**), (gchar**), Unit)
696 ML_bc9 (ml_gtk_font_selection_set_filter)
697 ML_1 (gtk_font_selection_get_preview_text, GtkFontSelection_val,
699 ML_2 (gtk_font_selection_set_preview_text, GtkFontSelection_val,
702 #define GtkFontSelectionDialog_val(val) \
703 check_cast(GTK_FONT_SELECTION_DIALOG,val)
704 ML_1 (gtk_font_selection_dialog_new, String_option_val, Val_GtkWidget_window)
706 ML_1 (gtk_font_selection_dialog_get_font, GtkFontSelectionDialog_val,
708 ML_1 (gtk_font_selection_dialog_get_font_name, GtkFontSelectionDialog_val,
710 ML_2 (gtk_font_selection_dialog_set_font_name, GtkFontSelectionDialog_val,
711 String_val, Val_bool)
712 ML_9 (gtk_font_selection_dialog_set_filter, GtkFontSelectionDialog_val,
713 Font_filter_type_val, Flags_Font_type_val,
714 (gchar**), (gchar**), (gchar**),
715 (gchar**), (gchar**), (gchar**), Unit)
716 ML_bc9 (ml_gtk_font_selection_dialog_set_filter)
717 ML_1 (gtk_font_selection_dialog_get_preview_text, GtkFontSelectionDialog_val,
719 ML_2 (gtk_font_selection_dialog_set_preview_text, GtkFontSelectionDialog_val,
722 Make_Extractor (gtk_font_selection_dialog, GtkFontSelectionDialog_val,
723 fontsel, Val_GtkWidget)
724 Make_Extractor (gtk_font_selection_dialog, GtkFontSelectionDialog_val,
725 ok_button, Val_GtkWidget)
726 Make_Extractor (gtk_font_selection_dialog, GtkFontSelectionDialog_val,
727 apply_button, Val_GtkWidget)
728 Make_Extractor (gtk_font_selection_dialog, GtkFontSelectionDialog_val,
729 cancel_button, Val_GtkWidget)
733 ML_1 (gtk_plug_new, XID_val, Val_GtkWidget_window)
737 #define GtkBox_val(val) check_cast(GTK_BOX,val)
738 ML_5 (gtk_box_pack_start, GtkBox_val, GtkWidget_val, Bool_val, Bool_val,
740 ML_5 (gtk_box_pack_end, GtkBox_val, GtkWidget_val, Bool_val, Bool_val,
742 ML_2 (gtk_box_set_homogeneous, GtkBox_val, Bool_val, Unit)
743 ML_2 (gtk_box_set_spacing, GtkBox_val, Int_val, Unit)
744 ML_3 (gtk_box_reorder_child, GtkBox_val, GtkWidget_val, Int_val, Unit)
745 value ml_gtk_box_query_child_packing (value box, value child)
748 unsigned int padding;
749 GtkPackType pack_type;
751 gtk_box_query_child_packing (GtkBox_val(box), GtkWidget_val(child),
752 &expand, &fill, &padding, &pack_type);
753 ret = alloc_small(4,0);
754 Field(ret,0) = Val_bool(expand);
755 Field(ret,1) = Val_bool(fill);
756 Field(ret,2) = Val_int(padding);
757 Field(ret,3) = Val_pack_type(pack_type);
760 value ml_gtk_box_set_child_packing (value vbox, value vchild, value vexpand,
761 value vfill, value vpadding, value vpack)
763 GtkBox *box = GtkBox_val(vbox);
764 GtkWidget *child = GtkWidget_val(vchild);
766 unsigned int padding;
768 gtk_box_query_child_packing (box, child, &expand, &fill, &padding, &pack);
769 gtk_box_set_child_packing (box, child,
770 Option_val(vexpand, Bool_val, expand),
771 Option_val(vfill, Bool_val, fill),
772 Option_val(vpadding, Int_val, padding),
773 Option_val(vpack, Pack_type_val, pack));
776 ML_bc6 (ml_gtk_box_set_child_packing)
778 ML_2 (gtk_hbox_new, Bool_val, Int_val, Val_GtkWidget_sink)
779 ML_2 (gtk_vbox_new, Bool_val, Int_val, Val_GtkWidget_sink)
783 #define GtkButtonBox_val(val) check_cast(GTK_BUTTON_BOX,val)
784 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, spacing, Val_int)
785 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, child_min_width, Val_int)
786 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, child_min_height,
788 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, child_ipad_x, Val_int)
789 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, child_ipad_y, Val_int)
790 Make_Extractor (gtk_button_box_get, GtkButtonBox_val, layout_style,
791 Val_button_box_style)
792 ML_2 (gtk_button_box_set_spacing, GtkButtonBox_val, Int_val, Unit)
793 ML_3 (gtk_button_box_set_child_size, GtkButtonBox_val,
794 Int_val, Int_val, Unit)
795 ML_3 (gtk_button_box_set_child_ipadding, GtkButtonBox_val,
796 Int_val, Int_val, Unit)
797 ML_2 (gtk_button_box_set_layout, GtkButtonBox_val, Button_box_style_val, Unit)
798 ML_2 (gtk_button_box_set_child_size_default, Int_val, Int_val, Unit)
799 ML_2 (gtk_button_box_set_child_ipadding_default, Int_val, Int_val, Unit)
801 ML_0 (gtk_hbutton_box_new, Val_GtkWidget_sink)
802 ML_0 (gtk_vbutton_box_new, Val_GtkWidget_sink)
806 #define GtkList_val(val) check_cast(GTK_LIST,val)
807 ML_0 (gtk_list_new, Val_GtkWidget_sink)
808 value ml_gtk_list_insert_item (value list, value item, value pos)
810 GList *tmp_list = g_list_alloc ();
811 tmp_list->data = GtkWidget_val(item);
812 tmp_list->next = NULL;
813 tmp_list->prev = NULL;
814 gtk_list_insert_items (GtkList_val(list), tmp_list, Int_val(pos));
817 ML_3 (gtk_list_clear_items, GtkList_val, Int_val, Int_val, Unit)
818 ML_2 (gtk_list_select_item, GtkList_val, Int_val, Unit)
819 ML_2 (gtk_list_unselect_item, GtkList_val, Int_val, Unit)
820 ML_2 (gtk_list_select_child, GtkList_val, GtkWidget_val, Unit)
821 ML_2 (gtk_list_unselect_child, GtkList_val, GtkWidget_val, Unit)
822 ML_2 (gtk_list_child_position, GtkList_val, GtkWidget_val, Val_int)
823 ML_2 (gtk_list_set_selection_mode, GtkList_val, Selection_mode_val, Unit)
827 #define GtkCombo_val(val) check_cast(GTK_COMBO,val)
828 ML_0 (gtk_combo_new, Val_GtkWidget_sink)
829 ML_3 (gtk_combo_set_value_in_list, GtkCombo_val,
830 Option_val(arg2, Bool_val, GtkCombo_val(arg1)->value_in_list) Ignore,
831 Option_val(arg3, Bool_val, GtkCombo_val(arg1)->ok_if_empty) Ignore,
833 ML_2 (gtk_combo_set_use_arrows, GtkCombo_val, Bool_val, Unit)
834 ML_2 (gtk_combo_set_use_arrows_always, GtkCombo_val, Bool_val, Unit)
835 ML_2 (gtk_combo_set_case_sensitive, GtkCombo_val, Bool_val, Unit)
836 ML_3 (gtk_combo_set_item_string, GtkCombo_val, GtkItem_val, String_val, Unit)
837 ML_1 (gtk_combo_disable_activate, GtkCombo_val, Unit)
838 Make_Extractor (gtk_combo, GtkCombo_val, entry, Val_GtkWidget)
839 Make_Extractor (gtk_combo, GtkCombo_val, list, Val_GtkWidget)
843 #define GtkStatusbar_val(val) check_cast(GTK_STATUSBAR,val)
844 ML_0 (gtk_statusbar_new, Val_GtkWidget_sink)
845 ML_2 (gtk_statusbar_get_context_id, GtkStatusbar_val, String_val, Val_int)
846 ML_3 (gtk_statusbar_push, GtkStatusbar_val, Int_val, String_val, Val_int)
847 ML_2 (gtk_statusbar_pop, GtkStatusbar_val, Int_val, Unit)
848 ML_3 (gtk_statusbar_remove, GtkStatusbar_val, Int_val, Int_val, Unit)
852 #define GtkGammaCurve_val(val) check_cast(GTK_GAMMA_CURVE,val)
853 ML_0 (gtk_gamma_curve_new, Val_GtkWidget_sink)
854 Make_Extractor (gtk_gamma_curve_get, GtkGammaCurve_val, gamma, copy_double)
858 #define GtkButton_val(val) check_cast(GTK_BUTTON,val)
859 ML_0 (gtk_button_new, Val_GtkWidget_sink)
860 ML_1 (gtk_button_new_with_label, String_val, Val_GtkWidget_sink)
861 ML_1 (gtk_button_pressed, GtkButton_val, Unit)
862 ML_1 (gtk_button_released, GtkButton_val, Unit)
863 ML_1 (gtk_button_clicked, GtkButton_val, Unit)
864 ML_1 (gtk_button_enter, GtkButton_val, Unit)
865 ML_1 (gtk_button_leave, GtkButton_val, Unit)
867 /* gtkoptionmenu.h */
869 #define GtkOptionMenu_val(val) check_cast(GTK_OPTION_MENU,val)
870 ML_0 (gtk_option_menu_new, Val_GtkWidget_sink)
871 ML_1 (gtk_option_menu_get_menu, GtkOptionMenu_val, Val_GtkWidget_sink)
872 ML_2 (gtk_option_menu_set_menu, GtkOptionMenu_val, GtkWidget_val, Unit)
873 ML_1 (gtk_option_menu_remove_menu, GtkOptionMenu_val, Unit)
874 ML_2 (gtk_option_menu_set_history, GtkOptionMenu_val, Int_val, Unit)
876 /* gtktogglebutton.h */
878 #define GtkToggleButton_val(val) check_cast(GTK_TOGGLE_BUTTON,val)
879 ML_0 (gtk_toggle_button_new, Val_GtkWidget_sink)
880 ML_1 (gtk_toggle_button_new_with_label, String_val, Val_GtkWidget_sink)
881 ML_2 (gtk_toggle_button_set_mode, GtkToggleButton_val, Bool_val, Unit)
882 ML_2 (gtk_toggle_button_set_active, GtkToggleButton_val, Bool_val, Unit)
883 ML_1 (gtk_toggle_button_toggled, GtkToggleButton_val, Unit)
884 Make_Extractor (gtk_toggle_button_get, GtkToggleButton_val, active, Val_bool)
886 /* gtkcheckbutton.h */
888 #define GtkCheckButton_val(val) check_cast(GTK_CHECK_BUTTON,val)
889 ML_0 (gtk_check_button_new, Val_GtkWidget_sink)
890 ML_1 (gtk_check_button_new_with_label, String_val, Val_GtkWidget_sink)
892 /* gtkradiobutton.h */
894 #define GtkRadioButton_val(val) check_cast(GTK_RADIO_BUTTON,val)
895 static GSList* button_group_val(value val)
897 return (val == Val_unit ? NULL :
898 gtk_radio_button_group(GtkRadioButton_val(Field(val,0))));
900 ML_1 (gtk_radio_button_new, button_group_val,
902 ML_2 (gtk_radio_button_new_with_label, button_group_val,
903 String_val, Val_GtkWidget_sink)
904 ML_2 (gtk_radio_button_set_group, GtkRadioButton_val, button_group_val, Unit)
908 #define GtkCList_val(val) check_cast(GTK_CLIST,val)
909 ML_1 (gtk_clist_new, Int_val, Val_GtkWidget_sink)
910 ML_1 (gtk_clist_new_with_titles, Insert(Wosize_val(arg1)) (char **),
912 Make_Extractor (gtk_clist_get, GtkCList_val, rows, Val_int)
913 Make_Extractor (gtk_clist_get, GtkCList_val, columns, Val_int)
914 Make_Extractor (gtk_clist_get, GtkCList_val, focus_row, Val_int)
915 ML_2 (gtk_clist_set_hadjustment, GtkCList_val, GtkAdjustment_val, Unit)
916 ML_2 (gtk_clist_set_vadjustment, GtkCList_val, GtkAdjustment_val, Unit)
917 ML_1 (gtk_clist_get_hadjustment, GtkCList_val, Val_GtkAny)
918 ML_1 (gtk_clist_get_vadjustment, GtkCList_val, Val_GtkAny)
919 ML_2 (gtk_clist_set_shadow_type, GtkCList_val, Shadow_type_val, Unit)
920 ML_2 (gtk_clist_set_selection_mode, GtkCList_val, Selection_mode_val, Unit)
921 ML_2 (gtk_clist_set_reorderable, GtkCList_val, Bool_val, Unit)
922 ML_2 (gtk_clist_set_use_drag_icons, GtkCList_val, Bool_val, Unit)
923 ML_3 (gtk_clist_set_button_actions, GtkCList_val, Int_val,
924 (guint8)Flags_Button_action_val, Unit)
925 ML_1 (gtk_clist_freeze, GtkCList_val, Unit)
926 ML_1 (gtk_clist_thaw, GtkCList_val, Unit)
927 ML_1 (gtk_clist_column_titles_show, GtkCList_val, Unit)
928 ML_1 (gtk_clist_column_titles_hide, GtkCList_val, Unit)
929 ML_2 (gtk_clist_column_title_active, GtkCList_val, Int_val, Unit)
930 ML_2 (gtk_clist_column_title_passive, GtkCList_val, Int_val, Unit)
931 ML_1 (gtk_clist_column_titles_active, GtkCList_val, Unit)
932 ML_1 (gtk_clist_column_titles_passive, GtkCList_val, Unit)
933 ML_3 (gtk_clist_set_column_title, GtkCList_val, Int_val, String_val, Unit)
934 ML_2 (gtk_clist_get_column_title, GtkCList_val, Int_val, Val_string)
935 ML_3 (gtk_clist_set_column_widget, GtkCList_val, Int_val, GtkWidget_val, Unit)
936 ML_2 (gtk_clist_get_column_widget, GtkCList_val, Int_val, Val_GtkWidget)
937 ML_3 (gtk_clist_set_column_justification, GtkCList_val, Int_val,
938 Justification_val, Unit)
939 ML_3 (gtk_clist_set_column_visibility, GtkCList_val, Int_val, Bool_val, Unit)
940 ML_3 (gtk_clist_set_column_resizeable, GtkCList_val, Int_val, Bool_val, Unit)
941 ML_3 (gtk_clist_set_column_auto_resize, GtkCList_val, Int_val, Bool_val, Unit)
942 ML_1 (gtk_clist_columns_autosize, GtkCList_val, Unit)
943 ML_2 (gtk_clist_optimal_column_width, GtkCList_val, Int_val, Val_int)
944 ML_3 (gtk_clist_set_column_width, GtkCList_val, Int_val, Int_val, Unit)
945 ML_3 (gtk_clist_set_column_min_width, GtkCList_val, Int_val, Int_val, Unit)
946 ML_3 (gtk_clist_set_column_max_width, GtkCList_val, Int_val, Int_val, Unit)
947 ML_2 (gtk_clist_set_row_height, GtkCList_val, Int_val, Unit)
948 ML_5 (gtk_clist_moveto, GtkCList_val, Int_val, Int_val,
949 Double_val, Double_val, Unit)
950 ML_2 (gtk_clist_row_is_visible, GtkCList_val, Int_val, Val_visibility)
951 ML_3 (gtk_clist_get_cell_type, GtkCList_val, Int_val, Int_val, Val_cell_type)
952 ML_4 (gtk_clist_set_text, GtkCList_val, Int_val, Int_val, Optstring_val, Unit)
953 value ml_gtk_clist_get_text (value clist, value row, value column)
956 if (!gtk_clist_get_text (GtkCList_val(clist), Int_val(row),
957 Int_val(column), &text))
958 invalid_argument ("Gtk.Clist.get_text");
959 return Val_optstring(text);
961 ML_5 (gtk_clist_set_pixmap, GtkCList_val, Int_val, Int_val, GdkPixmap_val,
963 value ml_gtk_clist_get_pixmap (value clist, value row, value column)
968 CAMLlocal2 (vpixmap,vbitmap);
971 if (!gtk_clist_get_pixmap (GtkCList_val(clist), Int_val(row),
972 Int_val(column), &pixmap, &bitmap))
973 invalid_argument ("Gtk.Clist.get_pixmap");
974 vpixmap = Val_option (pixmap, Val_GdkPixmap);
975 vbitmap = Val_option (bitmap, Val_GdkBitmap);
977 ret = alloc_small (2,0);
978 Field(ret,0) = vpixmap;
979 Field(ret,1) = vbitmap;
982 ML_7 (gtk_clist_set_pixtext, GtkCList_val, Int_val, Int_val, String_val,
983 (guint8)Long_val, GdkPixmap_val, GdkBitmap_val, Unit)
984 ML_bc7 (ml_gtk_clist_set_pixtext)
985 ML_3 (gtk_clist_set_foreground, GtkCList_val, Int_val, GdkColor_val, Unit)
986 ML_3 (gtk_clist_set_background, GtkCList_val, Int_val, GdkColor_val, Unit)
987 ML_3 (gtk_clist_get_cell_style, GtkCList_val, Int_val, Int_val, Val_GtkStyle)
988 ML_4 (gtk_clist_set_cell_style, GtkCList_val, Int_val, Int_val, GtkStyle_val,
990 ML_2 (gtk_clist_get_row_style, GtkCList_val, Int_val, Val_GtkStyle)
991 ML_3 (gtk_clist_set_row_style, GtkCList_val, Int_val, GtkStyle_val, Unit)
992 ML_3 (gtk_clist_set_selectable, GtkCList_val, Int_val, Bool_val, Unit)
993 ML_2 (gtk_clist_get_selectable, GtkCList_val, Int_val, Val_bool)
994 ML_5 (gtk_clist_set_shift, GtkCList_val, Int_val, Int_val, Int_val, Int_val,
996 /* ML_2 (gtk_clist_append, GtkCList_val, (char **), Val_int) */
997 ML_3 (gtk_clist_insert, GtkCList_val, Int_val, (char **), Val_int)
998 ML_2 (gtk_clist_remove, GtkCList_val, Int_val, Unit)
999 value ml_gtk_clist_set_row_data (value w, value row, value data)
1001 value *data_p = ml_gtk_root_new (data);
1002 gtk_clist_set_row_data_full (GtkCList_val(w), Int_val(row),
1003 data_p, ml_gtk_root_destroy);
1006 ML_2 (gtk_clist_get_row_data, GtkCList_val, Int_val, *(value*)Check_null)
1007 ML_3 (gtk_clist_select_row, GtkCList_val, Int_val, Int_val, Unit)
1008 ML_3 (gtk_clist_unselect_row, GtkCList_val, Int_val, Int_val, Unit)
1009 ML_1 (gtk_clist_clear, GtkCList_val, Unit)
1010 value ml_gtk_clist_get_selection_info (value clist, value x, value y)
1014 if (!gtk_clist_get_selection_info (GtkCList_val(clist), Int_val(x),
1015 Int_val(y), &row, &column))
1016 invalid_argument ("Gtk.Clist.get_selection_info");
1017 ret = alloc_small (2,0);
1019 Field(ret,1) = column;
1022 ML_1 (gtk_clist_select_all, GtkCList_val, Unit)
1023 ML_1 (gtk_clist_unselect_all, GtkCList_val, Unit)
1024 ML_3 (gtk_clist_swap_rows, GtkCList_val, Int_val, Int_val, Unit)
1025 ML_3 (gtk_clist_row_move, GtkCList_val, Int_val, Int_val, Unit)
1026 ML_2 (gtk_clist_set_sort_column, GtkCList_val, Int_val, Unit)
1027 ML_2 (gtk_clist_set_sort_type, GtkCList_val, Sort_type_val, Unit)
1028 ML_1 (gtk_clist_sort, GtkCList_val, Unit)
1029 ML_2 (gtk_clist_set_auto_sort, GtkCList_val, Bool_val, Unit)
1032 #define GtkCTree_val(val) check_cast(GTK_CTREE,val)
1033 /* Beware: this definition axpects arg1 to be a GtkCTree */
1035 #define GtkCTreeNode_val(val) \
1036 (gtk_ctree_find(GtkCTree_val(arg1),NULL,(GtkCTreeNode*)(val-1)) \
1037 ? (GtkCTreeNode*)(val-1) : (ml_raise_gtk ("Bad GtkCTreeNode"), NULL))
1038 #define Val_GtkCTreeNode Val_addr
1039 ML_2 (gtk_ctree_new, Int_val, Int_val, Val_GtkWidget_sink)
1040 ML_3 (gtk_ctree_new_with_titles, Int_val, Int_val, (char **),
1042 ML_11 (gtk_ctree_insert_node, GtkCTree_val, GtkCTreeNode_val,
1043 GtkCTreeNode_val, (char**), Int_val, GdkPixmap_val, GdkBitmap_val,
1044 GdkPixmap_val, GdkBitmap_val, Bool_val, Bool_val,
1046 ML_2 (gtk_ctree_remove_node, GtkCTree_val, GtkCTreeNode_val, Unit)
1047 ML_2 (gtk_ctree_is_viewable, GtkCTree_val, GtkCTreeNode_val, Val_bool)
1052 #define GtkFixed_val(val) check_cast(GTK_FIXED,val)
1053 ML_0 (gtk_fixed_new, Val_GtkWidget_sink)
1054 ML_4 (gtk_fixed_put, GtkFixed_val, GtkWidget_val, (gint16)Long_val, (gint16)Long_val, Unit)
1055 ML_4 (gtk_fixed_move, GtkFixed_val, GtkWidget_val, (gint16)Long_val, (gint16)Long_val, Unit)
1059 #define GtkLayout_val(val) check_cast(GTK_LAYOUT,val)
1060 ML_2 (gtk_layout_new, GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink)
1061 ML_4 (gtk_layout_put, GtkLayout_val, GtkWidget_val, Int_val, Int_val, Unit)
1062 ML_4 (gtk_layout_move, GtkLayout_val, GtkWidget_val, Int_val, Int_val, Unit)
1063 ML_3 (gtk_layout_set_size, GtkLayout_val, Int_val, Int_val, Unit)
1064 ML_1 (gtk_layout_get_hadjustment, GtkLayout_val, Val_GtkAny)
1065 ML_1 (gtk_layout_get_vadjustment, GtkLayout_val, Val_GtkAny)
1066 ML_2 (gtk_layout_set_hadjustment, GtkLayout_val, GtkAdjustment_val, Unit)
1067 ML_2 (gtk_layout_set_vadjustment, GtkLayout_val, GtkAdjustment_val, Unit)
1068 ML_1 (gtk_layout_freeze, GtkLayout_val, Unit)
1069 ML_1 (gtk_layout_thaw, GtkLayout_val, Unit)
1070 Make_Extractor (gtk_layout_get, GtkLayout_val, width, Val_int)
1071 Make_Extractor (gtk_layout_get, GtkLayout_val, height, Val_int)
1073 /* gtkmenushell.h */
1075 #define GtkMenuShell_val(val) check_cast(GTK_MENU_SHELL,val)
1076 ML_2 (gtk_menu_shell_append, GtkMenuShell_val, GtkWidget_val, Unit)
1077 ML_2 (gtk_menu_shell_prepend, GtkMenuShell_val, GtkWidget_val, Unit)
1078 ML_3 (gtk_menu_shell_insert, GtkMenuShell_val, GtkWidget_val, Int_val, Unit)
1079 ML_1 (gtk_menu_shell_deactivate, GtkMenuShell_val, Unit)
1083 #define GtkMenu_val(val) check_cast(GTK_MENU,val)
1084 ML_0 (gtk_menu_new, Val_GtkWidget_sink)
1085 ML_5 (gtk_menu_popup, GtkMenu_val, GtkWidget_val, GtkWidget_val,
1086 Insert(NULL) Insert(NULL) Int_val, Int_val, Unit)
1087 ML_1 (gtk_menu_popdown, GtkMenu_val, Unit)
1088 ML_1 (gtk_menu_get_active, GtkMenu_val, Val_GtkWidget)
1089 ML_2 (gtk_menu_set_active, GtkMenu_val, Int_val, Unit)
1090 ML_2 (gtk_menu_set_accel_group, GtkMenu_val, GtkAccelGroup_val, Unit)
1091 ML_1 (gtk_menu_get_accel_group, GtkMenu_val, Val_GtkAccelGroup)
1092 ML_1 (gtk_menu_ensure_uline_accel_group, GtkMenu_val, Val_GtkAccelGroup)
1093 value ml_gtk_menu_attach_to_widget (value menu, value widget)
1095 gtk_menu_attach_to_widget (GtkMenu_val(menu), GtkWidget_val(widget), NULL);
1098 ML_1 (gtk_menu_get_attach_widget, GtkMenu_val, Val_GtkWidget)
1099 ML_1 (gtk_menu_detach, GtkMenu_val, Unit)
1103 #define GtkMenuBar_val(val) check_cast(GTK_MENU_BAR,val)
1104 ML_0 (gtk_menu_bar_new, Val_GtkWidget_sink)
1108 #define GtkNotebook_val(val) check_cast(GTK_NOTEBOOK,val)
1109 ML_0 (gtk_notebook_new, Val_GtkWidget_sink)
1111 ML_5 (gtk_notebook_insert_page_menu, GtkNotebook_val, GtkWidget_val,
1112 GtkWidget_val, GtkWidget_val, Int_val, Unit)
1113 ML_2 (gtk_notebook_remove_page, GtkNotebook_val, Int_val, Unit)
1115 ML_2 (gtk_notebook_set_tab_pos, GtkNotebook_val, Position_val, Unit)
1116 ML_2 (gtk_notebook_set_homogeneous_tabs, GtkNotebook_val, Bool_val, Unit)
1117 ML_2 (gtk_notebook_set_show_tabs, GtkNotebook_val, Bool_val, Unit)
1118 ML_2 (gtk_notebook_set_show_border, GtkNotebook_val, Bool_val, Unit)
1119 ML_2 (gtk_notebook_set_scrollable, GtkNotebook_val, Bool_val, Unit)
1120 ML_2 (gtk_notebook_set_tab_border, GtkNotebook_val, Int_val, Unit)
1121 ML_1 (gtk_notebook_popup_enable, GtkNotebook_val, Unit)
1122 ML_1 (gtk_notebook_popup_disable, GtkNotebook_val, Unit)
1124 ML_1 (gtk_notebook_get_current_page, GtkNotebook_val, Val_int)
1125 ML_2 (gtk_notebook_set_page, GtkNotebook_val, Int_val, Unit)
1126 ML_2 (gtk_notebook_get_nth_page, GtkNotebook_val, Int_val, Val_GtkWidget)
1127 ML_2 (gtk_notebook_page_num, GtkNotebook_val, GtkWidget_val, Val_int)
1128 ML_1 (gtk_notebook_next_page, GtkNotebook_val, Unit)
1129 ML_1 (gtk_notebook_prev_page, GtkNotebook_val, Unit)
1131 ML_2 (gtk_notebook_get_tab_label, GtkNotebook_val, GtkWidget_val,
1133 ML_3 (gtk_notebook_set_tab_label, GtkNotebook_val, GtkWidget_val,
1134 GtkWidget_val, Unit)
1135 ML_2 (gtk_notebook_get_menu_label, GtkNotebook_val, GtkWidget_val,
1137 ML_3 (gtk_notebook_set_menu_label, GtkNotebook_val, GtkWidget_val,
1138 GtkWidget_val, Unit)
1139 ML_3 (gtk_notebook_reorder_child, GtkNotebook_val, GtkWidget_val,
1145 Make_OptFlags_val(Packer_options_val)
1147 #define GtkPacker_val(val) check_cast(GTK_PACKER,val)
1148 ML_0 (gtk_packer_new, Val_GtkWidget_sink)
1149 ML_10 (gtk_packer_add, GtkPacker_val, GtkWidget_val,
1150 Option_val(arg3,Side_type_val,GTK_SIDE_TOP) Ignore,
1151 Option_val(arg4,Anchor_type_val,GTK_ANCHOR_CENTER) Ignore,
1152 OptFlags_Packer_options_val,
1153 Option_val(arg6,Int_val,GtkPacker_val(arg1)->default_border_width) Ignore,
1154 Option_val(arg7,Int_val,GtkPacker_val(arg1)->default_pad_x) Ignore,
1155 Option_val(arg8,Int_val,GtkPacker_val(arg1)->default_pad_y) Ignore,
1156 Option_val(arg9,Int_val,GtkPacker_val(arg1)->default_i_pad_x) Ignore,
1157 Option_val(arg10,Int_val,GtkPacker_val(arg1)->default_i_pad_y) Ignore,
1159 ML_bc10 (ml_gtk_packer_add)
1160 ML_5 (gtk_packer_add_defaults, GtkPacker_val, GtkWidget_val,
1161 Option_val(arg3,Side_type_val,GTK_SIDE_TOP) Ignore,
1162 Option_val(arg4,Anchor_type_val,GTK_ANCHOR_CENTER) Ignore,
1163 OptFlags_Packer_options_val, Unit)
1164 ML_10 (gtk_packer_set_child_packing, GtkPacker_val, GtkWidget_val,
1165 Option_val(arg3,Side_type_val,GTK_SIDE_TOP) Ignore,
1166 Option_val(arg4,Anchor_type_val,GTK_ANCHOR_CENTER) Ignore,
1167 OptFlags_Packer_options_val,
1168 Option_val(arg6,Int_val,GtkPacker_val(arg1)->default_border_width) Ignore,
1169 Option_val(arg7,Int_val,GtkPacker_val(arg1)->default_pad_x) Ignore,
1170 Option_val(arg8,Int_val,GtkPacker_val(arg1)->default_pad_y) Ignore,
1171 Option_val(arg9,Int_val,GtkPacker_val(arg1)->default_i_pad_x) Ignore,
1172 Option_val(arg10,Int_val,GtkPacker_val(arg1)->default_i_pad_y) Ignore,
1174 ML_bc10 (ml_gtk_packer_set_child_packing)
1175 ML_3 (gtk_packer_reorder_child, GtkPacker_val, GtkWidget_val,
1177 ML_2 (gtk_packer_set_spacing, GtkPacker_val, Int_val, Unit)
1178 value ml_gtk_packer_set_defaults (value w, value border_width,
1179 value pad_x, value pad_y,
1180 value i_pad_x, value i_pad_y)
1182 GtkPacker *p = GtkPacker_val(w);
1183 if (Is_block(border_width))
1184 gtk_packer_set_default_border_width (p,Int_val(Field(border_width,0)));
1185 if (Is_block(pad_x) || Is_block(pad_y))
1186 gtk_packer_set_default_pad
1187 (p, Option_val(pad_x,Int_val,p->default_pad_x),
1188 Option_val(pad_y,Int_val,p->default_pad_y));
1189 if (Is_block(i_pad_x) || Is_block(i_pad_y))
1190 gtk_packer_set_default_ipad
1191 (p, Option_val(pad_x,Int_val,p->default_i_pad_x),
1192 Option_val(pad_y,Int_val,p->default_i_pad_y));
1195 ML_bc6 (ml_gtk_packer_set_defaults)
1199 #define GtkPaned_val(val) check_cast(GTK_PANED,val)
1200 ML_0 (gtk_hpaned_new, Val_GtkWidget_sink)
1201 ML_0 (gtk_vpaned_new, Val_GtkWidget_sink)
1202 ML_2 (gtk_paned_add1, GtkPaned_val, GtkWidget_val, Unit)
1203 ML_2 (gtk_paned_add2, GtkPaned_val, GtkWidget_val, Unit)
1204 ML_2 (gtk_paned_set_handle_size, GtkPaned_val, (gint16)Int_val, Unit)
1205 ML_2 (gtk_paned_set_gutter_size, GtkPaned_val, (gint16)Int_val, Unit)
1206 Make_Extractor (gtk_paned, GtkPaned_val, child1, Val_GtkWidget)
1207 Make_Extractor (gtk_paned, GtkPaned_val, child2, Val_GtkWidget)
1208 Make_Extractor (gtk_paned, GtkPaned_val, handle_size, Val_int)
1209 Make_Extractor (gtk_paned, GtkPaned_val, gutter_size, Val_int)
1211 /* gtkscrolledwindow.h */
1213 #define GtkScrolledWindow_val(val) check_cast(GTK_SCROLLED_WINDOW,val)
1214 ML_2 (gtk_scrolled_window_new, GtkAdjustment_val ,GtkAdjustment_val,
1216 ML_2 (gtk_scrolled_window_set_hadjustment, GtkScrolledWindow_val ,
1217 GtkAdjustment_val, Unit)
1218 ML_2 (gtk_scrolled_window_set_vadjustment, GtkScrolledWindow_val ,
1219 GtkAdjustment_val, Unit)
1220 ML_1 (gtk_scrolled_window_get_hadjustment, GtkScrolledWindow_val,
1222 ML_1 (gtk_scrolled_window_get_vadjustment, GtkScrolledWindow_val,
1224 ML_3 (gtk_scrolled_window_set_policy, GtkScrolledWindow_val,
1225 Policy_type_val, Policy_type_val, Unit)
1226 Make_Extractor (gtk_scrolled_window_get, GtkScrolledWindow_val,
1227 hscrollbar_policy, Val_policy_type)
1228 Make_Extractor (gtk_scrolled_window_get, GtkScrolledWindow_val,
1229 vscrollbar_policy, Val_policy_type)
1230 ML_2 (gtk_scrolled_window_set_placement, GtkScrolledWindow_val,
1231 Corner_type_val, Unit)
1232 ML_2 (gtk_scrolled_window_add_with_viewport, GtkScrolledWindow_val,
1233 GtkWidget_val, Unit)
1237 #define GtkSocket_val(val) check_cast(GTK_SOCKET,val)
1238 ML_0 (gtk_socket_new, Val_GtkWidget_sink)
1239 ML_2 (gtk_socket_steal, GtkSocket_val, XID_val, Unit)
1243 #define GtkTable_val(val) check_cast(GTK_TABLE,val)
1244 ML_3 (gtk_table_new, Int_val, Int_val, Int_val, Val_GtkWidget_sink)
1245 ML_10 (gtk_table_attach, GtkTable_val, GtkWidget_val,
1246 Int_val, Int_val, Int_val, Int_val,
1247 Flags_Attach_options_val, Flags_Attach_options_val,
1248 Int_val, Int_val, Unit)
1249 ML_bc10 (ml_gtk_table_attach)
1250 ML_3 (gtk_table_set_row_spacing, GtkTable_val, Int_val, Int_val, Unit)
1251 ML_3 (gtk_table_set_col_spacing, GtkTable_val, Int_val, Int_val, Unit)
1252 ML_2 (gtk_table_set_row_spacings, GtkTable_val, Int_val, Unit)
1253 ML_2 (gtk_table_set_col_spacings, GtkTable_val, Int_val, Unit)
1254 ML_2 (gtk_table_set_homogeneous, GtkTable_val, Bool_val, Unit)
1258 #define GtkToolbar_val(val) check_cast(GTK_TOOLBAR,val)
1259 ML_2 (gtk_toolbar_new, Orientation_val, Toolbar_style_val, Val_GtkWidget_sink)
1260 ML_2 (gtk_toolbar_insert_space, GtkToolbar_val, Int_val, Unit)
1261 ML_7 (gtk_toolbar_insert_element, GtkToolbar_val, Toolbar_child_val,
1262 Insert(NULL) Optstring_val, Optstring_val, Optstring_val, GtkWidget_val,
1263 Insert(NULL) Insert(NULL) Int_val, Val_GtkWidget)
1264 ML_bc7 (ml_gtk_toolbar_insert_element)
1265 ML_5 (gtk_toolbar_insert_widget, GtkToolbar_val, GtkWidget_val,
1266 Optstring_val, Optstring_val, Int_val, Unit)
1267 ML_2 (gtk_toolbar_set_orientation, GtkToolbar_val, Orientation_val, Unit)
1268 ML_2 (gtk_toolbar_set_style, GtkToolbar_val, Toolbar_style_val, Unit)
1269 ML_2 (gtk_toolbar_set_space_size, GtkToolbar_val, Int_val, Unit)
1270 ML_2 (gtk_toolbar_set_space_style, GtkToolbar_val, Toolbar_space_style_val, Unit)
1271 ML_2 (gtk_toolbar_set_tooltips, GtkToolbar_val, Bool_val, Unit)
1272 ML_2 (gtk_toolbar_set_button_relief, GtkToolbar_val, Relief_style_val, Unit)
1273 ML_1 (gtk_toolbar_get_button_relief, GtkToolbar_val, Val_relief_style)
1277 #define GtkTree_val(val) check_cast(GTK_TREE,val)
1278 ML_0 (gtk_tree_new, Val_GtkWidget_sink)
1279 ML_3 (gtk_tree_insert, GtkTree_val, GtkWidget_val, Int_val, Unit)
1280 ML_3 (gtk_tree_clear_items, GtkTree_val, Int_val, Int_val, Unit)
1281 ML_2 (gtk_tree_select_item, GtkTree_val, Int_val, Unit)
1282 ML_2 (gtk_tree_unselect_item, GtkTree_val, Int_val, Unit)
1283 ML_2 (gtk_tree_child_position, GtkTree_val, GtkWidget_val, Val_int)
1284 ML_2 (gtk_tree_set_selection_mode, GtkTree_val, Selection_mode_val, Unit)
1285 ML_2 (gtk_tree_set_view_mode, GtkTree_val, Tree_view_mode_val, Unit)
1286 ML_2 (gtk_tree_set_view_lines, GtkTree_val, Bool_val, Unit)
1288 static value val_gtkany (gpointer p) { return Val_GtkAny(p); }
1289 value ml_gtk_tree_selection (value tree)
1291 GList *selection = GTK_TREE_SELECTION(GtkTree_val(tree));
1292 return Val_GList(selection, val_gtkany);
1294 static gpointer gtkobject_val (value val) { return GtkObject_val(val); }
1295 value ml_gtk_tree_remove_items (value tree, value items)
1297 GList *items_list = GList_val (items, gtkobject_val);
1298 gtk_tree_remove_items (GtkTree_val(tree), items_list);
1304 #define GtkCalendar_val(val) check_cast(GTK_CALENDAR,val)
1305 ML_0 (gtk_calendar_new, Val_GtkWidget_sink)
1306 ML_3 (gtk_calendar_select_month, GtkCalendar_val, Int_val, Int_val, Unit)
1307 ML_2 (gtk_calendar_select_day, GtkCalendar_val, Int_val, Unit)
1308 ML_2 (gtk_calendar_mark_day, GtkCalendar_val, Int_val, Unit)
1309 ML_2 (gtk_calendar_unmark_day, GtkCalendar_val, Int_val, Unit)
1310 ML_1 (gtk_calendar_clear_marks, GtkCalendar_val, Unit)
1311 Make_Flags_val (Calendar_display_options_val)
1312 ML_2 (gtk_calendar_display_options, GtkCalendar_val,
1313 Flags_Calendar_display_options_val, Unit)
1314 value ml_gtk_calendar_get_date (value w)
1316 guint year, month, day;
1319 gtk_calendar_get_date (GtkCalendar_val(w), &year, &month, &day);
1320 ret = alloc_small (3, 0);
1321 Field(ret,0) = Val_int(year);
1322 Field(ret,1) = Val_int(month);
1323 Field(ret,2) = Val_int(day);
1326 ML_1 (gtk_calendar_freeze, GtkCalendar_val, Unit)
1327 ML_1 (gtk_calendar_thaw, GtkCalendar_val, Unit)
1329 /* gtkdrawingarea.h */
1331 #define GtkDrawingArea_val(val) check_cast(GTK_DRAWING_AREA,val)
1332 ML_0 (gtk_drawing_area_new, Val_GtkWidget_sink)
1333 ML_3 (gtk_drawing_area_size, GtkDrawingArea_val, Int_val, Int_val, Unit)
1337 #define GtkEditable_val(val) check_cast(GTK_EDITABLE,val)
1338 ML_3 (gtk_editable_select_region, GtkEditable_val, Int_val, Int_val, Unit)
1339 value ml_gtk_editable_insert_text (value w, value s, value pos)
1341 int position = Int_val(pos);
1342 gtk_editable_insert_text (GtkEditable_val(w), String_val(s),
1343 string_length(s), &position);
1344 return Val_int(position);
1346 ML_3 (gtk_editable_delete_text, GtkEditable_val, Int_val, Int_val, Unit)
1347 ML_3 (gtk_editable_get_chars, GtkEditable_val, Int_val, Int_val,
1348 copy_string_and_free)
1349 ML_1 (gtk_editable_cut_clipboard, GtkEditable_val, Unit)
1350 ML_1 (gtk_editable_copy_clipboard, GtkEditable_val, Unit)
1351 ML_1 (gtk_editable_paste_clipboard, GtkEditable_val, Unit)
1352 ML_3 (gtk_editable_claim_selection, GtkEditable_val, Bool_val, Int_val, Unit)
1353 ML_1 (gtk_editable_delete_selection, GtkEditable_val, Unit)
1354 ML_1 (gtk_editable_changed, GtkEditable_val, Unit)
1355 ML_2 (gtk_editable_set_position, GtkEditable_val, Int_val, Unit)
1356 ML_1 (gtk_editable_get_position, GtkEditable_val, Val_int)
1357 ML_2 (gtk_editable_set_editable, GtkEditable_val, Bool_val, Unit)
1358 Make_Extractor (gtk_editable, GtkEditable_val, selection_start_pos, Val_int)
1359 Make_Extractor (gtk_editable, GtkEditable_val, selection_end_pos, Val_int)
1360 Make_Extractor (gtk_editable, GtkEditable_val, has_selection, Val_bool)
1364 #define GtkEntry_val(val) check_cast(GTK_ENTRY,val)
1365 ML_0 (gtk_entry_new, Val_GtkWidget_sink)
1366 ML_1 (gtk_entry_new_with_max_length, (gint16)Long_val, Val_GtkWidget_sink)
1367 ML_2 (gtk_entry_set_text, GtkEntry_val, String_val, Unit)
1368 ML_2 (gtk_entry_append_text, GtkEntry_val, String_val, Unit)
1369 ML_2 (gtk_entry_prepend_text, GtkEntry_val, String_val, Unit)
1370 ML_1 (gtk_entry_get_text, GtkEntry_val, Val_string)
1371 ML_3 (gtk_entry_select_region, GtkEntry_val, Int_val, Int_val, Unit)
1372 ML_2 (gtk_entry_set_visibility, GtkEntry_val, Bool_val, Unit)
1373 ML_2 (gtk_entry_set_max_length, GtkEntry_val, (gint16)Long_val, Unit)
1374 Make_Extractor (GtkEntry, GtkEntry_val, text_length, Val_int)
1376 /* gtkspinbutton.h */
1378 #define GtkSpinButton_val(val) check_cast(GTK_SPIN_BUTTON,val)
1379 ML_3 (gtk_spin_button_new, GtkAdjustment_val,
1380 Float_val, Int_val, Val_GtkWidget_sink)
1381 ML_2 (gtk_spin_button_set_adjustment, GtkSpinButton_val, GtkAdjustment_val,
1383 ML_1 (gtk_spin_button_get_adjustment, GtkSpinButton_val, Val_GtkAny)
1384 ML_2 (gtk_spin_button_set_digits, GtkSpinButton_val, Int_val, Unit)
1385 ML_1 (gtk_spin_button_get_value_as_float, GtkSpinButton_val, copy_double)
1386 ML_2 (gtk_spin_button_set_value, GtkSpinButton_val, Float_val, Unit)
1387 ML_2 (gtk_spin_button_set_update_policy, GtkSpinButton_val,
1388 Update_type_val, Unit)
1389 ML_2 (gtk_spin_button_set_numeric, GtkSpinButton_val, Bool_val, Unit)
1390 ML_2 (gtk_spin_button_spin, GtkSpinButton_val,
1391 Insert (Is_long(arg2) ? Spin_type_val(arg2) : GTK_SPIN_USER_DEFINED)
1392 (Is_long(arg2) ? 0.0 : Float_val(Field(arg2,1))) Ignore, Unit)
1393 ML_2 (gtk_spin_button_set_wrap, GtkSpinButton_val, Bool_val, Unit)
1394 ML_2 (gtk_spin_button_set_shadow_type, GtkSpinButton_val, Shadow_type_val, Unit)
1395 ML_2 (gtk_spin_button_set_snap_to_ticks, GtkSpinButton_val, Bool_val, Unit)
1396 ML_4 (gtk_spin_button_configure, GtkSpinButton_val, GtkAdjustment_val,
1397 Float_val, Int_val, Unit)
1398 ML_1 (gtk_spin_button_update, GtkSpinButton_val, Unit)
1402 #define GtkText_val(val) check_cast(GTK_TEXT,val)
1403 ML_2 (gtk_text_new, GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink)
1404 ML_2 (gtk_text_set_word_wrap, GtkText_val, Bool_val, Unit)
1405 ML_2 (gtk_text_set_line_wrap, GtkText_val, Bool_val, Unit)
1406 ML_3 (gtk_text_set_adjustments, GtkText_val,
1407 Option_val(arg2,GtkAdjustment_val,GtkText_val(arg1)->hadj) Ignore,
1408 Option_val(arg3,GtkAdjustment_val,GtkText_val(arg1)->vadj) Ignore,
1410 Make_Extractor (gtk_text_get, GtkText_val, hadj, Val_GtkWidget)
1411 Make_Extractor (gtk_text_get, GtkText_val, vadj, Val_GtkWidget)
1412 ML_2 (gtk_text_set_point, GtkText_val, Int_val, Unit)
1413 ML_1 (gtk_text_get_point, GtkText_val, Val_int)
1414 ML_1 (gtk_text_get_length, GtkText_val, Val_int)
1415 ML_1 (gtk_text_freeze, GtkText_val, Unit)
1416 ML_1 (gtk_text_thaw, GtkText_val, Unit)
1417 value ml_gtk_text_insert (value text, value font, value fore, value back,
1420 gtk_text_insert (GtkText_val(text),
1421 Option_val(font,GdkFont_val,NULL),
1422 Option_val(fore,GdkColor_val,NULL),
1423 Option_val(back,GdkColor_val,NULL),
1424 String_val(str), string_length(str));
1427 ML_2 (gtk_text_forward_delete, GtkText_val, Int_val, Val_int)
1428 ML_2 (gtk_text_backward_delete, GtkText_val, Int_val, Val_int)
1432 #define GtkMisc_val(val) check_cast(GTK_MISC,val)
1433 ML_3 (gtk_misc_set_alignment, GtkMisc_val, Double_val, Double_val, Unit)
1434 ML_3 (gtk_misc_set_padding, GtkMisc_val, Int_val, Int_val, Unit)
1435 Make_Extractor (gtk_misc_get, GtkMisc_val, xalign, copy_double)
1436 Make_Extractor (gtk_misc_get, GtkMisc_val, yalign, copy_double)
1437 Make_Extractor (gtk_misc_get, GtkMisc_val, xpad, Val_int)
1438 Make_Extractor (gtk_misc_get, GtkMisc_val, ypad, Val_int)
1442 #define GtkArrow_val(val) check_cast(GTK_ARROW,val)
1443 ML_2 (gtk_arrow_new, Arrow_type_val, Shadow_type_val, Val_GtkWidget_sink)
1444 ML_3 (gtk_arrow_set, GtkArrow_val, Arrow_type_val, Shadow_type_val, Unit)
1448 #define GtkImage_val(val) check_cast(GTK_IMAGE,val)
1449 ML_2 (gtk_image_new, GdkImage_val,
1450 Option_val (arg2, GdkBitmap_val, NULL) Ignore, Val_GtkWidget_sink)
1451 ML_3 (gtk_image_set, GtkImage_val, GdkImage_val,
1452 Option_val (arg2, GdkBitmap_val, NULL) Ignore, Unit)
1456 #define GtkLabel_val(val) check_cast(GTK_LABEL,val)
1457 ML_1 (gtk_label_new, String_val, Val_GtkWidget_sink)
1458 ML_2 (gtk_label_set_text, GtkLabel_val, String_val, Unit)
1459 ML_2 (gtk_label_set_pattern, GtkLabel_val, String_val, Unit)
1460 ML_2 (gtk_label_set_justify, GtkLabel_val, Justification_val, Unit)
1461 ML_2 (gtk_label_set_line_wrap, GtkLabel_val, Bool_val, Unit)
1462 Make_Extractor (gtk_label_get, GtkLabel_val, label, Val_string)
1464 /* gtktipsquery.h */
1466 #define GtkTipsQuery_val(val) check_cast(GTK_TIPS_QUERY,val)
1467 ML_0 (gtk_tips_query_new, Val_GtkWidget_sink)
1468 ML_1 (gtk_tips_query_start_query, GtkTipsQuery_val, Unit)
1469 ML_1 (gtk_tips_query_stop_query, GtkTipsQuery_val, Unit)
1470 ML_2 (gtk_tips_query_set_caller, GtkTipsQuery_val, GtkWidget_val, Unit)
1471 ML_3 (gtk_tips_query_set_labels, GtkTipsQuery_val,
1472 String_val, String_val, Unit)
1473 value ml_gtk_tips_query_set_emit_always (value w, value arg)
1475 GtkTipsQuery_val(w)->emit_always = Bool_val(arg);
1478 Make_Extractor (gtk_tips_query_get, GtkTipsQuery_val, emit_always, Val_bool)
1479 Make_Extractor (gtk_tips_query_get, GtkTipsQuery_val, caller, Val_GtkWidget)
1480 Make_Extractor (gtk_tips_query_get, GtkTipsQuery_val, label_inactive,
1482 Make_Extractor (gtk_tips_query_get, GtkTipsQuery_val, label_no_tip,
1487 #define GtkPixmap_val(val) check_cast(GTK_PIXMAP,val)
1488 ML_2 (gtk_pixmap_new, GdkPixmap_val,
1489 Option_val (arg2, GdkBitmap_val, NULL) Ignore,
1491 value ml_gtk_pixmap_set (value val, value pixmap, value mask)
1493 GtkPixmap *w = GtkPixmap_val(val);
1494 gtk_pixmap_set (w, Option_val(pixmap,GdkPixmap_val,w->pixmap),
1495 Option_val(mask,GdkBitmap_val,w->mask));
1498 Make_Extractor (GtkPixmap, GtkPixmap_val, pixmap, Val_GdkPixmap)
1499 Make_Extractor (GtkPixmap, GtkPixmap_val, mask, Val_GdkBitmap)
1503 #define GtkPreview_val(val) GTK_PREVIEW(Pointer_val(val))
1504 ML_1 (gtk_preview_new, Preview_val, Val_GtkWidget_sink)
1505 ML_3 (gtk_preview_size, GtkPreview_val, Int_val, Int_val, Unit)
1506 ML_9 (gtk_preview_put, GtkPreview_val, GdkWindow_val, GdkGC_val,
1507 Int_val, Int_val, Int_val, Int_val, Int_val, Int_val, Unit)
1508 ML_bc9 (ml_gtk_preview_put)
1513 #define GtkProgress_val(val) check_cast(GTK_PROGRESS,val)
1514 ML_2 (gtk_progress_set_show_text, GtkProgress_val, Bool_val, Unit)
1515 ML_3 (gtk_progress_set_text_alignment, GtkProgress_val,
1516 Option_val(arg2,Float_val,(GtkProgress_val(arg1))->x_align) Ignore,
1517 Option_val(arg3,Float_val,(GtkProgress_val(arg1))->y_align) Ignore, Unit)
1518 ML_2 (gtk_progress_set_format_string, GtkProgress_val, String_val, Unit)
1519 ML_2 (gtk_progress_set_adjustment, GtkProgress_val, GtkAdjustment_val, Unit)
1520 ML_4 (gtk_progress_configure, GtkProgress_val,
1521 Float_val, Float_val, Float_val, Unit)
1522 ML_2 (gtk_progress_set_percentage, GtkProgress_val, Float_val, Unit)
1523 ML_2 (gtk_progress_set_value, GtkProgress_val, Float_val, Unit)
1524 ML_1 (gtk_progress_get_value, GtkProgress_val, copy_double)
1525 ML_1 (gtk_progress_get_current_percentage, GtkProgress_val, copy_double)
1526 ML_2 (gtk_progress_set_activity_mode, GtkProgress_val, Bool_val, Unit)
1527 ML_1 (gtk_progress_get_current_text, GtkProgress_val, Val_string)
1528 Make_Extractor (gtk_progress_get, GtkProgress_val, adjustment,
1531 /* gtkprogressbar.h */
1533 #define GtkProgressBar_val(val) check_cast(GTK_PROGRESS_BAR,val)
1534 ML_0 (gtk_progress_bar_new, Val_GtkWidget_sink)
1535 ML_1 (gtk_progress_bar_new_with_adjustment, GtkAdjustment_val,
1537 ML_2 (gtk_progress_bar_set_bar_style, GtkProgressBar_val,
1538 Progress_bar_style_val, Unit)
1539 ML_2 (gtk_progress_bar_set_discrete_blocks, GtkProgressBar_val, Int_val, Unit)
1540 ML_2 (gtk_progress_bar_set_activity_step, GtkProgressBar_val, Int_val, Unit)
1541 ML_2 (gtk_progress_bar_set_activity_blocks, GtkProgressBar_val, Int_val, Unit)
1542 ML_2 (gtk_progress_bar_set_orientation, GtkProgressBar_val,
1543 Progress_bar_orientation_val, Unit)
1544 /* ML_2 (gtk_progress_bar_update, GtkProgressBar_val, Float_val, Unit) */
1548 #define GtkRange_val(val) check_cast(GTK_RANGE,val)
1549 ML_1 (gtk_range_get_adjustment, GtkRange_val, Val_GtkAny)
1550 ML_2 (gtk_range_set_adjustment, GtkRange_val, GtkAdjustment_val, Unit)
1551 ML_2 (gtk_range_set_update_policy, GtkRange_val, Update_type_val, Unit)
1555 #define GtkScale_val(val) check_cast(GTK_SCALE,val)
1556 ML_2 (gtk_scale_set_digits, GtkScale_val, Int_val, Unit)
1557 ML_2 (gtk_scale_set_draw_value, GtkScale_val, Bool_val, Unit)
1558 ML_2 (gtk_scale_set_value_pos, GtkScale_val, Position_val, Unit)
1559 ML_1 (gtk_scale_get_value_width, GtkScale_val, Val_int)
1560 ML_1 (gtk_scale_draw_value, GtkScale_val, Unit)
1561 ML_1 (gtk_hscale_new, GtkAdjustment_val, Val_GtkWidget_sink)
1562 ML_1 (gtk_vscale_new, GtkAdjustment_val, Val_GtkWidget_sink)
1564 /* gtkscrollbar.h */
1566 ML_1 (gtk_hscrollbar_new, GtkAdjustment_val, Val_GtkWidget_sink)
1567 ML_1 (gtk_vscrollbar_new, GtkAdjustment_val, Val_GtkWidget_sink)
1571 #define GtkRuler_val(val) check_cast(GTK_RULER,val)
1572 ML_2 (gtk_ruler_set_metric, GtkRuler_val, Metric_type_val, Unit)
1573 ML_5 (gtk_ruler_set_range, GtkRuler_val, Float_val,
1574 Float_val, Float_val, Float_val, Unit)
1575 Make_Extractor (gtk_ruler_get, GtkRuler_val, lower, copy_double)
1576 Make_Extractor (gtk_ruler_get, GtkRuler_val, upper, copy_double)
1577 Make_Extractor (gtk_ruler_get, GtkRuler_val, position, copy_double)
1578 Make_Extractor (gtk_ruler_get, GtkRuler_val, max_size, copy_double)
1579 ML_1 (gtk_ruler_draw_ticks, GtkRuler_val, Unit)
1580 ML_1 (gtk_ruler_draw_pos, GtkRuler_val, Unit)
1581 ML_0 (gtk_hruler_new, Val_GtkWidget_sink)
1582 ML_0 (gtk_vruler_new, Val_GtkWidget_sink)
1584 /* gtk[hv]separator.h */
1586 ML_0 (gtk_hseparator_new, Val_GtkWidget_sink)
1587 ML_0 (gtk_vseparator_new, Val_GtkWidget_sink)
1591 value ml_gtk_init (value argv)
1594 int argc = Wosize_val(argv), i;
1597 copy = (argc ? alloc (argc, Abstract_tag) : Atom(0));
1598 for (i = 0; i < argc; i++) Field(copy,i) = Field(argv,i);
1599 gtk_init (&argc, (char ***)©);
1601 argv = (argc ? alloc (argc, 0) : Atom(0));
1602 for (i = 0; i < argc; i++) modify(&Field(argv,i), Field(copy,i));
1605 ML_1 (gtk_exit, Int_val, Unit)
1606 ML_0 (gtk_set_locale, Val_string)
1607 ML_0 (gtk_main, Unit)
1608 ML_1 (gtk_main_iteration_do, Bool_val, Val_bool)
1609 ML_0 (gtk_main_quit, Unit)
1610 ML_1 (gtk_grab_add, GtkWidget_val, Unit)
1611 ML_1 (gtk_grab_remove, GtkWidget_val, Unit)
1612 ML_0 (gtk_grab_get_current, Val_GtkWidget)
1613 value ml_gtk_get_version (value unit)
1615 value ret = alloc_small(3,0);
1616 Field(ret,0) = Val_int(gtk_major_version);
1617 Field(ret,1) = Val_int(gtk_minor_version);
1618 Field(ret,2) = Val_int(gtk_micro_version);
1624 void ml_gtk_callback_marshal (GtkObject *object, gpointer data,
1625 guint nargs, GtkArg *args)
1627 value vargs = alloc_small(3,0);
1630 Field(vargs,0) = (value) object;
1631 Field(vargs,1) = Val_int(nargs);
1632 Field(vargs,2) = (value) args;
1634 callback (*(value*)data, vargs);
1636 Field(vargs,0) = Val_int(-1);
1637 Field(vargs,1) = Val_int(-1);
1641 value ml_gtk_arg_shift (GtkArg *args, value index)
1643 return (value) (&args[Int_val(index)]);
1646 value ml_gtk_arg_get_type (GtkArg *arg)
1648 return Val_int (arg->type);
1651 value ml_gtk_arg_get (GtkArg *arg)
1656 GtkFundamentalType type = GTK_FUNDAMENTAL_TYPE(arg->type);
1662 tmp = Int_val(GTK_VALUE_CHAR(*arg));
1666 tmp = Val_bool(GTK_VALUE_BOOL(*arg));
1671 case GTK_TYPE_FLAGS:
1673 tmp = Val_int (GTK_VALUE_INT(*arg)); break;
1675 case GTK_TYPE_ULONG:
1677 tmp = Val_int (GTK_VALUE_LONG(*arg)); break;
1678 case GTK_TYPE_FLOAT:
1680 tmp = copy_double ((double)GTK_VALUE_FLOAT(*arg)); break;
1681 case GTK_TYPE_DOUBLE:
1683 tmp = copy_double (GTK_VALUE_DOUBLE(*arg)); break;
1684 case GTK_TYPE_STRING:
1686 tmp = Val_option (GTK_VALUE_STRING(*arg), copy_string); break;
1687 case GTK_TYPE_OBJECT:
1689 tmp = Val_option (GTK_VALUE_OBJECT(*arg), Val_GtkObject); break;
1690 case GTK_TYPE_BOXED:
1691 case GTK_TYPE_POINTER:
1693 tmp = Val_option (GTK_VALUE_POINTER(*arg), Val_pointer); break;
1695 tag = -1; ret = Val_unit;
1698 ret = alloc_small(1,tag);
1704 value ml_gtk_arg_set_retloc (GtkArg *arg, value val)
1706 value type = Fundamental_type_val(Is_block(val) ? Field(val,0) : val);
1707 value data = (Is_block(val) ? Field(val,1) : 0);
1708 if (GTK_FUNDAMENTAL_TYPE(arg->type) != GTK_TYPE_POINTER
1709 && GTK_FUNDAMENTAL_TYPE(arg->type) != type)
1710 ml_raise_gtk ("GtkArgv.Arg.set : argument type mismatch");
1712 case GTK_TYPE_CHAR: *GTK_RETLOC_CHAR(*arg) = Int_val(data); break;
1713 case GTK_TYPE_BOOL: *GTK_RETLOC_BOOL(*arg) = Int_val(data); break;
1715 case GTK_TYPE_ENUM: *GTK_RETLOC_INT(*arg) = Int_val(data); break;
1717 case GTK_TYPE_FLAGS: *GTK_RETLOC_UINT(*arg) = Int32_val(data); break;
1719 case GTK_TYPE_ULONG: *GTK_RETLOC_LONG(*arg) = Nativeint_val(data); break;
1720 case GTK_TYPE_FLOAT: *GTK_RETLOC_FLOAT(*arg) = Float_val(data); break;
1721 case GTK_TYPE_DOUBLE: *GTK_RETLOC_DOUBLE(*arg) = Double_val(data); break;
1722 case GTK_TYPE_STRING:
1723 *GTK_RETLOC_STRING(*arg) = Option_val(data, String_val, NULL);
1725 case GTK_TYPE_BOXED:
1726 case GTK_TYPE_POINTER:
1727 case GTK_TYPE_OBJECT:
1728 *GTK_RETLOC_POINTER(*arg) = Option_val(data, Pointer_val, NULL);
1735 value ml_gtk_arg_get_char (GtkArg *arg)
1737 if (GTK_FUNDAMENTAL_TYPE(arg->type) != GTK_TYPE_CHAR)
1738 ml_raise_gtk ("argument type mismatch");
1739 return Val_char (GTK_VALUE_CHAR(*arg));
1742 value ml_gtk_arg_get_bool (GtkArg *arg)
1744 if (GTK_FUNDAMENTAL_TYPE(arg->type) != GTK_TYPE_BOOL)
1745 ml_raise_gtk ("argument type mismatch");
1746 return Val_bool (GTK_VALUE_BOOL(*arg));
1749 value ml_gtk_arg_get_int (GtkArg *arg)
1751 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1754 return Val_int (GTK_VALUE_INT(*arg));
1756 case GTK_TYPE_ULONG:
1757 return Val_long (GTK_VALUE_LONG(*arg));
1759 return Val_int (GTK_VALUE_ENUM(*arg));
1760 case GTK_TYPE_FLAGS:
1761 return Val_int (GTK_VALUE_FLAGS(*arg));
1763 ml_raise_gtk ("argument type mismatch");
1768 value ml_gtk_arg_get_nativeint(GtkArg *arg) {
1770 switch(GTK_FUNDAMENTAL_TYPE(arg->type)) {
1773 return copy_nativeint (GTK_VALUE_INT(*arg));
1775 case GTK_TYPE_ULONG:
1776 return copy_nativeint (GTK_VALUE_LONG(*arg));
1778 return copy_nativeint (GTK_VALUE_ENUM(*arg));
1779 case GTK_TYPE_FLAGS:
1780 return copy_nativeint (GTK_VALUE_FLAGS(*arg));
1782 ml_raise_gtk ("argument type mismatch");
1787 value ml_gtk_arg_get_float (GtkArg *arg)
1789 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1790 case GTK_TYPE_FLOAT:
1791 return copy_double ((double)GTK_VALUE_FLOAT(*arg));
1792 case GTK_TYPE_DOUBLE:
1793 return copy_double (GTK_VALUE_DOUBLE(*arg));
1795 ml_raise_gtk ("argument type mismatch");
1800 value ml_gtk_arg_get_string (GtkArg *arg)
1803 if (GTK_FUNDAMENTAL_TYPE(arg->type) != GTK_TYPE_STRING)
1804 ml_raise_gtk ("argument type mismatch");
1805 p = GTK_VALUE_STRING(*arg);
1806 return Val_option (p, copy_string);
1809 value ml_gtk_arg_get_pointer (GtkArg *arg)
1812 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1813 case GTK_TYPE_STRING:
1814 case GTK_TYPE_BOXED:
1815 case GTK_TYPE_POINTER:
1816 case GTK_TYPE_OBJECT:
1817 p = GTK_VALUE_POINTER(*arg); break;
1819 ml_raise_gtk ("GtkArgv.get_pointer : argument type mismatch");
1821 return Val_pointer(p);
1824 value ml_gtk_arg_get_object (GtkArg *arg)
1827 if (GTK_FUNDAMENTAL_TYPE(arg->type) != GTK_TYPE_OBJECT)
1828 ml_raise_gtk ("argument type mismatch");
1829 p = GTK_VALUE_OBJECT(*arg);
1830 return Val_option (p, Val_GtkObject);
1834 value ml_string_at_pointer (value ofs, value len, value ptr)
1836 char *start = ((char*)Pointer_val(ptr)) + Option_val(ofs, Int_val, 0);
1837 int length = Option_val(len, Int_val, strlen(start));
1838 value ret = alloc_string(length);
1839 memcpy ((char*)ret, start, length);
1843 value ml_int_at_pointer (value ptr)
1845 return Val_int(*(int*)Pointer_val(ptr));
1849 value ml_gtk_arg_set_char (GtkArg *arg, value val)
1851 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1852 case GTK_TYPE_POINTER:
1854 *GTK_RETLOC_CHAR(*arg) = Char_val(val); break;
1856 ml_raise_gtk ("argument type mismatch");
1861 value ml_gtk_arg_set_bool (GtkArg *arg, value val)
1863 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1864 case GTK_TYPE_POINTER:
1866 *GTK_RETLOC_BOOL(*arg) = Bool_val(val); break;
1868 ml_raise_gtk ("argument type mismatch");
1873 value ml_gtk_arg_set_int (GtkArg *arg, value val)
1875 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1876 case GTK_TYPE_POINTER:
1879 *GTK_RETLOC_INT(*arg) = Int_val(val); break;
1881 case GTK_TYPE_ULONG:
1882 *GTK_RETLOC_LONG(*arg) = Long_val(val); break;
1884 *GTK_RETLOC_ENUM(*arg) = Int_val(val); break;
1885 case GTK_TYPE_FLAGS:
1886 *GTK_RETLOC_FLAGS(*arg) = Int_val(val); break;
1888 ml_raise_gtk ("argument type mismatch");
1893 value ml_gtk_arg_set_nativeint (GtkArg *arg, value val)
1895 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1896 case GTK_TYPE_POINTER:
1899 *GTK_RETLOC_INT(*arg) = Nativeint_val(val); break;
1901 case GTK_TYPE_ULONG:
1902 *GTK_RETLOC_LONG(*arg) = Nativeint_val(val); break;
1904 *GTK_RETLOC_ENUM(*arg) = Nativeint_val(val); break;
1905 case GTK_TYPE_FLAGS:
1906 *GTK_RETLOC_FLAGS(*arg) = Nativeint_val(val); break;
1908 ml_raise_gtk ("argument type mismatch");
1913 value ml_gtk_arg_set_float (GtkArg *arg, value val)
1915 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1916 case GTK_TYPE_POINTER:
1917 case GTK_TYPE_FLOAT:
1918 *GTK_RETLOC_FLOAT(*arg) = (float) Double_val(val); break;
1919 case GTK_TYPE_DOUBLE:
1920 *GTK_RETLOC_DOUBLE(*arg) = Double_val(val); break;
1922 ml_raise_gtk ("argument type mismatch");
1927 value ml_gtk_arg_set_string (GtkArg *arg, value val)
1929 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1930 case GTK_TYPE_POINTER:
1931 case GTK_TYPE_STRING:
1932 *GTK_RETLOC_STRING(*arg) = String_val(val); break;
1934 ml_raise_gtk ("argument type mismatch");
1939 value ml_gtk_arg_set_pointer (GtkArg *arg, value val)
1941 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1942 case GTK_TYPE_BOXED:
1943 *GTK_RETLOC_BOXED(*arg) = Pointer_val(val); break;
1944 case GTK_TYPE_POINTER:
1945 *GTK_RETLOC_POINTER(*arg) = Pointer_val(val); break;
1947 ml_raise_gtk ("argument type mismatch");
1952 value ml_gtk_arg_set_object (GtkArg *arg, value val)
1954 switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
1955 case GTK_TYPE_POINTER:
1956 case GTK_TYPE_OBJECT:
1957 *GTK_RETLOC_OBJECT(*arg) = GtkObject_val(val); break;
1959 ml_raise_gtk ("argument type mismatch");
1967 value ml_gtk_signal_connect (value object, value name, value clos, value after)
1969 value *clos_p = ml_gtk_root_new (clos);
1970 return Val_int (gtk_signal_connect_full
1971 (GtkObject_val(object), String_val(name), NULL,
1972 ml_gtk_callback_marshal, clos_p,
1973 ml_gtk_root_destroy, FALSE, Bool_val(after)));
1976 ML_2 (gtk_signal_disconnect, GtkObject_val, Int_val, Unit)
1977 ML_2 (gtk_signal_emit_stop_by_name, GtkObject_val, String_val, Unit)
1978 ML_2 (gtk_signal_handler_block, GtkObject_val, Int_val, Unit)
1979 ML_2 (gtk_signal_handler_unblock, GtkObject_val, Int_val, Unit)
1980 ML_2_name (ml_gtk_signal_emit_none, gtk_signal_emit_by_name,
1981 GtkObject_val, String_val, Unit)
1982 ML_3_name (ml_gtk_signal_emit_int, gtk_signal_emit_by_name,
1983 GtkObject_val, String_val, Int_val, Unit)
1984 ML_4_name (ml_gtk_signal_emit_scroll, gtk_signal_emit_by_name,
1985 GtkObject_val, String_val, Scroll_type_val, Double_val, Unit)
1987 /* gtkmain.h (again) */
1989 value ml_gtk_timeout_add (value interval, value clos)
1991 value *clos_p = ml_gtk_root_new (clos);
1992 return Val_int (gtk_timeout_add_full
1993 (Int_val(interval), NULL, ml_gtk_callback_marshal, clos_p,
1994 ml_gtk_root_destroy));
1996 ML_1 (gtk_timeout_remove, Int_val, Unit)
1999 #include "ml_gtkcaller.h"
2000 ML_0 (gtk_caller_new, Val_GtkWidget)
2003 static value ml_class_init=0;
2005 static void class_init (value class)
2007 callback(ml_class_init, class);
2011 value set_ml_class_init (value class_func)
2013 if (!ml_class_init) register_global_root (&ml_class_init);
2014 ml_class_init = class_func;
2018 value ml_gtk_type_new (value type)
2020 return Val_GtkWidget_sink(gtk_type_new(Int_val(type)));
2024 struct widget_info {
2027 guint (*get_type_func)(void);
2029 widget_info_array[] = {
2030 { sizeof(GtkObject), sizeof(GtkObjectClass), gtk_object_get_type },
2031 { sizeof(GtkWidget), sizeof(GtkWidgetClass), gtk_widget_get_type },
2032 { sizeof(GtkMisc), sizeof(GtkMiscClass), gtk_misc_get_type },
2033 { sizeof(GtkLabel), sizeof(GtkLabelClass), gtk_label_get_type },
2034 { sizeof(GtkAccelLabel), sizeof(GtkAccelLabelClass), gtk_accel_label_get_type },
2035 { sizeof(GtkTipsQuery), sizeof(GtkTipsQueryClass), gtk_tips_query_get_type },
2036 { sizeof(GtkArrow), sizeof(GtkArrowClass), gtk_arrow_get_type },
2037 { sizeof(GtkImage), sizeof(GtkImageClass), gtk_image_get_type },
2038 { sizeof(GtkPixmap), sizeof(GtkPixmapClass), gtk_pixmap_get_type },
2039 { sizeof(GtkContainer), sizeof(GtkContainerClass), gtk_container_get_type },
2040 { sizeof(GtkBin), sizeof(GtkBinClass), gtk_bin_get_type },
2041 { sizeof(GtkAlignment), sizeof(GtkAlignmentClass), gtk_alignment_get_type },
2042 { sizeof(GtkFrame), sizeof(GtkFrameClass), gtk_frame_get_type },
2043 { sizeof(GtkAspectFrame), sizeof(GtkAspectFrameClass), gtk_aspect_frame_get_type },
2044 { sizeof(GtkButton), sizeof(GtkButtonClass), gtk_button_get_type },
2045 { sizeof(GtkToggleButton), sizeof(GtkToggleButtonClass), gtk_toggle_button_get_type },
2046 { sizeof(GtkCheckButton), sizeof(GtkCheckButtonClass), gtk_check_button_get_type },
2047 { sizeof(GtkRadioButton), sizeof(GtkRadioButtonClass), gtk_radio_button_get_type },
2048 { sizeof(GtkOptionMenu), sizeof(GtkOptionMenuClass), gtk_option_menu_get_type },
2049 { sizeof(GtkItem), sizeof(GtkItemClass), gtk_item_get_type },
2050 { sizeof(GtkMenuItem), sizeof(GtkMenuItemClass), gtk_menu_item_get_type },
2051 { sizeof(GtkCheckMenuItem), sizeof(GtkCheckMenuItemClass), gtk_check_menu_item_get_type },
2052 { sizeof(GtkRadioMenuItem), sizeof(GtkRadioMenuItemClass), gtk_radio_menu_item_get_type },
2053 { sizeof(GtkTearoffMenuItem), sizeof(GtkTearoffMenuItemClass), gtk_tearoff_menu_item_get_type },
2054 { sizeof(GtkListItem), sizeof(GtkListItemClass), gtk_list_item_get_type },
2055 { sizeof(GtkTreeItem), sizeof(GtkTreeItemClass), gtk_tree_item_get_type },
2056 { sizeof(GtkWindow), sizeof(GtkWindowClass), gtk_window_get_type },
2057 { sizeof(GtkColorSelectionDialog), sizeof(GtkColorSelectionDialogClass), gtk_color_selection_dialog_get_type },
2058 { sizeof(GtkDialog), sizeof(GtkDialogClass), gtk_dialog_get_type },
2059 { sizeof(GtkInputDialog), sizeof(GtkInputDialogClass), gtk_input_dialog_get_type },
2060 { sizeof(GtkFileSelection), sizeof(GtkFileSelectionClass), gtk_file_selection_get_type },
2061 { sizeof(GtkFontSelectionDialog), sizeof(GtkFontSelectionDialogClass), gtk_font_selection_dialog_get_type },
2062 { sizeof(GtkPlug), sizeof(GtkPlugClass), gtk_plug_get_type },
2063 { sizeof(GtkEventBox), sizeof(GtkEventBoxClass), gtk_event_box_get_type },
2064 { sizeof(GtkHandleBox), sizeof(GtkHandleBoxClass), gtk_handle_box_get_type },
2065 { sizeof(GtkScrolledWindow), sizeof(GtkScrolledWindowClass), gtk_scrolled_window_get_type },
2066 { sizeof(GtkViewport), sizeof(GtkViewportClass), gtk_viewport_get_type },
2067 { sizeof(GtkBox), sizeof(GtkBoxClass), gtk_box_get_type },
2068 { sizeof(GtkButtonBox), sizeof(GtkButtonBoxClass), gtk_button_box_get_type },
2069 { sizeof(GtkHButtonBox), sizeof(GtkHButtonBoxClass), gtk_hbutton_box_get_type },
2070 { sizeof(GtkVButtonBox), sizeof(GtkVButtonBoxClass), gtk_vbutton_box_get_type },
2071 { sizeof(GtkVBox), sizeof(GtkVBoxClass), gtk_vbox_get_type },
2072 { sizeof(GtkColorSelection), sizeof(GtkColorSelectionClass), gtk_color_selection_get_type },
2073 { sizeof(GtkGammaCurve), sizeof(GtkGammaCurveClass), gtk_gamma_curve_get_type },
2074 { sizeof(GtkHBox), sizeof(GtkHBoxClass), gtk_hbox_get_type },
2075 { sizeof(GtkCombo), sizeof(GtkComboClass), gtk_combo_get_type },
2076 { sizeof(GtkStatusbar), sizeof(GtkStatusbarClass), gtk_statusbar_get_type },
2077 { sizeof(GtkCList), sizeof(GtkCListClass), gtk_clist_get_type },
2078 { sizeof(GtkCTree), sizeof(GtkCTreeClass), gtk_ctree_get_type },
2079 { sizeof(GtkFixed), sizeof(GtkFixedClass), gtk_fixed_get_type },
2080 { sizeof(GtkNotebook), sizeof(GtkNotebookClass), gtk_notebook_get_type },
2081 { sizeof(GtkFontSelection), sizeof(GtkFontSelectionClass), gtk_font_selection_get_type },
2082 { sizeof(GtkPaned), sizeof(GtkPanedClass), gtk_paned_get_type },
2083 { sizeof(GtkHPaned), sizeof(GtkHPanedClass), gtk_hpaned_get_type },
2084 { sizeof(GtkVPaned), sizeof(GtkVPanedClass), gtk_vpaned_get_type },
2085 { sizeof(GtkLayout), sizeof(GtkLayoutClass), gtk_layout_get_type },
2086 { sizeof(GtkList), sizeof(GtkListClass), gtk_list_get_type },
2087 { sizeof(GtkMenuShell), sizeof(GtkMenuShellClass), gtk_menu_shell_get_type },
2088 { sizeof(GtkMenuBar), sizeof(GtkMenuBarClass), gtk_menu_bar_get_type },
2089 { sizeof(GtkMenu), sizeof(GtkMenuClass), gtk_menu_get_type },
2090 { sizeof(GtkPacker), sizeof(GtkPackerClass), gtk_packer_get_type },
2091 { sizeof(GtkSocket), sizeof(GtkSocketClass), gtk_socket_get_type },
2092 { sizeof(GtkTable), sizeof(GtkTableClass), gtk_table_get_type },
2093 { sizeof(GtkToolbar), sizeof(GtkToolbarClass), gtk_toolbar_get_type },
2094 { sizeof(GtkTree), sizeof(GtkTreeClass), gtk_tree_get_type },
2095 { sizeof(GtkCalendar), sizeof(GtkCalendarClass), gtk_calendar_get_type },
2096 { sizeof(GtkDrawingArea), sizeof(GtkDrawingAreaClass), gtk_drawing_area_get_type },
2097 { sizeof(GtkCurve), sizeof(GtkCurveClass), gtk_curve_get_type },
2098 { sizeof(GtkEditable), sizeof(GtkEditableClass), gtk_editable_get_type },
2099 { sizeof(GtkEntry), sizeof(GtkEntryClass), gtk_entry_get_type },
2100 { sizeof(GtkSpinButton), sizeof(GtkSpinButtonClass), gtk_spin_button_get_type },
2101 { sizeof(GtkText), sizeof(GtkTextClass), gtk_text_get_type },
2102 { sizeof(GtkRuler), sizeof(GtkRulerClass), gtk_ruler_get_type },
2103 { sizeof(GtkHRuler), sizeof(GtkHRulerClass), gtk_hruler_get_type },
2104 { sizeof(GtkVRuler), sizeof(GtkVRulerClass), gtk_vruler_get_type },
2105 { sizeof(GtkRange), sizeof(GtkRangeClass), gtk_range_get_type },
2106 { sizeof(GtkScale), sizeof(GtkScaleClass), gtk_scale_get_type },
2107 { sizeof(GtkHScale), sizeof(GtkHScaleClass), gtk_hscale_get_type },
2108 { sizeof(GtkVScale), sizeof(GtkVScaleClass), gtk_vscale_get_type },
2109 { sizeof(GtkScrollbar), sizeof(GtkScrollbarClass), gtk_scrollbar_get_type },
2110 { sizeof(GtkHScrollbar), sizeof(GtkHScrollbarClass), gtk_hscrollbar_get_type },
2111 { sizeof(GtkVScrollbar), sizeof(GtkVScrollbarClass), gtk_vscrollbar_get_type },
2112 { sizeof(GtkSeparator), sizeof(GtkSeparatorClass), gtk_separator_get_type },
2113 { sizeof(GtkHSeparator), sizeof(GtkHSeparatorClass), gtk_hseparator_get_type },
2114 { sizeof(GtkVSeparator), sizeof(GtkVSeparatorClass), gtk_vseparator_get_type },
2115 { sizeof(GtkPreview), sizeof(GtkPreviewClass), gtk_preview_get_type },
2116 { sizeof(GtkProgress), sizeof(GtkProgressClass), gtk_progress_get_type },
2117 { sizeof(GtkProgressBar), sizeof(GtkProgressBarClass), gtk_progress_bar_get_type },
2118 { sizeof(GtkData), sizeof(GtkDataClass), gtk_data_get_type },
2119 { sizeof(GtkAdjustment), sizeof(GtkAdjustmentClass), gtk_adjustment_get_type },
2120 { sizeof(GtkTooltips), sizeof(GtkTooltipsClass), gtk_tooltips_get_type },
2121 { sizeof(GtkItemFactory), sizeof(GtkItemFactoryClass), gtk_item_factory_get_type }
2125 value ml_gtk_type_unique (value name, value parent, value nsignals)
2127 struct widget_info * wi;
2128 GtkTypeInfo ttt_info;
2130 wi = widget_info_array + Int_val(parent);
2131 ttt_info.type_name = String_val(name);
2132 ttt_info.object_size = wi->size;
2133 ttt_info.class_size = wi->class_size + Int_val(nsignals)*sizeof(void *);
2134 ttt_info.class_init_func = (GtkClassInitFunc) class_init;
2135 ttt_info.object_init_func = (GtkObjectInitFunc) NULL;
2136 ttt_info.reserved_1 = NULL;
2137 ttt_info.reserved_2 = NULL;
2138 ttt_info.base_class_init_func = (GtkClassInitFunc) NULL;
2140 return Val_int(gtk_type_unique(wi->get_type_func (), &ttt_info));
2143 static guint sig[100];
2145 value ml_gtk_object_class_add_signals (value class, value signals,
2149 for (i=0; i<nsignals; i++)
2150 sig[i] = Int_val(Field(signals, i));
2151 gtk_object_class_add_signals ((GtkObjectClass *)class,
2152 sig, Int_val(nsignals));
2156 value ml_gtk_signal_new (value name, value run_type, value classe,
2157 value parent, value num)
2159 struct widget_info * wi;
2162 wi = widget_info_array + Int_val(parent);
2163 offset = wi->class_size+Int_val(num)*sizeof(void *);
2164 return Val_int(gtk_signal_new (String_val(name), Int_val(run_type),
2165 ((GtkObjectClass *)classe)->type, offset,
2166 gtk_signal_default_marshaller, GTK_TYPE_NONE, 0));
2167 *(((int *)classe)+offset) = 0;
2170 ML_1 (gtk_rc_add_default_file, String_val, Unit)