diff options
| author | pboutill | 2011-01-07 14:26:36 +0000 |
|---|---|---|
| committer | pboutill | 2011-01-07 14:26:36 +0000 |
| commit | 5929b5d3ad5ddf3d5a8f0e3bd60117c8271fd3e7 (patch) | |
| tree | d667157fabbd6004e3e3df6354e31345707d3ef6 | |
| parent | ccfcc920b2136ab056d676a99618b9f2dde6b78f (diff) | |
Separate load_file handler in coqide
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13778 85f007b7-540e-0410-9357-904b9bb8a0f7
| -rw-r--r-- | ide/coqide.ml | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/ide/coqide.ml b/ide/coqide.ml index f99f2526fb..708835b93b 100644 --- a/ide/coqide.ml +++ b/ide/coqide.ml @@ -1591,52 +1591,7 @@ let do_print session = print_window#misc#show () end - -let main files = - (* Statup preferences *) - load_pref (); - - (* Main window *) - let w = GWindow.window - ~wm_class:"CoqIde" ~wm_name:"CoqIde" - ~allow_grow:true ~allow_shrink:true - ~width:!current.window_width ~height:!current.window_height - ~title:"CoqIde" () - in - (try - let icon_image = lib_ide_file "coq.png" in - let icon = GdkPixbuf.from_file icon_image in - w#set_icon (Some icon) - with _ -> ()); - - let vbox = GPack.vbox ~homogeneous:false ~packing:w#add () in - - - (* Menu bar *) - let menubar = GMenu.menu_bar ~packing:vbox#pack () in - - (* Toolbar *) - let toolbar = GButton.toolbar - ~orientation:`HORIZONTAL - ~style:`ICONS - ~tooltips:true - ~packing:(* handle#add *) - (vbox#pack ~expand:false ~fill:false) - () - in - show_toolbar := - (fun b -> if b then toolbar#misc#show () else toolbar#misc#hide ()); - - let factory = new GMenu.factory ~accel_path:"<CoqIde MenuBar>/" menubar in - let accel_group = factory#accel_group in - - (* File Menu *) - let file_menu = factory#add_submenu "_File" in - - let file_factory = new GMenu.factory ~accel_path:"<CoqIde MenuBar>/File/" file_menu ~accel_group in - - (* File/Load Menu *) - let load_file handler f = +let load_file handler f = let f = absolute_filename f in try prerr_endline "Loading file starts"; @@ -1681,14 +1636,60 @@ let main files = end with | e -> handler ("Load failed: "^(Printexc.to_string e)) + +let do_load = load_file flash_info + + +let main files = + (* Statup preferences *) + load_pref (); + + (* Main window *) + let w = GWindow.window + ~wm_class:"CoqIde" ~wm_name:"CoqIde" + ~allow_grow:true ~allow_shrink:true + ~width:!current.window_width ~height:!current.window_height + ~title:"CoqIde" () + in + (try + let icon_image = lib_ide_file "coq.png" in + let icon = GdkPixbuf.from_file icon_image in + w#set_icon (Some icon) + with _ -> ()); + + let vbox = GPack.vbox ~homogeneous:false ~packing:w#add () in + + + (* Menu bar *) + let menubar = GMenu.menu_bar ~packing:vbox#pack () in + + (* Toolbar *) + let toolbar = GButton.toolbar + ~orientation:`HORIZONTAL + ~style:`ICONS + ~tooltips:true + ~packing:(* handle#add *) + (vbox#pack ~expand:false ~fill:false) + () in - let load f = load_file flash_info f in + show_toolbar := + (fun b -> if b then toolbar#misc#show () else toolbar#misc#hide ()); + + let factory = new GMenu.factory ~accel_path:"<CoqIde MenuBar>/" menubar in + let accel_group = factory#accel_group in + + (* File Menu *) + let file_menu = factory#add_submenu "_File" in + + let file_factory = new GMenu.factory ~accel_path:"<CoqIde MenuBar>/File/" file_menu ~accel_group in + + (* File/Load Menu *) let load_m = file_factory#add_item "_New" ~key:GdkKeysyms._N in let load_f () = match select_file_for_save ~title:"Create file" () with | None -> () - | Some f -> load f + | Some f -> do_load f in ignore (load_m#connect#activate ~callback:(load_f)); @@ -1697,7 +1698,7 @@ let main files = let load_f () = match select_file_for_open ~title:"Load file" () with | None -> () - | Some f -> load f + | Some f -> do_load f in ignore (load_m#connect#activate ~callback:(load_f)); @@ -2731,7 +2732,7 @@ let cur_ct = session_notebook#current_term.toplvl in let next_error () = try let file,line,start,stop,error_msg = search_next_error () in - load file; + do_load file; let v = session_notebook#current_term in let av = v.analyzed_view in let input_buffer = v.script#buffer in @@ -3112,7 +3113,7 @@ let cur_ct = session_notebook#current_term.toplvl in if List.length files >=1 then begin List.iter (fun f -> - if Sys.file_exists f then load f else + if Sys.file_exists f then do_load f else let f = if Filename.check_suffix f ".v" then f else f^".v" in load_file (fun s -> print_endline s; exit 1) f) files; |
