From c5c0aa1566e7c95c4e3d009067b1e5133aa8736f Mon Sep 17 00:00:00 2001 From: Klaus Ethgen Date: Sat, 27 Jun 2009 22:38:09 +0100 Subject: [PATCH] Adding support for lua scripting Until now this is without any functionality. --- configure.in | 30 +++++++++++++++++++++++++++++- src/Makefile.am | 7 +++++-- src/lua.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/lua.h | 30 ++++++++++++++++++++++++++++++ src/main.c | 7 ++++++- 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 src/lua.c create mode 100644 src/lua.h diff --git a/configure.in b/configure.in index ac8415e7..57735ef7 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 144b0907..66f0be93 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 00000000..a711b274 --- /dev/null +++ b/src/lua.c @@ -0,0 +1,41 @@ +/** \file + * \short LUA implementation + * \author Klaus Ethgen + */ + +/* + * 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 +#include + +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 index 00000000..b24776d7 --- /dev/null +++ b/src/lua.h @@ -0,0 +1,30 @@ +/** \file + * \short LUA implementation + * \author Klaus Ethgen + */ + +/* + * 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: */ diff --git a/src/main.c b/src/main.c index 7cad734e..b54ac300 100644 --- a/src/main.c +++ b/src/main.c @@ -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)); -- 2.20.1