When I was trying to use the Gimp plug-in template for my gimp plug-in written in C/C++, I noticed that I was not able to use it straight forward. The supporting documentation is also very brief and therefore I decided to document how I incorporated the template in my project. Hopefully it will help others saving time figuring it out again. But please note that I only have very limited experience with the Linux autotools.
Start with downloading the template and extract the template
Modifications in the src directory in the scr directory delete the source files main.*, interface.* and render.*
Copy your own source files to the directory scr
Update the source files in the file makefile.am with your on filenames
To enable the help function for your plug-in make sure that in the query procedure you add the following lines.
help_path = g_build_filename (DATADIR, "help", NULL);
help_uri = g_filename_to_uri (help_path, NULL, NULL);
g_free (help_path);
And make sure that the dialog from where you call the help function refers to the correct help function id. The default name in the template is "plug-in-template", but you might consider changing it. Don't forget to make the same adjustment in the help folder of the template.
dialog = gimp_dialog_new ("Deblur Pan et al", "deblur", NULL, 0,gimp_standard_help_func, "plug-in-template", "Reset", 1, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
Modifications to autogen.sh I noticed that the version checking fails as at the time of writing of the template, the automake version was at 1.9 while my version was at 1.15. Therefore I've added the following on line 65.
For automake add your version:
elif (automake-1.15 --version) < /dev/null > /dev/null 2>&1; then
AUTOMAKE=automake-1.15
ACLOCAL=aclocal-1.15
Because the function check_version () is comparing strings instead of numbers, the check fails. By adding "| BC" the strings are converted to numbers. This will make the check pass.
change
if expr $1 \>= $2 | bc > /dev/null; then
The FILE variable is used for validating the directory of the src. Make sure it points to an existing directory
Modifications in configure.in change the language available for the plugin in the config.in file
make sure that the file AC_CONFIG_SRCDIR([src/main.c]) exists.
Because my plug-in also uses C++, I had to add the GCC compiler by adding an additional command 'AC_PROG_CXX'.
My plugin is using OpenCV. This is a C++ lib and therefore it is not possible to check whether it is installed in the regular way. I've used the following code to check whether the lib is installed on the computer and to add it to the linker libs.
AC_LANG(C++)
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -lopencv_core"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <opencv2/core/core.hpp>],
[cv::Mat dummy])],
[GIMP_LIBS="$GIMP_LIBS -lopencv_core -lopencv_imgproc"] [HAVE_OPENCV_CORE=1],
[AC_MSG_WARN([OPENCV CORE is not installed.])])
LDFLAGS=$SAVED_LDFLAGS
My plugin also uses log4c. I've used the following code to check if log4c is installed and to add it to the linker libs.
AC_CHECK_LIB([log4c], [log4c_init],
[HAVE_LOG4C=1] [GIMP_LIBS="$GIMP_LIBS -llog4c"],
AC_MSG_WARN([log4c is not installed.]))
Potfile.in Change in potfiles.in the file names which need internationalization.