]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaGtkMisc.mli
ocaml 3.09 transition
[helm.git] / helm / matita / matitaGtkMisc.mli
1 (* Copyright (C) 2004-2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (** {2 Gtk helpers} *)
27
28   (** given a window and a check menu item it links the two so that the former
29    * is only hidden on delete and the latter toggle show/hide of the former *)
30 val toggle_window_visibility:
31   window:GWindow.window -> check:GMenu.check_menu_item -> unit
32   
33   (** given a window and a check menu item it links the two so that the former
34    * is only hidden on delete and the latter toggle show/hide of the former *)
35 val toggle_widget_visibility:
36   widget:GObj.widget -> check:GMenu.check_menu_item -> unit
37
38 val toggle_callback:
39   callback:(bool -> unit) -> check:GMenu.check_menu_item -> unit
40   
41 val toggle_win:
42   ?check:GMenu.check_menu_item -> GWindow.window -> unit -> unit
43
44 val add_key_binding: Gdk.keysym -> (unit -> 'a) -> GBin.event_box -> unit
45
46 (** Connect a callback to the clicked signal of a button, ignoring its return
47   * value *)
48 val connect_button: #GButton.button -> (unit -> unit) -> unit
49
50
51 (** Connect a callback to the toggled signal of a button, ignoring its return
52   * value *)
53 val connect_toggle_button: #GButton.toggle_button -> (unit -> unit) -> unit
54
55 (** Like connect_button above, but connects a callback to the activate signal of
56   * a menu item *)
57 val connect_menu_item: #GMenu.menu_item -> (unit -> unit) -> unit
58
59   (** connect a unit -> unit callback to a particular key press event. Event can
60   * be specified using its keysym and a list of modifiers which must be in
61   * effect for the callback to be executed. Further signal processing of other
62   * key press events remains unchanged; further signal processing of the
63   * specified key press depends on the stop parameter *)
64 val connect_key:
65   GObj.event_ops ->
66   ?modifiers:Gdk.Tags.modifier list ->
67   ?stop:bool ->     (* stop signal handling when the given key has been pressed?
68                      * Defaults to false *)
69   Gdk.keysym ->     (* (= int) the key, see GdkKeysyms.ml *)
70   (unit -> unit) -> (* callback *)
71     unit
72
73   (** n-ary string column list *)
74 class multiStringListModel:
75   cols:int ->
76   GTree.view ->
77   object
78     method list_store: GTree.list_store (** list_store forwarding *)
79
80     method easy_mappend:     string list -> unit        (** append + set *)
81     method easy_minsert:     int -> string list -> unit (** insert + set *)
82     method easy_mselection:  unit -> string list list
83   end
84   
85   (** single string column list *)
86 class stringListModel:
87   GTree.view ->
88   object
89     inherit multiStringListModel
90
91     method easy_append:     string -> unit        (** append + set *)
92     method easy_insert:     int -> string -> unit (** insert + set *)
93     method easy_selection:  unit -> string list
94   end
95   
96
97   (** as above with Pixbuf associated to each row. Each time an insert is
98    * performed a string tag should be specified, the corresponding pixbuf in the
99    * tags associative list will be shown on the left of the inserted row *)
100 class taggedStringListModel:
101   tags:((string * GdkPixbuf.pixbuf) list) ->
102   GTree.view ->
103   object
104     method list_store: GTree.list_store (** list_store forwarding *)
105
106     method easy_append:     tag:string -> string -> unit
107     method easy_insert:     int -> tag:string -> string -> unit
108     method easy_selection:  unit -> string list
109   end
110
111 (** {2 Matita GUI components} *)
112
113 class type gui =
114   object  (* minimal gui object requirements *)
115     method newUriDialog:          unit -> MatitaGeneratedGui.uriChoiceDialog
116     method newRecordDialog:       unit -> MatitaGeneratedGui.recordChoiceDialog
117     method newConfirmationDialog: unit -> MatitaGeneratedGui.confirmationDialog
118     method newEmptyDialog:        unit -> MatitaGeneratedGui.emptyDialog
119   end
120
121   (** {3 Dialogs}
122    * In functions below:
123    * @param title window title
124    * @param message content of the text label shown to the user *)
125
126   (** @param parent to center the window on it *)
127 val ask_confirmation:
128   title:string -> message:string -> 
129   ?parent:#GWindow.window_skel ->
130   unit ->
131     [`YES | `NO | `CANCEL]
132
133   (** @param multiline (default: false) if true a TextView widget will be used
134   * for prompting the user otherwise a TextEntry widget will be
135   * @return the string given by the user *)
136 val ask_text:
137   gui:#gui ->
138   ?title:string -> ?message:string ->
139   ?multiline:bool -> ?default:string -> unit ->
140     string
141
142   (** @param fields field names
143    * @param records list of records, each record is a list of [fields] strings
144    * @return number of the chosen record, 0 for the first one *)
145 val ask_record_choice:
146   gui:#gui ->
147   ?title:string -> ?message:string ->
148   fields:string list -> records:string list list ->
149   unit ->
150     int
151
152 val report_error:
153   title:string -> message:string -> 
154   ?parent:#GWindow.window_skel ->
155   unit ->
156     unit
157