]> matita.cs.unibo.it Git - helm.git/commitdiff
snapshot, notably:
authorStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 Jan 2005 10:33:50 +0000 (10:33 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Thu, 20 Jan 2005 10:33:50 +0000 (10:33 +0000)
- added hyperlink handling in check and proof window
- start implementation of cic browser

13 files changed:
helm/matita/Makefile.in
helm/matita/matita.conf.xml.sample
helm/matita/matita.glade
helm/matita/matita.ml
helm/matita/matitaConsole.ml
helm/matita/matitaGeneratedGui.ml
helm/matita/matitaGeneratedGui.mli
helm/matita/matitaGui.ml
helm/matita/matitaInterpreter.ml
helm/matita/matitaMathView.ml
helm/matita/matitaMathView.mli
helm/matita/matitaTypes.ml
helm/matita/matitaTypes.mli

index 3d76d0d852a9a16eaf6b61eb2fbf16021238c9e3..6a2a88623b5620f4695834c884514fe9fdbc98ec 100644 (file)
@@ -65,7 +65,7 @@ matitac.opt: $(LIBX_DEPS) $(CMXS) matitac.ml
 
 matitaGeneratedGui.ml matitaGeneratedGui.mli: matita.glade
        $(LABLGLADECC) $< > matitaGeneratedGui.ml
-       $(OCAMLC) -i matitaGeneratedGui.ml > matitaGeneratedGui.mli
+       $(OCAMLC) $(PKGS) -i matitaGeneratedGui.ml > matitaGeneratedGui.mli
 
 %.cmi: %.mli
        $(OCAMLC) $(PKGS) -c $<
index aca8b98d6e1429f54920b52665dc1f90e51591c4..6aee8a561c292d1d368f0ca0afb3da3d65269dc3 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <helm_registry>
   <section name="prefs">
-    <key name="server">mowgli.cs.unibo.it</key>
-<!--     <key name="server">localhost</key> -->
+<!--     <key name="server">mowgli.cs.unibo.it</key> -->
+    <key name="server">localhost</key>
   </section>
   <section name="matita">
     <key name="glade_file">matita.glade</key>
@@ -12,8 +12,8 @@
   <section name="db">
     <key name="host">$(prefs.server)</key>
     <key name="user">helm</key>
-<!--     <key name="database">mowgli</key> -->
-    <key name="database">matita</key>
+    <key name="database">mowgli</key>
+<!--     <key name="database">matita</key> -->
   </section>
   <section name="getter">
     <key name="mode">remote</key>
index 103e27673fe8ee2076b2b3908739e52f28ef81af..12b772a953306d6ce398c40808e13f0d7296de04 100644 (file)
   <property name="decorated">True</property>
   <property name="skip_taskbar_hint">False</property>
   <property name="skip_pager_hint">False</property>
-  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_TOOLBAR</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
 
   <child>
@@ -2261,4 +2261,244 @@ Copyright (C) 2004,
   </child>
 </widget>
 
+<widget class="GtkWindow" id="BrowserWin">
+  <property name="title" translatable="yes">Cic browser</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+
+  <child>
+    <widget class="GtkEventBox" id="BrowserWinEventBox">
+      <property name="visible">True</property>
+      <property name="visible_window">True</property>
+      <property name="above_child">False</property>
+
+      <child>
+       <widget class="GtkVBox" id="vbox7">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkHBox" id="hbox7">
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <widget class="GtkButton" id="BrowserBackButton">
+                 <property name="visible">True</property>
+                 <property name="can_default">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+                 <property name="focus_on_click">True</property>
+
+                 <child>
+                   <widget class="GtkAlignment" id="alignment3">
+                     <property name="visible">True</property>
+                     <property name="xalign">0.5</property>
+                     <property name="yalign">0.5</property>
+                     <property name="xscale">0</property>
+                     <property name="yscale">0</property>
+                     <property name="top_padding">0</property>
+                     <property name="bottom_padding">0</property>
+                     <property name="left_padding">0</property>
+                     <property name="right_padding">0</property>
+
+                     <child>
+                       <widget class="GtkHBox" id="hbox6">
+                         <property name="visible">True</property>
+                         <property name="homogeneous">False</property>
+                         <property name="spacing">2</property>
+
+                         <child>
+                           <widget class="GtkImage" id="image188">
+                             <property name="visible">True</property>
+                             <property name="stock">gtk-go-back</property>
+                             <property name="icon_size">4</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                           <packing>
+                             <property name="padding">0</property>
+                             <property name="expand">False</property>
+                             <property name="fill">False</property>
+                           </packing>
+                         </child>
+
+                         <child>
+                           <widget class="GtkLabel" id="label10">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes"></property>
+                             <property name="use_underline">True</property>
+                             <property name="use_markup">False</property>
+                             <property name="justify">GTK_JUSTIFY_LEFT</property>
+                             <property name="wrap">False</property>
+                             <property name="selectable">False</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                           <packing>
+                             <property name="padding">0</property>
+                             <property name="expand">False</property>
+                             <property name="fill">False</property>
+                           </packing>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkButton" id="BrowserForwardButton">
+                 <property name="visible">True</property>
+                 <property name="can_default">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+                 <property name="focus_on_click">True</property>
+
+                 <child>
+                   <widget class="GtkImage" id="image189">
+                     <property name="visible">True</property>
+                     <property name="stock">gtk-go-forward</property>
+                     <property name="icon_size">4</property>
+                     <property name="xalign">0.5</property>
+                     <property name="yalign">0.5</property>
+                     <property name="xpad">0</property>
+                     <property name="ypad">0</property>
+                   </widget>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkButton" id="BrowserHomeButton">
+                 <property name="visible">True</property>
+                 <property name="can_default">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+                 <property name="focus_on_click">True</property>
+
+                 <child>
+                   <widget class="GtkImage" id="image190">
+                     <property name="visible">True</property>
+                     <property name="stock">gtk-home</property>
+                     <property name="icon_size">4</property>
+                     <property name="xalign">0.5</property>
+                     <property name="yalign">0.5</property>
+                     <property name="xpad">0</property>
+                     <property name="ypad">0</property>
+                   </widget>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkImage" id="image187">
+                 <property name="visible">True</property>
+                 <property name="stock">gtk-yes</property>
+                 <property name="icon_size">4</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">False</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+
+             <child>
+               <widget class="GtkComboBoxEntry" id="BrowserUriCombo">
+                 <property name="visible">True</property>
+               </widget>
+               <packing>
+                 <property name="padding">0</property>
+                 <property name="expand">True</property>
+                 <property name="fill">True</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkNotebook" id="BrowserNotebook">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="show_tabs">True</property>
+             <property name="show_border">True</property>
+             <property name="tab_pos">GTK_POS_TOP</property>
+             <property name="scrollable">False</property>
+             <property name="enable_popup">False</property>
+
+             <child>
+               <placeholder/>
+             </child>
+
+             <child>
+               <widget class="GtkLabel" id="label9">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">current proof</property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">False</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+               </widget>
+               <packing>
+                 <property name="type">tab</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+       </widget>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 364b5802599464ff80a5b7fd816c597831ecc550..107691932b6fc5b71eaa4226ab192087f3847de1 100644 (file)
@@ -87,11 +87,20 @@ let _ = (* attach observers to proof status *)
     false);
   currentProof#connect `Abort (fun () -> sequents_viewer#reset; false)
 
+let mathViewer = MatitaMathView.mathViewer ()
 let interpreter =
   let console = (gui#console :> MatitaTypes.console) in
   let currentProof = (currentProof :> MatitaTypes.currentProof) in
   new MatitaInterpreter.interpreter
-    ~disambiguator ~currentProof ~console ~dbd ()
+    ~disambiguator ~currentProof ~console ~mathViewer ~dbd ()
+let _ =
+  let href_callback uri =
+    let term = CicAst.Uri (UriManager.string_of_uri uri, None) in
+    ignore (interpreter#evalAst (TacticAst.Command (TacticAst.Check term)))
+  in
+  proof_viewer#set_href_callback (Some href_callback);
+  sequent_viewer#set_href_callback (Some href_callback);
+  mathViewer#set_href_callback (Some href_callback)
 
 (** {2 Script window handling} *)
 
@@ -214,5 +223,6 @@ let _ =
   (try
     load_script Sys.argv.(1)
   with Invalid_argument _ -> ());
+  gui#console#show ();
   GtkThread.main ()
 
index 2f36fc647a065479bf6c553f6a4cfbdf1dcd557c..3d40e949ee46ae156abe5e34625c7dbac8346fc2 100644 (file)
@@ -198,8 +198,10 @@ class console
       self#buffer#insert msg;
       paned#set_position (self#get_max_position - console_height);
       self#misc#grab_focus ()
-    method hide () =
-      paned#set_position self#get_max_position
+    method hide () =  (* ZACK still not sure about the gui, for the moment just
+                       * keep the console persistent *)
+      ()
+(*       paned#set_position self#get_max_position *)
     method toggle () =
       let pos = self#get_position in
       if pos > self#get_max_position - console_height then
index f21a1967be6b46125e69d72f77aba146a0a6de49..e9db307d44f8a1ec41ce34fc2038709352181f18 100644 (file)
@@ -777,9 +777,89 @@ class textDialog ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
       toplevel#destroy ()
     method check_widgets () = ()
   end
+class browserWin ?(file="matita.glade") ?domain ?autoconnect(*=true*) () =
+  let xmldata = Glade.create ~file  ~root:"BrowserWin" ?domain () in
+  object (self)
+    inherit Glade.xml ?autoconnect xmldata
+    val toplevel =
+      new GWindow.window (GtkWindow.Window.cast
+        (Glade.get_widget_msg ~name:"BrowserWin" ~info:"GtkWindow" xmldata))
+    method toplevel = toplevel
+    val browserWin =
+      new GWindow.window (GtkWindow.Window.cast
+        (Glade.get_widget_msg ~name:"BrowserWin" ~info:"GtkWindow" xmldata))
+    method browserWin = browserWin
+    val browserWinEventBox =
+      new GBin.event_box (GtkBin.EventBox.cast
+        (Glade.get_widget_msg ~name:"BrowserWinEventBox" ~info:"GtkEventBox" xmldata))
+    method browserWinEventBox = browserWinEventBox
+    val vbox7 =
+      new GPack.box (GtkPack.Box.cast
+        (Glade.get_widget_msg ~name:"vbox7" ~info:"GtkVBox" xmldata))
+    method vbox7 = vbox7
+    val hbox7 =
+      new GPack.box (GtkPack.Box.cast
+        (Glade.get_widget_msg ~name:"hbox7" ~info:"GtkHBox" xmldata))
+    method hbox7 = hbox7
+    val browserBackButton =
+      new GButton.button (GtkButton.Button.cast
+        (Glade.get_widget_msg ~name:"BrowserBackButton" ~info:"GtkButton" xmldata))
+    method browserBackButton = browserBackButton
+    val alignment3 =
+      new GBin.alignment (GtkBin.Alignment.cast
+        (Glade.get_widget_msg ~name:"alignment3" ~info:"GtkAlignment" xmldata))
+    method alignment3 = alignment3
+    val hbox6 =
+      new GPack.box (GtkPack.Box.cast
+        (Glade.get_widget_msg ~name:"hbox6" ~info:"GtkHBox" xmldata))
+    method hbox6 = hbox6
+    val image188 =
+      new GMisc.image (GtkMisc.Image.cast
+        (Glade.get_widget_msg ~name:"image188" ~info:"GtkImage" xmldata))
+    method image188 = image188
+    val label10 =
+      new GMisc.label (GtkMisc.Label.cast
+        (Glade.get_widget_msg ~name:"label10" ~info:"GtkLabel" xmldata))
+    method label10 = label10
+    val browserForwardButton =
+      new GButton.button (GtkButton.Button.cast
+        (Glade.get_widget_msg ~name:"BrowserForwardButton" ~info:"GtkButton" xmldata))
+    method browserForwardButton = browserForwardButton
+    val image189 =
+      new GMisc.image (GtkMisc.Image.cast
+        (Glade.get_widget_msg ~name:"image189" ~info:"GtkImage" xmldata))
+    method image189 = image189
+    val browserHomeButton =
+      new GButton.button (GtkButton.Button.cast
+        (Glade.get_widget_msg ~name:"BrowserHomeButton" ~info:"GtkButton" xmldata))
+    method browserHomeButton = browserHomeButton
+    val image190 =
+      new GMisc.image (GtkMisc.Image.cast
+        (Glade.get_widget_msg ~name:"image190" ~info:"GtkImage" xmldata))
+    method image190 = image190
+    val image187 =
+      new GMisc.image (GtkMisc.Image.cast
+        (Glade.get_widget_msg ~name:"image187" ~info:"GtkImage" xmldata))
+    method image187 = image187
+    val browserNotebook =
+      new GPack.notebook (GtkPack.Notebook.cast
+        (Glade.get_widget_msg ~name:"BrowserNotebook" ~info:"GtkNotebook" xmldata))
+    method browserNotebook = browserNotebook
+    val label9 =
+      new GMisc.label (GtkMisc.Label.cast
+        (Glade.get_widget_msg ~name:"label9" ~info:"GtkLabel" xmldata))
+    method label9 = label9
+    method reparent parent =
+      browserWinEventBox#misc#reparent parent;
+      toplevel#destroy ()
+    method check_widgets () = ()
+  end
 
 let check_all ?(show=false) () =
   ignore (GMain.Main.init ());
+  let browserWin = new browserWin () in
+  if show then browserWin#toplevel#show ();
+  browserWin#check_widgets ();
   let textDialog = new textDialog () in
   if show then textDialog#toplevel#show ();
   textDialog#check_widgets ();
index 6572f1a6df690d6be8143ce1ae27ddb348df6242..113538361a591607cddf00b875adf3ef829a467f 100644 (file)
@@ -477,4 +477,50 @@ class textDialog :
     method vbox5 : GPack.box
     method xml : Glade.glade_xml Gtk.obj
   end
+class browserWin :
+  ?file:string ->
+  ?domain:string ->
+  ?autoconnect:bool ->
+  unit ->
+  object
+    val alignment3 : GBin.alignment
+    val browserBackButton : GButton.button
+    val browserForwardButton : GButton.button
+    val browserHomeButton : GButton.button
+    val browserNotebook : GPack.notebook
+    val browserWin : GWindow.window
+    val browserWinEventBox : GBin.event_box
+    val hbox6 : GPack.box
+    val hbox7 : GPack.box
+    val image187 : GMisc.image
+    val image188 : GMisc.image
+    val image189 : GMisc.image
+    val image190 : GMisc.image
+    val label10 : GMisc.label
+    val label9 : GMisc.label
+    val toplevel : GWindow.window
+    val vbox7 : GPack.box
+    val xml : Glade.glade_xml Gtk.obj
+    method alignment3 : GBin.alignment
+    method bind : name:string -> callback:(unit -> unit) -> unit
+    method browserBackButton : GButton.button
+    method browserForwardButton : GButton.button
+    method browserHomeButton : GButton.button
+    method browserNotebook : GPack.notebook
+    method browserWin : GWindow.window
+    method browserWinEventBox : GBin.event_box
+    method check_widgets : unit -> unit
+    method hbox6 : GPack.box
+    method hbox7 : GPack.box
+    method image187 : GMisc.image
+    method image188 : GMisc.image
+    method image189 : GMisc.image
+    method image190 : GMisc.image
+    method label10 : GMisc.label
+    method label9 : GMisc.label
+    method reparent : GObj.widget -> unit
+    method toplevel : GWindow.window
+    method vbox7 : GPack.box
+    method xml : Glade.glade_xml Gtk.obj
+  end
 val check_all : ?show:bool -> unit -> unit
index 955ae13e529a401da0208e418f2dd843fece573f..f8f252b524f3e3e697b6ae12f339bde0cbb1bd54 100644 (file)
@@ -38,9 +38,12 @@ class gui file =
   let proof = new proofWin ~file () in
   let check = new checkWin ~file () in
   let script = new scriptWin ~file () in
+  let browser = new browserWin ~file () in
   let keyBindingBoxes = (* event boxes which should receive global key events *)
     [ toolbar#toolBarEventBox; proof#proofWinEventBox; main#mainWinEventBox;
-      check#checkWinEventBox; script#scriptWinEventBox; main#consoleEventBox ]
+      check#checkWinEventBox; script#scriptWinEventBox; main#consoleEventBox;
+      browser#browserWinEventBox
+    ]
   in
   let console =
     MatitaConsole.console ~evbox:main#consoleEventBox
@@ -62,7 +65,8 @@ class gui file =
         (* glade's check widgets *)
       List.iter (fun w -> w#check_widgets ())
         (let c w = (w :> <check_widgets: unit -> unit>) in
-         [ c about; c fileSel; c main; c proof; c toolbar; c check; c script ]);
+         [ c about; c fileSel; c main; c proof; c toolbar; c check; c script;
+           c browser ]);
         (* key bindings *)
       List.iter (* global key bindings *)
         (fun (key, callback) -> self#addKeyBinding key callback)
index 511a5931476f30fe354246257fb7bf4665263fb8..bb43d67e0ae950159bb249a45d09262cb46bbaff 100644 (file)
@@ -254,10 +254,6 @@ let inddef_of_ast params indTypes (disambiguator:MatitaTypes.disambiguator) =
       [] indTypes
   in
   let cicIndTypes = List.rev cicIndTypes in
-(*
-  prerr_endline uri;
-  pp_indtypes cicIndTypes;
-*)
   (UriManager.uri_of_string uri, (cicIndTypes, [], paramsno))
 
   (* TODO Zack a lot more to be done here:
@@ -423,7 +419,9 @@ class proofState
     | _ ->
         MatitaTypes.not_implemented "some tactic"
   in
-  let shared = new sharedState ~disambiguator ~currentProof ~console ~dbd () in
+  let shared =
+    new sharedState ~disambiguator ~currentProof ~console ?mathViewer ~dbd ()
+  in
   object (self)
     inherit interpreterState ~console
 
index d485ac02588c66e31510ed7a6d6fed2935122bb6..f264ec413cad9c51932a3c804d3c88fe3ca60c9c 100644 (file)
@@ -44,114 +44,122 @@ let list_map_fail f =
  in
   aux
 
-let choose_selection mmlwidget (element : Gdome.element option) =
-  let rec aux element =
-    if element#hasAttributeNS
-       ~namespaceURI:Misc.helmns
-       ~localName:(Gdome.domString "xref")
-    then
-      mmlwidget#set_selection (Some element)
-    else
-      try
-        match element#get_parentNode with
-        | None -> assert false
-        | Some p -> aux (new Gdome.element_of_node p)
-      with GdomeInit.DOMCastException _ ->
-        debug_print "trying to select above the document root"
-  in
-  match element with
-  | Some x -> aux x
-  | None   -> mmlwidget#set_selection None
+class clickable_math_view obj =
+  let href = Gdome.domString "href" in
+  let xref = Gdome.domString "xref" in
+  object (self)
+    inherit GMathViewAux.multi_selection_math_view obj
+
+    val mutable href_callback: (UriManager.uri -> unit) option = None
+    method set_href_callback f = href_callback <- f
+
+    initializer
+      ignore (self#connect#selection_changed self#choose_selection);
+      ignore (self#connect#click (fun (gdome_elt, _, _, _) ->
+        match gdome_elt with
+        | Some elt  (* element is an hyperlink, use href_callback on it *)
+          when elt#hasAttributeNS ~namespaceURI:Misc.xlink_ns ~localName:href ->
+            (match href_callback with
+            | None -> ()
+            | Some f ->
+                let uri =
+                  elt#getAttributeNS ~namespaceURI:Misc.xlink_ns ~localName:href
+                in
+                f (UriManager.uri_of_string (uri#to_string)))
+        | Some elt -> ignore (self#action_toggle elt)
+        | None -> ()))
+    method private choose_selection gdome_elt =
+      let rec aux elt =
+        if elt#hasAttributeNS ~namespaceURI:Misc.helm_ns ~localName:xref then
+          self#set_selection (Some elt)
+        else
+          try
+            (match elt#get_parentNode with
+            | None -> assert false
+            | Some p -> aux (new Gdome.element_of_node p))
+          with GdomeInit.DOMCastException _ -> ()
+(*             debug_print "trying to select above the document root" *)
+      in
+      match gdome_elt with
+      | Some elt -> aux elt
+      | None   -> self#set_selection None
+  end
 
 class proof_viewer obj =
- object(self)
 object(self)
 
-  inherit GMathViewAux.single_selection_math_view obj
+    inherit clickable_math_view obj
 
-  val mutable current_infos = None
-  val mutable current_mathml = None
+    val mutable current_infos = None
+    val mutable current_mathml = None
 
-  initializer
-    ignore (self#connect#click (fun (gdome_elt, _, _, _) ->
-      match gdome_elt with
-      | Some gdome_elt ->
-          prerr_endline (gdome_elt#get_nodeName#to_string);
-          ignore (self#action_toggle gdome_elt)
-      | None -> ()));
-    ignore (self#connect#selection_changed (choose_selection self))
-
-  method load_proof ((uri_opt, _, _, _) as proof, (goal_opt: int option)) =
-    let (annobj, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
-        ids_to_inner_types, ids_to_conjectures, ids_to_hypotheses) =
-      Cic2acic.acic_object_of_cic_object (cicCurrentProof proof)
-    in
-    current_infos <- Some (ids_to_terms, ids_to_father_ids, ids_to_conjectures,
-      ids_to_hypotheses);
-    let mathml =
-      ApplyTransformation.mml_of_cic_object ~explode_all:true
-        (unopt_uri uri_opt) annobj ids_to_inner_sorts ids_to_inner_types
-    in
-    debug_print "load_proof: dumping MathML to ./proof";
-    ignore (Misc.domImpl#saveDocumentToFile ~name:"./proof" ~doc:mathml ());
-    match current_mathml with
-    |  None ->
-        self#load_root ~root:mathml#get_documentElement ;
-        current_mathml <- Some mathml
-    | Some current_mathml ->
-        self#freeze;
-        XmlDiff.update_dom ~from:current_mathml mathml ;
-        self#thaw
+    method load_proof ((uri_opt, _, _, _) as proof, (goal_opt: int option)) =
+      let (annobj, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
+          ids_to_inner_types, ids_to_conjectures, ids_to_hypotheses) =
+        Cic2acic.acic_object_of_cic_object (cicCurrentProof proof)
+      in
+      current_infos <- Some (ids_to_terms, ids_to_father_ids,
+        ids_to_conjectures, ids_to_hypotheses);
+      let mathml =
+        ApplyTransformation.mml_of_cic_object ~explode_all:true
+          (unopt_uri uri_opt) annobj ids_to_inner_sorts ids_to_inner_types
+      in
+      debug_print "load_proof: dumping MathML to ./proof";
+      ignore (Misc.domImpl#saveDocumentToFile ~name:"./proof" ~doc:mathml ());
+      match current_mathml with
+      |  None ->
+          self#load_root ~root:mathml#get_documentElement ;
+          current_mathml <- Some mathml
+      | Some current_mathml ->
+          self#freeze;
+          XmlDiff.update_dom ~from:current_mathml mathml ;
+          self#thaw
   end
 
 class sequent_viewer obj =
- object(self)
-
-  inherit GMathViewAux.multi_selection_math_view obj
+  object(self)
 
-  initializer
-    ignore (self#connect#selection_changed (choose_selection self))
+    inherit clickable_math_view obj
 
-  val mutable current_infos = None
+    val mutable current_infos = None
 
-  method get_selected_terms =
-   let selections = self#get_selections in
-    list_map_fail
-     (function node ->
-       let xpath =
-        ((node : Gdome.element)#getAttributeNS
-          ~namespaceURI:Misc.helmns
-          ~localName:(Gdome.domString "xref"))#to_string
-       in
-        if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
-        else
-         match current_infos with
-            Some (ids_to_terms,_,_) ->
-             let id = xpath in
-              (try
-                Hashtbl.find ids_to_terms id
-               with _ -> raise Skip)
-          | None -> assert false (* "ERROR: No current term!!!" *)
-     ) selections
-
-  method get_selected_hypotheses =
-   let selections = self#get_selections in
-    list_map_fail
-     (function node ->
-       let xpath =
-        ((node : Gdome.element)#getAttributeNS
-          ~namespaceURI:Misc.helmns
-          ~localName:(Gdome.domString "xref"))#to_string
-       in
-        if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
-        else
-         match current_infos with
-            Some (_,_,ids_to_hypotheses) ->
-             let id = xpath in
-              (try
-                Hashtbl.find ids_to_hypotheses id
-               with _ -> raise Skip)
-          | None -> assert false (* "ERROR: No current term!!!" *)
-     ) selections
+    method get_selected_terms =
+      let selections = self#get_selections in
+      list_map_fail
+        (fun node ->
+          let xpath =
+            ((node : Gdome.element)#getAttributeNS
+              ~namespaceURI:Misc.helm_ns
+              ~localName:(Gdome.domString "xref"))#to_string
+          in
+          if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
+          else
+            match current_infos with
+            | Some (ids_to_terms,_,_) ->
+                (try
+                  Hashtbl.find ids_to_terms xpath
+                 with _ -> raise Skip)
+            | None -> assert false) (* "ERROR: No current term!!!" *)
+        selections
+
+    method get_selected_hypotheses =
+      let selections = self#get_selections in
+      list_map_fail
+        (fun node ->
+          let xpath =
+            ((node : Gdome.element)#getAttributeNS
+              ~namespaceURI:Misc.helm_ns
+              ~localName:(Gdome.domString "xref"))#to_string
+          in
+          if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
+          else
+            match current_infos with
+            | Some (_,_,ids_to_hypotheses) ->
+                (try
+                  Hashtbl.find ids_to_hypotheses xpath
+                with _ -> raise Skip)
+            | None -> assert false) (* "ERROR: No current term!!!" *)
+        selections
   
   method load_sequent metasenv metano =
 (*
@@ -281,13 +289,20 @@ let sequents_viewer ~(notebook:GPack.notebook)
 =
   new sequents_viewer ~notebook ~sequent_viewer ~set_goal ()
 
-let check_widget =
-  lazy
-    (let gui = MatitaGui.instance () in
-    sequent_viewer ~show:true ~packing:gui#check#scrolledCheck#add ())
-
 class mathViewer =
+  let href_callback: (UriManager.uri -> unit) option ref = ref None in
   object
+    val check_widget =
+      lazy
+        (let gui = MatitaGui.instance () in
+        let sequent_viewer =
+          sequent_viewer ~show:true ~packing:gui#check#scrolledCheck#add ()
+        in
+        sequent_viewer#set_href_callback !href_callback;
+        sequent_viewer)
+
+    method set_href_callback f = href_callback := f
+
     method checkTerm sequent metasenv =
       let (metano, context, expr) = sequent in
       let widget = Lazy.force check_widget in
index b7a18e920ed0b0cef08800c091979e6ad57eea8b..04d96befeb8cc0a16cb1cbf79be51ba4c2c4c1fd 100644 (file)
  * http://helm.cs.unibo.it/
  *)
 
+  (** multi selection gtkMathView which handle mactions and hyperlinks. Mactions
+  * are handled internally. Hyperlinks are handled by calling an user provided
+  * callback *)
+class type clickable_math_view =
+  object
+    inherit GMathViewAux.multi_selection_math_view
+
+      (** set hyperlink callback. None disable hyperlink handling *)
+    method set_href_callback: (UriManager.uri -> unit) option -> unit
+  end
+
 class type proof_viewer =
   object
-    inherit GMathViewAux.single_selection_math_view
+    inherit clickable_math_view
 
     method load_proof: StatefulProofEngine.proof_status -> unit
   end
 
 class type sequent_viewer =
   object
-    inherit GMathViewAux.multi_selection_math_view
+    inherit clickable_math_view
 
       (** @return the list of selected terms. Selections which are not terms are
       * ignored *)
index 5305ea463d66cec6a780a76c2cc6fefd14250362..c49bce0040049595cbcceda5b405559dc4bb713b 100644 (file)
@@ -136,6 +136,7 @@ class type mathViewer =
   object
     method checkTerm: Cic.conjecture -> Cic.metasenv -> unit
     method unload: unit -> unit
+    method set_href_callback: (UriManager.uri -> unit) option -> unit
   end
 
 type mml_of_cic_sequent =
index cc91486d672650793d0eae22e20be2b7e4fb5994..b0830c70928b09f4b1beea6b28d6287ea3bb8b3d 100644 (file)
@@ -157,6 +157,7 @@ class type mathViewer =
   object
     method checkTerm: Cic.conjecture -> Cic.metasenv -> unit
     method unload: unit -> unit
+    method set_href_callback: (UriManager.uri -> unit) option -> unit
   end
 
 type mml_of_cic_sequent =