[gimp] plug-ins: fix and install the Lua goat-exercise.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix and install the Lua goat-exercise.
- Date: Fri, 16 Aug 2019 17:48:32 +0000 (UTC)
commit 0abdbebaad63a0814ceaa66bd561d0383b187748
Author: Jehan <jehan girinstud io>
Date: Fri Aug 16 19:46:32 2019 +0200
plug-ins: fix and install the Lua goat-exercise.
So procedure:new_return_values() just seems broken with LGI. It doesn't
even look like it reaches the C code.
Anyway we can also just reconstruct the GimpValueArray, which works
fine. We now have official support for Lua plug-ins!
configure.ac | 49 ++++++++++++++++++++++++++-
plug-ins/goat-exercises/Makefile.am | 8 +++++
plug-ins/goat-exercises/goat-exercise-lua.lua | 21 ++++++++----
3 files changed, 71 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e2c7c3566d..1ac9c4e40c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2359,6 +2359,52 @@ fi
AM_CONDITIONAL(HAS_JAVASCRIPT_INTERP, test "x$GJS" != "xno")
AM_CONDITIONAL(BUILD_JAVASCRIPT, test "x$with_javascript" != xno)
+####################################
+# Check for Lua runtime dependencies
+####################################
+
+AC_ARG_WITH(lua,
+ [ --with-lua=no|yes|force install Lua plug-ins (default=yes)], ,
+ [with_lua=yes])
+
+if test "x$with_lua" = xno; then
+ warning_lua="
+WARNING: you disabled the installation of core Lua plug-ins. This
+ is discouraged as it won't provide the full GIMP experience.
+ Note that you may install the Lua plug-ins even if Lua LGI
+ is not installed at build-time by passing the configure option
+ --with-lua=force.
+ Just make sure that it is available at run-time."
+elif test "x$with_lua" = xforce; then
+ with_lua="yes"
+ warning_lua=
+ AC_CHECK_PROGS(LUA, luajit, no)
+ if test "x$LUA" = xno; then
+ warning_lua="
+WARNING: luagit not found.
+ Lua plug-ins will be installed anyway but you should make
+ sure that luagit and LGI are available at installation,
+ otherwise installed plug-ins won't be usable."
+ with_lua="yes (see warning below)"
+ fi
+else
+ with_lua="yes"
+ AC_CHECK_PROGS(LUA, luajit, no)
+ if test "x$GJS" = xno; then
+ required_deps="$required_deps
+ - luagit not found.
+ *** Please install the Lua interpreter luagit.
+ *** Note that you may install the Lua plug-ins even if luajit
+ *** is not installed at build-time by passing the configure
+ *** option --with-lua=force.
+ *** Just make sure that luajit and LGI are available at run-time."
+ with_lua="no"
+ fi
+fi
+
+AM_CONDITIONAL(HAS_LUA_INTERP, test "x$LUA" != "xno")
+AM_CONDITIONAL(BUILD_LUA, test "x$with_lua" != xno)
+
###########################################################
# Some plug-ins don't build on Win32, others are Win32-only
###########################################################
@@ -3092,6 +3138,7 @@ Optional Plug-Ins:
Print: $enable_print
Python 3 plug-ins: $with_python
JavaScript plug-ins: $with_javascript
+ Lua plug-ins: $with_lua
TWAIN (Win32): $os_win32
Webpage: $have_webkit
WMF: $have_libwmf
@@ -3110,7 +3157,7 @@ Tests:
Test desktop file $have_desktop_file_validate
Bug report URL: $with_bug_report_url
-$override_bug_report_url$warning_vector_icons_windows$warning_glib_networking$warning_gcc$warning_python$warning_javascript"
+$override_bug_report_url$warning_vector_icons_windows$warning_glib_networking$warning_gcc$warning_python$warning_javascript$warning_lua"
if test "x$required_deps" = "x"; then
AC_OUTPUT
diff --git a/plug-ins/goat-exercises/Makefile.am b/plug-ins/goat-exercises/Makefile.am
index 83e7ad04dd..b16e90743d 100644
--- a/plug-ins/goat-exercises/Makefile.am
+++ b/plug-ins/goat-exercises/Makefile.am
@@ -67,6 +67,13 @@ goat_exercise_gjsdir = $(gimpplugindir)/plug-ins/goat-exercise-gjs
goat_exercise_gjs_SCRIPTS = goat-exercise-gjs.js
endif
+# Lua (lua-jit + LGI) version.
+
+if BUILD_LUA
+goat_exercise_luadir = $(gimpplugindir)/plug-ins/goat-exercise-lua
+goat_exercise_lua_SCRIPTS = goat-exercise-lua.lua
+endif
+
# Python 3 (pygobject) version.
# Commented out for now until we figure out the GParamSpec issues.
@@ -78,4 +85,5 @@ endif
EXTRA_DIST = \
goat-exercise-gjs.js \
+ goat-exercise-lua.lua \
goat-exercise-py3.py
diff --git a/plug-ins/goat-exercises/goat-exercise-lua.lua b/plug-ins/goat-exercises/goat-exercise-lua.lua
index 6b0914e367..72bc025d89 100755
--- a/plug-ins/goat-exercises/goat-exercise-lua.lua
+++ b/plug-ins/goat-exercises/goat-exercise-lua.lua
@@ -33,6 +33,9 @@ local Goat = lgi.package 'Goat'
local Goat = lgi.Goat
function run(procedure, args, data)
+ -- procedure:new_return_values() crashes LGI so we construct the
+ -- GimpValueArray manually.
+ local retval = Gimp.ValueArray(1)
local run_mode = GObject.Value.get_enum(args:index(0))
if run_mode == Gimp.RunMode.INTERACTIVE then
Gimp.ui_init("goat-exercise-lua", false);
@@ -93,14 +96,16 @@ function run(procedure, args, data)
Gio.app_info_launch_default_for_uri(url, nil);
else -- CANCEL, CLOSE, DELETE_EVENT
dialog:destroy()
- return procedure:new_return_values(Gimp.PDBStatusType.CANCEL, nil)
+ local cancel = GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.CANCEL)
+ retval:append(cancel)
+ return retval
end
end
end
local drawable_id = args:index(2):get_int()
local x, y, width, height = Gimp.drawable_mask_intersect (drawable_id)
- if width > 0 and height > 0 then
+ if width ~= nill and height ~= nil and width > 0 and height > 0 then
Gegl.init(nil)
local buffer = Gimp.drawable_get_buffer (drawable_id)
@@ -122,12 +127,16 @@ function run(procedure, args, data)
Gimp.drawable_update(drawable_id, x, y, width, height)
Gimp.displays_flush()
else
- local err = GLib.Error.new_literal(GLib.quark_from_string("goat-error-quark"), 0,
- "No pixels to process in the selected area.")
- return procedure:new_return_values(Gimp.PDBStatusType.CALLING_ERROR, err)
+ local fail = GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.CALLING_ERROR)
+ retval:append(fail)
+ local err = GObject.Value(GObject.Type.STRING, "No pixels to process in the selected area.")
+ retval:append(err)
+ return retval
end
- return procedure:new_return_values(Gimp.PDBStatusType.SUCCESS, 0)
+ local success = GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.SUCCESS)
+ retval:append(success)
+ return retval
end
Goat:class('Exercise', Gimp.PlugIn)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]