File: spin.ml

package info (click to toggle)
lablgtk3 3.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,796 kB
  • sloc: ml: 40,890; ansic: 22,312; makefile: 133; sh: 17
file content (28 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(**************************************************************************)
(*    Lablgtk - Examples                                                  *)
(*                                                                        *)
(*    This code is in the public domain.                                  *)
(*    You may freely copy parts of it in your application.                *)
(*                                                                        *)
(**************************************************************************)

let run () =
  GMain.init ();
  let w = GWindow.dialog  ~title:"Go to page" ~modal:true ~position:`CENTER () 
  in
  ignore (GMisc.label ~text:"Page: " ~packing:w#vbox#add ());
  let sb = 
    GEdit.spin_button ~packing:w#vbox#add ~digits:0 ~numeric:true ~wrap:true ()
  in
  sb#adjustment#set_bounds ~lower:0. ~upper:50.0 ~step_incr:1. ();
  sb#set_value 22.;
  sb#connect#wrapped (fun () -> prerr_endline "Wrapped!");
  w#add_button_stock `OK `OK;
  w#add_button_stock `CANCEL `CANCEL;
  w#set_default_response `OK;
  let on_ok () = Format.printf "Ok...@." ; w#destroy () in
  match w#run () with
    | `DELETE_EVENT | `CANCEL -> w#destroy ()
    | `OK -> on_ok ()

let () = run ()