Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 8ddfbce9 authored by bguillaum's avatar bguillaum
Browse files

New gui

git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/semagramme/dep2pict/trunk@8324 7838e531-6607-4d57-9587-6c381814729c
parent 10077337
...@@ -2,40 +2,50 @@ include ../config/Makefile ...@@ -2,40 +2,50 @@ include ../config/Makefile
LOG = -DDEBUG=\"@DEBUG@\" -DINFO=\"@INFO@\" -DMESSAGE=\"@MESSAGE@\" -DWARNING=\"@WARNING@\" LOG = -DDEBUG=\"@DEBUG@\" -DINFO=\"@INFO@\" -DMESSAGE=\"@MESSAGE@\" -DWARNING=\"@WARNING@\"
opt_gtk : ui.ml ui.cmx gui.cmx main.cmx ../bin/dep2pict.opt opt_gtk : dep2pict_glade.ml dep2pict_glade.cmx gui.cmx main.cmx ../bin/dep2pict.opt
opt : main.cmx ../bin/dep2pict.opt opt : main.cmx ../bin/dep2pict.opt
ui.ml : dep2pict.glade dep2pict_glade.ml : dep2pict.glade
sed 's/<property name="invisible_char">&#x25CF;<\/property>//g' dep2pict.glade > glade.tmp @echo " ----> build file 'dep2pict_glade.ml' from 'dep2pict.glade'"
mv glade.tmp dep2pict.glade.ml lablgladecc2 dep2pict.glade > dep2pict_glade.ml
lablgladecc2 dep2pict.glade.ml > ui.ml @echo " ----> set absolute file location in 'dep2pict_glade.ml' (DATA_DIR = $(DATA_DIR))"
rm dep2pict.glade.ml sed -i back 's|dep2pict.glade|$(DATA_DIR)dep2pict.glade|g' dep2pict_glade.ml
sed 's|dep2pict.glade.ml|$(DATA_DIR)dep2pict.glade|g' ui.ml > ui.tmp rm -f dep2pict_glade.mlback
mv ui.tmp ui.ml
ui.cmx : ui.ml # dep2pict_glade.ml : dep2pict.glade
$(OCAMLOPT) -c $(LABLGTK_OPT) $(CAIRO_OPT) ui.ml # sed 's/<property name="invisible_char">&#x25CF;<\/property>//g' dep2pict.glade > glade.tmp
# mv glade.tmp dep2pict.glade.ml
# lablgladecc2 dep2pict.glade.ml > dep2pict_glade.ml
# rm dep2pict.glade.ml
# sed 's|dep2pict.glade.ml|$(DATA_DIR)dep2pict.glade|g' dep2pict_glade.ml > dep2pict_glade.tmp
# mv dep2pict_glade.tmp dep2pict_glade.ml
dep2pict_glade.cmx : dep2pict_glade.ml
$(OCAMLOPT) -c $(LABLGTK_OPT) $(CAIRO_OPT) dep2pict_glade.ml
DEP_OPT= unix.cmxa str.cmxa bigarray.cmxa $(LABLGTK_OPT) $(CAIRO_OPT) $(XML_LIGHT_OPT) $(ANSITERMINAL_OPT) $(LOG_OPT) $(DEP2PICT_OPT) DEP_OPT= unix.cmxa str.cmxa bigarray.cmxa $(LABLGTK_OPT) $(CAIRO_OPT) $(XML_LIGHT_OPT) $(ANSITERMINAL_OPT) $(LOG_OPT) $(DEP2PICT_OPT)
DEP_OPT_NOGUI= unix.cmxa str.cmxa bigarray.cmxa $(CAIRO_OPT) $(XML_LIGHT_OPT) $(ANSITERMINAL_OPT) $(LOG_OPT) $(DEP2PICT_OPT) DEP_OPT_NOGUI= unix.cmxa str.cmxa bigarray.cmxa $(CAIRO_OPT) $(XML_LIGHT_OPT) $(ANSITERMINAL_OPT) $(LOG_OPT) $(DEP2PICT_OPT)
gui.cmx : gui.ml ui.cmx global.cmx : global.ml
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) ui.cmx gui.ml $(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) global.ml
main.cmx : main.ml gui.cmx : gui.ml global.cmx dep2pict_glade.cmx
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) dep2pict_glade.cmx gui.ml
main.cmx : main.ml global.cmx
ifeq (@BUILD_GUI@,yes) ifeq (@BUILD_GUI@,yes)
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) ui.cmx gui.cmx main.ml $(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) dep2pict_glade.cmx global.cmx gui.cmx main.ml
else else
$(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) main.ml $(OCAMLOPT) -c -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) global.cmx main.ml
endif endif
../bin/dep2pict.opt : main.cmx ../bin/dep2pict.opt : main.cmx
mkdir -p ../bin mkdir -p ../bin
ifeq (@BUILD_GUI@,yes) ifeq (@BUILD_GUI@,yes)
$(OCAMLOPT) -o ../bin/dep2pict.opt -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) ui.cmx gui.cmx main.cmx $(OCAMLOPT) -o ../bin/dep2pict.opt -pp 'camlp4o pa_macro.cmo -DBUILD_GUI -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT) dep2pict_glade.cmx global.cmx gui.cmx main.cmx
else else
$(OCAMLOPT) -o ../bin/dep2pict.opt -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT_NOGUI) main.cmx $(OCAMLOPT) -o ../bin/dep2pict.opt -pp 'camlp4o pa_macro.cmo -DDATA_DIR=\"$(DATA_DIR)\" $(LOG) -DVERSION=\"$(VERSION)\"' $(DEP_OPT_NOGUI) global.cmx main.cmx
endif endif
...@@ -54,16 +54,123 @@ ...@@ -54,16 +54,123 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<widget class="GtkHButtonBox" id="hbuttonbox2"> <widget class="GtkHBox" id="hbox2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="layout_style">start</property>
<child> <child>
<widget class="GtkButton" id="edit"> <widget class="GtkHBox" id="hbox6">
<property name="label" translatable="yes">Edit</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property> <child>
<widget class="GtkButton" id="reload">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Reload (Ctrl + r)</property>
<child>
<widget class="GtkHBox" id="reload_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="save">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Save (Ctrl + s)</property>
<child>
<widget class="GtkHBox" id="save_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="save_as">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Save as</property>
<child>
<widget class="GtkHBox" id="save_as_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="edit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Edit (Ctrl + e)</property>
<child>
<widget class="GtkHBox" id="edit_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="open_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Open (Ctrl + o)</property>
<child>
<widget class="GtkHBox" id="open_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -72,24 +179,120 @@ ...@@ -72,24 +179,120 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkButton" id="open_btn"> <widget class="GtkLabel" id="void1">
<property name="label" translatable="yes">Open</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkButton" id="reload"> <widget class="GtkHBox" id="hbox3">
<property name="label" translatable="yes">Reload</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property> <child>
<widget class="GtkButton" id="first_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">First (Ctrl + ←)</property>
<child>
<widget class="GtkHBox" id="first_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="prev_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Prev (←)</property>
<child>
<widget class="GtkHBox" id="prev_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="view_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="next_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Next (→)</property>
<child>
<widget class="GtkHBox" id="next_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="last_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Last (Ctrl + →)</property>
<child>
<widget class="GtkHBox" id="last_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -98,77 +301,100 @@ ...@@ -98,77 +301,100 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkButton" id="save"> <widget class="GtkLabel" id="void">
<property name="label" translatable="yes">Save</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkButton" id="save_as"> <widget class="GtkHBox" id="hbox4">
<property name="label" translatable="yes">Save as</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="receives_default">True</property> <child>
<widget class="GtkRadioButton" id="svg_radio">
<property name="label" translatable="yes">svg</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="png_radio">
<property name="label" translatable="yes">png</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">svg_radio</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="pdf_radio">
<property name="label" translatable="yes">pdf</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">svg_radio</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="convert_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Convert (Ctrl + c)</property>
<child>
<widget class="GtkHBox" id="convert_button_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">4</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkButton" id="to_svg">
<property name="label" translatable="yes">To SVG</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="to_png">
<property name="label" translatable="yes">To PNG</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="to_pdf">
<property name="label" translatable="yes">To PDF</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
<property name="secondary">True</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
......
open Printf
open Log
type format = Dep | Conll | Xml | Png | Svg | Pdf
exception Found of format
let get_format file =
try
List.iter
(fun (ext, fmt) ->
if Filename.check_suffix file ext
then raise (Found fmt)
) [ ("dep", Dep); ("conll",Conll); ("xml",Xml); ("png",Png); ("svg",Svg); ("pdf",Pdf) ];
Log.fcritical "Unkwnow file extension for file \"%s\"" file
with Found fmt -> fmt
let string_of_format = function
| Dep -> "dep"
| Conll -> "conll"
| Xml -> "xml"
| Png -> "png"
| Svg -> "svg"
| Pdf -> "pdf"
let (input_file : string option ref) = ref None
let (output_file : string option ref) = ref None
let current_infos = ref ["pos"]
let (current_array : (string * string) array ref) = ref [||]
let (current_position : int option ref) = ref None (* position of the current_focus in the current_array *)
let current_source = ref ""
let modified = ref false
let debug = ref false
let get_pos () = match !current_position with
| None -> 0
| Some v -> v
(* -------------------------------------------------------------------------------- *)
let array_assoc key array =
let len = Array.length array in
let rec loop i =
if i = len
then raise Not_found
else
match array.(i) with
| (k,v) when k=key -> (i,v)
| _ -> loop (i+1)
in loop 0
(* -------------------------------------------------------------------------------- *)
let search_sentid sentid =
let (new_pos,_) = array_assoc sentid !current_array in
current_position := Some new_pos
(* -------------------------------------------------------------------------------- *)
let update_source () =
match !current_position with
| None -> ()
| Some p -> current_source := (snd !current_array.(p))
(* -------------------------------------------------------------------------------- *)
let first () =
current_position := Some 0;
update_source ()
(* -------------------------------------------------------------------------------- *)
let last () =
current_position := Some ((Array.length !current_array) - 1);
update_source ()
let has_more_than_one () = Array.length !current_array > 1
(* -------------------------------------------------------------------------------- *)
let next () =
match !current_position with
| Some p when p < (Array.length !current_array)-1 ->
current_position := Some (p+1);
update_source ()
| x -> ()
(* -------------------------------------------------------------------------------- *)
let has_next () =
match !current_position with
| Some p when p < (Array.length !current_array)-1 -> true
| _ -> false
(* -------------------------------------------------------------------------------- *)
let prev () =