12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697(**************************************************************************)(* Lablgtk *)(* *)(* This program is free software; you can redistribute it *)(* and/or modify it under the terms of the GNU Library General *)(* Public License as published by the Free Software Foundation *)(* version 2, with the exception described in file COPYING which *)(* comes with the library. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Library General Public License for more details. *)(* *)(* You should have received a copy of the GNU Library General *)(* Public License along with this program; if not, write to the *)(* Free Software Foundation, Inc., 59 Temple Place, Suite 330, *)(* Boston, MA 02111-1307 USA *)(* *)(* *)(**************************************************************************)(* $Id$ *)openStdLabelsopenGtklet()=Callback.register_exception"gtkerror"(Error"")let()=Gc.set{(Gc.get())withGc.max_overhead=1000000}moduleMain=structexternalinit:stringarray->stringarray="ml_gtk_init"(* external set_locale : unit -> string = "ml_gtk_set_locale" *)externaldisable_setlocale:unit->unit="ml_gtk_disable_setlocale"(* external main : unit -> unit = "ml_gtk_main" *)letinit?(setlocale=true)()=letsetlocale=trySys.getenv"GTK_SETLOCALE"<>"0"withNot_found->setlocaleinifnotsetlocalethendisable_setlocale();letargv=tryinitSys.argvwithErrorerr->raise(Error("GtkMain.init: initialization failed\n"^err))inifsetlocalethenignore(Glib.Main.setlocale`NUMERIC(Some"C"));Array.blit~src:argv~dst:Sys.argv~len:(Array.lengthargv)~src_pos:0~dst_pos:0;Obj.truncate(Obj.reprSys.argv)(Array.lengthargv)[@warnerror"-3"];ifsetlocalethenGlib.Main.setlocale`ALLNoneelse""openGlibletloops=ref[]letdefault_main()=letloop=(Main.createtrue)inloops:=loop::!loops;Glib.Main.wrap_poll_func();(* mark polling as blocking *)whileMain.is_runningloopdoMain.iterationtruedone;if!loops<>[]thenloops:=List.tl!loopsletmain_func=refdefault_mainletmain()=!main_func()letquit()=if!loops<>[]thenMain.quit(List.hd!loops)externalget_version:unit->int*int*int="ml_gtk_get_version"letversion=get_version()externalget_current_event_time:unit->int32="ml_gtk_get_current_event_time"endmoduleGrab=structexternaladd:[>`widget]obj->unit="ml_gtk_grab_add"externalremove:[>`widget]obj->unit="ml_gtk_grab_remove"externalget_current:unit->widgetobj="ml_gtk_grab_get_current"endmoduleEvent=struct(* May return GDK_CURRENT_TIME *)externalget_current_time:unit->int32="ml_gtk_get_current_event_time"(* May raise Gpointer.Null *)externalget_current:unit->GdkEvent.any="ml_gtk_get_current_event"(* May raise Gpointer.Null *)externalget_widget:'aGdk.event->widgetobj="ml_gtk_get_event_widget"externalpropagate:[>`widget]obj->'aGdk.event->unit="ml_gtk_propagate_event"endmoduleRc=structexternaladd_default_file:string->unit="ml_gtk_rc_add_default_file"externalparse:file:string->unit="ml_gtk_rc_parse"externalparse_string:string->unit="ml_gtk_rc_parse_string"endmoduleGc_custom=structexternalset_speed:int->unit="ml_set_gc_speed"externalget_speed:unit->int="ml_get_gc_speed"end