[gimp/wip/nielsdg/vapi] Add support for building Vala plug-ins
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/nielsdg/vapi] Add support for building Vala plug-ins
- Date: Fri, 8 May 2020 19:37:10 +0000 (UTC)
commit 312ba4741c046056693dc7a50b186a18ae8e1153
Author: Niels De Graef <nielsdegraef gmail com>
Date: Fri Aug 9 22:31:01 2019 +0200
Add support for building Vala plug-ins
acinclude.m4 | 1 +
configure.ac | 34 +++++
libgimp/GimpUi-3.0.metadata | 25 ++++
libgimp/Makefile.am | 34 +++++
libgimp/gimpaspectpreview.h | 3 +
libgimp/meson.build | 131 ++++++++++++-----
libgimpwidgets/gimpcolordisplay.h | 3 +
libgimpwidgets/gimpwidgetstypes.h | 2 +-
m4macros/Makefile.am | 3 +-
m4macros/vapigen.m4 | 96 +++++++++++++
meson.build | 10 ++
meson_options.txt | 1 +
plug-ins/goat-exercises/Makefile.am | 34 +++++
plug-ins/goat-exercises/goat-exercise-gjs.js | 8 +-
plug-ins/goat-exercises/goat-exercise-lua.lua | 5 +-
plug-ins/goat-exercises/goat-exercise-py3.py | 12 +-
plug-ins/goat-exercises/goat-exercise-vala.vala | 158 +++++++++++++++++++++
.../goat-exercises/goat_exercise_vala_vala.stamp-t | 1 +
plug-ins/goat-exercises/meson.build | 22 +++
19 files changed, 536 insertions(+), 47 deletions(-)
---
diff --git a/acinclude.m4 b/acinclude.m4
index c803690211..009690d31c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -6,3 +6,4 @@ m4_include([m4macros/ax_prog_cc_for_build.m4])
m4_include([m4macros/ax_prog_perl_version.m4])
m4_include([m4macros/detectcflags.m4])
m4_include([m4macros/python3dev.m4])
+m4_include([m4macros/vapigen.m4])
diff --git a/configure.ac b/configure.ac
index 34a1b93f80..98b5f0c89b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,10 @@ m4_define([gimp_full_name], [GNU Image Manipulation Program])
m4_define([alsa_required_version], [1.0.0])
m4_define([appstream_glib_required_version], [0.7.7])
m4_define([atk_required_version], [2.4.0])
+m4_define([babl_major_minor_version], [0.1])
+m4_define([babl_micro_version], [74])
+m4_define([babl_required_version],
+ [babl_major_minor_version.babl_micro_version])
m4_define([babl_required_version], [0.1.74])
m4_define([cairo_required_version], [1.14.0])
m4_define([cairo_pdf_required_version], [1.12.2])
@@ -83,6 +87,7 @@ m4_define([poppler_required_version], [0.69.0])
m4_define([poppler_data_required_version], [0.4.9])
m4_define([python3_required_version], [3.6.0])
m4_define([rsvg_required_version], [2.40.6])
+m4_define([vala_required_version], [0.40.0])
m4_define([webkitgtk_required_version], [2.20.3])
m4_define([webp_required_version], [0.6.0])
m4_define([wmf_required_version], [0.2.8])
@@ -155,6 +160,7 @@ AC_DEFINE(GIMP_TOOL_VERSION, "gimp_tool_version",
# These are used for substitution (.pc, INSTALL, etc.).
APPSTREAM_GLIB_REQUIRED_VERSION=appstream_glib_required_version
ATK_REQUIRED_VERSION=atk_required_version
+BABL_MAJOR_MINOR_VERSION=babl_major_minor_version
BABL_REQUIRED_VERSION=babl_required_version
CAIRO_REQUIRED_VERSION=cairo_required_version
CAIRO_PDF_REQUIRED_VERSION=cairo_pdf_required_version
@@ -181,6 +187,7 @@ POPPLER_REQUIRED_VERSION=poppler_required_version
POPPLER_DATA_REQUIRED_VERSION=poppler_data_required_version
PYTHON3_REQUIRED_VERSION=python3_required_version
RSVG_REQUIRED_VERSION=rsvg_required_version
+VALA_REQUIRED_VERSION=vala_required_version
WEBKITGTK_REQUIRED_VERSION=webkitgtk_required_version
WEBP_REQUIRED_VERSION=webp_required_version
WMF_REQUIRED_VERSION=wmf_required_version
@@ -188,6 +195,7 @@ LIBUNWIND_REQUIRED_VERSION=libunwind_required_version
XGETTEXT_REQUIRED_VERSION=xgettext_required_version
AC_SUBST(APPSTREAM_GLIB_REQUIRED_VERSION)
AC_SUBST(ATK_REQUIRED_VERSION)
+AC_SUBST(BABL_MAJOR_MINOR_VERSION)
AC_SUBST(BABL_REQUIRED_VERSION)
AC_SUBST(CAIRO_REQUIRED_VERSION)
AC_SUBST(CAIRO_PDF_REQUIRED_VERSION)
@@ -214,6 +222,7 @@ AC_SUBST(POPPLER_REQUIRED_VERSION)
AC_SUBST(POPPLER_DATA_REQUIRED_VERSION)
AC_SUBST(PYTHON3_REQUIRED_VERSION)
AC_SUBST(RSVG_REQUIRED_VERSION)
+AC_SUBST(VALA_REQUIRED_VERSION)
AC_SUBST(WEBKITGTK_REQUIRED_VERSION)
AC_SUBST(WEBP_REQUIRED_VERSION)
AC_SUBST(WMF_REQUIRED_VERSION)
@@ -2419,6 +2428,30 @@ fi
AM_CONDITIONAL(HAS_LUA_INTERP, test "x$LUA" != "xno")
AM_CONDITIONAL(BUILD_LUA, test "x$with_lua" != xno)
+#######################################
+# Check for Vala buildtime dependencies
+#######################################
+
+AC_ARG_WITH(vala,
+ [ --with-vala=no|yes install Vala plug-ins (default=yes)], ,
+ [with_vala=yes])
+
+if test "x$with_vala" = xno; then
+ warning_vala="
+WARNING: you disabled the installation of core Vala plug-ins. This
+ is discouraged as it won't provide the full GIMP experience."
+else
+ VAPIGEN_CHECK($VALA_REQUIRED_VERSION)
+ with_vala="yes"
+ warning_vala=
+ AC_PATH_PROG(VALAC, valac, no)
+ if test "x$VALAC" = xno; then
+ AC_MSG_ERROR([Vala-plugins are enabled, but could not find vala compiler])
+ fi
+fi
+
+AM_CONDITIONAL(BUILD_VALA, test "x$with_vala" != xno)
+
###########################################################
# Some plug-ins don't build on Win32, others are Win32-only
###########################################################
@@ -3186,6 +3219,7 @@ Optional Plug-Ins:
Python 3 plug-ins: $with_python
JavaScript plug-ins: $with_javascript
Lua plug-ins: $with_lua
+ Vala plug-ins: $with_vala
TWAIN (Win32): $os_win32
Webpage: $have_webkit
WMF: $have_libwmf
diff --git a/libgimp/GimpUi-3.0.metadata b/libgimp/GimpUi-3.0.metadata
new file mode 100644
index 0000000000..6397503fd1
--- /dev/null
+++ b/libgimp/GimpUi-3.0.metadata
@@ -0,0 +1,25 @@
+// Extra metadata for Vala, to deal with
+// annotations that GIR can't handle.
+//
+// For example, GIR function doesn't handle
+// varargs, but Vala *can* do this, so we can
+// remove the (skip) annotation.
+Dialog
+ .new skip=false
+ .add_buttons skip=false
+IntComboBox
+ .new skip=false
+IntStore
+ .new skip=false
+MessageDialog
+ .new skip=false
+ProcBrowserDialog
+ .new skip=false
+ToolDialog
+ .new skip=false
+OverlayDialog
+ .new skip=false
+ViewableDialog
+ .new skip=false
+
+text_layer_set
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index d05f09d8aa..c42f3838bb 100644
--- a/libgimp/Makefile.am
+++ b/libgimp/Makefile.am
@@ -343,3 +343,37 @@ typelibdir = $(libdir)/girepository-1.0
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
+
+
+if ENABLE_VAPIGEN
+
+-include $(VAPIGEN_MAKEFILE)
+
+gimp-@GIMP_API_MAJOR_VERSION@.vapi: Gimp-@GIMP_API_VERSION@.gir gimp-@GIMP_API_MAJOR_VERSION@.deps
+
+VAPIGEN_VAPIS = gimp-@GIMP_API_MAJOR_VERSION@.vapi
+
+gimp_@GIMP_API_MAJOR_VERSION@_vapi_DEPS = \
+ babl-@BABL_MAJOR_MINOR_VERSION@ \
+ cairo \
+ gdk-pixbuf-2.0 \
+ gegl-@GEGL_MAJOR_MINOR_VERSION@ \
+ glib-2.0 \
+ gio-2.0 \
+ gtk+-3.0
+gimp_@GIMP_API_MAJOR_VERSION@_vapi_METADATADIRS = $(srcdir)
+gimp_@GIMP_API_MAJOR_VERSION@_vapi_FILES = Gimp-@GIMP_API_VERSION@.gir
+
+gimp-$(GIMP_API_MAJOR_VERSION).deps: Makefile.am
+ $(AM_V_GEN) for pkg in $(gimp_@GIMP_API_MAJOR_VERSION@_vapi_DEPS); do \
+ echo $$pkg >> $@; \
+ done
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = \
+ gimp-@GIMP_API_MAJOR_VERSION@.vapi \
+ gimp-@GIMP_API_MAJOR_VERSION@.deps
+
+CLEANFILES += $(vapi_DATA)
+
+endif # ENABLE_VAPIGEN
diff --git a/libgimp/gimpaspectpreview.h b/libgimp/gimpaspectpreview.h
index e7d126aaaf..06aabcceaf 100644
--- a/libgimp/gimpaspectpreview.h
+++ b/libgimp/gimpaspectpreview.h
@@ -25,6 +25,9 @@
#ifndef __GIMP_ASPECT_PREVIEW_H__
#define __GIMP_ASPECT_PREVIEW_H__
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
G_BEGIN_DECLS
diff --git a/libgimp/meson.build b/libgimp/meson.build
index 272578ec40..e1a199ddc1 100644
--- a/libgimp/meson.build
+++ b/libgimp/meson.build
@@ -336,19 +336,22 @@ install_headers(
### GObject introspection
-introspectable_files = [
+libgimp_introspectable_files = [
libgimp_introspectable,
- libgimpui_introspectable,
libgimpbase_introspectable,
libgimpcolor_introspectable,
libgimpconfig_introspectable,
libgimpmath_introspectable,
libgimpmodule_introspectable,
- libgimpthumb_introspectable,
- libgimpwidgets_introspectable,
+ # libgimpthumb_introspectable,
'gimpparamspecs-body.c',
]
+libgimpui_introspectable_files = [
+ libgimpui_introspectable,
+ libgimpwidgets_introspectable,
+]
+
if meson.is_cross_build()
gobject_introspection_warning = '\n '.join(['',
'GObject Introspection is disabled while cross-compiling because',
@@ -360,53 +363,111 @@ if meson.is_cross_build()
warning(gobject_introspection_warning)
warnings += gobject_introspection_warning
else
+ libgimp_gir_includes = [
+ 'Babl-0.1',
+ 'cairo-1.0',
+ 'GdkPixbuf-2.0',
+ 'Gegl-0.4',
+ 'Gio-2.0',
+ 'GLib-2.0',
+ 'GObject-2.0',
+ 'Gtk-3.0',
+ ]
+
+ gir_args = [
+ '-DGIMP_COMPILATION',
+ '-DGIMP_BASE_COMPILATION',
+ '-DGIMP_COLOR_COMPILATION',
+ '-DGIMP_CONFIG_COMPILATION',
+ '-DGIMP_MATH_COMPILATION',
+ '-DGIMP_MODULE_COMPILATION',
+ '-DGIMP_THUMB_COMPILATION',
+ '-DGIMP_WIDGETS_COMPILATION',
+ '-DGIMP_DISABLE_DEPRECATED',
+ '--quiet',
+ ]
+
libgimp_gir = gnome.generate_gir(
libgimp,
- libgimpui,
libgimpbase,
libgimpcolor,
libgimpconfig,
libgimpmath,
libgimpmodule,
- libgimpthumb,
- libgimpwidgets,
- sources: introspectable_files,
+ sources: libgimp_introspectable_files,
nsversion: gimp_api_version,
namespace: 'Gimp',
identifier_prefix: 'Gimp',
# symbol_prefix: 'gimp',
header: 'libgimp/gimp.h',
+ includes: libgimp_gir_includes,
+ extra_args: gir_args,
- extra_args: [
- '-DGIMP_COMPILATION',
- '-DGIMP_BASE_COMPILATION',
- '-DGIMP_COLOR_COMPILATION',
- '-DGIMP_CONFIG_COMPILATION',
- '-DGIMP_MATH_COMPILATION',
- '-DGIMP_MODULE_COMPILATION',
- '-DGIMP_THUMB_COMPILATION',
- '-DGIMP_WIDGETS_COMPILATION',
- '-DGIMP_DISABLE_DEPRECATED',
- '--quiet',
- ],
-
- includes: [
- 'Babl-0.1',
- 'cairo-1.0',
- 'GdkPixbuf-2.0',
- 'Gegl-0.4',
- 'Gio-2.0',
- 'GLib-2.0',
- 'GObject-2.0',
- 'Gtk-3.0',
- ],
-
- link_with: [
- libgimpthumb,
- ],
+ # link_with: [
+ # libgimpthumb,
+ # ],
include_directories: rootInclude,
install: true,
)
+
+ libgimpui_gir = gnome.generate_gir(
+ libgimpui,
+ libgimpwidgets,
+
+ sources: libgimpui_introspectable_files,
+ nsversion: gimp_api_version,
+ namespace: 'GimpUi',
+ identifier_prefix: 'Gimp',
+ symbol_prefix: 'gimp',
+ header: 'gimp-3.0/libgimp/gimpui.h',
+ includes: [ libgimp_gir_includes, libgimp_gir[0] ],
+ extra_args: gir_args,
+
+ # link_with: [
+ # libgimpthumb,
+ # ],
+
+ include_directories: rootInclude,
+ install: true,
+ )
+
+ if have_vala
+ libgimp_vapi = gnome.generate_vapi('gimp-' + gimp_api_version,
+ sources: libgimp_gir[0],
+
+ packages: [
+ 'babl-0.1',
+ 'cairo-1.0',
+ 'gdk-pixbuf-2.0',
+ 'gegl-0.4',
+ 'gio-2.0',
+ 'glib-2.0',
+ 'gobject-2.0',
+ 'gtk+-3.0',
+ ],
+
+ install: true,
+ )
+
+ libgimpui_vapi = gnome.generate_vapi('gimp-ui-' + gimp_api_version,
+ sources: libgimpui_gir[0],
+
+ packages: [
+ 'babl-0.1',
+ 'cairo-1.0',
+ 'gdk-pixbuf-2.0',
+ 'gegl-0.4',
+ 'gio-2.0',
+ 'glib-2.0',
+ 'gobject-2.0',
+ 'gtk+-3.0',
+ 'gimp-' + gimp_api_version,
+ ],
+
+ vapi_dirs: [ meson.current_build_dir() ],
+ install: true,
+ )
+ endif
endif
diff --git a/libgimpwidgets/gimpcolordisplay.h b/libgimpwidgets/gimpcolordisplay.h
index 03c31f2884..3fb20c9aec 100644
--- a/libgimpwidgets/gimpcolordisplay.h
+++ b/libgimpwidgets/gimpcolordisplay.h
@@ -26,6 +26,9 @@
#ifndef __GIMP_COLOR_DISPLAY_H__
#define __GIMP_COLOR_DISPLAY_H__
+#include <glib-object.h>
+#include <gegl.h>
+
G_BEGIN_DECLS
/* For information look at the html documentation */
diff --git a/libgimpwidgets/gimpwidgetstypes.h b/libgimpwidgets/gimpwidgetstypes.h
index 2b92882eaa..0fea008b97 100644
--- a/libgimpwidgets/gimpwidgetstypes.h
+++ b/libgimpwidgets/gimpwidgetstypes.h
@@ -82,7 +82,7 @@ typedef struct _GimpZoomModel GimpZoomModel;
/**
* GimpHelpFunc:
* @help_id: the help ID
- * @help_data: (closure): the help user data
+ * @help_data: the help user data
*
* This is the prototype for all functions you pass as @help_func to
* the various GIMP dialog constructors like gimp_dialog_new(),
diff --git a/m4macros/Makefile.am b/m4macros/Makefile.am
index c79976280a..ed19e97a5a 100644
--- a/m4macros/Makefile.am
+++ b/m4macros/Makefile.am
@@ -11,7 +11,8 @@ uninstalled_m4 = \
ax_prog_perl_version.m4 \
detectcflags.m4 \
introspection.m4 \
- python3dev.m4
+ python3dev.m4 \
+ vapigen.m4
EXTRA_DIST = $(installed_m4) $(uninstalled_m4)
diff --git a/m4macros/vapigen.m4 b/m4macros/vapigen.m4
new file mode 100644
index 0000000000..f2df12f23f
--- /dev/null
+++ b/m4macros/vapigen.m4
@@ -0,0 +1,96 @@
+dnl vapigen.m4
+dnl
+dnl Copyright 2012 Evan Nemerson
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT])
+# --------------------------------------
+# Check vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+ AC_BEFORE([GOBJECT_INTROSPECTION_CHECK],[$0])
+ AC_BEFORE([GOBJECT_INTROSPECTION_REQUIRE],[$0])
+
+ AC_ARG_ENABLE([vala],
+ [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings
@<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
+ AS_IF([test "x$4" = "x"], [
+ enable_vala=auto
+ ], [
+ enable_vala=$4
+ ])
+ ])
+
+ AS_CASE([$enable_vala], [no], [enable_vala=no],
+ [yes], [
+ AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+ AC_MSG_ERROR([Vala bindings require GObject Introspection])
+ ])
+ ], [auto], [
+ AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+ enable_vala=no
+ ])
+ ], [
+ AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
+ ])
+
+ AS_IF([test "x$2" = "x"], [
+ vapigen_pkg_name=vapigen
+ ], [
+ vapigen_pkg_name=vapigen-$2
+ ])
+ AS_IF([test "x$1" = "x"], [
+ vapigen_pkg="$vapigen_pkg_name"
+ ], [
+ vapigen_pkg="$vapigen_pkg_name >= $1"
+ ])
+
+ PKG_PROG_PKG_CONFIG
+
+ PKG_CHECK_EXISTS([$vapigen_pkg], [
+ AS_IF([test "$enable_vala" = "auto"], [
+ enable_vala=yes
+ ])
+ ], [
+ AS_CASE([$enable_vala], [yes], [
+ AC_MSG_ERROR([$vapigen_pkg not found])
+ ], [auto], [
+ enable_vala=no
+ ])
+ ])
+
+ AC_MSG_CHECKING([for vala])
+
+ AS_CASE([$enable_vala],
+ [yes], [
+ VAPIGEN=`$PKG_CONFIG --variable=vapigen vapigen`
+ VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir vapigen`/vala/Makefile.vapigen
+ AS_IF([test "x$2" = "x"], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen`
+ ], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen`
+ ])
+ ])
+
+ AC_MSG_RESULT([$enable_vala])
+
+ AC_SUBST([VAPIGEN])
+ AC_SUBST([VAPIGEN_VAPIDIR])
+ AC_SUBST([VAPIGEN_MAKEFILE])
+
+ AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])
diff --git a/meson.build b/meson.build
index 304c79fe4f..8a16f12505 100644
--- a/meson.build
+++ b/meson.build
@@ -757,6 +757,16 @@ if libheif.version().version_compare('==1.5.0') or libheif.version().version_com
warnings += libheif_warning
endif
+have_vala = add_languages('vala', required: get_option('vala-plugins'))
+if have_vala
+ babl = declare_dependency(
+ dependencies: [
+ babl,
+ meson.get_compiler('vala').find_library('babl-0.1'),
+ ]
+ )
+endif
+
webkit_minver = '2.20.3'
webkit = dependency('webkit2gtk-4.0', version: '>=' + webkit_minver,
required: get_option('webkit')
diff --git a/meson_options.txt b/meson_options.txt
index 10255dc9ca..1b2d850807 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -45,6 +45,7 @@ option('png', type: 'feature', value: 'auto', description: 'PNG su
option('print', type: 'feature', value: 'auto', description: 'Print support')
option('screenshot', type: 'feature', value: 'auto', description: 'Screensh')
option('tiff', type: 'feature', value: 'auto', description: 'TIFF support')
+option('vala-plugins', type: 'feature', value: 'auto', description: 'Build VAPI and Vala plugins')
option('webkit', type: 'feature', value: 'auto', description: 'Help browser and webpage plugins')
option('webp', type: 'feature', value: 'auto', description: 'Webp support')
option('wmf', type: 'feature', value: 'auto', description: 'Wmf support')
diff --git a/plug-ins/goat-exercises/Makefile.am b/plug-ins/goat-exercises/Makefile.am
index c0c3c84efb..3e7a29501d 100644
--- a/plug-ins/goat-exercises/Makefile.am
+++ b/plug-ins/goat-exercises/Makefile.am
@@ -82,6 +82,40 @@ goat_exercise_py3dir = $(gimpplugindir)/plug-ins/goat-exercise-py3
goat_exercise_py3_SCRIPTS = goat-exercise-py3.py
endif
+# Vala (compiled to C) version
+
+if ENABLE_VAPIGEN
+
+goat_exercise_vala_libexecdir = $(gimpplugindir)/plug-ins/goat-exercise-vala
+goat_exercise_vala_datadir = $(goat_exercise_vala_libexecdir)
+
+goat_exercise_vala_libexec_PROGRAMS = goat-exercise-vala
+goat_exercise_vala_libexec_DATA = goat-exercise-vala.vala
+
+goat_exercise_vala_SOURCES = goat-exercise-vala.vala
+
+goat_exercise_vala_LDADD = \
+ $(libgimp) \
+ $(libgimpmath) \
+ $(libgimpconfig) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(libgimpui) \
+ $(libgimpwidgets) \
+ $(CAIRO_LIBS) \
+ $(GDK_PIXBUF_LIBS) \
+ $(GEGL_LIBS) \
+ $(GTK_LIBS) \
+ $(RT_LIBS) \
+ $(INTLLIBS) \
+ $(goat_exercise_RC)
+
+goat_exercise_vala_VALAFLAGS = \
+ --vapidir=$(abs_top_builddir)/libgimp \
+ --pkg gimp-@GIMP_API_MAJOR_VERSION@
+
+endif
+
EXTRA_DIST = \
goat-exercise-gjs.js \
goat-exercise-lua.lua \
diff --git a/plug-ins/goat-exercises/goat-exercise-gjs.js b/plug-ins/goat-exercises/goat-exercise-gjs.js
index d2287306d0..6eccebd039 100755
--- a/plug-ins/goat-exercises/goat-exercise-gjs.js
+++ b/plug-ins/goat-exercises/goat-exercise-gjs.js
@@ -24,6 +24,8 @@ const System = imports.system
imports.gi.versions.Gimp = '3.0';
const Gimp = imports.gi.Gimp;
+imports.gi.versions.GimpUi = '3.0';
+const GimpUi = imports.gi.GimpUi;
imports.gi.versions.Gegl = '0.4';
const Gegl = imports.gi.Gegl;
imports.gi.versions.Gtk = '3.0';
@@ -56,7 +58,7 @@ var Goat = GObject.registerClass({
procedure.set_image_types("*");
procedure.set_menu_label("Exercise a JavaScript goat");
- procedure.set_icon_name(Gimp.ICON_GEGL);
+ procedure.set_icon_name(GimpUi.ICON_GEGL);
procedure.add_menu_path ('<Image>/Filters/Development/Goat exercises/');
procedure.set_documentation("Exercise a goat in the JavaScript language (GJS)",
@@ -71,9 +73,9 @@ var Goat = GObject.registerClass({
/* TODO: localization. */
if (run_mode == Gimp.RunMode.INTERACTIVE) {
- Gimp.ui_init("goat-exercise-gjs");
+ GimpUi.ui_init("goat-exercise-gjs");
/* TODO: help function and ID. */
- let dialog = new Gimp.Dialog({
+ let dialog = new GimpUi.Dialog({
title: "Exercise a goat (JavaScript)",
role: "goat-exercise-JavaScript",
use_header_bar: true,
diff --git a/plug-ins/goat-exercises/goat-exercise-lua.lua b/plug-ins/goat-exercises/goat-exercise-lua.lua
index 1e099cdf4b..91c28611ce 100755
--- a/plug-ins/goat-exercises/goat-exercise-lua.lua
+++ b/plug-ins/goat-exercises/goat-exercise-lua.lua
@@ -26,6 +26,7 @@ local GObject = lgi.GObject
local Gio = lgi.Gio
local Gegl = lgi.Gegl
local Gimp = lgi.Gimp
+local GimpUi = lgi.GimpUi
local Gtk = lgi.Gtk
local Gdk = lgi.Gdk
@@ -40,7 +41,7 @@ function run(procedure, run_mode, image, drawable, args, run_data)
-- against Gimp.RunMode.INTERACTIVE.
if run_mode == "INTERACTIVE" then
Gimp.ui_init("goat-exercise-lua");
- local dialog = Gimp.Dialog {
+ local dialog = GimpUi.Dialog {
title = "Exercise a goat (Lua)",
role = "goat-exercise-Lua",
use_header_bar = 1
@@ -146,7 +147,7 @@ function Goat.Exercise:do_create_procedure(name)
procedure:set_image_types("*");
procedure:set_menu_label("Exercise a Lua goat");
- procedure:set_icon_name(Gimp.ICON_GEGL);
+ procedure:set_icon_name(GimpUi.ICON_GEGL);
procedure:add_menu_path('<Image>/Filters/Development/Goat exercises/');
procedure:set_documentation("Exercise a goat in the Lua language",
diff --git a/plug-ins/goat-exercises/goat-exercise-py3.py b/plug-ins/goat-exercises/goat-exercise-py3.py
index ee70bcf1ed..8f0d4a19ff 100755
--- a/plug-ins/goat-exercises/goat-exercise-py3.py
+++ b/plug-ins/goat-exercises/goat-exercise-py3.py
@@ -16,6 +16,8 @@
import gi
gi.require_version('Gimp', '3.0')
from gi.repository import Gimp
+gi.require_version('GimpUi', '3.0')
+from gi.repository import GimpUi
gi.require_version('Gegl', '0.4')
from gi.repository import Gegl
from gi.repository import GObject
@@ -44,7 +46,7 @@ class Goat (Gimp.PlugIn):
procedure.set_image_types("*");
procedure.set_menu_label("Exercise a goat and a python");
- procedure.set_icon_name(Gimp.ICON_GEGL);
+ procedure.set_icon_name(GimpUi.ICON_GEGL);
procedure.add_menu_path('<Image>/Filters/Development/Goat exercises/');
procedure.set_documentation("Exercise a goat in the Python 3 language",
@@ -61,11 +63,11 @@ class Goat (Gimp.PlugIn):
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk
- Gimp.ui_init("palette-offset.py")
+ GimpUi.ui_init("palette-offset.py")
- dialog = Gimp.Dialog(use_header_bar=True,
- title=_("Exercise a goat (Python 3)"),
- role="goat-exercise-Python3")
+ dialog = GimpUi.Dialog(use_header_bar=True,
+ title=_("Exercise a goat (Python 3)"),
+ role="goat-exercise-Python3")
dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
dialog.add_button("_Source", Gtk.ResponseType.APPLY)
diff --git a/plug-ins/goat-exercises/goat-exercise-vala.vala b/plug-ins/goat-exercises/goat-exercise-vala.vala
new file mode 100755
index 0000000000..d586e1fcfe
--- /dev/null
+++ b/plug-ins/goat-exercises/goat-exercise-vala.vala
@@ -0,0 +1,158 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * hello-world.vala
+ * Copyright (C) Niels De Graef <nielsdegraef gmail com>
+ *
+ * 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 3 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+private const string PLUG_IN_PROC = "plug-in-goat-exercise-vala";
+private const string PLUG_IN_ROLE = "goat-exercise-vala";
+private const string PLUG_IN_BINARY = "goat-exercise-vala";
+private const string PLUG_IN_SOURCE = PLUG_IN_BINARY + ".vala";
+private const string URL =
"https://gitlab.gnome.org/GNOME/gimp/blob/master/plug-ins/goat-exercises/goat-exercise-vala.vala";
+
+public int main(string[] args) {
+ return Gimp.main(typeof(Goat), args);
+}
+
+public class Goat : Gimp.PlugIn {
+
+ public override GLib.List<string> query_procedures() {
+ GLib.List<string> procs = null;
+ procs.append(PLUG_IN_PROC);
+ return procs;
+ }
+
+ public override Gimp.Procedure create_procedure(string name) {
+ assert(name == PLUG_IN_PROC);
+
+ var procedure = new Gimp.ImageProcedure(this, name, Gimp.PDBProcType.PLUGIN, this.run);
+ procedure.set_image_types("RGB*, INDEXED*, GRAY*");
+ procedure.set_menu_label("Exercise a Vala goat");
+ procedure.set_documentation("Exercise a goat in the Vala language",
+ "Takes a goat for a walk in Vala",
+ PLUG_IN_PROC);
+ procedure.add_menu_path("<Image>/Filters/Development/Goat exercises/");
+ procedure.set_attribution("Niels De Graef", "Niels De Graef", "2020");
+ procedure.set_icon_name(Gimp.ICON_GEGL);
+
+ return procedure;
+ }
+
+ public Gimp.ValueArray run(Gimp.Procedure procedure,
+ Gimp.RunMode run_mode,
+ Gimp.Image image,
+ Gimp.Drawable drawable,
+ Gimp.ValueArray args) {
+ if (run_mode == Gimp.RunMode.INTERACTIVE) {
+ Gimp.ui_init(PLUG_IN_BINARY);
+
+ /* TODO: need to get standard_help_func recognized as Gimp.HelpFunc */
+ var dialog =
+ new Gimp.Dialog(_("Exercise a goat (Vala)"),
+ PLUG_IN_ROLE,
+ null,
+ Gtk.DialogFlags.USE_HEADER_BAR,
+ Gimp.standard_help_func,
+ PLUG_IN_PROC,
+ _("_Cancel"), Gtk.ResponseType.CANCEL,
+ _("_Source"), Gtk.ResponseType.APPLY,
+ _("_Run"), Gtk.ResponseType.OK,
+ null);
+
+ var geometry = Gdk.Geometry();
+ geometry.min_aspect = 0.5;
+ geometry.max_aspect = 1.0;
+ dialog.set_geometry_hints(null, geometry, Gdk.WindowHints.ASPECT);
+
+ var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 12);
+ box.border_width = 12;
+ dialog.get_content_area().add(box);
+ box.show();
+
+ var head_text =
+ _("This plug-in is an exercise in '%s' to demo plug-in creation.\nCheck out the last version of the
source code online by clicking the \"Source\" button.")
+ .printf("Vala");
+
+ var label = new Gtk.Label(head_text);
+ box.pack_start(label, false, false, 1);
+ label.show();
+
+
+ string file = Path.build_filename(Gimp.PlugIn.directory(), "plug-ins", PLUG_IN_BINARY, PLUG_IN_SOURCE);
+ string contents;
+ try {
+ FileUtils.get_contents(file, out contents);
+ } catch (Error err) {
+ contents = "Couldn't get file contents: %s".printf(err.message);
+ }
+
+ var scrolled = new Gtk.ScrolledWindow(null, null);
+ scrolled.vexpand = true;
+ box.pack_start(scrolled, true, true, 1);
+ scrolled.show();
+
+ var view = new Gtk.TextView();
+ view.wrap_mode = Gtk.WrapMode.WORD;
+ view.editable = false;
+ view.buffer.text = contents;
+ scrolled.add(view);
+ view.show();
+
+ while (true) {
+ var response = dialog.run();
+
+ if (response == Gtk.ResponseType.OK) {
+ dialog.destroy();
+ break;
+ } else if (response == Gtk.ResponseType.APPLY) {
+ Gtk.show_uri_on_window(dialog, URL, Gdk.CURRENT_TIME);
+ continue;
+ } else {
+ dialog.destroy();
+ return procedure.new_return_values(Gimp.PDBStatusType.CANCEL, null);
+ }
+ }
+ }
+
+ int x, y, width, height;
+ if (!drawable.mask_intersect(out x, out y, out width, out height)) {
+ var error = new GLib.Error.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, error);
+ }
+
+ unowned string[]? argv = null;
+ Gegl.init(ref argv);
+
+ {
+ var buffer = drawable.get_buffer();
+ var shadow_buffer = drawable.get_shadow_buffer();
+ Gegl.render_op(buffer, shadow_buffer, "gegl:invert", null);
+ // We don't need this line, since shadow_buffer is unreffed
+ // at the end of this block.
+ // No block? Then you still need to uncomment the following line
+ // shadow_buffer.flush();
+ }
+
+ drawable.merge_shadow(true);
+ drawable.update(x, y, width, height);
+ Gimp.displays_flush();
+ Gegl.exit();
+
+ return procedure.new_return_values(Gimp.PDBStatusType.SUCCESS, null);
+ }
+}
diff --git a/plug-ins/goat-exercises/goat_exercise_vala_vala.stamp-t
b/plug-ins/goat-exercises/goat_exercise_vala_vala.stamp-t
new file mode 100644
index 0000000000..859afb1de8
--- /dev/null
+++ b/plug-ins/goat-exercises/goat_exercise_vala_vala.stamp-t
@@ -0,0 +1 @@
+stamp
diff --git a/plug-ins/goat-exercises/meson.build b/plug-ins/goat-exercises/meson.build
index 58e5996dd9..037ed3981b 100644
--- a/plug-ins/goat-exercises/meson.build
+++ b/plug-ins/goat-exercises/meson.build
@@ -44,6 +44,28 @@ install_data(
install_dir: gimpplugindir / 'plug-ins' / plugin_name + '-c',
)
+# Vala version
+
+if have_vala
+ goat_exercise_vala = executable('goat-exercise-vala',
+ 'goat-exercise-vala.vala',
+ include_directories: [ rootInclude, ],
+ dependencies: [
+ libgimp_vapi, libgimpui_vapi, gtk3, gegl, math,
+ ],
+ c_args: [
+ '-DGETTEXT_PACKAGE="@0@"'.format(gettext_package),
+ ],
+ install: true,
+ install_dir: gimpplugindir / 'plug-ins' / plugin_name + '-vala',
+ )
+
+ install_data(
+ 'goat-exercise-vala.vala',
+ install_dir: gimpplugindir / 'plug-ins' / plugin_name + '-vala',
+ )
+endif
+
# Python 3 (pygobject) version.
if have_python
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]