It is currently Mon Jul 22, 2024 2:19 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: How to use the Gimp plugin template for c plug-ins
PostPosted: Thu Jun 09, 2016 9:16 am  (#1) 
Offline
New Member

Joined: Jun 09, 2016
Posts: 1
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.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GIMP Python-Fu Plug-in template

4

No new posts Attachment(s) Map Transform - using Template

10

No new posts Attachment(s) Unable to create a new template

4

No new posts Creating a Rubik's Mosaic Template

4

No new posts Attachment(s) Don't work procedures plug-in-bump-map, plug-in-displace

2



* Login  



Powered by phpBB3 © phpBB Group