From aa4eb8949201e7a7b54e3459ec0fe271e126049c Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Thu, 15 Nov 2001 12:33:20 +0000 Subject: [PATCH] First commit towards the 0.2.8 version. --- helm/DEVEL/lablgtkmathview/Makefile.in | 172 ++++++++----------- helm/DEVEL/lablgtkmathview/configure.in | 64 ++----- helm/DEVEL/lablgtkmathview/gMathView.ml | 15 +- helm/DEVEL/lablgtkmathview/gtkMathView.ml | 42 +++-- helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c | 15 +- helm/DEVEL/lablgtkmathview/test/Makefile | 47 ++--- helm/DEVEL/lablgtkmathview/test/test.ml | 89 ++++++++-- helm/DEVEL/lablgtkmathview/test/test.xml | 21 ++- 8 files changed, 238 insertions(+), 227 deletions(-) diff --git a/helm/DEVEL/lablgtkmathview/Makefile.in b/helm/DEVEL/lablgtkmathview/Makefile.in index 3d7bd5d89..e2fcf1965 100644 --- a/helm/DEVEL/lablgtkmathview/Makefile.in +++ b/helm/DEVEL/lablgtkmathview/Makefile.in @@ -1,119 +1,95 @@ -# Makefile for lablgtk_mathview. - PACKAGE = @PACKAGE@ VERSION = @VERSION@ -LABLGTKDIR = @LABLGTK_LIB_DIR@ -MLMINIDOMDIR = @MLMINIDOM_LIB_DIR@ -TESTDIR = ./test -MLFLAGS += -I $(LABLGTKDIR) -I $(MLMINIDOMDIR) - +INCLUDEDIR = @OCAML_INCLUDE_DIR@ +PREFIX = +OBJECTS_C = ml_gtk_mathview.o +OBJECTS = gtk_mathview.cmo gtkMathView.cmo gMathView.cmo +OBJECTS_OPT = gtkMathView.cmx gtk_mathview.cmx gMathView.cmx +INST = META gMathView.cmi gtkMathView.cmi gtk_mathview.cmi DIST_FILES = \ AUTHORS COPYING ChangeLog LICENSE Makefile.in NEWS README configure \ configure.in configure.mk gMathView.ml gtkMathView.ml gtk_mathview.ml \ - ml_gtk_mathview.c + ml_gtk_mathview.c META.in +DOC_FILES = AUTHORS COPYING ChangeLog NEWS README +REQUIRES = mlminidom lablgtk +PREDICATES = +MLFLAGS = -labels + +OCAMLC = ocamlfind ocamlc $(MLFLAGS) +OCAMLOPT = ocamlfind ocamlopt $(MLFLAGS) +OCAMLDEP = ocamldep -TARGETS = ml_gtk_mathview.o lablgtkmathview.cma +ARCHIVE = $(PACKAGE).cma +ARCHIVE_C = $(PACKAGE).a +ARCHIVE_OPT = $(PACKAGE).cmxa -all: $(TARGETS) +TESTDIR = ./test +TMPDIR = .test +TMPPKGDIR = $(TMPDIR)/$(PACKAGE) + +all: $(OBJECTS_C) $(ARCHIVE) $(TESTDIR)/test -opt: lablgtkmathviewopt +opt: $(OBJECTS_C) $(ARCHIVE_OPT) $(TESTDIR)/test.opt dist: - rm -rf lablgtkmathview-$(VERSION) - mkdir lablgtkmathview-$(VERSION) - cp $(DIST_FILES) lablgtkmathview-$(VERSION) - tar cvfz lablgtkmathview-$(VERSION).tar.gz lablgtkmathview-$(VERSION) - rm -rf lablgtkmathview-$(VERSION) - -configure: - @rm -f config.make - @$(MAKE) --no-print-directory -f configure.mk - -depend: - @rm -f .depend - @$(MAKE) --no-print-directory -f configure.mk .depend - -.depend config.make: - @$(MAKE) --no-print-directory -f configure.mk - -COMPILER = $(CAMLC) $(MLFLAGS) -w s -labels -c -LINKER = $(CAMLC) $(MLFLAGS) -COMPOPT = $(CAMLOPT) $(MLFLAGS) -w s -labels -c -LINKOPT = $(CAMLOPT) $(MLFLAGS) - -include config.make - -INSTALLDIR = $(LIBDIR)/lablgtkmathview - -MLLIBS = lablgtkmathview.cma -CLIBS = -MLLINK = unix.cma str.cma - -ifdef DEBUG -CFLAGS = -g $(GTKCFLAGS) -MLLINK += -cclib -lcamlrund -MLFLAGS += -g -else -CFLAGS = -O -DGTK_NO_CHECK_CASTS -DGTK_DISABLE_COMPAT_H $(GTKCFLAGS) -endif -CFLAGS += $(MINIDOMCFLAGS) $(GTKMATHVIEWCFLAGS) - -THFLAGS = -thread -THLINK = unix.cma threads.cma - -ifdef USE_CC -CCOMPILER = $(CC) -c -I$(LIBDIR) $(CFLAGS) -else -CCOMPILER = ocamlc -c -ccopt "$(CFLAGS)" -endif - -# Rules -.SUFFIXES: .ml .mli .cmo .cmi .cmx .c .o .var .h .opt .def -.c.o: - $(CCOMPILER) $< + rm -rf $(PACKAGE)-$(VERSION) + mkdir $(PACKAGE)-$(VERSION) + cp $(DIST_FILES) $(DOC_FILES) $(PACKAGE)-$(VERSION) + tar cvfz $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) + rm -rf $(PACKAGE)-$(VERSION) + +ml_gtk_mathview.o: ml_gtk_mathview.c + gcc -c -I$(INCLUDEDIR) `ocamlfind query -i-format lablgtk` `glib-config --cflags` `minidom-config --cflags` `gtk-config --cflags` `gtkmathview-config --cflags` `ocamlfind query -i-format mlminidom` $< + +.SUFFIXES: .cmo .cmi .cmx .ml .mli + .ml.cmo: - $(COMPILER) $< + $(OCAMLC) -package "$(REQUIRES)" -predicates "$(PREDICATES)" \ + -c $< .mli.cmi: - $(COMPILER) $< + $(OCAMLC) -package "$(REQUIRES)" -predicates "$(PREDICATES)" \ + -c $< .ml.cmx: - $(COMPOPT) $< -.var.h: - ./var2def < $< > $@ -.var.c: - ./var2conv < $< > $@ + $(OCAMLOPT) -package "$(REQUIRES)" -predicates "$(PREDICATES)" \ + -c $< + +depend: *.ml *.mli + $(OCAMLDEP) *.ml *.mli >.depend +include .depend + +$(ARCHIVE): $(OBJECTS) + $(OCAMLC) -a -custom -package "$(REQUIRES)" \ + -predicates "$(PREDICATES)" -o $@ $^ \ + -cclib "`glib-config --libs` `minidom-config --libs` `gtkmathview-config --libs`" -# Targets -COBJS = ml_gtk_mathview.o -MLOBJS = gtk_mathview.cmo gtkMathView.cmo gMathView.cmo -ALLOBJS = $(MLOBJS) +$(ARCHIVE_OPT): $(OBJECTS_OPT) + $(OCAMLOPT) -a -package "$(REQUIRES)" \ + -predicates "$(PREDICATES)" -o $@ $^ \ + -cclib "`glib-config --libs` `minidom-config --libs` `gtkmathview-config --libs`" -lablgtkmathviewopt: $(CLIBS) $(MLLIBS:.cma=.cmxa) +$(TESTDIR)/test: $(OBJECTS_C) $(ARCHIVE) $(TESTDIR)/test.ml + mkdir -p $(TMPPKGDIR) + cp $(OBJECTS_C) $(ARCHIVE) $(INST) $(TMPPKGDIR) + cd $(TESTDIR) ; export OCAMLPATH=../$(TMPDIR):$$OCAMLPATH ; make + rm -r $(TMPDIR) + +$(TESTDIR)/test.opt: $(OBJECTS_C) $(ARCHIVE_C) $(ARCHIVE_OPT) $(TESTDIR)/test.ml + mkdir -p $(TMPPKGDIR) + cp $(OBJECTS_C) $(ARCHIVE_C) $(ARCHIVE_OPT) $(INST) $(TMPPKGDIR) + cd $(TESTDIR) ; export OCAMLPATH=../$(TMPDIR):$$OCAMLPATH ; make opt + rm -r $(TMPDIR) install: - if test -d $(INSTALLDIR); then : ; else mkdir -p $(INSTALLDIR); fi - cp $(ALLOBJS:.cmo=.cmi) $(INSTALLDIR) - if test -f *.mli ; then cp *.mli $(INSTALLDIR) ; fi - cp $(ALLOBJS:.cmo=.ml) $(INSTALLDIR) - cp $(MLLIBS) $(INSTALLDIR) - cp $(COBJS) $(INSTALLDIR) - if test ! -z "$(CLIBS)" ; then cp $(CLIBS) $(INSTALLDIR) ; fi - if test -f lablgtkmathview.cmxa; then \ - cp $(MLLIBS:.cma=.cmxa) $(MLLIBS:.cma=.a) \ - $(INSTALLDIR); fi - -lablgtkmathview.cma: $(MLOBJS) - $(LINKER) -a -custom -o $@ $(MLOBJS) $(GTKLIBS) -cclib "$(GTKMATHVIEWLIBS)" -cclib "$(MINIDOMLIBS)" -lablgtkmathview.cmxa: $(MLOBJS:.cmo=.cmx) - $(LINKOPT) -a -o $@ $(MLOBJS:.cmo=.cmx) $(GTKLIBS) -cclib "$(GTKMATHVIEWLIBS)" -cclib "$(MINIDOMLIBS)" - -ml_gtk.o: $(LABLGTKDIR)/gtk_tags.c $(LABLGTKDIR)/gtk_tags.h \ - $(LABLGTKDIR)/ml_gtk.h $(LABLGTKDIR)/ml_gdk.h $(LABLGTKDIR)/wrappers.h + test ! -f $(ARCHIVE_OPT) || extra="$(ARCHIVE_C) $(ARCHIVE_OPT)" ; \ + ocamlfind install $(PACKAGE) $(OBJECTS_C) $(ARCHIVE) $(INST) $$extra + +uninstall: + ocamlfind remove $(PACKAGE) clean: - rm -f *.cm* *.o *.a *_tags.[ch] $(TARGETS) - cd $(TESTDIR); make clean + rm -f *.o *.cm? $(ARCHIVE) $(ARCHIVE_C) $(ARCHIVE_OPT) + cd test ; make clean + rm -rf $(TMPDIR) distclean: clean - rm -f configure config.cache config.status config.log Makefile - -include .depend + rm -f config.log config.cache config.status Makefile META lablgtkmathview.spec diff --git a/helm/DEVEL/lablgtkmathview/configure.in b/helm/DEVEL/lablgtkmathview/configure.in index cccc5ea1a..c5546f28c 100644 --- a/helm/DEVEL/lablgtkmathview/configure.in +++ b/helm/DEVEL/lablgtkmathview/configure.in @@ -4,13 +4,10 @@ PACKAGE=lablgtkmathview LABLGTKMATHVIEW_MAJOR_VERSION=0 LABLGTKMATHVIEW_MINOR_VERSION=2 -LABLGTKMATHVIEW_MICRO_VERSION=4 +LABLGTKMATHVIEW_MICRO_VERSION=8 LABLGTKMATHVIEW_VERSION=$LABLGTKMATHVIEW_MAJOR_VERSION.$LABLGTKMATHVIEW_MINOR_VERSION.$LABLGTKMATHVIEW_MICRO_VERSION VERSION=$LABLGTKMATHVIEW_VERSION -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) - AC_CHECK_PROG(HAVE_GTKMATHVIEW, gtkmathview-config, yes, no) if test $HAVE_GTKMATHVIEW = "no"; then AC_MSG_ERROR(could not find gtkmathview configuration script, please make sure gtkmathview is installed) @@ -21,56 +18,27 @@ if test $HAVE_OCAMLC = "no"; then AC_MSG_ERROR(could not find ocamlc in PATH, please make sure ocaml is installed) fi -AC_MSG_CHECKING(for the ocaml library dir) -OCAML_LIB_DIR=`ocamlc -v | grep "^Standard" | sed 's/^.*: *//'` -AC_MSG_RESULT($OCAML_LIB_DIR) - -AC_CHECK_FILE($OCAML_LIB_DIR/lablgtk/gtk.ml, - RES="yes" - LABLGTK_LIB_DIR=$OCAML_LIB_DIR/lablgtk, - RES="no" -) - -if test $RES = "no"; then - RES="" - AC_CACHE_VAL(lablgtkmathview_cv_LABLGTK_LIB_DIR, - echo "In which directory can I find the lablgtk library? (I haven't found it in the usual location $OCAML_LIB_DIR/lablgtk)" - read lablgtkmathview_cv_LABLGTK_LIB_DIR - RES="Asked" - ) - LABLGTK_LIB_DIR=$lablgtkmathview_cv_LABLGTK_LIB_DIR - if test "$RES" != "Asked"; then - LABLGTK_LIB_DIR=`eval "echo $LABLGTK_LIB_DIR"` - fi - AC_CACHE_SAVE +AC_CHECK_PROG(HAVE_OCAMLFIND, ocamlfind, yes, no) +if test $HAVE_OCAMLFIND = "no"; then + AC_MSG_ERROR(could not find ocamlfind in PATH, please make sure findlib is installed) fi -AC_CHECK_FILE($OCAML_LIB_DIR/mlminidom/minidom.mli, - RES="yes" - MLMINIDOM_LIB_DIR=$OCAML_LIB_DIR/mlminidom, - RES="no" -) +AC_MSG_CHECKING("for the ocaml library dir") +OCAML_LIB_DIR=`ocamlc -where` +AC_MSG_RESULT($OCAML_LIB_DIR) -if test $RES = "no"; then - RES="" - AC_CACHE_VAL(lablgtkmathview_cv_MLMINIDOM_LIB_DIR, - echo "In which directory can I find the mlminidom library? (I haven't found it in the usual location $OCAML_LIB_DIR/mlminidom)" - read lablgtkmathview_cv_MLMINIDOM_LIB_DIR - RES="Asked" - ) - MLMINIDOM_LIB_DIR=$lablgtkmathview_cv_MLMINIDOM_LIB_DIR - if test "$RES" != "Asked"; then - MLMINIDOM_LIB_DIR=`eval "echo $MLMINIDOM_LIB_DIR"` - fi - AC_CACHE_SAVE -fi +AC_CHECK_FILE(/usr/include/caml/mlvalues.h, + OCAML_INCLUDE_DIR=/usr/include/caml, + OCAML_INCLUDE_DIR=$OCAML_LIB_DIR/caml +) -AC_SUBST(LABLGTKMATHVIEW_VERSION) -AC_SUBST(OCAML_LIB_DIR) -AC_SUBST(LABLGTK_LIB_DIR) -AC_SUBST(MLMINIDOM_LIB_DIR) +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) +AC_SUBST(OCAML_INCLUDE_DIR) AC_OUTPUT([ + test/Makefile Makefile lablgtkmathview.spec + META ]) diff --git a/helm/DEVEL/lablgtkmathview/gMathView.ml b/helm/DEVEL/lablgtkmathview/gMathView.ml index b937831f7..00c239afc 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gMathView.ml @@ -29,14 +29,16 @@ open GObj exception ErrorLoadingFile of string;; exception ErrorWritingFile of string;; +exception ErrorLoadingDOM;; exception NoSelection;; class math_view_signals obj = object inherit GContainer.container_signals obj method clicked = GtkSignal.connect ~sgn:MathView.Signals.clicked obj ~after - method jump = GtkSignal.connect ~sgn:MathView.Signals.jump obj ~after method selection_changed = - GtkSignal.connect ~sgn:MathView.Signals.selection_changed obj ~after + GtkSignal.connect ~sgn:MathView.Signals.selection_changed obj ~after + method element_changed = + GtkSignal.connect ~sgn:MathView.Signals.element_changed obj ~after end class math_view obj = object @@ -44,6 +46,8 @@ class math_view obj = object method connect = new math_view_signals obj method load ~filename = if not (MathView.load obj ~filename) then raise (ErrorLoadingFile filename) + method load_tree ~dom = + if not (MathView.load_tree obj ~dom) then raise ErrorLoadingDOM method unload = MathView.unload obj method get_selection = MathView.get_selection obj method set_selection (node : Ominidom.o_mDOMNode option) = MathView.set_selection obj node @@ -65,6 +69,8 @@ class math_view obj = object method get_anti_aliasing = MathView.get_anti_aliasing obj method set_kerning = MathView.set_kerning obj method get_kerning = MathView.get_kerning obj + method set_transparency = MathView.set_transparency obj + method get_transparency = MathView.get_transparency obj method set_log_verbosity = MathView.set_log_verbosity obj method get_log_verbosity = MathView.get_log_verbosity obj method export_to_postscript @@ -76,6 +82,11 @@ class math_view obj = object if not result then raise (ErrorWritingFile filename) method get_font_manager_type = MathView.get_font_manager_type obj method set_font_manager_type ~fm_type = MathView.set_font_manager_type obj ~fm_type + method get_element = MathView.get_element obj + method action_get_selected = MathView.action_get_selected obj + method action_set_selected = MathView.action_set_selected obj + method get_action = MathView.get_action obj + method action_toggle = MathView.action_toggle obj end let math_view ?adjustmenth ?adjustmentv ?font_size ?font_manager ?border_width diff --git a/helm/DEVEL/lablgtkmathview/gtkMathView.ml b/helm/DEVEL/lablgtkmathview/gtkMathView.ml index f4edcf588..eed812d9e 100644 --- a/helm/DEVEL/lablgtkmathview/gtkMathView.ml +++ b/helm/DEVEL/lablgtkmathview/gtkMathView.ml @@ -28,11 +28,11 @@ open Gpointer external mDOMNode_of_boxed_option : Gpointer.boxed option -> Minidom.mDOMNode = - "ml_gtk_math_view_mDOMNode_of_bodex_option" + "ml_gtk_math_view_mDOMNode_of_boxed_option" external mDOMNode_option_of_boxed_option : Gpointer.boxed option -> Minidom.mDOMNode option = - "ml_gtk_math_view_mDOMNode_option_of_bodex_option" + "ml_gtk_math_view_mDOMNode_option_of_boxed_option" let o_mDOMNode_of_mDOMNode node = new Ominidom.o_mDOMNode node @@ -56,6 +56,10 @@ module MathView = struct create (optboxed adjustmenth) (optboxed adjustmentv) external load : [>`math_view] obj -> filename:string -> bool = "ml_gtk_math_view_load" + external raw_load_tree : [>`math_view] obj -> Minidom.mDOMDoc -> bool = + "ml_gtk_math_view_load_tree" + let load_tree obj ~(dom:Ominidom.o_mDOMDoc) = + raw_load_tree obj dom#get_dom_doc external unload : [>`math_view] obj -> unit = "ml_gtk_math_view_unload" external raw_get_selection : [>`math_view] obj -> Minidom.mDOMNode option = @@ -96,6 +100,10 @@ module MathView = struct "ml_gtk_math_view_set_kerning" external get_kerning : [>`math_view] obj -> bool = "ml_gtk_math_view_get_kerning" + external set_transparency : [>`math_view] obj -> bool -> unit = + "ml_gtk_math_view_set_transparency" + external get_transparency : [>`math_view] obj -> bool = + "ml_gtk_math_view_get_transparency" external set_log_verbosity : [>`math_view] obj -> int -> unit = "ml_gtk_math_view_set_log_verbosity" external get_log_verbosity : [>`math_view] obj -> int = @@ -109,6 +117,20 @@ module MathView = struct external set_font_manager_type : [>`math_view] obj -> fm_type:[`font_manager_gtk | `font_manager_t1] -> unit = "ml_gtk_math_view_set_font_manager_type" + external raw_get_element : [>`math_view] obj -> Minidom.mDOMNode option = + "ml_gtk_math_view_get_element" + let get_element obj = + o_mDOMNode_option_of_mDOMNode_option (raw_get_element obj) + external action_get_selected : [>`math_view] obj -> int = + "ml_gtk_math_view_action_get_selected" + external action_set_selected : [>`math_view] obj -> int -> unit = + "ml_gtk_math_view_action_set_selected" + external raw_get_action : [>`math_view] obj -> Minidom.mDOMNode option = + "ml_gtk_math_view_get_action" + let get_action obj = + o_mDOMNode_option_of_mDOMNode_option (raw_get_action obj) + external action_toggle : [>`math_view] obj -> unit = + "ml_gtk_math_view_action_toggle" module Signals = struct open GtkSignal @@ -121,14 +143,6 @@ module MathView = struct in { name = "clicked"; marshaller = marshal_clicked } - let jump : ([>`math_view],_) t = - let marshal_jump f _ = - function - [GtkArgv.POINTER node] -> f (o_mDOMNode_of_mDOMNode (mDOMNode_of_boxed_option node)) - | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_jump" - in - { name = "jump"; marshaller = marshal_jump } - let selection_changed : ([>`math_view],_) t = let marshal_selection_changed f _ = function @@ -136,5 +150,13 @@ module MathView = struct | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_selection_changed" in { name = "selection_changed"; marshaller = marshal_selection_changed } + + let element_changed : ([>`math_view],_) t = + let marshal_element_changed f _ = + function + [GtkArgv.POINTER node] -> f (o_mDOMNode_option_of_mDOMNode_option (mDOMNode_option_of_boxed_option node)) + | _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_element_changed" + in + { name = "element_changed"; marshaller = marshal_element_changed } end end diff --git a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c index 0cb2728d7..5038e8b86 100644 --- a/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c +++ b/helm/DEVEL/lablgtkmathview/ml_gtk_mathview.c @@ -40,7 +40,7 @@ #include #include -#include "mlminidom/ml_minidom.h" +#include "ml_minidom.h" #define GtkMathView_val(val) check_cast(GTK_MATH_VIEW,val) @@ -71,8 +71,8 @@ value_of_font_manager_id(FontManagerId id) ML_2 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Val_GtkWidget_sink) ML_2 (gtk_math_view_load, GtkMathView_val, String_val, Val_bool) +ML_2 (gtk_math_view_load_tree, GtkMathView_val, mDOMDocRef_val, Val_bool) ML_1 (gtk_math_view_unload, GtkMathView_val, Unit) -/*ML_1 (gtk_math_view_dump, GtkMathView_val, Unit)*/ ML_1 (gtk_math_view_get_selection, GtkMathView_val, Val_mDOMNodeRef) ML_2 (gtk_math_view_set_selection, GtkMathView_val, mDOMNodeRef_val, Unit) ML_1 (gtk_math_view_get_width, GtkMathView_val, Val_int) @@ -89,10 +89,17 @@ ML_2 (gtk_math_view_set_anti_aliasing, GtkMathView_val, Bool_val, Unit) ML_1 (gtk_math_view_get_anti_aliasing, GtkMathView_val, Val_bool) ML_2 (gtk_math_view_set_kerning, GtkMathView_val, Bool_val, Unit) ML_1 (gtk_math_view_get_kerning, GtkMathView_val, Val_bool) +ML_2 (gtk_math_view_set_transparency, GtkMathView_val, Bool_val, Unit) +ML_1 (gtk_math_view_get_transparency, GtkMathView_val, Val_bool) ML_2 (gtk_math_view_set_log_verbosity, GtkMathView_val, Int_val, Unit) ML_1 (gtk_math_view_get_log_verbosity, GtkMathView_val, Val_int) ML_2 (gtk_math_view_set_font_manager_type, GtkMathView_val, font_manager_id_of_value, Unit) ML_1 (gtk_math_view_get_font_manager_type, GtkMathView_val, value_of_font_manager_id) +ML_1 (gtk_math_view_get_element, GtkMathView_val, Val_mDOMNodeRef) +ML_1 (gtk_math_view_get_action, GtkMathView_val, Val_mDOMNodeRef) +ML_1 (gtk_math_view_action_get_selected, GtkMathView_val, Val_int) +ML_2 (gtk_math_view_action_set_selected, GtkMathView_val, Int_val, Unit) +ML_1 (gtk_math_view_action_toggle, GtkMathView_val, Unit) value ml_gtk_math_view_export_to_postscript_native(value arg1, @@ -135,7 +142,7 @@ value ml_gtk_math_view_get_top (value arg1) } -value ml_gtk_math_view_mDOMNode_of_bodex_option (value arg1) +value ml_gtk_math_view_mDOMNode_of_boxed_option (value arg1) { CAMLparam1(arg1); @@ -160,7 +167,7 @@ value ml_gtk_math_view_mDOMNode_of_bodex_option (value arg1) CAMLreturn(res); } -value ml_gtk_math_view_mDOMNode_option_of_bodex_option (value arg1) +value ml_gtk_math_view_mDOMNode_option_of_boxed_option (value arg1) { CAMLparam1(arg1); diff --git a/helm/DEVEL/lablgtkmathview/test/Makefile b/helm/DEVEL/lablgtkmathview/test/Makefile index 514d24640..32f932145 100644 --- a/helm/DEVEL/lablgtkmathview/test/Makefile +++ b/helm/DEVEL/lablgtkmathview/test/Makefile @@ -1,45 +1,18 @@ -LABLGTK_DIR = /usr/lib/ocaml/lablgtk -LABLGTK_MATHVIEW_DIR = .. -MINIDOM_DIR = /usr/lib/ocaml/mlminidom -OCAMLC = ocamlc -I $(LABLGTK_DIR) -I $(LABLGTK_MATHVIEW_DIR) \ - -I $(MINIDOM_DIR) -I mlmathview -OCAMLOPT = ocamlopt -I $(LABLGTK_DIR) -I $(LABLGTK_MATHVIEW_DIR) \ - -I $(MINIDOM_DIR) -I mlmathview +# Generated automatically from Makefile.in by configure. +PACKAGE = lablgtkmathview +MLFLAGS = +OCAMLC = ocamlfind ocamlc $(MLFLAGS) +OCAMLOPT = ocamlfind ocamlopt $(MLFLAGS) +TMPDIR = .test all: test opt: test.opt -test: test.cmo - $(OCAMLC) -custom -o test lablgtk.cma gtkInit.cmo \ - $(MINIDOM_DIR)/minidom.cmo \ - $(MINIDOM_DIR)/ominidom.cmo \ - $(LABLGTK_MATHVIEW_DIR)/lablgtkmathview.cma \ - -cclib "$(MINIDOM_DIR)/ml_minidom.o" \ - test.cmo \ - -cclib "-lstr -L/usr/lib -L/usr/X11R6/lib -lgtk -lgdk \ - -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm \ - -L/usr/local/lib/gtkmathview -lgtkmathview \ - $(LABLGTK_MATHVIEW_DIR)/ml_gtk_mathview.o" +test: test.ml + $(OCAMLC) -package "$(PACKAGE)" -linkpkg -predicates "" -o $@ test.ml -test.opt: test.cmx - $(OCAMLOPT) -o test.opt lablgtk.cmxa gtkInit.cmx \ - $(MINIDOM_DIR)/minidom.cmx \ - $(MINIDOM_DIR)/ominidom.cmx \ - $(LABLGTK_MATHVIEW_DIR)/lablgtkmathview.cmxa \ - -cclib "$(MINIDOM_DIR)/ml_minidom.o" \ - test.cmx \ - -cclib "-lstr -L/usr/lib -L/usr/X11R6/lib -lgtk -lgdk \ - -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm \ - -L/usr/local/lib/gtkmathview -lgtkmathview \ - $(LABLGTK_MATHVIEW_DIR)/ml_gtk_mathview.o" - -.SUFFIXES: .ml .mli .cmo .cmi .cmx -.ml.cmo: - $(OCAMLC) -c $< -.mli.cmi: - $(OCAMLC) -c $< -.ml.cmx: - $(OCAMLOPT) -c $< +test.opt: test.ml + $(OCAMLOPT) -package "$(PACKAGE)" -linkpkg -predicates "" -o $@ test.ml clean: rm -f *.cm[iox] *.o test test.opt t1lib.log test.ps diff --git a/helm/DEVEL/lablgtkmathview/test/test.ml b/helm/DEVEL/lablgtkmathview/test/test.ml index 3e2edeed1..855ce9584 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.ml @@ -29,16 +29,6 @@ (******************************************************************************) (* Callbacks *) -let jump (node : Ominidom.o_mDOMNode) = - let module O = Ominidom in - print_string ("jump: " ^ - (match node#get_attribute (O.o_mDOMString_of_string "href") with - | Some x -> x#get_string - | None -> "NO HREF FOR THIS NODE" - ) ^ "\n"); - flush stdout -;; - let selection_changed mathview (node : Ominidom.o_mDOMNode option) = let module O = Ominidom in print_string ("selection_changed: " ^ @@ -54,14 +44,51 @@ let selection_changed mathview (node : Ominidom.o_mDOMNode option) = ;; -let clicked (node : Ominidom.o_mDOMNode) = +let rec jump (node : Ominidom.o_mDOMNode) = let module O = Ominidom in - print_string ("clicked: " ^ - (match node#get_name with - | Some x -> x#get_string - | None -> "no name" - ) ^ "\n"); - flush stdout + match node#get_attribute (O.o_mDOMString_of_string "href") with + None -> + begin + try + let p = node#get_parent in + jump p + with + O.Node_has_no_parent -> + print_string "jump: NO HREF FOR THIS NODE\n" ; + flush stdout ; + false + end + | Some x -> + print_string ("jump: " ^ x#get_string ^ "\n") ; + flush stdout ; + true +;; + +let clicked mathview (node : Ominidom.o_mDOMNode) = + let module O = Ominidom in + if not (jump node) then + match mathview#get_action with + Some n -> + mathview#action_toggle ; + print_string ("current action selection: " ^ + string_of_int mathview#action_get_selected ^ "\n") ; + flush stdout ; + | None -> + print_string ("mouse is on: " ^ + (match (mathview#get_element : Ominidom.o_mDOMNode option) with + Some e -> + (match e#get_name with + Some x -> x#get_string + | None -> "no name" + ) + | None -> "NO ELEMENT!\n" + ) ^ "\n") ; + print_string ("clicked: " ^ + (match node#get_name with + Some x -> x#get_string + | None -> "no name" + ) ^ "\n") ; + flush stdout ;; @@ -88,12 +115,31 @@ let get_font_manager_type mathview () = flush stdout ;; +let get_transparency mathview () = + print_string ("CURRENT TRANSPARENCY: " ^ + (if mathview#get_transparency then "ON" else "OFF") ^ "\n") ; + flush stdout +;; + +let set_transparency mathview () = + mathview#set_transparency (not mathview#get_transparency) ; + print_string "TRANSPARENCY CHANGED\n" ; + flush stdout +;; + + let load mathview () = mathview#load "test.xml" ; print_string "load: SEEMS TO WORK\n" ; flush stdout ;; +let load_dom mathview () = + mathview#load_tree (new Ominidom.o_mDOMDoc (Minidom.doc_load "test.xml")) ; + print_string "load from DOM: SEEMS TO WORK\n" ; + flush stdout +;; + let get_selection mathview () = let module O = Ominidom in let selection = @@ -284,6 +330,9 @@ let button_get_log_verbosity = GButton.button ~label:"get_log_verbosity" ~packin let button_export_to_postscript = GButton.button ~label:"export_to_postscript" ~packing:(table#attach ~left:2 ~top:4) () in let button_t1 = GButton.button ~label:"activate T1 fonts" ~packing:(table#attach ~left:3 ~top:4) () in let button_get_font_manager_type = GButton.button ~label:"get_font_manager" ~packing:(table#attach ~left:4 ~top:4) () in +let button_get_transparency = GButton.button ~label:"get_transparency" ~packing:(table#attach ~left:0 ~top:5) () in +let button_set_transparency = GButton.button ~label:"set_transparency" ~packing:(table#attach ~left:1 ~top:5) () in +let button_load_dom = GButton.button ~label:"load from DOM" ~packing:(table#attach ~left:2 ~top:5) () in (* Signals connection *) ignore(button_gtk#connect#clicked (activate_gtk mathview)) ; ignore(button_load#connect#clicked (load mathview)) ; @@ -310,9 +359,11 @@ ignore(button_get_log_verbosity#connect#clicked (get_log_verbosity mathview)) ; ignore(button_export_to_postscript#connect#clicked (export_to_postscript mathview)) ; ignore(button_t1#connect#clicked (activate_t1 mathview)) ; ignore(button_get_font_manager_type#connect#clicked (get_font_manager_type mathview)) ; -ignore(mathview#connect#jump jump) ; -ignore(mathview#connect#clicked clicked) ; +ignore(button_get_transparency#connect#clicked (get_transparency mathview)) ; +ignore(button_set_transparency#connect#clicked (set_transparency mathview)) ; +ignore(mathview#connect#clicked (clicked mathview)) ; ignore(mathview#connect#selection_changed (selection_changed mathview)) ; +ignore(button_load_dom#connect#clicked (load_dom mathview)) ; (* Main Loop *) main_window#show () ; GMain.Main.main () diff --git a/helm/DEVEL/lablgtkmathview/test/test.xml b/helm/DEVEL/lablgtkmathview/test/test.xml index b0f8c1563..5f9ce9fc6 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.xml +++ b/helm/DEVEL/lablgtkmathview/test/test.xml @@ -3,15 +3,18 @@ - - - a - - x - - + - b - + + It's a secret! + + + a + + x + + + + b + + x -- 2.39.2