]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/matitaMathView.ml
more properties of union
[helm.git] / matita / matita / matitaMathView.ml
index df8b5359d98b72e54a1361960f008fe03dfc656d..723170fa50812cc9b510b21c6e3ab0fc07348d72 100644 (file)
@@ -111,16 +111,21 @@ class sequentsViewer ~(notebook:GPack.notebook) ~(cicMathView:cicMathView) () =
         in
         let reparent () =
           scrolledWin <- Some w;
-          match cicMathView#misc#parent with
-          | None -> w#add cicMathView#coerce
-          | Some parent ->
-             let parent =
-              match cicMathView#misc#parent with
-                 None -> assert false
-               | Some p -> GContainer.cast_container p
-             in
-              parent#remove cicMathView#coerce;
-              w#add cicMathView#coerce
+          (match cicMathView#misc#parent with
+            | None -> ()
+            | Some parent ->
+               let parent =
+                match cicMathView#misc#parent with
+                   None -> assert false
+                 | Some p -> GContainer.cast_container p
+               in
+                parent#remove cicMathView#coerce);
+          w#add cicMathView#coerce;
+          ignore (w#vadjustment#set_value
+           (w#vadjustment#upper -. w#vadjustment#page_size));
+          ignore (w#vadjustment#connect#changed (fun _ ->
+            w#vadjustment#set_value
+             (w#vadjustment#upper -. w#vadjustment#page_size)))
         in
         goal2win <- (goal_switch, reparent) :: goal2win;
         w#coerce
@@ -550,8 +555,9 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history)
         | _ -> self#blank ()
 
     method private _loadNReference (NReference.Ref (uri,_)) =
-      let obj = NCicEnvironment.get_checked_obj uri in
-      self#_loadNObj (get_matita_script_current ())#status obj
+      let status = (get_matita_script_current ())#status in
+      let obj = NCicEnvironment.get_checked_obj status uri in
+      self#_loadNObj status obj
 
     method private _loadDir dir = 
       let content = Http_getter.ls ~local:false dir in
@@ -633,7 +639,7 @@ let sequentsViewer ~(notebook:GPack.notebook) ~(cicMathView:cicMathView) ():
 =
   (new sequentsViewer ~notebook ~cicMathView ():> MatitaGuiTypes.sequentsViewer)
 
-let cicBrowser () =
+let new_cicBrowser () =
   let size = BuildTimeConf.browser_history_size in
   let rec aux history =
     let browser = new cicBrowser_impl ~history () in
@@ -651,17 +657,31 @@ let cicBrowser () =
       GdkKeysyms._W (fun () -> win#toplevel#destroy ());
 *)
     cicBrowsers := browser :: !cicBrowsers;
-    (browser :> MatitaGuiTypes.cicBrowser)
+    browser
   in
   let history = new MatitaMisc.browser_history size (`About `Blank) in
   aux history
 
+(** @param reuse if set reused last opened cic browser otherwise 
+*  opens a new one. default is false *)
+let cicBrowser ?(reuse=false) t =
+ let browser =
+  if reuse then
+   (match !cicBrowsers with [] -> new_cicBrowser () | b :: _ -> b)
+  else
+   new_cicBrowser ()
+ in
+  match t with
+     None -> ()
+   | Some t -> browser#load t
+;;
+
 let default_cicMathView () =
  let res = cicMathView ~show:true () in
   res#set_href_callback
     (Some (fun uri ->
       let uri = `NRef (NReference.reference_of_string uri) in
-       (cicBrowser ())#load uri));
+       cicBrowser (Some uri)));
   res
 
 let cicMathView_instance =
@@ -670,6 +690,7 @@ let cicMathView_instance =
 let default_sequentsViewer notebook =
   let cicMathView = cicMathView_instance () in
   sequentsViewer ~notebook ~cicMathView ()
+
 let sequentsViewer_instance =
  let already_used = ref false in
   fun notebook ->
@@ -678,20 +699,6 @@ let sequentsViewer_instance =
     (already_used := true;
      default_sequentsViewer notebook)
 
-(** @param reuse if set reused last opened cic browser otherwise 
-*  opens a new one. default is false *)
-let show_entry ?(reuse=false) t =
- let browser =
-  if reuse then
-   (match !cicBrowsers with
-       [] -> cicBrowser ()
-     | b :: _ -> (b :> MatitaGuiTypes.cicBrowser))
-  else
-   cicBrowser ()
- in
-  browser#load t
-;;
-
 let refresh_all_browsers () =
   List.iter (fun b -> b#refresh ~force:false ()) !cicBrowsers