Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

why3ide.ml 18.7 KB
Newer Older
1 2 3 4

open Format
open Why3
open Gconfig
5 6 7
open Stdlib
open Session_itp
open Controller_itp
8

9 10
external reset_gc : unit -> unit = "ml_reset_gc"

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
let debug = Debug.lookup_flag "ide_info"

(************************)
(* parsing command line *)
(************************)

let files = Queue.create ()
let opt_parser = ref None

let spec = Arg.align [
  "-F", Arg.String (fun s -> opt_parser := Some s),
      "<format> select input format (default: \"why\")";
  "--format", Arg.String (fun s -> opt_parser := Some s),
      " same as -F";
(*
  "-f",
   Arg.String (fun s -> input_files := s :: !input_files),
   "<file> add file to the project (ignored if it is already there)";
*)
  Termcode.arg_extra_expl_prefix
]

let usage_str = sprintf
  "Usage: %s [options] [<file.why>|<project directory>]..."
  (Filename.basename Sys.argv.(0))

let gconfig = try
  let config, base_config, env =
    Whyconf.Args.initialize spec (fun f -> Queue.add f files) usage_str in
  if Queue.is_empty files then Whyconf.Args.exit_with_usage spec usage_str;
  Gconfig.load_config config base_config env;
  Gconfig.config ()

  with e when not (Debug.test_flag Debug.stack_trace) ->
    eprintf "%a@." Exn_printer.exn_printer e;
    exit 1

48 49 50 51 52 53 54 55
let task_driver =
  let main = Whyconf.get_main gconfig.config in
  let d = Filename.concat (Whyconf.datadir main)
                          (Filename.concat "drivers" "why3_itp.drv")
  in
  Driver.load_driver gconfig.env d []


MARCHE Claude's avatar
MARCHE Claude committed
56 57 58 59 60 61
let provers : Whyconf.config_prover Whyconf.Mprover.t =
  Whyconf.get_provers gconfig.config

let cont =
  Session_user_interface.cont_from_files spec usage_str gconfig.env files provers

62 63 64 65 66 67
let () =
  Debug.dprintf debug "[GUI] Init the GTK interface...@?";
  ignore (GtkMain.Main.init ());
  Debug.dprintf debug " done.@.";
  Gconfig.init ()

MARCHE Claude's avatar
MARCHE Claude committed
68

69 70 71
(**********************)
(* Graphical elements *)
(**********************)
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

let main_window =
  let w = GWindow.window
            ~allow_grow:true ~allow_shrink:true
            ~width:gconfig.window_width
            ~height:gconfig.window_height
            ~title:"Why3 Interactive Proof Session" ()
  in
  (* callback to record the new size of the main window when changed, so
   that on restart the window size is the same as the last session *)
  let (_ : GtkSignal.id) =
    w#misc#connect#size_allocate
      ~callback:
      (fun {Gtk.width=w;Gtk.height=h} ->
       gconfig.window_height <- h;
       gconfig.window_width <- w)
  in w

(* the main window contains a vertical box, containing:
   1. the menu
   2. an horizontal box
 *)

let vbox = GPack.vbox ~packing:main_window#add ()

let menubar = GMenu.menu_bar
  ~packing:(vbox#pack ?from:None ?expand:None ?fill:None ?padding:None)
  ()

let hb = GPack.hbox ~packing:vbox#add ()

(* 1. Menu *)

let factory = new GMenu.factory menubar

let accel_group = factory#accel_group

let file_menu = factory#add_submenu "_File"
let file_factory = new GMenu.factory file_menu ~accel_group

let exit_function ~destroy () =
  ignore(destroy); GMain.quit ()

let (_ : GtkSignal.id) = main_window#connect#destroy
  ~callback:(exit_function ~destroy:true)

118 119 120 121 122 123 124
let (_ : GMenu.menu_item) =
  file_factory#add_item ~key:GdkKeysyms._S "_Save session"
    ~callback:(fun () -> Session_itp.save_session cont.Controller_itp.controller_session)

let (replay_menu_item : GMenu.menu_item) =
  file_factory#add_item ~key:GdkKeysyms._R "_Replay all"

125 126 127 128 129 130 131 132
let (_ : GMenu.menu_item) =
  file_factory#add_item ~key:GdkKeysyms._Q "_Quit"
    ~callback:(exit_function ~destroy:false)

(* 2. horizontal box contains:
   2.1 TODO: a tool box ?
   2.2 a horizontal paned containing:
     2.2.1 a scrolled window to hold the tree view of the session
Clément Fumex's avatar
Clément Fumex committed
133
     2.2.2 a vertical paned containing
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
*)

let hp = GPack.paned `HORIZONTAL ~packing:hb#add ()

let scrollview =
  let sv =
    GBin.scrolled_window
      ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
      ~width:gconfig.tree_width ~shadow_type:`ETCHED_OUT
      ~packing:hp#add ()
  in
  let (_ : GtkSignal.id) =
    sv#misc#connect#size_allocate
      ~callback:
      (fun {Gtk.width=w;Gtk.height=_h} ->
       gconfig.tree_width <- w)
  in sv

Clément Fumex's avatar
Clément Fumex committed
152
let vpan222 = GPack.paned `VERTICAL ~packing:hp#add ()
153 154 155 156 157 158

(*  the scrolled window 2.2.1 contains a GTK tree

*)


MARCHE Claude's avatar
MARCHE Claude committed
159 160 161 162 163 164 165 166
(* view for the session tree *)
let scrolled_session_view =
  GBin.scrolled_window
    ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC
    ~shadow_type:`ETCHED_OUT
    ~packing:scrollview#add
    ()

167 168 169
let cols = new GTree.column_list
let name_column = cols#add Gobject.Data.string
let index_column = cols#add Gobject.Data.int
MARCHE Claude's avatar
MARCHE Claude committed
170

171 172 173 174 175
let name_renderer = GTree.cell_renderer_text [`XALIGN 0.]
let view_name_column = GTree.view_column ~title:"Theories/Goals" ()
let () =
  view_name_column#pack name_renderer;
  view_name_column#add_attribute name_renderer "text" name_column
176

177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
let goals_model,goals_view =
  Debug.dprintf debug "[GUI] Creating tree model...@?";
  let model = GTree.tree_store cols in
  let view = GTree.view ~model ~packing:scrolled_session_view#add () in
(*
  let () = view#selection#set_mode (* `SINGLE *) `MULTIPLE in
  let () = view#set_rules_hint true in
 *)
  ignore (view#append_column view_name_column);
(*
  ignore (view#append_column view_status_column);
  ignore (view#append_column view_time_column);
*)
  Debug.dprintf debug " done@.";
  model,view
192

Clément Fumex's avatar
Clément Fumex committed
193
(* vpan222 contains:
194
   2.2.2.1 a view of the current task
Clément Fumex's avatar
Clément Fumex committed
195 196
   2.2.2.2 a vertiacal pan which contains
     2.2.2.2.1 the input field to type commands
197
     2.2.2.2.2 a scrolled window to hold the output of the commands
198 199 200 201 202 203
 *)

let scrolled_task_view =
  GBin.scrolled_window
    ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC
    ~shadow_type:`ETCHED_OUT
Clément Fumex's avatar
Clément Fumex committed
204
    ~packing:vpan222#add ()
205 206 207 208

let task_view =
  GSourceView2.source_view
    ~editable:false
Clément Fumex's avatar
Clément Fumex committed
209
    ~cursor_visible:false
210 211 212 213
    ~show_line_numbers:true
    ~packing:scrolled_task_view#add
    ()

Clément Fumex's avatar
Clément Fumex committed
214
let vbox2222 = GPack.vbox ~packing:vpan222#add  ()
215

216 217 218 219 220 221 222 223 224 225
let hbox22221 =
  GPack.hbox
    ~packing:(vbox2222#pack ?from:None ?expand:None ?fill:None ?padding:None) ()

let command_entry = GEdit.entry ~packing:hbox22221#add ()

let monitor =
  GMisc.label
    ~text:"0/0/0"
    ~packing:(hbox22221#pack ?from:None ?expand:None ?fill:None ?padding:None) ()
226

MARCHE Claude's avatar
MARCHE Claude committed
227
let message_zone =
228 229 230 231
  let sv = GBin.scrolled_window
      ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
      ~shadow_type:`ETCHED_OUT ~packing:vbox2222#add ()
  in
MARCHE Claude's avatar
MARCHE Claude committed
232
  GText.view ~editable:false ~cursor_visible:false
233 234
    ~packing:sv#add ()

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
(**** Monitor *****)

let fan n =
  match n mod 4 with
    | 0 -> "|"
    | 1 | -3 -> "\\"
    | 2 | -2 -> "-"
    | 3 | -1 -> "/"
    | _ -> assert false

let update_monitor =
  let c = ref 0 in
  fun t s r ->
  reset_gc ();
  incr c;
  let r =
    if r=0 then "0" else
      (string_of_int r) ^ " " ^ (fan (!c / 4))
  in
  monitor#set_text ((string_of_int t) ^ "/" ^ (string_of_int s) ^ "/" ^ r)

256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
(****************************)
(* command entry completion *)
(****************************)

let completion_cols = new GTree.column_list
let completion_col = completion_cols#add Gobject.Data.string
let completion_model = GTree.tree_store completion_cols

let command_entry_completion : GEdit.entry_completion =
  GEdit.entry_completion ~model:completion_model ~minimum_key_length:1 ~entry:command_entry ()

let add_completion_entry s =
  let row = completion_model#append () in
  completion_model#set ~row ~column:completion_col s

let init_comp () =
  (* add the names of all the the transformations *)
  List.iter add_completion_entry (Trans.list_trans ());
  (* add the name of the commands *)
  List.iter (fun (c,_,_) -> add_completion_entry c)
    Session_user_interface.commands;
  (* todo: add queries *)

  command_entry_completion#set_text_column completion_col;
  command_entry#set_completion command_entry_completion
MARCHE Claude's avatar
MARCHE Claude committed
281

Sylvain Dailler's avatar
Sylvain Dailler committed
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312

(*********************)
(* Terminal historic *)
(*********************)

(* TODO use doubly linked list from Batteries.... *)
module Dl = struct

  type 'a dl = {content: 'a;
                mutable next: 'a dl;
                mutable prev: 'a dl}

  let prepend dl e =
    let rec new_element = {content = e; next = new_element; prev = new_element} in
    new_element.next <- dl;
    new_element.prev <- dl.prev;
    dl.prev.next <- new_element;
    dl.prev <- new_element

  let create e =
    let rec new_element = {content = e; next = new_element; prev = new_element} in
    new_element

  let prev dl = dl.prev

  let next dl = dl.next

  let get dl = dl.content

end

Sylvain Dailler's avatar
Sylvain Dailler committed
313

Sylvain Dailler's avatar
Sylvain Dailler committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
open Dl

type historic = {mutable top : string dl; mutable current : string dl}

let list_commands : historic =
  let top = create "" in
  { top = top; current = top}

let add_command s =
  prepend list_commands.top s;
  list_commands.top <- prev list_commands.top;
  list_commands.current <- list_commands.top

let next_command () =
  list_commands.current <- next list_commands.current

let prev_command () =
  list_commands.current <- prev list_commands.current

let get_current () =
  get list_commands.current

let _ =
  command_entry#event#connect#key_press
Sylvain Dailler's avatar
Sylvain Dailler committed
338
    ~callback:(fun (key: 'a Gdk.event) ->
Sylvain Dailler's avatar
Sylvain Dailler committed
339 340 341 342 343 344 345 346 347 348 349 350
      match (GdkEvent.Key.hardware_keycode key) with
      | 111 -> (* Arrow top *)
          next_command ();
          let s = get_current () in
          command_entry#set_text s; true
      | 116 -> (* Arrow bottom *)
          prev_command ();
          let s = get_current () in
          command_entry#set_text s; true
      | _ -> false
      )

351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
(********************************************)
(* controller instance on the GTK scheduler *)
(********************************************)


module S = struct
    let idle ~prio f =
      let (_ : GMain.Idle.id) = GMain.Idle.add ~prio f in ()

    let timeout ~ms f =
      let (_ : GMain.Timeout.id) = GMain.Timeout.add ~ms ~callback:f in
      ()
end

module C = Controller_itp.Make(S)

367 368 369 370 371 372
let () =
  let n = gconfig.session_nb_processes in
  Debug.dprintf debug "[IDE] setting max proof tasks to %d@." n;
  C.set_max_tasks n;
  C.register_observer update_monitor

373 374 375 376 377 378
let (_ : GtkSignal.id) =
  replay_menu_item#connect#activate
    ~callback:(fun () ->
               let callback = C.replay_print in
               C.replay ~use_steps:false cont ~callback ~remove_obsolete:false)

379 380 381 382 383 384 385

(***********************************)
(* Mapping session to the GTK tree *)
(***********************************)

type index =
  | Inone
386
  | IproofAttempt of proofAttemptID
387
  | IproofNode of proofNodeID
388
  | Itransformation  of transID
389 390 391 392
  | Ifile of file
  | Itheory of theory

let model_index : index Hint.t = Stdlib.Hint.create 17
393 394 395 396
(* To each proofnodeid we have the corresponding row_reference *)
let pn_id_to_gtree : GTree.row_reference Hpn.t = Hpn.create 17
let pan_id_to_gtree : GTree.row_reference Hpan.t = Hpan.create 17

397 398 399

let new_node =
  let cpt = ref (-1) in
400
  fun ?parent ?(collapse=false) name ind ->
401 402 403 404 405 406
  incr cpt;
  Hint.add model_index !cpt ind;
  let parent = Opt.map (fun x -> x#iter) parent in
  let iter = goals_model#append ?parent () in
  goals_model#set ~row:iter ~column:name_column name;
  goals_model#set ~row:iter ~column:index_column !cpt;
407
  let new_ref = goals_model#get_row_reference (goals_model#get_path iter) in
408 409
  (* By default expand_path when creating a new node *)
  if not collapse then goals_view#expand_to_path (goals_model#get_path iter);
410 411 412 413 414 415 416 417 418
  begin
    match ind with
    | IproofAttempt panid ->
       Hpan.add pan_id_to_gtree panid new_ref
    | IproofNode pnid ->
       Hpn.add pn_id_to_gtree pnid new_ref
    | _ -> ()
  end;
  new_ref
419

420
let build_subtree_proof_attempt_from_goal ses row_ref id =
421 422 423 424 425 426
  Whyconf.Hprover.iter
    (fun pa panid ->
     let name = Pp.string_of Whyconf.print_prover pa in
      ignore(new_node ~parent:row_ref name
                 (IproofAttempt panid)))
    (get_proof_attempt_ids ses id)
427 428

let rec build_subtree_from_goal ses th_row_reference id =
429
  let name = get_proof_name ses id in
430
  let row_ref =
431 432
    new_node ~parent:th_row_reference name.Ident.id_string
             (IproofNode id)
MARCHE Claude's avatar
MARCHE Claude committed
433
  in
434 435 436 437 438 439 440 441 442 443 444 445 446 447
  List.iter
    (fun trans_id ->
      build_subtree_from_trans ses row_ref trans_id)
    (get_transformations ses id);
  build_subtree_proof_attempt_from_goal ses row_ref id

and build_subtree_from_trans ses goal_row_reference trans_id =
  let name = get_transf_name ses trans_id in
  let row_ref =
    new_node ~parent:goal_row_reference name (Itransformation trans_id) in
  List.iter
    (fun goal_id ->
      (build_subtree_from_goal ses row_ref goal_id))
    (get_sub_tasks ses trans_id)
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468

let build_tree_from_session ses =
  let files = get_files ses in
  Stdlib.Hstr.iter
    (fun _ file ->
       let file_row_reference = new_node file.file_name (Ifile file) in
       List.iter (fun th ->
                  let th_row_reference =
                    new_node ~parent:file_row_reference
                             (theory_name th).Ident.id_string
                             (Itheory th)
                  in
                  List.iter (build_subtree_from_goal ses th_row_reference)
                            (theory_goals th))
                 file.file_theories)
    files

(******************)
(*    actions     *)
(******************)

469 470
(* TODO We currently use this for transformations etc... With strategies, we sure
   do not want to move the current index with the computing of strategy. *)
471 472
let current_selected_index = ref Inone

473
(* Callback of a transformation *)
MARCHE Claude's avatar
MARCHE Claude committed
474
let callback_update_tree_transform ses status =
475 476
  match status with
  | TSdone trans_id ->
MARCHE Claude's avatar
MARCHE Claude committed
477 478 479 480
     let id = get_trans_parent ses trans_id in
     let row_ref = Hpn.find pn_id_to_gtree id in (* TODO exception *)
     build_subtree_from_trans ses row_ref trans_id;
     (match Session_itp.get_sub_tasks ses trans_id with
481
      | first_goal :: _ ->
MARCHE Claude's avatar
MARCHE Claude committed
482 483
         (* Put the selection on the first goal *)
         goals_view#selection#select_iter (Hpn.find pn_id_to_gtree first_goal)#iter
484
      | [] -> ())
485 486
  | _ -> ()

487
let apply_transform ses t args =
488 489
  match !current_selected_index with
  | IproofNode id ->
MARCHE Claude's avatar
MARCHE Claude committed
490 491 492
     let callback = callback_update_tree_transform ses in
    C.schedule_transformation cont id t args ~callback
  | _ -> printf "Error: Give the name of the transformation@."
493 494 495


(* Callback of a proof_attempt *)
MARCHE Claude's avatar
MARCHE Claude committed
496 497 498 499
let callback_update_tree_proof ses panid pa_status =
  let pa = get_proof_attempt ses panid in
  let prover = pa.prover in
  let name = Pp.string_of Whyconf.print_prover prover in
500
  match pa_status with
MARCHE Claude's avatar
MARCHE Claude committed
501 502
  | Scheduled ->
     begin
503 504
       try
         let r = Hpan.find pan_id_to_gtree panid in
MARCHE Claude's avatar
MARCHE Claude committed
505 506 507 508 509 510 511 512 513 514 515 516 517
         goals_model#set ~row:r#iter ~column:name_column (name ^ " scheduled")
       with Not_found ->
         let parent_id = get_proof_attempt_parent ses panid in
         let parent = Hpn.find pn_id_to_gtree parent_id in
         ignore(new_node ~parent (name ^ " scheduled") (IproofAttempt panid))
     end
  | Done pr ->
     let r = Hpan.find pan_id_to_gtree panid in
     let res = Pp.string_of Call_provers.print_prover_result pr in
     goals_model#set ~row:r#iter ~column:name_column (name ^ " " ^ res)
  | Running ->
     let r = Hpan.find pan_id_to_gtree panid in
     goals_model#set ~row:r#iter ~column:name_column (name ^ " running")
518
  | _ ->  () (* TODO ? *)
519

520
let test_schedule_proof_attempt ses (p: Whyconf.config_prover) limit =
521 522
  match !current_selected_index with
  | IproofNode id ->
523
    let prover = p.Whyconf.prover in
MARCHE Claude's avatar
MARCHE Claude committed
524 525
    let callback = callback_update_tree_proof ses in
    C.schedule_proof_attempt cont id prover ~limit ~callback
526
  | _ -> message_zone#buffer#set_text ("Must be on a proof node to use a prover.")
527

MARCHE Claude's avatar
MARCHE Claude committed
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542

let run_strategy_on_task s =
  match !current_selected_index with
  | IproofNode id ->
     let l = Session_user_interface.strategies
               cont.controller_env gconfig.config
     in
     let st = List.filter (fun (_,c,_,_) -> c=s) l in
     begin
       match st with
       | [(n,_,_,st)] ->
          printf "running strategy '%s'@." n;
          let callback sts =
            printf "Strategy status: %a@." print_strategy_status sts
          in
MARCHE Claude's avatar
MARCHE Claude committed
543 544 545 546 547 548 549
          let callback_pa =
            callback_update_tree_proof cont.controller_session
          in
          let callback_tr st =
            callback_update_tree_transform cont.controller_session st
          in
          C.run_strategy_on_goal cont id st ~callback_pa ~callback_tr ~callback
MARCHE Claude's avatar
MARCHE Claude committed
550 551
    | _ -> printf "Strategy '%s' not found@." s
     end
552 553
  | _ -> (
)
MARCHE Claude's avatar
MARCHE Claude committed
554

555
let clear_command_entry () = command_entry#set_text ""
MARCHE Claude's avatar
MARCHE Claude committed
556

557
open Session_user_interface
MARCHE Claude's avatar
MARCHE Claude committed
558 559

let interp cmd =
560 561 562 563 564 565
  match interp cont.controller_env cmd with
    | Transform(s,_t,args) ->
       clear_command_entry ();
       apply_transform cont.controller_session s args
    | Query s ->
       message_zone#buffer#set_text s
566 567 568 569 570 571 572 573
    | Other(s,args) ->
      begin
        match parse_prover_name gconfig.config s args with
        | Some (prover_config, limit) ->
          clear_command_entry ();
          test_schedule_proof_attempt cont.controller_session prover_config limit
        | None ->
          match s with
MARCHE Claude's avatar
MARCHE Claude committed
574 575 576 577 578 579 580 581 582
       | "auto" ->
           let s =
             match args with
               | "2"::_ -> "2"
               | _ -> "1"
           in
           clear_command_entry ();
           run_strategy_on_task s
       | _ -> message_zone#buffer#set_text ("unknown command '"^s^"'")
583
      end
MARCHE Claude's avatar
MARCHE Claude committed
584 585 586 587 588 589
(*
       match s with
       | "c" -> clear_command_entry ();
                test_schedule_proof_attempt cont.controller_session
       | _ -> message_zone#buffer#set_text ("unknown command '"^s^"'")
 *)
MARCHE Claude's avatar
MARCHE Claude committed
590 591 592

let (_ : GtkSignal.id) =
  command_entry#connect#activate
Sylvain Dailler's avatar
Sylvain Dailler committed
593
    ~callback:(fun () -> add_command command_entry#text; interp command_entry#text)
594 595


596 597 598 599 600 601 602 603
let get_selected_row_references () =
  List.map
    (fun path -> goals_model#get_row_reference path)
    goals_view#selection#get_selected_rows

let on_selected_row r =
  let index = goals_model#get ~row:r#iter ~column:index_column in
  try
604 605
    let session_element = Hint.find model_index index in
    let () = match session_element with
606
             | IproofNode id -> Hpn.add pn_id_to_gtree id r (* TODO maybe not the good place to fill
607 608 609 610
                                                                    this table *)
             | _ -> () in
    current_selected_index := session_element;
    match session_element with
611 612 613 614 615
    | IproofNode id ->
       let task = get_task cont.controller_session id in
       let s = Pp.string_of
                 (Driver.print_task ~cntexample:false task_driver)
                 task
Clément Fumex's avatar
Clément Fumex committed
616 617 618
       in task_view#source_buffer#set_text s;
       (* scroll to end of text *)
       task_view#scroll_to_mark `INSERT
619 620 621 622 623 624 625 626 627 628 629 630
    | _ -> task_view#source_buffer#set_text ""
  with
    | Not_found -> task_view#source_buffer#set_text ""

let (_ : GtkSignal.id) =
  goals_view#selection#connect#after#changed ~callback:
    (fun () ->
      match get_selected_row_references () with
        | [r] -> on_selected_row r
        | _ -> ())

(***********************)
631
(* start the interface *)
632
(***********************)
633 634

let () =
635 636
  build_tree_from_session cont.controller_session;
  (* temporary *)
637
  init_comp ();
Clément Fumex's avatar
Clément Fumex committed
638
  vpan222#set_position 500;
639
  goals_view#expand_all ();
640 641 642 643
  main_window#add_accel_group accel_group;
  main_window#set_icon (Some !Gconfig.why_icon);
  main_window#show ();
  GMain.main ()