Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file configwin_types.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269(*********************************************************************************)(* Lablgtk-extras *)(* *)(* Copyright (C) 2011-2021 Institut National de Recherche en Informatique *)(* et en Automatique. All rights reserved. *)(* *)(* 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; either version 3 of the *)(* License. *)(* *)(* 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 *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(* *)(*********************************************************************************)(** This module contains the types used in Configwin. *)letname_to_keysym=("Button1",Configwin_keys.xk_Pointer_Button1)::("Button2",Configwin_keys.xk_Pointer_Button2)::("Button3",Configwin_keys.xk_Pointer_Button3)::("Button4",Configwin_keys.xk_Pointer_Button4)::("Button5",Configwin_keys.xk_Pointer_Button5)::Configwin_keys.name_to_keysymletstring_to_keys=letmask=ref[]inletkey=tryletpos=String.rindexs'-'infori=0topos-1doletm=matchs.[i]with'C'->`CONTROL|'S'->`SHIFT|'L'->`LOCK|'M'->`MOD1|'A'->`MOD1|'1'->`MOD1|'2'->`MOD2|'3'->`MOD3|'4'->`MOD4|'5'->`MOD5|_->prerr_endlines;raiseNot_foundinmask:=m::!maskdone;String.subs(pos+1)(String.lengths-pos-1)with_->sintry!mask,List.assockeyname_to_keysymwithe->prerr_endlines;raiseeletkey_to_string(m,k)=lets=List.assockConfigwin_keys.keysym_to_nameinmatchmwith[]->s|_->letreciterms=matchmwith[]->s|c::m->iterm((matchcwith|`CONTROL->"C"|`SHIFT->"S"|`LOCK->"L"|`MOD1->"A"|`MOD2->"2"|`MOD3->"3"|`MOD4->"4"|`MOD5->"5"|_->raiseNot_found)^s)initerm("-"^s)letkey_wrapper=letto_j?with_dock=`String(key_to_stringk)inletfrom_j?def=function|`Strings->string_to_keys|json->letmsg=Printf.sprintf"Invalid key %S"(Yojson.Safe.to_stringjson)infailwithmsginOcf.Wrapper.maketo_jfrom_j(** To define key options, with the {!Ocf} module. *)letkey_option?doc?cb=Ocf.option?doc?cbkey_wrapper(** This type represents a string or filename parameter, or
any other type, depending on the given conversion functions. *)type'astring_param={string_label:string;(** the label of the parameter *)mutablestring_value:'a;(** the current value of the parameter *)string_editable:bool;(** indicates if the value can be changed *)string_f_apply:('a->unit);(** the function to call to apply the new value of the parameter *)string_help:stringoption;(** optional help string *)string_expand:bool;(** expand or not *)string_to_string:'a->string;string_of_string:string->'a;};;(** This type represents a boolean parameter. *)typebool_param={bool_label:string;(** the label of the parameter *)mutablebool_value:bool;(** the current value of the parameter *)bool_editable:bool;(** indicates if the value can be changed *)bool_f_apply:(bool->unit);(** the function to call to apply the new value of the parameter *)bool_help:stringoption;(** optional help string *)};;(** This type represents a parameter whose value is a list of ['a]. *)type'alist_param={list_label:string;(** the label of the parameter *)mutablelist_value:'alist;(** the current value of the parameter *)list_columns:(('a->string)*stringoption)list;(** the list of columns: how each must be displayed, and its optional title *)list_f_edit:('a->'a)option;(** optional edition function *)list_eq:('a->'a->bool);(** the comparison function used to get list without doubles *)list_color:('a->stringoption);(** a function to get the optional color of an element *)list_editable:bool;(** indicates if the value can be changed *)list_f_add:unit->'alist;(** the function to call to add list *)list_f_apply:('alist->unit);(** the function to call to apply the new value of the parameter *)list_help:stringoption;(** optional help string *)};;typecombo_param={combo_label:string;mutablecombo_value:string;combo_choices:stringlist;combo_editable:bool;combo_new_allowed:bool;combo_f_apply:(string->unit);combo_help:stringoption;(** optional help string *)combo_expand:bool;(** expand the entry widget or not *)};;typecustom_param={custom_box:GPack.box;custom_f_apply:(unit->unit);custom_expand:bool;custom_framed:stringoption;(** optional label for an optional frame *)};;typecolor_param={color_label:string;(** the label of the parameter *)mutablecolor_value:string;(** the current value of the parameter *)color_editable:bool;(** indicates if the value can be changed *)color_f_apply:(string->unit);(** the function to call to apply the new value of the parameter *)color_help:stringoption;(** optional help string *)color_expand:bool;(** expand the entry widget or not *)};;typedate_param={date_label:string;(** the label of the parameter *)mutabledate_value:int*int*int;(** day, month, year *)date_editable:bool;(** indicates if the value can be changed *)date_f_string:(int*int*int)->string;(** the function used to display the current value (day, month, year) *)date_f_apply:((int*int*int)->unit);(** the function to call to apply the new value (day, month, year) of the parameter *)date_help:stringoption;(** optional help string *)date_expand:bool;(** expand the entry widget or not *)};;typefont_param={font_label:string;(** the label of the parameter *)mutablefont_value:string;(** the font name *)font_editable:bool;(** indicates if the value can be changed *)font_f_apply:(string->unit);(** the function to call to apply the new value of the parameter *)font_help:stringoption;(** optional help string *)font_expand:bool;(** expand the entry widget or not *)};;typehotkey_param={hk_label:string;(** the label of the parameter *)mutablehk_value:(Gdk.Tags.modifierlist*int);(** The value, as a list of modifiers and a key code *)hk_editable:bool;(** indicates if the value can be changed *)hk_f_apply:((Gdk.Tags.modifierlist*int)->unit);(** the function to call to apply the new value of the paramter *)hk_help:stringoption;(** optional help string *)hk_expand:bool;(** expand or not *)}letmk_custom_text_string_param(a:'astring_param):stringstring_param=Obj.magica(** This type represents the different kinds of parameters. *)typeparameter_kind=String_paramofstringstring_param|List_paramof(unit-><box:GObj.widget;apply:unit>)|Filename_paramofstringstring_param|Bool_paramofbool_param|Text_paramofstringstring_param|Combo_paramofcombo_param|Custom_paramofcustom_param|Color_paramofcolor_param|Date_paramofdate_param|Font_paramoffont_param|Hotkey_paramofhotkey_param|Html_paramofstringstring_param;;(** This type represents the structure of the configuration window. *)typeconfiguration_structure=|Sectionofstring*parameter_kindlist(** label of the section, parameters *)|Section_listofstring*configuration_structurelist(** label of the section, list of the sub sections *);;(** To indicate what button was pushed by the user when the window is closed. *)typereturn_button=Return_apply(** The user clicked on Apply at least once before
closing the window with Cancel or the window manager. *)|Return_ok(** The user closed the window with the ok button. *)|Return_cancel(** The user closed the window with the cancel
button or the window manager but never clicked
on the apply button.*)(** {2 Bindings in the html editor} *)typehtml_binding={mutablehtml_key:(Gdk.Tags.modifierlist*int);mutablehtml_begin:string;mutablehtml_end:string;}lethtmlbinding_wrapper=letfrom_hbt=(t.html_key,t.html_begin,t.html_end)inletw=Ocf.Wrapper.triplekey_wrapperOcf.Wrapper.stringOcf.Wrapper.stringinletto_j?with_doct=w.Ocf.Wrapper.to_json?with_doc(from_hbt)inletfrom_j?defjson=letdef=matchdefwith|None->None|Somehb->Some(from_hbhb)inlet(k,b,e)=w.from_json?defjsonin{html_key=k;html_begin=b;html_end=e}inOcf.Wrapper.maketo_jfrom_jlethtmlbinding_option?doc?cb=Ocf.option?doc?cbhtmlbinding_wrapper