package lablgtk3-extras

  1. Overview
  2. Docs

Building graphical interface to edit configuration parameters.

Types

type parameter_kind

This type represents the different kinds of parameters.

type configuration_structure =
  1. | Section of string * parameter_kind list
    (*

    label of the section, parameters

    *)
  2. | Section_list of string * configuration_structure list
    (*

    label of the section, list of the sub sections

    *)

This type represents the structure of the configuration window.

type return_button =
  1. | Return_apply
    (*

    The user clicked on Apply at least once before closing the window with Cancel or the window manager.

    *)
  2. | Return_ok
    (*

    The user closed the window with the ok button.

    *)
  3. | Return_cancel
    (*

    The user closed the window with the cancel button or the window manager but never clicked on the apply button.

    *)

To indicate what button pushed the user when the window is closed.

Ocf key options

val string_to_key : string -> Gdk.Tags.modifier list * int
val key_to_string : (Gdk.Tags.modifier list * int) -> string
val key_wrapper : (Gdk.Tags.modifier list * int) Ocf.wrapper
val key_option : ?doc:string -> ?cb:((Gdk.Tags.modifier list * int) -> unit) -> (Gdk.Tags.modifier list * int) -> (Gdk.Tags.modifier list * int) Ocf.conf_option

Functions to create parameters

val string : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

string label value creates a string parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val custom_string : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:('a -> unit) -> to_string:('a -> string) -> of_string:(string -> 'a) -> string -> 'a -> parameter_kind

Same as Configwin.string but for values which are not strings.

val bool : ?editable:bool -> ?help:string -> ?f:(bool -> unit) -> string -> bool -> parameter_kind

bool label value creates a boolean parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val strings : ?editable:bool -> ?help:string -> ?f:(string list -> unit) -> ?eq:(string -> string -> bool) -> ?add:(unit -> string list) -> string -> string list -> parameter_kind

strings label value creates a string list parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

  • parameter add

    the function returning a list of strings when the user wants to add strings (default returns an empty list).

  • parameter eq

    the comparison function, used not to have doubles in list. Default is Pervasives.(=). If you want to allow doubles in the list, give a function always returning false.

val list : ?editable:bool -> ?help:string -> ?f:('a list -> unit) -> ?eq:('a -> 'a -> bool) -> ?edit:('a -> 'a) -> ?add:(unit -> 'a list) -> ?color:('a -> string option) -> string -> (('a -> string) * string option) list -> 'a list -> parameter_kind

list label columns value creates a list parameter. columns is a list of pairs (f, title option), with f takeing a value and returning a string to display it. The value is the initial list.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

  • parameter eq

    the comparison function, used not to have doubles in list. Default is Pervasives.(=). If you want to allow doubles in the list, give a function always returning false.

  • parameter edit

    an optional function to use to edit an element of the list. The function returns an element, no matter if element was changed or not. When this function is given, a "Edit" button appears next to the list.

  • parameter add

    the function returning a list of values when the user wants to add values (default returns an empty list).

  • parameter color

    an optional function returning the optional color for a given element. This color is used to display the element in the list. The default function returns no color for any element.

val color : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

color label value creates a color parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val font : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

font label value creates a font parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val combo : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> ?new_allowed:bool -> string -> string list -> string -> parameter_kind

combo label choices value creates a combo parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

  • parameter new_allowed

    indicate if a entry not in the list of choices is accepted (default is false).

val text : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

text label value creates a text parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the box for the text must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val custom_text : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:('a -> unit) -> to_string:('a -> string) -> of_string:(string -> 'a) -> string -> 'a -> parameter_kind

Same as Configwin.text but for values which are not strings.

val html : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

Same as Configwin.text but html bindings are available in the text widget. Use the configwin_html_config utility to edit your bindings.

val filename : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:(string -> unit) -> string -> string -> parameter_kind

filename label value creates a filename parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val filenames : ?editable:bool -> ?help:string -> ?f:(string list -> unit) -> ?eq:(string -> string -> bool) -> string -> string list -> parameter_kind

filenames label value creates a filename list parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

  • parameter eq

    the comparison function, used not to have doubles in list. Default is Pervasives.(=). If you want to allow doubles in the list, give a function always returning false.

val date : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:((int * int * int) -> unit) -> ?f_string:((int * int * int) -> string) -> string -> (int * int * int) -> parameter_kind

date label value creates a date parameter.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

  • parameter f_string

    the function used to display the date as a string. The parameter is a tupe (day,month,year), where month is between 0 and 11. The default function creates the string year/month/day.

val hotkey : ?editable:bool -> ?expand:bool -> ?help:string -> ?f:((Gdk.Tags.modifier list * int) -> unit) -> string -> (Gdk.Tags.modifier list * int) -> parameter_kind

hotkey label value creates a hot key parameter. A hot key is defined by a list of modifiers and a key code.

  • parameter editable

    indicate if the value is editable (default is true).

  • parameter expand

    indicate if the entry widget must expand or not (default is true).

  • parameter help

    an optional help message.

  • parameter f

    the function called to apply the value (default function does nothing).

val custom : ?label:string -> GPack.box -> (unit -> unit) -> bool -> parameter_kind

custom box f expand creates a custom parameter, with the given box, the f function is called when the user wants to apply his changes, and expand indicates if the box must expand in its father.

  • parameter label

    if a value is specified, a the box is packed into a frame.

Functions creating configuration windows and boxes

val edit : ?parent:GWindow.window_skel -> ?apply:(unit -> unit) -> string -> ?width:int -> ?height:int -> configuration_structure list -> return_button

This function takes a configuration structure and creates a window to configure the various parameters.

  • parameter apply

    this function is called when the apply button is clicked, after giving new values to parameters.

val get : ?parent:GWindow.window_skel -> string -> ?width:int -> ?height:int -> configuration_structure list -> return_button

This function takes a configuration structure and creates a window used to get the various parameters from the user. It is the same window as edit but there is no apply button.

val simple_edit : ?parent:GWindow.window_skel -> ?apply:(unit -> unit) -> string -> ?width:int -> ?height:int -> parameter_kind list -> return_button

This function takes a list of parameter specifications and creates a window to configure the various parameters.

  • parameter apply

    this function is called when the apply button is clicked, after giving new values to parameters.

val simple_get : ?parent:GWindow.window_skel -> string -> ?width:int -> ?height:int -> parameter_kind list -> return_button

This function takes a list of parameter specifications and creates a window to configure the various parameters, without Apply button.

val box : parameter_kind list -> GPack.box * (unit -> unit)

Create a GPack.box with the list of given parameters, Return the box and the function to call to apply new values to parameters.

val tabbed_box : configuration_structure list -> (string * (unit -> unit)) list -> GPack.box

Create a GPack.box with the list of given configuration structure list, and the given list of buttons (defined by their label and callback). Before calling the callback of a button, the apply function of each parameter is called.