glib-2.0.m4: New file.

* glib-2.0.m4: New file.
	* gtk-2.0.m4: New file.
	* glib.m4: Remove.
	* gtk.m4: Remove.
	* configure.in: Update AM_PATH_GTK macro call to
	AM_PATH_GTK_2_0.  Likewise for AM_PATH_GLIB.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,
	jni/gtk-peer/gthread-jni.c,
	jni/gtk-peer/gthread-jni.h:
	New versions from classpath.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* gcj/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

From-SVN: r68746
This commit is contained in:
Thomas Fitzsimmons 2003-06-30 23:53:29 +00:00 committed by Thomas Fitzsimmons
parent 884a757a31
commit 29e531ff29
23 changed files with 1653 additions and 1200 deletions

View File

@ -1,3 +1,32 @@
2003-06-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* glib-2.0.m4: New file.
* gtk-2.0.m4: New file.
* glib.m4: Remove.
* gtk.m4: Remove.
* configure.in: Update AM_PATH_GTK macro call to
AM_PATH_GTK_2_0. Likewise for AM_PATH_GLIB.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,
jni/gtk-peer/gthread-jni.c,
jni/gtk-peer/gthread-jni.h:
New versions from classpath.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* Makefile.in: Regenerate.
* gcj/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
2003-06-30 Gary Benson <gbenson@redhat.com>
For PR libgcj/11349:

View File

@ -86,10 +86,11 @@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_QUERY = @GOBJECT_QUERY@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_CONFIG = @GTK_CONFIG@
GTK_LIBS = @GTK_LIBS@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
IEEESPEC = @IEEESPEC@
@ -115,6 +116,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PLATFORMOBJS = @PLATFORMOBJS@
RANLIB = @RANLIB@
STRIP = @STRIP@
@ -4284,7 +4286,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in acinclude.m4 \
./acinclude.m4 ./aclocal.m4 ./glib.m4 ./gtk.m4 \
./acinclude.m4 ./aclocal.m4 ./glib-2.0.m4 ./gtk-2.0.m4 \
./libart.m4
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)

268
libjava/aclocal.m4 vendored
View File

@ -435,58 +435,70 @@ done<<>>dnl>>)
changequote([,]))])
# Configure paths for GTK+
# Owen Taylor 97-11-3
# Owen Taylor 1997-2001
dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
dnl pass to pkg-config
dnl
AC_DEFUN(AM_PATH_GTK,
AC_DEFUN(AM_PATH_GTK_2_0,
[dnl
dnl Get the cflags and libraries from the gtk-config script
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
gtk_config_prefix="$withval", gtk_config_prefix="")
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
, enable_gtktest=yes)
pkg_config_args=gtk+-2.0
for module in . $4
do
case "$module" in
gthread)
gtk_config_args="$gtk_config_args gthread"
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
if test x$gtk_config_exec_prefix != x ; then
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
if test x${GTK_CONFIG+set} != xset ; then
GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
fi
fi
if test x$gtk_config_prefix != x ; then
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
if test x${GTK_CONFIG+set} != xset ; then
GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
fi
no_gtk=""
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG != xno ; then
if pkg-config --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_gtk=yes
PKG_CONFIG=no
fi
else
no_gtk=yes
fi
AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
min_gtk_version=ifelse([$1], ,0.99.7,$1)
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
no_gtk=""
if test "$GTK_CONFIG" = "no" ; then
no_gtk=yes
else
GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
min_gtk_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
enable_gtktest=no
fi
if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
:
else
no_gtk=yes
fi
fi
if test x"$no_gtk" = x ; then
GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_gtktest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
@ -494,8 +506,8 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$GTK_LIBS $LIBS"
dnl
dnl Now check if the installed GTK is sufficiently new. (Also sanity
dnl checks the results of gtk-config to some extent
dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.gtktest
AC_TRY_RUN([
@ -522,19 +534,17 @@ main ()
(gtk_minor_version != $gtk_config_minor_version) ||
(gtk_micro_version != $gtk_config_micro_version))
{
printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf ("*** was found! If gtk-config was correct, then it is best\n");
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
printf("*** before re-running configure\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
(gtk_minor_version != GTK_MINOR_VERSION) ||
(gtk_micro_version != GTK_MICRO_VERSION))
@ -544,7 +554,6 @@ main ()
printf("*** library (version %d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
}
#endif /* defined (GTK_MAJOR_VERSION) ... */
else
{
if ((gtk_major_version > major) ||
@ -562,10 +571,10 @@ main ()
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
printf("*** correct copy of gtk-config. (In this case, you will have to\n");
printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
@ -578,20 +587,20 @@ main ()
fi
fi
if test "x$no_gtk" = x ; then
AC_MSG_RESULT(yes)
AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GTK_CONFIG" = "no" ; then
echo "*** The gtk-config script installed by GTK could not be found"
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GTK_CONFIG environment variable to the"
echo "*** full path to gtk-config."
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://pkgconfig.sourceforge.net"
else
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GTK test program, checking why..."
echo "*** Could not run GTK+ test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
AC_TRY_LINK([
@ -599,23 +608,16 @@ main ()
#include <stdio.h>
], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GTK or finding the wrong"
echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GTK was incorrectly installed"
echo "*** or that you have moved GTK since it was installed. In the latter case, you"
echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
@ -630,62 +632,80 @@ main ()
])
# Configure paths for GLIB
# Owen Taylor 97-11-3
# Owen Taylor 1997-2001
dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or
dnl gthread is specified in MODULES, pass to glib-config
dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or
dnl gthread is specified in MODULES, pass to pkg-config
dnl
AC_DEFUN(AM_PATH_GLIB,
AC_DEFUN(AM_PATH_GLIB_2_0,
[dnl
dnl Get the cflags and libraries from the glib-config script
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)],
glib_config_prefix="$withval", glib_config_prefix="")
AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program],
, enable_glibtest=yes)
if test x$glib_config_exec_prefix != x ; then
glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
if test x${GLIB_CONFIG+set} != xset ; then
GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
fi
fi
if test x$glib_config_prefix != x ; then
glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
if test x${GLIB_CONFIG+set} != xset ; then
GLIB_CONFIG=$glib_config_prefix/bin/glib-config
fi
fi
pkg_config_args=glib-2.0
for module in . $4
do
case "$module" in
gmodule)
glib_config_args="$glib_config_args gmodule"
pkg_config_args="$pkg_config_args gmodule-2.0"
;;
gobject)
pkg_config_args="$pkg_config_args gobject-2.0"
;;
gthread)
glib_config_args="$glib_config_args gthread"
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
min_glib_version=ifelse([$1], ,0.99.7,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
no_glib=""
if test "$GLIB_CONFIG" = "no" ; then
no_glib=yes
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_glib=yes
PKG_CONFIG=no
fi
else
GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
no_glib=yes
fi
min_glib_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
enable_glibtest=no
fi
if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
:
else
no_glib=yes
fi
fi
if test x"$no_glib" = x ; then
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_glibtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
@ -694,7 +714,7 @@ AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and ru
LIBS="$GLIB_LIBS $LIBS"
dnl
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
dnl checks the results of glib-config to some extent
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.glibtest
AC_TRY_RUN([
@ -721,17 +741,16 @@ main ()
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If glib-config was correct, then it is best\n");
printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
printf("*** before re-running configure\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
(glib_minor_version != GLIB_MINOR_VERSION) ||
@ -759,10 +778,10 @@ main ()
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the glib-config shell script is\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
printf("*** correct copy of glib-config. (In this case, you will have to\n");
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
@ -775,20 +794,20 @@ main ()
fi
fi
if test "x$no_glib" = x ; then
AC_MSG_RESULT(yes)
AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GLIB_CONFIG" = "no" ; then
echo "*** The glib-config script installed by GLIB could not be found"
echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GLIB_CONFIG environment variable to the"
echo "*** full path to glib-config."
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://www.freedesktop.org/software/pkgconfig/"
else
if test -f conf.glibtest ; then
:
else
echo "*** Could not run GLIB test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"
AC_TRY_LINK([
@ -803,26 +822,25 @@ main ()
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GLIB_CFLAGS=""
GLIB_LIBS=""
GLIB_GENMARSHAL=""
GOBJECT_QUERY=""
GLIB_MKENUMS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_GENMARSHAL)
AC_SUBST(GOBJECT_QUERY)
AC_SUBST(GLIB_MKENUMS)
rm -f conf.glibtest
])

1024
libjava/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -785,8 +785,8 @@ else
# Test for Gtk stuff, if asked for.
if test "$use_gtk_awt" = yes; then
AM_PATH_GTK(1.2.4,,exit 1)
AM_PATH_GLIB(1.2.4,,exit 1,gthread)
AM_PATH_GTK_2_0(2.0.0,,exit 1)
AM_PATH_GLIB_2_0(2.0.0,,exit 1,gthread)
dnl XXX Fix me when libart.m4 has the compile test fixed!
enable_libarttest=no
AM_PATH_LIBART(2.1.0,,exit 1)

View File

@ -87,10 +87,11 @@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_QUERY = @GOBJECT_QUERY@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_CONFIG = @GTK_CONFIG@
GTK_LIBS = @GTK_LIBS@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
IEEESPEC = @IEEESPEC@
@ -117,6 +118,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PLATFORMOBJS = @PLATFORMOBJS@
RANLIB = @RANLIB@
STRIP = @STRIP@

View File

@ -1,60 +1,78 @@
# Configure paths for GLIB
# Owen Taylor 97-11-3
# Owen Taylor 1997-2001
dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or
dnl gthread is specified in MODULES, pass to glib-config
dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or
dnl gthread is specified in MODULES, pass to pkg-config
dnl
AC_DEFUN(AM_PATH_GLIB,
AC_DEFUN(AM_PATH_GLIB_2_0,
[dnl
dnl Get the cflags and libraries from the glib-config script
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_WITH(glib-prefix,[ --with-glib-prefix=PFX Prefix where GLIB is installed (optional)],
glib_config_prefix="$withval", glib_config_prefix="")
AC_ARG_WITH(glib-exec-prefix,[ --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program],
, enable_glibtest=yes)
if test x$glib_config_exec_prefix != x ; then
glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
if test x${GLIB_CONFIG+set} != xset ; then
GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
fi
fi
if test x$glib_config_prefix != x ; then
glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
if test x${GLIB_CONFIG+set} != xset ; then
GLIB_CONFIG=$glib_config_prefix/bin/glib-config
fi
fi
pkg_config_args=glib-2.0
for module in . $4
do
case "$module" in
gmodule)
glib_config_args="$glib_config_args gmodule"
pkg_config_args="$pkg_config_args gmodule-2.0"
;;
gobject)
pkg_config_args="$pkg_config_args gobject-2.0"
;;
gthread)
glib_config_args="$glib_config_args gthread"
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
min_glib_version=ifelse([$1], ,0.99.7,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
no_glib=""
if test "$GLIB_CONFIG" = "no" ; then
no_glib=yes
if test x$PKG_CONFIG != xno ; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_glib=yes
PKG_CONFIG=no
fi
else
GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
no_glib=yes
fi
min_glib_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
enable_glibtest=no
fi
if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
:
else
no_glib=yes
fi
fi
if test x"$no_glib" = x ; then
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_glibtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
@ -63,7 +81,7 @@ AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and ru
LIBS="$GLIB_LIBS $LIBS"
dnl
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
dnl checks the results of glib-config to some extent
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.glibtest
AC_TRY_RUN([
@ -90,17 +108,16 @@ main ()
(glib_minor_version != $glib_config_minor_version) ||
(glib_micro_version != $glib_config_micro_version))
{
printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
glib_major_version, glib_minor_version, glib_micro_version);
printf ("*** was found! If glib-config was correct, then it is best\n");
printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
printf("*** before re-running configure\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
(glib_minor_version != GLIB_MINOR_VERSION) ||
@ -128,10 +145,10 @@ main ()
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the glib-config shell script is\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
printf("*** correct copy of glib-config. (In this case, you will have to\n");
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
@ -144,20 +161,20 @@ main ()
fi
fi
if test "x$no_glib" = x ; then
AC_MSG_RESULT(yes)
AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GLIB_CONFIG" = "no" ; then
echo "*** The glib-config script installed by GLIB could not be found"
echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GLIB_CONFIG environment variable to the"
echo "*** full path to glib-config."
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://www.freedesktop.org/software/pkgconfig/"
else
if test -f conf.glibtest ; then
:
else
echo "*** Could not run GLIB test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"
AC_TRY_LINK([
@ -172,25 +189,24 @@ main ()
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
GLIB_CFLAGS=""
GLIB_LIBS=""
GLIB_GENMARSHAL=""
GOBJECT_QUERY=""
GLIB_MKENUMS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_GENMARSHAL)
AC_SUBST(GOBJECT_QUERY)
AC_SUBST(GLIB_MKENUMS)
rm -f conf.glibtest
])

View File

@ -1,56 +1,68 @@
# Configure paths for GTK+
# Owen Taylor 97-11-3
# Owen Taylor 1997-2001
dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
dnl pass to pkg-config
dnl
AC_DEFUN(AM_PATH_GTK,
AC_DEFUN(AM_PATH_GTK_2_0,
[dnl
dnl Get the cflags and libraries from the gtk-config script
dnl Get the cflags and libraries from pkg-config
dnl
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
gtk_config_prefix="$withval", gtk_config_prefix="")
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
, enable_gtktest=yes)
pkg_config_args=gtk+-2.0
for module in . $4
do
case "$module" in
gthread)
gtk_config_args="$gtk_config_args gthread"
pkg_config_args="$pkg_config_args gthread-2.0"
;;
esac
done
if test x$gtk_config_exec_prefix != x ; then
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
if test x${GTK_CONFIG+set} != xset ; then
GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
fi
fi
if test x$gtk_config_prefix != x ; then
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
if test x${GTK_CONFIG+set} != xset ; then
GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
fi
no_gtk=""
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG != xno ; then
if pkg-config --atleast-pkgconfig-version 0.7 ; then
:
else
echo *** pkg-config too old; version 0.7 or better required.
no_gtk=yes
PKG_CONFIG=no
fi
else
no_gtk=yes
fi
AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
min_gtk_version=ifelse([$1], ,0.99.7,$1)
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
no_gtk=""
if test "$GTK_CONFIG" = "no" ; then
no_gtk=yes
else
GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
min_gtk_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
if test x$PKG_CONFIG != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
enable_gtktest=no
fi
if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
:
else
no_gtk=yes
fi
fi
if test x"$no_gtk" = x ; then
GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_gtktest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
@ -58,8 +70,8 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$GTK_LIBS $LIBS"
dnl
dnl Now check if the installed GTK is sufficiently new. (Also sanity
dnl checks the results of gtk-config to some extent
dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
dnl
rm -f conf.gtktest
AC_TRY_RUN([
@ -86,19 +98,17 @@ main ()
(gtk_minor_version != $gtk_config_minor_version) ||
(gtk_micro_version != $gtk_config_micro_version))
{
printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
gtk_major_version, gtk_minor_version, gtk_micro_version);
printf ("*** was found! If gtk-config was correct, then it is best\n");
printf ("*** was found! If pkg-config was correct, then it is best\n");
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
printf("*** required on your system.\n");
printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
printf("*** before re-running configure\n");
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
printf("*** to point to the correct configuration files\n");
}
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
(gtk_minor_version != GTK_MINOR_VERSION) ||
(gtk_micro_version != GTK_MICRO_VERSION))
@ -108,7 +118,6 @@ main ()
printf("*** library (version %d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version);
}
#endif /* defined (GTK_MAJOR_VERSION) ... */
else
{
if ((gtk_major_version > major) ||
@ -126,10 +135,10 @@ main ()
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
printf("***\n");
printf("*** If you have already installed a sufficiently new version, this error\n");
printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
printf("*** being found. The easiest way to fix this is to remove the old version\n");
printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
printf("*** correct copy of gtk-config. (In this case, you will have to\n");
printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
printf("*** so that the correct libraries are found at run-time))\n");
}
@ -142,20 +151,20 @@ main ()
fi
fi
if test "x$no_gtk" = x ; then
AC_MSG_RESULT(yes)
AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GTK_CONFIG" = "no" ; then
echo "*** The gtk-config script installed by GTK could not be found"
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GTK_CONFIG environment variable to the"
echo "*** full path to gtk-config."
if test "$PKG_CONFIG" = "no" ; then
echo "*** A new enough version of pkg-config was not found."
echo "*** See http://pkgconfig.sourceforge.net"
else
if test -f conf.gtktest ; then
:
else
echo "*** Could not run GTK test program, checking why..."
echo "*** Could not run GTK+ test program, checking why..."
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GTK_CFLAGS"
LIBS="$LIBS $GTK_LIBS"
AC_TRY_LINK([
@ -163,23 +172,16 @@ main ()
#include <stdio.h>
], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GTK or finding the wrong"
echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***"
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GTK was incorrectly installed"
echo "*** or that you have moved GTK since it was installed. In the latter case, you"
echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi

View File

@ -87,10 +87,11 @@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_QUERY = @GOBJECT_QUERY@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_CONFIG = @GTK_CONFIG@
GTK_LIBS = @GTK_LIBS@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
IEEESPEC = @IEEESPEC@
@ -117,6 +118,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PLATFORMOBJS = @PLATFORMOBJS@
RANLIB = @RANLIB@
STRIP = @STRIP@

View File

@ -1,5 +1,5 @@
/* gdkgraphics.c
Copyright (C) 1999, 2003 Free Software Foundation, Inc.
Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -40,7 +40,7 @@ exception statement from your version. */
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#define GDK_STABLE_IS_PIXMAP(d) (((GdkWindowPrivate *)d)->window_type == GDK_WINDOW_PIXMAP)
#define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d))
GdkPoint *
translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints,

View File

@ -42,47 +42,43 @@ exception statement from your version. */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create
(JNIEnv *env, jobject obj)
{
gpointer widget;
GtkButton *button;
gdk_threads_enter ();
widget = gtk_type_new (gtk_button_get_type ());
button = gtk_button_new();
gtk_widget_show (GTK_WIDGET(button));
gdk_threads_leave ();
NSA_SET_PTR (env, obj, widget);
NSA_SET_PTR (env, obj, button);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring jname, jint size)
{
const char *xlfd;
# define FBUFSZ 200
char buf[FBUFSZ];
const char *font_name;
void *ptr;
GdkFont * new_font;
GtkStyle * style;
GtkWidget * button;
GtkWidget * label;
GtkWidget *button;
GtkWidget *label;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
button = GTK_WIDGET (ptr);
label = GTK_BIN(button)->child;
label = gtk_bin_get_child (GTK_BIN(button));
if (label == NULL) return;
xlfd = (*env)->GetStringUTFChars (env, jname, NULL);
snprintf(buf, FBUFSZ, xlfd, size);
(*env)->ReleaseStringUTFChars (env, jname, xlfd);
gdk_threads_enter();
new_font = gdk_font_load (buf); /* FIXME: deprecated. Replacement? */
if (new_font == NULL)
{
/* Fail quietly for now. */
gdk_threads_leave();
if (!label)
return;
}
style = gtk_style_copy (gtk_widget_get_style (label));
style -> font = new_font;
gtk_widget_set_style (label, style);
/* FIXME: Documentation varies as to whether we should unref style. */
font_name = (*env)->GetStringUTFChars (env, jname, NULL);
gdk_threads_enter();
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size);
gtk_widget_modify_font (GTK_WIDGET(label), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, font_name);
}

View File

@ -40,22 +40,6 @@ exception statement from your version. */
#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
#include <gtk/gtkprivate.h>
#define GTK_OBJECT_SETV(ptr, arg) \
gdk_threads_enter (); \
{ \
GtkArgInfo *info = NULL; \
char *error; \
\
error = gtk_object_arg_get_info (GTK_OBJECT_TYPE (ptr), arg.name, &info); \
if (error) \
{ \
/* assume the argument is destined for the container's only child */ \
ptr = gtk_container_children (GTK_CONTAINER (ptr))->data; \
} \
gtk_object_setv (GTK_OBJECT (ptr), 1, &arg); \
} \
gdk_threads_leave (); \
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkGenericPeer_dispose
(JNIEnv *env, jobject obj)
{
@ -519,8 +503,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_S
arg.type = GTK_TYPE_STRING;
arg.name = (char *) name;
GTK_VALUE_STRING (arg) = (char *) value;
GTK_OBJECT_SETV (ptr, arg);
gdk_threads_enter();
g_object_set(ptr, name, value, NULL);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, name);
(*env)->ReleaseStringUTFChars (env, jvalue, value);
@ -540,7 +525,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_la
arg.name = (char *) name;
GTK_VALUE_BOOL (arg) = value;
GTK_OBJECT_SETV (ptr, arg);
gdk_threads_enter();
g_object_set(ptr, name, value, NULL);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, name);
}
@ -559,7 +546,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_la
arg.name = (char *) name;
GTK_VALUE_INT (arg) = value;
GTK_OBJECT_SETV (ptr, arg);
gdk_threads_enter();
g_object_set(ptr, name, value, NULL);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, name);
}
@ -578,7 +567,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_la
arg.name = (char *) name;
GTK_VALUE_FLOAT (arg) = value;
GTK_OBJECT_SETV (ptr, arg);
gdk_threads_enter();
g_object_set(ptr, name, value, NULL);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, name);
}
@ -611,7 +602,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_O
arg.name = (char *) name;
GTK_VALUE_OBJECT (arg) = GTK_OBJECT (ptr2);
GTK_OBJECT_SETV (ptr1, arg);
gdk_threads_enter();
g_object_set(ptr1, name, ptr2, NULL);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, name);
}
@ -644,6 +637,15 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks
gdk_threads_enter ();
gtk_widget_realize (GTK_WIDGET (ptr));
if(GTK_IS_BUTTON(ptr))
{
g_print("-- connecting a button --\n");
connect_awt_hook (env, obj, 1, GTK_BUTTON(ptr)->event_window);
}
else
{
connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window);
g_print("Connection object %p with window %p (but ptr is %p)\n", obj, GTK_WIDGET(ptr)->window, ptr);
}
gdk_threads_leave ();
}

View File

@ -526,6 +526,7 @@ attach_jobject (GdkWindow *window, jobject *obj)
| GDK_KEY_PRESS_MASK
| GDK_FOCUS_CHANGE_MASK);
// g_print("storing obj %p property on window %p\n", obj, window);
gdk_property_change (window,
addr_atom,
type_atom,
@ -538,15 +539,22 @@ attach_jobject (GdkWindow *window, jobject *obj)
void
connect_awt_hook (JNIEnv *env, jobject peer_obj, int nwindows, ...)
{
int i;
va_list ap;
jobject *obj;
obj = (jobject *) malloc (sizeof (jobject));
*obj = (*env)->NewGlobalRef (env, peer_obj);
//g_print("Connection obj %p\n", peer_obj);
va_start (ap, nwindows);
{
int i;
for (i = 0; i < nwindows; i++)
attach_jobject (va_arg (ap, GdkWindow *), obj);
{
GdkWindow* attach = (va_arg (ap, GdkWindow *));
//g_print("attach peer obj %p and %p\n", peer_obj, attach);
attach_jobject(attach, obj);
}
}
va_end (ap);
}

View File

@ -251,33 +251,9 @@ Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize
list = GTK_WIDGET (CLIST_FROM_SW (ptr));
sw = GTK_SCROLLED_WINDOW (ptr);
/*
gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->hscrollbar),
&myreq);
dims[1]=myreq.height+GTK_SCROLLED_WINDOW_CLASS
(GTK_OBJECT (sw)->klass)->scrollbar_spacing;
*/
gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->vscrollbar),
"size_request", &myreq);
/*
gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->vscrollbar),
&myreq);
*/
dims[0]=myreq.width+GTK_SCROLLED_WINDOW_CLASS
(GTK_OBJECT (sw)->klass)->scrollbar_spacing;
gtk_signal_emit_by_name (GTK_OBJECT (list), "size_request", &myreq);
// gtk_widget_size_request(GTK_WIDGET (list), &myreq);
dims[0] += myreq.width + gdk_char_width (list->style->font, 'W');
dims[1] += ((rows * (gdk_char_height (list->style->font, 'W')+7))
+ (2 * (list->style->klass->ythickness)));
gtk_widget_size_request(list, &myreq);
dims[1]=myreq.height;
dims[0]=myreq.width;
gdk_threads_leave ();

View File

@ -56,6 +56,10 @@ jmethodID postItemEventID;
jmethodID postListItemEventID;
JNIEnv *gdk_env;
#ifdef PORTABLE_NATIVE_SYNC
JavaVM *gdk_vm;
#endif
/*
* Call gtk_init. It is very important that this happen before any other
* gtk calls.
@ -81,7 +85,16 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz)
/* until we have JDK 1.2 JNI, assume we have a VM with threads that
match what GLIB was compiled for */
g_thread_init (NULL);
#ifdef PORTABLE_NATIVE_SYNC
(*env)->GetJavaVM( env, &gdk_vm );
g_thread_init ( &g_thread_jni_functions );
printf("called gthread init\n");
#else
g_thread_init ( NULL );
#endif
/* From GDK 2.0 onwards we have to explicitly call gdk_threads_init */
gdk_threads_init();
gtk_init (&argc, &argv);

View File

@ -46,11 +46,15 @@ struct range_scrollbar
};
static void
post_adjustment_event (GtkAdjustment *adj, struct range_scrollbar *rs)
post_adjustment_event (GtkRange *range, GtkScrollType scroll,
struct range_scrollbar *rs)
{
jint type;
GtkAdjustment *adj;
switch (rs->range->scroll_type)
adj = gtk_range_get_adjustment (range);
switch (scroll)
{
case GTK_SCROLL_STEP_FORWARD:
type = AWT_ADJUSTMENT_UNIT_INCREMENT;
@ -113,15 +117,11 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectHooks
rs->range = GTK_RANGE (ptr);
rs->scrollbar = (jobject *) malloc (sizeof (jobject));
*(rs->scrollbar) = (*env)->NewGlobalRef (env, obj);
gtk_signal_connect (GTK_OBJECT (GTK_RANGE (ptr)->adjustment),
"value_changed",
gtk_signal_connect (GTK_OBJECT (GTK_RANGE (ptr)),
"move_slider",
GTK_SIGNAL_FUNC (post_adjustment_event), rs);
connect_awt_hook (env, obj, 4,
GTK_RANGE (ptr)->trough,
GTK_RANGE (ptr)->slider,
GTK_RANGE (ptr)->step_forw,
GTK_RANGE (ptr)->step_back);
connect_awt_hook (env, obj, 1, GTK_SCROLLBAR (ptr)->range);
gdk_threads_leave ();
}

View File

@ -39,7 +39,7 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkTextAreaPeer.h"
#define TEXT_FROM_SW(obj) (GTK_TEXT(GTK_SCROLLED_WINDOW (obj)->container.child))
#define TEXT_FROM_SW(obj) (GTK_TEXT_VIEW(GTK_SCROLLED_WINDOW (obj)->container.child))
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
(JNIEnv *env, jobject obj, jint scroll)
@ -47,7 +47,7 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
GtkWidget *text, *sw;
gdk_threads_enter ();
text = gtk_text_new (NULL, NULL);
text = gtk_text_view_new ();
gtk_widget_show (text);
sw = gtk_scrolled_window_new (NULL, NULL);
@ -64,54 +64,9 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create
(scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
|| scroll == AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY) ?
GTK_POLICY_ALWAYS : GTK_POLICY_NEVER);
gdk_threads_leave ();
NSA_SET_PTR (env, obj, sw);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_old_create
(JNIEnv *env, jobject obj, jobject parent_obj,
jstring contents, jint scroll)
{
GtkWidget *text, *sw;
const char *str;
int pos=0;
void *parent;
parent = NSA_GET_PTR (env, parent_obj);
str = (*env)->GetStringUTFChars (env, contents, NULL);
gdk_threads_enter ();
text = gtk_text_new (NULL, NULL);
gtk_text_set_editable (GTK_TEXT (text), TRUE);
gtk_editable_insert_text (GTK_EDITABLE (text), str,
strlen (str), &pos);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), text);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
/* horizontal scrollbar */
(scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
|| scroll == AWT_TEXTAREA_SCROLLBARS_HORIZONTAL_ONLY) ?
GTK_POLICY_ALWAYS : GTK_POLICY_NEVER,
/* vertical scrollbar */
(scroll == AWT_TEXTAREA_SCROLLBARS_BOTH
|| scroll == AWT_TEXTAREA_SCROLLBARS_VERTICAL_ONLY) ?
GTK_POLICY_ALWAYS : GTK_POLICY_NEVER);
set_visible (text, TRUE);
set_parent (sw, GTK_CONTAINER (parent));
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, contents, str);
NSA_SET_PTR (env, obj, sw);
}
@ -122,8 +77,8 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkTextGetSize
void *ptr;
jint *dims;
GtkWidget *text;
GtkScrolledWindow *sw;
GtkRequisition myreq;
/* GtkScrolledWindow *sw; */
GtkRequisition requisition;
ptr = NSA_GET_PTR (env, obj);
@ -133,35 +88,11 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkTextGetSize
gdk_threads_enter ();
text = GTK_WIDGET (TEXT_FROM_SW (ptr));
sw = GTK_SCROLLED_WINDOW (ptr);
/* sw = GTK_SCROLLED_WINDOW (ptr); */
gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->vscrollbar),
"size_request", &myreq);
//gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->hscrollbar),
// &myreq);
dims[0]=myreq.width+GTK_SCROLLED_WINDOW_CLASS
(GTK_OBJECT (sw)->klass)->scrollbar_spacing;
gtk_signal_emit_by_name (GTK_OBJECT (GTK_SCROLLED_WINDOW(sw)->hscrollbar),
"size_request", &myreq);
//gtk_widget_size_request(GTK_WIDGET (GTK_SCROLLED_WINDOW(sw)->vscrollbar),
// &myreq);
dims[1]=myreq.height+GTK_SCROLLED_WINDOW_CLASS
(GTK_OBJECT (sw)->klass)->scrollbar_spacing;
/* The '1' in the following assignments is from
#define TEXT_BORDER_ROOM 1
in gtktext.c */
/* Gtk text seems to wrap slightly prematurely. Compensate. */
++cols;
++dims[0];
dims[0] += ((cols * gdk_char_width (text->style->font, 'W'))
+ (2 * (text->style->klass->xthickness + 1)));
/* Guess at the height. Is there a better way? */
dims[1] += ((rows * gdk_string_height (text->style->font, "Wg"))
+ (2 * (text->style->klass->ythickness + 1)));
gtk_widget_size_request(GTK_WIDGET (text), &requisition);
dims[0] = requisition.width;
dims[1] = requisition.height;
gdk_threads_leave ();
@ -173,6 +104,9 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_insert
(JNIEnv *env, jobject obj, jstring contents, jint position)
{
GtkTextBuffer *buf;
GtkTextIter iter;
GtkWidget *text;
void *ptr;
const char *str;
int pos=position;
@ -181,8 +115,13 @@ Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_insert
str = (*env)->GetStringUTFChars (env, contents, NULL);
gdk_threads_enter ();
gtk_editable_insert_text (GTK_EDITABLE (TEXT_FROM_SW (ptr)),
str, strlen (str), &pos);
text = GTK_WIDGET (TEXT_FROM_SW (ptr));
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_get_iter_at_offset (buf, &iter, pos);
gtk_text_buffer_insert (buf, &iter, str, strlen (str));
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, contents, str);
@ -192,21 +131,29 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_replaceRange
(JNIEnv *env, jobject obj, jstring contents, jint start, jint end)
{
GtkWidget *text;
GtkTextBuffer *buf;
GtkTextIter iter, startIter, endIter;
void *ptr;
GtkEditable *text;
const char *str;
int pos = start;
int mystart = start;
int myend = end;
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, contents, NULL);
gdk_threads_enter ();
text = GTK_EDITABLE (TEXT_FROM_SW (ptr));
gtk_text_freeze (GTK_TEXT (text));
gtk_editable_delete_text (text, start, end);
gtk_editable_insert_text (text, str, strlen (str), &pos);
gtk_text_thaw (GTK_TEXT (text));
text = GTK_WIDGET (TEXT_FROM_SW (ptr));
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_get_iter_at_offset (buf, &startIter, mystart);
gtk_text_buffer_get_iter_at_offset (buf, &endIter, myend);
gtk_text_buffer_delete (buf, &startIter, &endIter);
gtk_text_buffer_get_iter_at_offset (buf, &iter, mystart);
gtk_text_buffer_insert(buf, &iter, str, strlen (str));
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, contents, str);
@ -216,31 +163,25 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring jname, jint size)
{
const char *xlfd;
# define FBUFSZ 200
char buf[FBUFSZ];
const char *font_name;
void *ptr;
GdkFont * new_font;
GtkStyle * style;
GtkWidget * text;
GtkWidget *text;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
text = GTK_WIDGET (TEXT_FROM_SW (ptr));
xlfd = (*env)->GetStringUTFChars (env, jname, NULL);
snprintf(buf, FBUFSZ, xlfd, size);
(*env)->ReleaseStringUTFChars (env, jname, xlfd);
font_name = (*env)->GetStringUTFChars (env, jname, NULL);
gdk_threads_enter();
new_font = gdk_font_load (buf); /* FIXME: deprecated. Replacement? */
if (new_font == NULL)
{
/* Fail quietly for now. */
gdk_threads_leave();
return;
}
style = gtk_style_copy (gtk_widget_get_style (text));
style -> font = new_font;
gtk_widget_set_style (text , style);
/* FIXME: Documentation varies as to whether we should unref style. */
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size);
gtk_widget_modify_font (GTK_WIDGET(text), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, font_name);
}

View File

@ -39,20 +39,47 @@ exception statement from your version. */
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkTextComponentPeer.h"
#define GET_EDITABLE(obj) (GTK_IS_EDITABLE (obj) ? GTK_EDITABLE (obj) : \
GTK_EDITABLE (GTK_SCROLLED_WINDOW (obj)->container.child))
JNIEXPORT jint JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getCaretPosition
(JNIEnv *env, jobject obj)
{
void *ptr;
int pos;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextMark *mark;
GtkTextIter iter;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
pos = gtk_editable_get_position (GET_EDITABLE (ptr));
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
pos = gtk_editable_get_position (editable);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
mark = gtk_text_buffer_get_insert (buf);
gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
pos = gtk_text_iter_get_offset (&iter);
}
}
gdk_threads_leave ();
return pos;
@ -63,11 +90,40 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setCaretPosition
(JNIEnv *env, jobject obj, jint pos)
{
void *ptr;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextMark *mark;
GtkTextIter iter;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_editable_set_position (GET_EDITABLE (ptr), pos);
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
gtk_editable_set_position (editable, pos);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
mark = gtk_text_buffer_get_insert (buf);
gtk_text_buffer_get_iter_at_mark (buf, &iter, mark);
gtk_text_iter_set_offset (&iter, pos);
}
}
gdk_threads_leave ();
}
@ -77,11 +133,42 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionStart
{
void *ptr;
int pos;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
int starti, endi;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
pos = GET_EDITABLE (ptr)->selection_start_pos;
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
if (gtk_editable_get_selection_bounds (editable, &starti, &endi))
pos = starti;
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
if (gtk_text_buffer_get_selection_bounds(buf, &start, &end))
pos = gtk_text_iter_get_offset (&start);
}
}
gdk_threads_leave ();
return pos;
@ -93,11 +180,42 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getSelectionEnd
{
void *ptr;
int pos;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextIter start;
GtkTextIter end;
int starti, endi;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
pos = GET_EDITABLE (ptr)->selection_end_pos;
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
if (gtk_editable_get_selection_bounds (editable, &starti, &endi))
pos = endi;
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
if (gtk_text_buffer_get_selection_bounds(buf, &start, &end))
pos = gtk_text_iter_get_offset (&end);
}
}
gdk_threads_leave ();
return pos;
@ -108,11 +226,44 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_select
(JNIEnv *env, jobject obj, jint start, jint end)
{
void *ptr;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextIter iter;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_editable_select_region (GET_EDITABLE (ptr), start, end);
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
gtk_editable_select_region (editable, start, end);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_get_iter_at_offset (buf, &iter, start);
/* quickly move both 'insert' and 'selection_bound' to the
same position */
gtk_text_buffer_place_cursor (buf, &iter);
gtk_text_buffer_get_iter_at_offset (buf, &iter, end);
gtk_text_buffer_move_mark_by_name (buf, "selection_bound", &iter);
}
}
gdk_threads_leave ();
}
@ -121,11 +272,35 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setEditable
(JNIEnv *env, jobject obj, jboolean state)
{
void *ptr;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
gtk_editable_set_editable (GET_EDITABLE (ptr), state);
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
gtk_editable_set_editable (editable, state);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
gtk_text_view_set_editable (GTK_TEXT_VIEW (text), state);
}
}
gdk_threads_leave ();
}
@ -136,11 +311,40 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_getText
void *ptr;
char *contents;
jstring jcontents;
GtkEditable *editable; // type of GtkEntry (TextField)
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
GtkTextIter start, end;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
contents = gtk_editable_get_chars (GET_EDITABLE (ptr), 0, -1);
if (GTK_IS_EDITABLE (ptr))
{
editable = GTK_EDITABLE (ptr);
contents = gtk_editable_get_chars (editable, 0, -1);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_get_start_iter (buf, &start);
gtk_text_buffer_get_end_iter (buf, &end);
contents = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
}
}
gdk_threads_leave ();
jcontents = (*env)->NewStringUTF (env, contents);
@ -154,25 +358,36 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setText
(JNIEnv *env, jobject obj, jstring contents)
{
void *ptr;
GtkEditable *text;
const char *str;
int pos = 0;
GtkWidget *text = NULL; // type of GtkTextView (TextArea)
GtkTextBuffer *buf;
ptr = NSA_GET_PTR (env, obj);
str = (*env)->GetStringUTFChars (env, contents, NULL);
gdk_threads_enter ();
text = GET_EDITABLE (ptr);
if (GTK_IS_EDITABLE (ptr))
{
gtk_entry_set_text (GTK_ENTRY (ptr), str);
}
else
{
if (GTK_IS_SCROLLED_WINDOW (ptr))
{
text = GTK_WIDGET (GTK_TEXT_VIEW (GTK_SCROLLED_WINDOW (ptr)->container.child));
}
else if (GTK_IS_TEXT_VIEW (ptr))
{
text = GTK_WIDGET (ptr);
}
if (GTK_IS_TEXT (text))
gtk_text_freeze (GTK_TEXT (text));
gtk_editable_delete_text (text, 0, -1);
gtk_editable_insert_text (text, str, strlen (str), &pos);
if (GTK_IS_TEXT (text))
gtk_text_thaw (GTK_TEXT (text));
if (text)
{
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_set_text (buf, str, strlen (str));
}
}
gdk_threads_leave ();

View File

@ -43,10 +43,10 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_create
(JNIEnv *env, jobject obj)
{
gpointer widget;
GtkWidget *widget;
gdk_threads_enter ();
widget = gtk_type_new (gtk_entry_get_type ());
widget = gtk_entry_new ();
gdk_threads_leave ();
NSA_SET_PTR (env, obj, widget);
@ -68,36 +68,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_connectHooks
gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_old_create
(JNIEnv *env, jobject obj, jobject parent_obj, jstring text)
{
GtkWidget *entry;
const char *str;
void *parent;
parent = NSA_GET_PTR (env, parent_obj);
str = (*env)->GetStringUTFChars (env, text, NULL);
gdk_threads_enter ();
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), str);
set_parent (entry, GTK_CONTAINER (parent));
gtk_widget_realize (entry);
connect_awt_hook (env, obj, 2,
entry->window, GTK_ENTRY (entry)->text_area);
NSA_SET_PTR (env, obj, entry);
gdk_threads_leave ();
(*env)->ReleaseStringUTFChars (env, text, str);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetSize
(JNIEnv *env, jobject obj, jint cols, jintArray jdims)
@ -105,19 +75,16 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetSize
void *ptr;
jint *dims;
GtkRequisition myreq;
GtkEntry *entry;
GtkWidget *entry;
ptr = NSA_GET_PTR (env, obj);
dims = (*env)->GetIntArrayElements (env, jdims, 0);
gdk_threads_enter ();
entry = GTK_ENTRY (ptr);
gtk_signal_emit_by_name (GTK_OBJECT (entry), "size_request", &myreq);
dims[0]=myreq.width-150 + (cols *
gdk_char_width (GTK_WIDGET (entry)->style->font,
'W'));
entry = GTK_WIDGET (ptr);
gtk_widget_size_request(entry, &myreq);
dims[0]=myreq.width;
dims[1]=myreq.height;
gdk_threads_leave ();
@ -153,31 +120,24 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkSetFont
(JNIEnv *env, jobject obj, jstring jname, jint size)
{
const char *xlfd;
# define FBUFSZ 200
char buf[FBUFSZ];
const char *font_name;
void *ptr;
GdkFont * new_font;
GtkStyle * style;
GtkWidget * text;
GtkWidget *entry;
PangoFontDescription *font_desc;
ptr = NSA_GET_PTR (env, obj);
text = GTK_WIDGET (ptr);
xlfd = (*env)->GetStringUTFChars (env, jname, NULL);
snprintf(buf, FBUFSZ, xlfd, size);
(*env)->ReleaseStringUTFChars (env, jname, xlfd);
entry = GTK_WIDGET (ptr);
font_name = (*env)->GetStringUTFChars (env, jname, NULL);
gdk_threads_enter();
new_font = gdk_font_load(buf); /* FIXME: deprecated. Replacement? */
if (new_font == NULL)
{
/* Fail quietly for now. */
gdk_threads_leave();
return;
}
style = gtk_style_copy (gtk_widget_get_style (text));
style -> font = new_font;
gtk_widget_set_style (text , style);
/* FIXME: Documentation varies as to whether we should unref style. */
font_desc = pango_font_description_from_string (font_name);
pango_font_description_set_size (font_desc, size);
gtk_widget_modify_font (GTK_WIDGET(entry), font_desc);
pango_font_description_free (font_desc);
gdk_threads_leave();
(*env)->ReleaseStringUTFChars (env, jname, font_name);
}

View File

@ -93,17 +93,37 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_connectHooks
(JNIEnv *env, jobject obj)
{
void *ptr;
GtkVBox* vbox;
GtkWidget *layout;
GList* children;
char* name;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
layout = GTK_WIDGET (gtk_container_children (GTK_CONTAINER (GTK_BIN (ptr)->child))->data);
children = gtk_container_get_children(GTK_CONTAINER(ptr));
vbox = children->data;
name = GTK_OBJECT_TYPE_NAME(vbox);
if(!GTK_IS_VBOX(vbox))
{
printf("*** this is not a vbox\n");
}
children = gtk_container_get_children(GTK_CONTAINER(vbox));
layout = children->data;
name = GTK_OBJECT_TYPE_NAME(layout);
if(!GTK_IS_LAYOUT(layout))
{
printf("*** widget is not a layout ***");
}
gtk_widget_realize (layout);
connect_awt_hook (env, obj, 1, GTK_LAYOUT (layout)->bin_window);
gtk_widget_realize (GTK_WIDGET (ptr));
gtk_widget_realize (ptr);
connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window);
gdk_threads_leave ();
}
@ -112,8 +132,8 @@ setup_window (JNIEnv *env, jobject obj, GtkWidget *window, jint width,
jint height, jboolean visible)
{
GtkWidget *layout, *vbox;
gint x, y;
gdk_threads_enter();
gtk_window_set_policy (GTK_WINDOW (window), 1, 1, 0);
gtk_widget_set_usize (window, width, height);
@ -131,6 +151,7 @@ setup_window (JNIEnv *env, jobject obj, GtkWidget *window, jint width,
connect_awt_hook (env, obj, 1, window->window);
set_visible (window, visible);
gdk_threads_leave ();
}
/*
@ -212,9 +233,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env,
static void
setBounds (GtkWidget *widget, jint x, jint y, jint width, jint height)
{
gint current_x, current_y;
gint origin_x, origin_y;
/* gdk_window_get_root_origin (widget->window, &current_x, &current_y); */
/* if (current_x != x || current_y != y) */
@ -295,16 +313,12 @@ gdk_window_get_root_geometry (GdkWindow *window,
gint *border,
gint *depth)
{
GdkWindowPrivate *private;
Window xwindow;
Window xparent;
Window root;
Window *children;
GdkWindow *private;
unsigned int nchildren;
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
private = (GdkWindow*) window;
if (x)
*x = 0;
if (y)
@ -318,48 +332,14 @@ gdk_window_get_root_geometry (GdkWindow *window,
if (depth)
*depth = 0;
if (private->destroyed)
if (GDK_WINDOW_DESTROYED (private))
return;
while (private->parent && ((GdkWindowPrivate*) private->parent)->parent)
private = (GdkWindowPrivate*) private->parent;
if (private->destroyed)
private = gdk_window_get_toplevel (private);
if (GDK_WINDOW_DESTROYED(private))
return;
xparent = private->xwindow;
do
{
xwindow = xparent;
if (!XQueryTree (private->xdisplay, xwindow,
&root, &xparent,
&children, &nchildren))
return;
gdk_window_get_geometry (private, x, y, width, height, depth);
if (children)
XFree (children);
}
while (xparent != root);
if (xparent == root)
{
unsigned int ww, wh, wb, wd;
int wx, wy;
if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
{
if (x)
*x = wx;
if (y)
*y = wy;
if (width)
*width = ww;
if (height)
*height = wh;
if (border)
*border = wb;
if (depth)
*depth = wd;
}
}
}

View File

@ -35,116 +35,430 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/************************************************************************/
/* Header */
/************************************************************************/
/*
* Julian Dolby (dolby@us.ibm.com)
* February 7, 2003
*
* This code implements the GThreadFunctions interface for GLIB using
* Java threading primitives. All of the locking and conditional variable
* functionality required by GThreadFunctions is implemented using the
* monitor and wait/notify functionality of Java objects. The thread-
* local fucntionality uses the java.lang.ThreadLocal class.
*
* This code is designed to be portable in that it makes no assumptions
* about the underlying VM beyond that it implements the JNI functionality
* that this code uses.
*
* The one piece that does not really work is trylock for mutexes. The
* Java locking model does not include such functionality, and I do not
* see how to implement it without knowing something about how the VM
* implements locking.
*
* NOTES:
*
* I have tested it only on JikesRVM---the CVS head as of early February
* 2003.
*
* Currently, use of this code is governed by the configuration option
* --enable-portable-native-sync
*
*/
/************************************************************************/
/* Global data */
/************************************************************************/
#include "gthread-jni.h"
/*
* This code has been written specifically to be used with GTK+ 1.2.
* `Real' GLIB threading is not supported. We fake things where necessary.
* Once we know we're running on a 1.2 VM, we can write a real implementation.
*/
/* The VM handle. This is set in GtkToolkitMain.gtkInit */
JavaVM *gdk_vm;
static GMutex *
g_mutex_new_jni_impl (void)
{
/************************************************************************/
/* Utilities to reflect exceptions back to the VM */
/************************************************************************/
/* This function checks for a pending exception, and rethrows it with
* a wrapper RuntimeException to deal with possible type problems (in
* case some calling piece of code does not expect the exception being
* thrown) and to include the given extra message.
*/
static void maybe_rethrow(JNIEnv *gdk_env, char *message, char *file, int line) {
jthrowable cause;
/* rethrow if an exception happened */
if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) {
jstring jmessage;
jclass obj_class;
jobject *mutex;
jobject obj;
jmethodID ctor;
/* allocate local message in Java */
int len = strlen(message) + strlen(file) + 25;
char buf[ len ];
bzero(buf, len);
sprintf(buf, "%s (at %s:%d)", message, file, line);
jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
/* create RuntimeException wrapper object */
obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/RuntimeException");
ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>", "(Ljava/langString;Ljava/lang/Throwable)V");
obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
/* throw it */
(*gdk_env)->Throw(gdk_env, (jthrowable)obj);
}
}
/* This macro is used to include a source location in the exception message */
#define MAYBE_RETHROW(_class, _message) \
maybe_rethrow(_class, _message, __FILE__, __LINE__)
/************************************************************************/
/* Utilities to allocate and free java.lang.Objects */
/************************************************************************/
/* Both the mutexes and the condition variables are java.lang.Object objects,
* which this method allocates and returns a global ref. Note that global
* refs must be explicitly freed (isn't C fun?).
*/
static jobject *allocatePlainObject() {
jclass obj_class;
jobject *obj;
JNIEnv *gdk_env;
jmethodID ctor;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/Object");
if (obj_class == NULL)
return NULL;
MAYBE_RETHROW(gdk_env, "cannot find Object");
mutex = (jobject *) g_malloc (sizeof (jobject));
*mutex = (*gdk_env)->AllocObject (gdk_env, obj_class);
if (*mutex == NULL)
{
g_free (mutex);
return NULL;
}
*mutex = (*gdk_env)->NewGlobalRef (gdk_env, *mutex);
ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>", "()V");
MAYBE_RETHROW(gdk_env, "cannot find constructor");
return (GMutex *) mutex;
obj = (jobject *) g_malloc (sizeof (jobject));
*obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor);
MAYBE_RETHROW(gdk_env, "cannot allocate object");
*obj = (*gdk_env)->NewGlobalRef (gdk_env, *obj);
MAYBE_RETHROW(gdk_env, "cannot make global ref");
return obj;
}
static void
g_mutex_lock_jni_impl (GMutex *mutex)
{
if (mutex && mutex == gdk_threads_mutex)
(*gdk_env)->MonitorEnter (gdk_env, *((jobject *)mutex));
/* Frees a Java object given a global ref (isn't C fun?) */
static void freePlainObject(jobject *obj) {
JNIEnv *gdk_env;
if (obj) {
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
(*gdk_env)->DeleteGlobalRef (gdk_env, *obj);
MAYBE_RETHROW(gdk_env, "cannot delete global ref");
g_free (obj);
}
}
static gboolean
g_mutex_trylock_jni_impl (GMutex *mutex)
{
return FALSE;
/************************************************************************/
/* Locking code */
/************************************************************************/
/* Lock a Java object */
static void takeLock(JNIEnv *gdk_env, void *mutex) {
(*gdk_env)->MonitorEnter (gdk_env, *((jobject *)mutex));
MAYBE_RETHROW(gdk_env, "cannot get lock");
}
static void
g_mutex_unlock_jni_impl (GMutex *mutex)
{
if (mutex && mutex == gdk_threads_mutex)
/* Unlock a Java object */
static void releaseLock(JNIEnv *gdk_env, void *mutex) {
(*gdk_env)->MonitorExit (gdk_env, *((jobject *)mutex));
MAYBE_RETHROW(gdk_env, "cannot release lock");
}
static void
g_mutex_free_jni_impl (GMutex *mutex)
{
if (mutex && mutex == gdk_threads_mutex)
{
(*gdk_env)->DeleteGlobalRef (gdk_env, *((jobject *)mutex));
g_free (mutex);
}
/* Create a mutex, which is a java.lang.Object for us */
static GMutex *g_mutex_new_jni_impl (void) {
return (GMutex*) allocatePlainObject();
}
static GPrivate *
g_private_new_jni_impl (GDestroyNotify notify)
{
return NULL;
/* Lock a mutex. */
static void g_mutex_lock_jni_impl (GMutex *mutex) {
JNIEnv *gdk_env;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
takeLock(gdk_env, mutex);
}
static gpointer
g_private_get_jni_impl (GPrivate *private)
{
return NULL;
}
static void
g_private_set_jni_impl (GPrivate *private, gpointer data)
{
}
static GCond *
g_cond_new_jni_impl ()
{
return NULL;
}
static void
g_cond_signal_jni_impl (GCond *cond)
{
}
static void
g_cond_broadcast_jni_impl (GCond *cond)
{
}
static void
g_cond_wait_jni_impl (GCond *cond, GMutex *mutex)
{
}
static gboolean
g_cond_timed_wait_jni_impl (GCond *cond, GMutex *mutex)
{
/* Try to lock a mutex. Actually, do not try because Java objects
* do not provide such an interface. To be at least minimally correct,
* pretend we tried and failed.
*/
static gboolean g_mutex_trylock_jni_impl (GMutex *mutex) {
// Shall we implement this in a JikesRVM-specific way under a flag?
return FALSE;
}
static void
g_cond_free_jni_impl (GCond *cond)
{
/* Unlock a mutex. */
static void g_mutex_unlock_jni_impl (GMutex *mutex) {
JNIEnv *gdk_env;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
releaseLock(gdk_env, mutex);
}
/* Free a mutex (isn't C fun?) */
static void g_mutex_free_jni_impl (GMutex *mutex)
{
freePlainObject( (jobject*)mutex );
}
/************************************************************************/
/* Condition variable code */
/************************************************************************/
/* Create a new condition variable. This is a java.lang.Object for us. */
static GCond *g_cond_new_jni_impl () {
return (GCond*)allocatePlainObject();
}
/* Signal on a condition variable. This is simply calling Object.notify
* for us.
*/
static void g_cond_signal_jni_impl (GCond *cond) {
jclass lcl_class;
jmethodID signal_mth;
JNIEnv *gdk_env;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object");
MAYBE_RETHROW(gdk_env, "cannot find Object");
signal_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "notify", "()V");
MAYBE_RETHROW(gdk_env, "cannot find Object.<notify>");
/* Must have locked an object to call notify */
takeLock(gdk_env, cond);
(*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, signal_mth);
MAYBE_RETHROW(gdk_env, "cannot signal mutex");
releaseLock(gdk_env, cond);
}
/* Broadcast to all waiting on a condition variable. This is simply
* calling Object.notifyAll for us.
*/
static void g_cond_broadcast_jni_impl (GCond *cond) {
jclass lcl_class;
jmethodID bcast_mth;
JNIEnv *gdk_env;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object");
MAYBE_RETHROW(gdk_env, "cannot find Object");
bcast_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "notifyAll", "()V");
MAYBE_RETHROW(gdk_env, "cannot find Object.<notifyAll>");
/* Must have locked an object to call notifyAll */
takeLock(gdk_env, cond);
(*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, bcast_mth);
MAYBE_RETHROW(gdk_env, "cannot broadcast to mutex");
releaseLock(gdk_env, cond);
}
/* Wait on a condition variable. For us, this simply means call
* Object.wait.
*/
static void g_cond_wait_jni_impl (GCond *cond, GMutex *mutex) {
jclass lcl_class;
jmethodID wait_mth;
JNIEnv *gdk_env;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object");
MAYBE_RETHROW(gdk_env, "cannot find Object");
wait_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "wait", "()V");
MAYBE_RETHROW(gdk_env, "cannot find Object.<wait>");
/* Must have locked an object to call wait */
takeLock(gdk_env, cond);
(*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, wait_mth);
MAYBE_RETHROW(gdk_env, "cannot wait on mutex");
releaseLock(gdk_env, cond);
}
/* Wait on a condition vairable until a timeout. This is a little tricky
* for us. We first call Object.wait(J) giving it the appropriate timeout
* value. On return, we check whether an InterruptedException happened. If
* so, that is Java-speak for wait timing out.
*/
static gboolean
g_cond_timed_wait_jni_impl (GCond *cond, GMutex *mutex, GTimeVal *end_time) {
jclass lcl_class;
jmethodID wait_mth;
JNIEnv *gdk_env;
jlong time;
jthrowable cause;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object");
MAYBE_RETHROW(gdk_env, "cannot find Object");
wait_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "wait", "(J)V");
MAYBE_RETHROW(gdk_env, "cannot find Object.<wait(J)>");
time = end_time->tv_sec*1000;
time += end_time->tv_usec/1000;
/* Must have locked an object to call wait */
takeLock(gdk_env, cond);
(*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, wait_mth, time);
if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) {
jclass intr = (*gdk_env)->FindClass (gdk_env, "java.lang.InterruptedException");
if ( (*gdk_env)->IsInstanceOf(gdk_env, cause, intr) ) {
releaseLock(gdk_env, cond);
return FALSE;
} else {
MAYBE_RETHROW(gdk_env, "error in timed wait");
}
}
releaseLock(gdk_env, cond);
return TRUE;
}
/* Free a condition variable. (isn't C fun?) */
static void g_cond_free_jni_impl (GCond *cond) {
freePlainObject( (jobject*)cond );
}
/************************************************************************/
/* Thread-local data code */
/************************************************************************/
/* Create a new thread-local key. We use java.lang.ThreadLocal objects
* for this.
*/
static GPrivate *g_private_new_jni_impl (GDestroyNotify notify) {
jclass lcl_class;
jobject *local;
JNIEnv *gdk_env;
jmethodID ctor;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal");
ctor = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "<init>", "()V");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal.<init>");
local = (jobject *) g_malloc (sizeof (jobject));
*local = (*gdk_env)->NewObject(gdk_env, lcl_class, ctor);
MAYBE_RETHROW(gdk_env, "cannot allocate a ThreadLocal");
*local = ((*gdk_env)->NewGlobalRef (gdk_env, *local));
MAYBE_RETHROW(gdk_env, "cannot create a GlobalRef");
return (GPrivate*) local;
}
/* Get this thread's value for a thread-local key. This is simply
* ThreadLocal.get for us.
*/
static gpointer g_private_get_jni_impl (GPrivate *private) {
jclass lcl_class;
jobject lcl_obj;
JNIEnv *gdk_env;
jmethodID get_mth;
jclass int_class;
jmethodID val_mth;
jint int_val;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal");
get_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "get", "()Ljava/lang/Object;");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal.<get>");
lcl_obj = (*gdk_env)->CallObjectMethod(gdk_env, *(jobject*)private, get_mth);
MAYBE_RETHROW(gdk_env, "cannot find thread-local object");
int_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Integer");
MAYBE_RETHROW(gdk_env, "cannot find Integer");
val_mth = (*gdk_env)->GetMethodID(gdk_env, int_class, "intValue", "()I");
MAYBE_RETHROW(gdk_env, "cannot find Integer.<intValue>");
int_val = (*gdk_env)->CallIntMethod(gdk_env, lcl_obj, val_mth);
MAYBE_RETHROW(gdk_env, "cannot get thread local value");
return (gpointer) int_val;
}
/* Set this thread's value for a thread-local key. This is simply
* ThreadLocal.set for us.
*/
static void g_private_set_jni_impl (GPrivate *private, gpointer data) {
jclass lcl_class, int_class;
jobject lcl_obj;
JNIEnv *gdk_env;
jmethodID new_int, set_mth;
(*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1);
int_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Integer");
MAYBE_RETHROW(gdk_env, "cannot find Integer");
new_int = (*gdk_env)->GetMethodID(gdk_env, int_class, "<init>", "(I)V");
MAYBE_RETHROW(gdk_env, "cannot find Integer.<init>");
lcl_obj = (*gdk_env)->NewObject(gdk_env, int_class, new_int, (jint)data);
MAYBE_RETHROW(gdk_env, "cannot create an Integer");
lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal");
set_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "set", "(Ljava/lang/Object;)V");
MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal.<set>");
(*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)private, set_mth, lcl_obj);
MAYBE_RETHROW(gdk_env, "cannot set thread local value");
}
/************************************************************************/
/* GLIB interface */
/************************************************************************/
/* set of function pointers to give to glib. */
GThreadFunctions g_thread_jni_functions =
{
g_mutex_new_jni_impl, /* mutex_new */
@ -163,7 +477,7 @@ GThreadFunctions g_thread_jni_functions =
g_private_set_jni_impl /* private_set */
};
void
gdk_threads_wake ()
{
/* ??? */
void gdk_threads_wake () {
}

View File

@ -43,5 +43,6 @@ exception statement from your version. */
#include "gtkpeer.h"
extern GThreadFunctions g_thread_jni_functions;
extern JavaVM *gdk_vm;
#endif /* __GTHREADJNI_H__ */

View File

@ -87,10 +87,11 @@ GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
GCTESTSPEC = @GCTESTSPEC@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_QUERY = @GOBJECT_QUERY@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_CONFIG = @GTK_CONFIG@
GTK_LIBS = @GTK_LIBS@
HASH_SYNC_SPEC = @HASH_SYNC_SPEC@
IEEESPEC = @IEEESPEC@
@ -117,6 +118,7 @@ OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PLATFORMOBJS = @PLATFORMOBJS@
RANLIB = @RANLIB@
STRIP = @STRIP@