File: expander.ml

package info (click to toggle)
lablgtk2 2.10.1-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,804 kB
  • ctags: 5,871
  • sloc: ml: 32,939; ansic: 8,488; makefile: 679; sh: 85
file content (33 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (6)
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
29
30
31
32
33
(**************************************************************************)
(*    Lablgtk - Examples                                                  *)
(*                                                                        *)
(*    There is no specific licensing policy, but you may freely           *)
(*    take inspiration from the code, and copy parts of it in your        *)
(*    application.                                                        *)
(*                                                                        *)
(**************************************************************************)

let setup_expander packing =
  let e = GBin.expander ~packing () in
  let pixbuf = e#misc#render_icon ~size:`DIALOG `DIALOG_INFO in
  let icon = GMisc.image ~pixbuf ~packing:e#add () in
  e#set_label "Show image" ;
  e#connect#after#activate (fun () ->
    e#set_label 
      (if e#expanded then "Hide image" else "Show image"))

let main () = 
  let w = GWindow.window ~title:"GtkExpander demo" () in
  w#connect#destroy GMain.quit ;

  setup_expander w#add ;

  w#show () ;
  GMain.main ()

let _ = main ()

(* Local Variables: *)
(* compile-command: "ocamlc -I ../src -w s lablgtk.cma gtkInit.cmo expander.ml" *)
(* End: *)