gmanager.ml 15 KB
Newer Older
MARCHE Claude's avatar
MARCHE Claude committed
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
(**************************************************************************)
(*                                                                        *)
(*  Copyright (C) 2010-                                                   *)
(*    Francois Bobot                                                      *)
(*    Jean-Christophe Filliatre                                           *)
(*    Johannes Kanig                                                      *)
(*    Andrei Paskevich                                                    *)
(*                                                                        *)
(*  This software is free software; you can redistribute it and/or        *)
(*  modify it under the terms of the GNU Library General Public           *)
(*  License version 2.1, with the special exception on linking            *)
(*  described in file LICENSE.                                            *)
(*                                                                        *)
(*  This software 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.                  *)
(*                                                                        *)
(**************************************************************************)

let pname = "[Why-rustprover]"

let () = ignore (GtkMain.Main.init ())

open Format
open Why
open Whyconf

(******************************)
(* loading user configuration *)
(******************************)

32 33
let config =
  try
MARCHE Claude's avatar
MARCHE Claude committed
34
    Whyconf.read_config None
35
  with
36
    | Not_found ->
MARCHE Claude's avatar
MARCHE Claude committed
37 38
        eprintf "%s No config file found.@." pname;
        exit 1
39 40
    | e ->
        eprintf "%a@." Exn_printer.exn_printer e;
MARCHE Claude's avatar
MARCHE Claude committed
41 42 43 44 45
        exit 1

let () = eprintf "%s Load path is: %a@." pname
  (Pp.print_list Pp.comma Pp.string) config.loadpath

46
let timelimit =
MARCHE Claude's avatar
MARCHE Claude committed
47 48 49 50 51 52 53 54 55 56
  match config.timelimit with
    | None -> 2
    | Some n -> n


(* TODO: put that in config file *)
let window_width = 1024
let window_height = 768
let font_name = "Monospace 10"

57 58 59 60 61 62
let split = ref false

let spec = [
  "-split", Arg.Set split, "split all goals";
]

MARCHE Claude's avatar
MARCHE Claude committed
63 64 65
let usage_str = "why-rustprover [options] <file>.why"
let file = ref None
let set_file f = match !file with
66
  | Some _ ->
MARCHE Claude's avatar
MARCHE Claude committed
67
      raise (Arg.Bad "only one file")
68
  | None ->
MARCHE Claude's avatar
MARCHE Claude committed
69
(*
70
      if not (Filename.check_suffix f ".why") then
MARCHE Claude's avatar
MARCHE Claude committed
71
	raise (Arg.Bad ("don't know what to do with " ^ f));
MARCHE Claude's avatar
MARCHE Claude committed
72
*)
MARCHE Claude's avatar
MARCHE Claude committed
73
      if not (Sys.file_exists f) then begin
74
	Format.eprintf "%s %s: no such file@." pname f;
MARCHE Claude's avatar
MARCHE Claude committed
75 76 77 78 79 80 81
        exit 1
      end;
      file := Some f

let () = Arg.parse spec set_file usage_str

let fname = match !file with
82 83
  | None ->
      Arg.usage spec usage_str;
MARCHE Claude's avatar
MARCHE Claude committed
84
      exit 1
85
  | Some f ->
MARCHE Claude's avatar
MARCHE Claude committed
86 87 88
      f

let lang =
89 90 91
  let load_path =
    List.fold_right Filename.concat
      [Filename.dirname Sys.argv.(0); ".."; "share"] "lang"
MARCHE Claude's avatar
MARCHE Claude committed
92
  in
93 94
  let languages_manager =
    GSourceView2.source_language_manager ~default:true
MARCHE Claude's avatar
MARCHE Claude committed
95
  in
96
  languages_manager#set_search_path
MARCHE Claude's avatar
MARCHE Claude committed
97 98 99 100 101
    (load_path :: languages_manager#search_path);
  match languages_manager#language "why" with
    | None -> Format.eprintf "pas trouv@;"; None
    | Some _ as l -> l

102
let source_text =
MARCHE Claude's avatar
MARCHE Claude committed
103 104 105 106 107 108 109 110 111 112 113 114 115
  let ic = open_in fname in
  let size = in_channel_length ic in
  let buf = String.create size in
  really_input ic buf 0 size;
  close_in ic;
  buf

let env = Why.Env.create_env (Why.Typing.retrieve config.loadpath)


(***********************)
(* Parsing input file  *)
(***********************)
116

MARCHE Claude's avatar
MARCHE Claude committed
117 118 119 120 121 122 123
let theories : Theory.theory Theory.Mnm.t =
  try
    let cin = open_in fname in
    let m = Env.read_channel env fname cin in
    close_in cin;
    eprintf "Parsing/Typing Ok@.";
    m
124
  with e ->
125
    eprintf "%a@." Exn_printer.exn_printer e;
MARCHE Claude's avatar
MARCHE Claude committed
126 127 128 129 130 131 132 133
    exit 1

(********************)
(* opening database *)
(********************)

let () = Db.init_base (fname ^ ".db")

134
let get_driver name =
MARCHE Claude's avatar
MARCHE Claude committed
135 136 137 138 139 140 141 142 143 144 145
  let pi = Util.Mstr.find name config.provers in
  Why.Driver.load_driver env pi.Whyconf.driver

type prover_data =
    { prover : Db.prover;
      command : string;
      driver : Why.Driver.driver;
    }

let provers_data =
  printf "===============================@\nProvers: ";
146
  let l =
MARCHE Claude's avatar
MARCHE Claude committed
147 148 149 150 151 152 153 154 155 156
    Util.Mstr.fold
    (fun id conf acc ->
       let name = conf.Whyconf.name in
       printf " %s, " name;
       { prover = Db.get_prover name;
         command = conf.Whyconf.command;
         driver = get_driver id; } :: acc
    ) config.provers []
  in
  printf "@\n===============================@.";
157
  l
MARCHE Claude's avatar
MARCHE Claude committed
158

MARCHE Claude's avatar
MARCHE Claude committed
159
let find_prover s =
MARCHE Claude's avatar
MARCHE Claude committed
160 161 162
  match
    List.fold_left
      (fun acc p ->
MARCHE Claude's avatar
MARCHE Claude committed
163
         if Db.prover_name p.prover = s then Some p else acc)
MARCHE Claude's avatar
MARCHE Claude committed
164 165 166 167 168
      None provers_data
  with
    | None -> assert false
    | Some p -> p

MARCHE Claude's avatar
MARCHE Claude committed
169
let alt_ergo = find_prover "Alt-Ergo"
170
let simplify = find_prover "simplify"
MARCHE Claude's avatar
MARCHE Claude committed
171 172 173
let z3 = find_prover "Z3"


174 175

let () =
MARCHE Claude's avatar
MARCHE Claude committed
176 177 178 179 180 181 182 183 184 185 186 187 188
  printf "previously known goals:@\n";
  List.iter (fun s -> printf "%s@\n" (Db.goal_task_checksum s)) (Db.root_goals ());
  printf "@."



(****************)
(* goals widget *)
(****************)

module Ide_goals = struct

  let cols = new GTree.column_list
MARCHE Claude's avatar
MARCHE Claude committed
189
  let name_column = cols#add Gobject.Data.string
MARCHE Claude's avatar
MARCHE Claude committed
190
  let id_column = cols#add Gobject.Data.caml
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
191 192
  let status_column = cols#add Gobject.Data.gobject
  let time_column = cols#add Gobject.Data.string
MARCHE Claude's avatar
MARCHE Claude committed
193

194 195
  let renderer = GTree.cell_renderer_text [`XALIGN 0.]
  let image_renderer = GTree.cell_renderer_pixbuf [ ]
MARCHE Claude's avatar
MARCHE Claude committed
196

197 198 199
  let view_name_column =
    GTree.view_column ~title:"Theories/Goals"
      ~renderer:(renderer, ["text", name_column]) ()
MARCHE Claude's avatar
MARCHE Claude committed
200

201
  let () =
MARCHE Claude's avatar
MARCHE Claude committed
202 203 204
    view_name_column#set_resizable true;
    view_name_column#set_max_width 400

205 206
  let view_status_column =
    GTree.view_column ~title:"Status"
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
207
      (*
208
        ~renderer:(icon_renderer, ["stock_id", status_column])
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
209
      *)
210
      ~renderer:(image_renderer, ["pixbuf", status_column])
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
211 212
      ()

213 214
  let view_time_column =
    GTree.view_column ~title:"Time"
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
215
      ~renderer:(renderer, ["text", time_column]) ()
MARCHE Claude's avatar
MARCHE Claude committed
216

217
  let () =
MARCHE Claude's avatar
MARCHE Claude committed
218
    view_status_column#set_resizable false;
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
219 220 221
    view_status_column#set_visible true;
    view_time_column#set_resizable false;
    view_time_column#set_visible true
MARCHE Claude's avatar
MARCHE Claude committed
222

MARCHE Claude's avatar
MARCHE Claude committed
223 224 225 226 227 228

  let create ~packing () =
    let model = GTree.tree_store cols in
    let view = GTree.view ~model ~packing () in
    let _ = view#selection#set_mode `SINGLE in
    let _ = view#set_rules_hint true in
MARCHE Claude's avatar
MARCHE Claude committed
229 230
    ignore (view#append_column view_name_column);
    ignore (view#append_column view_status_column);
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
231
    ignore (view#append_column view_time_column);
MARCHE Claude's avatar
MARCHE Claude committed
232
    model,view
MARCHE Claude's avatar
MARCHE Claude committed
233 234 235

  let clear model = model#clear ()

MARCHE Claude's avatar
MARCHE Claude committed
236
  let goal_table = Ident.Hid.create 17
MARCHE Claude's avatar
MARCHE Claude committed
237

MARCHE Claude's avatar
MARCHE Claude committed
238
  let get_goal id = fst (Ident.Hid.find goal_table id)
MARCHE Claude's avatar
MARCHE Claude committed
239

240 241
  let tr = Trans.lookup_transform_l "split_goal" env

MARCHE Claude's avatar
MARCHE Claude committed
242
  let add_goals (model : GTree.tree_store) th =
MARCHE Claude's avatar
MARCHE Claude committed
243 244 245 246
    let tname = th.Theory.th_name.Ident.id_string in
    let parent = model#append () in
    model#set ~row:parent ~column:name_column tname;
    model#set ~row:parent ~column:id_column th.Theory.th_name;
MARCHE Claude's avatar
MARCHE Claude committed
247
    (* model#set ~row:parent ~column:status_column `REMOVE; *)
248
    let tasks = Task.split_theory th None None in
249 250 251 252 253 254 255 256 257 258 259 260
    let tasks =
      if !split then
        begin
          eprintf "splitting@.";
          let l = List.fold_left
            (fun acc task ->
               List.rev_append (Trans.apply tr task) acc) [] tasks in
          List.rev l (* In order to keep the order for 1-1 transformation *)
        end
      else
        tasks
    in
MARCHE Claude's avatar
MARCHE Claude committed
261 262
    List.iter
      (fun t->
MARCHE Claude's avatar
MARCHE Claude committed
263 264 265 266 267 268 269
         let id = (Task.task_goal t).Decl.pr_name in
         let name = id.Ident.id_string in
         let g = Db.add_or_replace_task ~tname ~name t in
	 let row = model#append ~parent () in
         Ident.Hid.add goal_table id (g,row);
	 model#set ~row ~column:name_column name;
	 model#set ~row ~column:id_column id;
270
(*         model#set ~row ~column:status_column `REMOVE; *)
MARCHE Claude's avatar
MARCHE Claude committed
271 272
      )
      tasks
MARCHE Claude's avatar
MARCHE Claude committed
273 274 275

end

MARCHE Claude's avatar
MARCHE Claude committed
276
(****************)
MARCHE Claude's avatar
MARCHE Claude committed
277
(* windows, etc *)
MARCHE Claude's avatar
MARCHE Claude committed
278 279
(****************)

280
let move_to_line (v : GText.view) line =
MARCHE Claude's avatar
MARCHE Claude committed
281
  if line <= v#buffer#line_count && line <> 0 then begin
282
    let it = v#buffer#get_iter (`LINE line) in
MARCHE Claude's avatar
MARCHE Claude committed
283 284 285 286 287
    let mark = `MARK (v#buffer#create_mark it) in
    v#scroll_to_mark ~use_align:true ~yalign:0.5 mark
  end

(* to be run when a row in the tree view is selected *)
288 289
let select_goals (goals_view:GTree.tree_store) (task_view:GSourceView2.source_view)
   (_source_view:GSourceView2.source_view) selected_rows =
MARCHE Claude's avatar
MARCHE Claude committed
290 291 292
  List.iter
    (fun p ->
       let row = goals_view#get_iter p in
MARCHE Claude's avatar
MARCHE Claude committed
293 294
       let id = goals_view#get ~row ~column:Ide_goals.id_column in
       Format.eprintf "You clicked on %s@." id.Ident.id_string;
MARCHE Claude's avatar
MARCHE Claude committed
295 296
       let g = Ide_goals.get_goal id in
       let task_text = Pp.string_of Pretty.print_task (Db.goal_task g) in
MARCHE Claude's avatar
MARCHE Claude committed
297 298 299 300
       task_view#source_buffer#set_text task_text;
       task_view#scroll_to_mark `INSERT

(*
MARCHE Claude's avatar
MARCHE Claude committed
301 302 303 304
       match origin with
         | Ident.User (_loc,_) -> ()
             move_to_line source_view#as_view loc.Lexing.pos_lnum
         | _ -> ()
MARCHE Claude's avatar
MARCHE Claude committed
305
*)
MARCHE Claude's avatar
MARCHE Claude committed
306 307 308
    )
    selected_rows

MARCHE Claude's avatar
MARCHE Claude committed
309

MARCHE Claude's avatar
boomy  
MARCHE Claude committed
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
(*

  boomy icons

*)

let image ?size f =
  let n = Filename.concat "" (* todo *) (Filename.concat "images" (f^".png"))
  in
  match size with
    | None ->
        GdkPixbuf.from_file n
    | Some s ->
        GdkPixbuf.from_file_at_size ~width:s ~height:s n

let iconname_default = "pause32"
326
let iconname_scheduled = "pause32"
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
327 328 329 330 331 332 333 334
let iconname_running = "play32"
let iconname_valid = "accept32"
let iconname_unknown = "help32"
let iconname_invalid = "delete32"
let iconname_timeout = "clock32"
let iconname_failure = "bug32"
let iconname_yes = "accept32"
let iconname_no = "delete32"
335
(*
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
336
let iconname_down = "play32"
337
*)
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
338 339

let image_default = ref (image ~size:32 iconname_default)
340
let image_scheduled = ref !image_default
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
341 342 343 344 345 346 347 348
let image_running = ref !image_default
let image_valid = ref !image_default
let image_unknown = ref !image_default
let image_invalid = ref !image_default
let image_timeout = ref !image_default
let image_failure = ref !image_default
let image_yes = ref !image_default
let image_no = ref !image_default
349
(*
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
350
let image_down = ref !image_default
351
*)
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
352 353 354

let resize_images size =
  image_default := image ~size iconname_default;
355
  image_scheduled := image ~size iconname_scheduled;
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
356 357 358 359 360 361 362
  image_running := image ~size iconname_running;
  image_valid := image ~size iconname_valid;
  image_unknown := image ~size iconname_unknown;
  image_invalid := image ~size iconname_invalid;
  image_timeout := image ~size iconname_timeout;
  image_failure := image ~size iconname_failure;
  image_yes := image ~size iconname_yes;
363 364
  image_no := image ~size iconname_no
(*
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
365
  image_down := image ~size iconname_down
366
*)
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
367 368 369 370

let () = resize_images 16

let image_of_result = function
371
  | Db.Scheduled -> !image_scheduled
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
372 373 374 375 376 377 378 379
  | Db.Running -> !image_running
  | Db.Success -> !image_valid
  | Db.Timeout -> !image_timeout
  | Db.Unknown -> !image_unknown
  | Db.HighFailure -> !image_failure


(*
MARCHE Claude's avatar
MARCHE Claude committed
380
let count = ref 0
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
381
*)
MARCHE Claude's avatar
MARCHE Claude committed
382

MARCHE Claude's avatar
MARCHE Claude committed
383 384
let async f = GtkThread.async f ()

385
let prover_on_all_goals ~(model:GTree.tree_store) ~(view:GTree.view) p () =
MARCHE Claude's avatar
MARCHE Claude committed
386
  Ident.Hid.iter
MARCHE Claude's avatar
MARCHE Claude committed
387
    (fun id (g,row) ->
388
       let name = Db.prover_name p.prover in
389
       Format.eprintf "[main thread] scheduling %s on goal %s@." name id.Ident.id_string;
390
       let prover_row = model#append ~parent:row () in
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
391
       model#set ~row:prover_row ~column:Ide_goals.name_column ("prover: " ^name);
392
       view#expand_row (model#get_path row);
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
393
(*
MARCHE Claude's avatar
MARCHE Claude committed
394 395
       incr count;
       let c = !count in
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
396
*)
MARCHE Claude's avatar
MARCHE Claude committed
397
       let callback result =
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
398 399
         (*
           printf "Scheduled task #%d: status set to %a@." c
400
           Db.print_status result;
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
401
         *)
402
         model#set ~row:prover_row ~column:Ide_goals.status_column
MARCHE Claude's avatar
boomy  
MARCHE Claude committed
403 404
           (image_of_result result);

405
         model#set ~row:prover_row ~column:Ide_goals.time_column "n.a.";
MARCHE Claude's avatar
MARCHE Claude committed
406 407
       in
       Scheduler.schedule_proof_attempt
MARCHE Claude's avatar
MARCHE Claude committed
408
         ~async
409 410
         ~debug:false ~timelimit ~memlimit:0
         ~prover:p.prover ~command:p.command ~driver:p.driver
MARCHE Claude's avatar
MARCHE Claude committed
411 412 413 414
         ~callback
         g
    )
    Ide_goals.goal_table
MARCHE Claude's avatar
MARCHE Claude committed
415 416

let main () =
417
  let w = GWindow.window
MARCHE Claude's avatar
MARCHE Claude committed
418
    ~allow_grow:true ~allow_shrink:true
419
    ~width:window_width ~height:window_height
MARCHE Claude's avatar
MARCHE Claude committed
420 421 422 423 424 425 426 427 428 429 430
    ~title:"why-ide" ()
  in
  let _ = w#connect#destroy ~callback:(fun () -> exit 0) in
  let vbox = GPack.vbox ~homogeneous:false ~packing:w#add () in

  (* Menu *)
  let menubar = GMenu.menu_bar ~packing:vbox#pack () in
  let factory = new GMenu.factory menubar in
  let accel_group = factory#accel_group in
  let file_menu = factory#add_submenu "_File" in
  let file_factory = new GMenu.factory file_menu ~accel_group in
431 432 433
  let _ =
    file_factory#add_image_item ~key:GdkKeysyms._Q ~label:"_Quit"
      ~callback:(fun () -> exit 0) ()
MARCHE Claude's avatar
MARCHE Claude committed
434
  in
MARCHE Claude's avatar
MARCHE Claude committed
435 436
  let tools_menu = factory#add_submenu "_Tools" in
  let tools_factory = new GMenu.factory tools_menu ~accel_group in
MARCHE Claude's avatar
MARCHE Claude committed
437 438 439 440 441

  (* horizontal paned *)
  let hp = GPack.paned `HORIZONTAL  ~border_width:3 ~packing:vbox#add () in

  (* left tree of namespace *)
442 443 444
  let scrollview =
    GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
    ~width:(window_width / 3) ~packing:hp#add ()
MARCHE Claude's avatar
MARCHE Claude committed
445 446 447
  in
  let _ = scrollview#set_shadow_type `ETCHED_OUT in

MARCHE Claude's avatar
MARCHE Claude committed
448 449
  let goals_model,goals_view = Ide_goals.create ~packing:scrollview#add () in
  Theory.Mnm.iter (fun _ th -> Ide_goals.add_goals goals_model th) theories;
450 451 452 453 454
  let _ =
    tools_factory#add_image_item ~key:GdkKeysyms._A
      ~label:"Alt-Ergo on all goals"
      ~callback:(fun () ->
                   prover_on_all_goals ~model:goals_model ~view:goals_view
455
                     alt_ergo ();
456
                   prover_on_all_goals ~model:goals_model ~view:goals_view
457
                     simplify ();
458 459
                   prover_on_all_goals ~model:goals_model ~view:goals_view
                     z3 ()) ()
MARCHE Claude's avatar
MARCHE Claude committed
460
  in
461 462 463
  let _ =
    tools_factory#add_image_item ~key:GdkKeysyms._E
      ~label:"Expand all" ~callback:(fun () -> goals_view#expand_all ()) ()
MARCHE Claude's avatar
MARCHE Claude committed
464 465
  in

MARCHE Claude's avatar
MARCHE Claude committed
466

MARCHE Claude's avatar
MARCHE Claude committed
467 468 469 470
  (* horizontal paned *)
  let vp = GPack.paned `VERTICAL  ~border_width:3 ~packing:hp#add () in

  (* goal text view *)
MARCHE Claude's avatar
MARCHE Claude committed
471
  let scrolled_task_view = GBin.scrolled_window
MARCHE Claude's avatar
MARCHE Claude committed
472 473 474
    ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC
    ~packing:vp#add ()
  in
MARCHE Claude's avatar
MARCHE Claude committed
475
  let task_view =
MARCHE Claude's avatar
MARCHE Claude committed
476 477 478
    GSourceView2.source_view
      ~editable:false
      ~show_line_numbers:true
MARCHE Claude's avatar
MARCHE Claude committed
479
      ~packing:scrolled_task_view#add ~height:500 ~width:650
MARCHE Claude's avatar
MARCHE Claude committed
480 481
      ()
  in
MARCHE Claude's avatar
MARCHE Claude committed
482 483
  task_view#source_buffer#set_language lang;
  task_view#set_highlight_current_line true;
484

MARCHE Claude's avatar
MARCHE Claude committed
485
  (* source view *)
MARCHE Claude's avatar
MARCHE Claude committed
486
  let scrolled_source_view = GBin.scrolled_window
MARCHE Claude's avatar
MARCHE Claude committed
487
    ~hpolicy: `AUTOMATIC ~vpolicy: `AUTOMATIC
MARCHE Claude's avatar
MARCHE Claude committed
488
    ~packing:vp#add ()
MARCHE Claude's avatar
MARCHE Claude committed
489 490 491 492 493 494 495 496
  in
  let source_view =
    GSourceView2.source_view
      ~auto_indent:true
      ~insert_spaces_instead_of_tabs:true ~tab_width:2
      ~show_line_numbers:true
      ~right_margin_position:80 ~show_right_margin:true
      (* ~smart_home_end:true *)
MARCHE Claude's avatar
MARCHE Claude committed
497
      ~packing:scrolled_source_view#add ~height:500 ~width:650
MARCHE Claude's avatar
MARCHE Claude committed
498 499
      ()
  in
MARCHE Claude's avatar
MARCHE Claude committed
500
(*
MARCHE Claude's avatar
MARCHE Claude committed
501
  source_view#misc#modify_font_by_name font_name;
MARCHE Claude's avatar
MARCHE Claude committed
502
*)
MARCHE Claude's avatar
MARCHE Claude committed
503 504 505
  source_view#source_buffer#set_language lang;
  source_view#set_highlight_current_line true;
  source_view#source_buffer#set_text source_text;
MARCHE Claude's avatar
MARCHE Claude committed
506

507
(* Bind event: row selection on tree view on the left *)
MARCHE Claude's avatar
MARCHE Claude committed
508 509 510 511
  let _ =
    goals_view#selection#connect#after#changed ~callback:
      begin fun () ->
	let list = goals_view#selection#get_selected_rows in
MARCHE Claude's avatar
MARCHE Claude committed
512
        select_goals goals_model task_view source_view list
MARCHE Claude's avatar
MARCHE Claude committed
513 514 515
      end
  in

MARCHE Claude's avatar
MARCHE Claude committed
516 517 518 519 520 521 522 523
  w#add_accel_group accel_group;
  w#show ()

let () =
  main ();
  GtkThread.main ()

(*
524
Local Variables:
MARCHE Claude's avatar
MARCHE Claude committed
525
compile-command: "unset LANG; make -C ../.. bin/why-ide.byte"
526
End:
MARCHE Claude's avatar
MARCHE Claude committed
527
*)