]> matita.cs.unibo.it Git - helm.git/commitdiff
added find&replace facility
authorEnrico Tassi <enrico.tassi@inria.fr>
Wed, 13 Jul 2005 12:32:09 +0000 (12:32 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Wed, 13 Jul 2005 12:32:09 +0000 (12:32 +0000)
helm/matita/matita.glade
helm/matita/matitaGui.ml
helm/matita/matitaGui.mli

index 98526c5788d2a1ef51600a7e7880313980a5844c..10fb0a1cc84ef9a3fcb83a04e5544455eae96f75 100644 (file)
@@ -881,7 +881,7 @@ Copyright (C) 2005,
                              <property name="use_underline">True</property>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image334">
+                               <widget class="GtkImage" id="image351">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-new</property>
                                  <property name="icon_size">1</property>
@@ -902,7 +902,7 @@ Copyright (C) 2005,
                              <accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image335">
+                               <widget class="GtkImage" id="image352">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-open</property>
                                  <property name="icon_size">1</property>
@@ -923,7 +923,7 @@ Copyright (C) 2005,
                              <accelerator key="s" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image336">
+                               <widget class="GtkImage" id="image353">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-save</property>
                                  <property name="icon_size">1</property>
@@ -943,7 +943,7 @@ Copyright (C) 2005,
                              <property name="use_underline">True</property>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image337">
+                               <widget class="GtkImage" id="image354">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-save-as</property>
                                  <property name="icon_size">1</property>
@@ -970,7 +970,7 @@ Copyright (C) 2005,
                              <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                              <child internal-child="image">
-                               <widget class="GtkImage" id="image338">
+                               <widget class="GtkImage" id="image355">
                                  <property name="visible">True</property>
                                  <property name="stock">gtk-quit</property>
                                  <property name="icon_size">1</property>
@@ -992,6 +992,32 @@ Copyright (C) 2005,
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">_Edit</property>
                      <property name="use_underline">True</property>
+
+                     <child>
+                       <widget class="GtkMenu" id="editMenu_menu">
+
+                         <child>
+                           <widget class="GtkImageMenuItem" id="findReplMenuItem">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Find &amp; Replace</property>
+                             <property name="use_underline">True</property>
+                             <accelerator key="f" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                             <child internal-child="image">
+                               <widget class="GtkImage" id="image356">
+                                 <property name="visible">True</property>
+                                 <property name="stock">gtk-find-and-replace</property>
+                                 <property name="icon_size">1</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>
+                         </child>
+                       </widget>
+                     </child>
                    </widget>
                  </child>
 
@@ -2742,4 +2768,265 @@ Copyright (C) 2005,
   </child>
 </widget>
 
+<widget class="GtkWindow" id="FindReplWin">
+  <property name="border_width">5</property>
+  <property name="title" translatable="yes">Find &amp; Replace</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_MOUSE</property>
+  <property name="modal">False</property>
+  <property name="resizable">False</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_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+
+  <child>
+    <widget class="GtkTable" id="table1">
+      <property name="visible">True</property>
+      <property name="n_rows">3</property>
+      <property name="n_columns">2</property>
+      <property name="homogeneous">False</property>
+      <property name="row_spacing">5</property>
+      <property name="column_spacing">0</property>
+
+      <child>
+       <widget class="GtkLabel" id="label17">
+         <property name="visible">True</property>
+         <property name="label" translatable="yes">Find:</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</property>
+         <property name="yalign">0.5</property>
+         <property name="xpad">0</property>
+         <property name="ypad">0</property>
+       </widget>
+       <packing>
+         <property name="left_attach">0</property>
+         <property name="right_attach">1</property>
+         <property name="top_attach">0</property>
+         <property name="bottom_attach">1</property>
+         <property name="x_options">fill</property>
+         <property name="y_options"></property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkLabel" id="label18">
+         <property name="visible">True</property>
+         <property name="label" translatable="yes">Replace with: </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</property>
+         <property name="yalign">0.5</property>
+         <property name="xpad">0</property>
+         <property name="ypad">0</property>
+       </widget>
+       <packing>
+         <property name="left_attach">0</property>
+         <property name="right_attach">1</property>
+         <property name="top_attach">1</property>
+         <property name="bottom_attach">2</property>
+         <property name="x_options">fill</property>
+         <property name="y_options"></property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkEntry" id="findEntry">
+         <property name="visible">True</property>
+         <property name="can_default">True</property>
+         <property name="has_default">True</property>
+         <property name="can_focus">True</property>
+         <property name="has_focus">True</property>
+         <property name="editable">True</property>
+         <property name="visibility">True</property>
+         <property name="max_length">0</property>
+         <property name="text" translatable="yes"></property>
+         <property name="has_frame">True</property>
+         <property name="invisible_char">*</property>
+         <property name="activates_default">False</property>
+       </widget>
+       <packing>
+         <property name="left_attach">1</property>
+         <property name="right_attach">2</property>
+         <property name="top_attach">0</property>
+         <property name="bottom_attach">1</property>
+         <property name="y_options"></property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkEntry" id="replaceEntry">
+         <property name="visible">True</property>
+         <property name="can_focus">True</property>
+         <property name="editable">True</property>
+         <property name="visibility">True</property>
+         <property name="max_length">0</property>
+         <property name="text" translatable="yes"></property>
+         <property name="has_frame">True</property>
+         <property name="invisible_char">*</property>
+         <property name="activates_default">False</property>
+       </widget>
+       <packing>
+         <property name="left_attach">1</property>
+         <property name="right_attach">2</property>
+         <property name="top_attach">1</property>
+         <property name="bottom_attach">2</property>
+         <property name="y_options"></property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHBox" id="hbox19">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">5</property>
+
+         <child>
+           <widget class="GtkVBox" id="vbox9">
+             <property name="visible">True</property>
+             <property name="homogeneous">False</property>
+             <property name="spacing">0</property>
+
+             <child>
+               <placeholder/>
+             </child>
+
+             <child>
+               <placeholder/>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="findButton">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-find</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="findReplButton">
+             <property name="visible">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="alignment13">
+                 <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="hbox20">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">2</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image357">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-find-and-replace</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="label19">
+                         <property name="visible">True</property>
+                         <property name="label">Replace</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="cancelButton">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-cancel</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="left_attach">0</property>
+         <property name="right_attach">2</property>
+         <property name="top_attach">2</property>
+         <property name="bottom_attach">3</property>
+         <property name="y_padding">5</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 0d0fa1ba8c863df9bcd689054eb16a88e8f1f8fa..b54dbb777f2e57f7e898d5510f7dcf7b0232ca03 100644 (file)
@@ -109,6 +109,7 @@ class gui () =
   let main = new mainWin () in
   let about = new aboutWin () in
   let fileSel = new fileSelectionWin () in
+  let findRepl = new findReplWin () in
   let keyBindingBoxes = (* event boxes which should receive global key events *)
     [ main#mainWinEventBox ]
   in
@@ -137,7 +138,7 @@ class gui () =
         (* 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 about; c fileSel; c main; c findRepl]);
         (* key bindings *)
       List.iter (* global key bindings *)
         (fun (key, callback) -> self#addKeyBinding key callback)
@@ -156,6 +157,44 @@ class gui () =
         about#aboutWin#misc#hide ());
       about#aboutLabel#set_label (Pcre.replace ~pat:"@VERSION@"
         ~templ:BuildTimeConf.version about#aboutLabel#label);
+        (* findRepl win *)
+      let show_find_Repl () = 
+        findRepl#toplevel#misc#show ();
+        findRepl#toplevel#misc#grab_focus ()
+      in
+      let hide_find_Repl () = findRepl#toplevel#misc#hide () in
+      let find_forward _ = 
+          let highlight start end_ =
+            source_buffer#move_mark `INSERT ~where:start;
+            source_buffer#move_mark `SEL_BOUND ~where:end_
+          in
+          let text = findRepl#findEntry#text in
+          let iter = source_buffer#get_iter `SEL_BOUND in
+          match iter#forward_search text with
+          | None -> 
+              (match source_buffer#start_iter#forward_search text with
+              | None -> ()
+              | Some (start,end_) -> highlight start end_)
+          | Some (start,end_) -> highlight start end_ 
+      in
+      let replace _ =
+        let text = findRepl#replaceEntry#text in
+        let ins = source_buffer#get_iter `INSERT in
+        let sel = source_buffer#get_iter `SEL_BOUND in
+        if ins#compare sel < 0 then 
+          begin
+            ignore(source_buffer#delete_selection ());
+            source_buffer#insert text
+          end
+      in
+      connect_button findRepl#findButton find_forward;
+      connect_button findRepl#findReplButton replace;
+      connect_button findRepl#cancelButton (fun _ -> hide_find_Repl ());
+      ignore(findRepl#toplevel#event#connect#delete 
+        ~callback:(fun _ -> hide_find_Repl ();true));
+      ignore(self#main#findReplMenuItem#connect#activate
+        ~callback:show_find_Repl);
+      ignore (findRepl#findEntry#connect#activate ~callback:find_forward);
         (* file selection win *)
       ignore (fileSel#fileSelectionWin#event#connect#delete (fun _ -> true));
       ignore (fileSel#fileSelectionWin#connect#response (fun event ->
@@ -419,6 +458,7 @@ class gui () =
     method sourceView: GSourceView.source_view = (source_view: GSourceView.source_view)
     method about = about
     method fileSel = fileSel
+    method findRepl = findRepl
     method main = main
 
     method newBrowserWin () =
index 18fe330161f5b376713037e109e477af8a41d21f..6f9601f710475b740fa1529dd9549850ee5f5bfd 100644 (file)
@@ -51,6 +51,7 @@ object
   method about :        MatitaGeneratedGui.aboutWin
   method fileSel :      MatitaGeneratedGui.fileSelectionWin
   method main :         MatitaGeneratedGui.mainWin
+  method findRepl :     MatitaGeneratedGui.findReplWin
 (*   method toolbar :      MatitaGeneratedGui.toolBarWin *)
 
   method console:       console