Adding support for lua scripting
authorKlaus Ethgen <Klaus@Ethgen.de>
Sat, 27 Jun 2009 21:38:09 +0000 (22:38 +0100)
committerKlaus Ethgen <Klaus@Ethgen.de>
Thu, 23 Dec 2010 17:12:40 +0000 (18:12 +0100)
Until now this is without any functionality.

configure.in
src/Makefile.am
src/lua.c [new file with mode: 0644]
src/lua.h [new file with mode: 0644]
src/main.c

index ac8415e..57735ef 100644 (file)
@@ -376,6 +376,33 @@ AM_CONDITIONAL(HAVE_LIBCHAMPLAIN_GTK, [test "x$HAVE_LIBCHAMPLAIN_GTK" = xyes])
 AC_SUBST(LIBCHAMPLAIN_GTK_CFLAGS)
 AC_SUBST(LIBCHAMPLAIN_GTK_LIBS)
 
+#  Lua support
+# ----------------------------------------------------------------------
+
+AC_ARG_ENABLE([lua],
+  AC_HELP_STRING([--disable-lua], [disable lua support]),
+    [liblua=$enableval], [liblua=auto])
+
+if test "x${liblua}" != "xno"; then
+  PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1,
+    [
+      HAVE_LUA=yes
+      AC_DEFINE(HAVE_LUA, 1, [define to enable lua support])
+    ],
+    [
+      HAVE_LUA=no
+      AC_MSG_WARN([$LUA_PKG_ERRORS])
+    ])
+else
+  HAVE_LUA=disabled
+fi
+
+AM_CONDITIONAL(HAVE_LUA, [test "x$HAVE_LUA" = xyes])
+AC_SUBST(LUA_CFLAGS)
+AC_SUBST(LUA_LIBS)
+
+# ----------------------------------------------------------------------
+
 AH_TOP([
 /** \file
  * \short autogenerated definition by autoheader.
@@ -449,7 +476,7 @@ Flags:
   Gtk:           $GTK_CFLAGS
   Glib:          $GLIB_CFLAGS
   Thread:        $GTHREAD_LIBS
-  Others:       $LCMS_LIBS $EXIV2_LIBS $LIBCHAMPLAIN_LIBS $LIBCHAMPLAIN_GTK_LIBS
+  Others:       $LCMS_LIBS $EXIV2_LIBS $LIBCHAMPLAIN_LIBS $LIBCHAMPLAIN_GTK_LIBS $LUA_LIBS
 
 Localization:
   NLS support:   $USE_NLS
@@ -467,6 +494,7 @@ Support:
   Lirc:          $HAVE_LIRC
   Libchamplain:                $HAVE_LIBCHAMPLAIN
   Libchamplain-gtk:    $HAVE_LIBCHAMPLAIN_GTK
+  Lua:          $HAVE_LUA
 
 Documentation:
   Doxygen:       $DOXYGEN
index 144b090..66f0be9 100644 (file)
@@ -7,6 +7,7 @@ AM_CFLAGS =                             \
        $(EXIV2_CFLAGS)                 \
        $(LIBCHAMPLAIN_CFLAGS)          \
        $(LIBCHAMPLAIN_GTK_CFLAGS)      \
+       $(LUA_CFLAGS)                   \
        -I$(top_srcdir)                 \
        -I$(top_builddir)
 
@@ -17,6 +18,7 @@ AM_CXXFLAGS =                         \
        $(EXIV2_CFLAGS)                 \
        $(LIBCHAMPLAIN_CFLAGS)          \
        $(LIBCHAMPLAIN_GTK_CFLAGS)      \
+       $(LUA_CFLAGS)                   \
        -I$(top_srcdir)                 \
        -I$(top_builddir)
 
@@ -241,9 +243,10 @@ geeqie_SOURCES = \
        view_file_icon.c        \
        view_file_icon.h        \
        window.c        \
-       window.h
+       window.h        \
+       lua.c
 
-geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS)
+geeqie_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(INTLLIBS) $(LCMS_LIBS) $(EXIV2_LIBS) $(LIBCHAMPLAIN_LIBS) $(LIBCHAMPLAIN_GTK_LIBS) $(LUA_LIBS)
 
 EXTRA_DIST = \
        $(extra_SLIK)
diff --git a/src/lua.c b/src/lua.c
new file mode 100644 (file)
index 0000000..a711b27
--- /dev/null
+++ b/src/lua.c
@@ -0,0 +1,41 @@
+/** \file
+ * \short LUA implementation
+ * \author Klaus Ethgen <Klaus@Ethgen.de>
+ */
+
+/*
+ *  This file is a part of Geeqie project (http://geeqie.sourceforge.net/).
+ *  Copyright (C) 2008 - 2010 The Geeqie Team
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ */
+
+#include "config.h"
+
+#ifdef HAVE_LUA
+
+#include <lua.h>
+#include <lauxlib.h>
+
+static lua_State *L; /** The LUA object needed for all operations (NOTE: That is
+                      * a upper-case variable to match the documentation!) */
+
+/**
+ * \brief Initialize the lua interpreter.
+ */
+void lua_init(void)
+{
+       L = luaL_newstate();
+       luaL_openlibs(L); /* Open all libraries for lua programms */
+}
+
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
diff --git a/src/lua.h b/src/lua.h
new file mode 100644 (file)
index 0000000..b24776d
--- /dev/null
+++ b/src/lua.h
@@ -0,0 +1,30 @@
+/** \file
+ * \short LUA implementation
+ * \author Klaus Ethgen <Klaus@Ethgen.de>
+ */
+
+/*
+ *  This file is a part of Geeqie project (http://geeqie.sourceforge.net/).
+ *  Copyright (C) 2008 - 2010 The Geeqie Team
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the Free
+ *  Software Foundation; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ *  more details.
+ */
+
+#ifndef __LUA_H
+#define __LUA_H
+
+#ifdef HAVE_LUA
+
+void lua_init(void);
+
+#endif
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 7cad734..b54ac30 100644 (file)
@@ -45,6 +45,7 @@
 #include "exif.h"
 #include "histogram.h"
 #include "pixbuf_util.h"
+#include "lua.h"
 
 #ifdef HAVE_LIBCHAMPLAIN
 #ifdef HAVE_LIBCHAMPLAIN_GTK
@@ -755,7 +756,11 @@ gint main(gint argc, gchar *argv[])
 #endif
 
        exif_init();
-       
+
+#ifdef HAVE_LUA
+       lua_init();
+#endif
+
        /* setup random seed for random slideshow */
        srand(time(NULL));