Commit a82804c4 authored by Benedikt Meurer's avatar Benedikt Meurer
Browse files

2005-05-30 Benedikt Meurer <benny@xfce.org>

	* exo/Makefile.am: We don't use D-Bus any longer, so no need to keep
	  that define around.
	* configure.ac, acinclude.m4, java/, Makefile.am: Add experimental
	  Java bindings (very incomplete).




(Old svn revision: 16578)
parent 4073e23a
2005-05-30 Benedikt Meurer <benny@xfce.org>
* exo/Makefile.am: We don't use D-Bus any longer, so no need to keep
that define around.
* configure.ac, acinclude.m4, java/, Makefile.am: Add experimental
Java bindings (very incomplete).
2005-05-29 Benedikt Meurer <benny@xfce.org>
* exo/exo-mime-database.h: Fix missing function declaration.
......
......@@ -2,9 +2,12 @@ if HAVE_PYTHON
PYTHON_SUBDIR=python
endif
JAVA_SUBDIR=java
SUBDIRS = \
exo \
docs \
$(JAVA_SUBDIR) \
po \
$(PYTHON_SUBDIR)
......
dnl $Id$
dnl
dnl Copyright (c) 2004-2005 os-cillation.
dnl All rights reserved.
dnl
dnl Written by Stephane Bortzmeyer <bortzmeyer@pasteur.fr> and Benedikt
dnl Meurer <benny@xfce.org>.
dnl
AC_DEFUN([AC_PROG_JAVAC],
[
AC_REQUIRE([AC_EXEEXT])dnl
if test "x$JAVAPREFIX" = x; then
test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT)
else
test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT, $JAVAPREFIX)
fi
test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
AC_PROG_JAVAC_WORKS()
AC_PROVIDE([$0])dnl
])
AC_DEFUN([AC_PROG_JAVAC_WORKS],
[
AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* [#]line __oline__ "configure" */
public class Test {
}
EOF
if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
ac_cv_prog_javac_works=yes
else
AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
echo "configure: failed program was:" >&AC_FD_CC
cat $JAVA_TEST >&AC_FD_CC
fi
rm -f $JAVA_TEST $CLASS_TEST
])
AC_PROVIDE([$0])dnl
])
AC_DEFUN([AC_PROG_JAVAH],
[
AC_REQUIRE([AC_PROG_CPP])dnl
AC_PATH_PROG([JAVAH], javah)
if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then
AC_TRY_CPP([#include <jni.h>],,[
ac_save_CPPFLAGS="$CPPFLAGS"
changequote(, )dnl
ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'`
ac_machdep=`echo $build_os | sed 's,[-0-9].*,,' | sed 's,cygwin,win32,'`
changequote([, ])dnl
CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
AC_TRY_CPP([#include <jni.h>],
ac_save_CPPFLAGS="$CPPFLAGS",
AC_MSG_WARN([unable to include <jni.h>]))
CPPFLAGS="$ac_save_CPPFLAGS"])
fi
])
AC_DEFUN([AC_PROG_JAR],
[
AC_REQUIRE([AC_EXEEXT])dnl
if test "x$JAVAPREFIX" = x; then
test "x$JAR" = x && AC_CHECK_PROGS([JAR], fastjar$EXEEXT jar$EXEEXT)
else
test "x$JAR" = x && AC_CHECK_PROGS([JAR], jar, $JAVAPREFIX)
fi
test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH])
AC_PROVIDE([$0])dnl
])
......@@ -50,6 +50,9 @@ AC_MINIX()
dnl check for basic programs
AC_PROG_CC()
AC_PROG_INSTALL()
AC_PROG_JAR()
AC_PROG_JAVAC()
AC_PROG_JAVAH()
AC_PROG_LIBTOOL()
dnl check for standard header files
......@@ -141,6 +144,7 @@ exo/Makefile
exo/exo-0.3.pc
exo/exo-config.h
exo/xdgmime/Makefile
java/Makefile
po/Makefile.in
python/Makefile
python/examples/Makefile
......
......@@ -5,7 +5,6 @@ SUBDIRS = \
INCLUDES = \
-I$(top_srcdir) \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DEXO_API_SUBJECT_TO_CHANGE \
-DEXO_COMPILATION \
-DG_LOG_DOMAIN=\"exo\" \
......
# $Id$
INCLUDES = \
-I$(top_srcdir) \
-DEXO_API_SUBJECT_TO_CHANGE \
-DG_LOG_DOMAIN=\"exojava\"
JAVA_FILES = \
org/xfce/exo/MimeDatabase.java \
org/xfce/exo/MimeInfo.java
JAVAH_FILES = \
$(subst /,_,$(JAVA_FILES:.java=.h))
CLASS_FILES = \
$(JAVA_FILES:.java=.class)
exojava-$(LIBEXO_VERSION_API).jar: $(CLASS_FILES)
$(JAR) cf $@ $(CLASS_FILES)
%.class: %.java
$(JAVAC) $<
%.h: exojava-$(LIBEXO_VERSION_API).jar
CLASSPATH=".:$(CLASSPATH)" $(JAVAH) -jni $(subst _,.,$(@:.h=))
jnidir = $(libdir)/jni
jni_LTLIBRARIES = libexojava-0.3.la
libexojava_0_3_la_SOURCES = \
$(JAVAH_FILES) \
org_xfce_exo.c
libexojava_0_3_la_DEPENDENCIES = \
$(top_builddir)/exo/libexo-$(LIBEXO_VERSION_API).la
libexojava_0_3_la_CFLAGS = \
$(LIBXFCEGUI4_CFLAGS)
libexojava_0_3_la_LDFLAGS = \
-no-undefined
libexojava_0_3_la_LIBADD = \
$(top_builddir)/exo/libexo-$(LIBEXO_VERSION_API).la
all-local: exojava-$(LIBEXO_VERSION_API).jar
CLEANFILES = \
$(CLASS_FILES) \
$(JAVAH_FILES) \
exojava-$(LIBEXO_VERSION_API).jar
BUILT_SOURCES = \
$(JAVAH_FILES)
.PHONY: all-local
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
import org.xfce.exo.*;
import org.gnu.gtk.*;
public class Test {
private static final String[] FILENAMES = { "Class.java", "script.sh", "library.so", "source.c", "class.C" };
private static final String[] FILEPATHS = { "Test.class", "Test.java", "/dev/null", "/vmlinuz" };
public static void main(String[] args) {
Gtk.init(args);
MimeDatabase db = MimeDatabase.getDefault();
for (int n = 0; n < FILENAMES.length; ++n) {
MimeInfo info = db.getInfoFromFileName(FILENAMES[n]);
System.out.println("File name " + FILENAMES[n] + " has type " + info.getName() + " (" + info.getComment() + ")");
}
for (int n = 0; n < FILEPATHS.length; ++n) {
MimeInfo info = db.getInfoForFile(new java.io.File(FILEPATHS[n]));
System.out.println("File path " + FILEPATHS[n] + " has type " + info.getName() + " (" + info.getComment() + ")");
}
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_0002fxfce_0002fexo_0002fMimeDatabase */
#ifndef _Included_org_0002fxfce_0002fexo_0002fMimeDatabase
#define _Included_org_0002fxfce_0002fexo_0002fMimeDatabase
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_0002fxfce_0002fexo_0002fMimeDatabase
* Method: exo_mime_database_get_default
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_0002fxfce_0002fexo_0002fMimeDatabase_exo_1mime_1database_1get_1default
(JNIEnv *, jclass);
/*
* Class: org_0002fxfce_0002fexo_0002fMimeDatabase
* Method: exo_mime_database_get_info
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_0002fxfce_0002fexo_0002fMimeDatabase_exo_1mime_1database_1get_1info
(JNIEnv *, jclass, jint, jstring);
/*
* Class: org_0002fxfce_0002fexo_0002fMimeDatabase
* Method: exo_mime_database_get_info_for_file
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_0002fxfce_0002fexo_0002fMimeDatabase_exo_1mime_1database_1get_1info_1for_1file
(JNIEnv *, jclass, jint, jstring);
/*
* Class: org_0002fxfce_0002fexo_0002fMimeDatabase
* Method: exo_mime_database_get_info_from_file_name
* Signature: (ILjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_0002fxfce_0002fexo_0002fMimeDatabase_exo_1mime_1database_1get_1info_1from_1file_1name
(JNIEnv *, jclass, jint, jstring);
#ifdef __cplusplus
}
#endif
#endif
package org.xfce.exo;
import java.io.File;
import org.gnu.glib.GObject;
public final class MimeDatabase extends GObject {
private MimeDatabase(int handle) {
super(handle);
}
public static MimeDatabase getDefault() {
return new MimeDatabase(exo_mime_database_get_default());
}
public MimeInfo getInfo(String name) {
int handle = exo_mime_database_get_info(getHandle(), name);
MimeInfo info = (MimeInfo)retrieveGObject(handle);
if (info == null)
info = new MimeInfo(handle);
return info;
}
public MimeInfo getInfoForFile(File file) {
int handle = exo_mime_database_get_info_for_file(getHandle(), file.getAbsolutePath());
MimeInfo info = (MimeInfo)retrieveGObject(handle);
if (info == null)
info = new MimeInfo(handle);
return info;
}
public MimeInfo getInfoFromFileName(String fileName) {
int handle = exo_mime_database_get_info_from_file_name(getHandle(), fileName);
MimeInfo info = (MimeInfo)retrieveGObject(handle);
if (info == null)
info = new MimeInfo(handle);
return info;
}
private static final native int exo_mime_database_get_default();
private static final native int exo_mime_database_get_info(int handle, String name);
private static final native int exo_mime_database_get_info_for_file(int handle, String filePath);
private static final native int exo_mime_database_get_info_from_file_name(int handle, String fileName);
static {
System.loadLibrary("exojava0.3");
}
}
package org.xfce.exo;
import org.gnu.glib.GObject;
public final class MimeInfo extends GObject {
MimeInfo(int handle) {
super(handle);
}
public String getComment() {
return exo_mime_info_get_comment(getHandle());
}
public String getName() {
return exo_mime_info_get_name(getHandle());
}
private static final native String exo_mime_info_get_comment(int handle);
private static final native String exo_mime_info_get_name(int handle);
}
#include "org_xfce_exo_MimeDatabase.h"
#include "org_xfce_exo_MimeInfo.h"
#include <exo/exo.h>
JNIEXPORT jint JNICALL
Java_org_xfce_exo_MimeDatabase_exo_1mime_1database_1get_1default (JNIEnv *env, jclass cls)
{
return (jint) exo_mime_database_get_default();
}
JNIEXPORT jint JNICALL
Java_org_xfce_exo_MimeDatabase_exo_1mime_1database_1get_1info (JNIEnv *env, jclass cls, jint handle, jstring name)
{
const gchar *name_g = (*env)->GetStringUTFChars (env, name, NULL);
ExoMimeInfo *info = exo_mime_database_get_info (EXO_MIME_DATABASE (handle), name_g);
(*env)->ReleaseStringUTFChars(env, name, name_g);
return (jint) info;
}
JNIEXPORT jint JNICALL
Java_org_xfce_exo_MimeDatabase_exo_1mime_1database_1get_1info_1for_1file (JNIEnv *env, jclass cls, jint handle, jstring file_path)
{
const gchar *file_path_g = (*env)->GetStringUTFChars (env, file_path, NULL);
ExoMimeInfo *info = exo_mime_database_get_info_for_file (EXO_MIME_DATABASE (handle), file_path_g);
(*env)->ReleaseStringUTFChars(env, file_path, file_path_g);
return (jint) info;
}
JNIEXPORT jint JNICALL
Java_org_xfce_exo_MimeDatabase_exo_1mime_1database_1get_1info_1from_1file_1name (JNIEnv *env, jclass cls, jint handle, jstring file_name)
{
const gchar *file_name_g = (*env)->GetStringUTFChars (env, file_name, NULL);
ExoMimeInfo *info = exo_mime_database_get_info_from_file_name (EXO_MIME_DATABASE (handle), file_name_g);
(*env)->ReleaseStringUTFChars(env, file_name, file_name_g);
return (jint) info;
}
JNIEXPORT jstring JNICALL
Java_org_xfce_exo_MimeInfo_exo_1mime_1info_1get_1comment (JNIEnv *env,
jclass cls,
jint handle)
{
const gchar *comment = exo_mime_info_get_comment (EXO_MIME_INFO (handle));
return (*env)->NewStringUTF (env, comment);
}
JNIEXPORT jstring JNICALL
Java_org_xfce_exo_MimeInfo_exo_1mime_1info_1get_1name (JNIEnv *env,
jclass cls,
jint handle)
{
const gchar *name = exo_mime_info_get_name (EXO_MIME_INFO (handle));
return (*env)->NewStringUTF (env, name);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment