123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118(**************************************************************************)(* ocgtk - OCaml bindings for GTK4 *)(* *)(* This program is free software; you can redistribute it *)(* and/or modify it under the terms of the GNU Library General *)(* Public License version 2, as published by the *)(* Free Software Foundation with the exception described in file *)(* COPYING which comes with the library. *)(* *)(* Based on lablgtk3 (https://github.com/garrigue/lablgtk) *)(* *)(**************************************************************************)(** Interface to GLib functions (GTK4 / GLib 2.66+)
Provides:
- Main event loop
- Timeout and idle callbacks
- Character set conversion (UTF-8)
- String utilities *)typeunichar=inttypeunistring=unichararrayexceptionGErrorofstringlet()=Callback.register_exception"gerror"(GError"")(** {2 Main Event Loop} *)moduleMain=structtypet(* Abstract type for GMainLoop *)externalcreate:bool->t="ml_g_main_new"externalrun:t->unit="ml_g_main_run"externaliteration:bool->bool="ml_g_main_iteration"externalpending:unit->bool="ml_g_main_pending"externalis_running:t->bool="ml_g_main_is_running"externalquit:t->unit="ml_g_main_quit"externaldestroy:t->unit="ml_g_main_destroy"endexternalint_of_priority:[<`HIGH|`DEFAULT|`HIGH_IDLE|`DEFAULT_IDLE|`LOW]->int="ml_g_int_of_priority"(** Priority levels for timeouts and idle callbacks *)(** {2 Timeout Callbacks} *)moduleTimeout=structtypeid=intexternaladd_full:intoption->int->(unit->bool)->id="ml_g_timeout_add"letadd?prio~ms~callback()=add_fullpriomscallbackexternalremove:id->unit="ml_g_timeout_remove"end(** {2 Idle Callbacks} *)moduleIdle=structtypeid=intexternaladd_full:intoption->(unit->bool)->id="ml_g_idle_add"letadd?priocallback=add_fullpriocallbackexternalremove:id->unit="ml_g_idle_remove"end(** {2 Character Set Conversion} *)moduleConvert=structtypeerror=|NO_CONVERSION|ILLEGAL_SEQUENCE|FAILED|PARTIAL_INPUT|BAD_URI|NOT_ABSOLUTE_PATHexceptionErroroferror*stringlet()=Callback.register_exception"glib_convert_error"(Error(FAILED,""))externalconvert:string->to_codeset:string->from_codeset:string->string="ml_g_convert"externallocale_to_utf8:string->string="ml_g_locale_to_utf8"externallocale_from_utf8:string->string="ml_g_locale_from_utf8"externalfilename_to_utf8:string->string="ml_g_filename_to_utf8"externalfilename_from_utf8:string->string="ml_g_filename_from_utf8"externalget_charset:unit->bool*string="ml_g_get_charset"end(** {2 UTF-8 String Utilities} *)moduleUtf8=structexternalvalidate:string->bool="ml_g_utf8_validate"end(** {2 Application and Program Names} *)externalget_prgname:unit->stringoption="ml_g_get_prgname"externalset_prgname:string->unit="ml_g_set_prgname"externalget_application_name:unit->stringoption="ml_g_get_application_name"externalset_application_name:string->unit="ml_g_set_application_name"(* Initialize GLib error handling *)externalglib_init:unit->unit="ml_glib_init"let()=glib_init()