Skip to content

Commit

Permalink
Adding support for lua scripting
Browse files Browse the repository at this point in the history
Until now this is without any functionality.
  • Loading branch information
mowgli committed Dec 23, 2010
1 parent 55de20b commit c5c0aa1
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 4 deletions.
30 changes: 29 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -467,6 +494,7 @@ Support:
Lirc: $HAVE_LIRC
Libchamplain: $HAVE_LIBCHAMPLAIN
Libchamplain-gtk: $HAVE_LIBCHAMPLAIN_GTK
Lua: $HAVE_LUA

Documentation:
Doxygen: $DOXYGEN
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AM_CFLAGS = \
$(EXIV2_CFLAGS) \
$(LIBCHAMPLAIN_CFLAGS) \
$(LIBCHAMPLAIN_GTK_CFLAGS) \
$(LUA_CFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir)

Expand All @@ -17,6 +18,7 @@ AM_CXXFLAGS = \
$(EXIV2_CFLAGS) \
$(LIBCHAMPLAIN_CFLAGS) \
$(LIBCHAMPLAIN_GTK_CFLAGS) \
$(LUA_CFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir)

Expand Down Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions src/lua.c
Original file line number Diff line number Diff line change
@@ -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: */
30 changes: 30 additions & 0 deletions src/lua.h
Original file line number Diff line number Diff line change
@@ -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: */
7 changes: 6 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "exif.h"
#include "histogram.h"
#include "pixbuf_util.h"
#include "lua.h"

#ifdef HAVE_LIBCHAMPLAIN
#ifdef HAVE_LIBCHAMPLAIN_GTK
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit c5c0aa1

Please sign in to comment.