package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Ocgtk_gtk.GMain

Main event loop and initialization for GTK4

Initialization

exception Error of string
val init : ?setlocale:bool -> unit -> string array

Initialize GTK.

This must be called before using any GTK functions. Returns the remaining command-line arguments after GTK processes its options.

  • parameter argv

    Command-line arguments (typically Sys.argv)

  • raises Error

    if initialization fails

Example:

let () =
  let _ = GMain.init () in
  (* ... create widgets ... *)
  GMain.main ()

Main Loop

val main : unit -> unit

Start the GTK main event loop. This function blocks until quit is called.

val quit : unit -> unit

Exit the main event loop. Typically called from a signal handler or callback.

val iteration : bool -> bool

Run one iteration of the main loop.

  • parameter block

    If true, wait for events; if false, return immediately if no events

  • returns

    true if more events are pending

Deprecated - Use GtkApplication Instead

Note: For new GTK4 applications, GtkApplication is preferred over the main loop functions. However, these are provided for:

  • Testing during development
  • Simple examples
  • Migration from GTK3

Full GtkApplication support is planned for a future release.