summaryrefslogtreecommitdiffstats
path: root/plug-ins/pygimp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:13:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:13:10 +0000
commit3c57dd931145d43f2b0aef96c4d178135956bf91 (patch)
tree3de698981e9f0cc2c4f9569b19a5f3595e741f6b /plug-ins/pygimp
parentInitial commit. (diff)
downloadgimp-3c57dd931145d43f2b0aef96c4d178135956bf91.tar.xz
gimp-3c57dd931145d43f2b0aef96c4d178135956bf91.zip
Adding upstream version 2.10.36.upstream/2.10.36
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plug-ins/pygimp')
-rw-r--r--plug-ins/pygimp/Makefile.am188
-rw-r--r--plug-ins/pygimp/Makefile.in1431
-rw-r--r--plug-ins/pygimp/gimp-types.defs9
-rw-r--r--plug-ins/pygimp/gimpcolor-types.defs25
-rw-r--r--plug-ins/pygimp/gimpcolormodule.c433
-rw-r--r--plug-ins/pygimp/gimpenums-types.defs338
-rw-r--r--plug-ins/pygimp/gimpenums.py50
-rw-r--r--plug-ins/pygimp/gimpenumsmodule.c174
-rw-r--r--plug-ins/pygimp/gimpfu.py876
-rw-r--r--plug-ins/pygimp/gimpmodule.c2071
-rw-r--r--plug-ins/pygimp/gimpplugin.py81
-rw-r--r--plug-ins/pygimp/gimpshelf.py92
-rw-r--r--plug-ins/pygimp/gimpthumb.c694
-rw-r--r--plug-ins/pygimp/gimpthumb.defs312
-rw-r--r--plug-ins/pygimp/gimpthumb.override102
-rw-r--r--plug-ins/pygimp/gimpthumbmodule.c60
-rw-r--r--plug-ins/pygimp/gimpui.c9387
-rw-r--r--plug-ins/pygimp/gimpui.defs3411
-rw-r--r--plug-ins/pygimp/gimpui.override2075
-rw-r--r--plug-ins/pygimp/gimpui.py227
-rw-r--r--plug-ins/pygimp/gimpuimodule.c97
-rw-r--r--plug-ins/pygimp/plug-ins/Makefile.am64
-rw-r--r--plug-ins/pygimp/plug-ins/Makefile.in946
-rwxr-xr-xplug-ins/pygimp/plug-ins/benchmark-foreground-extract.py197
-rwxr-xr-xplug-ins/pygimp/plug-ins/clothify.py76
-rwxr-xr-xplug-ins/pygimp/plug-ins/colorxhtml.py212
-rwxr-xr-xplug-ins/pygimp/plug-ins/file-openraster.py404
-rwxr-xr-xplug-ins/pygimp/plug-ins/foggify.py77
-rwxr-xr-xplug-ins/pygimp/plug-ins/gradients-save-as-css.py104
-rwxr-xr-xplug-ins/pygimp/plug-ins/histogram-export.py114
-rw-r--r--plug-ins/pygimp/plug-ins/palette-offset.py61
-rw-r--r--plug-ins/pygimp/plug-ins/palette-sort.py357
-rw-r--r--plug-ins/pygimp/plug-ins/palette-to-gradient.py88
-rwxr-xr-xplug-ins/pygimp/plug-ins/py-slice.py457
-rw-r--r--plug-ins/pygimp/plug-ins/pyconsole.py749
-rwxr-xr-xplug-ins/pygimp/plug-ins/python-console.py245
-rwxr-xr-xplug-ins/pygimp/plug-ins/python-eval.py42
-rwxr-xr-xplug-ins/pygimp/plug-ins/shadow_bevel.py82
-rwxr-xr-xplug-ins/pygimp/plug-ins/sphere.py111
-rw-r--r--plug-ins/pygimp/plug-ins/spyro_plus.py2212
-rwxr-xr-xplug-ins/pygimp/plug-ins/whirlpinch.py227
-rwxr-xr-xplug-ins/pygimp/py-compile72
-rw-r--r--plug-ins/pygimp/pygimp-api.h122
-rw-r--r--plug-ins/pygimp/pygimp-colors.c2407
-rw-r--r--plug-ins/pygimp/pygimp-display.c140
-rw-r--r--plug-ins/pygimp/pygimp-drawable.c2459
-rw-r--r--plug-ins/pygimp/pygimp-image.c1564
-rw-r--r--plug-ins/pygimp/pygimp-intl.h48
-rw-r--r--plug-ins/pygimp/pygimp-item.c181
-rw-r--r--plug-ins/pygimp/pygimp-logo.pngbin0 -> 19823 bytes
-rw-r--r--plug-ins/pygimp/pygimp-parasite.c216
-rw-r--r--plug-ins/pygimp/pygimp-pdb.c1110
-rw-r--r--plug-ins/pygimp/pygimp-tile.c1046
-rw-r--r--plug-ins/pygimp/pygimp-util.h53
-rw-r--r--plug-ins/pygimp/pygimp-vectors.c992
-rw-r--r--plug-ins/pygimp/pygimp.h139
-rw-r--r--plug-ins/pygimp/pygimpcolor-api.h84
-rw-r--r--plug-ins/pygimp/pygimpcolor.h50
58 files changed, 39641 insertions, 0 deletions
diff --git a/plug-ins/pygimp/Makefile.am b/plug-ins/pygimp/Makefile.am
new file mode 100644
index 0000000..801b78a
--- /dev/null
+++ b/plug-ins/pygimp/Makefile.am
@@ -0,0 +1,188 @@
+## Process this file with automake to produce Makefile.in
+
+libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
+libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
+libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
+libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
+libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
+libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
+libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
+libgimpthumb = $(top_builddir)/libgimpthumb/libgimpthumb-$(GIMP_API_VERSION).la
+
+SUBDIRS = plug-ins
+
+if PLATFORM_WIN32
+no_undefined = -no-undefined
+shrext = -shrext .pyd
+path_separator = ;
+else
+path_separator = :
+endif
+
+AM_CFLAGS = $(PYGIMP_EXTRA_CFLAGS)
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ $(PYTHON_INCLUDES) \
+ $(PYGTK_CFLAGS) \
+ $(PYCAIRO_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GEGL_CFLAGS)
+
+pygimpbase = python
+
+pygimpdir = $(gimpplugindir)/$(pygimpbase)
+
+pygimp_LTLIBRARIES = gimp.la _gimpenums.la gimpcolor.la _gimpui.la \
+ gimpthumb.la
+
+gimp_la_SOURCES = \
+ gimpmodule.c \
+ pygimp-item.c \
+ pygimp-display.c \
+ pygimp-drawable.c \
+ pygimp-image.c \
+ pygimp-parasite.c \
+ pygimp-pdb.c \
+ pygimp-tile.c \
+ pygimp-vectors.c \
+ pygimp.h \
+ pygimp-api.h \
+ pygimp-intl.h \
+ pygimp-util.h
+
+gimp_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimp
+
+gimp_la_LIBADD = \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(libgimpui) \
+ $(GLIB_LIBS) \
+ $(GEGL_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS)
+
+_gimpenums_la_SOURCES = \
+ gimpenumsmodule.c
+
+_gimpenums_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex init_gimpenums
+
+_gimpenums_la_LIBADD = \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(GLIB_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS)
+
+gimpcolor_la_SOURCES = \
+ gimpcolormodule.c \
+ pygimp-colors.c \
+ pygimpcolor.h \
+ pygimpcolor-api.h
+
+gimpcolor_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimpcolor
+
+gimpcolor_la_LIBADD = \
+ $(libgimpcolor) \
+ $(GLIB_LIBS) \
+ $(PYLINK_LIBS)
+
+_gimpui_la_SOURCES = \
+ gimpuimodule.c \
+ gimpui.c
+
+_gimpui_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex init_gimpui
+
+_gimpui_la_LIBADD = \
+ $(libgimpui) \
+ $(libgimpwidgets) \
+ $(libgimpconfig) \
+ $(libgimpmath) \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(GTK_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS) \
+ $(INTLLIBS)
+
+gimpthumb_la_SOURCES = \
+ gimpthumbmodule.c \
+ gimpthumb.c
+
+gimpthumb_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimpthumb
+
+gimpthumb_la_LIBADD = \
+ $(libgimpthumb) \
+ $(GDK_PIXBUF_LIBS) \
+ $(PYLINK_LIBS)
+
+pygimp_PYTHON = \
+ gimpenums.py \
+ gimpfu.py \
+ gimpplugin.py \
+ gimpshelf.py \
+ gimpui.py
+
+pygimp_DATA = pygimp-logo.png
+
+codegen_files = \
+ gimp-types.defs \
+ gimpcolor-types.defs \
+ gimpenums-types.defs \
+ gimpthumb.defs \
+ gimpthumb.override \
+ gimpui.defs \
+ gimpui.override
+
+pyenvdir = $(gimpplugindir)/environ
+pyinterpdir = $(gimpplugindir)/interpreters
+
+pyenvfile = $(pyenvdir)/pygimp.env
+pyinterpfile = $(pyinterpdir)/pygimp.interp
+
+install-env-file:
+ $(mkinstalldirs) '$(DESTDIR)$(pyenvdir)'
+ echo '$(path_separator) PYTHONPATH=$${gimp_plug_in_dir}/$(pygimpbase)' > '$(DESTDIR)$(pyenvfile)'
+
+install-interp-file:
+ $(mkinstalldirs) '$(DESTDIR)$(pyinterpdir)'
+ echo 'python=$(PYBIN_PATH)' > '$(DESTDIR)$(pyinterpfile)'
+ echo 'python2=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)'
+ echo '/usr/bin/python=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)'
+ echo ":Python:E::py::`basename $(PYTHON)`:" >> '$(DESTDIR)$(pyinterpfile)'
+
+install-data-local: install-env-file install-interp-file
+
+uninstall-local:
+ rm -f '$(DESTDIR)$(pyenvfile)' '$(DESTDIR)$(pyinterpfile)'
+
+EXTRA_DIST = \
+ $(pygimp_DATA) \
+ $(codegen_files)
+
+gimpui.c: gimpui.defs gimpui.override gimp-types.defs gimpcolor-types.defs gimpenums-types.defs
+
+gimpthumb.c: gimpthumb.defs gimpthumb.override
+
+CLEANFILES = gimpui.c gimpthumb.c
+
+.defs.c:
+ (cd $(srcdir) \
+ && $(PYGTK_CODEGEN) \
+ --override $*.override \
+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --register gimp-types.defs \
+ --register gimpcolor-types.defs \
+ --register gimpenums-types.defs \
+ --prefix $* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
diff --git a/plug-ins/pygimp/Makefile.in b/plug-ins/pygimp/Makefile.in
new file mode 100644
index 0000000..7055e26
--- /dev/null
+++ b/plug-ins/pygimp/Makefile.in
@@ -0,0 +1,1431 @@
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = plug-ins/pygimp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/m4macros/alsa.m4 \
+ $(top_srcdir)/m4macros/ax_compare_version.m4 \
+ $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \
+ $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \
+ $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \
+ $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \
+ $(top_srcdir)/m4macros/detectcflags.m4 \
+ $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(pygimp_PYTHON) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(pygimpdir)" "$(DESTDIR)$(pygimpdir)" \
+ "$(DESTDIR)$(pygimpdir)"
+LTLIBRARIES = $(pygimp_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+_gimpenums_la_DEPENDENCIES = $(libgimp) $(libgimpcolor) $(libgimpbase) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am__gimpenums_la_OBJECTS = gimpenumsmodule.lo
+_gimpenums_la_OBJECTS = $(am__gimpenums_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+_gimpenums_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(_gimpenums_la_LDFLAGS) $(LDFLAGS) -o $@
+_gimpui_la_DEPENDENCIES = $(libgimpui) $(libgimpwidgets) \
+ $(libgimpconfig) $(libgimpmath) $(libgimp) $(libgimpcolor) \
+ $(libgimpbase) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__gimpui_la_OBJECTS = gimpuimodule.lo gimpui.lo
+_gimpui_la_OBJECTS = $(am__gimpui_la_OBJECTS)
+_gimpui_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(_gimpui_la_LDFLAGS) $(LDFLAGS) -o $@
+gimp_la_DEPENDENCIES = $(libgimp) $(libgimpcolor) $(libgimpbase) \
+ $(libgimpui) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_gimp_la_OBJECTS = gimpmodule.lo pygimp-item.lo pygimp-display.lo \
+ pygimp-drawable.lo pygimp-image.lo pygimp-parasite.lo \
+ pygimp-pdb.lo pygimp-tile.lo pygimp-vectors.lo
+gimp_la_OBJECTS = $(am_gimp_la_OBJECTS)
+gimp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(gimp_la_LDFLAGS) $(LDFLAGS) -o $@
+gimpcolor_la_DEPENDENCIES = $(libgimpcolor) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_gimpcolor_la_OBJECTS = gimpcolormodule.lo pygimp-colors.lo
+gimpcolor_la_OBJECTS = $(am_gimpcolor_la_OBJECTS)
+gimpcolor_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(gimpcolor_la_LDFLAGS) $(LDFLAGS) -o $@
+gimpthumb_la_DEPENDENCIES = $(libgimpthumb) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_gimpthumb_la_OBJECTS = gimpthumbmodule.lo gimpthumb.lo
+gimpthumb_la_OBJECTS = $(am_gimpthumb_la_OBJECTS)
+gimpthumb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(gimpthumb_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/gimpcolormodule.Plo \
+ ./$(DEPDIR)/gimpenumsmodule.Plo ./$(DEPDIR)/gimpmodule.Plo \
+ ./$(DEPDIR)/gimpthumb.Plo ./$(DEPDIR)/gimpthumbmodule.Plo \
+ ./$(DEPDIR)/gimpui.Plo ./$(DEPDIR)/gimpuimodule.Plo \
+ ./$(DEPDIR)/pygimp-colors.Plo ./$(DEPDIR)/pygimp-display.Plo \
+ ./$(DEPDIR)/pygimp-drawable.Plo ./$(DEPDIR)/pygimp-image.Plo \
+ ./$(DEPDIR)/pygimp-item.Plo ./$(DEPDIR)/pygimp-parasite.Plo \
+ ./$(DEPDIR)/pygimp-pdb.Plo ./$(DEPDIR)/pygimp-tile.Plo \
+ ./$(DEPDIR)/pygimp-vectors.Plo
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(_gimpenums_la_SOURCES) $(_gimpui_la_SOURCES) \
+ $(gimp_la_SOURCES) $(gimpcolor_la_SOURCES) \
+ $(gimpthumb_la_SOURCES)
+DIST_SOURCES = $(_gimpenums_la_SOURCES) $(_gimpui_la_SOURCES) \
+ $(gimp_la_SOURCES) $(gimpcolor_la_SOURCES) \
+ $(gimpthumb_la_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
+am__pep3147_tweak = \
+ sed -e 's|\.py$$||' -e 's|[^/]*$$|__pycache__/&.*.pyc __pycache__/&.*.pyo|'
+py_compile = $(top_srcdir)/py-compile
+DATA = $(pygimp_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ distdir distdir-am
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
+ $(top_srcdir)/py-compile py-compile
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+AA_LIBS = @AA_LIBS@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALL_LINGUAS = @ALL_LINGUAS@
+ALSA_CFLAGS = @ALSA_CFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPSTREAM_UTIL = @APPSTREAM_UTIL@
+AR = @AR@
+AS = @AS@
+ATK_CFLAGS = @ATK_CFLAGS@
+ATK_LIBS = @ATK_LIBS@
+ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BABL_CFLAGS = @BABL_CFLAGS@
+BABL_LIBS = @BABL_LIBS@
+BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@
+BUG_REPORT_URL = @BUG_REPORT_URL@
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_OBJEXT = @BUILD_OBJEXT@
+BZIP2_LIBS = @BZIP2_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@
+CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@
+CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@
+CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CC_VERSION = @CC_VERSION@
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+CPP_FOR_BUILD = @CPP_FOR_BUILD@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DESKTOP_DATADIR = @DESKTOP_DATADIR@
+DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@
+DLLTOOL = @DLLTOOL@
+DOC_SHOOTER = @DOC_SHOOTER@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FILE_AA = @FILE_AA@
+FILE_EXR = @FILE_EXR@
+FILE_HEIF = @FILE_HEIF@
+FILE_JP2_LOAD = @FILE_JP2_LOAD@
+FILE_JPEGXL = @FILE_JPEGXL@
+FILE_MNG = @FILE_MNG@
+FILE_PDF_SAVE = @FILE_PDF_SAVE@
+FILE_PS = @FILE_PS@
+FILE_WMF = @FILE_WMF@
+FILE_XMC = @FILE_XMC@
+FILE_XPM = @FILE_XPM@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@
+FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDBUS_CODEGEN = @GDBUS_CODEGEN@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@
+GEGL = @GEGL@
+GEGL_CFLAGS = @GEGL_CFLAGS@
+GEGL_LIBS = @GEGL_LIBS@
+GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@
+GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GEXIV2_CFLAGS = @GEXIV2_CFLAGS@
+GEXIV2_LIBS = @GEXIV2_LIBS@
+GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@
+GIMP_API_VERSION = @GIMP_API_VERSION@
+GIMP_APP_VERSION = @GIMP_APP_VERSION@
+GIMP_BINARY_AGE = @GIMP_BINARY_AGE@
+GIMP_COMMAND = @GIMP_COMMAND@
+GIMP_DATA_VERSION = @GIMP_DATA_VERSION@
+GIMP_FULL_NAME = @GIMP_FULL_NAME@
+GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@
+GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@
+GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@
+GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@
+GIMP_MKENUMS = @GIMP_MKENUMS@
+GIMP_MODULES = @GIMP_MODULES@
+GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@
+GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@
+GIMP_PLUGINS = @GIMP_PLUGINS@
+GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@
+GIMP_REAL_VERSION = @GIMP_REAL_VERSION@
+GIMP_RELEASE = @GIMP_RELEASE@
+GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@
+GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@
+GIMP_UNSTABLE = @GIMP_UNSTABLE@
+GIMP_USER_VERSION = @GIMP_USER_VERSION@
+GIMP_VERSION = @GIMP_VERSION@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@
+GIO_UNIX_LIBS = @GIO_UNIX_LIBS@
+GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@
+GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@
+GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@
+GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GOBJECT_QUERY = @GOBJECT_QUERY@
+GREP = @GREP@
+GS_LIBS = @GS_LIBS@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@
+GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@
+GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@
+GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@
+HARFBUZZ_LIBS = @HARFBUZZ_LIBS@
+HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@
+HAVE_CXX14 = @HAVE_CXX14@
+HAVE_FINITE = @HAVE_FINITE@
+HAVE_ISFINITE = @HAVE_ISFINITE@
+HAVE_VFORK = @HAVE_VFORK@
+HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
+INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
+INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
+INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@
+ISO_CODES_LOCATION = @ISO_CODES_LOCATION@
+JPEG_LIBS = @JPEG_LIBS@
+JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@
+JSON_GLIB_LIBS = @JSON_GLIB_LIBS@
+JXL_CFLAGS = @JXL_CFLAGS@
+JXL_LIBS = @JXL_LIBS@
+JXL_THREADS_CFLAGS = @JXL_THREADS_CFLAGS@
+JXL_THREADS_LIBS = @JXL_THREADS_LIBS@
+LCMS_CFLAGS = @LCMS_CFLAGS@
+LCMS_LIBS = @LCMS_LIBS@
+LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
+LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@
+LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@
+LIBHEIF_LIBS = @LIBHEIF_LIBS@
+LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@
+LIBJXL_REQUIRED_VERSION = @LIBJXL_REQUIRED_VERSION@
+LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@
+LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@
+LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@
+LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@
+LIBOBJS = @LIBOBJS@
+LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@
+LIBUNWIND_LIBS = @LIBUNWIND_LIBS@
+LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+LT_VERSION_INFO = @LT_VERSION_INFO@
+LZMA_CFLAGS = @LZMA_CFLAGS@
+LZMA_LIBS = @LZMA_LIBS@
+MAIL = @MAIL@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@
+MIME_INFO_LIBS = @MIME_INFO_LIBS@
+MIME_TYPES = @MIME_TYPES@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@
+MNG_CFLAGS = @MNG_CFLAGS@
+MNG_LIBS = @MNG_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@
+MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@
+NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@
+NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENEXR_CFLAGS = @OPENEXR_CFLAGS@
+OPENEXR_LIBS = @OPENEXR_LIBS@
+OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@
+OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@
+OPENJPEG_LIBS = @OPENJPEG_LIBS@
+OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@
+PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@
+PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@
+PATHSEP = @PATHSEP@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@
+PERL_VERSION = @PERL_VERSION@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PNG_CFLAGS = @PNG_CFLAGS@
+PNG_LIBS = @PNG_LIBS@
+POFILES = @POFILES@
+POPPLER_CFLAGS = @POPPLER_CFLAGS@
+POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@
+POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@
+POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@
+POPPLER_LIBS = @POPPLER_LIBS@
+POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PYBIN_PATH = @PYBIN_PATH@
+PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@
+PYCAIRO_LIBS = @PYCAIRO_LIBS@
+PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@
+PYGTK_CFLAGS = @PYGTK_CFLAGS@
+PYGTK_CODEGEN = @PYGTK_CODEGEN@
+PYGTK_DEFSDIR = @PYGTK_DEFSDIR@
+PYGTK_LIBS = @PYGTK_LIBS@
+PYLINK_LIBS = @PYLINK_LIBS@
+PYTHON = @PYTHON@
+PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@
+RT_LIBS = @RT_LIBS@
+SCREENSHOT_LIBS = @SCREENSHOT_LIBS@
+SED = @SED@
+SENDMAIL = @SENDMAIL@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOCKET_LIBS = @SOCKET_LIBS@
+SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
+SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
+STRIP = @STRIP@
+SVG_CFLAGS = @SVG_CFLAGS@
+SVG_LIBS = @SVG_LIBS@
+SYMPREFIX = @SYMPREFIX@
+TIFF_LIBS = @TIFF_LIBS@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WEBKIT_CFLAGS = @WEBKIT_CFLAGS@
+WEBKIT_LIBS = @WEBKIT_LIBS@
+WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@
+WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@
+WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@
+WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@
+WEBPMUX_LIBS = @WEBPMUX_LIBS@
+WEBP_CFLAGS = @WEBP_CFLAGS@
+WEBP_LIBS = @WEBP_LIBS@
+WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@
+WEB_PAGE = @WEB_PAGE@
+WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@
+WINDRES = @WINDRES@
+WMF_CFLAGS = @WMF_CFLAGS@
+WMF_CONFIG = @WMF_CONFIG@
+WMF_LIBS = @WMF_LIBS@
+WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@
+XDG_EMAIL = @XDG_EMAIL@
+XFIXES_CFLAGS = @XFIXES_CFLAGS@
+XFIXES_LIBS = @XFIXES_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@
+XMC_CFLAGS = @XMC_CFLAGS@
+XMC_LIBS = @XMC_LIBS@
+XMKMF = @XMKMF@
+XMLLINT = @XMLLINT@
+XMU_LIBS = @XMU_LIBS@
+XPM_LIBS = @XPM_LIBS@
+XSLTPROC = @XSLTPROC@
+XVFB_RUN = @XVFB_RUN@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+Z_LIBS = @Z_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gimpdatadir = @gimpdatadir@
+gimpdir = @gimpdir@
+gimplocaledir = @gimplocaledir@
+gimpplugindir = @gimpplugindir@
+gimpsysconfdir = @gimpsysconfdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+intltool__v_merge_options_ = @intltool__v_merge_options_@
+intltool__v_merge_options_0 = @intltool__v_merge_options_0@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+manpage_gimpdir = @manpage_gimpdir@
+mkdir_p = @mkdir_p@
+ms_librarian = @ms_librarian@
+mypaint_brushes_dir = @mypaint_brushes_dir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
+libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
+libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
+libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
+libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
+libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
+libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
+libgimpthumb = $(top_builddir)/libgimpthumb/libgimpthumb-$(GIMP_API_VERSION).la
+SUBDIRS = plug-ins
+@PLATFORM_WIN32_TRUE@no_undefined = -no-undefined
+@PLATFORM_WIN32_TRUE@shrext = -shrext .pyd
+@PLATFORM_WIN32_FALSE@path_separator = :
+@PLATFORM_WIN32_TRUE@path_separator = ;
+AM_CFLAGS = $(PYGIMP_EXTRA_CFLAGS)
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ $(PYTHON_INCLUDES) \
+ $(PYGTK_CFLAGS) \
+ $(PYCAIRO_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GEGL_CFLAGS)
+
+pygimpbase = python
+pygimpdir = $(gimpplugindir)/$(pygimpbase)
+pygimp_LTLIBRARIES = gimp.la _gimpenums.la gimpcolor.la _gimpui.la \
+ gimpthumb.la
+
+gimp_la_SOURCES = \
+ gimpmodule.c \
+ pygimp-item.c \
+ pygimp-display.c \
+ pygimp-drawable.c \
+ pygimp-image.c \
+ pygimp-parasite.c \
+ pygimp-pdb.c \
+ pygimp-tile.c \
+ pygimp-vectors.c \
+ pygimp.h \
+ pygimp-api.h \
+ pygimp-intl.h \
+ pygimp-util.h
+
+gimp_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimp
+
+gimp_la_LIBADD = \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(libgimpui) \
+ $(GLIB_LIBS) \
+ $(GEGL_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS)
+
+_gimpenums_la_SOURCES = \
+ gimpenumsmodule.c
+
+_gimpenums_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex init_gimpenums
+
+_gimpenums_la_LIBADD = \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(GLIB_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS)
+
+gimpcolor_la_SOURCES = \
+ gimpcolormodule.c \
+ pygimp-colors.c \
+ pygimpcolor.h \
+ pygimpcolor-api.h
+
+gimpcolor_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimpcolor
+
+gimpcolor_la_LIBADD = \
+ $(libgimpcolor) \
+ $(GLIB_LIBS) \
+ $(PYLINK_LIBS)
+
+_gimpui_la_SOURCES = \
+ gimpuimodule.c \
+ gimpui.c
+
+_gimpui_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex init_gimpui
+
+_gimpui_la_LIBADD = \
+ $(libgimpui) \
+ $(libgimpwidgets) \
+ $(libgimpconfig) \
+ $(libgimpmath) \
+ $(libgimp) \
+ $(libgimpcolor) \
+ $(libgimpbase) \
+ $(GTK_LIBS) \
+ $(PYLINK_LIBS) \
+ $(RT_LIBS) \
+ $(INTLLIBS)
+
+gimpthumb_la_SOURCES = \
+ gimpthumbmodule.c \
+ gimpthumb.c
+
+gimpthumb_la_LDFLAGS = -module -avoid-version $(no_undefined) $(shrext) \
+ -export-symbols-regex initgimpthumb
+
+gimpthumb_la_LIBADD = \
+ $(libgimpthumb) \
+ $(GDK_PIXBUF_LIBS) \
+ $(PYLINK_LIBS)
+
+pygimp_PYTHON = \
+ gimpenums.py \
+ gimpfu.py \
+ gimpplugin.py \
+ gimpshelf.py \
+ gimpui.py
+
+pygimp_DATA = pygimp-logo.png
+codegen_files = \
+ gimp-types.defs \
+ gimpcolor-types.defs \
+ gimpenums-types.defs \
+ gimpthumb.defs \
+ gimpthumb.override \
+ gimpui.defs \
+ gimpui.override
+
+pyenvdir = $(gimpplugindir)/environ
+pyinterpdir = $(gimpplugindir)/interpreters
+pyenvfile = $(pyenvdir)/pygimp.env
+pyinterpfile = $(pyinterpdir)/pygimp.interp
+EXTRA_DIST = \
+ $(pygimp_DATA) \
+ $(codegen_files)
+
+CLEANFILES = gimpui.c gimpthumb.c
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .defs .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/pygimp/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu plug-ins/pygimp/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+install-pygimpLTLIBRARIES: $(pygimp_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(pygimp_LTLIBRARIES)'; test -n "$(pygimpdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pygimpdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pygimpdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pygimpdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pygimpdir)"; \
+ }
+
+uninstall-pygimpLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pygimp_LTLIBRARIES)'; test -n "$(pygimpdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pygimpdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pygimpdir)/$$f"; \
+ done
+
+clean-pygimpLTLIBRARIES:
+ -test -z "$(pygimp_LTLIBRARIES)" || rm -f $(pygimp_LTLIBRARIES)
+ @list='$(pygimp_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+_gimpenums.la: $(_gimpenums_la_OBJECTS) $(_gimpenums_la_DEPENDENCIES) $(EXTRA__gimpenums_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(_gimpenums_la_LINK) -rpath $(pygimpdir) $(_gimpenums_la_OBJECTS) $(_gimpenums_la_LIBADD) $(LIBS)
+
+_gimpui.la: $(_gimpui_la_OBJECTS) $(_gimpui_la_DEPENDENCIES) $(EXTRA__gimpui_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(_gimpui_la_LINK) -rpath $(pygimpdir) $(_gimpui_la_OBJECTS) $(_gimpui_la_LIBADD) $(LIBS)
+
+gimp.la: $(gimp_la_OBJECTS) $(gimp_la_DEPENDENCIES) $(EXTRA_gimp_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(gimp_la_LINK) -rpath $(pygimpdir) $(gimp_la_OBJECTS) $(gimp_la_LIBADD) $(LIBS)
+
+gimpcolor.la: $(gimpcolor_la_OBJECTS) $(gimpcolor_la_DEPENDENCIES) $(EXTRA_gimpcolor_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(gimpcolor_la_LINK) -rpath $(pygimpdir) $(gimpcolor_la_OBJECTS) $(gimpcolor_la_LIBADD) $(LIBS)
+
+gimpthumb.la: $(gimpthumb_la_OBJECTS) $(gimpthumb_la_DEPENDENCIES) $(EXTRA_gimpthumb_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(gimpthumb_la_LINK) -rpath $(pygimpdir) $(gimpthumb_la_OBJECTS) $(gimpthumb_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcolormodule.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpenumsmodule.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpmodule.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpthumb.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpthumbmodule.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpui.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpuimodule.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-colors.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-display.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-drawable.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-image.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-item.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-parasite.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-pdb.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-tile.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pygimp-vectors.Plo@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pygimpPYTHON: $(pygimp_PYTHON)
+ @$(NORMAL_INSTALL)
+ @list='$(pygimp_PYTHON)'; dlist=; list2=; test -n "$(pygimpdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pygimpdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pygimpdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pygimpdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pygimpdir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ $(am__py_compile) --destdir "$(DESTDIR)" \
+ --basedir "$(pygimpdir)" $$dlist; \
+ else :; fi
+
+uninstall-pygimpPYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pygimp_PYTHON)'; test -n "$(pygimpdir)" || list=; \
+ py_files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$py_files" || exit 0; \
+ dir='$(DESTDIR)$(pygimpdir)'; \
+ pyc_files=`echo "$$py_files" | sed 's|$$|c|'`; \
+ pyo_files=`echo "$$py_files" | sed 's|$$|o|'`; \
+ st=0; \
+ for files in "$$py_files" "$$pyc_files" "$$pyo_files"; do \
+ $(am__uninstall_files_from_dir) || st=$$?; \
+ done; \
+ dir='$(DESTDIR)$(pygimpdir)'; \
+ echo "$$py_files" | $(am__pep3147_tweak) | $(am__base_list) | \
+ while read files; do \
+ $(am__uninstall_files_from_dir) || st=$$?; \
+ done || exit $$?; \
+ exit $$st
+install-pygimpDATA: $(pygimp_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(pygimp_DATA)'; test -n "$(pygimpdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pygimpdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pygimpdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pygimpdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pygimpdir)" || exit $$?; \
+ done
+
+uninstall-pygimpDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pygimp_DATA)'; test -n "$(pygimpdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pygimpdir)'; $(am__uninstall_files_from_dir)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(LTLIBRARIES) $(DATA)
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(pygimpdir)" "$(DESTDIR)$(pygimpdir)" "$(DESTDIR)$(pygimpdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool clean-pygimpLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f ./$(DEPDIR)/gimpcolormodule.Plo
+ -rm -f ./$(DEPDIR)/gimpenumsmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpthumb.Plo
+ -rm -f ./$(DEPDIR)/gimpthumbmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpui.Plo
+ -rm -f ./$(DEPDIR)/gimpuimodule.Plo
+ -rm -f ./$(DEPDIR)/pygimp-colors.Plo
+ -rm -f ./$(DEPDIR)/pygimp-display.Plo
+ -rm -f ./$(DEPDIR)/pygimp-drawable.Plo
+ -rm -f ./$(DEPDIR)/pygimp-image.Plo
+ -rm -f ./$(DEPDIR)/pygimp-item.Plo
+ -rm -f ./$(DEPDIR)/pygimp-parasite.Plo
+ -rm -f ./$(DEPDIR)/pygimp-pdb.Plo
+ -rm -f ./$(DEPDIR)/pygimp-tile.Plo
+ -rm -f ./$(DEPDIR)/pygimp-vectors.Plo
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-data-local install-pygimpDATA \
+ install-pygimpLTLIBRARIES install-pygimpPYTHON
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f ./$(DEPDIR)/gimpcolormodule.Plo
+ -rm -f ./$(DEPDIR)/gimpenumsmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpthumb.Plo
+ -rm -f ./$(DEPDIR)/gimpthumbmodule.Plo
+ -rm -f ./$(DEPDIR)/gimpui.Plo
+ -rm -f ./$(DEPDIR)/gimpuimodule.Plo
+ -rm -f ./$(DEPDIR)/pygimp-colors.Plo
+ -rm -f ./$(DEPDIR)/pygimp-display.Plo
+ -rm -f ./$(DEPDIR)/pygimp-drawable.Plo
+ -rm -f ./$(DEPDIR)/pygimp-image.Plo
+ -rm -f ./$(DEPDIR)/pygimp-item.Plo
+ -rm -f ./$(DEPDIR)/pygimp-parasite.Plo
+ -rm -f ./$(DEPDIR)/pygimp-pdb.Plo
+ -rm -f ./$(DEPDIR)/pygimp-tile.Plo
+ -rm -f ./$(DEPDIR)/pygimp-vectors.Plo
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-local uninstall-pygimpDATA \
+ uninstall-pygimpLTLIBRARIES uninstall-pygimpPYTHON
+
+.MAKE: $(am__recursive_targets) install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+ am--depfiles check check-am clean clean-generic clean-libtool \
+ clean-pygimpLTLIBRARIES cscopelist-am ctags ctags-am distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am \
+ install-data-local install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-pygimpDATA \
+ install-pygimpLTLIBRARIES install-pygimpPYTHON install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
+ uninstall-local uninstall-pygimpDATA \
+ uninstall-pygimpLTLIBRARIES uninstall-pygimpPYTHON
+
+.PRECIOUS: Makefile
+
+
+install-env-file:
+ $(mkinstalldirs) '$(DESTDIR)$(pyenvdir)'
+ echo '$(path_separator) PYTHONPATH=$${gimp_plug_in_dir}/$(pygimpbase)' > '$(DESTDIR)$(pyenvfile)'
+
+install-interp-file:
+ $(mkinstalldirs) '$(DESTDIR)$(pyinterpdir)'
+ echo 'python=$(PYBIN_PATH)' > '$(DESTDIR)$(pyinterpfile)'
+ echo 'python2=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)'
+ echo '/usr/bin/python=$(PYBIN_PATH)' >> '$(DESTDIR)$(pyinterpfile)'
+ echo ":Python:E::py::`basename $(PYTHON)`:" >> '$(DESTDIR)$(pyinterpfile)'
+
+install-data-local: install-env-file install-interp-file
+
+uninstall-local:
+ rm -f '$(DESTDIR)$(pyenvfile)' '$(DESTDIR)$(pyinterpfile)'
+
+gimpui.c: gimpui.defs gimpui.override gimp-types.defs gimpcolor-types.defs gimpenums-types.defs
+
+gimpthumb.c: gimpthumb.defs gimpthumb.override
+
+.defs.c:
+ (cd $(srcdir) \
+ && $(PYGTK_CODEGEN) \
+ --override $*.override \
+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --register gimp-types.defs \
+ --register gimpcolor-types.defs \
+ --register gimpenums-types.defs \
+ --prefix $* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/plug-ins/pygimp/gimp-types.defs b/plug-ins/pygimp/gimp-types.defs
new file mode 100644
index 0000000..0158ede
--- /dev/null
+++ b/plug-ins/pygimp/gimp-types.defs
@@ -0,0 +1,9 @@
+;; -*- scheme -*-
+
+;; from libgimpbase, implemented manually in pygimp-parasite.c
+
+(define-boxed GimpParasite
+ (in-module "Gimp")
+ (c-name "GimpParasite")
+ (gtype-id "GIMP_TYPE_PARASITE")
+)
diff --git a/plug-ins/pygimp/gimpcolor-types.defs b/plug-ins/pygimp/gimpcolor-types.defs
new file mode 100644
index 0000000..460ac92
--- /dev/null
+++ b/plug-ins/pygimp/gimpcolor-types.defs
@@ -0,0 +1,25 @@
+;; -*- scheme -*-
+
+(define-boxed GimpRGB
+ (in-module "Gimp")
+ (c-name "GimpRGB")
+ (gtype-id "GIMP_TYPE_RGB")
+)
+
+(define-boxed GimpHSV
+ (in-module "Gimp")
+ (c-name "GimpHSV")
+ (gtype-id "GIMP_TYPE_HSV")
+)
+
+(define-boxed GimpHSL
+ (in-module "Gimp")
+ (c-name "GimpHSL")
+ (gtype-id "GIMP_TYPE_HSL")
+)
+
+(define-boxed GimpCMYK
+ (in-module "Gimp")
+ (c-name "GimpCMYK")
+ (gtype-id "GIMP_TYPE_CMYK")
+)
diff --git a/plug-ins/pygimp/gimpcolormodule.c b/plug-ins/pygimp/gimpcolormodule.c
new file mode 100644
index 0000000..8b4a478
--- /dev/null
+++ b/plug-ins/pygimp/gimpcolormodule.c
@@ -0,0 +1,433 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005-2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pygimpcolor.h"
+
+#define _INSIDE_PYGIMPCOLOR_
+#include "pygimpcolor-api.h"
+
+#include "pygimp-util.h"
+
+
+static PyObject *
+pygimp_rgb_parse_name(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *name;
+ int len;
+ GimpRGB rgb;
+ gboolean success;
+ static char *kwlist[] = { "name", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:rgb_parse_name", kwlist,
+ &name, &len))
+ return NULL;
+
+ rgb.a = 1.0;
+ success = gimp_rgb_parse_name(&rgb, name, len);
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse color name");
+ return NULL;
+ }
+
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_rgb_parse_hex(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *hex;
+ int len;
+ GimpRGB rgb;
+ gboolean success;
+ static char *kwlist[] = { "hex", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:rgb_parse_hex", kwlist,
+ &hex, &len))
+ return NULL;
+
+ rgb.a = 1.0;
+ success = gimp_rgb_parse_hex(&rgb, hex, len);
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse hex value");
+ return NULL;
+ }
+
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_rgb_parse_css(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *css;
+ int len;
+ GimpRGB rgb;
+ gboolean success, with_alpha = FALSE;
+ static char *kwlist[] = { "css", "with_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "s#|i:rgb_parse_css", kwlist,
+ &css, &len, &with_alpha))
+ return NULL;
+
+ if (with_alpha)
+ success = gimp_rgba_parse_css(&rgb, css, len);
+ else {
+ rgb.a = 1.0;
+ success = gimp_rgb_parse_css(&rgb, css, len);
+ }
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse CSS color");
+ return NULL;
+ }
+
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_rgb_list_names(PyObject *self)
+{
+ int num_names, i;
+ const char **names;
+ GimpRGB *colors;
+ PyObject *dict, *color;
+
+ num_names = gimp_rgb_list_names(&names, &colors);
+
+ dict = PyDict_New();
+ if (!dict)
+ goto cleanup;
+
+ for (i = 0; i < num_names; i++) {
+ color = pygimp_rgb_new(&colors[i]);
+
+ if (!color)
+ goto bail;
+
+ if (PyDict_SetItemString(dict, names[i], color) < 0) {
+ Py_DECREF(color);
+ goto bail;
+ }
+
+ Py_DECREF(color);
+ }
+
+ goto cleanup;
+
+bail:
+ Py_DECREF(dict);
+ dict = NULL;
+
+cleanup:
+ g_free(names);
+ g_free(colors);
+
+ return dict;
+}
+
+static PyObject *
+pygimp_bilinear(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ gdouble x, y;
+ gdouble values[4];
+ PyObject *py_values;
+ static char *kwlist[] = { "x", "y", "values", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddO:bilinear", kwlist,
+ &x, &y, &py_values))
+ return NULL;
+
+ if (PyString_Check(py_values)) {
+ if (PyString_Size(py_values) == 4) {
+ guchar ret;
+ ret = gimp_bilinear_8(x, y, (guchar *)PyString_AsString(py_values));
+ return PyString_FromStringAndSize((char *)&ret, 1);
+ }
+ } else if (PySequence_Check(py_values)) {
+ if (PySequence_Size(py_values) == 4) {
+ int i;
+ for (i = 0; i < 4; i++) {
+ PyObject *v;
+ v = PySequence_GetItem(py_values, i);
+ values[i] = PyFloat_AsDouble(v);
+ Py_DECREF(v);
+ }
+ return PyFloat_FromDouble(gimp_bilinear(x, y, values));
+ }
+ }
+
+ PyErr_SetString(PyExc_TypeError, "values is not a sequence of 4 items");
+ return NULL;
+}
+
+static PyObject *
+pygimp_bilinear_color(PyObject *self, PyObject *args, PyObject *kwargs, gboolean with_alpha)
+{
+ gdouble x, y;
+ GimpRGB values[4];
+ GimpRGB rgb;
+ PyObject *py_values, *v;
+ int i, success;
+ static char *kwlist[] = { "x", "y", "values", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ with_alpha ? "ddO:bilinear_rgba"
+ : "ddO:bilinear_rgb",
+ kwlist,
+ &x, &y, &py_values))
+ return NULL;
+
+ if (!PySequence_Check(py_values) || PySequence_Size(py_values) != 4) {
+ PyErr_SetString(PyExc_TypeError, "values is not a sequence of 4 items");
+ return NULL;
+ }
+
+ for (i = 0; i < 4; i++) {
+ v = PySequence_GetItem(py_values, i);
+ success = pygimp_rgb_from_pyobject(v, &values[i]);
+ Py_DECREF(v);
+ if (!success) {
+ PyErr_Format(PyExc_TypeError, "values[%d] is not a GimpRGB", i);
+ return NULL;
+ }
+ }
+
+ if (with_alpha)
+ rgb = gimp_bilinear_rgba(x, y, values);
+ else
+ rgb = gimp_bilinear_rgb(x, y, values);
+
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_bilinear_rgb(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ return pygimp_bilinear_color(self, args, kwargs, FALSE);
+}
+
+static PyObject *
+pygimp_bilinear_rgba(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ return pygimp_bilinear_color(self, args, kwargs, TRUE);
+}
+
+#if 0
+static PyObject *
+pygimp_bilinear_pixels_8(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+typedef struct
+{
+ PyObject *func;
+ PyObject *data;
+} ProxyData;
+
+static void
+proxy_render(gdouble x, gdouble y, GimpRGB *color, gpointer pdata)
+{
+ ProxyData *data = pdata;
+
+ if (data->data)
+ PyObject_CallFunction(data->func, "ddO&O", x, y, pygimp_rgb_new, color,
+ data->data);
+ else
+ PyObject_CallFunction(data->func, "ddO&", x, y, pygimp_rgb_new, color);
+}
+
+static void
+proxy_put_pixel(gint x, gint y, GimpRGB *color, gpointer pdata)
+{
+ ProxyData *data = pdata;
+
+ if (data->data)
+ PyObject_CallFunction(data->func, "iiO&O", x, y, pygimp_rgb_new, color,
+ data->data);
+ else
+ PyObject_CallFunction(data->func, "iiO&", x, y, pygimp_rgb_new, color);
+}
+
+static void
+proxy_progress(gint min, gint max, gint current, gpointer pdata)
+{
+ ProxyData *data = pdata;
+
+ if (data->data)
+ PyObject_CallFunction(data->func, "iiiO", min, max, current,
+ data->data);
+ else
+ PyObject_CallFunction(data->func, "iii", min, max, current);
+}
+
+static PyObject *
+pygimp_adaptive_supersample_area(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ gulong r;
+
+ gint x1, y1, x2, y2, max_depth;
+ gdouble threshold;
+ PyObject *py_func_render = NULL, *py_data_render = NULL;
+ PyObject *py_func_put_pixel = NULL, *py_data_put_pixel = NULL;
+ PyObject *py_func_progress = NULL, *py_data_progress = NULL;
+
+ GimpRenderFunc proxy_func_render = NULL;
+ GimpPutPixelFunc proxy_func_put_pixel = NULL;
+ GimpProgressFunc proxy_func_progress = NULL;
+
+ ProxyData proxy_data_render, proxy_data_put_pixel, proxy_data_progress;
+
+ static char *kwlist[] = {
+ "x1", "y1", "x2", "y2", "max_depth", "threshold",
+ "render_func", "render_data",
+ "put_pixel_func", "put_pixel_data",
+ "progress_func", "progress_data",
+ NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "iiiiid|OOOOOO"
+ ":adaptive_supersample_area",
+ kwlist,
+ &x1, &y1, &x2, &y2, &max_depth, &threshold,
+ &py_func_render, &py_data_render,
+ &py_func_put_pixel, &py_data_put_pixel,
+ &py_func_progress, &py_data_progress))
+ return NULL;
+
+#define PROCESS_FUNC(n) G_STMT_START { \
+ if (py_func_##n != NULL) { \
+ if (!PyCallable_Check(py_func_##n)) { \
+ PyErr_SetString(PyExc_TypeError, #n "_func " \
+ "must be callable"); \
+ return NULL; \
+ } \
+ \
+ proxy_func_##n = proxy_##n; \
+ \
+ proxy_data_##n.func = py_func_##n; \
+ proxy_data_##n.data = py_data_##n; \
+ } \
+} G_STMT_END
+
+ PROCESS_FUNC(render);
+ PROCESS_FUNC(put_pixel);
+ PROCESS_FUNC(progress);
+
+#undef PROCESS_FUNC
+
+#define PASS_FUNC(n) proxy_func_##n, &proxy_data_##n
+
+ r = gimp_adaptive_supersample_area (x1, y1, x2, y2, max_depth, threshold,
+ PASS_FUNC(render),
+ PASS_FUNC(put_pixel),
+ PASS_FUNC(progress));
+
+#undef PASS_FUNC
+
+ return PyInt_FromLong(r);
+}
+#endif
+
+/* List of methods defined in the module */
+
+static struct PyMethodDef gimpcolor_methods[] = {
+ {"rgb_parse_name", (PyCFunction)pygimp_rgb_parse_name, METH_VARARGS | METH_KEYWORDS},
+ {"rgb_parse_hex", (PyCFunction)pygimp_rgb_parse_hex, METH_VARARGS | METH_KEYWORDS},
+ {"rgb_parse_css", (PyCFunction)pygimp_rgb_parse_css, METH_VARARGS | METH_KEYWORDS},
+ {"rgb_names", (PyCFunction)pygimp_rgb_list_names, METH_NOARGS},
+ {"bilinear", (PyCFunction)pygimp_bilinear, METH_VARARGS | METH_KEYWORDS},
+ {"bilinear_rgb", (PyCFunction)pygimp_bilinear_rgb, METH_VARARGS | METH_KEYWORDS},
+ {"bilinear_rgba", (PyCFunction)pygimp_bilinear_rgba, METH_VARARGS | METH_KEYWORDS},
+#if 0
+ {"bilinear_pixels_8", (PyCFunction)pygimp_bilinear_pixels_8, METH_VARARGS | METH_KEYWORDS},
+ {"adaptive_supersample_area", (PyCFunction)pygimp_adaptive_supersample_area, METH_VARARGS | METH_KEYWORDS},
+#endif
+ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
+};
+
+
+static struct _PyGimpColor_Functions pygimpcolor_api_functions = {
+ &PyGimpRGB_Type,
+ pygimp_rgb_new,
+ &PyGimpHSV_Type,
+ pygimp_hsv_new,
+ &PyGimpHSL_Type,
+ pygimp_hsl_new,
+ &PyGimpCMYK_Type,
+ pygimp_cmyk_new,
+ pygimp_rgb_from_pyobject
+};
+
+
+/* Initialization function for the module (*must* be called initgimpcolor) */
+
+static char gimpcolor_doc[] =
+"This module provides interfaces to allow you to write gimp plug-ins"
+;
+
+void initgimpcolor(void);
+
+PyMODINIT_FUNC
+initgimpcolor(void)
+{
+ PyObject *m, *d;
+
+ pygimp_init_pygobject();
+
+ /* Create the module and add the functions */
+ m = Py_InitModule3("gimpcolor", gimpcolor_methods, gimpcolor_doc);
+
+ d = PyModule_GetDict(m);
+
+ pyg_register_boxed(d, "RGB", GIMP_TYPE_RGB, &PyGimpRGB_Type);
+ pyg_register_boxed(d, "HSV", GIMP_TYPE_HSV, &PyGimpHSV_Type);
+ pyg_register_boxed(d, "HSL", GIMP_TYPE_HSL, &PyGimpHSL_Type);
+ pyg_register_boxed(d, "CMYK", GIMP_TYPE_CMYK, &PyGimpCMYK_Type);
+
+ PyModule_AddObject(m, "RGB_COMPOSITE_NONE",
+ PyInt_FromLong(GIMP_RGB_COMPOSITE_NONE));
+ PyModule_AddObject(m, "RGB_COMPOSITE_NORMAL",
+ PyInt_FromLong(GIMP_RGB_COMPOSITE_NORMAL));
+ PyModule_AddObject(m, "RGB_COMPOSITE_BEHIND",
+ PyInt_FromLong(GIMP_RGB_COMPOSITE_BEHIND));
+
+ PyModule_AddObject(m, "RGB_LUMINANCE_RED",
+ PyFloat_FromDouble(GIMP_RGB_LUMINANCE_RED));
+ PyModule_AddObject(m, "RGB_LUMINANCE_GREEN",
+ PyFloat_FromDouble(GIMP_RGB_LUMINANCE_GREEN));
+ PyModule_AddObject(m, "RGB_LUMINANCE_BLUE",
+ PyFloat_FromDouble(GIMP_RGB_LUMINANCE_BLUE));
+
+ /* for other modules */
+ PyModule_AddObject(m, "_PyGimpColor_API",
+ PyCObject_FromVoidPtr(&pygimpcolor_api_functions, NULL));
+
+ /* Check for errors */
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module gimpcolor");
+}
diff --git a/plug-ins/pygimp/gimpenums-types.defs b/plug-ins/pygimp/gimpenums-types.defs
new file mode 100644
index 0000000..b919c93
--- /dev/null
+++ b/plug-ins/pygimp/gimpenums-types.defs
@@ -0,0 +1,338 @@
+;; -*- scheme -*-
+; object definitions ...
+;; Enumerations and flags ...
+
+(define-enum BrushApplicationMode
+ (in-module "Gimp")
+ (c-name "GimpBrushApplicationMode")
+ (gtype-id "GIMP_TYPE_BRUSH_APPLICATION_MODE")
+ (values
+ '("hard" "GIMP_BRUSH_HARD")
+ '("soft" "GIMP_BRUSH_SOFT")
+ )
+)
+
+(define-enum BrushGeneratedShape
+ (in-module "Gimp")
+ (c-name "GimpBrushGeneratedShape")
+ (gtype-id "GIMP_TYPE_BRUSH_GENERATED_SHAPE")
+ (values
+ '("circle" "GIMP_BRUSH_GENERATED_CIRCLE")
+ '("square" "GIMP_BRUSH_GENERATED_SQUARE")
+ '("diamond" "GIMP_BRUSH_GENERATED_DIAMOND")
+ )
+)
+
+(define-enum ConvertDitherType
+ (in-module "Gimp")
+ (c-name "GimpConvertDitherType")
+ (gtype-id "GIMP_TYPE_CONVERT_DITHER_TYPE")
+ (values
+ '("no-dither" "GIMP_NO_DITHER")
+ '("fs-dither" "GIMP_FS_DITHER")
+ '("fslowbleed-dither" "GIMP_FSLOWBLEED_DITHER")
+ '("fixed-dither" "GIMP_FIXED_DITHER")
+ )
+)
+
+(define-enum ConvertPaletteType
+ (in-module "Gimp")
+ (c-name "GimpConvertPaletteType")
+ (gtype-id "GIMP_TYPE_CONVERT_PALETTE_TYPE")
+ (values
+ '("make-palette" "GIMP_MAKE_PALETTE")
+ '("reuse-palette" "GIMP_REUSE_PALETTE")
+ '("web-palette" "GIMP_WEB_PALETTE")
+ '("mono-palette" "GIMP_MONO_PALETTE")
+ '("custom-palette" "GIMP_CUSTOM_PALETTE")
+ )
+)
+
+(define-enum ConvolutionType
+ (in-module "Gimp")
+ (c-name "GimpConvolutionType")
+ (gtype-id "GIMP_TYPE_CONVOLUTION_TYPE")
+ (values
+ '("normal-convol" "GIMP_NORMAL_CONVOL")
+ '("absolute-convol" "GIMP_ABSOLUTE_CONVOL")
+ '("negative-convol" "GIMP_NEGATIVE_CONVOL")
+ )
+)
+
+(define-enum ConvolveType
+ (in-module "Gimp")
+ (c-name "GimpConvolveType")
+ (gtype-id "GIMP_TYPE_CONVOLVE_TYPE")
+ (values
+ '("blur-convolve" "GIMP_BLUR_CONVOLVE")
+ '("sharpen-convolve" "GIMP_SHARPEN_CONVOLVE")
+ )
+)
+
+(define-enum FillType
+ (in-module "Gimp")
+ (c-name "GimpFillType")
+ (gtype-id "GIMP_TYPE_FILL_TYPE")
+ (values
+ '("foreground-fill" "GIMP_FOREGROUND_FILL")
+ '("background-fill" "GIMP_BACKGROUND_FILL")
+ '("white-fill" "GIMP_WHITE_FILL")
+ '("transparent-fill" "GIMP_TRANSPARENT_FILL")
+ '("pattern-fill" "GIMP_PATTERN_FILL")
+ )
+)
+
+(define-enum GradientSegmentColor
+ (in-module "Gimp")
+ (c-name "GimpGradientSegmentColor")
+ (gtype-id "GIMP_TYPE_GRADIENT_SEGMENT_COLOR")
+ (values
+ '("rgb" "GIMP_GRADIENT_SEGMENT_RGB")
+ '("hsv-ccw" "GIMP_GRADIENT_SEGMENT_HSV_CCW")
+ '("hsv-cw" "GIMP_GRADIENT_SEGMENT_HSV_CW")
+ )
+)
+
+(define-enum GradientSegmentType
+ (in-module "Gimp")
+ (c-name "GimpGradientSegmentType")
+ (gtype-id "GIMP_TYPE_GRADIENT_SEGMENT_TYPE")
+ (values
+ '("linear" "GIMP_GRADIENT_SEGMENT_LINEAR")
+ '("curved" "GIMP_GRADIENT_SEGMENT_CURVED")
+ '("sine" "GIMP_GRADIENT_SEGMENT_SINE")
+ '("sphere-increasing" "GIMP_GRADIENT_SEGMENT_SPHERE_INCREASING")
+ '("sphere-decreasing" "GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING")
+ )
+)
+
+(define-enum HistogramChannel
+ (in-module "Gimp")
+ (c-name "GimpHistogramChannel")
+ (gtype-id "GIMP_TYPE_HISTOGRAM_CHANNEL")
+ (values
+ '("value" "GIMP_HISTOGRAM_VALUE")
+ '("red" "GIMP_HISTOGRAM_RED")
+ '("green" "GIMP_HISTOGRAM_GREEN")
+ '("blue" "GIMP_HISTOGRAM_BLUE")
+ '("alpha" "GIMP_HISTOGRAM_ALPHA")
+ )
+)
+
+(define-enum HueRange
+ (in-module "Gimp")
+ (c-name "GimpHueRange")
+ (gtype-id "GIMP_TYPE_HUE_RANGE")
+ (values
+ '("all-hues" "GIMP_ALL_HUES")
+ '("red-hues" "GIMP_RED_HUES")
+ '("yellow-hues" "GIMP_YELLOW_HUES")
+ '("green-hues" "GIMP_GREEN_HUES")
+ '("cyan-hues" "GIMP_CYAN_HUES")
+ '("blue-hues" "GIMP_BLUE_HUES")
+ '("magenta-hues" "GIMP_MAGENTA_HUES")
+ )
+)
+
+(define-enum ImageType
+ (in-module "Gimp")
+ (c-name "GimpImageType")
+ (gtype-id "GIMP_TYPE_IMAGE_TYPE")
+ (values
+ '("rgb" "GIMP_RGB_IMAGE")
+ '("rgba" "GIMP_RGBA_IMAGE")
+ '("gray" "GIMP_GRAY_IMAGE")
+ '("graya" "GIMP_GRAYA_IMAGE")
+ '("indexed" "GIMP_INDEXED_IMAGE")
+ '("indexeda" "GIMP_INDEXEDA_IMAGE")
+ )
+)
+
+(define-enum LayerModeEffects
+ (in-module "Gimp")
+ (c-name "GimpLayerModeEffects")
+ (gtype-id "GIMP_TYPE_LAYER_MODE_EFFECTS")
+ (values
+ '("normal-mode" "GIMP_NORMAL_MODE")
+ '("dissolve-mode" "GIMP_DISSOLVE_MODE")
+ '("behind-mode" "GIMP_BEHIND_MODE")
+ '("multiply-mode" "GIMP_MULTIPLY_MODE")
+ '("screen-mode" "GIMP_SCREEN_MODE")
+ '("overlay-mode" "GIMP_OVERLAY_MODE")
+ '("difference-mode" "GIMP_DIFFERENCE_MODE")
+ '("addition-mode" "GIMP_ADDITION_MODE")
+ '("subtract-mode" "GIMP_SUBTRACT_MODE")
+ '("darken-only-mode" "GIMP_DARKEN_ONLY_MODE")
+ '("lighten-only-mode" "GIMP_LIGHTEN_ONLY_MODE")
+ '("hue-mode" "GIMP_HUE_MODE")
+ '("saturation-mode" "GIMP_SATURATION_MODE")
+ '("color-mode" "GIMP_COLOR_MODE")
+ '("value-mode" "GIMP_VALUE_MODE")
+ '("divide-mode" "GIMP_DIVIDE_MODE")
+ '("dodge-mode" "GIMP_DODGE_MODE")
+ '("burn-mode" "GIMP_BURN_MODE")
+ '("hardlight-mode" "GIMP_HARDLIGHT_MODE")
+ '("softlight-mode" "GIMP_SOFTLIGHT_MODE")
+ '("grain-extract-mode" "GIMP_GRAIN_EXTRACT_MODE")
+ '("grain-merge-mode" "GIMP_GRAIN_MERGE_MODE")
+ '("color-erase-mode" "GIMP_COLOR_ERASE_MODE")
+ '("new-overlay-mode" "GIMP_NEW_OVERLAY_MODE")
+ )
+)
+
+(define-enum MaskApplyMode
+ (in-module "Gimp")
+ (c-name "GimpMaskApplyMode")
+ (gtype-id "GIMP_TYPE_MASK_APPLY_MODE")
+ (values
+ '("apply" "GIMP_MASK_APPLY")
+ '("discard" "GIMP_MASK_DISCARD")
+ )
+)
+
+(define-enum MergeType
+ (in-module "Gimp")
+ (c-name "GimpMergeType")
+ (gtype-id "GIMP_TYPE_MERGE_TYPE")
+ (values
+ '("expand-as-necessary" "GIMP_EXPAND_AS_NECESSARY")
+ '("clip-to-image" "GIMP_CLIP_TO_IMAGE")
+ '("clip-to-bottom-layer" "GIMP_CLIP_TO_BOTTOM_LAYER")
+ '("flatten-image" "GIMP_FLATTEN_IMAGE")
+ )
+)
+
+(define-enum OffsetType
+ (in-module "Gimp")
+ (c-name "GimpOffsetType")
+ (gtype-id "GIMP_TYPE_OFFSET_TYPE")
+ (values
+ '("background" "GIMP_OFFSET_BACKGROUND")
+ '("transparent" "GIMP_OFFSET_TRANSPARENT")
+ )
+)
+
+(define-enum OrientationType
+ (in-module "Gimp")
+ (c-name "GimpOrientationType")
+ (gtype-id "GIMP_TYPE_ORIENTATION_TYPE")
+ (values
+ '("horizontal" "GIMP_ORIENTATION_HORIZONTAL")
+ '("vertical" "GIMP_ORIENTATION_VERTICAL")
+ '("unknown" "GIMP_ORIENTATION_UNKNOWN")
+ )
+)
+
+(define-enum RotationType
+ (in-module "Gimp")
+ (c-name "GimpRotationType")
+ (gtype-id "GIMP_TYPE_ROTATION_TYPE")
+ (values
+ '("90" "GIMP_ROTATE_90")
+ '("180" "GIMP_ROTATE_180")
+ '("270" "GIMP_ROTATE_270")
+ )
+)
+
+
+;; From ../../libgimp/gimpenums.h
+
+(define-function gimp_brush_application_mode_get_type
+ (c-name "gimp_brush_application_mode_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_brush_generated_shape_get_type
+ (c-name "gimp_brush_generated_shape_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_convert_dither_type_get_type
+ (c-name "gimp_convert_dither_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_convert_palette_type_get_type
+ (c-name "gimp_convert_palette_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_convolution_type_get_type
+ (c-name "gimp_convolution_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_convolve_type_get_type
+ (c-name "gimp_convolve_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_fill_type_get_type
+ (c-name "gimp_fill_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_gradient_segment_color_get_type
+ (c-name "gimp_gradient_segment_color_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_gradient_segment_type_get_type
+ (c-name "gimp_gradient_segment_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_histogram_channel_get_type
+ (c-name "gimp_histogram_channel_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_hue_range_get_type
+ (c-name "gimp_hue_range_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_layer_mode_effects_get_type
+ (c-name "gimp_layer_mode_effects_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_mask_apply_mode_get_type
+ (c-name "gimp_mask_apply_mode_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_merge_type_get_type
+ (c-name "gimp_merge_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_offset_type_get_type
+ (c-name "gimp_offset_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_orientation_type_get_type
+ (c-name "gimp_orientation_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_rotation_type_get_type
+ (c-name "gimp_rotation_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_enums_init
+ (c-name "gimp_enums_init")
+ (return-type "none")
+)
+
+(define-function gimp_enums_get_type_names
+ (c-name "gimp_enums_get_type_names")
+ (return-type "const-gchar**")
+ (parameters
+ '("gint*" "n_type_names")
+ )
+)
+
+
diff --git a/plug-ins/pygimp/gimpenums.py b/plug-ins/pygimp/gimpenums.py
new file mode 100644
index 0000000..9e23ded
--- /dev/null
+++ b/plug-ins/pygimp/gimpenums.py
@@ -0,0 +1,50 @@
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 2005 Manish Singh <yosh@gimp.org>
+#
+# 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/>.
+
+# gimpenums.py -- constants for use with the gimp module
+#
+# this file pulls in constants that are useful for use in
+# gimp plugins. Just add 'from gimpenums import *' to the top
+# of the script
+
+from _gimpenums import *
+
+# This is from pygtk/gtk/__init__.py
+# Copyright (C) 1998-2003 James Henstridge
+
+class _DeprecatedConstant:
+ def __init__(self, value, name, suggestion):
+ self._v = value
+ self._name = name
+ self._suggestion = suggestion
+
+ def _deprecated(self, value):
+ import warnings
+ message = '%s is deprecated, use %s instead' % (self._name,
+ self._suggestion)
+ warnings.warn(message, DeprecationWarning, 3)
+ return value
+
+ __nonzero__ = lambda self: self._deprecated(self._v == True)
+ __int__ = lambda self: self._deprecated(int(self._v))
+ __str__ = lambda self: self._deprecated(str(self._v))
+ __repr__ = lambda self: self._deprecated(repr(self._v))
+ __cmp__ = lambda self, other: self._deprecated(cmp(self._v, other))
+
+TRUE = _DeprecatedConstant(True, 'gimpenums.TRUE', 'True')
+FALSE = _DeprecatedConstant(False, 'gimpenums.FALSE', 'False')
+
+del _DeprecatedConstant
diff --git a/plug-ins/pygimp/gimpenumsmodule.c b/plug-ins/pygimp/gimpenumsmodule.c
new file mode 100644
index 0000000..2a1194c
--- /dev/null
+++ b/plug-ins/pygimp/gimpenumsmodule.c
@@ -0,0 +1,174 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Python.h>
+
+#include <glib-object.h>
+
+#include <pygobject.h>
+
+#include "pygimp-api.h"
+#include "pygimp-util.h"
+#include "libgimp/gimpui.h"
+
+static void
+add_misc_enums(PyObject *m)
+{
+ PyModule_AddIntConstant(m, "PARASITE_PERSISTENT",
+ GIMP_PARASITE_PERSISTENT);
+ PyModule_AddIntConstant(m, "PARASITE_UNDOABLE",
+ GIMP_PARASITE_UNDOABLE);
+ PyModule_AddIntConstant(m, "PARASITE_ATTACH_PARENT",
+ GIMP_PARASITE_ATTACH_PARENT);
+ PyModule_AddIntConstant(m, "PARASITE_PARENT_PERSISTENT",
+ GIMP_PARASITE_PARENT_PERSISTENT);
+ PyModule_AddIntConstant(m, "PARASITE_PARENT_UNDOABLE",
+ GIMP_PARASITE_PARENT_UNDOABLE);
+ PyModule_AddIntConstant(m, "PARASITE_ATTACH_GRANDPARENT",
+ GIMP_PARASITE_ATTACH_GRANDPARENT);
+ PyModule_AddIntConstant(m, "PARASITE_GRANDPARENT_PERSISTENT",
+ GIMP_PARASITE_GRANDPARENT_PERSISTENT);
+ PyModule_AddIntConstant(m, "PARASITE_GRANDPARENT_UNDOABLE",
+ GIMP_PARASITE_GRANDPARENT_UNDOABLE);
+
+ PyModule_AddIntConstant(m, "UNIT_PIXEL",
+ GIMP_UNIT_PIXEL);
+ PyModule_AddIntConstant(m, "UNIT_INCH",
+ GIMP_UNIT_INCH);
+ PyModule_AddIntConstant(m, "UNIT_MM",
+ GIMP_UNIT_MM);
+ PyModule_AddIntConstant(m, "UNIT_POINT",
+ GIMP_UNIT_POINT);
+ PyModule_AddIntConstant(m, "UNIT_PICA",
+ GIMP_UNIT_PICA);
+
+ PyModule_AddIntConstant(m, "MIN_IMAGE_SIZE",
+ GIMP_MIN_IMAGE_SIZE);
+ PyModule_AddIntConstant(m, "MAX_IMAGE_SIZE",
+ GIMP_MAX_IMAGE_SIZE);
+
+ PyModule_AddObject(m, "MIN_RESOLUTION",
+ PyFloat_FromDouble(GIMP_MIN_RESOLUTION));
+ PyModule_AddObject(m, "MAX_RESOLUTION",
+ PyFloat_FromDouble(GIMP_MAX_RESOLUTION));
+
+ PyModule_AddObject(m, "MAX_MEMSIZE",
+ PyLong_FromUnsignedLongLong(GIMP_MAX_MEMSIZE));
+
+ PyModule_AddIntConstant(m, "PIXEL_FETCHER_EDGE_NONE",
+ GIMP_PIXEL_FETCHER_EDGE_NONE);
+ PyModule_AddIntConstant(m, "PIXEL_FETCHER_EDGE_WRAP",
+ GIMP_PIXEL_FETCHER_EDGE_WRAP);
+ PyModule_AddIntConstant(m, "PIXEL_FETCHER_EDGE_SMEAR",
+ GIMP_PIXEL_FETCHER_EDGE_SMEAR);
+ PyModule_AddIntConstant(m, "PIXEL_FETCHER_EDGE_BLACK",
+ GIMP_PIXEL_FETCHER_EDGE_BLACK);
+ PyModule_AddIntConstant(m, "PIXEL_FETCHER_EDGE_BACKGROUND",
+ GIMP_PIXEL_FETCHER_EDGE_BACKGROUND);
+}
+
+static void
+add_compat_enums(PyObject *m)
+{
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_RGB",
+ GIMP_EXPORT_CAN_HANDLE_RGB);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_GRAY",
+ GIMP_EXPORT_CAN_HANDLE_GRAY);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_INDEXED",
+ GIMP_EXPORT_CAN_HANDLE_INDEXED);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_BITMAP",
+ GIMP_EXPORT_CAN_HANDLE_BITMAP);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_ALPHA",
+ GIMP_EXPORT_CAN_HANDLE_ALPHA);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_LAYERS",
+ GIMP_EXPORT_CAN_HANDLE_LAYERS);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION",
+ GIMP_EXPORT_CAN_HANDLE_LAYERS_AS_ANIMATION);
+ PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_LAYER_MASKS",
+ GIMP_EXPORT_CAN_HANDLE_LAYER_MASKS);
+ PyModule_AddIntConstant(m, "EXPORT_NEEDS_ALPHA",
+ GIMP_EXPORT_NEEDS_ALPHA);
+
+ PyModule_AddIntConstant(m, "EXPORT_CANCEL",
+ GIMP_EXPORT_CANCEL);
+ PyModule_AddIntConstant(m, "EXPORT_IGNORE",
+ GIMP_EXPORT_IGNORE);
+ PyModule_AddIntConstant(m, "EXPORT_EXPORT",
+ GIMP_EXPORT_EXPORT);
+}
+
+static void
+add_registered_enums(PyObject *m)
+{
+ gint num_names, i;
+ const gchar **names;
+ GQuark quark = g_quark_from_static_string ("gimp-compat-enum");
+
+ names = gimp_enums_get_type_names (&num_names);
+
+ pyg_enum_add_constants (m, GIMP_TYPE_CHECK_SIZE, "GIMP_");
+ pyg_enum_add_constants (m, GIMP_TYPE_CHECK_TYPE, "GIMP_");
+
+ for (i = 0; i < num_names; i++)
+ {
+ GType enum_type = g_type_from_name (names[i]);
+
+ pyg_enum_add_constants (m, enum_type, "GIMP_");
+
+ enum_type = (GType) g_type_get_qdata (enum_type, quark);
+
+ if (enum_type)
+ pyg_enum_add_constants (m, enum_type, "GIMP_");
+ }
+}
+
+
+/* Initialization function for the module (*must* be called initgimpenums) */
+
+static char gimpenums_doc[] =
+"This module provides interfaces to allow you to write gimp plug-ins"
+;
+
+void init_gimpenums(void);
+
+PyMODINIT_FUNC
+init_gimpenums(void)
+{
+ PyObject *m;
+
+ pygimp_init_pygobject();
+
+ init_pygimp();
+
+ gimp_enums_init();
+
+ /* Create the module and add the functions */
+ m = Py_InitModule3("_gimpenums", NULL, gimpenums_doc);
+
+ add_misc_enums(m);
+ add_compat_enums(m);
+ add_registered_enums(m);
+
+ /* Check for errors */
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module _gimpenums");
+}
diff --git a/plug-ins/pygimp/gimpfu.py b/plug-ins/pygimp/gimpfu.py
new file mode 100644
index 0000000..266d5ae
--- /dev/null
+++ b/plug-ins/pygimp/gimpfu.py
@@ -0,0 +1,876 @@
+# Gimp-Python - allows the writing of GIMP plug-ins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+"""Simple interface for writing GIMP plug-ins in Python.
+
+Instead of worrying about all the user interaction, saving last used
+values and everything, the gimpfu module can take care of it for you.
+It provides a simple register() function that will register your
+plug-in if needed, and cause your plug-in function to be called when
+needed.
+
+Gimpfu will also handle showing a user interface for editing plug-in
+parameters if the plug-in is called interactively, and will also save
+the last used parameters, so the RUN_WITH_LAST_VALUES run_type will
+work correctly. It will also make sure that the displays are flushed
+on completion if the plug-in was run interactively.
+
+When registering the plug-in, you do not need to worry about
+specifying the run_type parameter.
+
+A typical gimpfu plug-in would look like this:
+ from gimpfu import *
+
+ def plugin_func(image, drawable, args):
+ # do what plugins do best
+ register(
+ "plugin_func",
+ "blurb",
+ "help message",
+ "author",
+ "copyright",
+ "year",
+ "My plug-in",
+ "*",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_STRING, "arg", "The argument", "default-value")
+ ],
+ [],
+ plugin_func, menu="<Image>/Somewhere")
+ main()
+
+The call to "from gimpfu import *" will import all the gimp constants
+into the plug-in namespace, and also import the symbols gimp, pdb,
+register and main. This should be just about all any plug-in needs.
+
+You can use any of the PF_* constants below as parameter types, and an
+appropriate user interface element will be displayed when the plug-in
+is run in interactive mode. Note that the the PF_SPINNER and
+PF_SLIDER types expect a fifth element in their description tuple -- a
+3-tuple of the form (lower,upper,step), which defines the limits for
+the slider or spinner.
+
+If want to localize your plug-in, add an optional domain parameter to
+the register call. It can be the name of the translation domain or a
+tuple that consists of the translation domain and the directory where
+the translations are installed.
+"""
+
+import string as _string
+import math
+import gimp
+import gimpcolor
+from gimpenums import *
+pdb = gimp.pdb
+
+import gettext
+t = gettext.translation("gimp20-python", gimp.locale_directory, fallback=True)
+_ = t.ugettext
+
+class error(RuntimeError): pass
+class CancelError(RuntimeError): pass
+
+PF_INT8 = PDB_INT8
+PF_INT16 = PDB_INT16
+PF_INT32 = PDB_INT32
+PF_INT = PF_INT32
+PF_FLOAT = PDB_FLOAT
+PF_STRING = PDB_STRING
+PF_VALUE = PF_STRING
+#PF_INT8ARRAY = PDB_INT8ARRAY
+#PF_INT16ARRAY = PDB_INT16ARRAY
+#PF_INT32ARRAY = PDB_INT32ARRAY
+#PF_INTARRAY = PF_INT32ARRAY
+#PF_FLOATARRAY = PDB_FLOATARRAY
+#PF_STRINGARRAY = PDB_STRINGARRAY
+PF_COLOR = PDB_COLOR
+PF_COLOUR = PF_COLOR
+PF_ITEM = PDB_ITEM
+PF_DISPLAY = PDB_DISPLAY
+PF_IMAGE = PDB_IMAGE
+PF_LAYER = PDB_LAYER
+PF_CHANNEL = PDB_CHANNEL
+PF_DRAWABLE = PDB_DRAWABLE
+PF_VECTORS = PDB_VECTORS
+#PF_SELECTION = PDB_SELECTION
+#PF_BOUNDARY = PDB_BOUNDARY
+#PF_PATH = PDB_PATH
+#PF_STATUS = PDB_STATUS
+
+PF_TOGGLE = 1000
+PF_BOOL = PF_TOGGLE
+PF_SLIDER = 1001
+PF_SPINNER = 1002
+PF_ADJUSTMENT = PF_SPINNER
+
+PF_FONT = 1003
+PF_FILE = 1004
+PF_BRUSH = 1005
+PF_PATTERN = 1006
+PF_GRADIENT = 1007
+PF_RADIO = 1008
+PF_TEXT = 1009
+PF_PALETTE = 1010
+PF_FILENAME = 1011
+PF_DIRNAME = 1012
+PF_OPTION = 1013
+
+_type_mapping = {
+ PF_INT8 : PDB_INT8,
+ PF_INT16 : PDB_INT16,
+ PF_INT32 : PDB_INT32,
+ PF_FLOAT : PDB_FLOAT,
+ PF_STRING : PDB_STRING,
+ #PF_INT8ARRAY : PDB_INT8ARRAY,
+ #PF_INT16ARRAY : PDB_INT16ARRAY,
+ #PF_INT32ARRAY : PDB_INT32ARRAY,
+ #PF_FLOATARRAY : PDB_FLOATARRAY,
+ #PF_STRINGARRAY : PDB_STRINGARRAY,
+ PF_COLOR : PDB_COLOR,
+ PF_ITEM : PDB_ITEM,
+ PF_DISPLAY : PDB_DISPLAY,
+ PF_IMAGE : PDB_IMAGE,
+ PF_LAYER : PDB_LAYER,
+ PF_CHANNEL : PDB_CHANNEL,
+ PF_DRAWABLE : PDB_DRAWABLE,
+ PF_VECTORS : PDB_VECTORS,
+
+ PF_TOGGLE : PDB_INT32,
+ PF_SLIDER : PDB_FLOAT,
+ PF_SPINNER : PDB_INT32,
+
+ PF_FONT : PDB_STRING,
+ PF_FILE : PDB_STRING,
+ PF_BRUSH : PDB_STRING,
+ PF_PATTERN : PDB_STRING,
+ PF_GRADIENT : PDB_STRING,
+ PF_RADIO : PDB_STRING,
+ PF_TEXT : PDB_STRING,
+ PF_PALETTE : PDB_STRING,
+ PF_FILENAME : PDB_STRING,
+ PF_DIRNAME : PDB_STRING,
+ PF_OPTION : PDB_INT32,
+}
+
+_obj_mapping = {
+ PF_INT8 : int,
+ PF_INT16 : int,
+ PF_INT32 : int,
+ PF_FLOAT : float,
+ PF_STRING : str,
+ #PF_INT8ARRAY : list,
+ #PF_INT16ARRAY : list,
+ #PF_INT32ARRAY : list,
+ #PF_FLOATARRAY : list,
+ #PF_STRINGARRAY : list,
+ PF_COLOR : gimpcolor.RGB,
+ PF_ITEM : int,
+ PF_DISPLAY : gimp.Display,
+ PF_IMAGE : gimp.Image,
+ PF_LAYER : gimp.Layer,
+ PF_CHANNEL : gimp.Channel,
+ PF_DRAWABLE : gimp.Drawable,
+ PF_VECTORS : gimp.Vectors,
+
+ PF_TOGGLE : bool,
+ PF_SLIDER : float,
+ PF_SPINNER : int,
+
+ PF_FONT : str,
+ PF_FILE : str,
+ PF_BRUSH : str,
+ PF_PATTERN : str,
+ PF_GRADIENT : str,
+ PF_RADIO : str,
+ PF_TEXT : str,
+ PF_PALETTE : str,
+ PF_FILENAME : str,
+ PF_DIRNAME : str,
+ PF_OPTION : int,
+}
+
+_registered_plugins_ = {}
+
+def register(proc_name, blurb, help, author, copyright, date, label,
+ imagetypes, params, results, function,
+ menu=None, domain=None, on_query=None, on_run=None, run_mode_param=True):
+ """This is called to register a new plug-in."""
+
+ # First perform some sanity checks on the data
+ def letterCheck(str):
+ allowed = _string.letters + _string.digits + "_" + "-"
+ for ch in str:
+ if not ch in allowed:
+ return 0
+ else:
+ return 1
+
+ if not letterCheck(proc_name):
+ raise error, "procedure name contains illegal characters"
+
+ for ent in params:
+ if len(ent) < 4:
+ raise error, ("parameter definition must contain at least 4 "
+ "elements (%s given: %s)" % (len(ent), ent))
+
+ if type(ent[0]) != int:
+ raise error, "parameter types must be integers"
+
+ if not letterCheck(ent[1]):
+ raise error, "parameter name contains illegal characters"
+
+ for ent in results:
+ if len(ent) < 3:
+ raise error, ("result definition must contain at least 3 elements "
+ "(%s given: %s)" % (len(ent), ent))
+
+ if type(ent[0]) != type(42):
+ raise error, "result types must be integers"
+
+ if not letterCheck(ent[1]):
+ raise error, "result name contains illegal characters"
+
+ plugin_type = PLUGIN
+
+ if (not proc_name.startswith("python-") and
+ not proc_name.startswith("python_") and
+ not proc_name.startswith("extension-") and
+ not proc_name.startswith("extension_") and
+ not proc_name.startswith("plug-in-") and
+ not proc_name.startswith("plug_in_") and
+ not proc_name.startswith("file-") and
+ not proc_name.startswith("file_")):
+ proc_name = "python-fu-" + proc_name
+
+ # if menu is not given, derive it from label
+ need_compat_params = False
+ if menu is None and label:
+ fields = label.split("/")
+ if fields:
+ label = fields.pop()
+ menu = "/".join(fields)
+ need_compat_params = True
+
+ import warnings
+ message = ("%s: passing the full menu path for the menu label is "
+ "deprecated, use the 'menu' parameter instead"
+ % (proc_name))
+ warnings.warn(message, DeprecationWarning, 3)
+
+ if need_compat_params and plugin_type == PLUGIN:
+ file_params = [(PDB_STRING, "filename", "The name of the file", ""),
+ (PDB_STRING, "raw-filename", "The name of the file", "")]
+
+ if menu is None:
+ pass
+ elif menu.startswith("<Load>"):
+ params[0:0] = file_params
+ elif menu.startswith("<Image>") or menu.startswith("<Save>"):
+ params.insert(0, (PDB_IMAGE, "image", "Input image", None))
+ params.insert(1, (PDB_DRAWABLE, "drawable", "Input drawable", None))
+ if menu.startswith("<Save>"):
+ params[2:2] = file_params
+
+ _registered_plugins_[proc_name] = (blurb, help, author, copyright,
+ date, label, imagetypes,
+ plugin_type, params, results,
+ function, menu, domain,
+ on_query, on_run, run_mode_param)
+
+def _query():
+ for plugin in _registered_plugins_.keys():
+ (blurb, help, author, copyright, date,
+ label, imagetypes, plugin_type,
+ params, results, function, menu, domain,
+ on_query, on_run, has_param_run_mode) = _registered_plugins_[plugin]
+
+ def make_params(params):
+ return [(_type_mapping[x[0]],
+ x[1],
+ _string.replace(x[2], "_", "")) for x in params]
+
+ params = make_params(params)
+ # add the run mode argument ...
+ if has_param_run_mode:
+ params.insert(0, (PDB_INT32, "run-mode",
+ "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"))
+
+ results = make_params(results)
+
+ if domain:
+ try:
+ (domain, locale_dir) = domain
+ gimp.domain_register(domain, locale_dir)
+ except ValueError:
+ gimp.domain_register(domain)
+
+ gimp.install_procedure(plugin, blurb, help, author, copyright,
+ date, label, imagetypes, plugin_type,
+ params, results)
+
+ if menu:
+ gimp.menu_register(plugin, menu)
+ if on_query:
+ on_query()
+
+def _get_defaults(proc_name):
+ import gimpshelf
+
+ (blurb, help, author, copyright, date,
+ label, imagetypes, plugin_type,
+ params, results, function, menu, domain,
+ on_query, on_run, has_run_mode) = _registered_plugins_[proc_name]
+
+ key = "python-fu-save--" + proc_name
+
+ if gimpshelf.shelf.has_key(key):
+ return gimpshelf.shelf[key]
+ else:
+ # return the default values
+ return [x[3] for x in params]
+
+def _set_defaults(proc_name, defaults):
+ import gimpshelf
+
+ key = "python-fu-save--" + proc_name
+ gimpshelf.shelf[key] = defaults
+
+def _interact(proc_name, start_params):
+ (blurb, help, author, copyright, date,
+ label, imagetypes, plugin_type,
+ params, results, function, menu, domain,
+ on_query, on_run, has_run_mode) = _registered_plugins_[proc_name]
+
+ def run_script(run_params):
+ params = start_params + tuple(run_params)
+ _set_defaults(proc_name, params)
+ return apply(function, params)
+
+ params = params[len(start_params):]
+
+ # short circuit for no parameters ...
+ if len(params) == 0:
+ return run_script([])
+
+ import pygtk
+ pygtk.require('2.0')
+
+ import gimpui
+ import gtk
+# import pango
+ gimpui.gimp_ui_init ()
+
+ defaults = _get_defaults(proc_name)
+ defaults = defaults[len(start_params):]
+
+ class EntryValueError(Exception):
+ pass
+
+ def warning_dialog(parent, primary, secondary=None):
+ dlg = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE,
+ primary)
+ if secondary:
+ dlg.format_secondary_text(secondary)
+ dlg.run()
+ dlg.destroy()
+
+ def error_dialog(parent, proc_name):
+ import sys, traceback
+
+ exc_str = exc_only_str = _("Missing exception information")
+
+ try:
+ etype, value, tb = sys.exc_info()
+ exc_str = "".join(traceback.format_exception(etype, value, tb))
+ exc_only_str = "".join(traceback.format_exception_only(etype, value))
+ finally:
+ etype = value = tb = None
+
+ title = _("An error occurred running %s") % proc_name
+ dlg = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
+ title)
+ dlg.format_secondary_text(exc_only_str)
+
+ alignment = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
+ alignment.set_padding(0, 0, 12, 12)
+ dlg.vbox.pack_start(alignment)
+ alignment.show()
+
+ expander = gtk.Expander(_("_More Information"));
+ expander.set_use_underline(True)
+ expander.set_spacing(6)
+ alignment.add(expander)
+ expander.show()
+
+ scrolled = gtk.ScrolledWindow()
+ scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scrolled.set_size_request(-1, 200)
+ expander.add(scrolled)
+ scrolled.show()
+
+
+ label = gtk.Label(exc_str)
+ label.set_alignment(0.0, 0.0)
+ label.set_padding(6, 6)
+ label.set_selectable(True)
+ scrolled.add_with_viewport(label)
+ label.show()
+
+ def response(widget, id):
+ widget.destroy()
+
+ dlg.connect("response", response)
+ dlg.set_resizable(True)
+ dlg.show()
+
+ # define a mapping of param types to edit objects ...
+ class StringEntry(gtk.Entry):
+ def __init__(self, default=""):
+ gtk.Entry.__init__(self)
+ self.set_text(str(default))
+ self.set_activates_default(True)
+
+ def get_value(self):
+ return self.get_text()
+
+ class TextEntry(gtk.ScrolledWindow):
+ def __init__ (self, default=""):
+ gtk.ScrolledWindow.__init__(self)
+ self.set_shadow_type(gtk.SHADOW_IN)
+
+ self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.set_size_request(100, -1)
+
+ self.view = gtk.TextView()
+ self.add(self.view)
+ self.view.show()
+
+ self.buffer = self.view.get_buffer()
+
+ self.set_value(str(default))
+
+ def set_value(self, text):
+ self.buffer.set_text(text)
+
+ def get_value(self):
+ return self.buffer.get_text(self.buffer.get_start_iter(),
+ self.buffer.get_end_iter())
+
+ class IntEntry(StringEntry):
+ def get_value(self):
+ try:
+ return int(self.get_text())
+ except ValueError, e:
+ raise EntryValueError, e.args
+
+ class FloatEntry(StringEntry):
+ def get_value(self):
+ try:
+ return float(self.get_text())
+ except ValueError, e:
+ raise EntryValueError, e.args
+
+# class ArrayEntry(StringEntry):
+# def get_value(self):
+# return eval(self.get_text(), {}, {})
+
+
+ def precision(step):
+ # calculate a reasonable precision from a given step size
+ if math.fabs(step) >= 1.0 or step == 0.0:
+ digits = 0
+ else:
+ digits = abs(math.floor(math.log10(math.fabs(step))));
+ if digits > 20:
+ digits = 20
+ return int(digits)
+
+ class SliderEntry(gtk.HScale):
+ # bounds is (upper, lower, step)
+ def __init__(self, default=0, bounds=(0, 100, 5)):
+ step = bounds[2]
+ self.adj = gtk.Adjustment(default, bounds[0], bounds[1],
+ step, 10 * step, 0)
+ gtk.HScale.__init__(self, self.adj)
+ self.set_digits(precision(step))
+
+ def get_value(self):
+ return self.adj.value
+
+ class SpinnerEntry(gtk.SpinButton):
+ # bounds is (upper, lower, step)
+ def __init__(self, default=0, bounds=(0, 100, 5)):
+ step = bounds[2]
+ self.adj = gtk.Adjustment(default, bounds[0], bounds[1],
+ step, 10 * step, 0)
+ gtk.SpinButton.__init__(self, self.adj, step, precision(step))
+
+ class ToggleEntry(gtk.ToggleButton):
+ def __init__(self, default=0):
+ gtk.ToggleButton.__init__(self)
+
+ self.label = gtk.Label(_("No"))
+ self.add(self.label)
+ self.label.show()
+
+ self.connect("toggled", self.changed)
+
+ self.set_active(default)
+
+ def changed(self, tog):
+ if tog.get_active():
+ self.label.set_text(_("Yes"))
+ else:
+ self.label.set_text(_("No"))
+
+ def get_value(self):
+ return self.get_active()
+
+ class RadioEntry(gtk.VBox):
+ def __init__(self, default=0, items=((_("Yes"), 1), (_("No"), 0))):
+ gtk.VBox.__init__(self, homogeneous=False, spacing=2)
+
+ button = None
+
+ for (label, value) in items:
+ button = gtk.RadioButton(button, label)
+ self.pack_start(button)
+ button.show()
+
+ button.connect("toggled", self.changed, value)
+
+ if value == default:
+ button.set_active(True)
+ self.active_value = value
+
+ def changed(self, radio, value):
+ if radio.get_active():
+ self.active_value = value
+
+ def get_value(self):
+ return self.active_value
+
+ class ComboEntry(gtk.ComboBox):
+ def __init__(self, default=0, items=()):
+ store = gtk.ListStore(str)
+ for item in items:
+ store.append([item])
+
+ gtk.ComboBox.__init__(self, model=store)
+
+ cell = gtk.CellRendererText()
+ self.pack_start(cell)
+ self.set_attributes(cell, text=0)
+
+ self.set_active(default)
+
+ def get_value(self):
+ return self.get_active()
+
+ def FileSelector(default="", title=None):
+ # FIXME: should this be os.path.separator? If not, perhaps explain why?
+ if default and default.endswith("/"):
+ if default == "/": default = ""
+ return DirnameSelector(default)
+ else:
+ return FilenameSelector(default, title=title, save_mode=False)
+
+ class FilenameSelector(gtk.HBox):
+ #gimpfu.FileChooserButton
+ def __init__(self, default, save_mode=True, title=None):
+ super(FilenameSelector, self).__init__()
+ if not title:
+ self.title = _("Python-Fu File Selection")
+ else:
+ self.title = title
+ self.save_mode = save_mode
+ box = self
+ self.entry = gtk.Entry()
+ image = gtk.Image()
+ image.set_from_stock(gtk.STOCK_FILE, gtk.ICON_SIZE_BUTTON)
+ self.button = gtk.Button()
+ self.button.set_image(image)
+ box.pack_start(self.entry)
+ box.pack_start(self.button, expand=False)
+ self.button.connect("clicked", self.pick_file)
+ if default:
+ self.entry.set_text(default)
+
+ def show(self):
+ super(FilenameSelector, self).show()
+ self.button.show()
+ self.entry.show()
+
+ def pick_file(self, widget):
+ entry = self.entry
+ dialog = gtk.FileChooserDialog(
+ title=self.title,
+ action=(gtk.FILE_CHOOSER_ACTION_SAVE
+ if self.save_mode else
+ gtk.FILE_CHOOSER_ACTION_OPEN),
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE
+ if self.save_mode else
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK)
+ )
+ dialog.set_alternative_button_order ((gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL))
+ dialog.show_all()
+ response = dialog.run()
+ if response == gtk.RESPONSE_OK:
+ entry.set_text(dialog.get_filename())
+ dialog.destroy()
+
+ def get_value(self):
+ return self.entry.get_text()
+
+
+ class DirnameSelector(gtk.FileChooserButton):
+ def __init__(self, default=""):
+ gtk.FileChooserButton.__init__(self,
+ _("Python-Fu Folder Selection"))
+ self.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ if default:
+ self.set_filename(default)
+
+ def get_value(self):
+ return self.get_filename()
+
+ _edit_mapping = {
+ PF_INT8 : IntEntry,
+ PF_INT16 : IntEntry,
+ PF_INT32 : IntEntry,
+ PF_FLOAT : FloatEntry,
+ PF_STRING : StringEntry,
+ #PF_INT8ARRAY : ArrayEntry,
+ #PF_INT16ARRAY : ArrayEntry,
+ #PF_INT32ARRAY : ArrayEntry,
+ #PF_FLOATARRAY : ArrayEntry,
+ #PF_STRINGARRAY : ArrayEntry,
+ PF_COLOR : gimpui.ColorSelector,
+ PF_ITEM : IntEntry, # should handle differently ...
+ PF_IMAGE : gimpui.ImageSelector,
+ PF_LAYER : gimpui.LayerSelector,
+ PF_CHANNEL : gimpui.ChannelSelector,
+ PF_DRAWABLE : gimpui.DrawableSelector,
+ PF_VECTORS : gimpui.VectorsSelector,
+
+ PF_TOGGLE : ToggleEntry,
+ PF_SLIDER : SliderEntry,
+ PF_SPINNER : SpinnerEntry,
+ PF_RADIO : RadioEntry,
+ PF_OPTION : ComboEntry,
+
+ PF_FONT : gimpui.FontSelector,
+ PF_FILE : FileSelector,
+ PF_FILENAME : FilenameSelector,
+ PF_DIRNAME : DirnameSelector,
+ PF_BRUSH : gimpui.BrushSelector,
+ PF_PATTERN : gimpui.PatternSelector,
+ PF_GRADIENT : gimpui.GradientSelector,
+ PF_PALETTE : gimpui.PaletteSelector,
+ PF_TEXT : TextEntry
+ }
+
+ if on_run:
+ on_run()
+
+ dialog = gimpui.Dialog(proc_name, "python-fu", None, 0, None, proc_name,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK))
+
+ dialog.set_alternative_button_order((gtk.RESPONSE_OK, gtk.RESPONSE_CANCEL))
+
+ dialog.set_transient()
+
+ vbox = gtk.VBox(False, 12)
+ vbox.set_border_width(12)
+ dialog.vbox.pack_start(vbox)
+ vbox.show()
+
+ if blurb:
+ if domain:
+ try:
+ (domain, locale_dir) = domain
+ trans = gettext.translation(domain, locale_dir, fallback=True)
+ except ValueError:
+ trans = gettext.translation(domain, fallback=True)
+ blurb = trans.ugettext(blurb)
+ box = gimpui.HintBox(blurb)
+ vbox.pack_start(box, expand=False)
+ box.show()
+
+ table = gtk.Table(len(params), 2, False)
+ table.set_row_spacings(6)
+ table.set_col_spacings(6)
+ vbox.pack_start(table, expand=False)
+ table.show()
+
+ def response(dlg, id):
+ if id == gtk.RESPONSE_OK:
+ dlg.set_response_sensitive(gtk.RESPONSE_OK, False)
+ dlg.set_response_sensitive(gtk.RESPONSE_CANCEL, False)
+
+ params = []
+
+ try:
+ for wid in edit_wids:
+ params.append(wid.get_value())
+ except EntryValueError:
+ warning_dialog(dialog, _("Invalid input for '%s'") % wid.desc)
+ else:
+ try:
+ dialog.res = run_script(params)
+ except CancelError:
+ pass
+ except Exception:
+ dlg.set_response_sensitive(gtk.RESPONSE_CANCEL, True)
+ error_dialog(dialog, proc_name)
+ raise
+
+ gtk.main_quit()
+
+ dialog.connect("response", response)
+
+ edit_wids = []
+ for i in range(len(params)):
+ pf_type = params[i][0]
+ name = params[i][1]
+ desc = params[i][2]
+ def_val = defaults[i]
+
+ label = gtk.Label(desc)
+ label.set_use_underline(True)
+ label.set_alignment(0.0, 0.5)
+ table.attach(label, 1, 2, i, i+1, xoptions=gtk.FILL)
+ label.show()
+
+ # Remove accelerator markers from tooltips
+ tooltip_text = desc.replace("_", "")
+
+ if pf_type in (PF_SPINNER, PF_SLIDER, PF_RADIO, PF_OPTION):
+ wid = _edit_mapping[pf_type](def_val, params[i][4])
+ elif pf_type in (PF_FILE, PF_FILENAME):
+ wid = _edit_mapping[pf_type](def_val, title= "%s - %s" %
+ (proc_name, tooltip_text))
+ else:
+ wid = _edit_mapping[pf_type](def_val)
+
+
+ label.set_mnemonic_widget(wid)
+
+ table.attach(wid, 2,3, i,i+1, yoptions=0)
+
+ if pf_type != PF_TEXT:
+ wid.set_tooltip_text(tooltip_text)
+ else:
+ # Attach tip to TextView, not to ScrolledWindow
+ wid.view.set_tooltip_text(tooltip_text)
+ wid.show()
+
+ wid.desc = desc
+ edit_wids.append(wid)
+
+ progress_vbox = gtk.VBox(False, 6)
+ vbox.pack_end(progress_vbox, expand=False)
+ progress_vbox.show()
+
+ progress = gimpui.ProgressBar()
+ progress_vbox.pack_start(progress)
+ progress.show()
+
+# progress_label = gtk.Label()
+# progress_label.set_alignment(0.0, 0.5)
+# progress_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
+
+# attrs = pango.AttrList()
+# attrs.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1))
+# progress_label.set_attributes(attrs)
+
+# progress_vbox.pack_start(progress_label)
+# progress_label.show()
+
+ dialog.show()
+
+ gtk.main()
+
+ if hasattr(dialog, "res"):
+ res = dialog.res
+ dialog.destroy()
+ return res
+ else:
+ dialog.destroy()
+ raise CancelError
+
+def _run(proc_name, params):
+ run_mode = params[0]
+ func = _registered_plugins_[proc_name][10]
+
+ if run_mode == RUN_NONINTERACTIVE:
+ return apply(func, params[1:])
+
+ script_params = _registered_plugins_[proc_name][8]
+ has_param_run_mode = _registered_plugins_[proc_name][15]
+
+ min_args = 0
+ start_param_idx = 1 if has_param_run_mode else 0
+ if len(params) > start_param_idx:
+ for i in range(start_param_idx, len(params)):
+ param_type = _obj_mapping[script_params[i - start_param_idx][0]]
+ if not isinstance(params[i], param_type):
+ break
+
+ min_args = i
+
+ if len(script_params) > min_args:
+ start_params = params[:min_args + 1]
+
+ if run_mode == RUN_WITH_LAST_VALS:
+ default_params = _get_defaults(proc_name)
+ params = start_params + default_params[min_args:]
+ else:
+ params = start_params
+ else:
+ run_mode = RUN_NONINTERACTIVE
+
+ if run_mode == RUN_INTERACTIVE:
+ try:
+ res = _interact(proc_name, params[start_param_idx:])
+ except CancelError:
+ return
+ else:
+ res = apply(func, params[start_param_idx:])
+
+ gimp.displays_flush()
+
+ return res
+
+def main():
+ """This should be called after registering the plug-in."""
+ gimp.main(None, None, _query, _run)
+
+def fail(msg):
+ """Display an error message and quit"""
+ gimp.message(msg)
+ raise error, msg
+
+def N_(message):
+ return message
diff --git a/plug-ins/pygimp/gimpmodule.c b/plug-ins/pygimp/gimpmodule.c
new file mode 100644
index 0000000..36a1b88
--- /dev/null
+++ b/plug-ins/pygimp/gimpmodule.c
@@ -0,0 +1,2071 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#undef GIMP_DISABLE_DEPRECATED
+#define GIMP_DISABLE_DEPRECATION_WARNINGS
+#include "pygimp.h"
+
+#include "pygimpcolor-api.h"
+
+#include <sysmodule.h>
+
+#include <glib-object.h>
+
+#include <pygobject.h>
+
+#include "pygimp-util.h"
+
+#include "pygimp-intl.h"
+
+#include "libgimp/gimpui.h"
+
+#include <gtk/gtk.h>
+
+#include <gegl.h>
+
+
+PyObject *pygimp_error;
+
+#ifndef PG_DEBUG
+# define PG_DEBUG 0
+#endif
+
+
+/* End of code for pdbFunc objects */
+/* -------------------------------------------------------- */
+
+GimpPlugInInfo PLUG_IN_INFO = {
+ NULL, /* init_proc */
+ NULL, /* quit_proc */
+ NULL, /* query_proc */
+ NULL /* run_proc */
+};
+
+static PyObject *callbacks[] = {
+ NULL, NULL, NULL, NULL
+};
+
+typedef struct _ProgressData ProgressData;
+
+struct _ProgressData
+{
+ PyObject *start, *end, *text, *value;
+ PyObject *user_data;
+};
+
+
+static void
+pygimp_init_proc(void)
+{
+ PyObject *r;
+
+ r = PyObject_CallFunction(callbacks[0], "()");
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_quit_proc(void)
+{
+ PyObject *r;
+
+ r = PyObject_CallFunction(callbacks[1], "()");
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_query_proc(void)
+{
+ PyObject *r;
+
+ r = PyObject_CallFunction(callbacks[2], "()");
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_run_proc(const char *name, int nparams, const GimpParam *params,
+ int *nreturn_vals, GimpParam **return_vals)
+{
+ PyObject *args, *ret;
+ GimpParamDef *pd, *rv;
+ GimpPDBProcType t;
+ char *b, *h, *a, *c, *d;
+ int np, nrv;
+
+ gimp_procedural_db_proc_info(name, &b, &h, &a, &c, &d, &t, &np, &nrv,
+ &pd, &rv);
+ g_free(b); g_free(h); g_free(a); g_free(c); g_free(d); g_free(pd);
+
+#if PG_DEBUG > 0
+ g_printerr("Params for %s:", name);
+ print_GParam(nparams, params);
+#endif
+
+ args = pygimp_param_to_tuple(nparams, params);
+
+ if (args == NULL) {
+ PyErr_Clear();
+
+ *nreturn_vals = 1;
+ *return_vals = g_new(GimpParam, 1);
+ (*return_vals)[0].type = GIMP_PDB_STATUS;
+ (*return_vals)[0].data.d_status = GIMP_PDB_CALLING_ERROR;
+
+ return;
+ }
+
+ ret = PyObject_CallFunction(callbacks[3], "(sO)", name, args);
+ Py_DECREF(args);
+
+ if (ret == NULL) {
+ PyErr_Print();
+ PyErr_Clear();
+
+ *nreturn_vals = 1;
+ *return_vals = g_new(GimpParam, 1);
+ (*return_vals)[0].type = GIMP_PDB_STATUS;
+ (*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ return;
+ }
+
+ *return_vals = pygimp_param_from_tuple(ret, rv, nrv);
+ g_free(rv);
+
+ if (*return_vals == NULL) {
+ PyErr_Clear();
+
+ *nreturn_vals = 1;
+ *return_vals = g_new(GimpParam, 1);
+ (*return_vals)[0].type = GIMP_PDB_STATUS;
+ (*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
+
+ return;
+ }
+
+ Py_DECREF(ret);
+
+ *nreturn_vals = nrv + 1;
+ (*return_vals)[0].type = GIMP_PDB_STATUS;
+ (*return_vals)[0].data.d_status = GIMP_PDB_SUCCESS;
+}
+
+static PyObject *
+pygimp_main(PyObject *self, PyObject *args)
+{
+ PyObject *av;
+ int argc, i;
+ char **argv;
+ PyObject *ip; // init proc
+ PyObject *qp; // quit proc
+ PyObject *query; // query proc
+ PyObject *rp; // run proc
+
+ if (!PyArg_ParseTuple(args, "OOOO:main", &ip, &qp, &query, &rp))
+ return NULL;
+
+#define Arg_Check(v) (PyCallable_Check(v) || (v) == Py_None)
+
+ if (!Arg_Check(ip) || !Arg_Check(qp) || !Arg_Check(query) ||
+ !Arg_Check(rp)) {
+ PyErr_SetString(pygimp_error, "arguments must be callable");
+ return NULL;
+ }
+
+#undef Arg_Check
+
+ if (query == Py_None) {
+ PyErr_SetString(pygimp_error, "a query procedure must be provided");
+ return NULL;
+ }
+
+ if (ip != Py_None) {
+ callbacks[0] = ip;
+ PLUG_IN_INFO.init_proc = pygimp_init_proc;
+ }
+
+ if (qp != Py_None) {
+ callbacks[1] = qp;
+ PLUG_IN_INFO.quit_proc = pygimp_quit_proc;
+ }
+
+ if (query != Py_None) {
+ callbacks[2] = query;
+ PLUG_IN_INFO.query_proc = pygimp_query_proc;
+ }
+
+ if (rp != Py_None) {
+ callbacks[3] = rp;
+ PLUG_IN_INFO.run_proc = pygimp_run_proc;
+ }
+
+ av = PySys_GetObject("argv");
+
+ argc = PyList_Size(av);
+ argv = g_new(char *, argc);
+
+ for (i = 0; i < argc; i++)
+ argv[i] = g_strdup(PyString_AsString(PyList_GetItem(av, i)));
+
+ gimp_main(&PLUG_IN_INFO, argc, argv);
+
+ if (argv != NULL) {
+ for (i = 0; i < argc; i++)
+ if (argv[i] != NULL)
+ g_free(argv[i]);
+
+ g_free(argv);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_quit(PyObject *self)
+{
+ gimp_quit();
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_message(PyObject *self, PyObject *args)
+{
+ char *msg;
+
+ if (!PyArg_ParseTuple(args, "s:message", &msg))
+ return NULL;
+
+ gimp_message(msg);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_exit(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ gboolean force = FALSE;
+ int nreturn_vals;
+ GimpParam *return_vals;
+
+ static char *kwlist[] = { "force", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:exit", kwlist, &force))
+ return NULL;
+
+ return_vals = gimp_run_procedure("gimp-quit",
+ &nreturn_vals,
+ GIMP_PDB_INT32, force,
+ GIMP_PDB_END);
+
+ if (return_vals[0].data.d_status != GIMP_PDB_SUCCESS) {
+ PyErr_SetString(pygimp_error, "error while exiting");
+ return NULL;
+ }
+
+ gimp_destroy_params(return_vals, nreturn_vals);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_set_data(PyObject *self, PyObject *args)
+{
+ char *id, *data;
+ int bytes, nreturn_vals;
+ GimpParam *return_vals;
+
+ if (!PyArg_ParseTuple(args, "ss#:set_data", &id, &data, &bytes))
+ return NULL;
+
+ return_vals = gimp_run_procedure("gimp-procedural-db-set-data",
+ &nreturn_vals,
+ GIMP_PDB_STRING, id,
+ GIMP_PDB_INT32, bytes,
+ GIMP_PDB_INT8ARRAY, data,
+ GIMP_PDB_END);
+
+ if (return_vals[0].data.d_status != GIMP_PDB_SUCCESS) {
+ PyErr_SetString(pygimp_error, "error occurred while storing");
+ return NULL;
+ }
+
+ gimp_destroy_params(return_vals, nreturn_vals);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_get_data(PyObject *self, PyObject *args)
+{
+ char *id;
+ int nreturn_vals;
+ GimpParam *return_vals;
+ PyObject *s;
+
+ if (!PyArg_ParseTuple(args, "s:get_data", &id))
+ return NULL;
+
+ return_vals = gimp_run_procedure("gimp-procedural-db-get-data",
+ &nreturn_vals,
+ GIMP_PDB_STRING, id,
+ GIMP_PDB_END);
+
+ if (return_vals[0].data.d_status != GIMP_PDB_SUCCESS) {
+ PyErr_SetString(pygimp_error, "no data for id");
+ return NULL;
+ }
+
+ s = PyString_FromStringAndSize((char *)return_vals[2].data.d_int8array,
+ return_vals[1].data.d_int32);
+ gimp_destroy_params(return_vals, nreturn_vals);
+
+ return s;
+}
+
+static PyObject *
+pygimp_progress_init(PyObject *self, PyObject *args)
+{
+ char *msg = NULL;
+
+ if (!PyArg_ParseTuple(args, "|s:progress_init", &msg))
+ return NULL;
+
+ gimp_progress_init(msg);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_progress_update(PyObject *self, PyObject *args)
+{
+ double p;
+
+ if (!PyArg_ParseTuple(args, "d:progress_update", &p))
+ return NULL;
+
+ gimp_progress_update(p);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static void
+pygimp_progress_start(const gchar *message, gboolean cancelable, gpointer data)
+{
+ ProgressData *pdata = data;
+ PyObject *r;
+
+ if (pdata->user_data) {
+ r = PyObject_CallFunction(pdata->start, "siO", message, cancelable,
+ pdata->user_data);
+ Py_DECREF(pdata->user_data);
+ } else
+ r = PyObject_CallFunction(pdata->start, "si", message, cancelable);
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_progress_end(gpointer data)
+{
+ ProgressData *pdata = data;
+ PyObject *r;
+
+ if (pdata->user_data) {
+ r = PyObject_CallFunction(pdata->end, "O", pdata->user_data);
+ Py_DECREF(pdata->user_data);
+ } else
+ r = PyObject_CallFunction(pdata->end, NULL);
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_progress_text(const gchar *message, gpointer data)
+{
+ ProgressData *pdata = data;
+ PyObject *r;
+
+ if (pdata->user_data) {
+ r = PyObject_CallFunction(pdata->text, "sO", message, pdata->user_data);
+ Py_DECREF(pdata->user_data);
+ } else
+ r = PyObject_CallFunction(pdata->text, "s", message);
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static void
+pygimp_progress_value(gdouble percentage, gpointer data)
+{
+ ProgressData *pdata = data;
+ PyObject *r;
+
+ if (pdata->user_data) {
+ r = PyObject_CallFunction(pdata->value, "dO", percentage,
+ pdata->user_data);
+ Py_DECREF(pdata->user_data);
+ } else
+ r = PyObject_CallFunction(pdata->value, "d", percentage);
+
+ if (!r) {
+ PyErr_Print();
+ PyErr_Clear();
+ return;
+ }
+
+ Py_DECREF(r);
+}
+
+static PyObject *
+pygimp_progress_install(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ GimpProgressVtable vtable = { 0, };
+ const gchar *ret;
+ ProgressData *pdata;
+ static char *kwlist[] = { "start", "end", "text", "value", "data", NULL };
+
+ pdata = g_new0(ProgressData, 1);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO|O:progress_install",
+ kwlist,
+ &pdata->start, &pdata->end,
+ &pdata->text, &pdata->value,
+ &pdata->user_data))
+ goto cleanup;
+
+#define PROCESS_FUNC(n) G_STMT_START { \
+ if (!PyCallable_Check(pdata->n)) { \
+ PyErr_SetString(pygimp_error, #n "argument must be callable"); \
+ goto cleanup; \
+ } \
+ Py_INCREF(pdata->n); \
+} G_STMT_END
+
+ PROCESS_FUNC(start);
+ PROCESS_FUNC(end);
+ PROCESS_FUNC(text);
+ PROCESS_FUNC(value);
+
+ Py_XINCREF(pdata->user_data);
+
+#undef PROCESS_FUNC
+
+ vtable.start = pygimp_progress_start;
+ vtable.end = pygimp_progress_end;
+ vtable.set_text = pygimp_progress_text;
+ vtable.set_value = pygimp_progress_value;
+
+ ret = gimp_progress_install_vtable(&vtable, pdata);
+
+ if (!ret) {
+ PyErr_SetString(pygimp_error,
+ "error occurred while installing progress functions");
+
+ Py_DECREF(pdata->start);
+ Py_DECREF(pdata->end);
+ Py_DECREF(pdata->text);
+ Py_DECREF(pdata->value);
+
+ goto cleanup;
+ }
+
+ return PyString_FromString(ret);
+
+cleanup:
+ g_free(pdata);
+ return NULL;
+}
+
+static PyObject *
+pygimp_progress_uninstall(PyObject *self, PyObject *args)
+{
+ ProgressData *pdata;
+ gchar *callback;
+
+ if (!PyArg_ParseTuple(args, "s:progress_uninstall", &callback))
+ return NULL;
+
+ pdata = gimp_progress_uninstall(callback);
+
+ if (!pdata) {
+ PyErr_SetString(pygimp_error,
+ "error occurred while uninstalling progress functions");
+ return NULL;
+ }
+
+ Py_DECREF(pdata->start);
+ Py_DECREF(pdata->end);
+ Py_DECREF(pdata->text);
+ Py_DECREF(pdata->value);
+
+ Py_XDECREF(pdata->user_data);
+
+ g_free(pdata);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_image_list(PyObject *self)
+{
+ gint32 *imgs;
+ int nimgs, i;
+ PyObject *ret;
+
+ imgs = gimp_image_list(&nimgs);
+ ret = PyList_New(nimgs);
+
+ for (i = 0; i < nimgs; i++)
+ PyList_SetItem(ret, i, (PyObject *)pygimp_image_new(imgs[i]));
+
+ g_free(imgs);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_install_procedure(PyObject *self, PyObject *args)
+{
+ char *name, *blurb, *help, *author, *copyright, *date, *menu_path,
+ *image_types, *n, *d;
+ GimpParamDef *params, *return_vals;
+ int type, nparams, nreturn_vals, i;
+ PyObject *pars, *rets;
+
+ if (!PyArg_ParseTuple(args, "sssssszziOO:install_procedure",
+ &name, &blurb, &help,
+ &author, &copyright, &date, &menu_path, &image_types,
+ &type, &pars, &rets))
+ return NULL;
+
+ if (!PySequence_Check(pars) || !PySequence_Check(rets)) {
+ PyErr_SetString(PyExc_TypeError, "last two args must be sequences");
+ return NULL;
+ }
+
+ nparams = PySequence_Length(pars);
+ nreturn_vals = PySequence_Length(rets);
+ params = g_new(GimpParamDef, nparams);
+
+ for (i = 0; i < nparams; i++) {
+ if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
+ &(params[i].type), &n, &d)) {
+ g_free(params);
+ return NULL;
+ }
+
+ params[i].name = g_strdup(n);
+ params[i].description = g_strdup(d);
+ }
+
+ return_vals = g_new(GimpParamDef, nreturn_vals);
+
+ for (i = 0; i < nreturn_vals; i++) {
+ if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
+ &(return_vals[i].type), &n, &d)) {
+ g_free(params); g_free(return_vals);
+ return NULL;
+ }
+
+ return_vals[i].name = g_strdup(n);
+ return_vals[i].description = g_strdup(d);
+ }
+
+ gimp_install_procedure(name, blurb, help, author, copyright, date,
+ menu_path, image_types, type, nparams, nreturn_vals,
+ params, return_vals);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_install_temp_proc(PyObject *self, PyObject *args)
+{
+ char *name, *blurb, *help, *author, *copyright, *date, *menu_path,
+ *image_types, *n, *d;
+ GimpParamDef *params, *return_vals;
+ int type, nparams, nreturn_vals, i;
+ PyObject *pars, *rets;
+
+ if (!PyArg_ParseTuple(args, "sssssszziOO:install_temp_proc",
+ &name, &blurb, &help,
+ &author, &copyright, &date, &menu_path, &image_types,
+ &type, &pars, &rets))
+ return NULL;
+
+ if (!PySequence_Check(pars) || !PySequence_Check(rets)) {
+ PyErr_SetString(PyExc_TypeError, "last two args must be sequences");
+ return NULL;
+ }
+
+ nparams = PySequence_Length(pars);
+ nreturn_vals = PySequence_Length(rets);
+ params = g_new(GimpParamDef, nparams);
+
+ for (i = 0; i < nparams; i++) {
+ if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
+ &(params[i].type), &n, &d)) {
+ g_free(params);
+ return NULL;
+ }
+
+ params[i].name = g_strdup(n);
+ params[i].description = g_strdup(d);
+ }
+
+ return_vals = g_new(GimpParamDef, nreturn_vals);
+
+ for (i = 0; i < nreturn_vals; i++) {
+ if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
+ &(return_vals[i].type), &n, &d)) {
+ g_free(params); g_free(return_vals);
+ return NULL;
+ }
+
+ return_vals[i].name = g_strdup(n);
+ return_vals[i].description = g_strdup(d);
+ }
+
+ gimp_install_temp_proc(name, blurb, help, author, copyright, date,
+ menu_path, image_types, type,
+ nparams, nreturn_vals, params, return_vals,
+ pygimp_run_proc);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_uninstall_temp_proc(PyObject *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:uninstall_temp_proc", &name))
+ return NULL;
+
+ gimp_uninstall_temp_proc(name);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_register_magic_load_handler(PyObject *self, PyObject *args)
+{
+ char *name, *extensions, *prefixes, *magics;
+
+ if (!PyArg_ParseTuple(args, "ssss:register_magic_load_handler",
+ &name, &extensions, &prefixes, &magics))
+ return NULL;
+
+ gimp_register_magic_load_handler(name, extensions, prefixes, magics);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_register_load_handler(PyObject *self, PyObject *args)
+{
+ char *name, *extensions, *prefixes;
+
+ if (!PyArg_ParseTuple(args, "sss:register_load_handler",
+ &name, &extensions, &prefixes))
+ return NULL;
+
+ gimp_register_load_handler(name, extensions, prefixes);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_register_save_handler(PyObject *self, PyObject *args)
+{
+ char *name, *extensions, *prefixes;
+
+ if (!PyArg_ParseTuple(args, "sss:register_save_handler",
+ &name, &extensions, &prefixes))
+ return NULL;
+
+ gimp_register_save_handler(name, extensions, prefixes);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_domain_register(PyObject *self, PyObject *args)
+{
+ char *name, *path = NULL;
+
+ if (!PyArg_ParseTuple(args, "s|s:domain_register", &name, &path))
+ return NULL;
+
+ gimp_plugin_domain_register(name, path);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_menu_register(PyObject *self, PyObject *args)
+{
+ char *name, *path;
+
+ if (!PyArg_ParseTuple(args, "ss:menu_register", &name, &path))
+ return NULL;
+
+ gimp_plugin_menu_register(name, path);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_gamma(PyObject *self)
+{
+ return PyFloat_FromDouble(gimp_gamma());
+}
+
+static PyObject *
+pygimp_gtkrc(PyObject *self)
+{
+ return PyString_FromString(gimp_gtkrc());
+}
+
+static PyObject *
+pygimp_personal_rc_file(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *basename, *filename;
+ PyObject *ret;
+
+ static char *kwlist[] = { "basename", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "s:personal_rc_file", kwlist,
+ &basename))
+ return NULL;
+
+ filename = gimp_personal_rc_file(basename);
+ ret = PyString_FromString(filename);
+ g_free(filename);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_context_push(PyObject *self)
+{
+ gimp_context_push();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_context_pop(PyObject *self)
+{
+ gimp_context_pop();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_get_background(PyObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_context_get_background(&rgb);
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_get_foreground(PyObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_context_get_foreground(&rgb);
+ return pygimp_rgb_new(&rgb);
+}
+
+static PyObject *
+pygimp_set_background(PyObject *self, PyObject *args)
+{
+ PyObject *color;
+ GimpRGB rgb;
+
+ if (PyArg_ParseTuple(args, "O:set_background", &color)) {
+ if (!pygimp_rgb_from_pyobject(color, &rgb))
+ return NULL;
+ } else {
+ PyErr_Clear();
+ if (!pygimp_rgb_from_pyobject(args, &rgb))
+ return NULL;
+ }
+
+ gimp_context_set_background(&rgb);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_set_foreground(PyObject *self, PyObject *args)
+{
+ PyObject *color;
+ GimpRGB rgb;
+
+ if (PyArg_ParseTuple(args, "O:set_foreground", &color)) {
+ if (!pygimp_rgb_from_pyobject(color, &rgb))
+ return NULL;
+ } else {
+ PyErr_Clear();
+ if (!pygimp_rgb_from_pyobject(args, &rgb))
+ return NULL;
+ }
+
+ gimp_context_set_foreground(&rgb);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_gradients_get_list(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char **list, *filter = NULL;
+ int num, i;
+ PyObject *ret;
+
+ static char *kwlist[] = { "filter", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|s:gradients_get_list", kwlist,
+ &filter))
+ return NULL;
+
+ list = gimp_gradients_get_list(filter, &num);
+
+ ret = PyList_New(num);
+
+ for (i = 0; i < num; i++) {
+ PyList_SetItem(ret, i, PyString_FromString(list[i]));
+ }
+
+ g_strfreev(list);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_context_get_gradient(PyObject *self)
+{
+ char *name;
+ PyObject *ret;
+
+ name = gimp_context_get_gradient();
+ ret = PyString_FromString(name);
+ g_free(name);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_gradients_get_gradient(PyObject *self)
+{
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimp.context_get_gradient") < 0)
+ return NULL;
+
+ return pygimp_context_get_gradient(self);
+}
+
+static PyObject *
+pygimp_context_set_gradient(PyObject *self, PyObject *args)
+{
+ char *actv;
+
+ if (!PyArg_ParseTuple(args, "s:gradients_set_gradient", &actv))
+ return NULL;
+
+ gimp_context_set_gradient(actv);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_gradients_set_gradient(PyObject *self, PyObject *args)
+{
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimp.context_set_gradient") < 0)
+ return NULL;
+
+ return pygimp_context_set_gradient(self, args);
+}
+
+static PyObject *
+pygimp_gradient_get_uniform_samples(PyObject *self, PyObject *args)
+{
+ int num, reverse = FALSE;
+ char *name;
+ int nsamp;
+ double *samp;
+ int i, j;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, "si|i:gradient_get_uniform_samples",
+ &name, &num, &reverse))
+ return NULL;
+
+ if (!gimp_gradient_get_uniform_samples(name, num, reverse, &nsamp, &samp)) {
+ PyErr_SetString(pygimp_error, "gradient_get_uniform_samples failed");
+ return NULL;
+ }
+
+ ret = PyList_New(num);
+ for (i = 0, j = 0; i < num; i++, j += 4)
+ PyList_SetItem(ret, i, Py_BuildValue("(dddd)", samp[j],
+ samp[j+1], samp[j+2], samp[j+3]));
+
+ g_free(samp);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_gradient_get_custom_samples(PyObject *self, PyObject *args)
+{
+ int num, reverse = FALSE;
+ char *name;
+ int nsamp;
+ double *pos, *samp;
+ int i, j;
+ PyObject *ret, *item;
+ gboolean success;
+
+ if (!PyArg_ParseTuple(args, "sO|i:gradient_get_custom_samples",
+ &name, &ret, &reverse))
+ return NULL;
+
+ if (!PySequence_Check(ret)) {
+ PyErr_SetString(PyExc_TypeError,
+ "second arg must be a sequence");
+ return NULL;
+ }
+
+ num = PySequence_Length(ret);
+ pos = g_new(gdouble, num);
+
+ for (i = 0; i < num; i++) {
+ item = PySequence_GetItem(ret, i);
+
+ if (!PyFloat_Check(item)) {
+ PyErr_SetString(PyExc_TypeError,
+ "second arg must be a sequence of floats");
+ g_free(pos);
+ return NULL;
+ }
+
+ pos[i] = PyFloat_AsDouble(item);
+ }
+
+ success = gimp_gradient_get_custom_samples(name, num, pos, reverse,
+ &nsamp, &samp);
+ g_free(pos);
+
+ if (!success) {
+ PyErr_SetString(pygimp_error, "gradient_get_custom_samples failed");
+ return NULL;
+ }
+
+ ret = PyList_New(num);
+ for (i = 0, j = 0; i < num; i++, j += 4)
+ PyList_SetItem(ret, i, Py_BuildValue("(dddd)", samp[j],
+ samp[j+1], samp[j+2], samp[j+3]));
+
+ g_free(samp);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_gradients_sample_uniform(PyObject *self, PyObject *args)
+{
+ char *name;
+ PyObject *arg_list, *str, *new_args, *ret;
+
+ if (PyErr_Warn(PyExc_DeprecationWarning,
+ "use gimp.gradient_get_uniform_samples") < 0)
+ return NULL;
+
+ arg_list = PySequence_List(args);
+
+ name = gimp_context_get_gradient();
+
+ str = PyString_FromString(name);
+ g_free(name);
+
+ PyList_Insert(arg_list, 0, str);
+ Py_XDECREF(str);
+
+ new_args = PyList_AsTuple(arg_list);
+ Py_XDECREF(arg_list);
+
+ ret = pygimp_gradient_get_uniform_samples(self, new_args);
+ Py_XDECREF(new_args);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_gradients_sample_custom(PyObject *self, PyObject *args)
+{
+ char *name;
+ PyObject *arg_list, *str, *new_args, *ret;
+
+ if (PyErr_Warn(PyExc_DeprecationWarning,
+ "use gimp.gradient_get_custom_samples") < 0)
+ return NULL;
+
+ arg_list = PySequence_List(args);
+
+ name = gimp_context_get_gradient();
+
+ str = PyString_FromString(name);
+ g_free(name);
+
+ PyList_Insert(arg_list, 0, str);
+ Py_XDECREF(str);
+
+ new_args = PyList_AsTuple(arg_list);
+ Py_XDECREF(arg_list);
+
+ ret = pygimp_gradient_get_custom_samples(self, new_args);
+
+ return ret;
+}
+
+static PyObject *
+pygimp_delete(PyObject *self, PyObject *args)
+{
+ PyGimpImage *img;
+
+ if (!PyArg_ParseTuple(args, "O:delete", &img))
+ return NULL;
+
+ if (pygimp_image_check(img))
+ gimp_image_delete(img->ID);
+ else if (pygimp_drawable_check(img))
+ gimp_item_delete(img->ID);
+ else if (pygimp_display_check(img))
+ gimp_display_delete(img->ID);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+pygimp_displays_flush(PyObject *self)
+{
+ gimp_displays_flush();
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_displays_reconnect(PyObject *self, PyObject *args)
+{
+ PyGimpImage *old_img, *new_img;
+
+ if (!PyArg_ParseTuple(args, "O!O!:displays_reconnect",
+ &PyGimpImage_Type, &old_img,
+ &PyGimpImage_Type, &new_img))
+ return NULL;
+
+ if (!gimp_displays_reconnect (old_img->ID, new_img->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not reconnect the displays of image (ID %d) "
+ "to image (ID %d)",
+ old_img->ID, new_img->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_tile_cache_size(PyObject *self, PyObject *args)
+{
+ unsigned long k;
+
+ if (!PyArg_ParseTuple(args, "l:tile_cache_size", &k))
+ return NULL;
+
+ gimp_tile_cache_size(k);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+pygimp_tile_cache_ntiles(PyObject *self, PyObject *args)
+{
+ unsigned long n;
+
+ if (!PyArg_ParseTuple(args, "l:tile_cache_ntiles", &n))
+ return NULL;
+
+ gimp_tile_cache_ntiles(n);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+pygimp_tile_width(PyObject *self)
+{
+ return PyInt_FromLong(gimp_tile_width());
+}
+
+
+static PyObject *
+pygimp_tile_height(PyObject *self)
+{
+ return PyInt_FromLong(gimp_tile_height());
+}
+
+static PyObject *
+pygimp_extension_ack(PyObject *self)
+{
+ gimp_extension_ack();
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_extension_enable(PyObject *self)
+{
+ gimp_extension_enable();
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_extension_process(PyObject *self, PyObject *args)
+{
+ guint timeout;
+
+ if (!PyArg_ParseTuple(args, "I:extension_process", &timeout))
+ return NULL;
+
+ gimp_extension_process(timeout);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_parasite_find(PyObject *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
+ return NULL;
+
+ return pygimp_parasite_new(gimp_get_parasite(name));
+}
+
+static PyObject *
+pygimp_parasite_attach(PyObject *self, PyObject *args)
+{
+ PyGimpParasite *parasite;
+
+ if (!PyArg_ParseTuple(args, "O!:parasite_attach",
+ &PyGimpParasite_Type, &parasite))
+ return NULL;
+
+ if (!gimp_attach_parasite(parasite->para)) {
+ PyErr_Format(pygimp_error, "could not attach parasite '%s'",
+ gimp_parasite_name(parasite->para));
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_attach_new_parasite(PyObject *self, PyObject *args)
+{
+ GimpParasite *parasite;
+ char *name, *data;
+ int flags, size;
+
+ if (!PyArg_ParseTuple(args, "sis#:attach_new_parasite", &name, &flags,
+ &data, &size))
+ return NULL;
+
+ parasite = gimp_parasite_new (name, flags, size, data);
+
+ if (!gimp_attach_parasite (parasite)) {
+ PyErr_Format(pygimp_error, "could not attach new parasite '%s'", name);
+ gimp_parasite_free (parasite);
+ return NULL;
+ }
+
+ gimp_parasite_free (parasite);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_parasite_detach(PyObject *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_detach", &name))
+ return NULL;
+
+ if (!gimp_detach_parasite(name)) {
+ PyErr_Format(pygimp_error, "could not detach parasite '%s'", name);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_parasite_list(PyObject *self)
+{
+ gint num_parasites;
+ gchar **parasites;
+ PyObject *ret;
+ gint i;
+
+ parasites = gimp_get_parasite_list (&num_parasites);
+
+ ret = PyTuple_New(num_parasites);
+
+ for (i = 0; i < num_parasites; i++)
+ PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
+
+ g_strfreev(parasites);
+ return ret;
+}
+
+static PyObject *
+pygimp_show_tool_tips(PyObject *self)
+{
+ return PyBool_FromLong(gimp_show_tool_tips());
+}
+
+static PyObject *
+pygimp_show_help_button(PyObject *self)
+{
+ return PyBool_FromLong(gimp_show_help_button());
+}
+
+static PyObject *
+pygimp_check_size(PyObject *self)
+{
+ return PyInt_FromLong(gimp_check_size());
+}
+
+static PyObject *
+pygimp_check_type(PyObject *self)
+{
+ return PyInt_FromLong(gimp_check_type());
+}
+
+static PyObject *
+pygimp_default_display(PyObject *self)
+{
+ return pygimp_display_new(gimp_default_display());
+}
+
+static PyObject *
+pygimp_wm_class(PyObject *self)
+{
+ return PyString_FromString(gimp_wm_class());
+}
+
+static PyObject *
+pygimp_display_name(PyObject *self)
+{
+ return PyString_FromString(gimp_display_name());
+}
+
+static PyObject *
+pygimp_monitor_number(PyObject *self)
+{
+ return PyInt_FromLong(gimp_monitor_number());
+}
+
+static PyObject *
+pygimp_get_progname(PyObject *self)
+{
+ return PyString_FromString(gimp_get_progname());
+}
+
+static PyObject *
+pygimp_user_directory(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ GimpUserDirectory type;
+ const char *user_dir;
+ PyObject *py_type, *ret;
+
+ static char *kwlist[] = { "type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:user_directory", kwlist,
+ &py_type))
+ return NULL;
+
+ if (pyg_enum_get_value(GIMP_TYPE_USER_DIRECTORY, py_type, (gpointer)&type))
+ return NULL;
+
+ /* GimpUserDirectory and GUserDirectory are compatible */
+ user_dir = g_get_user_special_dir((GUserDirectory)type);
+
+ if (user_dir) {
+ ret = PyString_FromString(user_dir);
+ } else {
+ Py_INCREF(Py_None);
+ ret = Py_None;
+ }
+
+ return ret;
+}
+
+static PyObject *
+pygimp_fonts_refresh(PyObject *self)
+{
+ if (!gimp_fonts_refresh()) {
+ PyErr_SetString(pygimp_error, "could not refresh fonts");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_checks_get_shades(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ int type;
+ guchar light, dark;
+ static char *kwlist[] = { "type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "i:checks_get_shades", kwlist,
+ &type))
+ return NULL;
+
+ if (type < GIMP_CHECK_TYPE_LIGHT_CHECKS ||
+ type > GIMP_CHECK_TYPE_BLACK_ONLY) {
+ PyErr_SetString(PyExc_ValueError, "Invalid check type");
+ return NULL;
+ }
+
+ gimp_checks_get_shades(type, &light, &dark);
+
+ return Py_BuildValue("(ii)", light, dark);
+}
+
+static PyObject *
+pygimp_fonts_get_list(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char **list, *filter = NULL;
+ int num, i;
+ PyObject *ret;
+
+ static char *kwlist[] = { "filter", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|s:fonts_get_list", kwlist,
+ &filter))
+ return NULL;
+
+ list = gimp_fonts_get_list(filter, &num);
+
+ if (num == 0) {
+ PyErr_SetString(pygimp_error, "could not get font list");
+ return NULL;
+ }
+
+ ret = PyList_New(num);
+
+ for (i = 0; i < num; i++) {
+ PyList_SetItem(ret, i, PyString_FromString(list[i]));
+ }
+
+ g_strfreev(list);
+
+ return ret;
+}
+
+static PyObject *
+vectors_to_objects(int num_vectors, int *vectors)
+{
+ PyObject *ret;
+ int i;
+
+ ret = PyList_New(num_vectors);
+ if (ret == NULL)
+ goto done;
+
+ for (i = 0; i < num_vectors; i++)
+ PyList_SetItem(ret, i, pygimp_vectors_new(vectors[i]));
+
+done:
+ g_free(vectors);
+ return ret;
+}
+
+static PyObject *
+pygimp_vectors_import_from_file(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ PyObject *py_file;
+ gboolean merge = FALSE, scale = FALSE;
+ int *vectors, num_vectors;
+ gboolean success;
+
+ static char *kwlist[] = { "image", "svg_file", "merge", "scale", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!O|ii:vectors_import_from_file", kwlist,
+ &PyGimpImage_Type, &img, &py_file,
+ &merge, &scale))
+ return NULL;
+
+ if (PyString_Check(py_file)) {
+ success = gimp_vectors_import_from_file(img->ID,
+ PyString_AsString(py_file),
+ merge, scale,
+ &num_vectors, &vectors);
+ } else {
+ PyObject *chunk_size, *buffer, *read_method;
+
+ chunk_size = PyInt_FromLong(16 * 1024);
+ if (chunk_size == NULL)
+ return NULL;
+
+ buffer = PyString_FromString("");
+ if (buffer == NULL) {
+ Py_DECREF(chunk_size);
+ return NULL;
+ }
+
+ read_method = PyString_FromString("read");
+ if (read_method == NULL || !PyCallable_Check(read_method)) {
+ Py_XDECREF(read_method);
+ PyErr_SetString(PyExc_TypeError,
+ "svg_file must be an object that has a \"read\" "
+ "method, or a filename (str)");
+ return NULL;
+ }
+
+ while (1) {
+ PyObject *chunk;
+ chunk = PyObject_CallMethodObjArgs(py_file, read_method,
+ chunk_size, NULL);
+
+ if (!chunk || !PyString_Check(chunk)) {
+ Py_XDECREF(chunk);
+ Py_DECREF(chunk_size);
+ Py_DECREF(buffer);
+ Py_DECREF(read_method);
+ return NULL;
+ }
+
+ if (PyString_GET_SIZE(chunk) != 0) {
+ PyString_ConcatAndDel(&buffer, chunk);
+ if (buffer == NULL) {
+ Py_DECREF(chunk_size);
+ Py_DECREF(read_method);
+ return NULL;
+ }
+ } else {
+ Py_DECREF(chunk);
+ break;
+ }
+ }
+
+ success = gimp_vectors_import_from_string(img->ID,
+ PyString_AsString(buffer),
+ PyString_Size(buffer),
+ merge, scale,
+ &num_vectors, &vectors);
+
+ Py_DECREF(chunk_size);
+ Py_DECREF(buffer);
+ Py_DECREF(read_method);
+ }
+
+ if (!success) {
+ PyErr_Format(pygimp_error,
+ "Vectors import failed: %s", gimp_get_pdb_error());
+ return NULL;
+ }
+
+ return vectors_to_objects(num_vectors, vectors);
+}
+
+static PyObject *
+pygimp_vectors_import_from_string(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ const char *svg_string;
+ int length;
+ gboolean merge = FALSE, scale = FALSE;
+ int *vectors, num_vectors;
+ gboolean success;
+
+ static char *kwlist[] = { "image", "svg_string", "merge", "scale", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!s#|ii:vectors_import_from_string", kwlist,
+ &PyGimpImage_Type, &img,
+ &svg_string, &length,
+ &merge, &scale))
+ return NULL;
+
+ success = gimp_vectors_import_from_string(img->ID, svg_string, length,
+ merge, scale,
+ &num_vectors, &vectors);
+
+ if (!success) {
+ PyErr_Format(pygimp_error,
+ "Vectors import failed: %s", gimp_get_pdb_error());
+ return NULL;
+ }
+
+ return vectors_to_objects(num_vectors, vectors);
+}
+
+static PyObject *
+id2image(PyObject *self, PyObject *args)
+{
+ int id;
+
+ if (!PyArg_ParseTuple(args, "i:_id2image", &id))
+ return NULL;
+
+ if (id >= 0)
+ return pygimp_image_new(id);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+id2drawable(PyObject *self, PyObject *args)
+{
+ int id;
+
+ if (!PyArg_ParseTuple(args, "i:_id2drawable", &id))
+ return NULL;
+
+ if (id >= 0)
+ return pygimp_drawable_new(NULL, id);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+id2display(PyObject *self, PyObject *args)
+{
+ int id;
+
+ if (!PyArg_ParseTuple(args, "i:_id2display", &id))
+ return NULL;
+
+ if (id >= 0)
+ return pygimp_display_new(id);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+id2vectors(PyObject *self, PyObject *args)
+{
+ int id;
+
+ if (!PyArg_ParseTuple(args, "i:_id2vectors", &id))
+ return NULL;
+
+ if (id >= 0)
+ return pygimp_vectors_new(id);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+pygimp_export_image (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ PyGimpDrawable *drw = NULL;
+ gchar *format_name = NULL;
+ unsigned int capabilities = -1;
+ GimpExportReturn result;
+ gint32 img_id;
+ gint32 drw_id;
+ PyObject *return_values;
+
+ static char *kwlist[] = { "image", "drawable", "format_name", "capabilities", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|OsI:export_image", kwlist,
+ &PyGimpImage_Type, &img,
+ &drw,
+ &format_name,
+ &capabilities))
+ return NULL;
+ if (capabilities == -1) {
+ PyErr_SetString(PyExc_TypeError,
+ "the \"capabilities\" (4th) parameter must be set with "
+ "a combination of the "
+ "EXPORT_CAN_HANDLE_*/EXPORT_NEEDS_ALPHA values. "
+ "(check developer documentation on the C function "
+ "gimp_export_image for details)"
+ );
+ return NULL;
+ }
+
+ /* If no drawable is given, assume the active drawable */
+ if (drw == NULL) {
+ drw = (PyGimpDrawable *)PyObject_GetAttrString((PyObject *)img,
+ "active_drawable");
+ if ((PyObject *)drw == Py_None) {
+ PyErr_SetString(PyExc_ValueError,
+ "No active drawable in the image and no drawable "
+ " specified for export."
+ );
+ return NULL;
+ }
+ }
+ img_id = img->ID;
+ drw_id = drw->ID;
+
+ result = gimp_export_image(&img_id, &drw_id, format_name, capabilities);
+
+ if (img_id != img->ID) {
+ img = (PyGimpImage *)pygimp_image_new(img_id);
+ }
+ else {
+ Py_INCREF(img);
+ }
+ if (drw_id != drw->ID) {
+ drw = (PyGimpDrawable *)pygimp_drawable_new(NULL, drw_id);
+ }
+ else {
+ Py_INCREF(drw);
+ }
+
+ return_values = PyTuple_New(3);
+ PyTuple_SetItem(return_values, 0, PyInt_FromLong(result));
+ PyTuple_SetItem(return_values, 1, (PyObject *)img);
+ PyTuple_SetItem(return_values, 2, (PyObject *)drw);
+
+ return return_values;
+}
+
+static PyObject *
+pygimp_export_dialog_new (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *format_name;
+ gchar *role = NULL;
+ gchar *help_id = NULL;
+ GtkWidget *dialog = NULL;
+
+ static char *kwlist[] = { "format_name", "role", "help_id", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|ss:export_dialog", kwlist,
+ &format_name,
+ &role,
+ &help_id))
+ return NULL;
+
+ if (role == NULL) {
+ role = "gimp_export_image";
+ }
+
+ dialog = gimp_export_dialog_new(format_name, role, help_id);
+
+ /* pyobject_new handles NULL values */
+
+ return pygobject_new((GObject *)dialog);
+
+}
+
+/* No need to expose "gimp_export_dialog_get_content_area",
+ * because one just have to call the "get_content_area" method
+ * on the returned export_dialog
+ */
+
+
+/* List of methods defined in the module */
+
+static struct PyMethodDef gimp_methods[] = {
+ {"main", (PyCFunction)pygimp_main, METH_VARARGS},
+ {"quit", (PyCFunction)pygimp_quit, METH_NOARGS},
+ {"message", (PyCFunction)pygimp_message, METH_VARARGS},
+ {"exit", (PyCFunction)pygimp_exit, METH_VARARGS | METH_KEYWORDS},
+ {"set_data", (PyCFunction)pygimp_set_data, METH_VARARGS},
+ {"get_data", (PyCFunction)pygimp_get_data, METH_VARARGS},
+ {"progress_init", (PyCFunction)pygimp_progress_init, METH_VARARGS},
+ {"progress_update", (PyCFunction)pygimp_progress_update, METH_VARARGS},
+ {"progress_install", (PyCFunction)pygimp_progress_install, METH_VARARGS | METH_KEYWORDS},
+ {"progress_uninstall", (PyCFunction)pygimp_progress_uninstall, METH_VARARGS},
+ {"image_list", (PyCFunction)pygimp_image_list, METH_NOARGS},
+ {"install_procedure", (PyCFunction)pygimp_install_procedure, METH_VARARGS},
+ {"install_temp_proc", (PyCFunction)pygimp_install_temp_proc, METH_VARARGS},
+ {"uninstall_temp_proc", (PyCFunction)pygimp_uninstall_temp_proc, METH_VARARGS},
+ {"register_magic_load_handler", (PyCFunction)pygimp_register_magic_load_handler, METH_VARARGS},
+ {"register_load_handler", (PyCFunction)pygimp_register_load_handler, METH_VARARGS},
+ {"register_save_handler", (PyCFunction)pygimp_register_save_handler, METH_VARARGS},
+ {"domain_register", (PyCFunction)pygimp_domain_register, METH_VARARGS},
+ {"menu_register", (PyCFunction)pygimp_menu_register, METH_VARARGS},
+ {"gamma", (PyCFunction)pygimp_gamma, METH_NOARGS},
+ {"gtkrc", (PyCFunction)pygimp_gtkrc, METH_NOARGS},
+ {"personal_rc_file", (PyCFunction)pygimp_personal_rc_file, METH_VARARGS | METH_KEYWORDS},
+ {"context_push", (PyCFunction)pygimp_context_push, METH_NOARGS},
+ {"context_pop", (PyCFunction)pygimp_context_pop, METH_NOARGS},
+ {"get_background", (PyCFunction)pygimp_get_background, METH_NOARGS},
+ {"get_foreground", (PyCFunction)pygimp_get_foreground, METH_NOARGS},
+ {"set_background", (PyCFunction)pygimp_set_background, METH_VARARGS},
+ {"set_foreground", (PyCFunction)pygimp_set_foreground, METH_VARARGS},
+ {"gradients_get_list", (PyCFunction)pygimp_gradients_get_list, METH_VARARGS | METH_KEYWORDS},
+ {"context_get_gradient", (PyCFunction)pygimp_context_get_gradient, METH_NOARGS},
+ {"context_set_gradient", (PyCFunction)pygimp_context_set_gradient, METH_VARARGS},
+ {"gradients_get_gradient", (PyCFunction)pygimp_gradients_get_gradient, METH_NOARGS},
+ {"gradients_set_gradient", (PyCFunction)pygimp_gradients_set_gradient, METH_VARARGS},
+ {"gradient_get_uniform_samples", (PyCFunction)pygimp_gradient_get_uniform_samples, METH_VARARGS},
+ {"gradient_get_custom_samples", (PyCFunction)pygimp_gradient_get_custom_samples, METH_VARARGS},
+ {"gradients_sample_uniform", (PyCFunction)pygimp_gradients_sample_uniform, METH_VARARGS},
+ {"gradients_sample_custom", (PyCFunction)pygimp_gradients_sample_custom, METH_VARARGS},
+ {"delete", (PyCFunction)pygimp_delete, METH_VARARGS},
+ {"displays_flush", (PyCFunction)pygimp_displays_flush, METH_NOARGS},
+ {"displays_reconnect", (PyCFunction)pygimp_displays_reconnect, METH_VARARGS},
+ {"tile_cache_size", (PyCFunction)pygimp_tile_cache_size, METH_VARARGS},
+ {"tile_cache_ntiles", (PyCFunction)pygimp_tile_cache_ntiles, METH_VARARGS},
+ {"tile_width", (PyCFunction)pygimp_tile_width, METH_NOARGS},
+ {"tile_height", (PyCFunction)pygimp_tile_height, METH_NOARGS},
+ {"extension_ack", (PyCFunction)pygimp_extension_ack, METH_NOARGS},
+ {"extension_enable", (PyCFunction)pygimp_extension_enable, METH_NOARGS},
+ {"extension_process", (PyCFunction)pygimp_extension_process, METH_VARARGS},
+ {"parasite_find", (PyCFunction)pygimp_parasite_find, METH_VARARGS},
+ {"parasite_attach", (PyCFunction)pygimp_parasite_attach, METH_VARARGS},
+ {"attach_new_parasite",(PyCFunction)pygimp_attach_new_parasite,METH_VARARGS},
+ {"parasite_detach", (PyCFunction)pygimp_parasite_detach, METH_VARARGS},
+ {"parasite_list", (PyCFunction)pygimp_parasite_list, METH_NOARGS},
+ {"show_tool_tips", (PyCFunction)pygimp_show_tool_tips, METH_NOARGS},
+ {"show_help_button", (PyCFunction)pygimp_show_help_button, METH_NOARGS},
+ {"check_size", (PyCFunction)pygimp_check_size, METH_NOARGS},
+ {"check_type", (PyCFunction)pygimp_check_type, METH_NOARGS},
+ {"default_display", (PyCFunction)pygimp_default_display, METH_NOARGS},
+ {"wm_class", (PyCFunction)pygimp_wm_class, METH_NOARGS},
+ {"display_name", (PyCFunction)pygimp_display_name, METH_NOARGS},
+ {"monitor_number", (PyCFunction)pygimp_monitor_number, METH_NOARGS},
+ {"get_progname", (PyCFunction)pygimp_get_progname, METH_NOARGS},
+ {"user_directory", (PyCFunction)pygimp_user_directory, METH_VARARGS | METH_KEYWORDS},
+ {"fonts_refresh", (PyCFunction)pygimp_fonts_refresh, METH_NOARGS},
+ {"fonts_get_list", (PyCFunction)pygimp_fonts_get_list, METH_VARARGS | METH_KEYWORDS},
+ {"checks_get_shades", (PyCFunction)pygimp_checks_get_shades, METH_VARARGS | METH_KEYWORDS},
+ {"vectors_import_from_file", (PyCFunction)pygimp_vectors_import_from_file, METH_VARARGS | METH_KEYWORDS},
+ {"vectors_import_from_string", (PyCFunction)pygimp_vectors_import_from_string, METH_VARARGS | METH_KEYWORDS},
+ {"_id2image", (PyCFunction)id2image, METH_VARARGS},
+ {"_id2drawable", (PyCFunction)id2drawable, METH_VARARGS},
+ {"_id2display", (PyCFunction)id2display, METH_VARARGS},
+ {"_id2vectors", (PyCFunction)id2vectors, METH_VARARGS},
+ {"export_image", (PyCFunction)pygimp_export_image, METH_VARARGS | METH_KEYWORDS},
+ {"export_dialog", (PyCFunction)pygimp_export_dialog_new, METH_VARARGS | METH_KEYWORDS},
+ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
+};
+
+
+static struct _PyGimp_Functions pygimp_api_functions = {
+ &PyGimpImage_Type,
+ pygimp_image_new,
+ &PyGimpDisplay_Type,
+ pygimp_display_new,
+ &PyGimpItem_Type,
+ pygimp_item_new,
+ &PyGimpDrawable_Type,
+ pygimp_drawable_new,
+ &PyGimpLayer_Type,
+ pygimp_layer_new,
+ &PyGimpGroupLayer_Type,
+ pygimp_group_layer_new,
+ &PyGimpChannel_Type,
+ pygimp_channel_new,
+ &PyGimpVectors_Type,
+ pygimp_vectors_new,
+};
+
+
+/* Initialization function for the module (*must* be called initgimp) */
+
+static char gimp_module_documentation[] =
+"This module provides interfaces to allow you to write gimp plug-ins"
+;
+
+void initgimp(void);
+
+PyMODINIT_FUNC
+initgimp(void)
+{
+ PyObject *m;
+
+ PyGimpPDB_Type.ob_type = &PyType_Type;
+ PyGimpPDB_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpPDB_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpPDB_Type) < 0)
+ return;
+
+ PyGimpPDBFunction_Type.ob_type = &PyType_Type;
+ PyGimpPDBFunction_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpPDBFunction_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpPDBFunction_Type) < 0)
+ return;
+
+ PyGimpImage_Type.ob_type = &PyType_Type;
+ PyGimpImage_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpImage_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpImage_Type) < 0)
+ return;
+
+ PyGimpDisplay_Type.ob_type = &PyType_Type;
+ PyGimpDisplay_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpDisplay_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpDisplay_Type) < 0)
+ return;
+
+ PyGimpLayer_Type.ob_type = &PyType_Type;
+ PyGimpLayer_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpLayer_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpLayer_Type) < 0)
+ return;
+
+ PyGimpGroupLayer_Type.ob_type = &PyType_Type;
+ PyGimpGroupLayer_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpGroupLayer_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpGroupLayer_Type) < 0)
+ return;
+
+ PyGimpChannel_Type.ob_type = &PyType_Type;
+ PyGimpChannel_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpChannel_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpChannel_Type) < 0)
+ return;
+
+ PyGimpTile_Type.ob_type = &PyType_Type;
+ PyGimpTile_Type.tp_alloc = PyType_GenericAlloc;
+ if (PyType_Ready(&PyGimpTile_Type) < 0)
+ return;
+
+ PyGimpPixelRgn_Type.ob_type = &PyType_Type;
+ PyGimpPixelRgn_Type.tp_alloc = PyType_GenericAlloc;
+ if (PyType_Ready(&PyGimpPixelRgn_Type) < 0)
+ return;
+
+ PyGimpParasite_Type.ob_type = &PyType_Type;
+ PyGimpParasite_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpParasite_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpParasite_Type) < 0)
+ return;
+
+ PyGimpVectorsStroke_Type.ob_type = &PyType_Type;
+ PyGimpVectorsStroke_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpVectorsStroke_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpVectorsStroke_Type) < 0)
+ return;
+
+ PyGimpVectorsBezierStroke_Type.ob_type = &PyType_Type;
+ PyGimpVectorsBezierStroke_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpVectorsBezierStroke_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpVectorsBezierStroke_Type) < 0)
+ return;
+
+ PyGimpVectors_Type.ob_type = &PyType_Type;
+ PyGimpVectors_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpVectors_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpVectors_Type) < 0)
+ return;
+
+ PyGimpPixelFetcher_Type.ob_type = &PyType_Type;
+ PyGimpPixelFetcher_Type.tp_alloc = PyType_GenericAlloc;
+ PyGimpPixelFetcher_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGimpPixelFetcher_Type) < 0)
+ return;
+
+ pygimp_init_pygobject();
+ init_pygimpcolor();
+
+ /* initialize i18n support */
+ bindtextdomain (GETTEXT_PACKAGE "-python", gimp_locale_directory ());
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset (GETTEXT_PACKAGE "-python", "UTF-8");
+#endif
+
+ /* set the default python encoding to utf-8 */
+ PyUnicode_SetDefaultEncoding("utf-8");
+
+ /* initialize gegl */
+ gegl_init(0, NULL);
+
+ /* Create the module and add the functions */
+ m = Py_InitModule4("gimp", gimp_methods,
+ gimp_module_documentation,
+ NULL, PYTHON_API_VERSION);
+
+ /* Add some symbolic constants to the module */
+ pygimp_error = PyErr_NewException("gimp.error", PyExc_RuntimeError, NULL);
+ PyModule_AddObject(m, "error", pygimp_error);
+
+ PyModule_AddObject(m, "pdb", pygimp_pdb_new());
+
+ /* export the types used in gimpmodule */
+ Py_INCREF(&PyGimpImage_Type);
+ PyModule_AddObject(m, "Image", (PyObject *)&PyGimpImage_Type);
+
+ Py_INCREF(&PyGimpItem_Type);
+ PyModule_AddObject(m, "Item", (PyObject *)&PyGimpItem_Type);
+
+ Py_INCREF(&PyGimpDrawable_Type);
+ PyModule_AddObject(m, "Drawable", (PyObject *)&PyGimpDrawable_Type);
+
+ Py_INCREF(&PyGimpLayer_Type);
+ PyModule_AddObject(m, "Layer", (PyObject *)&PyGimpLayer_Type);
+
+ Py_INCREF(&PyGimpGroupLayer_Type);
+ PyModule_AddObject(m, "GroupLayer", (PyObject *)&PyGimpGroupLayer_Type);
+
+ Py_INCREF(&PyGimpChannel_Type);
+ PyModule_AddObject(m, "Channel", (PyObject *)&PyGimpChannel_Type);
+
+ Py_INCREF(&PyGimpDisplay_Type);
+ PyModule_AddObject(m, "Display", (PyObject *)&PyGimpDisplay_Type);
+
+ Py_INCREF(&PyGimpTile_Type);
+ PyModule_AddObject(m, "Tile", (PyObject *)&PyGimpTile_Type);
+
+ Py_INCREF(&PyGimpPixelRgn_Type);
+ PyModule_AddObject(m, "PixelRgn", (PyObject *)&PyGimpPixelRgn_Type);
+
+ Py_INCREF(&PyGimpParasite_Type);
+ PyModule_AddObject(m, "Parasite", (PyObject *)&PyGimpParasite_Type);
+
+ Py_INCREF(&PyGimpVectorsBezierStroke_Type);
+ PyModule_AddObject(m, "VectorsBezierStroke", (PyObject *)&PyGimpVectorsBezierStroke_Type);
+
+ Py_INCREF(&PyGimpVectors_Type);
+ PyModule_AddObject(m, "Vectors", (PyObject *)&PyGimpVectors_Type);
+
+ Py_INCREF(&PyGimpPixelFetcher_Type);
+ PyModule_AddObject(m, "PixelFetcher", (PyObject *)&PyGimpPixelFetcher_Type);
+
+ /* for other modules */
+ pygimp_api_functions.pygimp_error = pygimp_error;
+
+ PyModule_AddObject(m, "_PyGimp_API",
+ PyCObject_FromVoidPtr(&pygimp_api_functions, NULL));
+
+ PyModule_AddObject(m, "version",
+ Py_BuildValue("(iii)",
+ gimp_major_version,
+ gimp_minor_version,
+ gimp_micro_version));
+
+ /* Some environment constants */
+ PyModule_AddObject(m, "directory",
+ PyString_FromString(gimp_directory()));
+ PyModule_AddObject(m, "data_directory",
+ PyString_FromString(gimp_data_directory()));
+ PyModule_AddObject(m, "locale_directory",
+ PyString_FromString(gimp_locale_directory()));
+ PyModule_AddObject(m, "sysconf_directory",
+ PyString_FromString(gimp_sysconf_directory()));
+ PyModule_AddObject(m, "plug_in_directory",
+ PyString_FromString(gimp_plug_in_directory()));
+
+ /* Check for errors */
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module gimp");
+}
diff --git a/plug-ins/pygimp/gimpplugin.py b/plug-ins/pygimp/gimpplugin.py
new file mode 100644
index 0000000..eeaa3f3
--- /dev/null
+++ b/plug-ins/pygimp/gimpplugin.py
@@ -0,0 +1,81 @@
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+# plugin.py -- helper for writing gimp plugins
+# Copyright (C) 1997, James Henstridge.
+#
+# This is a small wrapper that makes plugins look like an object class that
+# you can derive to create your plugin. With this wrapper, you are pretty
+# much responsible for doing everything (checking run_mode, gui, etc). If
+# you want to write a quick plugin, you probably want the gimpfu module.
+#
+# A plugin using this module would look something like this:
+#
+# import gimp, gimpplugin
+#
+# pdb = gimp.pdb
+#
+# class myplugin(gimpplugin.plugin):
+# def query(self):
+# gimp.install_procedure("plug_in_mine", ...)
+#
+# def plug_in_mine(self, par1, par2, par3,...):
+# do_something()
+#
+# if __name__ == '__main__':
+# myplugin().start()
+
+import gimp
+
+class plugin:
+ def start(self):
+ # only pass the init()/quit() member functions to gimp.main() if the
+ # plug-in overrides them, to avoid the default NOP versions from being
+ # called unnecessarily. in particular, this avoids plug-ins that don't
+ # implement init() from being registered as having an init function,
+ # causing them to be run at each startup.
+ def get_func(name):
+ if getattr(self.__class__, name) != getattr(plugin, name):
+ return getattr(self, name)
+ else:
+ return None
+
+ gimp.main(get_func("init"),
+ get_func("quit"),
+ self.query,
+ self._run)
+
+ def init(self):
+ pass
+
+ def quit(self):
+ pass
+
+ def query(self):
+ pass
+
+ def _run(self, name, params):
+ import sys
+ if "gimpui" in sys.modules.keys():
+ sys.modules["gimpui"].gimp_ui_init ()
+
+ if hasattr(self, name):
+ return apply(getattr(self, name), params)
+ else:
+ raise AttributeError, name
+
+if __name__ == '__main__':
+ plugin().start()
diff --git a/plug-ins/pygimp/gimpshelf.py b/plug-ins/pygimp/gimpshelf.py
new file mode 100644
index 0000000..999d319
--- /dev/null
+++ b/plug-ins/pygimp/gimpshelf.py
@@ -0,0 +1,92 @@
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+# gimpshelf.py -- a simple module to help gimp modules written in Python
+# store persistent data.
+#
+# Copyright (C) 1997, James Henstridge
+#
+# The gimp module provides a basic method for storing information that persists
+# for a whole gimp session, but only allows for the storage of strings. This
+# is because other Python types usually have pointers to other Python objects,
+# making it difficult to work out what to save. This module gives an interface
+# to the gimp module's primitive interface, which resembles the shelve module.
+
+# use cPickle and cStringIO if available
+
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+try:
+ import cStringIO as StringIO
+except ImportError:
+ import StringIO
+
+import gimp
+
+import copy_reg
+
+def _image_id(obj):
+ return gimp._id2image, (obj.ID,)
+
+def _drawable_id(obj):
+ return gimp._id2drawable, (obj.ID,)
+
+def _display_id(obj):
+ return gimp._id2display, (obj.ID,)
+
+def _vectors_id(obj):
+ return gimp._id2vectors, (int(obj.ID),)
+
+copy_reg.pickle(gimp.Image, _image_id, gimp._id2image)
+copy_reg.pickle(gimp.Layer, _drawable_id, gimp._id2drawable)
+copy_reg.pickle(gimp.GroupLayer, _drawable_id, gimp._id2drawable)
+copy_reg.pickle(gimp.Channel, _drawable_id, gimp._id2drawable)
+copy_reg.pickle(gimp.Display, _display_id, gimp._id2display)
+copy_reg.pickle(gimp.Vectors, _vectors_id, gimp._id2vectors)
+
+del copy_reg, _image_id, _drawable_id, _display_id, _vectors_id
+
+class Gimpshelf:
+ def has_key(self, key):
+ try:
+ s = gimp.get_data(key)
+ return 1
+ except gimp.error:
+ return 0
+
+ def __getitem__(self, key):
+ try:
+ s = gimp.get_data(key)
+ except gimp.error:
+ raise KeyError, key
+
+ f = StringIO.StringIO(s)
+ return pickle.Unpickler(f).load()
+
+ def __setitem__(self, key, value):
+ f = StringIO.StringIO()
+ p = pickle.Pickler(f)
+ p.dump(value)
+ gimp.set_data(key, f.getvalue())
+
+ def __delitem__(self, key):
+ gimp.set_data(key, '')
+
+shelf = Gimpshelf()
+del Gimpshelf
diff --git a/plug-ins/pygimp/gimpthumb.c b/plug-ins/pygimp/gimpthumb.c
new file mode 100644
index 0000000..d917e6b
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumb.c
@@ -0,0 +1,694 @@
+/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */
+
+#include <Python.h>
+
+
+
+#line 3 "gimpthumb.override"
+#include <Python.h>
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libgimpthumb/gimpthumb.h>
+
+/* TODO: Add a header for these */
+void gimpthumb_register_classes(PyObject *d);
+void gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix);
+#line 21 "gimpthumb.c"
+
+
+/* ---------- types from other modules ---------- */
+static PyTypeObject *_PyGObject_Type;
+#define PyGObject_Type (*_PyGObject_Type)
+static PyTypeObject *_PyGdkPixbuf_Type;
+#define PyGdkPixbuf_Type (*_PyGdkPixbuf_Type)
+
+
+/* ---------- forward type declarations ---------- */
+PyTypeObject G_GNUC_INTERNAL PyGimpThumbnail_Type;
+
+#line 34 "gimpthumb.c"
+
+
+
+/* ----------- GimpThumbnail ----------- */
+
+static int
+_wrap_gimp_thumbnail_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpthumb.Thumbnail.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpthumb.Thumbnail object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_set_uri(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "uri", NULL };
+ char *uri;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.Thumbnail.set_uri", kwlist, &uri))
+ return NULL;
+
+ gimp_thumbnail_set_uri(GIMP_THUMBNAIL(self->obj), uri);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_set_filename(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "filename", NULL };
+ char *filename;
+ int ret;
+ GError *error = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.Thumbnail.set_filename", kwlist, &filename))
+ return NULL;
+
+ ret = gimp_thumbnail_set_filename(GIMP_THUMBNAIL(self->obj), filename, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_set_from_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "filename", NULL };
+ char *filename;
+ int ret;
+ GError *error = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.Thumbnail.set_from_thumb", kwlist, &filename))
+ return NULL;
+
+ ret = gimp_thumbnail_set_from_thumb(GIMP_THUMBNAIL(self->obj), filename, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_peek_image(PyGObject *self)
+{
+ gint ret;
+
+
+ ret = gimp_thumbnail_peek_image(GIMP_THUMBNAIL(self->obj));
+
+ return pyg_enum_from_gtype(GIMP_TYPE_THUMB_STATE, ret);
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_peek_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ gint ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.peek_thumb", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumbnail_peek_thumb(GIMP_THUMBNAIL(self->obj), size);
+
+ return pyg_enum_from_gtype(GIMP_TYPE_THUMB_STATE, ret);
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_check_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ gint ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.check_thumb", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumbnail_check_thumb(GIMP_THUMBNAIL(self->obj), size);
+
+ return pyg_enum_from_gtype(GIMP_TYPE_THUMB_STATE, ret);
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_load_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ GdkPixbuf *ret;
+ GError *error = NULL;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.load_thumb", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumbnail_load_thumb(GIMP_THUMBNAIL(self->obj), size, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_save_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "pixbuf", "software", NULL };
+ PyGObject *pixbuf;
+ char *software;
+ int ret;
+ GError *error = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!s:Gimp.Thumbnail.save_thumb", kwlist, &PyGdkPixbuf_Type, &pixbuf, &software))
+ return NULL;
+
+ ret = gimp_thumbnail_save_thumb(GIMP_THUMBNAIL(self->obj), GDK_PIXBUF(pixbuf->obj), software, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_save_thumb_local(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "pixbuf", "software", NULL };
+ PyGObject *pixbuf;
+ char *software;
+ int ret;
+ GError *error = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!s:Gimp.Thumbnail.save_thumb_local", kwlist, &PyGdkPixbuf_Type, &pixbuf, &software))
+ return NULL;
+
+ ret = gimp_thumbnail_save_thumb_local(GIMP_THUMBNAIL(self->obj), GDK_PIXBUF(pixbuf->obj), software, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_save_failure(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "software", NULL };
+ char *software;
+ int ret;
+ GError *error = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.Thumbnail.save_failure", kwlist, &software))
+ return NULL;
+
+ ret = gimp_thumbnail_save_failure(GIMP_THUMBNAIL(self->obj), software, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_delete_failure(PyGObject *self)
+{
+
+ gimp_thumbnail_delete_failure(GIMP_THUMBNAIL(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_delete_others(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.delete_others", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ gimp_thumbnail_delete_others(GIMP_THUMBNAIL(self->obj), size);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumbnail_has_failed(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_thumbnail_has_failed(GIMP_THUMBNAIL(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static const PyMethodDef _PyGimpThumbnail_methods[] = {
+ { "set_uri", (PyCFunction)_wrap_gimp_thumbnail_set_uri, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_filename", (PyCFunction)_wrap_gimp_thumbnail_set_filename, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_from_thumb", (PyCFunction)_wrap_gimp_thumbnail_set_from_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "peek_image", (PyCFunction)_wrap_gimp_thumbnail_peek_image, METH_NOARGS,
+ NULL },
+ { "peek_thumb", (PyCFunction)_wrap_gimp_thumbnail_peek_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "check_thumb", (PyCFunction)_wrap_gimp_thumbnail_check_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "load_thumb", (PyCFunction)_wrap_gimp_thumbnail_load_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "save_thumb", (PyCFunction)_wrap_gimp_thumbnail_save_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "save_thumb_local", (PyCFunction)_wrap_gimp_thumbnail_save_thumb_local, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "save_failure", (PyCFunction)_wrap_gimp_thumbnail_save_failure, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "delete_failure", (PyCFunction)_wrap_gimp_thumbnail_delete_failure, METH_NOARGS,
+ NULL },
+ { "delete_others", (PyCFunction)_wrap_gimp_thumbnail_delete_others, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "has_failed", (PyCFunction)_wrap_gimp_thumbnail_has_failed, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpThumbnail_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpthumb.Thumbnail", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpThumbnail_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_thumbnail_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- functions ----------- */
+
+#line 25 "gimpthumb.override"
+static PyObject *
+_wrap_gimp_thumb_init(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *creator, *thumb_basedir = NULL;
+
+ static char *kwlist[] = { "creator", "thumb_basedir", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "s|z:init", kwlist,
+ &creator, &thumb_basedir))
+ return NULL;
+
+ return PyBool_FromLong(gimp_thumb_init(creator, thumb_basedir));
+}
+#line 375 "gimpthumb.c"
+
+
+#line 41 "gimpthumb.override"
+static PyObject *
+_wrap_gimp_thumb_find_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *uri, *ret;
+ PyObject *py_size, *py_ret;
+ GimpThumbSize size;
+
+ static char *kwlist[] = { "uri", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:find_thumb", kwlist,
+ &uri, &py_size))
+ return NULL;
+
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gint *)&size))
+ return NULL;
+
+ ret = gimp_thumb_find_thumb(uri, &size);
+
+ if (ret == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ py_ret = Py_BuildValue("sN", ret,
+ pyg_enum_from_gtype(GIMP_TYPE_THUMB_SIZE, size));
+ g_free(ret);
+ return py_ret;
+}
+#line 407 "gimpthumb.c"
+
+
+#line 71 "gimpthumb.override"
+static PyObject *
+_wrap_gimp_thumb_file_test(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *filename;
+ GimpThumbFileType ret;
+ gint64 mtime, size;
+ gint err_no;
+
+ static char *kwlist[] = { "filename", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:file_test", kwlist,
+ &filename))
+ return NULL;
+
+ ret = gimp_thumb_file_test(filename, &mtime, &size, &err_no);
+
+ if (ret == GIMP_THUMB_FILE_TYPE_NONE) {
+ PyObject *v = Py_BuildValue("iss",
+ err_no, g_strerror(err_no), filename);
+ if (v != NULL) {
+ PyErr_SetObject(PyExc_IOError, v);
+ Py_DECREF(v);
+ }
+
+ return NULL;
+ }
+
+ return Py_BuildValue("NNN",
+ pyg_enum_from_gtype(GIMP_TYPE_THUMB_FILE_TYPE, ret),
+ PyLong_FromLongLong(mtime),
+ PyLong_FromLongLong(size));
+}
+#line 443 "gimpthumb.c"
+
+
+static PyObject *
+_wrap_gimp_thumb_name_from_uri(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "uri", "size", NULL };
+ char *uri;
+ PyObject *py_size = NULL;
+ gchar *ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:name_from_uri", kwlist, &uri, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_name_from_uri(uri, size);
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumb_get_thumb_dir(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ const gchar *ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:get_thumb_dir", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_get_thumb_dir(size);
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumb_ensure_thumb_dir(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "size", NULL };
+ PyObject *py_size = NULL;
+ int ret;
+ GError *error = NULL;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:ensure_thumb_dir", kwlist, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_ensure_thumb_dir(size, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbs_delete_for_uri(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "uri", NULL };
+ char *uri;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:delete_for_uri", kwlist, &uri))
+ return NULL;
+
+ gimp_thumbs_delete_for_uri(uri);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumb_name_from_uri_local(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "uri", "size", NULL };
+ char *uri;
+ PyObject *py_size = NULL;
+ gchar *ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:name_from_uri_local", kwlist, &uri, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_name_from_uri_local(uri, size);
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumb_get_thumb_dir_local(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "dirname", "size", NULL };
+ char *dirname;
+ PyObject *py_size = NULL;
+ gchar *ret;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:get_thumb_dir_local", kwlist, &dirname, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_get_thumb_dir_local(dirname, size);
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_thumb_ensure_thumb_dir_local(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "dirname", "size", NULL };
+ char *dirname;
+ PyObject *py_size = NULL;
+ int ret;
+ GError *error = NULL;
+ GimpThumbSize size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:ensure_thumb_dir_local", kwlist, &dirname, &py_size))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
+ return NULL;
+
+ ret = gimp_thumb_ensure_thumb_dir_local(dirname, size, &error);
+
+ if (pyg_error_check(&error))
+ return NULL;
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_thumbs_delete_for_uri_local(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "uri", NULL };
+ char *uri;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:delete_for_uri_local", kwlist, &uri))
+ return NULL;
+
+ gimp_thumbs_delete_for_uri_local(uri);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+const PyMethodDef gimpthumb_functions[] = {
+ { "init", (PyCFunction)_wrap_gimp_thumb_init, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "find_thumb", (PyCFunction)_wrap_gimp_thumb_find_thumb, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "file_test", (PyCFunction)_wrap_gimp_thumb_file_test, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "name_from_uri", (PyCFunction)_wrap_gimp_thumb_name_from_uri, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_thumb_dir", (PyCFunction)_wrap_gimp_thumb_get_thumb_dir, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "ensure_thumb_dir", (PyCFunction)_wrap_gimp_thumb_ensure_thumb_dir, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "delete_for_uri", (PyCFunction)_wrap_gimp_thumbs_delete_for_uri, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "name_from_uri_local", (PyCFunction)_wrap_gimp_thumb_name_from_uri_local, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_thumb_dir_local", (PyCFunction)_wrap_gimp_thumb_get_thumb_dir_local, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "ensure_thumb_dir_local", (PyCFunction)_wrap_gimp_thumb_ensure_thumb_dir_local, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "delete_for_uri_local", (PyCFunction)_wrap_gimp_thumbs_delete_for_uri_local, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+
+/* ----------- enums and flags ----------- */
+
+void
+gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix)
+{
+#ifdef VERSION
+ PyModule_AddStringConstant(module, "__version__", VERSION);
+#endif
+ pyg_enum_add(module, "ThumbFileType", strip_prefix, GIMP_TYPE_THUMB_FILE_TYPE);
+ pyg_enum_add(module, "ThumbSize", strip_prefix, GIMP_TYPE_THUMB_SIZE);
+ pyg_enum_add(module, "ThumbState", strip_prefix, GIMP_TYPE_THUMB_STATE);
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
+/* initialise stuff extension classes */
+void
+gimpthumb_register_classes(PyObject *d)
+{
+ PyObject *module;
+
+ if ((module = PyImport_ImportModule("gobject")) != NULL) {
+ _PyGObject_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GObject");
+ if (_PyGObject_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name GObject from gobject");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gobject");
+ return ;
+ }
+ if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) {
+ _PyGdkPixbuf_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Pixbuf");
+ if (_PyGdkPixbuf_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Pixbuf from gtk.gdk");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gtk.gdk");
+ return ;
+ }
+
+
+#line 692 "gimpthumb.c"
+ pygobject_register_class(d, "GimpThumbnail", GIMP_TYPE_THUMBNAIL, &PyGimpThumbnail_Type, Py_BuildValue("(O)", &PyGObject_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_THUMBNAIL);
+}
diff --git a/plug-ins/pygimp/gimpthumb.defs b/plug-ins/pygimp/gimpthumb.defs
new file mode 100644
index 0000000..35ecc7b
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumb.defs
@@ -0,0 +1,312 @@
+;; -*- scheme -*-
+; object definitions ...
+(define-object Thumbnail
+ (in-module "Gimp")
+ (parent "GObject")
+ (c-name "GimpThumbnail")
+ (gtype-id "GIMP_TYPE_THUMBNAIL")
+)
+
+;; Enumerations and flags ...
+
+(define-enum ThumbFileType
+ (in-module "Gimp")
+ (c-name "GimpThumbFileType")
+ (gtype-id "GIMP_TYPE_THUMB_FILE_TYPE")
+ (values
+ '("none" "GIMP_THUMB_FILE_TYPE_NONE")
+ '("regular" "GIMP_THUMB_FILE_TYPE_REGULAR")
+ '("folder" "GIMP_THUMB_FILE_TYPE_FOLDER")
+ '("special" "GIMP_THUMB_FILE_TYPE_SPECIAL")
+ )
+)
+
+(define-enum ThumbSize
+ (in-module "Gimp")
+ (c-name "GimpThumbSize")
+ (gtype-id "GIMP_TYPE_THUMB_SIZE")
+ (values
+ '("fail" "GIMP_THUMB_SIZE_FAIL")
+ '("normal" "GIMP_THUMB_SIZE_NORMAL")
+ '("large" "GIMP_THUMB_SIZE_LARGE")
+ )
+)
+
+(define-enum ThumbState
+ (in-module "Gimp")
+ (c-name "GimpThumbState")
+ (gtype-id "GIMP_TYPE_THUMB_STATE")
+ (values
+ '("unknown" "GIMP_THUMB_STATE_UNKNOWN")
+ '("remote" "GIMP_THUMB_STATE_REMOTE")
+ '("folder" "GIMP_THUMB_STATE_FOLDER")
+ '("special" "GIMP_THUMB_STATE_SPECIAL")
+ '("not-found" "GIMP_THUMB_STATE_NOT_FOUND")
+ '("exists" "GIMP_THUMB_STATE_EXISTS")
+ '("old" "GIMP_THUMB_STATE_OLD")
+ '("failed" "GIMP_THUMB_STATE_FAILED")
+ '("ok" "GIMP_THUMB_STATE_OK")
+ )
+)
+
+
+;; From ../../libgimpthumb/gimpthumb-enums.h
+
+(define-function gimp_thumb_file_type_get_type
+ (c-name "gimp_thumb_file_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_thumb_size_get_type
+ (c-name "gimp_thumb_size_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_thumb_state_get_type
+ (c-name "gimp_thumb_state_get_type")
+ (return-type "GType")
+)
+
+
+
+;; From ../../libgimpthumb/gimpthumb-types.h
+
+
+
+;; From ../../libgimpthumb/gimpthumb-utils.h
+
+(define-function init
+ (c-name "gimp_thumb_init")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "creator")
+ '("const-gchar*" "thumb_basedir")
+ )
+)
+
+(define-function find_thumb
+ (c-name "gimp_thumb_find_thumb")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "uri")
+ '("GimpThumbSize*" "size")
+ )
+)
+
+(define-function file_test
+ (c-name "gimp_thumb_file_test")
+ (return-type "GimpThumbFileType")
+ (parameters
+ '("const-gchar*" "filename")
+ '("gint64*" "mtime")
+ '("gint64*" "size")
+ '("gint*" "err_no")
+ )
+)
+
+(define-function name_from_uri
+ (c-name "gimp_thumb_name_from_uri")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "uri")
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-function get_thumb_dir
+ (c-name "gimp_thumb_get_thumb_dir")
+ (return-type "const-gchar*")
+ (parameters
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-function ensure_thumb_dir
+ (c-name "gimp_thumb_ensure_thumb_dir")
+ (return-type "gboolean")
+ (parameters
+ '("GimpThumbSize" "size")
+ '("GError**" "error")
+ )
+)
+
+(define-function delete_for_uri
+ (c-name "gimp_thumbs_delete_for_uri")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "uri")
+ )
+)
+
+(define-function name_from_uri_local
+ (c-name "gimp_thumb_name_from_uri_local")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "uri")
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-function get_thumb_dir_local
+ (c-name "gimp_thumb_get_thumb_dir_local")
+ (return-type "gchar*")
+ (parameters
+ '("const-gchar*" "dirname")
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-function ensure_thumb_dir_local
+ (c-name "gimp_thumb_ensure_thumb_dir_local")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "dirname")
+ '("GimpThumbSize" "size")
+ '("GError**" "error")
+ )
+)
+
+(define-function delete_for_uri_local
+ (c-name "gimp_thumbs_delete_for_uri_local")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "uri")
+ )
+)
+
+
+
+;; From ../../libgimpthumb/gimpthumb.h
+
+
+
+;; From ../../libgimpthumb/gimpthumbnail.h
+
+(define-function gimp_thumbnail_get_type
+ (c-name "gimp_thumbnail_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_thumbnail_new
+ (c-name "gimp_thumbnail_new")
+ (is-constructor-of "GimpThumbnail")
+ (return-type "GimpThumbnail*")
+)
+
+(define-method set_uri
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_set_uri")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "uri")
+ )
+)
+
+(define-method set_filename
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_set_filename")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "filename")
+ '("GError**" "error")
+ )
+)
+
+(define-method set_from_thumb
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_set_from_thumb")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "filename")
+ '("GError**" "error")
+ )
+)
+
+(define-method peek_image
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_peek_image")
+ (return-type "GimpThumbState")
+)
+
+(define-method peek_thumb
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_peek_thumb")
+ (return-type "GimpThumbState")
+ (parameters
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-method check_thumb
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_check_thumb")
+ (return-type "GimpThumbState")
+ (parameters
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-method load_thumb
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_load_thumb")
+ (return-type "GdkPixbuf*")
+ (parameters
+ '("GimpThumbSize" "size")
+ '("GError**" "error")
+ )
+)
+
+(define-method save_thumb
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_save_thumb")
+ (return-type "gboolean")
+ (parameters
+ '("GdkPixbuf*" "pixbuf")
+ '("const-gchar*" "software")
+ '("GError**" "error")
+ )
+)
+
+(define-method save_thumb_local
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_save_thumb_local")
+ (return-type "gboolean")
+ (parameters
+ '("GdkPixbuf*" "pixbuf")
+ '("const-gchar*" "software")
+ '("GError**" "error")
+ )
+)
+
+(define-method save_failure
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_save_failure")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "software")
+ '("GError**" "error")
+ )
+)
+
+(define-method delete_failure
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_delete_failure")
+ (return-type "none")
+)
+
+(define-method delete_others
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_delete_others")
+ (return-type "none")
+ (parameters
+ '("GimpThumbSize" "size")
+ )
+)
+
+(define-method has_failed
+ (of-object "GimpThumbnail")
+ (c-name "gimp_thumbnail_has_failed")
+ (return-type "gboolean")
+)
+
+
diff --git a/plug-ins/pygimp/gimpthumb.override b/plug-ins/pygimp/gimpthumb.override
new file mode 100644
index 0000000..c43e539
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumb.override
@@ -0,0 +1,102 @@
+%%
+headers
+#include <Python.h>
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libgimpthumb/gimpthumb.h>
+
+/* TODO: Add a header for these */
+void gimpthumb_register_classes(PyObject *d);
+void gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix);
+%%
+modulename gimpthumb
+%%
+import gobject.GObject as PyGObject_Type
+import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
+%%
+ignore-glob
+ *_get_type
+%%
+override gimp_thumb_init kwargs
+static PyObject *
+_wrap_gimp_thumb_init(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *creator, *thumb_basedir = NULL;
+
+ static char *kwlist[] = { "creator", "thumb_basedir", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "s|z:init", kwlist,
+ &creator, &thumb_basedir))
+ return NULL;
+
+ return PyBool_FromLong(gimp_thumb_init(creator, thumb_basedir));
+}
+%%
+override gimp_thumb_find_thumb kwargs
+static PyObject *
+_wrap_gimp_thumb_find_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *uri, *ret;
+ PyObject *py_size, *py_ret;
+ GimpThumbSize size;
+
+ static char *kwlist[] = { "uri", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:find_thumb", kwlist,
+ &uri, &py_size))
+ return NULL;
+
+ if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gint *)&size))
+ return NULL;
+
+ ret = gimp_thumb_find_thumb(uri, &size);
+
+ if (ret == NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ py_ret = Py_BuildValue("sN", ret,
+ pyg_enum_from_gtype(GIMP_TYPE_THUMB_SIZE, size));
+ g_free(ret);
+ return py_ret;
+}
+%%
+override gimp_thumb_file_test kwargs
+static PyObject *
+_wrap_gimp_thumb_file_test(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *filename;
+ GimpThumbFileType ret;
+ gint64 mtime, size;
+ gint err_no;
+
+ static char *kwlist[] = { "filename", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:file_test", kwlist,
+ &filename))
+ return NULL;
+
+ ret = gimp_thumb_file_test(filename, &mtime, &size, &err_no);
+
+ if (ret == GIMP_THUMB_FILE_TYPE_NONE) {
+ PyObject *v = Py_BuildValue("iss",
+ err_no, g_strerror(err_no), filename);
+ if (v != NULL) {
+ PyErr_SetObject(PyExc_IOError, v);
+ Py_DECREF(v);
+ }
+
+ return NULL;
+ }
+
+ return Py_BuildValue("NNN",
+ pyg_enum_from_gtype(GIMP_TYPE_THUMB_FILE_TYPE, ret),
+ PyLong_FromLongLong(mtime),
+ PyLong_FromLongLong(size));
+}
diff --git a/plug-ins/pygimp/gimpthumbmodule.c b/plug-ins/pygimp/gimpthumbmodule.c
new file mode 100644
index 0000000..5f87844
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumbmodule.c
@@ -0,0 +1,60 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005-2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Python.h>
+
+#include <pygobject.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libgimpthumb/gimpthumb.h>
+
+#include "pygimp-util.h"
+
+
+void gimpthumb_register_classes(PyObject *d);
+void gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix);
+extern PyMethodDef gimpthumb_functions[];
+
+
+static char gimpthumb_doc[] =
+"This module provides interfaces to allow you to write gimp plug-ins"
+;
+
+void initgimpthumb(void);
+
+PyMODINIT_FUNC
+initgimpthumb(void)
+{
+ PyObject *m, *d;
+
+ pygimp_init_pygobject();
+
+ m = Py_InitModule3("gimpthumb", gimpthumb_functions, gimpthumb_doc);
+ d = PyModule_GetDict(m);
+
+ gimpthumb_register_classes(d);
+ gimpthumb_add_constants(m, "GIMP_THUMB_");
+
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module gimpthumb");
+}
diff --git a/plug-ins/pygimp/gimpui.c b/plug-ins/pygimp/gimpui.c
new file mode 100644
index 0000000..26b9f50
--- /dev/null
+++ b/plug-ins/pygimp/gimpui.c
@@ -0,0 +1,9387 @@
+/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */
+
+#include <Python.h>
+
+
+
+#line 2 "gimpui.override"
+#include <Python.h>
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include <pycairo.h>
+extern Pycairo_CAPI_t *Pycairo_CAPI;
+
+#define GIMP_DISABLE_DEPRECATION_WARNINGS
+#include <libgimp/gimp.h>
+#undef GIMP_DISABLE_DEPRECATED
+#include <libgimp/gimpui.h>
+#define GIMP_DISABLE_DEPRECATED
+
+#define NO_IMPORT_PYGIMP
+#include "pygimp-api.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+typedef struct {
+ PyObject *constraint;
+ PyObject *user_data;
+} PyGimpConstraintData;
+
+typedef struct {
+ PyObject *sensitivity_func;
+ PyObject *user_data;
+} PyGimpIntSensitivityData;
+
+/* TODO: Add a header for these */
+void gimpui_register_classes(PyObject *d);
+void gimpui_add_constants(PyObject *module, const gchar *strip_prefix);
+
+static void
+pygimp_decref_callback(PyObject* obj) {
+ Py_XDECREF (obj);
+}
+
+#line 48 "gimpui.c"
+
+
+/* ---------- types from other modules ---------- */
+static PyTypeObject *_PyGObject_Type;
+#define PyGObject_Type (*_PyGObject_Type)
+static PyTypeObject *_PyGdkPixbuf_Type;
+#define PyGdkPixbuf_Type (*_PyGdkPixbuf_Type)
+static PyTypeObject *_PyGtkObject_Type;
+#define PyGtkObject_Type (*_PyGtkObject_Type)
+static PyTypeObject *_PyGtkWidget_Type;
+#define PyGtkWidget_Type (*_PyGtkWidget_Type)
+static PyTypeObject *_PyGtkDialog_Type;
+#define PyGtkDialog_Type (*_PyGtkDialog_Type)
+static PyTypeObject *_PyGtkWindow_Type;
+#define PyGtkWindow_Type (*_PyGtkWindow_Type)
+static PyTypeObject *_PyGtkLabel_Type;
+#define PyGtkLabel_Type (*_PyGtkLabel_Type)
+static PyTypeObject *_PyGtkButton_Type;
+#define PyGtkButton_Type (*_PyGtkButton_Type)
+static PyTypeObject *_PyGtkToggleButton_Type;
+#define PyGtkToggleButton_Type (*_PyGtkToggleButton_Type)
+static PyTypeObject *_PyGtkRadioButton_Type;
+#define PyGtkRadioButton_Type (*_PyGtkRadioButton_Type)
+static PyTypeObject *_PyGtkSpinButton_Type;
+#define PyGtkSpinButton_Type (*_PyGtkSpinButton_Type)
+static PyTypeObject *_PyGtkEntry_Type;
+#define PyGtkEntry_Type (*_PyGtkEntry_Type)
+static PyTypeObject *_PyGtkDrawingArea_Type;
+#define PyGtkDrawingArea_Type (*_PyGtkDrawingArea_Type)
+static PyTypeObject *_PyGtkTable_Type;
+#define PyGtkTable_Type (*_PyGtkTable_Type)
+static PyTypeObject *_PyGtkFrame_Type;
+#define PyGtkFrame_Type (*_PyGtkFrame_Type)
+static PyTypeObject *_PyGtkHBox_Type;
+#define PyGtkHBox_Type (*_PyGtkHBox_Type)
+static PyTypeObject *_PyGtkVBox_Type;
+#define PyGtkVBox_Type (*_PyGtkVBox_Type)
+static PyTypeObject *_PyGtkHPaned_Type;
+#define PyGtkHPaned_Type (*_PyGtkHPaned_Type)
+static PyTypeObject *_PyGtkVPaned_Type;
+#define PyGtkVPaned_Type (*_PyGtkVPaned_Type)
+static PyTypeObject *_PyGtkScale_Type;
+#define PyGtkScale_Type (*_PyGtkScale_Type)
+static PyTypeObject *_PyGtkProgressBar_Type;
+#define PyGtkProgressBar_Type (*_PyGtkProgressBar_Type)
+static PyTypeObject *_PyGtkOptionMenu_Type;
+#define PyGtkOptionMenu_Type (*_PyGtkOptionMenu_Type)
+static PyTypeObject *_PyGtkComboBox_Type;
+#define PyGtkComboBox_Type (*_PyGtkComboBox_Type)
+static PyTypeObject *_PyGtkListStore_Type;
+#define PyGtkListStore_Type (*_PyGtkListStore_Type)
+static PyTypeObject *_PyGtkTreeModel_Type;
+#define PyGtkTreeModel_Type (*_PyGtkTreeModel_Type)
+static PyTypeObject *_PyGtkCellRenderer_Type;
+#define PyGtkCellRenderer_Type (*_PyGtkCellRenderer_Type)
+static PyTypeObject *_PyGtkCellRendererToggle_Type;
+#define PyGtkCellRendererToggle_Type (*_PyGtkCellRendererToggle_Type)
+static PyTypeObject *_PyGimpParasite_Type;
+#define PyGimpParasite_Type (*_PyGimpParasite_Type)
+
+
+/* ---------- forward type declarations ---------- */
+PyTypeObject G_GNUC_INTERNAL PyGimpBrowser_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpCellRendererColor_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpCellRendererToggle_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpChainButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorArea_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorConfig_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorDisplay_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorDisplayStack_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorHexEntry_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorProfileComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorProfileStore_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorScale_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorScales_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorSelection_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorSelector_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorNotebook_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpDialog_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumLabel_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpFrame_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpHintBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpIntComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpImageComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpDrawableComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpChannelComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpIntStore_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumStore_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpLayerComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpMemsizeEntry_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpNumberPairEntry_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpOffsetArea_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPageSelector_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPathEditor_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPickButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPreview_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpAspectPreview_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPreviewArea_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpProcBrowserDialog_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpProgressBar_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpScrolledPreview_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpDrawablePreview_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPatternSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpPaletteSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpGradientSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpFontSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpBrushSelectButton_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpRuler_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpSizeEntry_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpStringComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpUnitComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpUnitMenu_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpVectorsComboBox_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpZoomModel_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpZoomPreview_Type;
+PyTypeObject G_GNUC_INTERNAL PyGimpColorManaged_Type;
+
+#line 170 "gimpui.c"
+
+
+
+/* ----------- GimpBrowser ----------- */
+
+static int
+_wrap_gimp_browser_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.Browser.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.Browser object");
+ return -1;
+ }
+ return 0;
+}
+
+#line 1375 "gimpui.override"
+static PyObject *
+_wrap_gimp_browser_add_search_types(PyGObject *self, PyObject *args)
+{
+ GimpBrowser *browser;
+ int len, i;
+ PyObject *element;
+ gchar *label;
+ gint id;
+
+ browser = GIMP_BROWSER(self->obj);
+
+ len = PyTuple_Size(args);
+
+ for (i = 0; i < len; ++i) {
+ element = PyTuple_GetItem(args, i);
+ if (!PyTuple_Check(element)) {
+ PyErr_SetString(PyExc_TypeError, "GimpBrowser.add_search_types: Arguments must be tuples");
+ return NULL;
+ }
+ if (!PyArg_ParseTuple(element, "si", &label, &id))
+ return NULL;
+ gimp_browser_add_search_types(browser, label, id, NULL);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 224 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_browser_set_widget(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "widget", NULL };
+ PyGObject *widget;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.Browser.set_widget", kwlist, &PyGtkWidget_Type, &widget))
+ return NULL;
+
+ gimp_browser_set_widget(GIMP_BROWSER(self->obj), GTK_WIDGET(widget->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_browser_show_message(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "message", NULL };
+ char *message;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.Browser.show_message", kwlist, &message))
+ return NULL;
+
+ gimp_browser_show_message(GIMP_BROWSER(self->obj), message);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpBrowser_methods[] = {
+ { "add_search_types", (PyCFunction)_wrap_gimp_browser_add_search_types, METH_VARARGS,
+ NULL },
+ { "set_widget", (PyCFunction)_wrap_gimp_browser_set_widget, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "show_message", (PyCFunction)_wrap_gimp_browser_show_message, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpBrowser_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Browser", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpBrowser_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_browser_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpButton ----------- */
+
+static int
+_wrap_gimp_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.Button.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.Button object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_button_extended_clicked(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "state", NULL };
+ PyObject *py_state = NULL;
+ GdkModifierType state;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Button.extended_clicked", kwlist, &py_state))
+ return NULL;
+ if (pyg_flags_get_value(GDK_TYPE_MODIFIER_TYPE, py_state, (gpointer)&state))
+ return NULL;
+
+ gimp_button_extended_clicked(GIMP_BUTTON(self->obj), state);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpButton_methods[] = {
+ { "extended_clicked", (PyCFunction)_wrap_gimp_button_extended_clicked, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Button", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpCellRendererColor ----------- */
+
+static int
+_wrap_gimp_cell_renderer_color_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.CellRendererColor.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.CellRendererColor object");
+ return -1;
+ }
+ return 0;
+}
+
+PyTypeObject G_GNUC_INTERNAL PyGimpCellRendererColor_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.CellRendererColor", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_cell_renderer_color_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpCellRendererToggle ----------- */
+
+static int
+_wrap_gimp_cell_renderer_toggle_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[1];
+ PyObject *parsed_args[1] = {NULL, };
+ char *arg_names[] = {"stock_id", NULL };
+ char *prop_names[] = {"stock-id", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:gimpui.CellRendererToggle.__init__" , arg_names , &parsed_args[0]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*1);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.CellRendererToggle object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_cell_renderer_toggle_clicked(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "path", "state", NULL };
+ char *path;
+ PyObject *py_state = NULL;
+ GdkModifierType state;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sO:Gimp.CellRendererToggle.clicked", kwlist, &path, &py_state))
+ return NULL;
+ if (pyg_flags_get_value(GDK_TYPE_MODIFIER_TYPE, py_state, (gpointer)&state))
+ return NULL;
+
+ gimp_cell_renderer_toggle_clicked(GIMP_CELL_RENDERER_TOGGLE(self->obj), path, state);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpCellRendererToggle_methods[] = {
+ { "clicked", (PyCFunction)_wrap_gimp_cell_renderer_toggle_clicked, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpCellRendererToggle_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.CellRendererToggle", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpCellRendererToggle_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_cell_renderer_toggle_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpChainButton ----------- */
+
+ static int
+_wrap_gimp_chain_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[1];
+ PyObject *parsed_args[1] = {NULL, };
+ char *arg_names[] = {"position", NULL };
+ char *prop_names[] = {"position", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gimpui.ChainButton.__init__" , arg_names , &parsed_args[0]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*1);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ChainButton object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_chain_button_set_active(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "active", NULL };
+ int active;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ChainButton.set_active", kwlist, &active))
+ return NULL;
+
+ gimp_chain_button_set_active(GIMP_CHAIN_BUTTON(self->obj), active);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_chain_button_get_active(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_chain_button_get_active(GIMP_CHAIN_BUTTON(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static const PyMethodDef _PyGimpChainButton_methods[] = {
+ { "set_active", (PyCFunction)_wrap_gimp_chain_button_set_active, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active", (PyCFunction)_wrap_gimp_chain_button_get_active, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpChainButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ChainButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpChainButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_chain_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorArea ----------- */
+
+ static int
+_wrap_gimp_color_area_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[3];
+ PyObject *parsed_args[3] = {NULL, };
+ char *arg_names[] = {"color", "type", "drag_mask", NULL };
+ char *prop_names[] = {"color", "type", "drag-mask", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO:gimpui.ColorArea.__init__" , arg_names , &parsed_args[0] , &parsed_args[1] , &parsed_args[2]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*3);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorArea object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_area_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "color", NULL };
+ PyObject *py_color;
+ GimpRGB *color = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorArea.set_color", kwlist, &py_color))
+ return NULL;
+ if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB");
+ return NULL;
+ }
+
+ gimp_color_area_set_color(GIMP_COLOR_AREA(self->obj), color);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1792 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_area_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_area_get_color(GIMP_COLOR_AREA(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+#line 758 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_area_has_alpha(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_color_area_has_alpha(GIMP_COLOR_AREA(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_color_area_set_type(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "type", NULL };
+ PyObject *py_type = NULL;
+ GimpColorAreaType type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorArea.set_type", kwlist, &py_type))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_AREA_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ gimp_color_area_set_type(GIMP_COLOR_AREA(self->obj), type);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_area_set_draw_border(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "draw_border", NULL };
+ int draw_border;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorArea.set_draw_border", kwlist, &draw_border))
+ return NULL;
+
+ gimp_color_area_set_draw_border(GIMP_COLOR_AREA(self->obj), draw_border);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorArea_methods[] = {
+ { "set_color", (PyCFunction)_wrap_gimp_color_area_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_color", (PyCFunction)_wrap_gimp_color_area_get_color, METH_NOARGS,
+ NULL },
+ { "has_alpha", (PyCFunction)_wrap_gimp_color_area_has_alpha, METH_NOARGS,
+ NULL },
+ { "set_type", (PyCFunction)_wrap_gimp_color_area_set_type, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_draw_border", (PyCFunction)_wrap_gimp_color_area_set_draw_border, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorArea_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorArea", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorArea_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_area_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorButton ----------- */
+
+#line 941 "gimpui.override"
+static int
+_wrap_gimp_color_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *title = NULL;
+ gint width = -1, height = -1;
+ PyObject *py_color = NULL, *py_type = NULL;
+ GimpRGB *color, default_color = { 0.0, 0.0, 0.0, 100.0 };
+ GimpColorAreaType type;
+
+ static char *kwlist[] = { "title", "width", "height", "color", "type",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|ziiOO:gimpui.ColorButton.__init__",
+ kwlist,
+ &title, &width, &height,
+ &py_color, &py_type))
+ return -1;
+
+ if (py_color == NULL || (PyObject*)py_color == Py_None)
+ color = &default_color;
+ else if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB or None");
+ return -1;
+ }
+
+ if (py_type == NULL || (PyObject*)py_type == Py_None)
+ type = GIMP_COLOR_AREA_FLAT;
+ else if (pyg_enum_get_value(GIMP_TYPE_COLOR_AREA_TYPE, py_type,
+ (gint*)&type))
+ return -1;
+
+ if (pygobject_construct(self,
+ "title", title,
+ "type", type,
+ "color", color,
+ "area-width", width,
+ "area-height", height,
+ NULL))
+ return -1;
+
+ return 0;
+}
+#line 915 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_button_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "color", NULL };
+ PyObject *py_color;
+ GimpRGB *color = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorButton.set_color", kwlist, &py_color))
+ return NULL;
+ if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB");
+ return NULL;
+ }
+
+ gimp_color_button_set_color(GIMP_COLOR_BUTTON(self->obj), color);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 903 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_button_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_button_get_color(GIMP_COLOR_BUTTON(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+#line 950 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_button_has_alpha(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_color_button_has_alpha(GIMP_COLOR_BUTTON(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_color_button_set_type(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "type", NULL };
+ PyObject *py_type = NULL;
+ GimpColorAreaType type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorButton.set_type", kwlist, &py_type))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_AREA_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ gimp_color_button_set_type(GIMP_COLOR_BUTTON(self->obj), type);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_button_get_update(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_color_button_get_update(GIMP_COLOR_BUTTON(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_color_button_set_update(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "continuous", NULL };
+ int continuous;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorButton.set_update", kwlist, &continuous))
+ return NULL;
+
+ gimp_color_button_set_update(GIMP_COLOR_BUTTON(self->obj), continuous);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorButton_methods[] = {
+ { "set_color", (PyCFunction)_wrap_gimp_color_button_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_color", (PyCFunction)_wrap_gimp_color_button_get_color, METH_NOARGS,
+ NULL },
+ { "has_alpha", (PyCFunction)_wrap_gimp_color_button_has_alpha, METH_NOARGS,
+ NULL },
+ { "set_type", (PyCFunction)_wrap_gimp_color_button_set_type, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_update", (PyCFunction)_wrap_gimp_color_button_get_update, METH_NOARGS,
+ NULL },
+ { "set_update", (PyCFunction)_wrap_gimp_color_button_set_update, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorConfig ----------- */
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorConfig_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorConfig", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorDisplay ----------- */
+
+static PyObject *
+_wrap_gimp_color_display_clone(PyGObject *self)
+{
+ GimpColorDisplay *ret;
+
+
+ ret = gimp_color_display_clone(GIMP_COLOR_DISPLAY(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+#line 1996 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_display_convert_surface(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PycairoSurface *pysurface;
+
+ static char *kwlist[] = { "surface", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpColorDisplay.convert_surface",
+ kwlist,
+ &PycairoSurface_Type, &pysurface))
+ return NULL;
+
+ gimp_color_display_convert_surface(GIMP_COLOR_DISPLAY(self->obj),
+ pysurface->surface);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 1157 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_display_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "buf", "width", "height", "bpp", "bpl", NULL };
+ int buf_len, width, height, bpp, bpl;
+ guchar *buf;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s#iiii:Gimp.ColorDisplay.convert", kwlist, &buf, &buf_len, &width, &height, &bpp, &bpl))
+ return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use convert_surface(cairo_surface_t*) instead") < 0)
+ return NULL;
+
+ gimp_color_display_convert(GIMP_COLOR_DISPLAY(self->obj), buf, width, height, bpp, bpl);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_load_state(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "state", NULL };
+ GimpParasite *state = NULL;
+ PyObject *py_state;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorDisplay.load_state", kwlist, &py_state))
+ return NULL;
+ if (pyg_boxed_check(py_state, GIMP_TYPE_PARASITE))
+ state = pyg_boxed_get(py_state, GimpParasite);
+ else {
+ PyErr_SetString(PyExc_TypeError, "state should be a GimpParasite");
+ return NULL;
+ }
+
+ gimp_color_display_load_state(GIMP_COLOR_DISPLAY(self->obj), state);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_save_state(PyGObject *self)
+{
+ GimpParasite *ret;
+
+
+ ret = gimp_color_display_save_state(GIMP_COLOR_DISPLAY(self->obj));
+
+ /* pyg_boxed_new handles NULL checking */
+ return pyg_boxed_new(GIMP_TYPE_PARASITE, ret, TRUE, TRUE);
+}
+
+static PyObject *
+_wrap_gimp_color_display_configure(PyGObject *self)
+{
+ GtkWidget *ret;
+
+
+ ret = gimp_color_display_configure(GIMP_COLOR_DISPLAY(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_color_display_configure_reset(PyGObject *self)
+{
+
+ gimp_color_display_configure_reset(GIMP_COLOR_DISPLAY(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_changed(PyGObject *self)
+{
+
+ gimp_color_display_changed(GIMP_COLOR_DISPLAY(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_set_enabled(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enabled", NULL };
+ int enabled;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorDisplay.set_enabled", kwlist, &enabled))
+ return NULL;
+
+ gimp_color_display_set_enabled(GIMP_COLOR_DISPLAY(self->obj), enabled);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_get_enabled(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_color_display_get_enabled(GIMP_COLOR_DISPLAY(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_color_display_get_config(PyGObject *self)
+{
+ GimpColorConfig *ret;
+
+
+ ret = gimp_color_display_get_config(GIMP_COLOR_DISPLAY(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_color_display_get_managed(PyGObject *self)
+{
+ GimpColorManaged *ret;
+
+
+ ret = gimp_color_display_get_managed(GIMP_COLOR_DISPLAY(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static const PyMethodDef _PyGimpColorDisplay_methods[] = {
+ { "clone", (PyCFunction)_wrap_gimp_color_display_clone, METH_NOARGS,
+ NULL },
+ { "convert_surface", (PyCFunction)_wrap_gimp_color_display_convert_surface, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "convert", (PyCFunction)_wrap_gimp_color_display_convert, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "load_state", (PyCFunction)_wrap_gimp_color_display_load_state, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "save_state", (PyCFunction)_wrap_gimp_color_display_save_state, METH_NOARGS,
+ NULL },
+ { "configure", (PyCFunction)_wrap_gimp_color_display_configure, METH_NOARGS,
+ NULL },
+ { "configure_reset", (PyCFunction)_wrap_gimp_color_display_configure_reset, METH_NOARGS,
+ NULL },
+ { "changed", (PyCFunction)_wrap_gimp_color_display_changed, METH_NOARGS,
+ NULL },
+ { "set_enabled", (PyCFunction)_wrap_gimp_color_display_set_enabled, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_enabled", (PyCFunction)_wrap_gimp_color_display_get_enabled, METH_NOARGS,
+ NULL },
+ { "get_config", (PyCFunction)_wrap_gimp_color_display_get_config, METH_NOARGS,
+ NULL },
+ { "get_managed", (PyCFunction)_wrap_gimp_color_display_get_managed, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorDisplay_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorDisplay", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorDisplay_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorDisplayStack ----------- */
+
+ static int
+_wrap_gimp_color_display_stack_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.ColorDisplayStack.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorDisplayStack object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_clone(PyGObject *self)
+{
+ GimpColorDisplayStack *ret;
+
+
+ ret = gimp_color_display_stack_clone(GIMP_COLOR_DISPLAY_STACK(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_changed(PyGObject *self)
+{
+
+ gimp_color_display_stack_changed(GIMP_COLOR_DISPLAY_STACK(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_add(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "display", NULL };
+ PyGObject *display;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorDisplayStack.add", kwlist, &PyGimpColorDisplay_Type, &display))
+ return NULL;
+
+ gimp_color_display_stack_add(GIMP_COLOR_DISPLAY_STACK(self->obj), GIMP_COLOR_DISPLAY(display->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_remove(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "display", NULL };
+ PyGObject *display;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorDisplayStack.remove", kwlist, &PyGimpColorDisplay_Type, &display))
+ return NULL;
+
+ gimp_color_display_stack_remove(GIMP_COLOR_DISPLAY_STACK(self->obj), GIMP_COLOR_DISPLAY(display->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_reorder_up(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "display", NULL };
+ PyGObject *display;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorDisplayStack.reorder_up", kwlist, &PyGimpColorDisplay_Type, &display))
+ return NULL;
+
+ gimp_color_display_stack_reorder_up(GIMP_COLOR_DISPLAY_STACK(self->obj), GIMP_COLOR_DISPLAY(display->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_display_stack_reorder_down(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "display", NULL };
+ PyGObject *display;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorDisplayStack.reorder_down", kwlist, &PyGimpColorDisplay_Type, &display))
+ return NULL;
+
+ gimp_color_display_stack_reorder_down(GIMP_COLOR_DISPLAY_STACK(self->obj), GIMP_COLOR_DISPLAY(display->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 2018 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_display_stack_convert_surface(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PycairoSurface *pysurface;
+
+ static char *kwlist[] = { "surface", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpColorDisplayStack.convert_surface",
+ kwlist,
+ &PycairoSurface_Type, &pysurface))
+ return NULL;
+
+ gimp_color_display_stack_convert_surface(GIMP_COLOR_DISPLAY_STACK(self->obj),
+ pysurface->surface);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 1495 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_display_stack_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "buf", "width", "height", "bpp", "bpl", NULL };
+ int buf_len, width, height, bpp, bpl;
+ guchar *buf;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s#iiii:Gimp.ColorDisplayStack.convert", kwlist, &buf, &buf_len, &width, &height, &bpp, &bpl))
+ return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use convert_surface(cairo_surface_t*) instead") < 0)
+ return NULL;
+
+ gimp_color_display_stack_convert(GIMP_COLOR_DISPLAY_STACK(self->obj), buf, width, height, bpp, bpl);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorDisplayStack_methods[] = {
+ { "clone", (PyCFunction)_wrap_gimp_color_display_stack_clone, METH_NOARGS,
+ NULL },
+ { "changed", (PyCFunction)_wrap_gimp_color_display_stack_changed, METH_NOARGS,
+ NULL },
+ { "add", (PyCFunction)_wrap_gimp_color_display_stack_add, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "remove", (PyCFunction)_wrap_gimp_color_display_stack_remove, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "reorder_up", (PyCFunction)_wrap_gimp_color_display_stack_reorder_up, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "reorder_down", (PyCFunction)_wrap_gimp_color_display_stack_reorder_down, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "convert_surface", (PyCFunction)_wrap_gimp_color_display_stack_convert_surface, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "convert", (PyCFunction)_wrap_gimp_color_display_stack_convert, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorDisplayStack_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorDisplayStack", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorDisplayStack_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_display_stack_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorHexEntry ----------- */
+
+static int
+_wrap_gimp_color_hex_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.ColorHexEntry.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorHexEntry object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_hex_entry_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "color", NULL };
+ PyObject *py_color;
+ GimpRGB *color = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorHexEntry.set_color", kwlist, &py_color))
+ return NULL;
+ if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB");
+ return NULL;
+ }
+
+ gimp_color_hex_entry_set_color(GIMP_COLOR_HEX_ENTRY(self->obj), color);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1803 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_hex_entry_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_hex_entry_get_color(GIMP_COLOR_HEX_ENTRY(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+#line 1637 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpColorHexEntry_methods[] = {
+ { "set_color", (PyCFunction)_wrap_gimp_color_hex_entry_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_color", (PyCFunction)_wrap_gimp_color_hex_entry_get_color, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorHexEntry_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorHexEntry", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorHexEntry_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_hex_entry_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorProfileComboBox ----------- */
+
+static int
+_wrap_gimp_color_profile_combo_box_new_with_model(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"dialog", "model", NULL };
+ char *prop_names[] = {"dialog", "model", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:gimpui.ColorProfileComboBox.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorProfileComboBox object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_profile_combo_box_add(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "filename", "label", NULL };
+ char *filename, *label;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ss:Gimp.ColorProfileComboBox.add", kwlist, &filename, &label))
+ return NULL;
+
+ gimp_color_profile_combo_box_add(GIMP_COLOR_PROFILE_COMBO_BOX(self->obj), filename, label);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_profile_combo_box_set_active(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "filename", "label", NULL };
+ char *filename, *label;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ss:Gimp.ColorProfileComboBox.set_active", kwlist, &filename, &label))
+ return NULL;
+
+ gimp_color_profile_combo_box_set_active(GIMP_COLOR_PROFILE_COMBO_BOX(self->obj), filename, label);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_profile_combo_box_get_active(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_color_profile_combo_box_get_active(GIMP_COLOR_PROFILE_COMBO_BOX(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorProfileComboBox_methods[] = {
+ { "add", (PyCFunction)_wrap_gimp_color_profile_combo_box_add, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_active", (PyCFunction)_wrap_gimp_color_profile_combo_box_set_active, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active", (PyCFunction)_wrap_gimp_color_profile_combo_box_get_active, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorProfileComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorProfileComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorProfileComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_profile_combo_box_new_with_model, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorProfileStore ----------- */
+
+ static int
+_wrap_gimp_color_profile_store_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[1];
+ PyObject *parsed_args[1] = {NULL, };
+ char *arg_names[] = {"history", NULL };
+ char *prop_names[] = {"history", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gimpui.ColorProfileStore.__init__" , arg_names , &parsed_args[0]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*1);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorProfileStore object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_profile_store_add(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "filename", "label", NULL };
+ char *filename, *label;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ss:Gimp.ColorProfileStore.add", kwlist, &filename, &label))
+ return NULL;
+
+ gimp_color_profile_store_add(GIMP_COLOR_PROFILE_STORE(self->obj), filename, label);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorProfileStore_methods[] = {
+ { "add", (PyCFunction)_wrap_gimp_color_profile_store_add, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorProfileStore_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorProfileStore", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorProfileStore_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_profile_store_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorScale ----------- */
+
+#line 990 "gimpui.override"
+static int
+_wrap_gimp_color_scale_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_orientation, *py_channel;
+ GtkOrientation orientation;
+ GimpColorSelectorChannel channel;
+
+ static char *kwlist[] = { "orientation", "channel", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OO:gimpui.ColorScale.__init__",
+ kwlist,
+ &py_orientation, &py_channel))
+ return -1;
+
+ if (pyg_enum_get_value(GTK_TYPE_ORIENTATION, py_orientation,
+ (gint*)&orientation))
+ return -1;
+
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_SELECTOR_CHANNEL, py_channel,
+ (gint*)&channel))
+ return -1;
+
+ if (pygobject_construct(self,
+ "orientation", orientation,
+ "channel", channel,
+ NULL))
+ return -1;
+
+ gtk_range_set_flippable (GTK_RANGE (self->obj),
+ orientation == GTK_ORIENTATION_HORIZONTAL);
+
+ return 0;
+}
+#line 1968 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_scale_set_channel(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "channel", NULL };
+ GimpColorSelectorChannel channel;
+ PyObject *py_channel = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorScale.set_channel", kwlist, &py_channel))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_SELECTOR_CHANNEL, py_channel, (gpointer)&channel))
+ return NULL;
+
+ gimp_color_scale_set_channel(GIMP_COLOR_SCALE(self->obj), channel);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_scale_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "rgb", "hsv", NULL };
+ PyObject *py_rgb, *py_hsv;
+ GimpHSV *hsv = NULL;
+ GimpRGB *rgb = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:Gimp.ColorScale.set_color", kwlist, &py_rgb, &py_hsv))
+ return NULL;
+ if (pyg_boxed_check(py_rgb, GIMP_TYPE_RGB))
+ rgb = pyg_boxed_get(py_rgb, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "rgb should be a GimpRGB");
+ return NULL;
+ }
+ if (pyg_boxed_check(py_hsv, GIMP_TYPE_HSV))
+ hsv = pyg_boxed_get(py_hsv, GimpHSV);
+ else {
+ PyErr_SetString(PyExc_TypeError, "hsv should be a GimpHSV");
+ return NULL;
+ }
+
+ gimp_color_scale_set_color(GIMP_COLOR_SCALE(self->obj), rgb, hsv);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorScale_methods[] = {
+ { "set_channel", (PyCFunction)_wrap_gimp_color_scale_set_channel, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_color", (PyCFunction)_wrap_gimp_color_scale_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorScale_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorScale", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorScale_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_scale_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorSelector ----------- */
+
+static int
+_wrap_gimp_color_selector_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "selector_type", "rgb", "hsv", "channel", NULL };
+ PyObject *py_selector_type = NULL, *py_rgb, *py_hsv, *py_channel = NULL;
+ GimpHSV *hsv = NULL;
+ GType selector_type;
+ GimpColorSelectorChannel channel;
+ GimpRGB *rgb = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OOOO:Gimp.ColorSelector.__init__", kwlist, &py_selector_type, &py_rgb, &py_hsv, &py_channel))
+ return -1;
+ if ((selector_type = pyg_type_from_object(py_selector_type)) == 0)
+ return -1;
+ if (pyg_boxed_check(py_rgb, GIMP_TYPE_RGB))
+ rgb = pyg_boxed_get(py_rgb, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "rgb should be a GimpRGB");
+ return -1;
+ }
+ if (pyg_boxed_check(py_hsv, GIMP_TYPE_HSV))
+ hsv = pyg_boxed_get(py_hsv, GimpHSV);
+ else {
+ PyErr_SetString(PyExc_TypeError, "hsv should be a GimpHSV");
+ return -1;
+ }
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_SELECTOR_CHANNEL, py_channel, (gpointer)&channel))
+ return -1;
+ self->obj = (GObject *)gimp_color_selector_new(selector_type, rgb, hsv, channel);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpColorSelector object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_toggles_visible(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "visible", NULL };
+ int visible;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorSelector.set_toggles_visible", kwlist, &visible))
+ return NULL;
+
+ gimp_color_selector_set_toggles_visible(GIMP_COLOR_SELECTOR(self->obj), visible);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_toggles_sensitive(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "sensitive", NULL };
+ int sensitive;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorSelector.set_toggles_sensitive", kwlist, &sensitive))
+ return NULL;
+
+ gimp_color_selector_set_toggles_sensitive(GIMP_COLOR_SELECTOR(self->obj), sensitive);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_show_alpha(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "show_alpha", NULL };
+ int show_alpha;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorSelector.set_show_alpha", kwlist, &show_alpha))
+ return NULL;
+
+ gimp_color_selector_set_show_alpha(GIMP_COLOR_SELECTOR(self->obj), show_alpha);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "rgb", "hsv", NULL };
+ PyObject *py_rgb, *py_hsv;
+ GimpHSV *hsv = NULL;
+ GimpRGB *rgb = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:Gimp.ColorSelector.set_color", kwlist, &py_rgb, &py_hsv))
+ return NULL;
+ if (pyg_boxed_check(py_rgb, GIMP_TYPE_RGB))
+ rgb = pyg_boxed_get(py_rgb, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "rgb should be a GimpRGB");
+ return NULL;
+ }
+ if (pyg_boxed_check(py_hsv, GIMP_TYPE_HSV))
+ hsv = pyg_boxed_get(py_hsv, GimpHSV);
+ else {
+ PyErr_SetString(PyExc_TypeError, "hsv should be a GimpHSV");
+ return NULL;
+ }
+
+ gimp_color_selector_set_color(GIMP_COLOR_SELECTOR(self->obj), rgb, hsv);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_channel(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "channel", NULL };
+ GimpColorSelectorChannel channel;
+ PyObject *py_channel = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorSelector.set_channel", kwlist, &py_channel))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_SELECTOR_CHANNEL, py_channel, (gpointer)&channel))
+ return NULL;
+
+ gimp_color_selector_set_channel(GIMP_COLOR_SELECTOR(self->obj), channel);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_color_changed(PyGObject *self)
+{
+
+ gimp_color_selector_color_changed(GIMP_COLOR_SELECTOR(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_channel_changed(PyGObject *self)
+{
+
+ gimp_color_selector_channel_changed(GIMP_COLOR_SELECTOR(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selector_set_config(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "config", NULL };
+ PyGObject *config;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorSelector.set_config", kwlist, &PyGimpColorConfig_Type, &config))
+ return NULL;
+
+ gimp_color_selector_set_config(GIMP_COLOR_SELECTOR(self->obj), GIMP_COLOR_CONFIG(config->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorSelector_methods[] = {
+ { "set_toggles_visible", (PyCFunction)_wrap_gimp_color_selector_set_toggles_visible, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_toggles_sensitive", (PyCFunction)_wrap_gimp_color_selector_set_toggles_sensitive, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_show_alpha", (PyCFunction)_wrap_gimp_color_selector_set_show_alpha, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_color", (PyCFunction)_wrap_gimp_color_selector_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_channel", (PyCFunction)_wrap_gimp_color_selector_set_channel, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "color_changed", (PyCFunction)_wrap_gimp_color_selector_color_changed, METH_NOARGS,
+ NULL },
+ { "channel_changed", (PyCFunction)_wrap_gimp_color_selector_channel_changed, METH_NOARGS,
+ NULL },
+ { "set_config", (PyCFunction)_wrap_gimp_color_selector_set_config, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorSelector_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorSelector", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorSelector_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_selector_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorScales ----------- */
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorScales_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorScales", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorSelection ----------- */
+
+ static int
+_wrap_gimp_color_selection_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.ColorSelection.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ColorSelection object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_color_selection_set_show_alpha(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "show_alpha", NULL };
+ int show_alpha;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.ColorSelection.set_show_alpha", kwlist, &show_alpha))
+ return NULL;
+
+ gimp_color_selection_set_show_alpha(GIMP_COLOR_SELECTION(self->obj), show_alpha);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selection_get_show_alpha(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_color_selection_get_show_alpha(GIMP_COLOR_SELECTION(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_color_selection_set_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "color", NULL };
+ PyObject *py_color;
+ GimpRGB *color = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorSelection.set_color", kwlist, &py_color))
+ return NULL;
+ if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB");
+ return NULL;
+ }
+
+ gimp_color_selection_set_color(GIMP_COLOR_SELECTION(self->obj), color);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1825 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_selection_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_selection_get_color(GIMP_COLOR_SELECTION(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+#line 2437 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_selection_set_old_color(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "color", NULL };
+ PyObject *py_color;
+ GimpRGB *color = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.ColorSelection.set_old_color", kwlist, &py_color))
+ return NULL;
+ if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB");
+ return NULL;
+ }
+
+ gimp_color_selection_set_old_color(GIMP_COLOR_SELECTION(self->obj), color);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1836 "gimpui.override"
+static PyObject *
+_wrap_gimp_color_selection_get_old_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_selection_get_old_color(GIMP_COLOR_SELECTION(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+#line 2472 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_color_selection_reset(PyGObject *self)
+{
+
+ gimp_color_selection_reset(GIMP_COLOR_SELECTION(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selection_color_changed(PyGObject *self)
+{
+
+ gimp_color_selection_color_changed(GIMP_COLOR_SELECTION(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_color_selection_set_config(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "config", NULL };
+ PyGObject *config;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.ColorSelection.set_config", kwlist, &PyGimpColorConfig_Type, &config))
+ return NULL;
+
+ gimp_color_selection_set_config(GIMP_COLOR_SELECTION(self->obj), GIMP_COLOR_CONFIG(config->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpColorSelection_methods[] = {
+ { "set_show_alpha", (PyCFunction)_wrap_gimp_color_selection_set_show_alpha, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_show_alpha", (PyCFunction)_wrap_gimp_color_selection_get_show_alpha, METH_NOARGS,
+ NULL },
+ { "set_color", (PyCFunction)_wrap_gimp_color_selection_set_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_color", (PyCFunction)_wrap_gimp_color_selection_get_color, METH_NOARGS,
+ NULL },
+ { "set_old_color", (PyCFunction)_wrap_gimp_color_selection_set_old_color, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_old_color", (PyCFunction)_wrap_gimp_color_selection_get_old_color, METH_NOARGS,
+ NULL },
+ { "reset", (PyCFunction)_wrap_gimp_color_selection_reset, METH_NOARGS,
+ NULL },
+ { "color_changed", (PyCFunction)_wrap_gimp_color_selection_color_changed, METH_NOARGS,
+ NULL },
+ { "set_config", (PyCFunction)_wrap_gimp_color_selection_set_config, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorSelection_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorSelection", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorSelection_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_color_selection_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorNotebook ----------- */
+
+static PyObject *
+_wrap_gimp_color_notebook_set_has_page(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_type", "has_page", NULL };
+ PyObject *py_page_type = NULL;
+ int has_page;
+ GType page_type;
+ GtkWidget *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"Oi:Gimp.ColorNotebook.set_has_page", kwlist, &py_page_type, &has_page))
+ return NULL;
+ if ((page_type = pyg_type_from_object(py_page_type)) == 0)
+ return NULL;
+
+ ret = gimp_color_notebook_set_has_page(GIMP_COLOR_NOTEBOOK(self->obj), page_type, has_page);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static const PyMethodDef _PyGimpColorNotebook_methods[] = {
+ { "set_has_page", (PyCFunction)_wrap_gimp_color_notebook_set_has_page, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorNotebook_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorNotebook", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpColorNotebook_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpDialog ----------- */
+
+#line 730 "gimpui.override"
+static void
+pygimp_help_func_marshal(const gchar *help_id, gpointer help_data)
+{
+ GObject *dialog = help_data;
+ PyObject *py_dialog, *help_func, *ret;
+
+ py_dialog = g_object_get_data(dialog, "pygimp-dialog-pyobject");
+ help_func = g_object_get_data(dialog, "pygimp-dialog-help_func");
+
+ ret = PyObject_CallFunction(help_func, "sO", help_id, py_dialog);
+
+ if (ret)
+ Py_DECREF(ret);
+ else
+ PyErr_Print();
+}
+
+static void
+pygimp_help_func_destroy(gpointer data)
+{
+ PyObject *help_func = data;
+
+ Py_DECREF(help_func);
+}
+
+static void
+pygimp_dialog_close(GtkWidget *widget)
+{
+ /* Synthesize delete_event to close dialog. */
+
+ if (gtk_widget_get_window (widget)) {
+ GdkEvent *event = gdk_event_new(GDK_DELETE);
+
+ event->any.window = g_object_ref (gtk_widget_get_window (widget));
+ event->any.send_event = TRUE;
+
+ gtk_main_do_event(event);
+ gdk_event_free(event);
+ }
+}
+
+static int
+_wrap_gimp_dialog_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *title, *role;
+ PyGObject *py_window = NULL;
+ PyObject *py_flags = NULL, *py_buttons = Py_None;
+ PyObject *help_func = NULL;
+ gchar *help_id = NULL;
+ GtkDialogFlags flags = 0;
+ int len, i;
+ GtkWidget *parent;
+ GimpHelpFunc func;
+
+ static char *kwlist[] = { "title", "role", "parent", "flags",
+ "help_func", "help_id", "buttons", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "zz|OOOzO:gimpui.GimpDialog.__init__",
+ kwlist,
+ &title, &role, &py_window, &py_flags,
+ &help_func, &help_id, &py_buttons))
+ return -1;
+
+ if (py_window == NULL || (PyObject*)py_window == Py_None)
+ parent = NULL;
+ else if (pygobject_check(py_window, &PyGtkWindow_Type))
+ parent = GTK_WIDGET(py_window->obj);
+ else {
+ PyErr_SetString(PyExc_TypeError, "parent must be a GtkWindow or None");
+ return -1;
+ }
+
+ if (pyg_flags_get_value(GTK_TYPE_DIALOG_FLAGS, py_flags, (gint *)&flags))
+ return -1;
+
+ if (py_buttons == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_buttons))
+ len = PyTuple_Size(py_buttons);
+ else {
+ PyErr_SetString(PyExc_TypeError, "buttons must be a tuple containing text/response pairs or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "buttons tuple must contain text/response id pairs");
+ return -1;
+ }
+
+ if (help_func) {
+ if (help_func != Py_None) {
+ if (!PyCallable_Check(help_func)) {
+ PyErr_SetString(PyExc_TypeError, "help_func must be callable");
+ return -1;
+ }
+
+ func = pygimp_help_func_marshal;
+
+ } else {
+ func = gimp_standard_help_func;
+ }
+ } else {
+ func = gimp_standard_help_func;
+ }
+
+ pygobject_construct(self,
+ "title", title,
+ "role", role,
+ "modal", (flags & GTK_DIALOG_MODAL),
+ "help-func", func,
+ "help-id", help_id,
+ NULL);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpDialog object");
+ return -1;
+ }
+
+ if (parent) {
+ if (GTK_IS_WINDOW(parent))
+ gtk_window_set_transient_for(GTK_WINDOW(self->obj),
+ GTK_WINDOW(parent));
+ else
+ gtk_window_set_screen(GTK_WINDOW(self->obj),
+ gtk_widget_get_screen(parent));
+
+ if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
+ g_signal_connect_object(parent, "destroy",
+ G_CALLBACK(pygimp_dialog_close),
+ self->obj, G_CONNECT_SWAPPED);
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *text = PyTuple_GetItem(py_buttons, i);
+ PyObject *id = PyTuple_GetItem(py_buttons, i + 1);
+ if (!PyString_Check(text) && !PyUnicode_Check(text)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each text/response id pair "
+ "must be a string");
+ return -1;
+ }
+ if (!PyInt_Check(id)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each text/response id pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_dialog_add_button(GIMP_DIALOG(self->obj), PyString_AsString(text),
+ PyInt_AsLong(id));
+ }
+
+ if (help_func && help_func != Py_None) {
+ g_object_set_data(self->obj, "pygimp-dialog-help-data", self);
+
+ Py_INCREF(help_func);
+ g_object_set_data_full(self->obj, "pygimp-dialog-help-func",
+ help_func, pygimp_help_func_destroy);
+ }
+
+ return 0;
+}
+#line 2826 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_dialog_add_button(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "button_text", "response_id", NULL };
+ char *button_text;
+ int response_id;
+ GtkWidget *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"si:Gimp.Dialog.add_button", kwlist, &button_text, &response_id))
+ return NULL;
+
+ ret = gimp_dialog_add_button(GIMP_DIALOG(self->obj), button_text, response_id);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_dialog_run(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_dialog_run(GIMP_DIALOG(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+#line 932 "gimpui.override"
+static PyObject *
+_wrap_gimp_window_set_transient(PyGObject *self)
+{
+ gimp_window_set_transient(GTK_WINDOW(self->obj));
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 2865 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpDialog_methods[] = {
+ { "add_button", (PyCFunction)_wrap_gimp_dialog_add_button, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "run", (PyCFunction)_wrap_gimp_dialog_run, METH_NOARGS,
+ NULL },
+ { "set_transient", (PyCFunction)_wrap_gimp_window_set_transient, METH_VARARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpDialog_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Dialog", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpDialog_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_dialog_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpEnumLabel ----------- */
+
+#line 1028 "gimpui.override"
+static int
+_wrap_gimp_enum_label_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_enum_type = NULL;
+ GType enum_type;
+ gint value;
+
+ static char *kwlist[] = { "enum_type", "value", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Oi:gimpui.GimpEnumLabel.__init__",
+ kwlist,
+ &py_enum_type, &value))
+ return -1;
+
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return -1;
+
+ if (pygobject_construct(self,
+ "enum-type", enum_type,
+ "enum-value", value,
+ NULL))
+ return -1;
+
+ return 0;
+}
+#line 2954 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_enum_label_set_value(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", NULL };
+ int value;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.EnumLabel.set_value", kwlist, &value))
+ return NULL;
+
+ gimp_enum_label_set_value(GIMP_ENUM_LABEL(self->obj), value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpEnumLabel_methods[] = {
+ { "set_value", (PyCFunction)_wrap_gimp_enum_label_set_value, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumLabel_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.EnumLabel", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpEnumLabel_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_enum_label_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpFrame ----------- */
+
+static int
+_wrap_gimp_frame_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[1];
+ PyObject *parsed_args[1] = {NULL, };
+ char *arg_names[] = {"label", NULL };
+ char *prop_names[] = {"label", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gimpui.Frame.__init__" , arg_names , &parsed_args[0]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*1);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.Frame object");
+ return -1;
+ }
+ return 0;
+}
+
+PyTypeObject G_GNUC_INTERNAL PyGimpFrame_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Frame", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_frame_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpHintBox ----------- */
+
+ static int
+_wrap_gimp_hint_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"hint", "stock-id", NULL };
+ char *prop_names[] = {"hint", "stock-id", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:gimpui.HintBox.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.HintBox object");
+ return -1;
+ }
+ return 0;
+}
+
+PyTypeObject G_GNUC_INTERNAL PyGimpHintBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.HintBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_hint_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpIntComboBox ----------- */
+
+#line 1058 "gimpui.override"
+static int
+_wrap_gimp_int_combo_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_items = NULL;
+ int len, i;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|O:gimpui.IntComboBox.__init__",
+ kwlist,
+ &py_items))
+ return -1;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return -1;
+ }
+
+ if (pygobject_construct(self, NULL))
+ return -1;
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_int_combo_box_append(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ return 0;
+}
+#line 3252 "gimpui.c"
+
+
+#line 1312 "gimpui.override"
+static PyObject *
+_wrap_gimp_int_combo_box_prepend(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_items;
+ int i, len;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:gimpui.IntComboBox.prepend",
+ kwlist,
+ &py_items))
+ return NULL;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return NULL;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return NULL;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return NULL;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return NULL;
+ }
+
+ gimp_int_combo_box_prepend(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3317 "gimpui.c"
+
+
+#line 1249 "gimpui.override"
+static PyObject *
+_wrap_gimp_int_combo_box_append(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_items;
+ int i, len;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:gimpui.IntComboBox.append",
+ kwlist,
+ &py_items))
+ return NULL;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return NULL;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return NULL;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return NULL;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return NULL;
+ }
+
+ gimp_int_combo_box_append(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3382 "gimpui.c"
+
+
+#line 1224 "gimpui.override"
+static PyObject *
+_wrap_gimp_int_combo_box_set_active(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ int value;
+
+ static char *kwlist[] = { "value", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "i:GimpIntComboBox.set_active", kwlist,
+ &value))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), value)) {
+ PyErr_Format(pygimp_error,
+ "Value %d does not exist in GimpIntComboBox",
+ value);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3409 "gimpui.c"
+
+
+#line 1211 "gimpui.override"
+static PyObject *
+_wrap_gimp_int_combo_box_get_active(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return PyLong_FromLong(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3424 "gimpui.c"
+
+
+#line 1128 "gimpui.override"
+static gboolean
+pygimp_int_combo_box_sensitivity_marshal(gint value, gpointer user_data)
+{
+ PyObject *py_value;
+ PyGimpIntSensitivityData *data;
+ PyObject *ret;
+ gboolean res;
+
+ data = user_data;
+
+ py_value = PyInt_FromLong(value);
+
+ ret = PyObject_CallFunctionObjArgs(data->sensitivity_func, py_value,
+ data->user_data, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(py_value);
+
+ return res;
+}
+
+static void
+pygimp_int_combo_box_sensitivity_data_destroy(gpointer user_data)
+{
+ PyGimpIntSensitivityData *data;
+ data = user_data;
+
+ Py_DECREF(data->sensitivity_func);
+ Py_XDECREF(data->user_data);
+
+ g_free(data);
+}
+
+static PyObject *
+_wrap_gimp_int_combo_box_set_sensitivity(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_sensitivity_func;
+ PyObject *py_user_data = NULL;
+ PyGimpIntSensitivityData *data;
+
+ static char *kwlist[] = { "sensitivity_func", "user_data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|O:GimpIntComboBox.set_sensitivity",
+ kwlist, &py_sensitivity_func,
+ &py_user_data))
+ return NULL;
+
+ if (!PyCallable_Check(py_sensitivity_func)) {
+ PyErr_SetString(PyExc_TypeError, "first argument must be callable.");
+ return NULL;
+ }
+
+ data = g_new(PyGimpIntSensitivityData, 1);
+
+ data->sensitivity_func = py_sensitivity_func;
+ Py_INCREF(data->sensitivity_func);
+
+ if (py_user_data == NULL || py_user_data == Py_None)
+ data->user_data = NULL;
+ else {
+ data->user_data = py_user_data;
+ Py_INCREF(data->user_data);
+ }
+
+ gimp_int_combo_box_set_sensitivity(GIMP_INT_COMBO_BOX(self->obj),
+ pygimp_int_combo_box_sensitivity_marshal,
+ data,
+ pygimp_int_combo_box_sensitivity_data_destroy);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3509 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpIntComboBox_methods[] = {
+ { "prepend", (PyCFunction)_wrap_gimp_int_combo_box_prepend, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "append", (PyCFunction)_wrap_gimp_int_combo_box_append, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_active", (PyCFunction)_wrap_gimp_int_combo_box_set_active, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active", (PyCFunction)_wrap_gimp_int_combo_box_get_active, METH_NOARGS,
+ NULL },
+ { "set_sensitivity", (PyCFunction)_wrap_gimp_int_combo_box_set_sensitivity, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpIntComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.IntComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpIntComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_int_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpImageComboBox ----------- */
+
+#line 609 "gimpui.override"
+static gboolean
+pygimp_image_constraint_marshal(gint32 image_id, gpointer user_data)
+{
+ PyObject *img, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_image_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpImageConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.ImageComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_image_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_image_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_IMAGE_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.ImageComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 3656 "gimpui.c"
+
+
+#line 717 "gimpui.override"
+static PyObject *
+_wrap_gimp_image_combo_box_get_active_image(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_image_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3671 "gimpui.c"
+
+
+#line 691 "gimpui.override"
+static PyObject *
+_wrap_gimp_image_combo_box_set_active_image(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpImage *img;
+
+ static char *kwlist[] = { "image", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpImageComboBox.set_active_image",
+ kwlist,
+ PyGimpImage_Type, &img))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), img->ID)) {
+ PyErr_Format(pygimp_error,
+ "Image (ID %d) does not exist in GimpImageComboBox",
+ img->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3699 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpImageComboBox_methods[] = {
+ { "get_active_image", (PyCFunction)_wrap_gimp_image_combo_box_get_active_image, METH_NOARGS,
+ NULL },
+ { "set_active_image", (PyCFunction)_wrap_gimp_image_combo_box_set_active_image, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpImageComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ImageComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpImageComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_image_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpEnumComboBox ----------- */
+
+static int
+_wrap_gimp_enum_combo_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enum_type", NULL };
+ PyObject *py_enum_type = NULL;
+ GType enum_type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.EnumComboBox.__init__", kwlist, &py_enum_type))
+ return -1;
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return -1;
+ self->obj = (GObject *)gimp_enum_combo_box_new(enum_type);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpEnumComboBox object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_enum_combo_box_set_stock_prefix(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "stock_prefix", NULL };
+ char *stock_prefix;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.EnumComboBox.set_stock_prefix", kwlist, &stock_prefix))
+ return NULL;
+
+ gimp_enum_combo_box_set_stock_prefix(GIMP_ENUM_COMBO_BOX(self->obj), stock_prefix);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpEnumComboBox_methods[] = {
+ { "set_stock_prefix", (PyCFunction)_wrap_gimp_enum_combo_box_set_stock_prefix, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.EnumComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpEnumComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_enum_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpDrawableComboBox ----------- */
+
+#line 89 "gimpui.override"
+static gboolean
+pygimp_drawable_constraint_marshal(gint32 image_id, gint32 drawable_id,
+ gpointer user_data)
+{
+ PyObject *img, *drw, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ drw = pygimp_drawable_new(NULL, drawable_id);
+ if (!drw) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, drw,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, drw, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(drw);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_drawable_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.DrawableComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_XINCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_drawable_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_drawable_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_DRAWABLE_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.DrawableComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 3940 "gimpui.c"
+
+
+#line 180 "gimpui.override"
+static PyObject *
+_wrap_gimp_drawable_combo_box_set_active_drawable(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpDrawable *drw;
+
+ static char *kwlist[] = { "drawable", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpDrawableComboBox.set_active_drawable",
+ kwlist,
+ PyGimpDrawable_Type, &drw))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), drw->ID)) {
+ PyErr_Format(pygimp_error,
+ "Drawable (ID %d) does not exist in GimpDrawableComboBox",
+ drw->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3968 "gimpui.c"
+
+
+#line 206 "gimpui.override"
+static PyObject *
+_wrap_gimp_drawable_combo_box_get_active_drawable(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_drawable_new(NULL, value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 3983 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpDrawableComboBox_methods[] = {
+ { "set_active_drawable", (PyCFunction)_wrap_gimp_drawable_combo_box_set_active_drawable, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active_drawable", (PyCFunction)_wrap_gimp_drawable_combo_box_get_active_drawable, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpDrawableComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.DrawableComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpDrawableComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_drawable_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpChannelComboBox ----------- */
+
+#line 219 "gimpui.override"
+static gboolean
+pygimp_channel_constraint_marshal(gint32 image_id, gint32 channel_id,
+ gpointer user_data)
+{
+ PyObject *img, *chn, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ chn = pygimp_channel_new(channel_id);
+ if (!chn) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, chn,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, chn, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(chn);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_channel_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.ChannelComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_channel_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_channel_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_CHANNEL_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.ChannelComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 4133 "gimpui.c"
+
+
+#line 310 "gimpui.override"
+static PyObject *
+_wrap_gimp_channel_combo_box_set_active_channel(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpChannel *chn;
+
+ static char *kwlist[] = { "channel", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpChannelComboBox.set_active_channel",
+ kwlist,
+ PyGimpChannel_Type, &chn))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "Channel (ID %d) does not exist in GimpChannelComboBox",
+ chn->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4161 "gimpui.c"
+
+
+#line 336 "gimpui.override"
+static PyObject *
+_wrap_gimp_channel_combo_box_get_active_channel(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_channel_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4176 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpChannelComboBox_methods[] = {
+ { "set_active_channel", (PyCFunction)_wrap_gimp_channel_combo_box_set_active_channel, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active_channel", (PyCFunction)_wrap_gimp_channel_combo_box_get_active_channel, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpChannelComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ChannelComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpChannelComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_channel_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpIntStore ----------- */
+
+ static int
+_wrap_gimp_int_store_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.IntStore.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.IntStore object");
+ return -1;
+ }
+ return 0;
+}
+
+#line 1727 "gimpui.override"
+static PyObject *
+_wrap_gimp_int_store_lookup_by_value(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", NULL };
+ int value, ret;
+ GtkTreeIter iter;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "i:GimpIntStore.gimp_int_store_lookup_by_value",
+ kwlist, &value))
+ return NULL;
+
+ ret = gimp_int_store_lookup_by_value(GTK_TREE_MODEL(self->obj), value,
+ &iter);
+ if (ret)
+ pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4278 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpIntStore_methods[] = {
+ { "lookup_by_value", (PyCFunction)_wrap_gimp_int_store_lookup_by_value, METH_VARARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpIntStore_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.IntStore", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpIntStore_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_int_store_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpEnumStore ----------- */
+
+#line 1847 "gimpui.override"
+static int
+_wrap_gimp_enum_store_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enum_type", "minimum", "maximum", NULL };
+ PyObject *py_enum_type = NULL;
+ PyObject *py_minimum = NULL;
+ PyObject *py_maximum = NULL;
+ GType enum_type;
+ GEnumClass *enum_class;
+ gint minimum, maximum;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|O!O!:GimpEnumStore.__init__", kwlist,
+ &py_enum_type, &PyInt_Type, &py_minimum,
+ &PyInt_Type, &py_maximum))
+ return -1;
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return -1;
+
+ enum_class = g_type_class_ref(enum_type);
+
+ if (py_minimum == NULL)
+ minimum = enum_class->minimum;
+ else
+ minimum = PyInt_AsLong(py_minimum);
+
+ if (py_maximum == NULL)
+ maximum = enum_class->maximum;
+ else
+ maximum = PyInt_AsLong(py_maximum);
+
+ g_type_class_unref(enum_class);
+
+ self->obj = (GObject *)gimp_enum_store_new_with_range(enum_type, minimum, maximum);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpEnumStore object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 4379 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_enum_store_set_stock_prefix(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "stock_prefix", NULL };
+ char *stock_prefix;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.EnumStore.set_stock_prefix", kwlist, &stock_prefix))
+ return NULL;
+
+ gimp_enum_store_set_stock_prefix(GIMP_ENUM_STORE(self->obj), stock_prefix);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpEnumStore_methods[] = {
+ { "set_stock_prefix", (PyCFunction)_wrap_gimp_enum_store_set_stock_prefix, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpEnumStore_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.EnumStore", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpEnumStore_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_enum_store_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpLayerComboBox ----------- */
+
+#line 349 "gimpui.override"
+static gboolean
+pygimp_layer_constraint_marshal(gint32 image_id, gint32 layer_id,
+ gpointer user_data)
+{
+ PyObject *img, *lay, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ lay = pygimp_layer_new(layer_id);
+ if (!lay) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, lay,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, lay, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(lay);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_layer_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.LayerComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_layer_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_layer_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_LAYER_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.LayerComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 4542 "gimpui.c"
+
+
+#line 466 "gimpui.override"
+static PyObject *
+_wrap_gimp_layer_combo_box_get_active_layer(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_layer_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4557 "gimpui.c"
+
+
+#line 440 "gimpui.override"
+static PyObject *
+_wrap_gimp_layer_combo_box_set_active_layer(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpLayer *lay;
+
+ static char *kwlist[] = { "layer", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpLayerComboBox.set_active_layer",
+ kwlist,
+ PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "Layer (ID %d) does not exist in GimpLayerComboBox",
+ lay->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4585 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpLayerComboBox_methods[] = {
+ { "get_active_layer", (PyCFunction)_wrap_gimp_layer_combo_box_get_active_layer, METH_NOARGS,
+ NULL },
+ { "set_active_layer", (PyCFunction)_wrap_gimp_layer_combo_box_set_active_layer, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpLayerComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.LayerComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpLayerComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_layer_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpMemsizeEntry ----------- */
+
+#line 1750 "gimpui.override"
+static int
+_wrap_gimp_memsize_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", "lower", "upper", NULL };
+ guint64 value, lower, upper;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "LLL:GimpMemsizeEntry.__init__",
+ kwlist, &value, &lower, &upper))
+ return -1;
+
+ self->obj = (GObject *)gimp_memsize_entry_new(value, lower, upper);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpMemsizeEntry object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 4667 "gimpui.c"
+
+
+#line 1773 "gimpui.override"
+static PyObject *
+_wrap_gimp_memsize_entry_set_value(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", NULL };
+ guint64 value;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "L:GimpMemsizeEntry.set_value",
+ kwlist, &value))
+ return NULL;
+
+ gimp_memsize_entry_set_value(GIMP_MEMSIZE_ENTRY(self->obj), value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4688 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_memsize_entry_get_value(PyGObject *self)
+{
+ guint64 ret;
+
+
+ ret = gimp_memsize_entry_get_value(GIMP_MEMSIZE_ENTRY(self->obj));
+
+ return PyLong_FromUnsignedLongLong(ret);
+}
+
+static const PyMethodDef _PyGimpMemsizeEntry_methods[] = {
+ { "set_value", (PyCFunction)_wrap_gimp_memsize_entry_set_value, METH_VARARGS,
+ NULL },
+ { "get_value", (PyCFunction)_wrap_gimp_memsize_entry_get_value, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpMemsizeEntry_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.MemsizeEntry", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpMemsizeEntry_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_memsize_entry_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpNumberPairEntry ----------- */
+
+static int
+_wrap_gimp_number_pair_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[4];
+ PyObject *parsed_args[4] = {NULL, };
+ char *arg_names[] = {"separators", "allow_simplification", "min_valid_value", "max_valid_value", NULL };
+ char *prop_names[] = {"separators", "allow-simplification", "min-valid-value", "max-valid-value", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:gimpui.NumberPairEntry.__init__" , arg_names , &parsed_args[0] , &parsed_args[1] , &parsed_args[2] , &parsed_args[3]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*4);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.NumberPairEntry object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_number_pair_entry_set_default_values(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "left", "right", NULL };
+ double left, right;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"dd:Gimp.NumberPairEntry.set_default_values", kwlist, &left, &right))
+ return NULL;
+
+ gimp_number_pair_entry_set_default_values(GIMP_NUMBER_PAIR_ENTRY(self->obj), left, right);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1523 "gimpui.override"
+static PyObject *
+_wrap_gimp_number_pair_entry_get_default_values(PyGObject *self)
+{
+ gdouble left, right;
+
+ gimp_number_pair_entry_get_default_values(
+ GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ &left, &right);
+
+ return Py_BuildValue("(dd)", left, right);
+}
+#line 4816 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_number_pair_entry_set_values(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "left", "right", NULL };
+ double left, right;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"dd:Gimp.NumberPairEntry.set_values", kwlist, &left, &right))
+ return NULL;
+
+ gimp_number_pair_entry_set_values(GIMP_NUMBER_PAIR_ENTRY(self->obj), left, right);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1511 "gimpui.override"
+static PyObject *
+_wrap_gimp_number_pair_entry_get_values(PyGObject *self)
+{
+ gdouble left, right;
+
+ gimp_number_pair_entry_get_values(GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ &left, &right);
+
+ return Py_BuildValue("(dd)", left, right);
+}
+#line 4845 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_number_pair_entry_set_default_text(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "string", NULL };
+ char *string;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.NumberPairEntry.set_default_text", kwlist, &string))
+ return NULL;
+
+ gimp_number_pair_entry_set_default_text(GIMP_NUMBER_PAIR_ENTRY(self->obj), string);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_number_pair_entry_get_default_text(PyGObject *self)
+{
+ const gchar *ret;
+
+
+ ret = gimp_number_pair_entry_get_default_text(GIMP_NUMBER_PAIR_ENTRY(self->obj));
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_number_pair_entry_set_ratio(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "ratio", NULL };
+ double ratio;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"d:Gimp.NumberPairEntry.set_ratio", kwlist, &ratio))
+ return NULL;
+
+ gimp_number_pair_entry_set_ratio(GIMP_NUMBER_PAIR_ENTRY(self->obj), ratio);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_number_pair_entry_get_ratio(PyGObject *self)
+{
+ double ret;
+
+
+ ret = gimp_number_pair_entry_get_ratio(GIMP_NUMBER_PAIR_ENTRY(self->obj));
+
+ return PyFloat_FromDouble(ret);
+}
+
+#line 1548 "gimpui.override"
+static PyObject *
+_wrap_gimp_number_pair_entry_set_aspect(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_aspect;
+ GimpAspectType aspect;
+
+ static char *kwlist[] = {"aspect", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:GimpNumberPairEntry.set_aspect",
+ kwlist, &py_aspect))
+ return NULL;
+
+ if (pyg_enum_get_value(GIMP_TYPE_ASPECT_TYPE, py_aspect, (gint*)&aspect))
+ {
+ Py_XDECREF(py_aspect);
+ return NULL;
+ }
+
+ gimp_number_pair_entry_set_aspect(GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ aspect);
+
+ Py_DECREF(py_aspect);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 4932 "gimpui.c"
+
+
+#line 1536 "gimpui.override"
+static PyObject *
+_wrap_gimp_number_pair_entry_get_aspect(PyGObject *self)
+{
+ GimpAspectType aspect;
+
+ aspect =
+ gimp_number_pair_entry_get_aspect(GIMP_NUMBER_PAIR_ENTRY(self->obj));
+
+ return pyg_enum_from_gtype(GIMP_TYPE_ASPECT_TYPE, aspect);
+}
+#line 4946 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_number_pair_entry_set_user_override(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "user_override", NULL };
+ int user_override;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.NumberPairEntry.set_user_override", kwlist, &user_override))
+ return NULL;
+
+ gimp_number_pair_entry_set_user_override(GIMP_NUMBER_PAIR_ENTRY(self->obj), user_override);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_number_pair_entry_get_user_override(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_number_pair_entry_get_user_override(GIMP_NUMBER_PAIR_ENTRY(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static const PyMethodDef _PyGimpNumberPairEntry_methods[] = {
+ { "set_default_values", (PyCFunction)_wrap_gimp_number_pair_entry_set_default_values, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_default_values", (PyCFunction)_wrap_gimp_number_pair_entry_get_default_values, METH_NOARGS,
+ NULL },
+ { "set_values", (PyCFunction)_wrap_gimp_number_pair_entry_set_values, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_values", (PyCFunction)_wrap_gimp_number_pair_entry_get_values, METH_NOARGS,
+ NULL },
+ { "set_default_text", (PyCFunction)_wrap_gimp_number_pair_entry_set_default_text, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_default_text", (PyCFunction)_wrap_gimp_number_pair_entry_get_default_text, METH_NOARGS,
+ NULL },
+ { "set_ratio", (PyCFunction)_wrap_gimp_number_pair_entry_set_ratio, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_ratio", (PyCFunction)_wrap_gimp_number_pair_entry_get_ratio, METH_NOARGS,
+ NULL },
+ { "set_aspect", (PyCFunction)_wrap_gimp_number_pair_entry_set_aspect, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_aspect", (PyCFunction)_wrap_gimp_number_pair_entry_get_aspect, METH_NOARGS,
+ NULL },
+ { "set_user_override", (PyCFunction)_wrap_gimp_number_pair_entry_set_user_override, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_user_override", (PyCFunction)_wrap_gimp_number_pair_entry_get_user_override, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpNumberPairEntry_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.NumberPairEntry", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpNumberPairEntry_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_number_pair_entry_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpOffsetArea ----------- */
+
+static int
+_wrap_gimp_offset_area_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "orig_width", "orig_height", NULL };
+ int orig_width, orig_height;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.OffsetArea.__init__", kwlist, &orig_width, &orig_height))
+ return -1;
+ self->obj = (GObject *)gimp_offset_area_new(orig_width, orig_height);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpOffsetArea object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_offset_area_set_pixbuf(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "pixbuf", NULL };
+ PyGObject *pixbuf;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:Gimp.OffsetArea.set_pixbuf", kwlist, &PyGdkPixbuf_Type, &pixbuf))
+ return NULL;
+
+ gimp_offset_area_set_pixbuf(GIMP_OFFSET_AREA(self->obj), GDK_PIXBUF(pixbuf->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_offset_area_set_size(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "width", "height", NULL };
+ int width, height;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.OffsetArea.set_size", kwlist, &width, &height))
+ return NULL;
+
+ gimp_offset_area_set_size(GIMP_OFFSET_AREA(self->obj), width, height);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_offset_area_set_offsets(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "offset_x", "offset_y", NULL };
+ int offset_x, offset_y;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.OffsetArea.set_offsets", kwlist, &offset_x, &offset_y))
+ return NULL;
+
+ gimp_offset_area_set_offsets(GIMP_OFFSET_AREA(self->obj), offset_x, offset_y);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpOffsetArea_methods[] = {
+ { "set_pixbuf", (PyCFunction)_wrap_gimp_offset_area_set_pixbuf, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_size", (PyCFunction)_wrap_gimp_offset_area_set_size, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_offsets", (PyCFunction)_wrap_gimp_offset_area_set_offsets, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpOffsetArea_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.OffsetArea", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpOffsetArea_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_offset_area_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPageSelector ----------- */
+
+ static int
+_wrap_gimp_page_selector_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.PageSelector.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PageSelector object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_set_n_pages(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "n_pages", NULL };
+ int n_pages;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.set_n_pages", kwlist, &n_pages))
+ return NULL;
+
+ gimp_page_selector_set_n_pages(GIMP_PAGE_SELECTOR(self->obj), n_pages);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_get_n_pages(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_page_selector_get_n_pages(GIMP_PAGE_SELECTOR(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static PyObject *
+_wrap_gimp_page_selector_set_target(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "target", NULL };
+ GimpPageSelectorTarget target;
+ PyObject *py_target = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.PageSelector.set_target", kwlist, &py_target))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_PAGE_SELECTOR_TARGET, py_target, (gpointer)&target))
+ return NULL;
+
+ gimp_page_selector_set_target(GIMP_PAGE_SELECTOR(self->obj), target);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_get_target(PyGObject *self)
+{
+ gint ret;
+
+
+ ret = gimp_page_selector_get_target(GIMP_PAGE_SELECTOR(self->obj));
+
+ return pyg_enum_from_gtype(GIMP_TYPE_PAGE_SELECTOR_TARGET, ret);
+}
+
+static PyObject *
+_wrap_gimp_page_selector_set_page_thumbnail(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", "thumbnail", NULL };
+ int page_no;
+ PyGObject *thumbnail;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iO!:Gimp.PageSelector.set_page_thumbnail", kwlist, &page_no, &PyGdkPixbuf_Type, &thumbnail))
+ return NULL;
+
+ gimp_page_selector_set_page_thumbnail(GIMP_PAGE_SELECTOR(self->obj), page_no, GDK_PIXBUF(thumbnail->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_get_page_thumbnail(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", NULL };
+ int page_no;
+ GdkPixbuf *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.get_page_thumbnail", kwlist, &page_no))
+ return NULL;
+
+ ret = gimp_page_selector_get_page_thumbnail(GIMP_PAGE_SELECTOR(self->obj), page_no);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_page_selector_set_page_label(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", "label", NULL };
+ int page_no;
+ char *label;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"is:Gimp.PageSelector.set_page_label", kwlist, &page_no, &label))
+ return NULL;
+
+ gimp_page_selector_set_page_label(GIMP_PAGE_SELECTOR(self->obj), page_no, label);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_get_page_label(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", NULL };
+ int page_no;
+ gchar *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.get_page_label", kwlist, &page_no))
+ return NULL;
+
+ ret = gimp_page_selector_get_page_label(GIMP_PAGE_SELECTOR(self->obj), page_no);
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_select_all(PyGObject *self)
+{
+
+ gimp_page_selector_select_all(GIMP_PAGE_SELECTOR(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_unselect_all(PyGObject *self)
+{
+
+ gimp_page_selector_unselect_all(GIMP_PAGE_SELECTOR(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_select_page(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", NULL };
+ int page_no;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.select_page", kwlist, &page_no))
+ return NULL;
+
+ gimp_page_selector_select_page(GIMP_PAGE_SELECTOR(self->obj), page_no);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_unselect_page(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", NULL };
+ int page_no;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.unselect_page", kwlist, &page_no))
+ return NULL;
+
+ gimp_page_selector_unselect_page(GIMP_PAGE_SELECTOR(self->obj), page_no);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_page_is_selected(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "page_no", NULL };
+ int page_no, ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.PageSelector.page_is_selected", kwlist, &page_no))
+ return NULL;
+
+ ret = gimp_page_selector_page_is_selected(GIMP_PAGE_SELECTOR(self->obj), page_no);
+
+ return PyBool_FromLong(ret);
+
+}
+
+#line 1578 "gimpui.override"
+static PyObject *
+_wrap_gimp_page_selector_get_selected_pages(PyGObject *self)
+{
+ gint *selected_pages;
+ gint n_selected_pages;
+ PyObject *py_selected_pages;
+ int i;
+
+ selected_pages = gimp_page_selector_get_selected_pages(
+ GIMP_PAGE_SELECTOR (self->obj),
+ &n_selected_pages);
+
+ py_selected_pages = PyTuple_New(n_selected_pages);
+ for (i = 0; i < n_selected_pages; ++i)
+ PyTuple_SetItem(py_selected_pages, i,
+ PyInt_FromLong(selected_pages[i]));
+
+ g_free(selected_pages);
+
+ return py_selected_pages;
+}
+#line 5406 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_page_selector_select_range(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "range", NULL };
+ char *range;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PageSelector.select_range", kwlist, &range))
+ return NULL;
+
+ gimp_page_selector_select_range(GIMP_PAGE_SELECTOR(self->obj), range);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_page_selector_get_selected_range(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_page_selector_get_selected_range(GIMP_PAGE_SELECTOR(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpPageSelector_methods[] = {
+ { "set_n_pages", (PyCFunction)_wrap_gimp_page_selector_set_n_pages, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_n_pages", (PyCFunction)_wrap_gimp_page_selector_get_n_pages, METH_NOARGS,
+ NULL },
+ { "set_target", (PyCFunction)_wrap_gimp_page_selector_set_target, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_target", (PyCFunction)_wrap_gimp_page_selector_get_target, METH_NOARGS,
+ NULL },
+ { "set_page_thumbnail", (PyCFunction)_wrap_gimp_page_selector_set_page_thumbnail, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_page_thumbnail", (PyCFunction)_wrap_gimp_page_selector_get_page_thumbnail, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_page_label", (PyCFunction)_wrap_gimp_page_selector_set_page_label, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_page_label", (PyCFunction)_wrap_gimp_page_selector_get_page_label, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "select_all", (PyCFunction)_wrap_gimp_page_selector_select_all, METH_NOARGS,
+ NULL },
+ { "unselect_all", (PyCFunction)_wrap_gimp_page_selector_unselect_all, METH_NOARGS,
+ NULL },
+ { "select_page", (PyCFunction)_wrap_gimp_page_selector_select_page, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "unselect_page", (PyCFunction)_wrap_gimp_page_selector_unselect_page, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "page_is_selected", (PyCFunction)_wrap_gimp_page_selector_page_is_selected, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_selected_pages", (PyCFunction)_wrap_gimp_page_selector_get_selected_pages, METH_NOARGS,
+ NULL },
+ { "select_range", (PyCFunction)_wrap_gimp_page_selector_select_range, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_selected_range", (PyCFunction)_wrap_gimp_page_selector_get_selected_range, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPageSelector_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PageSelector", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPageSelector_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_page_selector_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPathEditor ----------- */
+
+static int
+_wrap_gimp_path_editor_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"title", "path", NULL };
+ char *prop_names[] = {"title", "path", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:gimpui.PathEditor.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PathEditor object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_path_editor_get_path(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_path_editor_get_path(GIMP_PATH_EDITOR(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_path_editor_set_path(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "path", NULL };
+ char *path;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PathEditor.set_path", kwlist, &path))
+ return NULL;
+
+ gimp_path_editor_set_path(GIMP_PATH_EDITOR(self->obj), path);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_path_editor_get_writable_path(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_path_editor_get_writable_path(GIMP_PATH_EDITOR(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_path_editor_set_writable_path(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "path", NULL };
+ char *path;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PathEditor.set_writable_path", kwlist, &path))
+ return NULL;
+
+ gimp_path_editor_set_writable_path(GIMP_PATH_EDITOR(self->obj), path);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_path_editor_get_dir_writable(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "directory", NULL };
+ char *directory;
+ int ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PathEditor.get_dir_writable", kwlist, &directory))
+ return NULL;
+
+ ret = gimp_path_editor_get_dir_writable(GIMP_PATH_EDITOR(self->obj), directory);
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_path_editor_set_dir_writable(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "directory", "writable", NULL };
+ char *directory;
+ int writable;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"si:Gimp.PathEditor.set_dir_writable", kwlist, &directory, &writable))
+ return NULL;
+
+ gimp_path_editor_set_dir_writable(GIMP_PATH_EDITOR(self->obj), directory, writable);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpPathEditor_methods[] = {
+ { "get_path", (PyCFunction)_wrap_gimp_path_editor_get_path, METH_NOARGS,
+ NULL },
+ { "set_path", (PyCFunction)_wrap_gimp_path_editor_set_path, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_writable_path", (PyCFunction)_wrap_gimp_path_editor_get_writable_path, METH_NOARGS,
+ NULL },
+ { "set_writable_path", (PyCFunction)_wrap_gimp_path_editor_set_writable_path, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_dir_writable", (PyCFunction)_wrap_gimp_path_editor_get_dir_writable, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_dir_writable", (PyCFunction)_wrap_gimp_path_editor_set_dir_writable, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPathEditor_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PathEditor", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPathEditor_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_path_editor_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPickButton ----------- */
+
+ static int
+_wrap_gimp_pick_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.PickButton.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PickButton object");
+ return -1;
+ }
+ return 0;
+}
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPickButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PickButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_pick_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPreview ----------- */
+
+static PyObject *
+_wrap_gimp_preview_set_update(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "update", NULL };
+ int update;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.Preview.set_update", kwlist, &update))
+ return NULL;
+
+ gimp_preview_set_update(GIMP_PREVIEW(self->obj), update);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_get_update(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_preview_get_update(GIMP_PREVIEW(self->obj));
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_preview_set_bounds(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "xmin", "ymin", "xmax", "ymax", NULL };
+ int xmin, ymin, xmax, ymax;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiii:Gimp.Preview.set_bounds", kwlist, &xmin, &ymin, &xmax, &ymax))
+ return NULL;
+
+ gimp_preview_set_bounds(GIMP_PREVIEW(self->obj), xmin, ymin, xmax, ymax);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1601 "gimpui.override"
+static PyObject *
+_wrap_gimp_preview_get_position(PyGObject *self)
+{
+ gint x;
+ gint y;
+
+ gimp_preview_get_position(GIMP_PREVIEW(self->obj), &x, &y);
+
+ return Py_BuildValue("(ii)", x, y);
+}
+#line 5839 "gimpui.c"
+
+
+#line 1613 "gimpui.override"
+static PyObject *
+_wrap_gimp_preview_get_size(PyGObject *self)
+{
+ gint width;
+ gint height;
+
+ gimp_preview_get_size(GIMP_PREVIEW(self->obj), &width, &height);
+
+ return Py_BuildValue("(ii)", width, height);
+}
+#line 5853 "gimpui.c"
+
+
+#line 1625 "gimpui.override"
+static PyObject *
+_wrap_gimp_preview_transform(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gint src_x;
+ gint src_y;
+ gint dest_x;
+ gint dest_y;
+
+ static char *kwlist[] = {"x", "y", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GimpPreview.transform",
+ kwlist, &src_x, &src_y))
+ return NULL;
+
+ gimp_preview_transform(GIMP_PREVIEW(self->obj), src_x, src_y, &dest_x,
+ &dest_y);
+
+ return Py_BuildValue("(ii)", dest_x, dest_y);
+}
+#line 5876 "gimpui.c"
+
+
+#line 1646 "gimpui.override"
+static PyObject *
+_wrap_gimp_preview_untransform(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ gint src_x;
+ gint src_y;
+ gint dest_x;
+ gint dest_y;
+
+ static char *kwlist[] = {"x", "y", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ii:GimpPreview.untransform",
+ kwlist, &src_x, &src_y))
+ return NULL;
+
+ gimp_preview_untransform(GIMP_PREVIEW(self->obj), src_x, src_y, &dest_x,
+ &dest_y);
+
+ return Py_BuildValue("(ii)", dest_x, dest_y);
+}
+#line 5901 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_preview_get_area(PyGObject *self)
+{
+ GtkWidget *ret;
+
+
+ ret = gimp_preview_get_area(GIMP_PREVIEW(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_preview_draw(PyGObject *self)
+{
+
+ gimp_preview_draw(GIMP_PREVIEW(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_draw_buffer(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "buffer", "rowstride", NULL };
+ int buffer_len, rowstride;
+ guchar *buffer;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s#i:Gimp.Preview.draw_buffer", kwlist, &buffer, &buffer_len, &rowstride))
+ return NULL;
+
+ gimp_preview_draw_buffer(GIMP_PREVIEW(self->obj), buffer, rowstride);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_invalidate(PyGObject *self)
+{
+
+ gimp_preview_invalidate(GIMP_PREVIEW(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_set_default_cursor(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "cursor", NULL };
+ PyObject *py_cursor;
+ GdkCursor *cursor = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Preview.set_default_cursor", kwlist, &py_cursor))
+ return NULL;
+ if (pyg_boxed_check(py_cursor, GDK_TYPE_CURSOR))
+ cursor = pyg_boxed_get(py_cursor, GdkCursor);
+ else {
+ PyErr_SetString(PyExc_TypeError, "cursor should be a GdkCursor");
+ return NULL;
+ }
+
+ gimp_preview_set_default_cursor(GIMP_PREVIEW(self->obj), cursor);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_get_controls(PyGObject *self)
+{
+ GtkWidget *ret;
+
+
+ ret = gimp_preview_get_controls(GIMP_PREVIEW(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static const PyMethodDef _PyGimpPreview_methods[] = {
+ { "set_update", (PyCFunction)_wrap_gimp_preview_set_update, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_update", (PyCFunction)_wrap_gimp_preview_get_update, METH_NOARGS,
+ NULL },
+ { "set_bounds", (PyCFunction)_wrap_gimp_preview_set_bounds, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_position", (PyCFunction)_wrap_gimp_preview_get_position, METH_NOARGS,
+ NULL },
+ { "get_size", (PyCFunction)_wrap_gimp_preview_get_size, METH_NOARGS,
+ NULL },
+ { "transform", (PyCFunction)_wrap_gimp_preview_transform, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "untransform", (PyCFunction)_wrap_gimp_preview_untransform, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_area", (PyCFunction)_wrap_gimp_preview_get_area, METH_NOARGS,
+ NULL },
+ { "draw", (PyCFunction)_wrap_gimp_preview_draw, METH_NOARGS,
+ NULL },
+ { "draw_buffer", (PyCFunction)_wrap_gimp_preview_draw_buffer, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "invalidate", (PyCFunction)_wrap_gimp_preview_invalidate, METH_NOARGS,
+ NULL },
+ { "set_default_cursor", (PyCFunction)_wrap_gimp_preview_set_default_cursor, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_controls", (PyCFunction)_wrap_gimp_preview_get_controls, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPreview_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Preview", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPreview_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpAspectPreview ----------- */
+
+#line 1928 "gimpui.override"
+static int
+_wrap_gimp_aspect_preview_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", NULL };
+ PyGimpDrawable *py_drawable;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|:GimpAspectPreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable))
+ return -1;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, NULL))
+ return -1;
+
+ g_signal_connect_swapped(self->obj, "destroy",
+ (GCallback)pygimp_decref_callback, py_drawable);
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+#line 6089 "gimpui.c"
+
+
+PyTypeObject G_GNUC_INTERNAL PyGimpAspectPreview_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.AspectPreview", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_aspect_preview_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPreviewArea ----------- */
+
+static int
+_wrap_gimp_preview_area_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.PreviewArea.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PreviewArea object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_draw(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", "width", "height", "type", "buf", "rowstride", NULL };
+ int x, y, width, height, buf_len, rowstride;
+ PyObject *py_type = NULL;
+ guchar *buf;
+ GimpImageType type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiiiOs#i:Gimp.PreviewArea.draw", kwlist, &x, &y, &width, &height, &py_type, &buf, &buf_len, &rowstride))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_IMAGE_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ gimp_preview_area_draw(GIMP_PREVIEW_AREA(self->obj), x, y, width, height, type, buf, rowstride);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_blend(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", "width", "height", "type", "buf1", "rowstride1", "buf2", "rowstride2", "opacity", NULL };
+ int x, y, width, height, buf1_len, rowstride1, buf2_len, rowstride2;
+ PyObject *py_type = NULL;
+ guchar *buf1, *buf2;
+ char opacity;
+ GimpImageType type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiiiOs#is#ic:Gimp.PreviewArea.blend", kwlist, &x, &y, &width, &height, &py_type, &buf1, &buf1_len, &rowstride1, &buf2, &buf2_len, &rowstride2, &opacity))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_IMAGE_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ gimp_preview_area_blend(GIMP_PREVIEW_AREA(self->obj), x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, opacity);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_mask(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", "width", "height", "type", "buf1", "rowstride1", "buf2", "rowstride2", "mask", "rowstride_mask", NULL };
+ int x, y, width, height, buf1_len, rowstride1, buf2_len, rowstride2, mask_len, rowstride_mask;
+ PyObject *py_type = NULL;
+ guchar *buf1, *buf2, *mask;
+ GimpImageType type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiiiOs#is#is#i:Gimp.PreviewArea.mask", kwlist, &x, &y, &width, &height, &py_type, &buf1, &buf1_len, &rowstride1, &buf2, &buf2_len, &rowstride2, &mask, &mask_len, &rowstride_mask))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_IMAGE_TYPE, py_type, (gpointer)&type))
+ return NULL;
+
+ gimp_preview_area_mask(GIMP_PREVIEW_AREA(self->obj), x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, mask, rowstride_mask);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_fill(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", "width", "height", "red", "green", "blue", NULL };
+ int x, y, width, height;
+ char red, green, blue;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iiiiccc:Gimp.PreviewArea.fill", kwlist, &x, &y, &width, &height, &red, &green, &blue))
+ return NULL;
+
+ gimp_preview_area_fill(GIMP_PREVIEW_AREA(self->obj), x, y, width, height, red, green, blue);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_set_offsets(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", NULL };
+ int x, y;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.PreviewArea.set_offsets", kwlist, &x, &y))
+ return NULL;
+
+ gimp_preview_area_set_offsets(GIMP_PREVIEW_AREA(self->obj), x, y);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_set_colormap(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "colormap", "num_colors", NULL };
+ int colormap_len, num_colors;
+ guchar *colormap;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s#i:Gimp.PreviewArea.set_colormap", kwlist, &colormap, &colormap_len, &num_colors))
+ return NULL;
+
+ gimp_preview_area_set_colormap(GIMP_PREVIEW_AREA(self->obj), colormap, num_colors);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_set_max_size(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "width", "height", NULL };
+ int width, height;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.PreviewArea.set_max_size", kwlist, &width, &height))
+ return NULL;
+
+ gimp_preview_area_set_max_size(GIMP_PREVIEW_AREA(self->obj), width, height);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_preview_area_menu_popup(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "event", NULL };
+ GdkEvent *event = NULL;
+ PyObject *py_event;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.PreviewArea.menu_popup", kwlist, &py_event))
+ return NULL;
+ if (pyg_boxed_check(py_event, GDK_TYPE_EVENT))
+ event = pyg_boxed_get(py_event, GdkEvent);
+ else {
+ PyErr_SetString(PyExc_TypeError, "event should be a GdkEvent");
+ return NULL;
+ }
+
+ gimp_preview_area_menu_popup(GIMP_PREVIEW_AREA(self->obj), (GdkEventButton *)event);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpPreviewArea_methods[] = {
+ { "draw", (PyCFunction)_wrap_gimp_preview_area_draw, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "blend", (PyCFunction)_wrap_gimp_preview_area_blend, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "mask", (PyCFunction)_wrap_gimp_preview_area_mask, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "fill", (PyCFunction)_wrap_gimp_preview_area_fill, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_offsets", (PyCFunction)_wrap_gimp_preview_area_set_offsets, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_colormap", (PyCFunction)_wrap_gimp_preview_area_set_colormap, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_max_size", (PyCFunction)_wrap_gimp_preview_area_set_max_size, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "menu_popup", (PyCFunction)_wrap_gimp_preview_area_menu_popup, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPreviewArea_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PreviewArea", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPreviewArea_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_preview_area_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpProcBrowserDialog ----------- */
+
+#line 1404 "gimpui.override"
+static int
+_wrap_gimp_proc_browser_dialog_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ gchar *title, *role;
+ PyObject *py_buttons = Py_None;
+ PyObject *help_func = NULL;
+ gchar *help_id = NULL;
+ int len, i;
+ GimpHelpFunc func;
+
+ static char *kwlist[] = { "title", "role", "help_func", "help_id",
+ "buttons", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "zz|OzO:gimpui.GimpProcBrowserDialog.__init__",
+ kwlist,
+ &title, &role, &help_func, &help_id,
+ &py_buttons))
+ return -1;
+
+ if (py_buttons == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_buttons))
+ len = PyTuple_Size(py_buttons);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "buttons must be a tuple containing text/response "
+ "pairs or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "buttons tuple must contain text/response id pairs");
+ return -1;
+ }
+
+ if (help_func) {
+ if (help_func != Py_None) {
+ if (!PyCallable_Check(help_func)) {
+ PyErr_SetString(PyExc_TypeError, "help_func must be callable");
+ return -1;
+ }
+
+ func = pygimp_help_func_marshal;
+
+ } else {
+ func = gimp_standard_help_func;
+ }
+ } else {
+ func = gimp_standard_help_func;
+ }
+
+ pygobject_construct(self,
+ "title", title,
+ "role", role,
+ "help-func", func,
+ "help-id", help_id,
+ NULL);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpProcBrowserDialog object");
+ return -1;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *text = PyTuple_GetItem(py_buttons, i);
+ PyObject *id = PyTuple_GetItem(py_buttons, i + 1);
+ if (!PyString_Check(text) && !PyUnicode_Check(text)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each text/response id pair "
+ "must be a string");
+ return -1;
+ }
+ if (!PyInt_Check(id)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each text/response id pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_dialog_add_button(GIMP_DIALOG(self->obj), PyString_AsString(text),
+ PyInt_AsLong(id));
+ }
+
+ if (help_func && help_func != Py_None) {
+ g_object_set_data(self->obj, "pygimp-dialog-help-data", self);
+
+ Py_INCREF(help_func);
+ g_object_set_data_full(self->obj, "pygimp-dialog-help-func",
+ help_func, pygimp_help_func_destroy);
+ }
+
+ g_signal_emit_by_name(GIMP_PROC_BROWSER_DIALOG(self->obj)->browser,
+ "search", "", 0, self->obj);
+ return 0;
+}
+#line 6479 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_proc_browser_dialog_get_selected(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_proc_browser_dialog_get_selected(GIMP_PROC_BROWSER_DIALOG(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpProcBrowserDialog_methods[] = {
+ { "get_selected", (PyCFunction)_wrap_gimp_proc_browser_dialog_get_selected, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpProcBrowserDialog_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ProcBrowserDialog", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpProcBrowserDialog_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_proc_browser_dialog_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpProgressBar ----------- */
+
+static int
+_wrap_gimp_progress_bar_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.ProgressBar.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ProgressBar object");
+ return -1;
+ }
+ return 0;
+}
+
+PyTypeObject G_GNUC_INTERNAL PyGimpProgressBar_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ProgressBar", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_progress_bar_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpScrolledPreview ----------- */
+
+static PyObject *
+_wrap_gimp_scrolled_preview_set_position(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "x", "y", NULL };
+ int x, y;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.ScrolledPreview.set_position", kwlist, &x, &y))
+ return NULL;
+
+ gimp_scrolled_preview_set_position(GIMP_SCROLLED_PREVIEW(self->obj), x, y);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_scrolled_preview_set_policy(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "hscrollbar_policy", "vscrollbar_policy", NULL };
+ PyObject *py_hscrollbar_policy = NULL, *py_vscrollbar_policy = NULL;
+ GtkPolicyType hscrollbar_policy, vscrollbar_policy;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:Gimp.ScrolledPreview.set_policy", kwlist, &py_hscrollbar_policy, &py_vscrollbar_policy))
+ return NULL;
+ if (pyg_enum_get_value(GTK_TYPE_POLICY_TYPE, py_hscrollbar_policy, (gpointer)&hscrollbar_policy))
+ return NULL;
+ if (pyg_enum_get_value(GTK_TYPE_POLICY_TYPE, py_vscrollbar_policy, (gpointer)&vscrollbar_policy))
+ return NULL;
+
+ gimp_scrolled_preview_set_policy(GIMP_SCROLLED_PREVIEW(self->obj), hscrollbar_policy, vscrollbar_policy);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_scrolled_preview_freeze(PyGObject *self)
+{
+
+ gimp_scrolled_preview_freeze(GIMP_SCROLLED_PREVIEW(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_scrolled_preview_thaw(PyGObject *self)
+{
+
+ gimp_scrolled_preview_thaw(GIMP_SCROLLED_PREVIEW(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpScrolledPreview_methods[] = {
+ { "set_position", (PyCFunction)_wrap_gimp_scrolled_preview_set_position, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_policy", (PyCFunction)_wrap_gimp_scrolled_preview_set_policy, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "freeze", (PyCFunction)_wrap_gimp_scrolled_preview_freeze, METH_NOARGS,
+ NULL },
+ { "thaw", (PyCFunction)_wrap_gimp_scrolled_preview_thaw, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpScrolledPreview_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ScrolledPreview", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpScrolledPreview_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpDrawablePreview ----------- */
+
+#line 1955 "gimpui.override"
+static int
+_wrap_gimp_drawable_preview_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", NULL };
+ PyGimpDrawable *py_drawable;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|:GimpDrawablePreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable))
+ return -1;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, NULL))
+ return -1;
+
+ g_object_set_data_full(self->obj, "pygimp-drawable-preview-pydrawable",
+ py_drawable,
+ (GDestroyNotify)pygimp_decref_callback);
+
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+
+#line 6766 "gimpui.c"
+
+
+#line 1682 "gimpui.override"
+static PyObject *
+_wrap_gimp_drawable_preview_get_drawable(PyGObject *self)
+{
+ PyObject *drawable;
+
+ drawable = g_object_get_data(self->obj,
+ "pygimp-drawable-preview-pydrawable");
+ Py_INCREF(drawable);
+ return drawable;
+}
+#line 6780 "gimpui.c"
+
+
+#line 1706 "gimpui.override"
+static PyObject *
+_wrap_gimp_drawable_preview_draw_region(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+/* PyGimpPixelRgn *pypixelrgn;
+
+ static char *kwlist[] = {"drawable", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpDrawablePreview.draw_region",
+ kwlist, PyGimpPixelRgn_Type, &pypixelrgn))
+ return NULL;
+
+ gimp_drawable_preview_draw_region(GIMP_DRAWABLE_PREVIEW(self->obj),
+ &pypixelrgn->pr);
+*/
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 6803 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpDrawablePreview_methods[] = {
+ { "get_drawable", (PyCFunction)_wrap_gimp_drawable_preview_get_drawable, METH_NOARGS,
+ NULL },
+ { "draw_region", (PyCFunction)_wrap_gimp_drawable_preview_draw_region, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpDrawablePreview_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.DrawablePreview", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpDrawablePreview_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_drawable_preview_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpSelectButton ----------- */
+
+static PyObject *
+_wrap_gimp_select_button_close_popup(PyGObject *self)
+{
+
+ gimp_select_button_close_popup(GIMP_SELECT_BUTTON(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpSelectButton_methods[] = {
+ { "close_popup", (PyCFunction)_wrap_gimp_select_button_close_popup, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.SelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPatternSelectButton ----------- */
+
+static int
+_wrap_gimp_pattern_select_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"title", "pattern_name", NULL };
+ char *prop_names[] = {"title", "pattern-name", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:gimpui.PatternSelectButton.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PatternSelectButton object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_pattern_select_button_get_pattern(PyGObject *self)
+{
+ const gchar *ret;
+
+
+ ret = gimp_pattern_select_button_get_pattern(GIMP_PATTERN_SELECT_BUTTON(self->obj));
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_pattern_select_button_set_pattern(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "pattern_name", NULL };
+ char *pattern_name;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PatternSelectButton.set_pattern", kwlist, &pattern_name))
+ return NULL;
+
+ gimp_pattern_select_button_set_pattern(GIMP_PATTERN_SELECT_BUTTON(self->obj), pattern_name);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpPatternSelectButton_methods[] = {
+ { "get_pattern", (PyCFunction)_wrap_gimp_pattern_select_button_get_pattern, METH_NOARGS,
+ NULL },
+ { "set_pattern", (PyCFunction)_wrap_gimp_pattern_select_button_set_pattern, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPatternSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PatternSelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPatternSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_pattern_select_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpPaletteSelectButton ----------- */
+
+ static int
+_wrap_gimp_palette_select_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"title", "palette_name", NULL };
+ char *prop_names[] = {"title", "palette-name", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:gimpui.PaletteSelectButton.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.PaletteSelectButton object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_palette_select_button_get_palette(PyGObject *self)
+{
+ const gchar *ret;
+
+
+ ret = gimp_palette_select_button_get_palette(GIMP_PALETTE_SELECT_BUTTON(self->obj));
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_palette_select_button_set_palette(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "palette_name", NULL };
+ char *palette_name;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.PaletteSelectButton.set_palette", kwlist, &palette_name))
+ return NULL;
+
+ gimp_palette_select_button_set_palette(GIMP_PALETTE_SELECT_BUTTON(self->obj), palette_name);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpPaletteSelectButton_methods[] = {
+ { "get_palette", (PyCFunction)_wrap_gimp_palette_select_button_get_palette, METH_NOARGS,
+ NULL },
+ { "set_palette", (PyCFunction)_wrap_gimp_palette_select_button_set_palette, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpPaletteSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.PaletteSelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpPaletteSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_palette_select_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpGradientSelectButton ----------- */
+
+ static int
+_wrap_gimp_gradient_select_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"title", "gradient_name", NULL };
+ char *prop_names[] = {"title", "gradient-name", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:gimpui.GradientSelectButton.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.GradientSelectButton object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_gradient_select_button_get_gradient(PyGObject *self)
+{
+ const gchar *ret;
+
+
+ ret = gimp_gradient_select_button_get_gradient(GIMP_GRADIENT_SELECT_BUTTON(self->obj));
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_gradient_select_button_set_gradient(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "gradient_name", NULL };
+ char *gradient_name;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.GradientSelectButton.set_gradient", kwlist, &gradient_name))
+ return NULL;
+
+ gimp_gradient_select_button_set_gradient(GIMP_GRADIENT_SELECT_BUTTON(self->obj), gradient_name);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpGradientSelectButton_methods[] = {
+ { "get_gradient", (PyCFunction)_wrap_gimp_gradient_select_button_get_gradient, METH_NOARGS,
+ NULL },
+ { "set_gradient", (PyCFunction)_wrap_gimp_gradient_select_button_set_gradient, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpGradientSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.GradientSelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpGradientSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_gradient_select_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpFontSelectButton ----------- */
+
+ static int
+_wrap_gimp_font_select_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[2];
+ PyObject *parsed_args[2] = {NULL, };
+ char *arg_names[] = {"title", "font_name", NULL };
+ char *prop_names[] = {"title", "font-name", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:gimpui.FontSelectButton.__init__" , arg_names , &parsed_args[0] , &parsed_args[1]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*2);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.FontSelectButton object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_font_select_button_get_font(PyGObject *self)
+{
+ const gchar *ret;
+
+
+ ret = gimp_font_select_button_get_font(GIMP_FONT_SELECT_BUTTON(self->obj));
+
+ if (ret)
+ return PyString_FromString(ret);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_font_select_button_set_font(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "font_name", NULL };
+ char *font_name;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.FontSelectButton.set_font", kwlist, &font_name))
+ return NULL;
+
+ gimp_font_select_button_set_font(GIMP_FONT_SELECT_BUTTON(self->obj), font_name);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpFontSelectButton_methods[] = {
+ { "get_font", (PyCFunction)_wrap_gimp_font_select_button_get_font, METH_NOARGS,
+ NULL },
+ { "set_font", (PyCFunction)_wrap_gimp_font_select_button_set_font, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpFontSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.FontSelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpFontSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_font_select_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpBrushSelectButton ----------- */
+
+ static int
+_wrap_gimp_brush_select_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[5];
+ PyObject *parsed_args[5] = {NULL, };
+ char *arg_names[] = {"title", "brush_name", "opacity", "spacing", "paint_mode", NULL };
+ char *prop_names[] = {"title", "brush-name", "brush-opacity", "brush-spacing", "brush-paint-mode", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOOO:gimpui.BrushSelectButton.__init__" , arg_names , &parsed_args[0] , &parsed_args[1] , &parsed_args[2] , &parsed_args[3] , &parsed_args[4]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*5);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.BrushSelectButton object");
+ return -1;
+ }
+ return 0;
+}
+
+#line 914 "gimpui.override"
+static PyObject *
+_wrap_gimp_brush_select_button_get_brush(PyGObject *self)
+{
+ const gchar *brush_name;
+ gdouble opacity;
+ gint spacing;
+ GimpLayerMode paint_mode;
+
+ brush_name =
+ gimp_brush_select_button_get_brush(GIMP_BRUSH_SELECT_BUTTON(self->obj),
+ &opacity, &spacing, &paint_mode);
+
+ return Py_BuildValue("(sdiN)", brush_name, opacity, spacing,
+ pyg_enum_from_gtype(GIMP_TYPE_LAYER_MODE,
+ paint_mode));
+}
+#line 7439 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpBrushSelectButton_methods[] = {
+ { "get_brush", (PyCFunction)_wrap_gimp_brush_select_button_get_brush, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpBrushSelectButton_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.BrushSelectButton", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpBrushSelectButton_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_brush_select_button_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpRuler ----------- */
+
+ static int
+_wrap_gimp_ruler_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[4];
+ PyObject *parsed_args[4] = {NULL, };
+ char *arg_names[] = {"orientation", "lower", "upper", "max_size", NULL };
+ char *prop_names[] = {"orientation", "lower", "upper", "max-size", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOO:gimpui.Ruler.__init__" , arg_names , &parsed_args[0] , &parsed_args[1] , &parsed_args[2] , &parsed_args[3]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*4);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.Ruler object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_ruler_set_unit(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "unit", NULL };
+ int unit;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.Ruler.set_unit", kwlist, &unit))
+ return NULL;
+
+ gimp_ruler_set_unit(GIMP_RULER(self->obj), unit);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_ruler_get_unit(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_ruler_get_unit(GIMP_RULER(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static PyObject *
+_wrap_gimp_ruler_set_position(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "position", NULL };
+ double position;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"d:Gimp.Ruler.set_position", kwlist, &position))
+ return NULL;
+
+ gimp_ruler_set_position(GIMP_RULER(self->obj), position);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_ruler_get_position(PyGObject *self)
+{
+ double ret;
+
+
+ ret = gimp_ruler_get_position(GIMP_RULER(self->obj));
+
+ return PyFloat_FromDouble(ret);
+}
+
+static PyObject *
+_wrap_gimp_ruler_set_range(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "lower", "upper", "max_size", NULL };
+ double lower, upper, max_size;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ddd:Gimp.Ruler.set_range", kwlist, &lower, &upper, &max_size))
+ return NULL;
+
+ gimp_ruler_set_range(GIMP_RULER(self->obj), lower, upper, max_size);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#line 1985 "gimpui.override"
+static PyObject *
+_wrap_gimp_ruler_get_range(PyGObject *self)
+{
+ gdouble lower, upper, max_size;
+
+ gimp_ruler_get_range(GIMP_RULER(self->obj), &lower, &upper, &max_size);
+
+ return Py_BuildValue("(ddd)", lower, upper, max_size);
+}
+#line 7604 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpRuler_methods[] = {
+ { "set_unit", (PyCFunction)_wrap_gimp_ruler_set_unit, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_unit", (PyCFunction)_wrap_gimp_ruler_get_unit, METH_NOARGS,
+ NULL },
+ { "set_position", (PyCFunction)_wrap_gimp_ruler_set_position, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_position", (PyCFunction)_wrap_gimp_ruler_get_position, METH_NOARGS,
+ NULL },
+ { "set_range", (PyCFunction)_wrap_gimp_ruler_set_range, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_range", (PyCFunction)_wrap_gimp_ruler_get_range, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpRuler_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.Ruler", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpRuler_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_ruler_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpSizeEntry ----------- */
+
+static int
+_wrap_gimp_size_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "number_of_fields", "unit", "unit_format", "menu_show_pixels", "menu_show_percent", "show_refval", "spinbutton_width", "update_policy", NULL };
+ int number_of_fields, unit, menu_show_pixels, menu_show_percent, show_refval, spinbutton_width;
+ char *unit_format;
+ GimpSizeEntryUpdatePolicy update_policy;
+ PyObject *py_update_policy = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"iisiiiiO:Gimp.SizeEntry.__init__", kwlist, &number_of_fields, &unit, &unit_format, &menu_show_pixels, &menu_show_percent, &show_refval, &spinbutton_width, &py_update_policy))
+ return -1;
+ if (pyg_enum_get_value(GIMP_TYPE_SIZE_ENTRY_UPDATE_POLICY, py_update_policy, (gpointer)&update_policy))
+ return -1;
+ self->obj = (GObject *)gimp_size_entry_new(number_of_fields, unit, unit_format, menu_show_pixels, menu_show_percent, show_refval, spinbutton_width, update_policy);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpSizeEntry object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_add_field(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "value_spinbutton", "refval_spinbutton", NULL };
+ PyGObject *value_spinbutton, *refval_spinbutton;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!:Gimp.SizeEntry.add_field", kwlist, &PyGtkSpinButton_Type, &value_spinbutton, &PyGtkSpinButton_Type, &refval_spinbutton))
+ return NULL;
+
+ gimp_size_entry_add_field(GIMP_SIZE_ENTRY(self->obj), GTK_SPIN_BUTTON(value_spinbutton->obj), GTK_SPIN_BUTTON(refval_spinbutton->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_attach_label(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "text", "row", "column", "alignment", NULL };
+ char *text;
+ int row, column;
+ GtkWidget *ret;
+ double alignment;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"siid:Gimp.SizeEntry.attach_label", kwlist, &text, &row, &column, &alignment))
+ return NULL;
+
+ ret = gimp_size_entry_attach_label(GIMP_SIZE_ENTRY(self->obj), text, row, column, alignment);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_resolution(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "resolution", "keep_size", NULL };
+ int field, keep_size;
+ double resolution;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"idi:Gimp.SizeEntry.set_resolution", kwlist, &field, &resolution, &keep_size))
+ return NULL;
+
+ gimp_size_entry_set_resolution(GIMP_SIZE_ENTRY(self->obj), field, resolution, keep_size);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_size(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "lower", "upper", NULL };
+ int field;
+ double lower, upper;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"idd:Gimp.SizeEntry.set_size", kwlist, &field, &lower, &upper))
+ return NULL;
+
+ gimp_size_entry_set_size(GIMP_SIZE_ENTRY(self->obj), field, lower, upper);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_value_boundaries(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "lower", "upper", NULL };
+ int field;
+ double lower, upper;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"idd:Gimp.SizeEntry.set_value_boundaries", kwlist, &field, &lower, &upper))
+ return NULL;
+
+ gimp_size_entry_set_value_boundaries(GIMP_SIZE_ENTRY(self->obj), field, lower, upper);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_get_value(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", NULL };
+ int field;
+ double ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.get_value", kwlist, &field))
+ return NULL;
+
+ ret = gimp_size_entry_get_value(GIMP_SIZE_ENTRY(self->obj), field);
+
+ return PyFloat_FromDouble(ret);
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_value(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "value", NULL };
+ int field;
+ double value;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"id:Gimp.SizeEntry.set_value", kwlist, &field, &value))
+ return NULL;
+
+ gimp_size_entry_set_value(GIMP_SIZE_ENTRY(self->obj), field, value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_refval_boundaries(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "lower", "upper", NULL };
+ int field;
+ double lower, upper;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"idd:Gimp.SizeEntry.set_refval_boundaries", kwlist, &field, &lower, &upper))
+ return NULL;
+
+ gimp_size_entry_set_refval_boundaries(GIMP_SIZE_ENTRY(self->obj), field, lower, upper);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_refval_digits(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "digits", NULL };
+ int field, digits;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"ii:Gimp.SizeEntry.set_refval_digits", kwlist, &field, &digits))
+ return NULL;
+
+ gimp_size_entry_set_refval_digits(GIMP_SIZE_ENTRY(self->obj), field, digits);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_get_refval(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", NULL };
+ int field;
+ double ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.get_refval", kwlist, &field))
+ return NULL;
+
+ ret = gimp_size_entry_get_refval(GIMP_SIZE_ENTRY(self->obj), field);
+
+ return PyFloat_FromDouble(ret);
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_refval(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", "refval", NULL };
+ int field;
+ double refval;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"id:Gimp.SizeEntry.set_refval", kwlist, &field, &refval))
+ return NULL;
+
+ gimp_size_entry_set_refval(GIMP_SIZE_ENTRY(self->obj), field, refval);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_get_unit(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_size_entry_get_unit(GIMP_SIZE_ENTRY(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_unit(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "unit", NULL };
+ int unit;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.set_unit", kwlist, &unit))
+ return NULL;
+
+ gimp_size_entry_set_unit(GIMP_SIZE_ENTRY(self->obj), unit);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_show_unit_menu(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "show", NULL };
+ int show;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.show_unit_menu", kwlist, &show))
+ return NULL;
+
+ gimp_size_entry_show_unit_menu(GIMP_SIZE_ENTRY(self->obj), show);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_pixel_digits(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "digits", NULL };
+ int digits;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.set_pixel_digits", kwlist, &digits))
+ return NULL;
+
+ gimp_size_entry_set_pixel_digits(GIMP_SIZE_ENTRY(self->obj), digits);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_grab_focus(PyGObject *self)
+{
+
+ gimp_size_entry_grab_focus(GIMP_SIZE_ENTRY(self->obj));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_set_activates_default(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "setting", NULL };
+ int setting;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.set_activates_default", kwlist, &setting))
+ return NULL;
+
+ gimp_size_entry_set_activates_default(GIMP_SIZE_ENTRY(self->obj), setting);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_size_entry_get_help_widget(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "field", NULL };
+ int field;
+ GtkWidget *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.SizeEntry.get_help_widget", kwlist, &field))
+ return NULL;
+
+ ret = gimp_size_entry_get_help_widget(GIMP_SIZE_ENTRY(self->obj), field);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static const PyMethodDef _PyGimpSizeEntry_methods[] = {
+ { "add_field", (PyCFunction)_wrap_gimp_size_entry_add_field, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "attach_label", (PyCFunction)_wrap_gimp_size_entry_attach_label, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_resolution", (PyCFunction)_wrap_gimp_size_entry_set_resolution, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_size", (PyCFunction)_wrap_gimp_size_entry_set_size, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_value_boundaries", (PyCFunction)_wrap_gimp_size_entry_set_value_boundaries, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_value", (PyCFunction)_wrap_gimp_size_entry_get_value, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_value", (PyCFunction)_wrap_gimp_size_entry_set_value, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_refval_boundaries", (PyCFunction)_wrap_gimp_size_entry_set_refval_boundaries, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_refval_digits", (PyCFunction)_wrap_gimp_size_entry_set_refval_digits, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_refval", (PyCFunction)_wrap_gimp_size_entry_get_refval, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_refval", (PyCFunction)_wrap_gimp_size_entry_set_refval, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_unit", (PyCFunction)_wrap_gimp_size_entry_get_unit, METH_NOARGS,
+ NULL },
+ { "set_unit", (PyCFunction)_wrap_gimp_size_entry_set_unit, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "show_unit_menu", (PyCFunction)_wrap_gimp_size_entry_show_unit_menu, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "set_pixel_digits", (PyCFunction)_wrap_gimp_size_entry_set_pixel_digits, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "grab_focus", (PyCFunction)_wrap_gimp_size_entry_grab_focus, METH_NOARGS,
+ NULL },
+ { "set_activates_default", (PyCFunction)_wrap_gimp_size_entry_set_activates_default, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_help_widget", (PyCFunction)_wrap_gimp_size_entry_get_help_widget, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpSizeEntry_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.SizeEntry", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpSizeEntry_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_size_entry_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpStringComboBox ----------- */
+
+ static int
+_wrap_gimp_string_combo_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ GType obj_type = pyg_type_from_object((PyObject *) self);
+ GParameter params[3];
+ PyObject *parsed_args[3] = {NULL, };
+ char *arg_names[] = {"model", "id_column", "label_column", NULL };
+ char *prop_names[] = {"model", "id-column", "label-column", NULL };
+ guint nparams, i;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:gimpui.StringComboBox.__init__" , arg_names , &parsed_args[0] , &parsed_args[1] , &parsed_args[2]))
+ return -1;
+
+ memset(params, 0, sizeof(GParameter)*3);
+ if (!pyg_parse_constructor_args(obj_type, arg_names,
+ prop_names, params,
+ &nparams, parsed_args))
+ return -1;
+ pygobject_constructv(self, nparams, params);
+ for (i = 0; i < nparams; ++i)
+ g_value_unset(&params[i].value);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.StringComboBox object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_string_combo_box_set_active(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "id", NULL };
+ char *id;
+ int ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:Gimp.StringComboBox.set_active", kwlist, &id))
+ return NULL;
+
+ ret = gimp_string_combo_box_set_active(GIMP_STRING_COMBO_BOX(self->obj), id);
+
+ return PyBool_FromLong(ret);
+
+}
+
+static PyObject *
+_wrap_gimp_string_combo_box_get_active(PyGObject *self)
+{
+ gchar *ret;
+
+
+ ret = gimp_string_combo_box_get_active(GIMP_STRING_COMBO_BOX(self->obj));
+
+ if (ret) {
+ PyObject *py_ret = PyString_FromString(ret);
+ g_free(ret);
+ return py_ret;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpStringComboBox_methods[] = {
+ { "set_active", (PyCFunction)_wrap_gimp_string_combo_box_set_active, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_active", (PyCFunction)_wrap_gimp_string_combo_box_get_active, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpStringComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.StringComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpStringComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_string_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpUnitComboBox ----------- */
+
+ static int
+_wrap_gimp_unit_combo_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.UnitComboBox.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.UnitComboBox object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_unit_combo_box_get_active(PyGObject *self)
+{
+ int ret;
+
+
+ ret = gimp_unit_combo_box_get_active(GIMP_UNIT_COMBO_BOX(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static PyObject *
+_wrap_gimp_unit_combo_box_set_active(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "unit", NULL };
+ int unit;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.UnitComboBox.set_active", kwlist, &unit))
+ return NULL;
+
+ gimp_unit_combo_box_set_active(GIMP_UNIT_COMBO_BOX(self->obj), unit);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static const PyMethodDef _PyGimpUnitComboBox_methods[] = {
+ { "get_active", (PyCFunction)_wrap_gimp_unit_combo_box_get_active, METH_NOARGS,
+ NULL },
+ { "set_active", (PyCFunction)_wrap_gimp_unit_combo_box_set_active, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpUnitComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.UnitComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpUnitComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_unit_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpUnitMenu ----------- */
+
+static int
+_wrap_gimp_unit_menu_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "format", "unit", "show_pixels", "show_percent", "show_custom", NULL };
+ char *format;
+ int unit, show_pixels, show_percent, show_custom;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"siiii:Gimp.UnitMenu.__init__", kwlist, &format, &unit, &show_pixels, &show_percent, &show_custom))
+ return -1;
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimpui.UnitComboBox instead") < 0)
+ return -1;
+ self->obj = (GObject *)gimp_unit_menu_new(format, unit, show_pixels, show_percent, show_custom);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpUnitMenu object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_unit_menu_set_unit(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "unit", NULL };
+ int unit;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.UnitMenu.set_unit", kwlist, &unit))
+ return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimpui.UnitComboBox instead") < 0)
+ return NULL;
+
+ gimp_unit_menu_set_unit(GIMP_UNIT_MENU(self->obj), unit);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_unit_menu_get_unit(PyGObject *self)
+{
+ int ret;
+
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimpui.UnitComboBox instead") < 0)
+ return NULL;
+
+ ret = gimp_unit_menu_get_unit(GIMP_UNIT_MENU(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static PyObject *
+_wrap_gimp_unit_menu_set_pixel_digits(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "digits", NULL };
+ int digits;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"i:Gimp.UnitMenu.set_pixel_digits", kwlist, &digits))
+ return NULL;
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimpui.UnitComboBox instead") < 0)
+ return NULL;
+
+ gimp_unit_menu_set_pixel_digits(GIMP_UNIT_MENU(self->obj), digits);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_unit_menu_get_pixel_digits(PyGObject *self)
+{
+ int ret;
+
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use gimpui.UnitComboBox instead") < 0)
+ return NULL;
+
+ ret = gimp_unit_menu_get_pixel_digits(GIMP_UNIT_MENU(self->obj));
+
+ return PyInt_FromLong(ret);
+}
+
+static const PyMethodDef _PyGimpUnitMenu_methods[] = {
+ { "set_unit", (PyCFunction)_wrap_gimp_unit_menu_set_unit, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_unit", (PyCFunction)_wrap_gimp_unit_menu_get_unit, METH_NOARGS,
+ NULL },
+ { "set_pixel_digits", (PyCFunction)_wrap_gimp_unit_menu_set_pixel_digits, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_pixel_digits", (PyCFunction)_wrap_gimp_unit_menu_get_pixel_digits, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpUnitMenu_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.UnitMenu", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpUnitMenu_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_unit_menu_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpVectorsComboBox ----------- */
+
+#line 479 "gimpui.override"
+static gboolean
+pygimp_vectors_constraint_marshal(gint32 image_id, gint32 vectors_id,
+ gpointer user_data)
+{
+ PyObject *img, *vect, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ vect = pygimp_vectors_new(vectors_id);
+ if (!vect) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(vect);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_vectors_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpVectorsConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.VectorsComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_vectors_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_vectors_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_VECTORS_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.VectorsComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+#line 8510 "gimpui.c"
+
+
+#line 596 "gimpui.override"
+static PyObject *
+_wrap_gimp_vectors_combo_box_get_active_vectors(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_vectors_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 8525 "gimpui.c"
+
+
+#line 570 "gimpui.override"
+static PyObject *
+_wrap_gimp_vectors_combo_box_set_active_vectors(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpVectors *vect;
+
+ static char *kwlist[] = { "vectors", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpVectorsComboBox.set_active_vectors",
+ kwlist,
+ PyGimpVectors_Type, &vect))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), vect->ID)) {
+ PyErr_Format(pygimp_error,
+ "Vectors (ID %d) does not exist in GimpVectorsComboBox",
+ vect->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 8553 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpVectorsComboBox_methods[] = {
+ { "get_active_vectors", (PyCFunction)_wrap_gimp_vectors_combo_box_get_active_vectors, METH_NOARGS,
+ NULL },
+ { "set_active_vectors", (PyCFunction)_wrap_gimp_vectors_combo_box_set_active_vectors, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpVectorsComboBox_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.VectorsComboBox", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpVectorsComboBox_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_vectors_combo_box_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpZoomModel ----------- */
+
+static int
+_wrap_gimp_zoom_model_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char* kwlist[] = { NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ ":gimpui.ZoomModel.__init__",
+ kwlist))
+ return -1;
+
+ pygobject_constructv(self, 0, NULL);
+ if (!self->obj) {
+ PyErr_SetString(
+ PyExc_RuntimeError,
+ "could not create gimpui.ZoomModel object");
+ return -1;
+ }
+ return 0;
+}
+
+static PyObject *
+_wrap_gimp_zoom_model_set_range(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "min", "max", NULL };
+ double min, max;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"dd:Gimp.ZoomModel.set_range", kwlist, &min, &max))
+ return NULL;
+
+ gimp_zoom_model_set_range(GIMP_ZOOM_MODEL(self->obj), min, max);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_zoom_model_zoom(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "zoom_type", "scale", NULL };
+ PyObject *py_zoom_type = NULL;
+ double scale;
+ GimpZoomType zoom_type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"Od:Gimp.ZoomModel.zoom", kwlist, &py_zoom_type, &scale))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_ZOOM_TYPE, py_zoom_type, (gpointer)&zoom_type))
+ return NULL;
+
+ gimp_zoom_model_zoom(GIMP_ZOOM_MODEL(self->obj), zoom_type, scale);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_gimp_zoom_model_get_factor(PyGObject *self)
+{
+ double ret;
+
+
+ ret = gimp_zoom_model_get_factor(GIMP_ZOOM_MODEL(self->obj));
+
+ return PyFloat_FromDouble(ret);
+}
+
+#line 1669 "gimpui.override"
+static PyObject *
+_wrap_gimp_zoom_model_get_fraction(PyGObject *self)
+{
+ gint numerator;
+ gint denominator;
+
+ gimp_zoom_model_get_fraction(GIMP_ZOOM_MODEL(self->obj), &numerator,
+ &denominator);
+
+ return Py_BuildValue("(ii)", numerator, denominator);
+}
+#line 8690 "gimpui.c"
+
+
+static const PyMethodDef _PyGimpZoomModel_methods[] = {
+ { "set_range", (PyCFunction)_wrap_gimp_zoom_model_set_range, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "zoom", (PyCFunction)_wrap_gimp_zoom_model_zoom, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "get_factor", (PyCFunction)_wrap_gimp_zoom_model_get_factor, METH_NOARGS,
+ NULL },
+ { "get_fraction", (PyCFunction)_wrap_gimp_zoom_model_get_fraction, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpZoomModel_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ZoomModel", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpZoomModel_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_zoom_model_new, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpZoomPreview ----------- */
+
+#line 1891 "gimpui.override"
+static int
+_wrap_gimp_zoom_preview_new_with_model(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", "model", NULL };
+ PyGimpDrawable *py_drawable;
+ PyGObject *py_zoom_model = NULL;
+ GimpZoomModel *zoom_model;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!:GimpZoomPreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable,
+ &PyGimpZoomModel_Type, &py_zoom_model))
+ return -1;
+
+ if (py_zoom_model)
+ zoom_model = (GimpZoomModel*)py_zoom_model->obj;
+ else
+ zoom_model = NULL;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, "model", zoom_model, NULL))
+ return -1;
+
+ g_object_set_data_full(self->obj, "pygimp-zoom-preview-pydrawable",
+ py_drawable,
+ (GDestroyNotify)pygimp_decref_callback);
+
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+#line 8788 "gimpui.c"
+
+
+#line 2040 "gimpui.override"
+static PyObject *
+_wrap_gimp_zoom_preview_get_source(PyGObject *self)
+{
+ gint width, height, bpp;
+ guchar *image;
+ PyObject *pyimage;
+
+ image = gimp_zoom_preview_get_source(GIMP_ZOOM_PREVIEW(self->obj),
+ &width, &height, &bpp);
+
+ if (image)
+ {
+ pyimage = PyByteArray_FromStringAndSize((const char *)image,
+ width * height * bpp);
+ g_free (image);
+ }
+ else
+ {
+ Py_INCREF(Py_None);
+ pyimage = Py_None;
+ }
+
+ return Py_BuildValue("(Niii)", pyimage, width, height, bpp);
+}
+#line 8816 "gimpui.c"
+
+
+#line 1694 "gimpui.override"
+static PyObject *
+_wrap_gimp_zoom_preview_get_drawable(PyGObject *self)
+{
+ PyObject *drawable;
+
+ drawable = g_object_get_data(self->obj,
+ "pygimp-zoom-preview-pydrawable");
+ Py_INCREF(drawable);
+ return drawable;
+}
+#line 8830 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_zoom_preview_get_model(PyGObject *self)
+{
+ GimpZoomModel *ret;
+
+
+ ret = gimp_zoom_preview_get_model(GIMP_ZOOM_PREVIEW(self->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_zoom_preview_get_factor(PyGObject *self)
+{
+ double ret;
+
+
+ ret = gimp_zoom_preview_get_factor(GIMP_ZOOM_PREVIEW(self->obj));
+
+ return PyFloat_FromDouble(ret);
+}
+
+static const PyMethodDef _PyGimpZoomPreview_methods[] = {
+ { "get_source", (PyCFunction)_wrap_gimp_zoom_preview_get_source, METH_NOARGS,
+ NULL },
+ { "get_drawable", (PyCFunction)_wrap_gimp_zoom_preview_get_drawable, METH_NOARGS,
+ NULL },
+ { "get_model", (PyCFunction)_wrap_gimp_zoom_preview_get_model, METH_NOARGS,
+ NULL },
+ { "get_factor", (PyCFunction)_wrap_gimp_zoom_preview_get_factor, METH_NOARGS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+PyTypeObject G_GNUC_INTERNAL PyGimpZoomPreview_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ZoomPreview", /* tp_name */
+ sizeof(PyGObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)_PyGimpZoomPreview_methods, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ offsetof(PyGObject, inst_dict), /* tp_dictoffset */
+ (initproc)_wrap_gimp_zoom_preview_new_with_model, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- GimpColorManaged ----------- */
+
+PyTypeObject G_GNUC_INTERNAL PyGimpColorManaged_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpui.ColorManaged", /* tp_name */
+ sizeof(PyObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)0, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ (PySequenceMethods*)0, /* tp_as_sequence */
+ (PyMappingMethods*)0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ (struct PyMethodDef*)NULL, /* tp_methods */
+ (struct PyMemberDef*)0, /* tp_members */
+ (struct PyGetSetDef*)0, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+
+
+/* ----------- functions ----------- */
+
+#line 2066 "gimpui.override"
+static PyObject *
+_wrap_gimp_ui_init(PyObject *self)
+{
+ extern const char *prog_name;
+
+ gimp_ui_init (prog_name, FALSE);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+#line 8977 "gimpui.c"
+
+
+static PyObject *
+_wrap_gimp_enum_combo_box_new_with_model(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enum_store", NULL };
+ PyGObject *enum_store;
+ GtkWidget *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:gimp_enum_combo_box_new_with_model", kwlist, &PyGimpEnumStore_Type, &enum_store))
+ return NULL;
+
+ ret = gimp_enum_combo_box_new_with_model(GIMP_ENUM_STORE(enum_store->obj));
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_enum_store_new_with_range(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enum_type", "minimum", "maximum", NULL };
+ PyObject *py_enum_type = NULL;
+ int minimum, maximum;
+ GType enum_type;
+ GtkListStore *ret;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"Oii:gimp_enum_store_new_with_range", kwlist, &py_enum_type, &minimum, &maximum))
+ return NULL;
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return NULL;
+
+ ret = gimp_enum_store_new_with_range(enum_type, minimum, maximum);
+
+ /* pygobject_new handles NULL checking */
+ return pygobject_new((GObject *)ret);
+}
+
+static PyObject *
+_wrap_gimp_zoom_model_zoom_step(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "zoom_type", "scale", NULL };
+ PyObject *py_zoom_type = NULL;
+ double scale, ret;
+ GimpZoomType zoom_type;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"Od:gimp_zoom_model_zoom_step", kwlist, &py_zoom_type, &scale))
+ return NULL;
+ if (pyg_enum_get_value(GIMP_TYPE_ZOOM_TYPE, py_zoom_type, (gpointer)&zoom_type))
+ return NULL;
+
+ ret = gimp_zoom_model_zoom_step(zoom_type, scale);
+
+ return PyFloat_FromDouble(ret);
+}
+
+static PyObject *
+_wrap_gimp_pattern_select_destroy(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "pattern_callback", NULL };
+ char *pattern_callback;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:gimp_pattern_select_destroy", kwlist, &pattern_callback))
+ return NULL;
+
+ gimp_pattern_select_destroy(pattern_callback);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+const PyMethodDef gimpui_functions[] = {
+ { "gimp_ui_init", (PyCFunction)_wrap_gimp_ui_init, METH_NOARGS,
+ NULL },
+ { "gimp_enum_combo_box_new_with_model", (PyCFunction)_wrap_gimp_enum_combo_box_new_with_model, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "gimp_enum_store_new_with_range", (PyCFunction)_wrap_gimp_enum_store_new_with_range, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "gimp_zoom_model_zoom_step", (PyCFunction)_wrap_gimp_zoom_model_zoom_step, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { "gimp_pattern_select_destroy", (PyCFunction)_wrap_gimp_pattern_select_destroy, METH_VARARGS|METH_KEYWORDS,
+ NULL },
+ { NULL, NULL, 0, NULL }
+};
+
+
+/* ----------- enums and flags ----------- */
+
+void
+gimpui_add_constants(PyObject *module, const gchar *strip_prefix)
+{
+#ifdef VERSION
+ PyModule_AddStringConstant(module, "__version__", VERSION);
+#endif
+ pyg_enum_add(module, "AspectType", strip_prefix, GIMP_TYPE_ASPECT_TYPE);
+ pyg_enum_add(module, "ChainPosition", strip_prefix, GIMP_TYPE_CHAIN_POSITION);
+ pyg_enum_add(module, "ColorAreaType", strip_prefix, GIMP_TYPE_COLOR_AREA_TYPE);
+ pyg_enum_add(module, "ColorSelectorChannel", strip_prefix, GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
+ pyg_enum_add(module, "PageSelectorTarget", strip_prefix, GIMP_TYPE_PAGE_SELECTOR_TARGET);
+ pyg_enum_add(module, "SizeEntryUpdatePolicy", strip_prefix, GIMP_TYPE_SIZE_ENTRY_UPDATE_POLICY);
+ PyModule_AddIntConstant(module, (char *) pyg_constant_strip_prefix("GIMP_UNIT_PIXEL", strip_prefix), GIMP_UNIT_PIXEL);
+ PyModule_AddIntConstant(module, (char *) pyg_constant_strip_prefix("GIMP_UNIT_INCH", strip_prefix), GIMP_UNIT_INCH);
+ PyModule_AddIntConstant(module, (char *) pyg_constant_strip_prefix("GIMP_UNIT_MM", strip_prefix), GIMP_UNIT_MM);
+ PyModule_AddIntConstant(module, (char *) pyg_constant_strip_prefix("GIMP_UNIT_POINT", strip_prefix), GIMP_UNIT_POINT);
+ PyModule_AddIntConstant(module, (char *) pyg_constant_strip_prefix("GIMP_UNIT_PICA", strip_prefix), GIMP_UNIT_PICA);
+ pyg_enum_add(module, "ZoomType", strip_prefix, GIMP_TYPE_ZOOM_TYPE);
+
+ if (PyErr_Occurred())
+ PyErr_Print();
+}
+
+/* initialise stuff extension classes */
+void
+gimpui_register_classes(PyObject *d)
+{
+ PyObject *module;
+
+ if ((module = PyImport_ImportModule("gobject")) != NULL) {
+ _PyGObject_Type = (PyTypeObject *)PyObject_GetAttrString(module, "GObject");
+ if (_PyGObject_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name GObject from gobject");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gobject");
+ return ;
+ }
+ if ((module = PyImport_ImportModule("gtk")) != NULL) {
+ _PyGtkObject_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Object");
+ if (_PyGtkObject_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Object from gtk");
+ return ;
+ }
+ _PyGtkWidget_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Widget");
+ if (_PyGtkWidget_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Widget from gtk");
+ return ;
+ }
+ _PyGtkDialog_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Dialog");
+ if (_PyGtkDialog_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Dialog from gtk");
+ return ;
+ }
+ _PyGtkWindow_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Window");
+ if (_PyGtkWindow_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Window from gtk");
+ return ;
+ }
+ _PyGtkLabel_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Label");
+ if (_PyGtkLabel_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Label from gtk");
+ return ;
+ }
+ _PyGtkButton_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Button");
+ if (_PyGtkButton_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Button from gtk");
+ return ;
+ }
+ _PyGtkToggleButton_Type = (PyTypeObject *)PyObject_GetAttrString(module, "ToggleButton");
+ if (_PyGtkToggleButton_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name ToggleButton from gtk");
+ return ;
+ }
+ _PyGtkRadioButton_Type = (PyTypeObject *)PyObject_GetAttrString(module, "RadioButton");
+ if (_PyGtkRadioButton_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name RadioButton from gtk");
+ return ;
+ }
+ _PyGtkSpinButton_Type = (PyTypeObject *)PyObject_GetAttrString(module, "SpinButton");
+ if (_PyGtkSpinButton_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name SpinButton from gtk");
+ return ;
+ }
+ _PyGtkEntry_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Entry");
+ if (_PyGtkEntry_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Entry from gtk");
+ return ;
+ }
+ _PyGtkDrawingArea_Type = (PyTypeObject *)PyObject_GetAttrString(module, "DrawingArea");
+ if (_PyGtkDrawingArea_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name DrawingArea from gtk");
+ return ;
+ }
+ _PyGtkTable_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Table");
+ if (_PyGtkTable_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Table from gtk");
+ return ;
+ }
+ _PyGtkFrame_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Frame");
+ if (_PyGtkFrame_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Frame from gtk");
+ return ;
+ }
+ _PyGtkHBox_Type = (PyTypeObject *)PyObject_GetAttrString(module, "HBox");
+ if (_PyGtkHBox_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name HBox from gtk");
+ return ;
+ }
+ _PyGtkVBox_Type = (PyTypeObject *)PyObject_GetAttrString(module, "VBox");
+ if (_PyGtkVBox_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name VBox from gtk");
+ return ;
+ }
+ _PyGtkHPaned_Type = (PyTypeObject *)PyObject_GetAttrString(module, "HPaned");
+ if (_PyGtkHPaned_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name HPaned from gtk");
+ return ;
+ }
+ _PyGtkVPaned_Type = (PyTypeObject *)PyObject_GetAttrString(module, "VPaned");
+ if (_PyGtkVPaned_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name VPaned from gtk");
+ return ;
+ }
+ _PyGtkScale_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Scale");
+ if (_PyGtkScale_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Scale from gtk");
+ return ;
+ }
+ _PyGtkProgressBar_Type = (PyTypeObject *)PyObject_GetAttrString(module, "ProgressBar");
+ if (_PyGtkProgressBar_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name ProgressBar from gtk");
+ return ;
+ }
+ _PyGtkOptionMenu_Type = (PyTypeObject *)PyObject_GetAttrString(module, "OptionMenu");
+ if (_PyGtkOptionMenu_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name OptionMenu from gtk");
+ return ;
+ }
+ _PyGtkComboBox_Type = (PyTypeObject *)PyObject_GetAttrString(module, "ComboBox");
+ if (_PyGtkComboBox_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name ComboBox from gtk");
+ return ;
+ }
+ _PyGtkListStore_Type = (PyTypeObject *)PyObject_GetAttrString(module, "ListStore");
+ if (_PyGtkListStore_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name ListStore from gtk");
+ return ;
+ }
+ _PyGtkTreeModel_Type = (PyTypeObject *)PyObject_GetAttrString(module, "TreeModel");
+ if (_PyGtkTreeModel_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name TreeModel from gtk");
+ return ;
+ }
+ _PyGtkCellRenderer_Type = (PyTypeObject *)PyObject_GetAttrString(module, "CellRenderer");
+ if (_PyGtkCellRenderer_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name CellRenderer from gtk");
+ return ;
+ }
+ _PyGtkCellRendererToggle_Type = (PyTypeObject *)PyObject_GetAttrString(module, "CellRendererToggle");
+ if (_PyGtkCellRendererToggle_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name CellRendererToggle from gtk");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gtk");
+ return ;
+ }
+ if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) {
+ _PyGdkPixbuf_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Pixbuf");
+ if (_PyGdkPixbuf_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Pixbuf from gtk.gdk");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gtk.gdk");
+ return ;
+ }
+ if ((module = PyImport_ImportModule("gimp")) != NULL) {
+ _PyGimpParasite_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Parasite");
+ if (_PyGimpParasite_Type == NULL) {
+ PyErr_SetString(PyExc_ImportError,
+ "cannot import name Parasite from gimp");
+ return ;
+ }
+ } else {
+ PyErr_SetString(PyExc_ImportError,
+ "could not import gimp");
+ return ;
+ }
+
+
+#line 9289 "gimpui.c"
+ pyg_register_interface(d, "ColorManaged", GIMP_TYPE_COLOR_MANAGED, &PyGimpColorManaged_Type);
+ pygobject_register_class(d, "GimpBrowser", GIMP_TYPE_BROWSER, &PyGimpBrowser_Type, Py_BuildValue("(O)", &PyGtkHPaned_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_BROWSER);
+ pygobject_register_class(d, "GimpButton", GIMP_TYPE_BUTTON, &PyGimpButton_Type, Py_BuildValue("(O)", &PyGtkButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_BUTTON);
+ pygobject_register_class(d, "GimpCellRendererColor", GIMP_TYPE_CELL_RENDERER_COLOR, &PyGimpCellRendererColor_Type, Py_BuildValue("(O)", &PyGtkCellRenderer_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_CELL_RENDERER_COLOR);
+ pygobject_register_class(d, "GimpCellRendererToggle", GIMP_TYPE_CELL_RENDERER_TOGGLE, &PyGimpCellRendererToggle_Type, Py_BuildValue("(O)", &PyGtkCellRendererToggle_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_CELL_RENDERER_TOGGLE);
+ pygobject_register_class(d, "GimpChainButton", GIMP_TYPE_CHAIN_BUTTON, &PyGimpChainButton_Type, Py_BuildValue("(O)", &PyGtkTable_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_CHAIN_BUTTON);
+ pygobject_register_class(d, "GimpColorArea", GIMP_TYPE_COLOR_AREA, &PyGimpColorArea_Type, Py_BuildValue("(O)", &PyGtkDrawingArea_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_AREA);
+ pygobject_register_class(d, "GimpColorButton", GIMP_TYPE_COLOR_BUTTON, &PyGimpColorButton_Type, Py_BuildValue("(O)", &PyGimpButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_BUTTON);
+ pygobject_register_class(d, "GimpColorConfig", GIMP_TYPE_COLOR_CONFIG, &PyGimpColorConfig_Type, Py_BuildValue("(O)", &PyGObject_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_CONFIG);
+ pygobject_register_class(d, "GimpColorDisplay", GIMP_TYPE_COLOR_DISPLAY, &PyGimpColorDisplay_Type, Py_BuildValue("(O)", &PyGObject_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_DISPLAY);
+ pygobject_register_class(d, "GimpColorDisplayStack", GIMP_TYPE_COLOR_DISPLAY_STACK, &PyGimpColorDisplayStack_Type, Py_BuildValue("(O)", &PyGObject_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_DISPLAY_STACK);
+ pygobject_register_class(d, "GimpColorHexEntry", GIMP_TYPE_COLOR_HEX_ENTRY, &PyGimpColorHexEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_HEX_ENTRY);
+ pygobject_register_class(d, "GimpColorProfileComboBox", GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, &PyGimpColorProfileComboBox_Type, Py_BuildValue("(O)", &PyGtkComboBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_PROFILE_COMBO_BOX);
+ pygobject_register_class(d, "GimpColorProfileStore", GIMP_TYPE_COLOR_PROFILE_STORE, &PyGimpColorProfileStore_Type, Py_BuildValue("(O)", &PyGtkListStore_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_PROFILE_STORE);
+ pygobject_register_class(d, "GimpColorScale", GIMP_TYPE_COLOR_SCALE, &PyGimpColorScale_Type, Py_BuildValue("(O)", &PyGtkScale_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_SCALE);
+ pygobject_register_class(d, "GimpColorSelection", GIMP_TYPE_COLOR_SELECTION, &PyGimpColorSelection_Type, Py_BuildValue("(O)", &PyGtkVBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_COLOR_SELECTION);
+ pygobject_register_class(d, "GimpColorSelector", GIMP_TYPE_COLOR_SELECTOR, &PyGimpColorSelector_Type, Py_BuildValue("(O)", &PyGtkVBox_Type));
+ pygobject_register_class(d, "GimpColorScales", GIMP_TYPE_COLOR_SCALES, &PyGimpColorScales_Type, Py_BuildValue("(O)", &PyGimpColorSelector_Type));
+ pygobject_register_class(d, "GimpColorNotebook", GIMP_TYPE_COLOR_NOTEBOOK, &PyGimpColorNotebook_Type, Py_BuildValue("(O)", &PyGimpColorSelector_Type));
+ pygobject_register_class(d, "GimpDialog", GIMP_TYPE_DIALOG, &PyGimpDialog_Type, Py_BuildValue("(O)", &PyGtkDialog_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_DIALOG);
+ pygobject_register_class(d, "GimpEnumLabel", GIMP_TYPE_ENUM_LABEL, &PyGimpEnumLabel_Type, Py_BuildValue("(O)", &PyGtkLabel_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_ENUM_LABEL);
+ pygobject_register_class(d, "GimpFrame", GIMP_TYPE_FRAME, &PyGimpFrame_Type, Py_BuildValue("(O)", &PyGtkFrame_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_FRAME);
+ pygobject_register_class(d, "GimpHintBox", GIMP_TYPE_HINT_BOX, &PyGimpHintBox_Type, Py_BuildValue("(O)", &PyGtkHBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_HINT_BOX);
+ pygobject_register_class(d, "GimpIntComboBox", GIMP_TYPE_INT_COMBO_BOX, &PyGimpIntComboBox_Type, Py_BuildValue("(O)", &PyGtkComboBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_INT_COMBO_BOX);
+ pygobject_register_class(d, "GimpImageComboBox", GIMP_TYPE_IMAGE_COMBO_BOX, &PyGimpImageComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpEnumComboBox", GIMP_TYPE_ENUM_COMBO_BOX, &PyGimpEnumComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpDrawableComboBox", GIMP_TYPE_DRAWABLE_COMBO_BOX, &PyGimpDrawableComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpChannelComboBox", GIMP_TYPE_CHANNEL_COMBO_BOX, &PyGimpChannelComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpIntStore", GIMP_TYPE_INT_STORE, &PyGimpIntStore_Type, Py_BuildValue("(O)", &PyGtkListStore_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_INT_STORE);
+ pygobject_register_class(d, "GimpEnumStore", GIMP_TYPE_ENUM_STORE, &PyGimpEnumStore_Type, Py_BuildValue("(O)", &PyGimpIntStore_Type));
+ pygobject_register_class(d, "GimpLayerComboBox", GIMP_TYPE_LAYER_COMBO_BOX, &PyGimpLayerComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpMemsizeEntry", GIMP_TYPE_MEMSIZE_ENTRY, &PyGimpMemsizeEntry_Type, Py_BuildValue("(O)", &PyGtkHBox_Type));
+ pygobject_register_class(d, "GimpNumberPairEntry", GIMP_TYPE_NUMBER_PAIR_ENTRY, &PyGimpNumberPairEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_NUMBER_PAIR_ENTRY);
+ pygobject_register_class(d, "GimpOffsetArea", GIMP_TYPE_OFFSET_AREA, &PyGimpOffsetArea_Type, Py_BuildValue("(O)", &PyGtkDrawingArea_Type));
+ pygobject_register_class(d, "GimpPageSelector", GIMP_TYPE_PAGE_SELECTOR, &PyGimpPageSelector_Type, Py_BuildValue("(O)", &PyGtkVBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PAGE_SELECTOR);
+ pygobject_register_class(d, "GimpPathEditor", GIMP_TYPE_PATH_EDITOR, &PyGimpPathEditor_Type, Py_BuildValue("(O)", &PyGtkVBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PATH_EDITOR);
+ pygobject_register_class(d, "GimpPickButton", GIMP_TYPE_PICK_BUTTON, &PyGimpPickButton_Type, Py_BuildValue("(O)", &PyGtkButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PICK_BUTTON);
+ pygobject_register_class(d, "GimpPreview", GIMP_TYPE_PREVIEW, &PyGimpPreview_Type, Py_BuildValue("(O)", &PyGtkVBox_Type));
+ pygobject_register_class(d, "GimpAspectPreview", GIMP_TYPE_ASPECT_PREVIEW, &PyGimpAspectPreview_Type, Py_BuildValue("(O)", &PyGimpPreview_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_ASPECT_PREVIEW);
+ pygobject_register_class(d, "GimpPreviewArea", GIMP_TYPE_PREVIEW_AREA, &PyGimpPreviewArea_Type, Py_BuildValue("(O)", &PyGtkDrawingArea_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PREVIEW_AREA);
+ pygobject_register_class(d, "GimpProcBrowserDialog", GIMP_TYPE_PROC_BROWSER_DIALOG, &PyGimpProcBrowserDialog_Type, Py_BuildValue("(O)", &PyGimpDialog_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PROC_BROWSER_DIALOG);
+ pygobject_register_class(d, "GimpProgressBar", GIMP_TYPE_PROGRESS_BAR, &PyGimpProgressBar_Type, Py_BuildValue("(O)", &PyGtkProgressBar_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PROGRESS_BAR);
+ pygobject_register_class(d, "GimpScrolledPreview", GIMP_TYPE_SCROLLED_PREVIEW, &PyGimpScrolledPreview_Type, Py_BuildValue("(O)", &PyGimpPreview_Type));
+ pygobject_register_class(d, "GimpDrawablePreview", GIMP_TYPE_DRAWABLE_PREVIEW, &PyGimpDrawablePreview_Type, Py_BuildValue("(O)", &PyGimpScrolledPreview_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_DRAWABLE_PREVIEW);
+ pygobject_register_class(d, "GimpSelectButton", GIMP_TYPE_SELECT_BUTTON, &PyGimpSelectButton_Type, Py_BuildValue("(O)", &PyGtkHBox_Type));
+ pygobject_register_class(d, "GimpPatternSelectButton", GIMP_TYPE_PATTERN_SELECT_BUTTON, &PyGimpPatternSelectButton_Type, Py_BuildValue("(O)", &PyGimpSelectButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PATTERN_SELECT_BUTTON);
+ pygobject_register_class(d, "GimpPaletteSelectButton", GIMP_TYPE_PALETTE_SELECT_BUTTON, &PyGimpPaletteSelectButton_Type, Py_BuildValue("(O)", &PyGimpSelectButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_PALETTE_SELECT_BUTTON);
+ pygobject_register_class(d, "GimpGradientSelectButton", GIMP_TYPE_GRADIENT_SELECT_BUTTON, &PyGimpGradientSelectButton_Type, Py_BuildValue("(O)", &PyGimpSelectButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_GRADIENT_SELECT_BUTTON);
+ pygobject_register_class(d, "GimpFontSelectButton", GIMP_TYPE_FONT_SELECT_BUTTON, &PyGimpFontSelectButton_Type, Py_BuildValue("(O)", &PyGimpSelectButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_FONT_SELECT_BUTTON);
+ pygobject_register_class(d, "GimpBrushSelectButton", GIMP_TYPE_BRUSH_SELECT_BUTTON, &PyGimpBrushSelectButton_Type, Py_BuildValue("(O)", &PyGimpSelectButton_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_BRUSH_SELECT_BUTTON);
+ pygobject_register_class(d, "GimpRuler", GIMP_TYPE_RULER, &PyGimpRuler_Type, Py_BuildValue("(O)", &PyGtkWidget_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_RULER);
+ pygobject_register_class(d, "GimpSizeEntry", GIMP_TYPE_SIZE_ENTRY, &PyGimpSizeEntry_Type, Py_BuildValue("(O)", &PyGtkTable_Type));
+ pygobject_register_class(d, "GimpStringComboBox", GIMP_TYPE_STRING_COMBO_BOX, &PyGimpStringComboBox_Type, Py_BuildValue("(O)", &PyGtkComboBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_STRING_COMBO_BOX);
+ pygobject_register_class(d, "GimpUnitComboBox", GIMP_TYPE_UNIT_COMBO_BOX, &PyGimpUnitComboBox_Type, Py_BuildValue("(O)", &PyGtkComboBox_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_UNIT_COMBO_BOX);
+ pygobject_register_class(d, "GimpUnitMenu", GIMP_TYPE_UNIT_MENU, &PyGimpUnitMenu_Type, Py_BuildValue("(O)", &PyGtkOptionMenu_Type));
+ pygobject_register_class(d, "GimpVectorsComboBox", GIMP_TYPE_VECTORS_COMBO_BOX, &PyGimpVectorsComboBox_Type, Py_BuildValue("(O)", &PyGimpIntComboBox_Type));
+ pygobject_register_class(d, "GimpZoomModel", GIMP_TYPE_ZOOM_MODEL, &PyGimpZoomModel_Type, Py_BuildValue("(O)", &PyGObject_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_ZOOM_MODEL);
+ pygobject_register_class(d, "GimpZoomPreview", GIMP_TYPE_ZOOM_PREVIEW, &PyGimpZoomPreview_Type, Py_BuildValue("(O)", &PyGimpScrolledPreview_Type));
+ pyg_set_object_has_new_constructor(GIMP_TYPE_ZOOM_PREVIEW);
+}
diff --git a/plug-ins/pygimp/gimpui.defs b/plug-ins/pygimp/gimpui.defs
new file mode 100644
index 0000000..1540534
--- /dev/null
+++ b/plug-ins/pygimp/gimpui.defs
@@ -0,0 +1,3411 @@
+;; -*- scheme -*-
+; object definitions ...
+(define-object Browser
+ (in-module "Gimp")
+ (parent "GtkHPaned")
+ (c-name "GimpBrowser")
+ (gtype-id "GIMP_TYPE_BROWSER")
+)
+
+(define-object Button
+ (in-module "Gimp")
+ (parent "GtkButton")
+ (c-name "GimpButton")
+ (gtype-id "GIMP_TYPE_BUTTON")
+)
+
+(define-object CellRendererColor
+ (in-module "Gimp")
+ (parent "GtkCellRenderer")
+ (c-name "GimpCellRendererColor")
+ (gtype-id "GIMP_TYPE_CELL_RENDERER_COLOR")
+)
+
+(define-object CellRendererToggle
+ (in-module "Gimp")
+ (parent "GtkCellRendererToggle")
+ (c-name "GimpCellRendererToggle")
+ (gtype-id "GIMP_TYPE_CELL_RENDERER_TOGGLE")
+)
+
+(define-object ChainButton
+ (in-module "Gimp")
+ (parent "GtkTable")
+ (c-name "GimpChainButton")
+ (gtype-id "GIMP_TYPE_CHAIN_BUTTON")
+)
+
+(define-object ColorArea
+ (in-module "Gimp")
+ (parent "GtkDrawingArea")
+ (c-name "GimpColorArea")
+ (gtype-id "GIMP_TYPE_COLOR_AREA")
+)
+
+(define-object ColorButton
+ (in-module "Gimp")
+ (parent "GimpButton")
+ (c-name "GimpColorButton")
+ (gtype-id "GIMP_TYPE_COLOR_BUTTON")
+)
+
+(define-object ColorConfig
+ (in-module "Gimp")
+ (parent "GObject")
+ (c-name "GimpColorConfig")
+ (gtype-id "GIMP_TYPE_COLOR_CONFIG")
+)
+
+(define-object ColorDisplay
+ (in-module "Gimp")
+ (parent "GObject")
+ (c-name "GimpColorDisplay")
+ (gtype-id "GIMP_TYPE_COLOR_DISPLAY")
+)
+
+(define-object ColorDisplayStack
+ (in-module "Gimp")
+ (parent "GObject")
+ (c-name "GimpColorDisplayStack")
+ (gtype-id "GIMP_TYPE_COLOR_DISPLAY_STACK")
+)
+
+(define-object ColorHexEntry
+ (in-module "Gimp")
+ (parent "GtkEntry")
+ (c-name "GimpColorHexEntry")
+ (gtype-id "GIMP_TYPE_COLOR_HEX_ENTRY")
+)
+
+(define-object ColorProfileComboBox
+ (in-module "Gimp")
+ (parent "GtkComboBox")
+ (c-name "GimpColorProfileComboBox")
+ (gtype-id "GIMP_TYPE_COLOR_PROFILE_COMBO_BOX")
+)
+
+(define-object ColorProfileStore
+ (in-module "Gimp")
+ (parent "GtkListStore")
+ (c-name "GimpColorProfileStore")
+ (gtype-id "GIMP_TYPE_COLOR_PROFILE_STORE")
+)
+
+(define-object ColorScale
+ (in-module "Gimp")
+ (parent "GtkScale")
+ (c-name "GimpColorScale")
+ (gtype-id "GIMP_TYPE_COLOR_SCALE")
+)
+
+(define-object ColorScales
+ (in-module "Gimp")
+ (parent "GimpColorSelector")
+ (c-name "GimpColorScales")
+ (gtype-id "GIMP_TYPE_COLOR_SCALES")
+)
+
+(define-object ColorSelection
+ (in-module "Gimp")
+ (parent "GtkVBox")
+ (c-name "GimpColorSelection")
+ (gtype-id "GIMP_TYPE_COLOR_SELECTION")
+)
+
+(define-object ColorSelector
+ (in-module "Gimp")
+ (parent "GtkVBox")
+ (c-name "GimpColorSelector")
+ (gtype-id "GIMP_TYPE_COLOR_SELECTOR")
+)
+
+(define-object ColorNotebook
+ (in-module "Gimp")
+ (parent "GimpColorSelector")
+ (c-name "GimpColorNotebook")
+ (gtype-id "GIMP_TYPE_COLOR_NOTEBOOK")
+)
+
+(define-object Dialog
+ (in-module "Gimp")
+ (parent "GtkDialog")
+ (c-name "GimpDialog")
+ (gtype-id "GIMP_TYPE_DIALOG")
+)
+
+(define-object EnumLabel
+ (in-module "Gimp")
+ (parent "GtkLabel")
+ (c-name "GimpEnumLabel")
+ (gtype-id "GIMP_TYPE_ENUM_LABEL")
+)
+
+(define-object Frame
+ (in-module "Gimp")
+ (parent "GtkFrame")
+ (c-name "GimpFrame")
+ (gtype-id "GIMP_TYPE_FRAME")
+)
+
+(define-object HintBox
+ (in-module "Gimp")
+ (parent "GtkHBox")
+ (c-name "GimpHintBox")
+ (gtype-id "GIMP_TYPE_HINT_BOX")
+)
+
+(define-object IntComboBox
+ (in-module "Gimp")
+ (parent "GtkComboBox")
+ (c-name "GimpIntComboBox")
+ (gtype-id "GIMP_TYPE_INT_COMBO_BOX")
+)
+
+(define-object ImageComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpImageComboBox")
+ (gtype-id "GIMP_TYPE_IMAGE_COMBO_BOX")
+)
+
+(define-object EnumComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpEnumComboBox")
+ (gtype-id "GIMP_TYPE_ENUM_COMBO_BOX")
+)
+
+(define-object DrawableComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpDrawableComboBox")
+ (gtype-id "GIMP_TYPE_DRAWABLE_COMBO_BOX")
+)
+
+(define-object ChannelComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpChannelComboBox")
+ (gtype-id "GIMP_TYPE_CHANNEL_COMBO_BOX")
+)
+
+(define-object IntStore
+ (in-module "Gimp")
+ (parent "GtkListStore")
+ (c-name "GimpIntStore")
+ (gtype-id "GIMP_TYPE_INT_STORE")
+)
+
+(define-object EnumStore
+ (in-module "Gimp")
+ (parent "GimpIntStore")
+ (c-name "GimpEnumStore")
+ (gtype-id "GIMP_TYPE_ENUM_STORE")
+)
+
+(define-object LayerComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpLayerComboBox")
+ (gtype-id "GIMP_TYPE_LAYER_COMBO_BOX")
+)
+
+(define-object MemsizeEntry
+ (in-module "Gimp")
+ (parent "GtkHBox")
+ (c-name "GimpMemsizeEntry")
+ (gtype-id "GIMP_TYPE_MEMSIZE_ENTRY")
+)
+
+(define-object NumberPairEntry
+ (in-module "Gimp")
+ (parent "GtkEntry")
+ (c-name "GimpNumberPairEntry")
+ (gtype-id "GIMP_TYPE_NUMBER_PAIR_ENTRY")
+)
+
+(define-object OffsetArea
+ (in-module "Gimp")
+ (parent "GtkDrawingArea")
+ (c-name "GimpOffsetArea")
+ (gtype-id "GIMP_TYPE_OFFSET_AREA")
+)
+
+(define-object PageSelector
+ (in-module "Gimp")
+ (parent "GtkVBox")
+ (c-name "GimpPageSelector")
+ (gtype-id "GIMP_TYPE_PAGE_SELECTOR")
+)
+
+(define-object PathEditor
+ (in-module "Gimp")
+ (parent "GtkVBox")
+ (c-name "GimpPathEditor")
+ (gtype-id "GIMP_TYPE_PATH_EDITOR")
+)
+
+(define-object PickButton
+ (in-module "Gimp")
+ (parent "GtkButton")
+ (c-name "GimpPickButton")
+ (gtype-id "GIMP_TYPE_PICK_BUTTON")
+)
+
+(define-object Preview
+ (in-module "Gimp")
+ (parent "GtkVBox")
+ (c-name "GimpPreview")
+ (gtype-id "GIMP_TYPE_PREVIEW")
+)
+
+(define-object AspectPreview
+ (in-module "Gimp")
+ (parent "GimpPreview")
+ (c-name "GimpAspectPreview")
+ (gtype-id "GIMP_TYPE_ASPECT_PREVIEW")
+)
+
+(define-object PreviewArea
+ (in-module "Gimp")
+ (parent "GtkDrawingArea")
+ (c-name "GimpPreviewArea")
+ (gtype-id "GIMP_TYPE_PREVIEW_AREA")
+)
+
+(define-object ProcBrowserDialog
+ (in-module "Gimp")
+ (parent "GimpDialog")
+ (c-name "GimpProcBrowserDialog")
+ (gtype-id "GIMP_TYPE_PROC_BROWSER_DIALOG")
+)
+
+(define-object ProgressBar
+ (in-module "Gimp")
+ (parent "GtkProgressBar")
+ (c-name "GimpProgressBar")
+ (gtype-id "GIMP_TYPE_PROGRESS_BAR")
+)
+
+(define-object ScrolledPreview
+ (in-module "Gimp")
+ (parent "GimpPreview")
+ (c-name "GimpScrolledPreview")
+ (gtype-id "GIMP_TYPE_SCROLLED_PREVIEW")
+)
+
+(define-object DrawablePreview
+ (in-module "Gimp")
+ (parent "GimpScrolledPreview")
+ (c-name "GimpDrawablePreview")
+ (gtype-id "GIMP_TYPE_DRAWABLE_PREVIEW")
+)
+
+(define-object SelectButton
+ (in-module "Gimp")
+ (parent "GtkHBox")
+ (c-name "GimpSelectButton")
+ (gtype-id "GIMP_TYPE_SELECT_BUTTON")
+)
+
+(define-object PatternSelectButton
+ (in-module "Gimp")
+ (parent "GimpSelectButton")
+ (c-name "GimpPatternSelectButton")
+ (gtype-id "GIMP_TYPE_PATTERN_SELECT_BUTTON")
+)
+
+(define-object PaletteSelectButton
+ (in-module "Gimp")
+ (parent "GimpSelectButton")
+ (c-name "GimpPaletteSelectButton")
+ (gtype-id "GIMP_TYPE_PALETTE_SELECT_BUTTON")
+)
+
+(define-object GradientSelectButton
+ (in-module "Gimp")
+ (parent "GimpSelectButton")
+ (c-name "GimpGradientSelectButton")
+ (gtype-id "GIMP_TYPE_GRADIENT_SELECT_BUTTON")
+)
+
+(define-object FontSelectButton
+ (in-module "Gimp")
+ (parent "GimpSelectButton")
+ (c-name "GimpFontSelectButton")
+ (gtype-id "GIMP_TYPE_FONT_SELECT_BUTTON")
+)
+
+(define-object BrushSelectButton
+ (in-module "Gimp")
+ (parent "GimpSelectButton")
+ (c-name "GimpBrushSelectButton")
+ (gtype-id "GIMP_TYPE_BRUSH_SELECT_BUTTON")
+)
+
+(define-object Ruler
+ (in-module "Gimp")
+ (parent "GtkWidget")
+ (c-name "GimpRuler")
+ (gtype-id "GIMP_TYPE_RULER")
+)
+
+(define-object SizeEntry
+ (in-module "Gimp")
+ (parent "GtkTable")
+ (c-name "GimpSizeEntry")
+ (gtype-id "GIMP_TYPE_SIZE_ENTRY")
+)
+
+(define-object StringComboBox
+ (in-module "Gimp")
+ (parent "GtkComboBox")
+ (c-name "GimpStringComboBox")
+ (gtype-id "GIMP_TYPE_STRING_COMBO_BOX")
+)
+
+(define-object UnitComboBox
+ (in-module "Gimp")
+ (parent "GtkComboBox")
+ (c-name "GimpUnitComboBox")
+ (gtype-id "GIMP_TYPE_UNIT_COMBO_BOX")
+)
+
+(define-object UnitMenu
+ (in-module "Gimp")
+ (parent "GtkOptionMenu")
+ (c-name "GimpUnitMenu")
+ (gtype-id "GIMP_TYPE_UNIT_MENU")
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-object VectorsComboBox
+ (in-module "Gimp")
+ (parent "GimpIntComboBox")
+ (c-name "GimpVectorsComboBox")
+ (gtype-id "GIMP_TYPE_VECTORS_COMBO_BOX")
+)
+
+(define-object ZoomModel
+ (in-module "Gimp")
+ (parent "GObject")
+ (c-name "GimpZoomModel")
+ (gtype-id "GIMP_TYPE_ZOOM_MODEL")
+)
+
+(define-object ZoomPreview
+ (in-module "Gimp")
+ (parent "GimpScrolledPreview")
+ (c-name "GimpZoomPreview")
+ (gtype-id "GIMP_TYPE_ZOOM_PREVIEW")
+)
+
+;; Interfaces
+
+(define-interface ColorManaged
+ (in-module "Gimp")
+ (c-name "GimpColorManaged")
+ (gtype-id "GIMP_TYPE_COLOR_MANAGED")
+)
+
+;; Enumerations and flags ...
+
+(define-enum IntStoreColumns
+ (in-module "Gimp")
+ (c-name "GimpIntStoreColumns")
+ (gtype-id "GIMP_TYPE_INT_STORE_COLUMNS")
+ (values
+ '("value" "GIMP_INT_STORE_VALUE")
+ '("label" "GIMP_INT_STORE_LABEL")
+ '("stock-id" "GIMP_INT_STORE_STOCK_ID")
+ '("pixbuf" "GIMP_INT_STORE_PIXBUF")
+ '("user-data" "GIMP_INT_STORE_USER_DATA")
+ '("num-columns" "GIMP_INT_STORE_NUM_COLUMNS")
+ )
+)
+
+(define-enum AspectType
+ (in-module "Gimp")
+ (c-name "GimpAspectType")
+ (gtype-id "GIMP_TYPE_ASPECT_TYPE")
+ (values
+ '("square" "GIMP_ASPECT_SQUARE")
+ '("portrait" "GIMP_ASPECT_PORTRAIT")
+ '("landscape" "GIMP_ASPECT_LANDSCAPE")
+ )
+)
+
+(define-enum ChainPosition
+ (in-module "Gimp")
+ (c-name "GimpChainPosition")
+ (gtype-id "GIMP_TYPE_CHAIN_POSITION")
+ (values
+ '("top" "GIMP_CHAIN_TOP")
+ '("left" "GIMP_CHAIN_LEFT")
+ '("bottom" "GIMP_CHAIN_BOTTOM")
+ '("right" "GIMP_CHAIN_RIGHT")
+ )
+)
+
+(define-enum ColorAreaType
+ (in-module "Gimp")
+ (c-name "GimpColorAreaType")
+ (gtype-id "GIMP_TYPE_COLOR_AREA_TYPE")
+ (values
+ '("flat" "GIMP_COLOR_AREA_FLAT")
+ '("small-checks" "GIMP_COLOR_AREA_SMALL_CHECKS")
+ '("large-checks" "GIMP_COLOR_AREA_LARGE_CHECKS")
+ )
+)
+
+(define-enum ColorSelectorChannel
+ (in-module "Gimp")
+ (c-name "GimpColorSelectorChannel")
+ (gtype-id "GIMP_TYPE_COLOR_SELECTOR_CHANNEL")
+ (values
+ '("hue" "GIMP_COLOR_SELECTOR_HUE")
+ '("saturation" "GIMP_COLOR_SELECTOR_SATURATION")
+ '("value" "GIMP_COLOR_SELECTOR_VALUE")
+ '("red" "GIMP_COLOR_SELECTOR_RED")
+ '("green" "GIMP_COLOR_SELECTOR_GREEN")
+ '("blue" "GIMP_COLOR_SELECTOR_BLUE")
+ '("alpha" "GIMP_COLOR_SELECTOR_ALPHA")
+ )
+)
+
+(define-enum PageSelectorTarget
+ (in-module "Gimp")
+ (c-name "GimpPageSelectorTarget")
+ (gtype-id "GIMP_TYPE_PAGE_SELECTOR_TARGET")
+ (values
+ '("layers" "GIMP_PAGE_SELECTOR_TARGET_LAYERS")
+ '("images" "GIMP_PAGE_SELECTOR_TARGET_IMAGES")
+ )
+)
+
+(define-enum SizeEntryUpdatePolicy
+ (in-module "Gimp")
+ (c-name "GimpSizeEntryUpdatePolicy")
+ (gtype-id "GIMP_TYPE_SIZE_ENTRY_UPDATE_POLICY")
+ (values
+ '("none" "GIMP_SIZE_ENTRY_UPDATE_NONE")
+ '("size" "GIMP_SIZE_ENTRY_UPDATE_SIZE")
+ '("resolution" "GIMP_SIZE_ENTRY_UPDATE_RESOLUTION")
+ )
+)
+
+(define-enum Unit
+ (in-module "Gimp")
+ (c-name "GimpUnit")
+;; FIXME: make GimpUnit enum more binding-friendly -- gimp_unit_get_type()
+;; (gtype-id "GIMP_TYPE_UNIT")
+ (values
+ '("pixel" "GIMP_UNIT_PIXEL")
+ '("inch" "GIMP_UNIT_INCH")
+ '("mm" "GIMP_UNIT_MM")
+ '("point" "GIMP_UNIT_POINT")
+ '("pica" "GIMP_UNIT_PICA")
+ )
+)
+
+(define-enum ZoomType
+ (in-module "Gimp")
+ (c-name "GimpZoomType")
+ (gtype-id "GIMP_TYPE_ZOOM_TYPE")
+ (values
+ '("in" "GIMP_ZOOM_IN")
+ '("out" "GIMP_ZOOM_OUT")
+ '("in-more" "GIMP_ZOOM_IN_MORE")
+ '("out-more" "GIMP_ZOOM_OUT_MORE")
+ '("in-max" "GIMP_ZOOM_IN_MAX")
+ '("out-max" "GIMP_ZOOM_OUT_MAX")
+ '("to" "GIMP_ZOOM_TO")
+ )
+)
+
+
+;; From gimpbrowser.h
+
+(define-function gimp_browser_get_type
+ (c-name "gimp_browser_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_browser_new
+ (c-name "gimp_browser_new")
+ (is-constructor-of "GimpBrowser")
+ (return-type "GtkWidget*")
+)
+
+(define-method add_search_types
+ (of-object "GimpBrowser")
+ (c-name "gimp_browser_add_search_types")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "first_type_label")
+ '("gint" "first_type_id")
+ )
+ (varargs #t)
+)
+
+(define-method set_widget
+ (of-object "GimpBrowser")
+ (c-name "gimp_browser_set_widget")
+ (return-type "none")
+ (parameters
+ '("GtkWidget*" "widget")
+ )
+)
+
+(define-method show_message
+ (of-object "GimpBrowser")
+ (c-name "gimp_browser_show_message")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "message")
+ )
+)
+
+
+
+;; From gimpbutton.h
+
+(define-function gimp_button_get_type
+ (c-name "gimp_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_button_new
+ (c-name "gimp_button_new")
+ (is-constructor-of "GimpButton")
+ (return-type "GtkWidget*")
+)
+
+(define-method extended_clicked
+ (of-object "GimpButton")
+ (c-name "gimp_button_extended_clicked")
+ (return-type "none")
+ (parameters
+ '("GdkModifierType" "state")
+ )
+)
+
+
+
+;; From gimpcellrenderercolor.h
+
+(define-function gimp_cell_renderer_color_get_type
+ (c-name "gimp_cell_renderer_color_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_cell_renderer_color_new
+ (c-name "gimp_cell_renderer_color_new")
+ (is-constructor-of "GimpCellRendererColor")
+ (return-type "GtkCellRenderer*")
+)
+
+
+
+;; From gimpcellrenderertoggle.h
+
+(define-function gimp_cell_renderer_toggle_get_type
+ (c-name "gimp_cell_renderer_toggle_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_cell_renderer_toggle_new
+ (c-name "gimp_cell_renderer_toggle_new")
+ (is-constructor-of "GimpCellRendererToggle")
+ (return-type "GtkCellRenderer*")
+ (properties
+ '("stock-id" (argname "stock_id") (optional))
+ )
+)
+
+(define-method clicked
+ (of-object "GimpCellRendererToggle")
+ (c-name "gimp_cell_renderer_toggle_clicked")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "path")
+ '("GdkModifierType" "state")
+ )
+)
+
+
+
+;; From gimpchainbutton.h
+
+(define-function gimp_chain_button_get_type
+ (c-name "gimp_chain_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_chain_button_new
+ (c-name "gimp_chain_button_new")
+ (is-constructor-of "GimpChainButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("position")
+ )
+)
+
+(define-method set_active
+ (of-object "GimpChainButton")
+ (c-name "gimp_chain_button_set_active")
+ (return-type "none")
+ (parameters
+ '("gboolean" "active")
+ )
+)
+
+(define-method get_active
+ (of-object "GimpChainButton")
+ (c-name "gimp_chain_button_get_active")
+ (return-type "gboolean")
+)
+
+
+
+;; From gimpcolorarea.h
+
+(define-function gimp_color_area_get_type
+ (c-name "gimp_color_area_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_area_new
+ (c-name "gimp_color_area_new")
+ (is-constructor-of "GimpColorArea")
+ (return-type "GtkWidget*")
+ (properties
+ '("color" (optional))
+ '("type" (optional))
+ '("drag-mask" (argname "drag_mask") (optional))
+ )
+)
+
+(define-method set_color
+ (of-object "GimpColorArea")
+ (c-name "gimp_color_area_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "color")
+ )
+)
+
+(define-method get_color
+ (of-object "GimpColorArea")
+ (c-name "gimp_color_area_get_color")
+ (return-type "none")
+ (parameters
+ '("GimpRGB*" "color")
+ )
+)
+
+(define-method has_alpha
+ (of-object "GimpColorArea")
+ (c-name "gimp_color_area_has_alpha")
+ (return-type "gboolean")
+)
+
+(define-method set_type
+ (of-object "GimpColorArea")
+ (c-name "gimp_color_area_set_type")
+ (return-type "none")
+ (parameters
+ '("GimpColorAreaType" "type")
+ )
+)
+
+(define-method set_draw_border
+ (of-object "GimpColorArea")
+ (c-name "gimp_color_area_set_draw_border")
+ (return-type "none")
+ (parameters
+ '("gboolean" "draw_border")
+ )
+)
+
+
+
+;; From gimpcolorbutton.h
+
+(define-function gimp_color_button_get_type
+ (c-name "gimp_color_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_button_new
+ (c-name "gimp_color_button_new")
+ (is-constructor-of "GimpColorButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("width" (optional))
+ '("height" (optional))
+ '("color" (optional))
+ '("type" (optional))
+ )
+)
+
+(define-method set_color
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "color")
+ )
+)
+
+(define-method get_color
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_get_color")
+ (return-type "none")
+ (parameters
+ '("GimpRGB*" "color")
+ )
+)
+
+(define-method has_alpha
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_has_alpha")
+ (return-type "gboolean")
+)
+
+(define-method set_type
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_set_type")
+ (return-type "none")
+ (parameters
+ '("GimpColorAreaType" "type")
+ )
+)
+
+(define-method get_update
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_get_update")
+ (return-type "gboolean")
+)
+
+(define-method set_update
+ (of-object "GimpColorButton")
+ (c-name "gimp_color_button_set_update")
+ (return-type "none")
+ (parameters
+ '("gboolean" "continuous")
+ )
+)
+
+
+
+;; From gimpcolordisplay.h
+
+(define-function gimp_color_display_get_type
+ (c-name "gimp_color_display_get_type")
+ (return-type "GType")
+)
+
+(define-method clone
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_clone")
+ (return-type "GimpColorDisplay*")
+)
+
+(define-method convert_surface
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_convert_surface")
+ (return-type "none")
+ (parameters
+ '("cairo_surface_t*" "surface")
+ )
+)
+
+(define-method convert
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_convert")
+ (return-type "none")
+ (parameters
+ '("guchar*" "buf")
+ '("gint" "width")
+ '("gint" "height")
+ '("gint" "bpp")
+ '("gint" "bpl")
+ )
+ (deprecated "use convert_surface(cairo_surface_t*) instead")
+)
+
+(define-method load_state
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_load_state")
+ (return-type "none")
+ (parameters
+ '("GimpParasite*" "state")
+ )
+)
+
+(define-method save_state
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_save_state")
+ (return-type "GimpParasite*")
+)
+
+(define-method configure
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_configure")
+ (return-type "GtkWidget*")
+)
+
+(define-method configure_reset
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_configure_reset")
+ (return-type "none")
+)
+
+(define-method changed
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_changed")
+ (return-type "none")
+)
+
+(define-method set_enabled
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_set_enabled")
+ (return-type "none")
+ (parameters
+ '("gboolean" "enabled")
+ )
+)
+
+(define-method get_enabled
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_get_enabled")
+ (return-type "gboolean")
+)
+
+(define-method get_config
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_get_config")
+ (return-type "GimpColorConfig*")
+)
+
+(define-method get_managed
+ (of-object "GimpColorDisplay")
+ (c-name "gimp_color_display_get_managed")
+ (return-type "GimpColorManaged*")
+)
+
+
+
+;; From gimpcolordisplaystack.h
+
+(define-function gimp_color_display_stack_get_type
+ (c-name "gimp_color_display_stack_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_display_stack_new
+ (c-name "gimp_color_display_stack_new")
+ (is-constructor-of "GimpColorDisplayStack")
+ (return-type "GimpColorDisplayStack*")
+)
+
+(define-method clone
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_clone")
+ (return-type "GimpColorDisplayStack*")
+)
+
+(define-method changed
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_changed")
+ (return-type "none")
+)
+
+(define-method add
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_add")
+ (return-type "none")
+ (parameters
+ '("GimpColorDisplay*" "display")
+ )
+)
+
+(define-method remove
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_remove")
+ (return-type "none")
+ (parameters
+ '("GimpColorDisplay*" "display")
+ )
+)
+
+(define-method reorder_up
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_reorder_up")
+ (return-type "none")
+ (parameters
+ '("GimpColorDisplay*" "display")
+ )
+)
+
+(define-method reorder_down
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_reorder_down")
+ (return-type "none")
+ (parameters
+ '("GimpColorDisplay*" "display")
+ )
+)
+
+(define-method convert_surface
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_convert_surface")
+ (return-type "none")
+ (parameters
+ '("cairo_surface_t*" "surface")
+ )
+)
+
+(define-method convert
+ (of-object "GimpColorDisplayStack")
+ (c-name "gimp_color_display_stack_convert")
+ (return-type "none")
+ (parameters
+ '("guchar*" "buf")
+ '("gint" "width")
+ '("gint" "height")
+ '("gint" "bpp")
+ '("gint" "bpl")
+ )
+ (deprecated "use convert_surface(cairo_surface_t*) instead")
+)
+
+
+
+;; From gimpcolorhexentry.h
+
+(define-function gimp_color_hex_entry_get_type
+ (c-name "gimp_color_hex_entry_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_hex_entry_new
+ (c-name "gimp_color_hex_entry_new")
+ (is-constructor-of "GimpColorHexEntry")
+ (return-type "GtkWidget*")
+)
+
+(define-method set_color
+ (of-object "GimpColorHexEntry")
+ (c-name "gimp_color_hex_entry_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "color")
+ )
+)
+
+(define-method get_color
+ (of-object "GimpColorHexEntry")
+ (c-name "gimp_color_hex_entry_get_color")
+ (return-type "none")
+ (parameters
+ '("GimpRGB*" "color")
+ )
+)
+
+
+
+;; From gimpcolornotebook.h
+
+(define-function gimp_color_notebook_get_type
+ (c-name "gimp_color_notebook_get_type")
+ (return-type "GType")
+)
+
+(define-method set_has_page
+ (of-object "GimpColorNotebook")
+ (c-name "gimp_color_notebook_set_has_page")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GType" "page_type")
+ '("gboolean" "has_page")
+ )
+)
+
+
+
+;; From gimpcolorprofilecombobox.h
+
+(define-function gimp_color_profile_combo_box_get_type
+ (c-name "gimp_color_profile_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_profile_combo_box_new_with_model
+ (c-name "gimp_color_profile_combo_box_new_with_model")
+ (is-constructor-of "GimpColorProfileComboBox")
+ (return-type "GtkWidget*")
+ (properties
+ '("dialog")
+ '("model")
+ )
+)
+
+(define-method add
+ (of-object "GimpColorProfileComboBox")
+ (c-name "gimp_color_profile_combo_box_add")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "filename")
+ '("const-gchar*" "label")
+ )
+)
+
+(define-method set_active
+ (of-object "GimpColorProfileComboBox")
+ (c-name "gimp_color_profile_combo_box_set_active")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "filename")
+ '("const-gchar*" "label")
+ )
+)
+
+(define-method get_active
+ (of-object "GimpColorProfileComboBox")
+ (c-name "gimp_color_profile_combo_box_get_active")
+ (return-type "gchar*")
+)
+
+
+
+;; From gimpcolorprofilestore.h
+
+(define-function gimp_color_profile_store_get_type
+ (c-name "gimp_color_profile_store_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_profile_store_new
+ (c-name "gimp_color_profile_store_new")
+ (is-constructor-of "GimpColorProfileStore")
+ (return-type "GtkListStore*")
+ (properties
+ '("history")
+ )
+)
+
+(define-method add
+ (of-object "GimpColorProfileStore")
+ (c-name "gimp_color_profile_store_add")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "filename")
+ '("const-gchar*" "label")
+ )
+)
+
+
+
+;; From gimpcolorscale.h
+
+(define-function gimp_color_scale_get_type
+ (c-name "gimp_color_scale_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_scale_new
+ (c-name "gimp_color_scale_new")
+ (is-constructor-of "GimpColorScale")
+ (return-type "GtkWidget*")
+ (properties
+ '("orientation")
+ '("channel")
+ )
+)
+
+(define-method set_channel
+ (of-object "GimpColorScale")
+ (c-name "gimp_color_scale_set_channel")
+ (return-type "none")
+ (parameters
+ '("GimpColorSelectorChannel" "channel")
+ )
+)
+
+(define-method set_color
+ (of-object "GimpColorScale")
+ (c-name "gimp_color_scale_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "rgb")
+ '("const-GimpHSV*" "hsv")
+ )
+)
+
+
+
+;; From gimpcolorscales.h
+
+(define-function gimp_color_scales_get_type
+ (c-name "gimp_color_scales_get_type")
+ (return-type "GType")
+)
+
+
+
+;; From gimpcolorselect.h
+
+(define-function gimp_color_select_get_type
+ (c-name "gimp_color_select_get_type")
+ (return-type "GType")
+)
+
+
+
+;; From gimpcolorselection.h
+
+(define-function gimp_color_selection_get_type
+ (c-name "gimp_color_selection_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_selection_new
+ (c-name "gimp_color_selection_new")
+ (is-constructor-of "GimpColorSelection")
+ (return-type "GtkWidget*")
+)
+
+(define-method set_show_alpha
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_set_show_alpha")
+ (return-type "none")
+ (parameters
+ '("gboolean" "show_alpha")
+ )
+)
+
+(define-method get_show_alpha
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_get_show_alpha")
+ (return-type "gboolean")
+)
+
+(define-method set_color
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "color")
+ )
+)
+
+(define-method get_color
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_get_color")
+ (return-type "none")
+ (parameters
+ '("GimpRGB*" "color")
+ )
+)
+
+(define-method set_old_color
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_set_old_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "color")
+ )
+)
+
+(define-method get_old_color
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_get_old_color")
+ (return-type "none")
+ (parameters
+ '("GimpRGB*" "color")
+ )
+)
+
+(define-method reset
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_reset")
+ (return-type "none")
+)
+
+(define-method color_changed
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_color_changed")
+ (return-type "none")
+)
+
+(define-method set_config
+ (of-object "GimpColorSelection")
+ (c-name "gimp_color_selection_set_config")
+ (return-type "none")
+ (parameters
+ '("GimpColorConfig*" "config")
+ )
+)
+
+
+
+;; From gimpcolorselector.h
+
+(define-function gimp_color_selector_get_type
+ (c-name "gimp_color_selector_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_selector_new
+ (c-name "gimp_color_selector_new")
+ (is-constructor-of "GimpColorSelector")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GType" "selector_type")
+ '("const-GimpRGB*" "rgb")
+ '("const-GimpHSV*" "hsv")
+ '("GimpColorSelectorChannel" "channel")
+ )
+)
+
+(define-method set_toggles_visible
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_toggles_visible")
+ (return-type "none")
+ (parameters
+ '("gboolean" "visible")
+ )
+)
+
+(define-method set_toggles_sensitive
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_toggles_sensitive")
+ (return-type "none")
+ (parameters
+ '("gboolean" "sensitive")
+ )
+)
+
+(define-method set_show_alpha
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_show_alpha")
+ (return-type "none")
+ (parameters
+ '("gboolean" "show_alpha")
+ )
+)
+
+(define-method set_color
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_color")
+ (return-type "none")
+ (parameters
+ '("const-GimpRGB*" "rgb")
+ '("const-GimpHSV*" "hsv")
+ )
+)
+
+(define-method set_channel
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_channel")
+ (return-type "none")
+ (parameters
+ '("GimpColorSelectorChannel" "channel")
+ )
+)
+
+(define-method color_changed
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_color_changed")
+ (return-type "none")
+)
+
+(define-method channel_changed
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_channel_changed")
+ (return-type "none")
+)
+
+(define-method set_config
+ (of-object "GimpColorSelector")
+ (c-name "gimp_color_selector_set_config")
+ (return-type "none")
+ (parameters
+ '("GimpColorConfig*" "config")
+ )
+)
+
+
+
+;; From gimpdialog.h
+
+(define-function gimp_dialog_get_type
+ (c-name "gimp_dialog_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_dialog_new
+ (c-name "gimp_dialog_new")
+ (is-constructor-of "GimpDialog")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "title")
+ '("const-gchar*" "role")
+ '("GtkWidget*" "parent")
+ '("GtkDialogFlags" "flags")
+ '("GimpHelpFunc" "help_func")
+ '("const-gchar*" "help_id")
+ )
+ (varargs #t)
+)
+
+(define-function gimp_dialog_new_valist
+ (c-name "gimp_dialog_new_valist")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "title")
+ '("const-gchar*" "role")
+ '("GtkWidget*" "parent")
+ '("GtkDialogFlags" "flags")
+ '("GimpHelpFunc" "help_func")
+ '("const-gchar*" "help_id")
+ '("va_list" "args")
+ )
+)
+
+(define-method add_button
+ (of-object "GimpDialog")
+ (c-name "gimp_dialog_add_button")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "button_text")
+ '("gint" "response_id")
+ )
+)
+
+(define-method add_buttons
+ (of-object "GimpDialog")
+ (c-name "gimp_dialog_add_buttons")
+ (return-type "none")
+ (parameters
+ )
+ (varargs #t)
+)
+
+(define-method add_buttons_valist
+ (of-object "GimpDialog")
+ (c-name "gimp_dialog_add_buttons_valist")
+ (return-type "none")
+ (parameters
+ '("va_list" "args")
+ )
+)
+
+(define-method run
+ (of-object "GimpDialog")
+ (c-name "gimp_dialog_run")
+ (return-type "gint")
+)
+
+(function gimp_dialogs_show_help_button
+ (c-name "gimp_dialogs_show_help_button")
+ (return-type "none")
+ (parameters
+ '("gboolean" "show")
+ )
+)
+
+;; from gimpui.h
+
+(define-method set_transient
+ (of-object "GimpDialog")
+ (c-name "gimp_window_set_transient")
+ (return-type "none")
+)
+
+
+;; From gimpenumcombobox.h
+
+(define-function gimp_enum_combo_box_get_type
+ (c-name "gimp_enum_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_enum_combo_box_new
+ (c-name "gimp_enum_combo_box_new")
+ (is-constructor-of "GimpEnumComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GType" "enum_type")
+ )
+)
+
+(define-function gimp_ui_init
+ (c-name "gimp_ui_init")
+ (return-type "none")
+)
+
+(define-function gimp_enum_combo_box_new_with_model
+ (c-name "gimp_enum_combo_box_new_with_model")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpEnumStore*" "enum_store")
+ )
+)
+
+(define-method set_stock_prefix
+ (of-object "GimpEnumComboBox")
+ (c-name "gimp_enum_combo_box_set_stock_prefix")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "stock_prefix")
+ )
+)
+
+
+
+;; From gimpenumlabel.h
+
+(define-function gimp_enum_label_get_type
+ (c-name "gimp_enum_label_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_enum_label_new
+ (c-name "gimp_enum_label_new")
+ (is-constructor-of "GimpEnumLabel")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GType" "enum_type")
+ '("gint" "value")
+ )
+)
+
+(define-method set_value
+ (of-object "GimpEnumLabel")
+ (c-name "gimp_enum_label_set_value")
+ (return-type "none")
+ (parameters
+ '("gint" "value")
+ )
+)
+
+
+
+;; From gimpenumstore.h
+
+(define-function gimp_enum_store_get_type
+ (c-name "gimp_enum_store_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_enum_store_new
+ (c-name "gimp_enum_store_new")
+ (is-constructor-of "GimpEnumStore")
+ (return-type "GtkListStore*")
+ (parameters
+ '("GType" "enum_type")
+ )
+)
+
+(define-function gimp_enum_store_new_with_range
+ (c-name "gimp_enum_store_new_with_range")
+ (return-type "GtkListStore*")
+ (parameters
+ '("GType" "enum_type")
+ '("gint" "minimum")
+ '("gint" "maximum")
+ )
+)
+
+(define-function gimp_enum_store_new_with_values
+ (c-name "gimp_enum_store_new_with_values")
+ (return-type "GtkListStore*")
+ (parameters
+ '("GType" "enum_type")
+ '("gint" "n_values")
+ )
+ (varargs #t)
+)
+
+(define-function gimp_enum_store_new_with_values_valist
+ (c-name "gimp_enum_store_new_with_values_valist")
+ (return-type "GtkListStore*")
+ (parameters
+ '("GType" "enum_type")
+ '("gint" "n_values")
+ '("va_list" "args")
+ )
+)
+
+(define-method set_stock_prefix
+ (of-object "GimpEnumStore")
+ (c-name "gimp_enum_store_set_stock_prefix")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "stock_prefix")
+ )
+)
+
+
+
+;; From gimpframe.h
+
+(define-function gimp_frame_get_type
+ (c-name "gimp_frame_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_frame_new
+ (c-name "gimp_frame_new")
+ (is-constructor-of "GimpFrame")
+ (return-type "GtkWidget*")
+ (properties
+ '("label")
+ )
+)
+
+
+
+;; From gimphintbox.h
+
+(define-function gimp_hint_box_get_type
+ (c-name "gimp_hint_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_hint_box_new
+ (c-name "gimp_hint_box_new")
+ (is-constructor-of "GimpHintBox")
+ (return-type "GtkWidget*")
+ (properties
+ '("hint")
+ '("stock-id" (optional))
+ )
+)
+
+
+
+;; From gimpintcombobox.h
+
+(define-function gimp_int_combo_box_get_type
+ (c-name "gimp_int_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_int_combo_box_new
+ (c-name "gimp_int_combo_box_new")
+ (is-constructor-of "GimpIntComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "first_label")
+ '("gint" "first_value")
+ )
+ (varargs #t)
+)
+
+(define-function gimp_int_combo_box_new_valist
+ (c-name "gimp_int_combo_box_new_valist")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "first_label")
+ '("gint" "first_value")
+ '("va_list" "values")
+ )
+)
+
+(define-function gimp_int_combo_box_new_array
+ (c-name "gimp_int_combo_box_new_array")
+ (return-type "GtkWidget*")
+ (parameters
+ '("gint" "n_values")
+ '("const-gchar*[]" "labels")
+ )
+)
+
+(define-method prepend
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_prepend")
+ (return-type "none")
+ (parameters
+ )
+ (varargs #t)
+)
+
+(define-method append
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_append")
+ (return-type "none")
+ (parameters
+ )
+ (varargs #t)
+)
+
+(define-method set_active
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_set_active")
+ (return-type "gboolean")
+ (parameters
+ '("gint" "value")
+ )
+)
+
+(define-method get_active
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_get_active")
+ (return-type "gboolean")
+ (parameters
+ '("gint*" "value")
+ )
+)
+
+(define-method connect
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_connect")
+ (return-type "gulong")
+ (parameters
+ '("gint" "value")
+ '("GCallback" "callback")
+ '("gpointer" "data")
+ )
+)
+
+(define-method set_sensitivity
+ (of-object "GimpIntComboBox")
+ (c-name "gimp_int_combo_box_set_sensitivity")
+ (return-type "none")
+ (parameters
+ '("GimpIntSensitivityFunc" "func")
+ '("gpointer" "data")
+ '("GDestroyNotify" "destroy")
+ )
+)
+
+
+
+;; From gimpintstore.h
+
+(define-function gimp_int_store_get_type
+ (c-name "gimp_int_store_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_int_store_new
+ (c-name "gimp_int_store_new")
+ (is-constructor-of "GimpIntStore")
+ (return-type "GtkListStore*")
+)
+
+(define-method lookup_by_value
+ (of-object "GimpIntStore")
+ (c-name "gimp_int_store_lookup_by_value")
+ (return-type "gboolean")
+ (parameters
+ '("gint" "value")
+ '("GtkTreeIter*" "iter")
+ )
+)
+
+
+
+;; From gimpmemsizeentry.h
+
+(define-function gimp_memsize_entry_get_type
+ (c-name "gimp_memsize_entry_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_memsize_entry_new
+ (c-name "gimp_memsize_entry_new")
+ (is-constructor-of "GimpMemsizeEntry")
+ (return-type "GtkWidget*")
+ (parameters
+ '("guint64" "value")
+ '("guint64" "lower")
+ '("guint64" "upper")
+ )
+)
+
+(define-method set_value
+ (of-object "GimpMemsizeEntry")
+ (c-name "gimp_memsize_entry_set_value")
+ (return-type "none")
+ (parameters
+ '("guint64" "value")
+ )
+)
+
+(define-method get_value
+ (of-object "GimpMemsizeEntry")
+ (c-name "gimp_memsize_entry_get_value")
+ (return-type "guint64")
+)
+
+
+
+;; From gimpnumberpairentry.h
+
+(define-function gimp_number_pair_entry_get_type
+ (c-name "gimp_number_pair_entry_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_number_pair_entry_new
+ (c-name "gimp_number_pair_entry_new")
+ (is-constructor-of "GimpNumberPairEntry")
+ (return-type "GtkWidget*")
+ (properties
+ '("separators")
+ '("allow-simplification" (argname "allow_simplification"))
+ '("min-valid-value" (argname "min_valid_value"))
+ '("max-valid-value" (argname "max_valid_value"))
+ )
+)
+
+(define-method set_default_values
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_default_values")
+ (return-type "none")
+ (parameters
+ '("gdouble" "left")
+ '("gdouble" "right")
+ )
+)
+
+(define-method get_default_values
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_default_values")
+ (return-type "none")
+ (parameters
+ '("gdouble*" "left")
+ '("gdouble*" "right")
+ )
+)
+
+(define-method set_values
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_values")
+ (return-type "none")
+ (parameters
+ '("gdouble" "left")
+ '("gdouble" "right")
+ )
+)
+
+(define-method get_values
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_values")
+ (return-type "none")
+ (parameters
+ '("gdouble*" "left")
+ '("gdouble*" "right")
+ )
+)
+
+(define-method set_default_text
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_default_text")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "string")
+ )
+)
+
+(define-method get_default_text
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_default_text")
+ (return-type "const-gchar*")
+)
+
+(define-method set_ratio
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_ratio")
+ (return-type "none")
+ (parameters
+ '("gdouble" "ratio")
+ )
+)
+
+(define-method get_ratio
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_ratio")
+ (return-type "gdouble")
+)
+
+(define-method set_aspect
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_aspect")
+ (return-type "none")
+ (parameters
+ '("GimpAspectType" "aspect")
+ )
+)
+
+(define-method get_aspect
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_aspect")
+ (return-type "GimpAspectType")
+)
+
+(define-method set_user_override
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_set_user_override")
+ (return-type "none")
+ (parameters
+ '("gboolean" "user_override")
+ )
+)
+
+(define-method get_user_override
+ (of-object "GimpNumberPairEntry")
+ (c-name "gimp_number_pair_entry_get_user_override")
+ (return-type "gboolean")
+)
+
+
+
+;; From gimpoffsetarea.h
+
+(define-function gimp_offset_area_get_type
+ (c-name "gimp_offset_area_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_offset_area_new
+ (c-name "gimp_offset_area_new")
+ (is-constructor-of "GimpOffsetArea")
+ (return-type "GtkWidget*")
+ (parameters
+ '("gint" "orig_width")
+ '("gint" "orig_height")
+ )
+)
+
+(define-method set_pixbuf
+ (of-object "GimpOffsetArea")
+ (c-name "gimp_offset_area_set_pixbuf")
+ (return-type "none")
+ (parameters
+ '("GdkPixbuf*" "pixbuf")
+ )
+)
+
+(define-method set_size
+ (of-object "GimpOffsetArea")
+ (c-name "gimp_offset_area_set_size")
+ (return-type "none")
+ (parameters
+ '("gint" "width")
+ '("gint" "height")
+ )
+)
+
+(define-method set_offsets
+ (of-object "GimpOffsetArea")
+ (c-name "gimp_offset_area_set_offsets")
+ (return-type "none")
+ (parameters
+ '("gint" "offset_x")
+ '("gint" "offset_y")
+ )
+)
+
+
+
+;; From gimppageselector.h
+
+(define-function gimp_page_selector_get_type
+ (c-name "gimp_page_selector_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_page_selector_new
+ (c-name "gimp_page_selector_new")
+ (is-constructor-of "GimpPageSelector")
+ (return-type "GtkWidget*")
+)
+
+(define-method set_n_pages
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_set_n_pages")
+ (return-type "none")
+ (parameters
+ '("gint" "n_pages")
+ )
+)
+
+(define-method get_n_pages
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_n_pages")
+ (return-type "gint")
+)
+
+(define-method set_target
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_set_target")
+ (return-type "none")
+ (parameters
+ '("GimpPageSelectorTarget" "target")
+ )
+)
+
+(define-method get_target
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_target")
+ (return-type "GimpPageSelectorTarget")
+)
+
+(define-method set_page_thumbnail
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_set_page_thumbnail")
+ (return-type "none")
+ (parameters
+ '("gint" "page_no")
+ '("GdkPixbuf*" "thumbnail")
+ )
+)
+
+(define-method get_page_thumbnail
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_page_thumbnail")
+ (return-type "GdkPixbuf*")
+ (parameters
+ '("gint" "page_no")
+ )
+)
+
+(define-method set_page_label
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_set_page_label")
+ (return-type "none")
+ (parameters
+ '("gint" "page_no")
+ '("const-gchar*" "label")
+ )
+)
+
+(define-method get_page_label
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_page_label")
+ (return-type "gchar*")
+ (parameters
+ '("gint" "page_no")
+ )
+)
+
+(define-method select_all
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_select_all")
+ (return-type "none")
+)
+
+(define-method unselect_all
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_unselect_all")
+ (return-type "none")
+)
+
+(define-method select_page
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_select_page")
+ (return-type "none")
+ (parameters
+ '("gint" "page_no")
+ )
+)
+
+(define-method unselect_page
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_unselect_page")
+ (return-type "none")
+ (parameters
+ '("gint" "page_no")
+ )
+)
+
+(define-method page_is_selected
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_page_is_selected")
+ (return-type "gboolean")
+ (parameters
+ '("gint" "page_no")
+ )
+)
+
+(define-method get_selected_pages
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_selected_pages")
+ (return-type "gint*")
+ (parameters
+ '("gint*" "n_selected_pages")
+ )
+)
+
+(define-method select_range
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_select_range")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "range")
+ )
+)
+
+(define-method get_selected_range
+ (of-object "GimpPageSelector")
+ (c-name "gimp_page_selector_get_selected_range")
+ (return-type "gchar*")
+)
+
+
+
+;; From gimppatheditor.h
+
+(define-function gimp_path_editor_get_type
+ (c-name "gimp_path_editor_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_path_editor_new
+ (c-name "gimp_path_editor_new")
+ (is-constructor-of "GimpPathEditor")
+ (properties
+ '("title")
+ '("path" (optional))
+ )
+ (return-type "GtkWidget*")
+)
+
+(define-method get_path
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_get_path")
+ (return-type "gchar*")
+)
+
+(define-method set_path
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_set_path")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "path")
+ )
+)
+
+(define-method get_writable_path
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_get_writable_path")
+ (return-type "gchar*")
+)
+
+(define-method set_writable_path
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_set_writable_path")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "path")
+ )
+)
+
+(define-method get_dir_writable
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_get_dir_writable")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "directory")
+ )
+)
+
+(define-method set_dir_writable
+ (of-object "GimpPathEditor")
+ (c-name "gimp_path_editor_set_dir_writable")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "directory")
+ '("gboolean" "writable")
+ )
+)
+
+
+
+;; From gimppickbutton.h
+
+(define-function gimp_pick_button_get_type
+ (c-name "gimp_pick_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_pick_button_new
+ (c-name "gimp_pick_button_new")
+ (is-constructor-of "GimpPickButton")
+ (return-type "GtkWidget*")
+)
+
+
+
+;; From gimppreview.h
+
+(define-function gimp_preview_get_type
+ (c-name "gimp_preview_get_type")
+ (return-type "GType")
+)
+
+(define-method set_update
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_set_update")
+ (return-type "none")
+ (parameters
+ '("gboolean" "update")
+ )
+)
+
+(define-method get_update
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_get_update")
+ (return-type "gboolean")
+)
+
+(define-method set_bounds
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_set_bounds")
+ (return-type "none")
+ (parameters
+ '("gint" "xmin")
+ '("gint" "ymin")
+ '("gint" "xmax")
+ '("gint" "ymax")
+ )
+)
+
+(define-method get_position
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_get_position")
+ (return-type "none")
+ (parameters
+ '("gint*" "x")
+ '("gint*" "y")
+ )
+)
+
+(define-method get_size
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_get_size")
+ (return-type "none")
+ (parameters
+ '("gint*" "width")
+ '("gint*" "height")
+ )
+)
+
+(define-method transform
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_transform")
+ (return-type "none")
+ (parameters
+ '("gint" "src_x")
+ '("gint" "src_y")
+ '("gint*" "dest_x")
+ '("gint*" "dest_y")
+ )
+)
+
+(define-method untransform
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_untransform")
+ (return-type "none")
+ (parameters
+ '("gint" "src_x")
+ '("gint" "src_y")
+ '("gint*" "dest_x")
+ '("gint*" "dest_y")
+ )
+)
+
+(define-method get_area
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_get_area")
+ (return-type "GtkWidget*")
+)
+
+(define-method draw
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_draw")
+ (return-type "none")
+)
+
+(define-method draw_buffer
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_draw_buffer")
+ (return-type "none")
+ (parameters
+ '("const-guchar*" "buffer")
+ '("gint" "rowstride")
+ )
+)
+
+(define-method invalidate
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_invalidate")
+ (return-type "none")
+)
+
+(define-method set_default_cursor
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_set_default_cursor")
+ (return-type "none")
+ (parameters
+ '("GdkCursor*" "cursor")
+ )
+)
+
+(define-method get_controls
+ (of-object "GimpPreview")
+ (c-name "gimp_preview_get_controls")
+ (return-type "GtkWidget*")
+)
+
+
+
+;; From gimppreviewarea.h
+
+(define-function gimp_preview_area_get_type
+ (c-name "gimp_preview_area_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_preview_area_new
+ (c-name "gimp_preview_area_new")
+ (is-constructor-of "GimpPreviewArea")
+ (return-type "GtkWidget*")
+)
+
+(define-method draw
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_draw")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ '("gint" "width")
+ '("gint" "height")
+ '("GimpImageType" "type")
+ '("const-guchar*" "buf")
+ '("gint" "rowstride")
+ )
+)
+
+(define-method blend
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_blend")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ '("gint" "width")
+ '("gint" "height")
+ '("GimpImageType" "type")
+ '("const-guchar*" "buf1")
+ '("gint" "rowstride1")
+ '("const-guchar*" "buf2")
+ '("gint" "rowstride2")
+ '("guchar" "opacity")
+ )
+)
+
+(define-method mask
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_mask")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ '("gint" "width")
+ '("gint" "height")
+ '("GimpImageType" "type")
+ '("const-guchar*" "buf1")
+ '("gint" "rowstride1")
+ '("const-guchar*" "buf2")
+ '("gint" "rowstride2")
+ '("const-guchar*" "mask")
+ '("gint" "rowstride_mask")
+ )
+)
+
+(define-method fill
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_fill")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ '("gint" "width")
+ '("gint" "height")
+ '("guchar" "red")
+ '("guchar" "green")
+ '("guchar" "blue")
+ )
+)
+
+(define-method set_offsets
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_set_offsets")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ )
+)
+
+(define-method set_colormap
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_set_colormap")
+ (return-type "none")
+ (parameters
+ '("const-guchar*" "colormap")
+ '("gint" "num_colors")
+ )
+)
+
+(define-method set_max_size
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_set_max_size")
+ (return-type "none")
+ (parameters
+ '("gint" "width")
+ '("gint" "height")
+ )
+)
+
+(define-method menu_popup
+ (of-object "GimpPreviewArea")
+ (c-name "gimp_preview_area_menu_popup")
+ (return-type "none")
+ (parameters
+ '("GdkEventButton*" "event")
+ )
+)
+
+
+
+;; From gimpscrolledpreview.h
+
+(define-function gimp_scrolled_preview_get_type
+ (c-name "gimp_scrolled_preview_get_type")
+ (return-type "GType")
+)
+
+(define-method set_position
+ (of-object "GimpScrolledPreview")
+ (c-name "gimp_scrolled_preview_set_position")
+ (return-type "none")
+ (parameters
+ '("gint" "x")
+ '("gint" "y")
+ )
+)
+
+(define-method set_policy
+ (of-object "GimpScrolledPreview")
+ (c-name "gimp_scrolled_preview_set_policy")
+ (return-type "none")
+ (parameters
+ '("GtkPolicyType" "hscrollbar_policy")
+ '("GtkPolicyType" "vscrollbar_policy")
+ )
+)
+
+(define-method freeze
+ (of-object "GimpScrolledPreview")
+ (c-name "gimp_scrolled_preview_freeze")
+ (return-type "none")
+)
+
+(define-method thaw
+ (of-object "GimpScrolledPreview")
+ (c-name "gimp_scrolled_preview_thaw")
+ (return-type "none")
+)
+
+
+
+;; From gimpsizeentry.h
+
+(define-function gimp_size_entry_get_type
+ (c-name "gimp_size_entry_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_size_entry_new
+ (c-name "gimp_size_entry_new")
+ (is-constructor-of "GimpSizeEntry")
+ (return-type "GtkWidget*")
+ (parameters
+ '("gint" "number_of_fields")
+ '("GimpUnit" "unit")
+ '("const-gchar*" "unit_format")
+ '("gboolean" "menu_show_pixels")
+ '("gboolean" "menu_show_percent")
+ '("gboolean" "show_refval")
+ '("gint" "spinbutton_width")
+ '("GimpSizeEntryUpdatePolicy" "update_policy")
+ )
+)
+
+(define-method add_field
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_add_field")
+ (return-type "none")
+ (parameters
+ '("GtkSpinButton*" "value_spinbutton")
+ '("GtkSpinButton*" "refval_spinbutton")
+ )
+)
+
+(define-method attach_label
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_attach_label")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "text")
+ '("gint" "row")
+ '("gint" "column")
+ '("gfloat" "alignment")
+ )
+)
+
+(define-method set_resolution
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_resolution")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "resolution")
+ '("gboolean" "keep_size")
+ )
+)
+
+(define-method set_size
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_size")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "lower")
+ '("gdouble" "upper")
+ )
+)
+
+(define-method set_value_boundaries
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_value_boundaries")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "lower")
+ '("gdouble" "upper")
+ )
+)
+
+(define-method get_value
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_get_value")
+ (return-type "gdouble")
+ (parameters
+ '("gint" "field")
+ )
+)
+
+(define-method set_value
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_value")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "value")
+ )
+)
+
+(define-method set_refval_boundaries
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_refval_boundaries")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "lower")
+ '("gdouble" "upper")
+ )
+)
+
+(define-method set_refval_digits
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_refval_digits")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gint" "digits")
+ )
+)
+
+(define-method get_refval
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_get_refval")
+ (return-type "gdouble")
+ (parameters
+ '("gint" "field")
+ )
+)
+
+(define-method set_refval
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_refval")
+ (return-type "none")
+ (parameters
+ '("gint" "field")
+ '("gdouble" "refval")
+ )
+)
+
+(define-method get_unit
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_get_unit")
+ (return-type "GimpUnit")
+)
+
+(define-method set_unit
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_unit")
+ (return-type "none")
+ (parameters
+ '("GimpUnit" "unit")
+ )
+)
+
+(define-method show_unit_menu
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_show_unit_menu")
+ (return-type "none")
+ (parameters
+ '("gboolean" "show")
+ )
+)
+
+(define-method set_pixel_digits
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_pixel_digits")
+ (return-type "none")
+ (parameters
+ '("gint" "digits")
+ )
+)
+
+(define-method grab_focus
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_grab_focus")
+ (return-type "none")
+)
+
+(define-method set_activates_default
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_set_activates_default")
+ (return-type "none")
+ (parameters
+ '("gboolean" "setting")
+ )
+)
+
+(define-method get_help_widget
+ (of-object "GimpSizeEntry")
+ (c-name "gimp_size_entry_get_help_widget")
+ (return-type "GtkWidget*")
+ (parameters
+ '("gint" "field")
+ )
+)
+
+
+
+;; From gimpstringcombobox.h
+
+(define-function gimp_string_combo_box_get_type
+ (c-name "gimp_string_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_string_combo_box_new
+ (c-name "gimp_string_combo_box_new")
+ (is-constructor-of "GimpStringComboBox")
+ (return-type "GtkWidget*")
+ (properties
+ '("model")
+ '("id-column" (argname "id_column"))
+ '("label-column" (argname "label_column"))
+ )
+)
+
+(define-method set_active
+ (of-object "GimpStringComboBox")
+ (c-name "gimp_string_combo_box_set_active")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "id")
+ )
+)
+
+(define-method get_active
+ (of-object "GimpStringComboBox")
+ (c-name "gimp_string_combo_box_get_active")
+ (return-type "gchar*")
+)
+
+
+
+;; From gimpunitcombobox.h
+
+(define-function gimp_unit_combo_box_get_type
+ (c-name "gimp_unit_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_unit_combo_box_new
+ (c-name "gimp_unit_combo_box_new")
+ (is-constructor-of "GimpUnitComboBox")
+ (return-type "GtkWidget*")
+)
+
+(define-function gimp_unit_combo_box_new_with_model
+ (c-name "gimp_unit_combo_box_new_with_model")
+ (is-constructor-of "GimpUnitComboBox")
+ (return-type "GtkWidget*")
+ (properties
+ '("model" (optional))
+ )
+)
+
+(define-method get_active
+ (of-object "GimpUnitComboBox")
+ (c-name "gimp_unit_combo_box_get_active")
+ (return-type "GimpUnit")
+)
+
+(define-method set_active
+ (of-object "GimpUnitComboBox")
+ (c-name "gimp_unit_combo_box_set_active")
+ (return-type "none")
+ (parameters
+ '("GimpUnit" "unit")
+ )
+)
+
+
+
+;; From gimpunitmenu.h
+
+(define-function gimp_unit_menu_get_type
+ (c-name "gimp_unit_menu_get_type")
+ (return-type "GType")
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-function gimp_unit_menu_new
+ (c-name "gimp_unit_menu_new")
+ (is-constructor-of "GimpUnitMenu")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "format")
+ '("GimpUnit" "unit")
+ '("gboolean" "show_pixels")
+ '("gboolean" "show_percent")
+ '("gboolean" "show_custom")
+ )
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-method set_unit
+ (of-object "GimpUnitMenu")
+ (c-name "gimp_unit_menu_set_unit")
+ (return-type "none")
+ (parameters
+ '("GimpUnit" "unit")
+ )
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-method get_unit
+ (of-object "GimpUnitMenu")
+ (c-name "gimp_unit_menu_get_unit")
+ (return-type "GimpUnit")
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-method set_pixel_digits
+ (of-object "GimpUnitMenu")
+ (c-name "gimp_unit_menu_set_pixel_digits")
+ (return-type "none")
+ (parameters
+ '("gint" "digits")
+ )
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+(define-method get_pixel_digits
+ (of-object "GimpUnitMenu")
+ (c-name "gimp_unit_menu_get_pixel_digits")
+ (return-type "gint")
+ (deprecated "use gimpui.UnitComboBox instead")
+)
+
+
+
+;; From gimpzoommodel.h
+
+(define-function gimp_zoom_model_get_type
+ (c-name "gimp_zoom_model_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_zoom_model_new
+ (c-name "gimp_zoom_model_new")
+ (is-constructor-of "GimpZoomModel")
+ (return-type "GimpZoomModel*")
+)
+
+(define-method set_range
+ (of-object "GimpZoomModel")
+ (c-name "gimp_zoom_model_set_range")
+ (return-type "none")
+ (parameters
+ '("gdouble" "min")
+ '("gdouble" "max")
+ )
+)
+
+(define-method zoom
+ (of-object "GimpZoomModel")
+ (c-name "gimp_zoom_model_zoom")
+ (return-type "none")
+ (parameters
+ '("GimpZoomType" "zoom_type")
+ '("gdouble" "scale")
+ )
+)
+
+(define-method get_factor
+ (of-object "GimpZoomModel")
+ (c-name "gimp_zoom_model_get_factor")
+ (return-type "gdouble")
+)
+
+(define-method get_fraction
+ (of-object "GimpZoomModel")
+ (c-name "gimp_zoom_model_get_fraction")
+ (return-type "none")
+ (parameters
+ '("gint*" "numerator")
+ '("gint*" "denominator")
+ )
+)
+
+(define-function gimp_zoom_button_new
+ (c-name "gimp_zoom_button_new")
+ (is-constructor-of "GimpZoomButton")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpZoomModel*" "model")
+ '("GimpZoomType" "zoom_type")
+ '("GtkIconSize" "icon_size")
+ )
+)
+
+(define-function gimp_zoom_model_zoom_step
+ (c-name "gimp_zoom_model_zoom_step")
+ (return-type "gdouble")
+ (parameters
+ '("GimpZoomType" "zoom_type")
+ '("gdouble" "scale")
+ )
+)
+
+
+
+;; From gimpaspectpreview.h
+
+(define-function gimp_aspect_preview_get_type
+ (c-name "gimp_aspect_preview_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_aspect_preview_new
+ (c-name "gimp_aspect_preview_new")
+ (is-constructor-of "GimpAspectPreview")
+ (return-type "GtkWidget*")
+ (properties
+ '("drawable")
+ '("update" (optional))
+ )
+)
+
+
+
+;; From gimpdrawablepreview.h
+
+(define-function gimp_drawable_preview_get_type
+ (c-name "gimp_drawable_preview_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_drawable_preview_new
+ (c-name "gimp_drawable_preview_new")
+ (is-constructor-of "GimpDrawablePreview")
+ (return-type "GtkWidget*")
+ (properties
+ '("drawable")
+ )
+)
+
+(define-method get_drawable
+ (of-object "GimpDrawablePreview")
+ (c-name "gimp_drawable_preview_get_drawable")
+ (return-type "GimpDrawable*")
+)
+
+(define-method draw_region
+ (of-object "GimpDrawablePreview")
+ (c-name "gimp_drawable_preview_draw_region")
+ (return-type "none")
+ (parameters
+ '("const-GimpPixelRgn*" "region")
+ )
+)
+
+
+
+;; From gimpimagecombobox.h
+
+(define-function gimp_image_combo_box_get_type
+ (c-name "gimp_image_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_image_combo_box_new
+ (c-name "gimp_image_combo_box_new")
+ (is-constructor-of "GimpImageComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpImageConstraintFunc" "constraint")
+ '("gpointer" "data")
+ )
+)
+
+
+
+;; From gimpitemcombobox.h
+
+(define-function gimp_drawable_combo_box_get_type
+ (c-name "gimp_drawable_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_channel_combo_box_get_type
+ (c-name "gimp_channel_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_layer_combo_box_get_type
+ (c-name "gimp_layer_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_vectors_combo_box_get_type
+ (c-name "gimp_vectors_combo_box_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_drawable_combo_box_new
+ (c-name "gimp_drawable_combo_box_new")
+ (is-constructor-of "GimpDrawableComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpDrawableConstraintFunc" "constraint")
+ '("gpointer" "data")
+ )
+)
+
+(define-function gimp_channel_combo_box_new
+ (c-name "gimp_channel_combo_box_new")
+ (is-constructor-of "GimpChannelComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpDrawableConstraintFunc" "constraint")
+ '("gpointer" "data")
+ )
+)
+
+(define-function gimp_layer_combo_box_new
+ (c-name "gimp_layer_combo_box_new")
+ (is-constructor-of "GimpLayerComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpDrawableConstraintFunc" "constraint")
+ '("gpointer" "data")
+ )
+)
+
+(define-function gimp_vectors_combo_box_new
+ (c-name "gimp_vectors_combo_box_new")
+ (is-constructor-of "GimpVectorsComboBox")
+ (return-type "GtkWidget*")
+ (parameters
+ '("GimpVectorsConstraintFunc" "constraint")
+ '("gpointer" "data")
+ )
+)
+
+
+
+;; From gimppatternselect.h
+
+(define-function gimp_pattern_select_new
+ (c-name "gimp_pattern_select_new")
+ (is-constructor-of "GimpPatternSelect")
+ (return-type "const-gchar*")
+ (parameters
+ '("const-gchar*" "title")
+ '("const-gchar*" "pattern_name")
+ '("GimpRunPatternCallback" "callback")
+ '("gpointer" "data")
+ )
+)
+
+(define-function gimp_pattern_select_destroy
+ (c-name "gimp_pattern_select_destroy")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "pattern_callback")
+ )
+)
+
+
+
+;; From gimpprocbrowserdialog.h
+
+(define-function gimp_proc_browser_dialog_get_type
+ (c-name "gimp_proc_browser_dialog_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_proc_browser_dialog_new
+ (c-name "gimp_proc_browser_dialog_new")
+ (is-constructor-of "GimpProcBrowserDialog")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "title")
+ '("const-gchar*" "role")
+ '("GimpHelpFunc" "help_func")
+ '("const-gchar*" "help_id")
+ )
+ (varargs #t)
+)
+
+(define-method get_selected
+ (of-object "GimpProcBrowserDialog")
+ (c-name "gimp_proc_browser_dialog_get_selected")
+ (return-type "gchar*")
+)
+
+
+
+;; From gimpprocview.h
+
+(define-function gimp_proc_view_new
+ (c-name "gimp_proc_view_new")
+ (is-constructor-of "GimpProcView")
+ (return-type "GtkWidget*")
+ (parameters
+ '("const-gchar*" "name")
+ '("const-gchar*" "menu_path")
+ '("const-gchar*" "blurb")
+ '("const-gchar*" "help")
+ '("const-gchar*" "author")
+ '("const-gchar*" "copyright")
+ '("const-gchar*" "date")
+ '("GimpPDBProcType" "type")
+ '("gint" "n_params")
+ '("gint" "n_return_vals")
+ '("GimpParamDef*" "params")
+ '("GimpParamDef*" "return_vals")
+ )
+)
+
+
+
+;; From gimpzoompreview.h
+
+(define-function gimp_zoom_preview_get_type
+ (c-name "gimp_zoom_preview_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_zoom_preview_new_with_model
+ (c-name "gimp_zoom_preview_new_with_model")
+ (is-constructor-of "GimpZoomPreview")
+ (return-type "GtkWidget*")
+ (properties
+ '("drawable")
+ '("model" (optional))
+ )
+)
+
+(define-method get_source
+ (of-object "GimpZoomPreview")
+ (c-name "gimp_zoom_preview_get_source")
+ (return-type "guchar*")
+ (parameters
+ '("gint*" "width")
+ '("gint*" "height")
+ '("gint*" "bpp")
+ )
+)
+
+(define-method get_drawable
+ (of-object "GimpZoomPreview")
+ (c-name "gimp_zoom_preview_get_drawable")
+ (return-type "GimpDrawable*")
+)
+
+(define-method get_model
+ (of-object "GimpZoomPreview")
+ (c-name "gimp_zoom_preview_get_model")
+ (return-type "GimpZoomModel*")
+)
+
+(define-method get_factor
+ (of-object "GimpZoomPreview")
+ (c-name "gimp_zoom_preview_get_factor")
+ (return-type "gdouble")
+)
+
+
+
+;; From gimpprogressbar.h
+
+(define-function gimp_progress_bar_get_type
+ (c-name "gimp_progress_bar_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_progress_bar_new
+ (c-name "gimp_progress_bar_new")
+ (is-constructor-of "GimpProgressBar")
+ (return-type "GtkWidget*")
+)
+
+
+
+;; From gimpbrushselectbutton.h
+
+(define-function gimp_brush_select_button_get_type
+ (c-name "gimp_brush_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_brush_select_button_new
+ (c-name "gimp_brush_select_button_new")
+ (is-constructor-of "GimpBrushSelectButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("brush-name" (argname "brush_name") (optional))
+ '("brush-opacity" (argname "opacity") (optional))
+ '("brush-spacing" (argname "spacing") (optional))
+ '("brush-paint-mode" (argname "paint_mode") (optional))
+ )
+)
+
+(define-method get_brush
+ (of-object "GimpBrushSelectButton")
+ (c-name "gimp_brush_select_button_get_brush")
+ (return-type "const-gchar*")
+ (parameters
+ '("gdouble*" "opacity")
+ '("gint*" "spacing")
+ '("GimpLayerMode*" "paint_mode")
+ )
+)
+
+(define-method set_brush
+ (of-object "GimpBrushSelectButton")
+ (c-name "gimp_brush_select_button_set_brush")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "brush_name")
+ '("gdouble" "opacity")
+ '("gint" "spacing")
+ '("GimpLayerMode" "paint_mode")
+ )
+)
+
+
+
+;; From gimpfontselectbutton.h
+
+(define-function gimp_font_select_button_get_type
+ (c-name "gimp_font_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_font_select_button_new
+ (c-name "gimp_font_select_button_new")
+ (is-constructor-of "GimpFontSelectButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("font-name" (argname "font_name") (optional))
+ )
+)
+
+(define-method get_font
+ (of-object "GimpFontSelectButton")
+ (c-name "gimp_font_select_button_get_font")
+ (return-type "const-gchar*")
+)
+
+(define-method set_font
+ (of-object "GimpFontSelectButton")
+ (c-name "gimp_font_select_button_set_font")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "font_name")
+ )
+)
+
+
+
+;; From gimpgradientselectbutton.h
+
+(define-function gimp_gradient_select_button_get_type
+ (c-name "gimp_gradient_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_gradient_select_button_new
+ (c-name "gimp_gradient_select_button_new")
+ (is-constructor-of "GimpGradientSelectButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("gradient-name" (argname "gradient_name") (optional))
+ )
+)
+
+(define-method get_gradient
+ (of-object "GimpGradientSelectButton")
+ (c-name "gimp_gradient_select_button_get_gradient")
+ (return-type "const-gchar*")
+)
+
+(define-method set_gradient
+ (of-object "GimpGradientSelectButton")
+ (c-name "gimp_gradient_select_button_set_gradient")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "gradient_name")
+ )
+)
+
+
+
+;; From gimppaletteselectbutton.h
+
+(define-function gimp_palette_select_button_get_type
+ (c-name "gimp_palette_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_palette_select_button_new
+ (c-name "gimp_palette_select_button_new")
+ (is-constructor-of "GimpPaletteSelectButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("palette-name" (argname "palette_name") (optional))
+ )
+)
+
+(define-method get_palette
+ (of-object "GimpPaletteSelectButton")
+ (c-name "gimp_palette_select_button_get_palette")
+ (return-type "const-gchar*")
+)
+
+(define-method set_palette
+ (of-object "GimpPaletteSelectButton")
+ (c-name "gimp_palette_select_button_set_palette")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "palette_name")
+ )
+)
+
+
+
+;; From gimppatternselectbutton.h
+
+(define-function gimp_pattern_select_button_get_type
+ (c-name "gimp_pattern_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_pattern_select_button_new
+ (c-name "gimp_pattern_select_button_new")
+ (is-constructor-of "GimpPatternSelectButton")
+ (return-type "GtkWidget*")
+ (properties
+ '("title" (optional))
+ '("pattern-name" (argname "pattern_name") (optional))
+ )
+)
+
+(define-method get_pattern
+ (of-object "GimpPatternSelectButton")
+ (c-name "gimp_pattern_select_button_get_pattern")
+ (return-type "const-gchar*")
+)
+
+(define-method set_pattern
+ (of-object "GimpPatternSelectButton")
+ (c-name "gimp_pattern_select_button_set_pattern")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "pattern_name")
+ )
+)
+
+
+
+;; From gimpselectbutton.h
+
+(define-function gimp_select_button_get_type
+ (c-name "gimp_select_button_get_type")
+ (return-type "GType")
+)
+
+(define-method close_popup
+ (of-object "GimpSelectButton")
+ (c-name "gimp_select_button_close_popup")
+ (return-type "none")
+)
+
+
+
+;; From gimpwidgetsenums.h
+
+(define-function gimp_aspect_type_get_type
+ (c-name "gimp_aspect_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_chain_position_get_type
+ (c-name "gimp_chain_position_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_area_type_get_type
+ (c-name "gimp_color_area_type_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_color_selector_channel_get_type
+ (c-name "gimp_color_selector_channel_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_page_selector_target_get_type
+ (c-name "gimp_page_selector_target_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_size_entry_update_policy_get_type
+ (c-name "gimp_size_entry_update_policy_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_zoom_type_get_type
+ (c-name "gimp_zoom_type_get_type")
+ (return-type "GType")
+)
+
+
+
+;; From gimpruler.h
+
+(define-function gimp_ruler_get_type
+ (c-name "gimp_ruler_get_type")
+ (return-type "GType")
+)
+
+(define-function gimp_ruler_new
+ (c-name "gimp_ruler_new")
+ (is-constructor-of "GimpRuler")
+ (return-type "GtkWidget*")
+ (properties
+ '("orientation")
+ '("lower" (optional))
+ '("upper" (optional))
+ '("max-size" (argname "max_size") (optional))
+ )
+)
+
+(define-method set_unit
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_set_unit")
+ (return-type "none")
+ (parameters
+ '("GimpUnit" "unit")
+ )
+)
+
+(define-method get_unit
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_get_unit")
+ (return-type "GimpUnit")
+)
+
+(define-method set_position
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_set_position")
+ (return-type "none")
+ (parameters
+ '("gdouble" "position")
+ )
+)
+
+(define-method get_position
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_get_position")
+ (return-type "gdouble")
+)
+
+(define-method set_range
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_set_range")
+ (return-type "none")
+ (parameters
+ '("gdouble" "lower")
+ '("gdouble" "upper")
+ '("gdouble" "max_size")
+ )
+)
+
+(define-method get_range
+ (of-object "GimpRuler")
+ (c-name "gimp_ruler_get_range")
+ (return-type "none")
+ (parameters
+ '("gdouble*" "lower")
+ '("gdouble*" "upper")
+ '("gdouble*" "max_size")
+ )
+)
+
+
diff --git a/plug-ins/pygimp/gimpui.override b/plug-ins/pygimp/gimpui.override
new file mode 100644
index 0000000..5851989
--- /dev/null
+++ b/plug-ins/pygimp/gimpui.override
@@ -0,0 +1,2075 @@
+headers
+#include <Python.h>
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include <pycairo.h>
+extern Pycairo_CAPI_t *Pycairo_CAPI;
+
+#define GIMP_DISABLE_DEPRECATION_WARNINGS
+#include <libgimp/gimp.h>
+#undef GIMP_DISABLE_DEPRECATED
+#include <libgimp/gimpui.h>
+#define GIMP_DISABLE_DEPRECATED
+
+#define NO_IMPORT_PYGIMP
+#include "pygimp-api.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+typedef struct {
+ PyObject *constraint;
+ PyObject *user_data;
+} PyGimpConstraintData;
+
+typedef struct {
+ PyObject *sensitivity_func;
+ PyObject *user_data;
+} PyGimpIntSensitivityData;
+
+/* TODO: Add a header for these */
+void gimpui_register_classes(PyObject *d);
+void gimpui_add_constants(PyObject *module, const gchar *strip_prefix);
+
+static void
+pygimp_decref_callback(PyObject* obj) {
+ Py_XDECREF (obj);
+}
+
+%%
+modulename gimpui
+%%
+import gobject.GObject as PyGObject_Type
+import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
+import gtk.Object as PyGtkObject_Type
+import gtk.Widget as PyGtkWidget_Type
+import gtk.Dialog as PyGtkDialog_Type
+import gtk.Window as PyGtkWindow_Type
+import gtk.Label as PyGtkLabel_Type
+import gtk.Button as PyGtkButton_Type
+import gtk.ToggleButton as PyGtkToggleButton_Type
+import gtk.RadioButton as PyGtkRadioButton_Type
+import gtk.SpinButton as PyGtkSpinButton_Type
+import gtk.Entry as PyGtkEntry_Type
+import gtk.DrawingArea as PyGtkDrawingArea_Type
+import gtk.Table as PyGtkTable_Type
+import gtk.Frame as PyGtkFrame_Type
+import gtk.HBox as PyGtkHBox_Type
+import gtk.VBox as PyGtkVBox_Type
+import gtk.HPaned as PyGtkHPaned_Type
+import gtk.VPaned as PyGtkVPaned_Type
+import gtk.Scale as PyGtkScale_Type
+import gtk.ProgressBar as PyGtkProgressBar_Type
+import gtk.OptionMenu as PyGtkOptionMenu_Type
+import gtk.ComboBox as PyGtkComboBox_Type
+import gtk.ListStore as PyGtkListStore_Type
+import gtk.TreeModel as PyGtkTreeModel_Type
+import gtk.CellRenderer as PyGtkCellRenderer_Type
+import gtk.CellRendererToggle as PyGtkCellRendererToggle_Type
+import gimp.Parasite as PyGimpParasite_Type
+%%
+ignore
+ gimp_dialog_add_buttons
+ gimp_int_combo_box_connect
+ gimp_color_profile_combo_box_new
+ gimp_enum_store_new_with_values
+ gimp_int_combo_box_new_array
+%%
+ignore-glob
+ *_get_type
+ *_valist
+ gimp_resolution_*
+%%
+ignore-type
+ GimpIntStoreColumns
+%%
+override gimp_drawable_combo_box_new kwargs
+static gboolean
+pygimp_drawable_constraint_marshal(gint32 image_id, gint32 drawable_id,
+ gpointer user_data)
+{
+ PyObject *img, *drw, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ drw = pygimp_drawable_new(NULL, drawable_id);
+ if (!drw) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, drw,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, drw, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(drw);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_drawable_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.DrawableComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_XINCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_drawable_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_drawable_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_DRAWABLE_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.DrawableComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+define GimpDrawableComboBox.set_active_drawable kwargs
+static PyObject *
+_wrap_gimp_drawable_combo_box_set_active_drawable(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpDrawable *drw;
+
+ static char *kwlist[] = { "drawable", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpDrawableComboBox.set_active_drawable",
+ kwlist,
+ PyGimpDrawable_Type, &drw))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), drw->ID)) {
+ PyErr_Format(pygimp_error,
+ "Drawable (ID %d) does not exist in GimpDrawableComboBox",
+ drw->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define GimpDrawableComboBox.get_active_drawable noargs
+static PyObject *
+_wrap_gimp_drawable_combo_box_get_active_drawable(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_drawable_new(NULL, value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_channel_combo_box_new kwargs
+static gboolean
+pygimp_channel_constraint_marshal(gint32 image_id, gint32 channel_id,
+ gpointer user_data)
+{
+ PyObject *img, *chn, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ chn = pygimp_channel_new(channel_id);
+ if (!chn) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, chn,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, chn, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(chn);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_channel_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.ChannelComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_channel_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_channel_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_CHANNEL_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.ChannelComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+define GimpChannelComboBox.set_active_channel kwargs
+static PyObject *
+_wrap_gimp_channel_combo_box_set_active_channel(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpChannel *chn;
+
+ static char *kwlist[] = { "channel", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpChannelComboBox.set_active_channel",
+ kwlist,
+ PyGimpChannel_Type, &chn))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "Channel (ID %d) does not exist in GimpChannelComboBox",
+ chn->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define GimpChannelComboBox.get_active_channel noargs
+static PyObject *
+_wrap_gimp_channel_combo_box_get_active_channel(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_channel_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_layer_combo_box_new kwargs
+static gboolean
+pygimp_layer_constraint_marshal(gint32 image_id, gint32 layer_id,
+ gpointer user_data)
+{
+ PyObject *img, *lay, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ lay = pygimp_layer_new(layer_id);
+ if (!lay) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, lay,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, lay, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(lay);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_layer_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpDrawableConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.LayerComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_layer_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_layer_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_LAYER_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.LayerComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+define GimpLayerComboBox.set_active_layer kwargs
+static PyObject *
+_wrap_gimp_layer_combo_box_set_active_layer(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpLayer *lay;
+
+ static char *kwlist[] = { "layer", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpLayerComboBox.set_active_layer",
+ kwlist,
+ PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "Layer (ID %d) does not exist in GimpLayerComboBox",
+ lay->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define GimpLayerComboBox.get_active_layer noargs
+static PyObject *
+_wrap_gimp_layer_combo_box_get_active_layer(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_layer_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_vectors_combo_box_new kwargs
+static gboolean
+pygimp_vectors_constraint_marshal(gint32 image_id, gint32 vectors_id,
+ gpointer user_data)
+{
+ PyObject *img, *vect, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ vect = pygimp_vectors_new(vectors_id);
+ if (!vect) {
+ PyErr_Print();
+ Py_DECREF(img);
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, vect, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(vect);
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_vectors_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpVectorsConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.VectorsComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_vectors_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_vectors_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_VECTORS_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.VectorsComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+define GimpVectorsComboBox.set_active_vectors kwargs
+static PyObject *
+_wrap_gimp_vectors_combo_box_set_active_vectors(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpVectors *vect;
+
+ static char *kwlist[] = { "vectors", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpVectorsComboBox.set_active_vectors",
+ kwlist,
+ PyGimpVectors_Type, &vect))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), vect->ID)) {
+ PyErr_Format(pygimp_error,
+ "Vectors (ID %d) does not exist in GimpVectorsComboBox",
+ vect->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define GimpVectorsComboBox.get_active_vectors noargs
+static PyObject *
+_wrap_gimp_vectors_combo_box_get_active_vectors(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_vectors_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_image_combo_box_new kwargs
+static gboolean
+pygimp_image_constraint_marshal(gint32 image_id, gpointer user_data)
+{
+ PyObject *img, *ret;
+ gboolean res;
+ PyGimpConstraintData *data = user_data;
+
+ img = pygimp_image_new(image_id);
+ if (!img) {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ if (data->user_data && data->user_data != Py_None)
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img,
+ data->user_data, NULL);
+ else
+ ret = PyObject_CallFunctionObjArgs(data->constraint, img, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(img);
+
+ return res;
+}
+
+static int
+_wrap_gimp_image_combo_box_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *constraint = NULL, *user_data = NULL;
+ GimpImageConstraintFunc func = NULL;
+ PyGimpConstraintData *data = NULL;
+
+ static char *kwlist[] = { "constraint", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|OO:gimpui.ImageComboBox.__init__",
+ kwlist,
+ &constraint, &user_data))
+ return -1;
+
+ if (constraint && constraint != Py_None) {
+ if (!PyCallable_Check(constraint)) {
+ PyErr_SetString(PyExc_TypeError, "first arg must be callable");
+ return -1;
+ }
+
+ data = g_new(PyGimpConstraintData, 1);
+
+ data->constraint = constraint;
+ Py_INCREF(constraint);
+
+ data->user_data = user_data;
+ Py_XINCREF(user_data);
+
+ func = pygimp_image_constraint_marshal;
+ }
+
+ self->obj = (GObject *)gimp_image_combo_box_new(func, data);
+
+ Py_XDECREF(constraint);
+ Py_XDECREF(user_data);
+ g_free(data);
+
+ if (pyg_type_from_object((PyObject *)self) != GIMP_TYPE_IMAGE_COMBO_BOX) {
+ PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
+ "when subclassing gimpui.ImageComboBox");
+ return -1;
+ }
+
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+define GimpImageComboBox.set_active_image kwargs
+static PyObject *
+_wrap_gimp_image_combo_box_set_active_image(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyGimpImage *img;
+
+ static char *kwlist[] = { "image", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpImageComboBox.set_active_image",
+ kwlist,
+ PyGimpImage_Type, &img))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), img->ID)) {
+ PyErr_Format(pygimp_error,
+ "Image (ID %d) does not exist in GimpImageComboBox",
+ img->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+define GimpImageComboBox.get_active_image noargs
+static PyObject *
+_wrap_gimp_image_combo_box_get_active_image(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return pygimp_image_new(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_dialog_new kwargs
+static void
+pygimp_help_func_marshal(const gchar *help_id, gpointer help_data)
+{
+ GObject *dialog = help_data;
+ PyObject *py_dialog, *help_func, *ret;
+
+ py_dialog = g_object_get_data(dialog, "pygimp-dialog-pyobject");
+ help_func = g_object_get_data(dialog, "pygimp-dialog-help_func");
+
+ ret = PyObject_CallFunction(help_func, "sO", help_id, py_dialog);
+
+ if (ret)
+ Py_DECREF(ret);
+ else
+ PyErr_Print();
+}
+
+static void
+pygimp_help_func_destroy(gpointer data)
+{
+ PyObject *help_func = data;
+
+ Py_DECREF(help_func);
+}
+
+static void
+pygimp_dialog_close(GtkWidget *widget)
+{
+ /* Synthesize delete_event to close dialog. */
+
+ if (gtk_widget_get_window (widget)) {
+ GdkEvent *event = gdk_event_new(GDK_DELETE);
+
+ event->any.window = g_object_ref (gtk_widget_get_window (widget));
+ event->any.send_event = TRUE;
+
+ gtk_main_do_event(event);
+ gdk_event_free(event);
+ }
+}
+
+static int
+_wrap_gimp_dialog_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *title, *role;
+ PyGObject *py_window = NULL;
+ PyObject *py_flags = NULL, *py_buttons = Py_None;
+ PyObject *help_func = NULL;
+ gchar *help_id = NULL;
+ GtkDialogFlags flags = 0;
+ int len, i;
+ GtkWidget *parent;
+ GimpHelpFunc func;
+
+ static char *kwlist[] = { "title", "role", "parent", "flags",
+ "help_func", "help_id", "buttons", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "zz|OOOzO:gimpui.GimpDialog.__init__",
+ kwlist,
+ &title, &role, &py_window, &py_flags,
+ &help_func, &help_id, &py_buttons))
+ return -1;
+
+ if (py_window == NULL || (PyObject*)py_window == Py_None)
+ parent = NULL;
+ else if (pygobject_check(py_window, &PyGtkWindow_Type))
+ parent = GTK_WIDGET(py_window->obj);
+ else {
+ PyErr_SetString(PyExc_TypeError, "parent must be a GtkWindow or None");
+ return -1;
+ }
+
+ if (pyg_flags_get_value(GTK_TYPE_DIALOG_FLAGS, py_flags, (gint *)&flags))
+ return -1;
+
+ if (py_buttons == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_buttons))
+ len = PyTuple_Size(py_buttons);
+ else {
+ PyErr_SetString(PyExc_TypeError, "buttons must be a tuple containing text/response pairs or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "buttons tuple must contain text/response id pairs");
+ return -1;
+ }
+
+ if (help_func) {
+ if (help_func != Py_None) {
+ if (!PyCallable_Check(help_func)) {
+ PyErr_SetString(PyExc_TypeError, "help_func must be callable");
+ return -1;
+ }
+
+ func = pygimp_help_func_marshal;
+
+ } else {
+ func = gimp_standard_help_func;
+ }
+ } else {
+ func = gimp_standard_help_func;
+ }
+
+ pygobject_construct(self,
+ "title", title,
+ "role", role,
+ "modal", (flags & GTK_DIALOG_MODAL),
+ "help-func", func,
+ "help-id", help_id,
+ NULL);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpDialog object");
+ return -1;
+ }
+
+ if (parent) {
+ if (GTK_IS_WINDOW(parent))
+ gtk_window_set_transient_for(GTK_WINDOW(self->obj),
+ GTK_WINDOW(parent));
+ else
+ gtk_window_set_screen(GTK_WINDOW(self->obj),
+ gtk_widget_get_screen(parent));
+
+ if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
+ g_signal_connect_object(parent, "destroy",
+ G_CALLBACK(pygimp_dialog_close),
+ self->obj, G_CONNECT_SWAPPED);
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *text = PyTuple_GetItem(py_buttons, i);
+ PyObject *id = PyTuple_GetItem(py_buttons, i + 1);
+ if (!PyString_Check(text) && !PyUnicode_Check(text)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each text/response id pair "
+ "must be a string");
+ return -1;
+ }
+ if (!PyInt_Check(id)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each text/response id pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_dialog_add_button(GIMP_DIALOG(self->obj), PyString_AsString(text),
+ PyInt_AsLong(id));
+ }
+
+ if (help_func && help_func != Py_None) {
+ g_object_set_data(self->obj, "pygimp-dialog-help-data", self);
+
+ Py_INCREF(help_func);
+ g_object_set_data_full(self->obj, "pygimp-dialog-help-func",
+ help_func, pygimp_help_func_destroy);
+ }
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_DIALOG
+%%
+override gimp_color_button_get_color noargs
+static PyObject *
+_wrap_gimp_color_button_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_button_get_color(GIMP_COLOR_BUTTON(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_brush_select_button_get_brush noargs
+static PyObject *
+_wrap_gimp_brush_select_button_get_brush(PyGObject *self)
+{
+ const gchar *brush_name;
+ gdouble opacity;
+ gint spacing;
+ GimpLayerMode paint_mode;
+
+ brush_name =
+ gimp_brush_select_button_get_brush(GIMP_BRUSH_SELECT_BUTTON(self->obj),
+ &opacity, &spacing, &paint_mode);
+
+ return Py_BuildValue("(sdiN)", brush_name, opacity, spacing,
+ pyg_enum_from_gtype(GIMP_TYPE_LAYER_MODE,
+ paint_mode));
+}
+%%
+override gimp_window_set_transient
+static PyObject *
+_wrap_gimp_window_set_transient(PyGObject *self)
+{
+ gimp_window_set_transient(GTK_WINDOW(self->obj));
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_color_button_new kwargs
+static int
+_wrap_gimp_color_button_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gchar *title = NULL;
+ gint width = -1, height = -1;
+ PyObject *py_color = NULL, *py_type = NULL;
+ GimpRGB *color, default_color = { 0.0, 0.0, 0.0, 100.0 };
+ GimpColorAreaType type;
+
+ static char *kwlist[] = { "title", "width", "height", "color", "type",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|ziiOO:gimpui.ColorButton.__init__",
+ kwlist,
+ &title, &width, &height,
+ &py_color, &py_type))
+ return -1;
+
+ if (py_color == NULL || (PyObject*)py_color == Py_None)
+ color = &default_color;
+ else if (pyg_boxed_check(py_color, GIMP_TYPE_RGB))
+ color = pyg_boxed_get(py_color, GimpRGB);
+ else {
+ PyErr_SetString(PyExc_TypeError, "color should be a GimpRGB or None");
+ return -1;
+ }
+
+ if (py_type == NULL || (PyObject*)py_type == Py_None)
+ type = GIMP_COLOR_AREA_FLAT;
+ else if (pyg_enum_get_value(GIMP_TYPE_COLOR_AREA_TYPE, py_type,
+ (gint*)&type))
+ return -1;
+
+ if (pygobject_construct(self,
+ "title", title,
+ "type", type,
+ "color", color,
+ "area-width", width,
+ "area-height", height,
+ NULL))
+ return -1;
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_COLOR_BUTTON
+%%
+override gimp_color_scale_new kwargs
+static int
+_wrap_gimp_color_scale_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_orientation, *py_channel;
+ GtkOrientation orientation;
+ GimpColorSelectorChannel channel;
+
+ static char *kwlist[] = { "orientation", "channel", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OO:gimpui.ColorScale.__init__",
+ kwlist,
+ &py_orientation, &py_channel))
+ return -1;
+
+ if (pyg_enum_get_value(GTK_TYPE_ORIENTATION, py_orientation,
+ (gint*)&orientation))
+ return -1;
+
+ if (pyg_enum_get_value(GIMP_TYPE_COLOR_SELECTOR_CHANNEL, py_channel,
+ (gint*)&channel))
+ return -1;
+
+ if (pygobject_construct(self,
+ "orientation", orientation,
+ "channel", channel,
+ NULL))
+ return -1;
+
+ gtk_range_set_flippable (GTK_RANGE (self->obj),
+ orientation == GTK_ORIENTATION_HORIZONTAL);
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_COLOR_SCALE
+%%
+override gimp_enum_label_new kwargs
+static int
+_wrap_gimp_enum_label_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_enum_type = NULL;
+ GType enum_type;
+ gint value;
+
+ static char *kwlist[] = { "enum_type", "value", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "Oi:gimpui.GimpEnumLabel.__init__",
+ kwlist,
+ &py_enum_type, &value))
+ return -1;
+
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return -1;
+
+ if (pygobject_construct(self,
+ "enum-type", enum_type,
+ "enum-value", value,
+ NULL))
+ return -1;
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_ENUM_LABEL
+%%
+override gimp_int_combo_box_new kwargs
+static int
+_wrap_gimp_int_combo_box_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_items = NULL;
+ int len, i;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|O:gimpui.IntComboBox.__init__",
+ kwlist,
+ &py_items))
+ return -1;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return -1;
+ }
+
+ if (pygobject_construct(self, NULL))
+ return -1;
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_int_combo_box_append(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_INT_COMBO_BOX
+%%
+override gimp_int_combo_box_set_sensitivity kwargs
+static gboolean
+pygimp_int_combo_box_sensitivity_marshal(gint value, gpointer user_data)
+{
+ PyObject *py_value;
+ PyGimpIntSensitivityData *data;
+ PyObject *ret;
+ gboolean res;
+
+ data = user_data;
+
+ py_value = PyInt_FromLong(value);
+
+ ret = PyObject_CallFunctionObjArgs(data->sensitivity_func, py_value,
+ data->user_data, NULL);
+
+ if (!ret) {
+ PyErr_Print();
+ res = FALSE;
+ } else {
+ res = PyObject_IsTrue(ret);
+ Py_DECREF(ret);
+ }
+
+ Py_DECREF(py_value);
+
+ return res;
+}
+
+static void
+pygimp_int_combo_box_sensitivity_data_destroy(gpointer user_data)
+{
+ PyGimpIntSensitivityData *data;
+ data = user_data;
+
+ Py_DECREF(data->sensitivity_func);
+ Py_XDECREF(data->user_data);
+
+ g_free(data);
+}
+
+static PyObject *
+_wrap_gimp_int_combo_box_set_sensitivity(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_sensitivity_func;
+ PyObject *py_user_data = NULL;
+ PyGimpIntSensitivityData *data;
+
+ static char *kwlist[] = { "sensitivity_func", "user_data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|O:GimpIntComboBox.set_sensitivity",
+ kwlist, &py_sensitivity_func,
+ &py_user_data))
+ return NULL;
+
+ if (!PyCallable_Check(py_sensitivity_func)) {
+ PyErr_SetString(PyExc_TypeError, "first argument must be callable.");
+ return NULL;
+ }
+
+ data = g_new(PyGimpIntSensitivityData, 1);
+
+ data->sensitivity_func = py_sensitivity_func;
+ Py_INCREF(data->sensitivity_func);
+
+ if (py_user_data == NULL || py_user_data == Py_None)
+ data->user_data = NULL;
+ else {
+ data->user_data = py_user_data;
+ Py_INCREF(data->user_data);
+ }
+
+ gimp_int_combo_box_set_sensitivity(GIMP_INT_COMBO_BOX(self->obj),
+ pygimp_int_combo_box_sensitivity_marshal,
+ data,
+ pygimp_int_combo_box_sensitivity_data_destroy);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_int_combo_box_get_active noargs
+static PyObject *
+_wrap_gimp_int_combo_box_get_active(PyGObject *self)
+{
+ int value;
+
+ if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(self->obj), &value))
+ return PyLong_FromLong(value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_int_combo_box_set_active kwargs
+static PyObject *
+_wrap_gimp_int_combo_box_set_active(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ int value;
+
+ static char *kwlist[] = { "value", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "i:GimpIntComboBox.set_active", kwlist,
+ &value))
+ return NULL;
+
+ if (!gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(self->obj), value)) {
+ PyErr_Format(pygimp_error,
+ "Value %d does not exist in GimpIntComboBox",
+ value);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_int_combo_box_append kwargs
+static PyObject *
+_wrap_gimp_int_combo_box_append(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_items;
+ int i, len;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:gimpui.IntComboBox.append",
+ kwlist,
+ &py_items))
+ return NULL;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return NULL;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return NULL;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return NULL;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return NULL;
+ }
+
+ gimp_int_combo_box_append(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_int_combo_box_prepend kwargs
+static PyObject *
+_wrap_gimp_int_combo_box_prepend(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_items;
+ int i, len;
+
+ static char *kwlist[] = { "items", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:gimpui.IntComboBox.prepend",
+ kwlist,
+ &py_items))
+ return NULL;
+
+ if (py_items == NULL || py_items == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_items))
+ len = PyTuple_Size(py_items);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "items must be a tuple containing label/value pairs "
+ "or None");
+ return NULL;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "items tuple must contain label/value pairs");
+ return NULL;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *label = PyTuple_GetItem(py_items, i);
+ PyObject *value = PyTuple_GetItem(py_items, i + 1);
+
+ if (!PyString_Check(label)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each label/value pair "
+ "must be a string");
+ return NULL;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each label/value pair "
+ "must be a number");
+ return NULL;
+ }
+
+ gimp_int_combo_box_prepend(GIMP_INT_COMBO_BOX(self->obj),
+ GIMP_INT_STORE_LABEL,
+ PyString_AsString(label),
+ GIMP_INT_STORE_VALUE,
+ PyInt_AsLong(value),
+ -1);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_browser_add_search_types args
+static PyObject *
+_wrap_gimp_browser_add_search_types(PyGObject *self, PyObject *args)
+{
+ GimpBrowser *browser;
+ int len, i;
+ PyObject *element;
+ gchar *label;
+ gint id;
+
+ browser = GIMP_BROWSER(self->obj);
+
+ len = PyTuple_Size(args);
+
+ for (i = 0; i < len; ++i) {
+ element = PyTuple_GetItem(args, i);
+ if (!PyTuple_Check(element)) {
+ PyErr_SetString(PyExc_TypeError, "GimpBrowser.add_search_types: Arguments must be tuples");
+ return NULL;
+ }
+ if (!PyArg_ParseTuple(element, "si", &label, &id))
+ return NULL;
+ gimp_browser_add_search_types(browser, label, id, NULL);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_proc_browser_dialog_new kwargs
+static int
+_wrap_gimp_proc_browser_dialog_new(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ gchar *title, *role;
+ PyObject *py_buttons = Py_None;
+ PyObject *help_func = NULL;
+ gchar *help_id = NULL;
+ int len, i;
+ GimpHelpFunc func;
+
+ static char *kwlist[] = { "title", "role", "help_func", "help_id",
+ "buttons", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "zz|OzO:gimpui.GimpProcBrowserDialog.__init__",
+ kwlist,
+ &title, &role, &help_func, &help_id,
+ &py_buttons))
+ return -1;
+
+ if (py_buttons == Py_None)
+ len = 0;
+ else if (PyTuple_Check(py_buttons))
+ len = PyTuple_Size(py_buttons);
+ else {
+ PyErr_SetString(PyExc_TypeError,
+ "buttons must be a tuple containing text/response "
+ "pairs or None");
+ return -1;
+ }
+
+ if (len % 2) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "buttons tuple must contain text/response id pairs");
+ return -1;
+ }
+
+ if (help_func) {
+ if (help_func != Py_None) {
+ if (!PyCallable_Check(help_func)) {
+ PyErr_SetString(PyExc_TypeError, "help_func must be callable");
+ return -1;
+ }
+
+ func = pygimp_help_func_marshal;
+
+ } else {
+ func = gimp_standard_help_func;
+ }
+ } else {
+ func = gimp_standard_help_func;
+ }
+
+ pygobject_construct(self,
+ "title", title,
+ "role", role,
+ "help-func", func,
+ "help-id", help_id,
+ NULL);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpProcBrowserDialog object");
+ return -1;
+ }
+
+ for (i = 0; i < len; i += 2) {
+ PyObject *text = PyTuple_GetItem(py_buttons, i);
+ PyObject *id = PyTuple_GetItem(py_buttons, i + 1);
+ if (!PyString_Check(text) && !PyUnicode_Check(text)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "first member of each text/response id pair "
+ "must be a string");
+ return -1;
+ }
+ if (!PyInt_Check(id)) {
+ gtk_object_destroy(GTK_OBJECT(self->obj));
+ self->obj = NULL;
+ PyErr_SetString(PyExc_RuntimeError,
+ "second member of each text/response id pair "
+ "must be a number");
+ return -1;
+ }
+
+ gimp_dialog_add_button(GIMP_DIALOG(self->obj), PyString_AsString(text),
+ PyInt_AsLong(id));
+ }
+
+ if (help_func && help_func != Py_None) {
+ g_object_set_data(self->obj, "pygimp-dialog-help-data", self);
+
+ Py_INCREF(help_func);
+ g_object_set_data_full(self->obj, "pygimp-dialog-help-func",
+ help_func, pygimp_help_func_destroy);
+ }
+
+ g_signal_emit_by_name(GIMP_PROC_BROWSER_DIALOG(self->obj)->browser,
+ "search", "", 0, self->obj);
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_PROC_BROWSER_DIALOG
+%%
+override gimp_number_pair_entry_get_values noargs
+static PyObject *
+_wrap_gimp_number_pair_entry_get_values(PyGObject *self)
+{
+ gdouble left, right;
+
+ gimp_number_pair_entry_get_values(GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ &left, &right);
+
+ return Py_BuildValue("(dd)", left, right);
+}
+%%
+override gimp_number_pair_entry_get_default_values noargs
+static PyObject *
+_wrap_gimp_number_pair_entry_get_default_values(PyGObject *self)
+{
+ gdouble left, right;
+
+ gimp_number_pair_entry_get_default_values(
+ GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ &left, &right);
+
+ return Py_BuildValue("(dd)", left, right);
+}
+%%
+override gimp_number_pair_entry_get_aspect noargs
+static PyObject *
+_wrap_gimp_number_pair_entry_get_aspect(PyGObject *self)
+{
+ GimpAspectType aspect;
+
+ aspect =
+ gimp_number_pair_entry_get_aspect(GIMP_NUMBER_PAIR_ENTRY(self->obj));
+
+ return pyg_enum_from_gtype(GIMP_TYPE_ASPECT_TYPE, aspect);
+}
+%%
+override gimp_number_pair_entry_set_aspect kwargs
+static PyObject *
+_wrap_gimp_number_pair_entry_set_aspect(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PyObject *py_aspect;
+ GimpAspectType aspect;
+
+ static char *kwlist[] = {"aspect", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:GimpNumberPairEntry.set_aspect",
+ kwlist, &py_aspect))
+ return NULL;
+
+ if (pyg_enum_get_value(GIMP_TYPE_ASPECT_TYPE, py_aspect, (gint*)&aspect))
+ {
+ Py_XDECREF(py_aspect);
+ return NULL;
+ }
+
+ gimp_number_pair_entry_set_aspect(GIMP_NUMBER_PAIR_ENTRY(self->obj),
+ aspect);
+
+ Py_DECREF(py_aspect);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_page_selector_get_selected_pages noargs
+static PyObject *
+_wrap_gimp_page_selector_get_selected_pages(PyGObject *self)
+{
+ gint *selected_pages;
+ gint n_selected_pages;
+ PyObject *py_selected_pages;
+ int i;
+
+ selected_pages = gimp_page_selector_get_selected_pages(
+ GIMP_PAGE_SELECTOR (self->obj),
+ &n_selected_pages);
+
+ py_selected_pages = PyTuple_New(n_selected_pages);
+ for (i = 0; i < n_selected_pages; ++i)
+ PyTuple_SetItem(py_selected_pages, i,
+ PyInt_FromLong(selected_pages[i]));
+
+ g_free(selected_pages);
+
+ return py_selected_pages;
+}
+%%
+override gimp_preview_get_position noargs
+static PyObject *
+_wrap_gimp_preview_get_position(PyGObject *self)
+{
+ gint x;
+ gint y;
+
+ gimp_preview_get_position(GIMP_PREVIEW(self->obj), &x, &y);
+
+ return Py_BuildValue("(ii)", x, y);
+}
+%%
+override gimp_preview_get_size noargs
+static PyObject *
+_wrap_gimp_preview_get_size(PyGObject *self)
+{
+ gint width;
+ gint height;
+
+ gimp_preview_get_size(GIMP_PREVIEW(self->obj), &width, &height);
+
+ return Py_BuildValue("(ii)", width, height);
+}
+%%
+override gimp_preview_transform kwargs
+static PyObject *
+_wrap_gimp_preview_transform(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ gint src_x;
+ gint src_y;
+ gint dest_x;
+ gint dest_y;
+
+ static char *kwlist[] = {"x", "y", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GimpPreview.transform",
+ kwlist, &src_x, &src_y))
+ return NULL;
+
+ gimp_preview_transform(GIMP_PREVIEW(self->obj), src_x, src_y, &dest_x,
+ &dest_y);
+
+ return Py_BuildValue("(ii)", dest_x, dest_y);
+}
+%%
+override gimp_preview_untransform kwargs
+static PyObject *
+_wrap_gimp_preview_untransform(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ gint src_x;
+ gint src_y;
+ gint dest_x;
+ gint dest_y;
+
+ static char *kwlist[] = {"x", "y", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ii:GimpPreview.untransform",
+ kwlist, &src_x, &src_y))
+ return NULL;
+
+ gimp_preview_untransform(GIMP_PREVIEW(self->obj), src_x, src_y, &dest_x,
+ &dest_y);
+
+ return Py_BuildValue("(ii)", dest_x, dest_y);
+}
+%%
+override gimp_zoom_model_get_fraction noargs
+static PyObject *
+_wrap_gimp_zoom_model_get_fraction(PyGObject *self)
+{
+ gint numerator;
+ gint denominator;
+
+ gimp_zoom_model_get_fraction(GIMP_ZOOM_MODEL(self->obj), &numerator,
+ &denominator);
+
+ return Py_BuildValue("(ii)", numerator, denominator);
+}
+%%
+override gimp_drawable_preview_get_drawable noargs
+static PyObject *
+_wrap_gimp_drawable_preview_get_drawable(PyGObject *self)
+{
+ PyObject *drawable;
+
+ drawable = g_object_get_data(self->obj,
+ "pygimp-drawable-preview-pydrawable");
+ Py_INCREF(drawable);
+ return drawable;
+}
+%%
+override gimp_zoom_preview_get_drawable noargs
+static PyObject *
+_wrap_gimp_zoom_preview_get_drawable(PyGObject *self)
+{
+ PyObject *drawable;
+
+ drawable = g_object_get_data(self->obj,
+ "pygimp-zoom-preview-pydrawable");
+ Py_INCREF(drawable);
+ return drawable;
+}
+%%
+override gimp_drawable_preview_draw_region kwargs
+static PyObject *
+_wrap_gimp_drawable_preview_draw_region(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+/* PyGimpPixelRgn *pypixelrgn;
+
+ static char *kwlist[] = {"drawable", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpDrawablePreview.draw_region",
+ kwlist, PyGimpPixelRgn_Type, &pypixelrgn))
+ return NULL;
+
+ gimp_drawable_preview_draw_region(GIMP_DRAWABLE_PREVIEW(self->obj),
+ &pypixelrgn->pr);
+*/
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_int_store_lookup_by_value
+static PyObject *
+_wrap_gimp_int_store_lookup_by_value(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", NULL };
+ int value, ret;
+ GtkTreeIter iter;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "i:GimpIntStore.gimp_int_store_lookup_by_value",
+ kwlist, &value))
+ return NULL;
+
+ ret = gimp_int_store_lookup_by_value(GTK_TREE_MODEL(self->obj), value,
+ &iter);
+ if (ret)
+ pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_memsize_entry_new
+static int
+_wrap_gimp_memsize_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", "lower", "upper", NULL };
+ guint64 value, lower, upper;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "LLL:GimpMemsizeEntry.__init__",
+ kwlist, &value, &lower, &upper))
+ return -1;
+
+ self->obj = (GObject *)gimp_memsize_entry_new(value, lower, upper);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not create GimpMemsizeEntry object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+override gimp_memsize_entry_set_value
+static PyObject *
+_wrap_gimp_memsize_entry_set_value(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "value", NULL };
+ guint64 value;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "L:GimpMemsizeEntry.set_value",
+ kwlist, &value))
+ return NULL;
+
+ gimp_memsize_entry_set_value(GIMP_MEMSIZE_ENTRY(self->obj), value);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_color_area_get_color noargs
+static PyObject *
+_wrap_gimp_color_area_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_area_get_color(GIMP_COLOR_AREA(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_color_hex_entry_get_color noargs
+static PyObject *
+_wrap_gimp_color_hex_entry_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_hex_entry_get_color(GIMP_COLOR_HEX_ENTRY(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_color_notebook_get_color noargs
+static PyObject *
+_wrap_gimp_color_notebook_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_notebook_get_color(GIMP_COLOR_NOTEBOOK(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_color_selection_get_color noargs
+static PyObject *
+_wrap_gimp_color_selection_get_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_selection_get_color(GIMP_COLOR_SELECTION(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_color_selection_get_old_color noargs
+static PyObject *
+_wrap_gimp_color_selection_get_old_color(PyGObject *self)
+{
+ GimpRGB rgb;
+
+ gimp_color_selection_get_old_color(GIMP_COLOR_SELECTION(self->obj), &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+%%
+override gimp_enum_store_new kwargs
+static int
+_wrap_gimp_enum_store_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "enum_type", "minimum", "maximum", NULL };
+ PyObject *py_enum_type = NULL;
+ PyObject *py_minimum = NULL;
+ PyObject *py_maximum = NULL;
+ GType enum_type;
+ GEnumClass *enum_class;
+ gint minimum, maximum;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|O!O!:GimpEnumStore.__init__", kwlist,
+ &py_enum_type, &PyInt_Type, &py_minimum,
+ &PyInt_Type, &py_maximum))
+ return -1;
+ if ((enum_type = pyg_type_from_object(py_enum_type)) == 0)
+ return -1;
+
+ enum_class = g_type_class_ref(enum_type);
+
+ if (py_minimum == NULL)
+ minimum = enum_class->minimum;
+ else
+ minimum = PyInt_AsLong(py_minimum);
+
+ if (py_maximum == NULL)
+ maximum = enum_class->maximum;
+ else
+ maximum = PyInt_AsLong(py_maximum);
+
+ g_type_class_unref(enum_class);
+
+ self->obj = (GObject *)gimp_enum_store_new_with_range(enum_type, minimum, maximum);
+
+ if (!self->obj) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create GimpEnumStore object");
+ return -1;
+ }
+ pygobject_register_wrapper((PyObject *)self);
+ return 0;
+}
+%%
+override gimp_zoom_preview_new_with_model kwargs
+static int
+_wrap_gimp_zoom_preview_new_with_model(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", "model", NULL };
+ PyGimpDrawable *py_drawable;
+ PyGObject *py_zoom_model = NULL;
+ GimpZoomModel *zoom_model;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!:GimpZoomPreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable,
+ &PyGimpZoomModel_Type, &py_zoom_model))
+ return -1;
+
+ if (py_zoom_model)
+ zoom_model = (GimpZoomModel*)py_zoom_model->obj;
+ else
+ zoom_model = NULL;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, "model", zoom_model, NULL))
+ return -1;
+
+ g_object_set_data_full(self->obj, "pygimp-zoom-preview-pydrawable",
+ py_drawable,
+ (GDestroyNotify)pygimp_decref_callback);
+
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_ZOOM_PREVIEW
+%%
+override gimp_aspect_preview_new kwargs
+static int
+_wrap_gimp_aspect_preview_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", NULL };
+ PyGimpDrawable *py_drawable;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|:GimpAspectPreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable))
+ return -1;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, NULL))
+ return -1;
+
+ g_signal_connect_swapped(self->obj, "destroy",
+ (GCallback)pygimp_decref_callback, py_drawable);
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+%%
+new-constructor GIMP_TYPE_ASPECT_PREVIEW
+%%
+override gimp_drawable_preview_new kwargs
+static int
+_wrap_gimp_drawable_preview_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "drawable", NULL };
+ PyGimpDrawable *py_drawable;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|:GimpDrawablePreview.__init__", kwlist,
+ PyGimpDrawable_Type, &py_drawable))
+ return -1;
+
+ if (!py_drawable->drawable)
+ py_drawable->drawable = gimp_drawable_get(py_drawable->ID);
+
+ if (pygobject_construct(self, "drawable", py_drawable->drawable, NULL))
+ return -1;
+
+ g_object_set_data_full(self->obj, "pygimp-drawable-preview-pydrawable",
+ py_drawable,
+ (GDestroyNotify)pygimp_decref_callback);
+
+ Py_INCREF(py_drawable);
+
+ return 0;
+}
+
+%%
+new-constructor GIMP_TYPE_DRAWABLE_PREVIEW
+%%
+override gimp_ruler_get_range noargs
+static PyObject *
+_wrap_gimp_ruler_get_range(PyGObject *self)
+{
+ gdouble lower, upper, max_size;
+
+ gimp_ruler_get_range(GIMP_RULER(self->obj), &lower, &upper, &max_size);
+
+ return Py_BuildValue("(ddd)", lower, upper, max_size);
+}
+%%
+override gimp_color_display_convert_surface kwargs
+static PyObject *
+_wrap_gimp_color_display_convert_surface(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PycairoSurface *pysurface;
+
+ static char *kwlist[] = { "surface", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpColorDisplay.convert_surface",
+ kwlist,
+ &PycairoSurface_Type, &pysurface))
+ return NULL;
+
+ gimp_color_display_convert_surface(GIMP_COLOR_DISPLAY(self->obj),
+ pysurface->surface);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_color_display_stack_convert_surface kwargs
+static PyObject *
+_wrap_gimp_color_display_stack_convert_surface(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ PycairoSurface *pysurface;
+
+ static char *kwlist[] = { "surface", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!:GimpColorDisplayStack.convert_surface",
+ kwlist,
+ &PycairoSurface_Type, &pysurface))
+ return NULL;
+
+ gimp_color_display_stack_convert_surface(GIMP_COLOR_DISPLAY_STACK(self->obj),
+ pysurface->surface);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
+override gimp_zoom_preview_get_source noargs
+static PyObject *
+_wrap_gimp_zoom_preview_get_source(PyGObject *self)
+{
+ gint width, height, bpp;
+ guchar *image;
+ PyObject *pyimage;
+
+ image = gimp_zoom_preview_get_source(GIMP_ZOOM_PREVIEW(self->obj),
+ &width, &height, &bpp);
+
+ if (image)
+ {
+ pyimage = PyByteArray_FromStringAndSize((const char *)image,
+ width * height * bpp);
+ g_free (image);
+ }
+ else
+ {
+ Py_INCREF(Py_None);
+ pyimage = Py_None;
+ }
+
+ return Py_BuildValue("(Niii)", pyimage, width, height, bpp);
+}
+%%
+override gimp_ui_init noargs
+static PyObject *
+_wrap_gimp_ui_init(PyObject *self)
+{
+ extern const char *prog_name;
+
+ gimp_ui_init (prog_name, FALSE);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
diff --git a/plug-ins/pygimp/gimpui.py b/plug-ins/pygimp/gimpui.py
new file mode 100644
index 0000000..76ee584
--- /dev/null
+++ b/plug-ins/pygimp/gimpui.py
@@ -0,0 +1,227 @@
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+'''This module implements the UI items found in the libgimpui library.
+It requires pygtk to work. These functions take use to callbacks -- one
+is a constraint function, and the other is the callback object. The
+constraint function takes an image object as its first argument, and
+a drawable object as its second if appropriate. The callback functions
+get the selected object as their first argument, and the user data as
+the second.
+
+It also implements a number of selector widgets, which can be used to select
+various gimp data types. Each of these selectors takes default as an argument
+to the constructor, and has a get_value() method for retrieving the result.
+'''
+
+import pygtk
+pygtk.require('2.0')
+
+import gtk, gobject, gimp, gimpcolor
+
+from _gimpui import *
+
+import gettext
+t = gettext.translation('gimp20-python', gimp.locale_directory, fallback=True)
+_ = t.ugettext
+
+def _callbackWrapper(menu_item, callback, data):
+ callback(menu_item.get_data("Gimp-ID"), data)
+
+def _createMenu(items, callback, data):
+ menu = gtk.Menu()
+ if not items:
+ items = [("(none)", None)]
+ for label, id in items:
+ menu_item = gtk.MenuItem(label)
+ menu_item.set_data("Gimp-ID", id)
+ menu.add(menu_item)
+ if callback:
+ menu_item.connect("activate", _callbackWrapper,
+ callback, data)
+ menu_item.show()
+ return menu
+
+
+def ImageMenu(constraint=None, callback=None, data=None):
+ items = []
+ for img in gimp.image_list():
+ if constraint and not constraint(img):
+ continue
+ if not img.filename:
+ filename = img.name
+ else:
+ filename = img.filename
+ items.append((filename, img))
+ items.sort()
+ return _createMenu(items, callback, data)
+
+def LayerMenu(constraint=None, callback=None, data=None):
+ items = []
+ for img in gimp.image_list():
+ filename = img.filename
+ if not filename:
+ filename = img.name
+ for layer in img.layers:
+ if constraint and not constraint(img, layer):
+ continue
+ name = filename + "/" + layer.name
+ items.append((name, layer))
+ items.sort()
+ return _createMenu(items, callback, data)
+
+def ChannelMenu(constraint=None, callback=None, data=None):
+ items = []
+ for img in gimp.image_list():
+ filename = img.filename
+ if not filename:
+ filename = img.name
+ for channel in img.channels:
+ if constraint and not constraint(img, channel):
+ continue
+ name = filename + "/" + channel.name
+ items.append((name, channel))
+ items.sort()
+ return _createMenu(items, callback, data)
+
+def DrawableMenu(constraint=None, callback=None, data=None):
+ items = []
+ for img in gimp.image_list():
+ filename = img.filename
+ if not filename:
+ filename = img.name
+ for drawable in img.layers + img.channels:
+ if constraint and not constraint(img, drawable):
+ continue
+ name = filename + "/" + drawable.name
+ items.append((name, drawable))
+ items.sort()
+ return _createMenu(items, callback, data)
+
+def VectorsMenu(constraint=None, callback=None, data=None):
+ items = []
+ for img in gimp.image_list():
+ filename = img.filename
+ if not filename:
+ filename = img.name
+ for vectors in img.vectors:
+ if constraint and not constraint(img, vectors):
+ continue
+ name = filename + "/" + vectors.name
+ items.append((name, vectors))
+ items.sort()
+ return _createMenu(items, callback, data)
+
+class ImageSelector(ImageComboBox):
+ def __init__(self, default=None):
+ ImageComboBox.__init__(self)
+ if default is not None:
+ self.set_active_image(default)
+ def get_value(self):
+ return self.get_active_image()
+
+class LayerSelector(LayerComboBox):
+ def __init__(self, default=None):
+ LayerComboBox.__init__(self)
+ if default is not None:
+ self.set_active_layer(default)
+ def get_value(self):
+ return self.get_active_layer()
+
+class ChannelSelector(ChannelComboBox):
+ def __init__(self, default=None):
+ ChannelComboBox.__init__(self)
+ if default is not None:
+ self.set_active_channel(default)
+ def get_value(self):
+ return self.get_active_channel()
+
+class DrawableSelector(DrawableComboBox):
+ def __init__(self, default=None):
+ DrawableComboBox.__init__(self)
+ if default is not None:
+ self.set_active_drawable(default)
+ def get_value(self):
+ return self.get_active_drawable()
+
+class VectorsSelector(VectorsComboBox):
+ def __init__(self, default=None):
+ VectorsComboBox.__init__(self)
+ if default is not None:
+ self.set_active_vectors(default)
+ def get_value(self):
+ return self.get_active_vectors()
+
+class ColorSelector(ColorButton):
+ def __init__(self, default=gimpcolor.RGB(1.0, 0, 0)):
+ if isinstance(default, gimpcolor.RGB):
+ color = default
+ elif isinstance(default, tuple):
+ color = apply(gimpcolor.RGB, default)
+ elif isinstance(default, str):
+ color = gimpcolor.rgb_parse_css(default)
+ ColorButton.__init__(self, _("Python-Fu Color Selection"), 100, 20,
+ color, COLOR_AREA_FLAT)
+ def get_value(self):
+ return self.get_color();
+
+class PatternSelector(PatternSelectButton):
+ def __init__(self, default=""):
+ PatternSelectButton.__init__(self)
+ if default:
+ self.set_pattern(default)
+ def get_value(self):
+ return self.get_pattern()
+
+class BrushSelector(BrushSelectButton):
+ def __init__(self, default=""):
+ BrushSelectButton.__init__(self)
+ if default:
+ self.set_brush(default, -1.0, -1, -1)
+ def get_value(self):
+ return self.get_brush()[0]
+
+class GradientSelector(GradientSelectButton):
+ def __init__(self, default=""):
+ GradientSelectButton.__init__(self)
+ if default:
+ self.set_gradient(default)
+ def get_value(self):
+ return self.get_gradient()
+
+class PaletteSelector(PaletteSelectButton):
+ def __init__(self, default=""):
+ PaletteSelectButton.__init__(self)
+ if default:
+ self.set_palette(default)
+ def get_value(self):
+ return self.get_palette()
+
+class FontSelector(FontSelectButton):
+ def __init__(self, default="Sans"):
+ FontSelectButton.__init__(self)
+ if default:
+ self.set_font(default)
+ def get_value(self):
+ return self.get_font()
+
+class FileSelector(gtk.FileChooserButton):
+ def __init__(self, default=""):
+ gtk.FileChooserButton.__init__(self, _("Python-Fu File Selection"))
+ if default:
+ self.set_filename(default)
+ def get_value(self):
+ return self.get_filename()
diff --git a/plug-ins/pygimp/gimpuimodule.c b/plug-ins/pygimp/gimpuimodule.c
new file mode 100644
index 0000000..ab4e31d
--- /dev/null
+++ b/plug-ins/pygimp/gimpuimodule.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Python.h>
+
+#include <pygobject.h>
+#include <pygtk/pygtk.h>
+
+#include <pycairo.h>
+Pycairo_CAPI_t *Pycairo_CAPI;
+
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
+
+#include "pygimpcolor-api.h"
+#include "pygimp-api.h"
+#include "pygimp-util.h"
+
+
+void gimpui_register_classes(PyObject *d);
+void gimpui_add_constants(PyObject *module, const gchar *strip_prefix);
+extern PyMethodDef gimpui_functions[];
+
+
+static char gimpui_doc[] =
+"This module provides interfaces to allow you to write gimp plug-ins"
+;
+
+void init_gimpui(void);
+
+static gboolean
+init_pycairo(void)
+{
+ Pycairo_IMPORT;
+ if (Pycairo_CAPI == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
+extern const char *prog_name;
+
+const char *prog_name = "pygimp";
+
+PyMODINIT_FUNC
+init_gimpui(void)
+{
+ PyObject *m, *d;
+ PyObject *av;
+
+ av = PySys_GetObject("argv");
+ if (av != NULL) {
+ if (PyList_Check(av) && PyList_Size(av) > 0 &&
+ PyString_Check(PyList_GetItem(av, 0)))
+ prog_name = PyString_AsString(PyList_GetItem(av, 0));
+ else
+ PyErr_Warn(PyExc_Warning,
+ "ignoring sys.argv: it must be a list of strings");
+ }
+
+
+ pygimp_init_pygobject();
+
+ init_pygtk();
+ if (!init_pycairo())
+ return;
+ init_pygimpcolor();
+ init_pygimp();
+
+ m = Py_InitModule3("_gimpui", gimpui_functions, gimpui_doc);
+ d = PyModule_GetDict(m);
+
+ gimpui_register_classes(d);
+ gimpui_add_constants(m, "GIMP_");
+
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module _gimpui");
+}
diff --git a/plug-ins/pygimp/plug-ins/Makefile.am b/plug-ins/pygimp/plug-ins/Makefile.am
new file mode 100644
index 0000000..751f524
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/Makefile.am
@@ -0,0 +1,64 @@
+## Process this file with automake to produce Makefile.in
+
+pluginexecdir = $(gimpplugindir)/plug-ins
+
+source_scripts = \
+ colorxhtml.py \
+ file-openraster.py \
+ foggify.py \
+ gradients-save-as-css.py \
+ histogram-export.py \
+ palette-offset.py \
+ palette-sort.py \
+ palette-to-gradient.py \
+ py-slice.py \
+ python-eval.py \
+ spyro_plus.py \
+ \
+ benchmark-foreground-extract.py \
+ clothify.py \
+ shadow_bevel.py \
+ sphere.py \
+ whirlpinch.py
+
+scripts = \
+ colorxhtml/colorxhtml.py \
+ file-openraster/file-openraster.py \
+ foggify/foggify.py \
+ gradients-save-as-css/gradients-save-as-css.py \
+ histogram-export/histogram-export.py \
+ palette-offset/palette-offset.py \
+ palette-sort/palette-sort.py \
+ palette-to-gradient/palette-to-gradient.py \
+ py-slice/py-slice.py \
+ python-eval/python-eval.py \
+ spyro_plus/spyro_plus.py
+
+test_scripts = \
+ benchmark-foreground-extract/benchmark-foreground-extract.py \
+ clothify/clothify.py \
+ shadow_bevel/shadow_bevel.py \
+ sphere/sphere.py \
+ whirlpinch/whirlpinch.py
+
+$(scripts) $(test_scripts): $(source_scripts)
+ $(AM_V_GEN) mkdir -p $(@D) && cp -f "$(srcdir)/$(@F)" $@
+
+nobase_pluginexec_SCRIPTS = $(scripts)
+
+if GIMP_UNSTABLE
+nobase_pluginexec_SCRIPTS += $(test_scripts)
+endif
+
+# python-console has a data file.
+# Therefore let's move it to its own sub-directory.
+consoleexecdir = $(gimpplugindir)/plug-ins/python-console
+console_scripts = python-console.py
+consoleexec_SCRIPTS = $(console_scripts)
+dist_consoleexec_DATA = pyconsole.py
+
+EXTRA_DIST = \
+ $(source_scripts) \
+ $(console_scripts)
+
+CLEANFILES = $(scripts) $(test_scripts)
diff --git a/plug-ins/pygimp/plug-ins/Makefile.in b/plug-ins/pygimp/plug-ins/Makefile.in
new file mode 100644
index 0000000..a7c7feb
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/Makefile.in
@@ -0,0 +1,946 @@
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@GIMP_UNSTABLE_TRUE@am__append_1 = $(test_scripts)
+subdir = plug-ins/pygimp/plug-ins
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/m4macros/alsa.m4 \
+ $(top_srcdir)/m4macros/ax_compare_version.m4 \
+ $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \
+ $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \
+ $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \
+ $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \
+ $(top_srcdir)/m4macros/detectcflags.m4 \
+ $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(dist_consoleexec_DATA) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(consoleexecdir)" \
+ "$(DESTDIR)$(pluginexecdir)" "$(DESTDIR)$(consoleexecdir)"
+SCRIPTS = $(consoleexec_SCRIPTS) $(nobase_pluginexec_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+DATA = $(dist_consoleexec_DATA)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+AA_LIBS = @AA_LIBS@
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALL_LINGUAS = @ALL_LINGUAS@
+ALSA_CFLAGS = @ALSA_CFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+APPSTREAM_UTIL = @APPSTREAM_UTIL@
+AR = @AR@
+AS = @AS@
+ATK_CFLAGS = @ATK_CFLAGS@
+ATK_LIBS = @ATK_LIBS@
+ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BABL_CFLAGS = @BABL_CFLAGS@
+BABL_LIBS = @BABL_LIBS@
+BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@
+BUG_REPORT_URL = @BUG_REPORT_URL@
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_OBJEXT = @BUILD_OBJEXT@
+BZIP2_LIBS = @BZIP2_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@
+CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@
+CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@
+CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CC_VERSION = @CC_VERSION@
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+CPP_FOR_BUILD = @CPP_FOR_BUILD@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DESKTOP_DATADIR = @DESKTOP_DATADIR@
+DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@
+DLLTOOL = @DLLTOOL@
+DOC_SHOOTER = @DOC_SHOOTER@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FILE_AA = @FILE_AA@
+FILE_EXR = @FILE_EXR@
+FILE_HEIF = @FILE_HEIF@
+FILE_JP2_LOAD = @FILE_JP2_LOAD@
+FILE_JPEGXL = @FILE_JPEGXL@
+FILE_MNG = @FILE_MNG@
+FILE_PDF_SAVE = @FILE_PDF_SAVE@
+FILE_PS = @FILE_PS@
+FILE_WMF = @FILE_WMF@
+FILE_XMC = @FILE_XMC@
+FILE_XPM = @FILE_XPM@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@
+FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDBUS_CODEGEN = @GDBUS_CODEGEN@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@
+GEGL = @GEGL@
+GEGL_CFLAGS = @GEGL_CFLAGS@
+GEGL_LIBS = @GEGL_LIBS@
+GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@
+GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GEXIV2_CFLAGS = @GEXIV2_CFLAGS@
+GEXIV2_LIBS = @GEXIV2_LIBS@
+GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@
+GIMP_API_VERSION = @GIMP_API_VERSION@
+GIMP_APP_VERSION = @GIMP_APP_VERSION@
+GIMP_BINARY_AGE = @GIMP_BINARY_AGE@
+GIMP_COMMAND = @GIMP_COMMAND@
+GIMP_DATA_VERSION = @GIMP_DATA_VERSION@
+GIMP_FULL_NAME = @GIMP_FULL_NAME@
+GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@
+GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@
+GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@
+GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@
+GIMP_MKENUMS = @GIMP_MKENUMS@
+GIMP_MODULES = @GIMP_MODULES@
+GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@
+GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@
+GIMP_PLUGINS = @GIMP_PLUGINS@
+GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@
+GIMP_REAL_VERSION = @GIMP_REAL_VERSION@
+GIMP_RELEASE = @GIMP_RELEASE@
+GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@
+GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@
+GIMP_UNSTABLE = @GIMP_UNSTABLE@
+GIMP_USER_VERSION = @GIMP_USER_VERSION@
+GIMP_VERSION = @GIMP_VERSION@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@
+GIO_UNIX_LIBS = @GIO_UNIX_LIBS@
+GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@
+GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@
+GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@
+GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GOBJECT_QUERY = @GOBJECT_QUERY@
+GREP = @GREP@
+GS_LIBS = @GS_LIBS@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@
+GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@
+GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@
+GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@
+HARFBUZZ_LIBS = @HARFBUZZ_LIBS@
+HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@
+HAVE_CXX14 = @HAVE_CXX14@
+HAVE_FINITE = @HAVE_FINITE@
+HAVE_ISFINITE = @HAVE_ISFINITE@
+HAVE_VFORK = @HAVE_VFORK@
+HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
+INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
+INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
+INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@
+ISO_CODES_LOCATION = @ISO_CODES_LOCATION@
+JPEG_LIBS = @JPEG_LIBS@
+JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@
+JSON_GLIB_LIBS = @JSON_GLIB_LIBS@
+JXL_CFLAGS = @JXL_CFLAGS@
+JXL_LIBS = @JXL_LIBS@
+JXL_THREADS_CFLAGS = @JXL_THREADS_CFLAGS@
+JXL_THREADS_LIBS = @JXL_THREADS_LIBS@
+LCMS_CFLAGS = @LCMS_CFLAGS@
+LCMS_LIBS = @LCMS_LIBS@
+LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
+LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@
+LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@
+LIBHEIF_LIBS = @LIBHEIF_LIBS@
+LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@
+LIBJXL_REQUIRED_VERSION = @LIBJXL_REQUIRED_VERSION@
+LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@
+LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@
+LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@
+LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@
+LIBOBJS = @LIBOBJS@
+LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@
+LIBUNWIND_LIBS = @LIBUNWIND_LIBS@
+LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+LT_VERSION_INFO = @LT_VERSION_INFO@
+LZMA_CFLAGS = @LZMA_CFLAGS@
+LZMA_LIBS = @LZMA_LIBS@
+MAIL = @MAIL@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@
+MIME_INFO_LIBS = @MIME_INFO_LIBS@
+MIME_TYPES = @MIME_TYPES@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@
+MNG_CFLAGS = @MNG_CFLAGS@
+MNG_LIBS = @MNG_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_OPTS = @MSGFMT_OPTS@
+MSGMERGE = @MSGMERGE@
+MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@
+MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@
+NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@
+NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENEXR_CFLAGS = @OPENEXR_CFLAGS@
+OPENEXR_LIBS = @OPENEXR_LIBS@
+OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@
+OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@
+OPENJPEG_LIBS = @OPENJPEG_LIBS@
+OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@
+PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@
+PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@
+PATHSEP = @PATHSEP@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@
+PERL_VERSION = @PERL_VERSION@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PNG_CFLAGS = @PNG_CFLAGS@
+PNG_LIBS = @PNG_LIBS@
+POFILES = @POFILES@
+POPPLER_CFLAGS = @POPPLER_CFLAGS@
+POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@
+POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@
+POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@
+POPPLER_LIBS = @POPPLER_LIBS@
+POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PYBIN_PATH = @PYBIN_PATH@
+PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@
+PYCAIRO_LIBS = @PYCAIRO_LIBS@
+PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@
+PYGTK_CFLAGS = @PYGTK_CFLAGS@
+PYGTK_CODEGEN = @PYGTK_CODEGEN@
+PYGTK_DEFSDIR = @PYGTK_DEFSDIR@
+PYGTK_LIBS = @PYGTK_LIBS@
+PYLINK_LIBS = @PYLINK_LIBS@
+PYTHON = @PYTHON@
+PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@
+RT_LIBS = @RT_LIBS@
+SCREENSHOT_LIBS = @SCREENSHOT_LIBS@
+SED = @SED@
+SENDMAIL = @SENDMAIL@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOCKET_LIBS = @SOCKET_LIBS@
+SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
+SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
+STRIP = @STRIP@
+SVG_CFLAGS = @SVG_CFLAGS@
+SVG_LIBS = @SVG_LIBS@
+SYMPREFIX = @SYMPREFIX@
+TIFF_LIBS = @TIFF_LIBS@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WEBKIT_CFLAGS = @WEBKIT_CFLAGS@
+WEBKIT_LIBS = @WEBKIT_LIBS@
+WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@
+WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@
+WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@
+WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@
+WEBPMUX_LIBS = @WEBPMUX_LIBS@
+WEBP_CFLAGS = @WEBP_CFLAGS@
+WEBP_LIBS = @WEBP_LIBS@
+WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@
+WEB_PAGE = @WEB_PAGE@
+WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@
+WINDRES = @WINDRES@
+WMF_CFLAGS = @WMF_CFLAGS@
+WMF_CONFIG = @WMF_CONFIG@
+WMF_LIBS = @WMF_LIBS@
+WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@
+XDG_EMAIL = @XDG_EMAIL@
+XFIXES_CFLAGS = @XFIXES_CFLAGS@
+XFIXES_LIBS = @XFIXES_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@
+XMC_CFLAGS = @XMC_CFLAGS@
+XMC_LIBS = @XMC_LIBS@
+XMKMF = @XMKMF@
+XMLLINT = @XMLLINT@
+XMU_LIBS = @XMU_LIBS@
+XPM_LIBS = @XPM_LIBS@
+XSLTPROC = @XSLTPROC@
+XVFB_RUN = @XVFB_RUN@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+Z_LIBS = @Z_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gimpdatadir = @gimpdatadir@
+gimpdir = @gimpdir@
+gimplocaledir = @gimplocaledir@
+gimpplugindir = @gimpplugindir@
+gimpsysconfdir = @gimpsysconfdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+intltool__v_merge_options_ = @intltool__v_merge_options_@
+intltool__v_merge_options_0 = @intltool__v_merge_options_0@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+manpage_gimpdir = @manpage_gimpdir@
+mkdir_p = @mkdir_p@
+ms_librarian = @ms_librarian@
+mypaint_brushes_dir = @mypaint_brushes_dir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+pluginexecdir = $(gimpplugindir)/plug-ins
+source_scripts = \
+ colorxhtml.py \
+ file-openraster.py \
+ foggify.py \
+ gradients-save-as-css.py \
+ histogram-export.py \
+ palette-offset.py \
+ palette-sort.py \
+ palette-to-gradient.py \
+ py-slice.py \
+ python-eval.py \
+ spyro_plus.py \
+ \
+ benchmark-foreground-extract.py \
+ clothify.py \
+ shadow_bevel.py \
+ sphere.py \
+ whirlpinch.py
+
+scripts = \
+ colorxhtml/colorxhtml.py \
+ file-openraster/file-openraster.py \
+ foggify/foggify.py \
+ gradients-save-as-css/gradients-save-as-css.py \
+ histogram-export/histogram-export.py \
+ palette-offset/palette-offset.py \
+ palette-sort/palette-sort.py \
+ palette-to-gradient/palette-to-gradient.py \
+ py-slice/py-slice.py \
+ python-eval/python-eval.py \
+ spyro_plus/spyro_plus.py
+
+test_scripts = \
+ benchmark-foreground-extract/benchmark-foreground-extract.py \
+ clothify/clothify.py \
+ shadow_bevel/shadow_bevel.py \
+ sphere/sphere.py \
+ whirlpinch/whirlpinch.py
+
+nobase_pluginexec_SCRIPTS = $(scripts) $(am__append_1)
+
+# python-console has a data file.
+# Therefore let's move it to its own sub-directory.
+consoleexecdir = $(gimpplugindir)/plug-ins/python-console
+console_scripts = python-console.py
+consoleexec_SCRIPTS = $(console_scripts)
+dist_consoleexec_DATA = pyconsole.py
+EXTRA_DIST = \
+ $(source_scripts) \
+ $(console_scripts)
+
+CLEANFILES = $(scripts) $(test_scripts)
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/pygimp/plug-ins/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu plug-ins/pygimp/plug-ins/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-consoleexecSCRIPTS: $(consoleexec_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(consoleexec_SCRIPTS)'; test -n "$(consoleexecdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(consoleexecdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(consoleexecdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(consoleexecdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(consoleexecdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-consoleexecSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(consoleexec_SCRIPTS)'; test -n "$(consoleexecdir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(consoleexecdir)'; $(am__uninstall_files_from_dir)
+install-nobase_pluginexecSCRIPTS: $(nobase_pluginexec_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(nobase_pluginexec_SCRIPTS)'; test -n "$(pluginexecdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pluginexecdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pluginexecdir)" || exit 1; \
+ fi; \
+ $(am__nobase_strip_setup); \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e "s|$$srcdirstrip/||" -e 'h;s|[^/]*$$||; s|^$$|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ case $$type in \
+ d) echo " $(MKDIR_P) '$(DESTDIR)$(pluginexecdir)/$$dir'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pluginexecdir)/$$dir" || exit $$?;; \
+ f) \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(pluginexecdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(pluginexecdir)$$dir" || exit $$?; \
+ } \
+ ;; esac \
+ ; done
+
+uninstall-nobase_pluginexecSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nobase_pluginexec_SCRIPTS)'; test -n "$(pluginexecdir)" || exit 0; \
+ $(am__nobase_strip_setup); \
+ files=`$(am__nobase_strip) \
+ -e 'h;s,.*/,,;$(transform);x;s|[^/]*$$||;G;s,\n,,'`; \
+ dir='$(DESTDIR)$(pluginexecdir)'; $(am__uninstall_files_from_dir)
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-dist_consoleexecDATA: $(dist_consoleexec_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_consoleexec_DATA)'; test -n "$(consoleexecdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(consoleexecdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(consoleexecdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(consoleexecdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(consoleexecdir)" || exit $$?; \
+ done
+
+uninstall-dist_consoleexecDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_consoleexec_DATA)'; test -n "$(consoleexecdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(consoleexecdir)'; $(am__uninstall_files_from_dir)
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(consoleexecdir)" "$(DESTDIR)$(pluginexecdir)" "$(DESTDIR)$(consoleexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-consoleexecSCRIPTS \
+ install-dist_consoleexecDATA install-nobase_pluginexecSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-consoleexecSCRIPTS \
+ uninstall-dist_consoleexecDATA \
+ uninstall-nobase_pluginexecSCRIPTS
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distdir dvi dvi-am html html-am info info-am \
+ install install-am install-consoleexecSCRIPTS install-data \
+ install-data-am install-dist_consoleexecDATA install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-nobase_pluginexecSCRIPTS install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am uninstall-consoleexecSCRIPTS \
+ uninstall-dist_consoleexecDATA \
+ uninstall-nobase_pluginexecSCRIPTS
+
+.PRECIOUS: Makefile
+
+
+$(scripts) $(test_scripts): $(source_scripts)
+ $(AM_V_GEN) mkdir -p $(@D) && cp -f "$(srcdir)/$(@F)" $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py b/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py
new file mode 100755
index 0000000..2637547
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/benchmark-foreground-extract.py
@@ -0,0 +1,197 @@
+#!/usr/bin/env python2
+
+# Foreground Extraction Benchmark
+# Copyright 2005 Sven Neumann <sven@gimp.org>
+#
+# This is a from-scratch implementation of the benchmark proposed in
+# "GrabCut": interactive foreground extraction using iterated graph
+# cuts published in the Proceedings of the 2004 SIGGRAPH Conference.
+#
+# No guarantee is made that this benchmark produces the same results
+# as the cited benchmark but the goal is that it does. So if you find
+# any bugs or inaccuracies in this code, please let us know.
+#
+# The benchmark has been adapted work with the SIOX algorithm
+# (http://www.siox.org). which is (currently) the only
+# implementation of gimp_drawable_foreground_extract(). If other
+# implementations are being added, this benchmark should be changed
+# accordingly.
+#
+# You will need a set of test images to run this benchmark, preferably
+# the original set of 50 images. Some of these images are from the
+# Berkeley Segmentation Dataset
+# (http://www.cs.berkeley.edu/projects/vision/grouping/segbench/).
+# See also http://www.siox.org/details.html for trimaps.
+#
+# 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/>.
+
+
+import os, re, struct, sys, time
+
+from gimpfu import *
+
+
+def benchmark (folder, save_output):
+ folder = os.path.abspath (folder)
+ if not os.path.exists (folder):
+ gimp.message("Folder '" + folder + "' doesn't exist.\n")
+ return;
+
+ total_unclassified = 0
+ total_misclassified = 0
+ total_time = 0.0
+
+ images = os.path.join (folder, "images")
+ for name in os.listdir (images):
+
+ try:
+ gimp.delete (image_display)
+ gimp.delete (mask_display)
+ except UnboundLocalError:
+ pass
+
+ image_name = os.path.join (images, name)
+
+ # FIXME: improve this!
+ name = re.sub (r'\.jpg$', '', name)
+ name = re.sub (r'\.JPG$', '', name)
+ name = re.sub (r'\.bmp$', '', name)
+
+ mask_name = os.path.join (folder, "cm_bmp", name + '.png')
+ truth_name = os.path.join (folder, "truth", name + '.bmp')
+
+ image = pdb.gimp_file_load (image_name, image_name)
+ image_layer = image.active_layer;
+
+ mask = pdb.gimp_file_load (mask_name, mask_name)
+ convert_grayscale (mask)
+ mask_layer = mask.active_layer;
+
+ truth = pdb.gimp_file_load (truth_name, truth_name)
+ convert_grayscale (truth)
+ truth_layer = truth.active_layer;
+
+ unclassified = unclassified_pixels (mask_layer, truth_layer)
+
+ sys.stderr.write (os.path.basename (image_name))
+
+ start = time.time ()
+ pdb.gimp_drawable_foreground_extract (image_layer,
+ FOREGROUND_EXTRACT_SIOX,
+ mask_layer)
+ end = time.time ()
+
+ sys.stderr.write (" ")
+
+ mask_layer.flush ()
+
+ # Ignore errors when creating image displays;
+ # allows us to be used without a display.
+ try:
+ image_display = pdb.gimp_display_new (image)
+ mask_display = pdb.gimp_display_new (mask)
+
+ gimp.displays_flush ()
+ time.sleep (1.0)
+ except:
+ pass
+
+ gimp.delete (image)
+
+ misclassified = misclassified_pixels (mask_layer, truth_layer)
+
+ sys.stderr.write ("%d %d %.2f%% %.3fs\n" %
+ (unclassified, misclassified,
+ (misclassified * 100.0 / unclassified),
+ end - start))
+
+ total_unclassified += unclassified
+ total_misclassified += misclassified
+ total_time += end - start
+
+ gimp.delete (truth)
+
+ if save_output:
+ filename = os.path.join (folder, "output", name + '.png')
+ pdb.gimp_file_save (mask, mask_layer, filename, filename)
+
+ gimp.delete (mask)
+
+ # for loop ends
+
+ try:
+ gimp.delete (image_display)
+ gimp.delete (mask_display)
+ except UnboundLocalError:
+ pass
+
+ sys.stderr.write ("Total: %d %d %.2f%% %.3fs\n" %
+ (total_unclassified, total_misclassified,
+ (total_misclassified * 100.0 / total_unclassified),
+ total_time))
+
+def convert_grayscale (image):
+ if image.base_type != GRAY:
+ pdb.gimp_image_convert_grayscale (image)
+
+
+def unclassified_pixels (mask, truth):
+ (mean, std_dev, median, pixels,
+ count, percentile) = pdb.gimp_histogram (mask, HISTOGRAM_VALUE, 1, 254)
+
+ return count
+
+
+def misclassified_pixels (mask, truth):
+ image = truth.image
+
+ copy = pdb.gimp_layer_new_from_drawable (mask, image)
+ copy.name = "Difference"
+ copy.mode = DIFFERENCE_MODE
+
+ image.insert_layer (copy)
+
+ # The assumption made here is that the output of
+ # foreground_extract is a strict black and white mask. The truth
+ # however may contain unclassified pixels. These are considered
+ # unknown, a strict segmentation isn't possible here.
+ #
+ # The result of using the Difference mode as done here is that
+ # pure black pixels in the result can be considered correct.
+ # White pixels are wrong. Gray values were unknown in the truth
+ # and thus are not counted as wrong.
+
+ (mean, std_dev, median, pixels,
+ count, percentile) = pdb.gimp_histogram (image.flatten (),
+ HISTOGRAM_VALUE, 255, 255)
+
+ return count
+
+
+register (
+ "python-fu-benchmark-foreground-extract",
+ "Benchmark and regression test for the SIOX algorithm",
+ "",
+ "Sven Neumann",
+ "Sven Neumann",
+ "2005",
+ "Foreground Extraction",
+ "",
+ [ (PF_FILE, "image-folder", "Image folder",
+ "~/segmentation/msbench/imagedata"),
+ (PF_TOGGLE, "save-output", "Save output images", False) ],
+ [],
+ benchmark, menu="<Image>/Filters/Extensions/Benchmark")
+
+main ()
diff --git a/plug-ins/pygimp/plug-ins/clothify.py b/plug-ins/pygimp/plug-ins/clothify.py
new file mode 100755
index 0000000..258329c
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/clothify.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+import math
+from gimpfu import *
+
+def clothify(timg, tdrawable, bx=9, by=9, azimuth=135, elevation=45, depth=3):
+ width = tdrawable.width
+ height = tdrawable.height
+
+ img = gimp.Image(width, height, RGB)
+ img.disable_undo()
+
+ layer_one = gimp.Layer(img, "X Dots", width, height, RGB_IMAGE,
+ 100, NORMAL_MODE)
+ img.insert_layer(layer_one)
+ pdb.gimp_edit_fill(layer_one, BACKGROUND_FILL)
+
+ pdb.plug_in_noisify(img, layer_one, 0, 0.7, 0.7, 0.7, 0.7)
+
+ layer_two = layer_one.copy()
+ layer_two.mode = MULTIPLY_MODE
+ layer_two.name = "Y Dots"
+ img.insert_layer(layer_two)
+
+ pdb.plug_in_gauss_rle(img, layer_one, bx, 1, 0)
+ pdb.plug_in_gauss_rle(img, layer_two, by, 0, 1)
+
+ img.flatten()
+
+ bump_layer = img.active_layer
+
+ pdb.plug_in_c_astretch(img, bump_layer)
+ pdb.plug_in_noisify(img, bump_layer, 0, 0.2, 0.2, 0.2, 0.2)
+ pdb.plug_in_bump_map(img, tdrawable, bump_layer, azimuth,
+ elevation, depth, 0, 0, 0, 0, True, False, 0)
+
+ gimp.delete(img)
+
+register(
+ "python-fu-clothify",
+ "Make the image look like it is printed on cloth",
+ "Make the specified layer look like it is printed on cloth",
+ "James Henstridge",
+ "James Henstridge",
+ "1997-1999",
+ "_Clothify...",
+ "RGB*, GRAY*",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_INT, "x-blur", "X blur", 9),
+ (PF_INT, "y-blur", "Y blur", 9),
+ (PF_INT, "azimuth", "Azimuth", 135),
+ (PF_INT, "elevation", "Elevation", 45),
+ (PF_INT, "depth", "Depth", 3)
+ ],
+ [],
+ clothify, menu="<Image>/Filters/Artistic")
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/colorxhtml.py b/plug-ins/pygimp/plug-ins/colorxhtml.py
new file mode 100755
index 0000000..011f8ca
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/colorxhtml.py
@@ -0,0 +1,212 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 2003, 2005 Manish Singh <yosh@gimp.org>
+#
+# 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/>.
+
+import string
+import struct
+import inspect
+import os.path
+
+import gimp
+from gimpfu import *
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+all_source_types = (CHARS_SOURCE, CHARS_FILE, CHARS_PARAMETER) = range(3)
+
+escape_table = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;'
+}
+
+style_def = """body {
+ width: 100%%;
+ font-size: %dpx;
+ background-color: #000000;
+ color: #ffffff;
+}
+"""
+
+preamble = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+<title>CSS Color XHTML written by GIMP</title>
+%s
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+<pre>
+"""
+
+postamble = """\n</pre>\n</body>\n</html>\n"""
+
+def colorxhtml(img, drawable, filename, raw_filename,
+ source_type, characters, size, separate):
+ width = drawable.width
+ height = drawable.height
+ bpp = drawable.bpp
+
+ if not drawable.is_rgb or drawable.has_alpha:
+ return
+
+ if source_type not in all_source_types:
+ return
+
+ gimp.tile_cache_ntiles(width / gimp.tile_width() + 1)
+
+ html = file(filename, 'w')
+
+ if separate:
+ dirname, cssfile = os.path.split(filename)
+ cssfile = os.path.splitext(cssfile)[0] + '.css'
+ cssname = os.path.join(dirname, cssfile)
+
+ css = file(cssname, 'w')
+
+ if source_type == CHARS_SOURCE:
+ chars = file(inspect.getsourcefile(colorxhtml)).read()
+ elif source_type == CHARS_FILE:
+ chars = file(characters).read()
+ elif source_type == CHARS_PARAMETER:
+ chars = characters
+
+ allchars = string.maketrans('', '')
+
+ goodchars = string.digits + string.ascii_letters + string.punctuation
+ badchars = ''.join([c for c in allchars if c not in goodchars])
+
+ chars = chars.translate(allchars, badchars)
+
+ data = []
+
+ for c in chars:
+ data.append(escape_table.get(c, c))
+
+ if data:
+ data.reverse()
+ else:
+ data = list('X' * 80)
+
+ pr = drawable.get_pixel_rgn(0, 0, width, height, False, False)
+
+ gimp.progress_init(_("Saving as colored XHTML"))
+
+ style = style_def % size
+
+ if separate:
+ ss = '<link rel="stylesheet" type="text/css" href="%s" />' % cssfile
+ css.write(style)
+ else:
+ ss = '<style type="text/css">\n%s</style>' % style
+
+ html.write(preamble % ss)
+
+ colors = {}
+ chars = []
+
+ for y in range(0, height):
+ row = pr[0:width, y]
+
+ while len(chars) < width:
+ chars[0:0] = data
+
+ for pixel in RowIterator(row, bpp):
+ color = '%02x%02x%02x' % pixel
+ style = 'background-color:black; color:#%s;' % color
+ char = chars.pop()
+
+ if separate:
+ if color not in colors:
+ css.write('span.N%s { %s }\n' % (color, style))
+ colors[color] = 1
+
+ html.write('<span class="N%s">%s</span>' % (color, char))
+
+ else:
+ html.write('<span style="%s">%s</span>' % (style, char))
+
+ html.write('\n')
+
+ gimp.progress_update(y / float(height))
+
+ html.write(postamble)
+
+ html.close()
+
+ if separate:
+ css.close()
+
+def register_save():
+ gimp.register_save_handler("file-colorxhtml-save", "xhtml", "")
+
+class RowIterator:
+ def __init__(self, row, bpp):
+ self.row = row
+ self.bpp = bpp
+
+ self.start = 0
+ self.stop = bpp
+
+ self.length = len(row)
+ self.fmt = 'B' * bpp
+
+ def __iter__(self):
+ return iter(self.get_pixel, None)
+
+ def get_pixel(self):
+ if self.stop > self.length:
+ return None
+
+ pixel = struct.unpack(self.fmt, self.row[self.start:self.stop])
+
+ self.start += self.bpp
+ self.stop += self.bpp
+
+ return pixel
+
+register(
+ "file-colorxhtml-save",
+ N_("Save as colored XHTML"),
+ "Saves the image as colored XHTML text (based on Perl version by Marc Lehmann)",
+ "Manish Singh and Carol Spears",
+ "Manish Singh and Carol Spears",
+ "2003",
+ N_("Colored XHTML"),
+ "RGB",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_STRING, "filename", "The name of the file", None),
+ (PF_STRING, "raw-filename", "The name of the file", None),
+ (PF_RADIO, "source", _("Character _source"), 0,
+ ((_("Source code"), CHARS_SOURCE),
+ (_("Text file"), CHARS_FILE),
+ (_("Entry box"), CHARS_PARAMETER))),
+ (PF_FILE, "characters", _("_File to read or characters to use"),
+ ""),
+ (PF_INT, "font-size", _("Fo_nt size in pixels"), 10),
+ (PF_BOOL, "separate", _("_Write a separate CSS file"), True)
+ ],
+ [],
+ colorxhtml, on_query=register_save,
+ menu="<Save>", domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/file-openraster.py b/plug-ins/pygimp/plug-ins/file-openraster.py
new file mode 100755
index 0000000..c55b1b6
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/file-openraster.py
@@ -0,0 +1,404 @@
+#!/usr/bin/env python2
+
+# GIMP Plug-in for the OpenRaster file format
+# http://create.freedesktop.org/wiki/OpenRaster
+
+# Copyright (C) 2009 by Jon Nordby <jononor@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.
+#
+# Based on MyPaint source code by Martin Renold
+# http://gitorious.org/mypaint/mypaint/blobs/edd84bcc1e091d0d56aa6d26637aa8a925987b6a/lib/document.py
+
+import os, sys, tempfile, zipfile
+import xml.etree.ElementTree as ET
+
+
+from gimpfu import *
+
+NESTED_STACK_END = object()
+
+
+layermodes_map = {
+ "svg:src-over": LAYER_MODE_NORMAL,
+ "svg:multiply": LAYER_MODE_MULTIPLY_LEGACY,
+ "svg:screen": LAYER_MODE_SCREEN_LEGACY,
+ "svg:overlay": LAYER_MODE_OVERLAY,
+ "svg:darken": LAYER_MODE_DARKEN_ONLY_LEGACY,
+ "svg:lighten": LAYER_MODE_LIGHTEN_ONLY_LEGACY,
+ "svg:color-dodge": LAYER_MODE_DODGE_LEGACY,
+ "svg:color-burn": LAYER_MODE_BURN_LEGACY,
+ "svg:hard-light": LAYER_MODE_HARDLIGHT_LEGACY,
+ "svg:soft-light": LAYER_MODE_SOFTLIGHT_LEGACY,
+ "svg:difference": LAYER_MODE_DIFFERENCE_LEGACY,
+ "svg:color": LAYER_MODE_HSL_COLOR_LEGACY,
+ "svg:luminosity": LAYER_MODE_HSV_VALUE_LEGACY,
+ "svg:hue": LAYER_MODE_HSV_HUE_LEGACY,
+ "svg:saturation": LAYER_MODE_HSV_SATURATION_LEGACY,
+ "svg:plus": LAYER_MODE_ADDITION_LEGACY,
+}
+
+def reverse_map(mapping):
+ return dict((v,k) for k, v in mapping.iteritems())
+
+def get_image_attributes(orafile):
+ xml = orafile.read('stack.xml')
+ image = ET.fromstring(xml)
+ stack = image.find('stack')
+ w = int(image.attrib.get('w', ''))
+ h = int(image.attrib.get('h', ''))
+
+ return stack, w, h
+
+def get_layer_attributes(layer):
+ a = layer.attrib
+ path = a.get('src', '')
+ name = a.get('name', '')
+ x = int(a.get('x', '0'))
+ y = int(a.get('y', '0'))
+ opac = float(a.get('opacity', '1.0'))
+ visible = a.get('visibility', 'visible') != 'hidden'
+ m = a.get('composite-op', 'svg:src-over')
+ layer_mode = layermodes_map.get(m, LAYER_MODE_NORMAL)
+
+ return path, name, x, y, opac, visible, layer_mode
+
+def get_group_layer_attributes(layer):
+ a = layer.attrib
+ name = a.get('name', '')
+ opac = float(a.get('opacity', '1.0'))
+ visible = a.get('visibility', 'visible') != 'hidden'
+ m = a.get('composite-op', 'svg:src-over')
+ layer_mode = layermodes_map.get(m, NORMAL_MODE)
+
+ return name, 0, 0, opac, visible, layer_mode
+
+def thumbnail_ora(filename, thumb_size):
+ # FIXME: Untested. Does not seem to be used at all? should be run
+ # when registered and there is no thumbnail in cache
+ tempdir = tempfile.mkdtemp('gimp-plugin-file-openraster')
+ original_name = filename
+ try:
+ if not isinstance(filename, str):
+ filename = filename.decode("utf-8")
+ orafile = zipfile.ZipFile(filename.encode(sys.getfilesystemencoding() or "utf-8"))
+ except (UnicodeDecodeError, IOError):
+ # Someone may try to open an actually garbled name, and pass a raw
+ # non-utf 8 filename:
+ orafile = zipfile.ZipFile(original_name)
+ orafile = zipfile.ZipFile(filename)
+ stack, w, h = get_image_attributes(orafile)
+
+ # create temp file
+ tmp = os.path.join(tempdir, 'tmp.png')
+ f = open(tmp, 'wb')
+ f.write(orafile.read('Thumbnails/thumbnail.png'))
+ f.close()
+
+ img = pdb['file-png-load'](tmp, 'tmp.png')
+ # TODO: scaling
+ os.remove(tmp)
+ os.rmdir(tempdir)
+
+ return (img, w, h)
+
+def save_ora(img, drawable, filename, raw_filename):
+ def write_file_str(zfile, fname, data):
+ # work around a permission bug in the zipfile library:
+ # http://bugs.python.org/issue3394
+ zi = zipfile.ZipInfo(fname)
+ zi.external_attr = int("100644", 8) << 16
+ zfile.writestr(zi, data)
+
+ tempdir = tempfile.mkdtemp('gimp-plugin-file-openraster')
+
+ if isinstance(filename, str):
+ try:
+ filename = filename.decode("utf-8")
+ except UnicodeDecodeError:
+ # 1 - 1 correspondence between raw_bytes and UCS-2 used by Python
+ # Unicode characters
+ filename = filename.decode("latin1")
+ encoding = sys.getfilesystemencoding() or "utf-8"
+ filename = filename.encode(encoding)
+ tmp_sufix = ".tmpsave".encode(encoding)
+ # use .tmpsave extension, so we don't overwrite a valid file if
+ # there is an exception
+ orafile = zipfile.ZipFile(filename + tmp_sufix, 'w', compression=zipfile.ZIP_STORED)
+
+ write_file_str(orafile, 'mimetype', 'image/openraster') # must be the first file written
+
+ # build image attributes
+ image = ET.Element('image')
+ stack = ET.SubElement(image, 'stack')
+ a = image.attrib
+ a['w'] = str(img.width)
+ a['h'] = str(img.height)
+
+ def store_layer(img, drawable, path):
+ tmp = os.path.join(tempdir, 'tmp.png')
+ interlace, compression = 0, 2
+ png_chunks = (1, 1, 0, 1, 1) # write all PNG chunks except oFFs(ets)
+ pdb['file-png-save'](img, drawable, tmp, 'tmp.png',
+ interlace, compression, *png_chunks)
+ orafile.write(tmp, path)
+ os.remove(tmp)
+
+ def add_layer(parent, x, y, opac, gimp_layer, path, visible=True):
+ store_layer(img, gimp_layer, path)
+ # create layer attributes
+ layer = ET.Element('layer')
+ parent.append(layer)
+ a = layer.attrib
+ a['src'] = path
+ a['name'] = gimp_layer.name
+ a['x'] = str(x)
+ a['y'] = str(y)
+ a['opacity'] = str(opac)
+ a['visibility'] = 'visible' if visible else 'hidden'
+ a['composite-op'] = reverse_map(layermodes_map).get(gimp_layer.mode, 'svg:src-over')
+ return layer
+
+ def add_group_layer(parent, opac, gimp_layer, visible=True):
+ # create layer attributes
+ group_layer = ET.Element('stack')
+ parent.append(group_layer)
+ a = group_layer.attrib
+ a['name'] = gimp_layer.name
+ a['opacity'] = str(opac)
+ a['visibility'] = 'visible' if visible else 'hidden'
+ a['composite-op'] = reverse_map(layermodes_map).get(gimp_layer.mode, 'svg:src-over')
+ return group_layer
+
+
+ def enumerate_layers(group):
+ for layer in group.layers:
+ if not isinstance(layer, gimp.GroupLayer):
+ yield layer
+ else:
+ yield layer
+ for sublayer in enumerate_layers(layer):
+ yield sublayer
+ yield NESTED_STACK_END
+
+ # save layers
+ parent_groups = []
+ i = 0
+ for lay in enumerate_layers(img):
+ if lay is NESTED_STACK_END:
+ parent_groups.pop()
+ continue
+ x, y = lay.offsets
+ opac = lay.opacity / 100.0 # needs to be between 0.0 and 1.0
+
+ if not parent_groups:
+ path_name = 'data/{:03d}.png'.format(i)
+ i += 1
+ else:
+ path_name = 'data/{}-{:03d}.png'.format(
+ parent_groups[-1][1], parent_groups[-1][2])
+ parent_groups[-1][2] += 1
+
+ parent = stack if not parent_groups else parent_groups[-1][0]
+
+ if isinstance(lay, gimp.GroupLayer):
+ group = add_group_layer(parent, opac, lay, lay.visible)
+ group_path = ("{:03d}".format(i) if not parent_groups else
+ parent_groups[-1][1] + "-{:03d}".format(parent_groups[-1][2]))
+ parent_groups.append([group, group_path , 0])
+ else:
+ add_layer(parent, x, y, opac, lay, path_name, lay.visible)
+
+ # save mergedimage
+ thumb = pdb['gimp-image-duplicate'](img)
+ thumb_layer = thumb.merge_visible_layers (CLIP_TO_IMAGE)
+ store_layer (thumb, thumb_layer, 'mergedimage.png')
+
+ # save thumbnail
+ w, h = img.width, img.height
+ if max (w, h) > 256:
+ # should be at most 256x256, without changing aspect ratio
+ if w > h:
+ w, h = 256, max(h*256/w, 1)
+ else:
+ w, h = max(w*256/h, 1), 256
+ thumb_layer.scale(w, h)
+ if thumb.precision != PRECISION_U8_GAMMA:
+ pdb.gimp_image_convert_precision (thumb, PRECISION_U8_GAMMA)
+ store_layer(thumb, thumb_layer, 'Thumbnails/thumbnail.png')
+ gimp.delete(thumb)
+
+ # write stack.xml
+ xml = ET.tostring(image, encoding='UTF-8')
+ write_file_str(orafile, 'stack.xml', xml)
+
+ # finish up
+ orafile.close()
+ os.rmdir(tempdir)
+ if os.path.exists(filename):
+ os.remove(filename) # win32 needs that
+ os.rename(filename + tmp_sufix, filename)
+
+
+def load_ora(filename, raw_filename):
+ tempdir = tempfile.mkdtemp('gimp-plugin-file-openraster')
+ original_name = filename
+ try:
+ if not isinstance(filename, str):
+ filename = filename.decode("utf-8")
+ orafile = zipfile.ZipFile(filename.encode(sys.getfilesystemencoding() or "utf-8"))
+ except (UnicodeDecodeError, IOError):
+ # Someone may try to open an actually garbled name, and pass a raw
+ # non-utf 8 filename:
+ orafile = zipfile.ZipFile(original_name)
+ stack, w, h = get_image_attributes(orafile)
+
+ img = gimp.Image(w, h, RGB)
+ img.filename = filename
+
+ def get_layers(root):
+ """iterates over layers and nested stacks"""
+ for item in root:
+ if item.tag == 'layer':
+ yield item
+ elif item.tag == 'stack':
+ yield item
+ for subitem in get_layers(item):
+ yield subitem
+ yield NESTED_STACK_END
+
+ parent_groups = []
+
+ layer_no = 0
+ for item in get_layers(stack):
+
+ if item is NESTED_STACK_END:
+ parent_groups.pop()
+ continue
+
+ if item.tag == 'stack':
+ name, x, y, opac, visible, layer_mode = get_group_layer_attributes(item)
+ gimp_layer = gimp.GroupLayer(img)
+
+ else:
+ path, name, x, y, opac, visible, layer_mode = get_layer_attributes(item)
+
+ if not path.lower().endswith('.png'):
+ continue
+ if not name:
+ # use the filename without extension as name
+ n = os.path.basename(path)
+ name = os.path.splitext(n)[0]
+
+ # create temp file. Needed because gimp cannot load files from inside a zip file
+ tmp = os.path.join(tempdir, 'tmp.png')
+ f = open(tmp, 'wb')
+ try:
+ data = orafile.read(path)
+ except KeyError:
+ # support for bad zip files (saved by old versions of this plugin)
+ data = orafile.read(path.encode('utf-8'))
+ print 'WARNING: bad OpenRaster ZIP file. There is an utf-8 encoded filename that does not have the utf-8 flag set:', repr(path)
+ f.write(data)
+ f.close()
+
+ # import layer, set attributes and add to image
+ gimp_layer = pdb['gimp-file-load-layer'](img, tmp)
+ os.remove(tmp)
+ gimp_layer.name = name
+ gimp_layer.mode = layer_mode
+ gimp_layer.set_offsets(x, y) # move to correct position
+ gimp_layer.opacity = opac * 100 # a float between 0 and 100
+ gimp_layer.visible = visible
+
+ pdb.gimp_image_insert_layer(img, gimp_layer,
+ parent_groups[-1][0] if parent_groups else None,
+ parent_groups[-1][1] if parent_groups else layer_no)
+ if parent_groups:
+ parent_groups[-1][1] += 1
+ else:
+ layer_no += 1
+
+ if isinstance(gimp_layer, gimp.GroupLayer):
+ parent_groups.append([gimp_layer, 0])
+
+ os.rmdir(tempdir)
+
+ return img
+
+
+def register_load_handlers():
+ gimp.register_load_handler('file-openraster-load', 'ora', '')
+ pdb['gimp-register-file-handler-mime']('file-openraster-load', 'image/openraster')
+ pdb['gimp-register-thumbnail-loader']('file-openraster-load', 'file-openraster-load-thumb')
+
+def register_save_handlers():
+ gimp.register_save_handler('file-openraster-save', 'ora', '')
+
+register(
+ 'file-openraster-load-thumb', #name
+ 'loads a thumbnail from an OpenRaster (.ora) file', #description
+ 'loads a thumbnail from an OpenRaster (.ora) file',
+ 'Jon Nordby', #author
+ 'Jon Nordby', #copyright
+ '2009', #year
+ None,
+ None, #image type
+ [ #input args. Format (type, name, description, default [, extra])
+ (PF_STRING, 'filename', 'The name of the file to load', None),
+ (PF_INT, 'thumb-size', 'Preferred thumbnail size', None),
+ ],
+ [ #results. Format (type, name, description)
+ (PF_IMAGE, 'image', 'Thumbnail image'),
+ (PF_INT, 'image-width', 'Width of full-sized image'),
+ (PF_INT, 'image-height', 'Height of full-sized image')
+ ],
+ thumbnail_ora, #callback
+ run_mode_param = False
+)
+
+register(
+ 'file-openraster-save', #name
+ 'save an OpenRaster (.ora) file', #description
+ 'save an OpenRaster (.ora) file',
+ 'Jon Nordby', #author
+ 'Jon Nordby', #copyright
+ '2009', #year
+ 'OpenRaster',
+ '*',
+ [ #input args. Format (type, name, description, default [, extra])
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_STRING, "filename", "The name of the file", None),
+ (PF_STRING, "raw-filename", "The name of the file", None),
+ ],
+ [], #results. Format (type, name, description)
+ save_ora, #callback
+ on_query = register_save_handlers,
+ menu = '<Save>'
+)
+
+register(
+ 'file-openraster-load', #name
+ 'load an OpenRaster (.ora) file', #description
+ 'load an OpenRaster (.ora) file',
+ 'Jon Nordby', #author
+ 'Jon Nordby', #copyright
+ '2009', #year
+ 'OpenRaster',
+ None, #image type
+ [ #input args. Format (type, name, description, default [, extra])
+ (PF_STRING, 'filename', 'The name of the file to load', None),
+ (PF_STRING, 'raw-filename', 'The name entered', None),
+ ],
+ [(PF_IMAGE, 'image', 'Output image')], #results. Format (type, name, description)
+ load_ora, #callback
+ on_query = register_load_handlers,
+ menu = "<Load>",
+)
+
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/foggify.py b/plug-ins/pygimp/plug-ins/foggify.py
new file mode 100755
index 0000000..4964d8c
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/foggify.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+from gimpfu import *
+import time
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def foggify(img, layer, name, colour, turbulence, opacity):
+
+ gimp.context_push()
+ img.undo_group_start()
+
+ if img.base_type is RGB:
+ type = RGBA_IMAGE
+ else:
+ type = GRAYA_IMAGE
+ fog = gimp.Layer(img, name,
+ layer.width, layer.height, type, opacity, NORMAL_MODE)
+ fog.fill(FILL_TRANSPARENT)
+ img.insert_layer(fog)
+
+ gimp.set_background(colour)
+ pdb.gimp_edit_fill(fog, FILL_BACKGROUND)
+
+ # create a layer mask for the new layer
+ mask = fog.create_mask(0)
+ fog.add_mask(mask)
+
+ # add some clouds to the layer
+ pdb.plug_in_plasma(img, mask, int(time.time()), turbulence)
+
+ # apply the clouds to the layer
+ fog.remove_mask(MASK_APPLY)
+
+ img.undo_group_end()
+ gimp.context_pop()
+
+register(
+ "python-fu-foggify",
+ N_("Add a layer of fog"),
+ "Adds a layer of fog to the image.",
+ "James Henstridge",
+ "James Henstridge",
+ "1999,2007",
+ N_("_Fog..."),
+ "RGB*, GRAY*",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_STRING, "name", _("_Layer name"), _("Clouds")),
+ (PF_COLOUR, "colour", _("_Fog color"), (240, 180, 70)),
+ (PF_SLIDER, "turbulence", _("_Turbulence"), 1.0, (0, 7, 0.1)),
+ (PF_SLIDER, "opacity", _("Op_acity"), 100, (0, 100, 1)),
+ ],
+ [],
+ foggify,
+ menu="<Image>/Filters/Decor",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/gradients-save-as-css.py b/plug-ins/pygimp/plug-ins/gradients-save-as-css.py
new file mode 100755
index 0000000..44179e4
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/gradients-save-as-css.py
@@ -0,0 +1,104 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Allows saving (TODO: and loading) CSS gradient files
+# Copyright (C) 2011 João S. O. Bueno <gwidion@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/>.
+
+
+# Currently this exports all color segments as RGB linear centered segments.
+# TODO: Respect gradient alpha, off-center segments, different blending
+# functions and HSV colors
+
+from gimpfu import *
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+w3c_template = """background-image: linear-gradient(top, %s);\n"""
+moz_template = """background-image: -moz-linear-gradient(center top, %s);\n"""
+webkit_template = """background-image: -webkit-gradient(linear, """ \
+ """left top, left bottom, %s);\n"""
+
+color_to_html = lambda c: "rgb(%d,%d,%d)" % tuple(c)[:3]
+
+def format_text(text):
+ counter = 0
+ new_text = []
+ for token in text.split(","):
+ if counter + len(token) > 77:
+ token = "\n " + token
+ counter = 4
+ new_text.append(token)
+ if "\n" in token:
+ counter = len(token.rsplit("\n")[-1]) + 1
+ else:
+ counter += len(token) + 1
+
+ return ",".join(new_text)
+
+def gradient_css_save(gradient, file_name):
+ stops = []
+ wk_stops = []
+ n_segments = pdb.gimp_gradient_get_number_of_segments(gradient)
+ last_stop = None
+ for index in xrange(n_segments):
+ lcolor, lopacity = pdb.gimp_gradient_segment_get_left_color(
+ gradient,
+ index)
+ rcolor, ropacity = pdb.gimp_gradient_segment_get_right_color(
+ gradient,
+ index)
+ lpos = pdb.gimp_gradient_segment_get_left_pos(gradient, index)
+ rpos = pdb.gimp_gradient_segment_get_right_pos(gradient, index)
+
+ lstop = color_to_html(lcolor) + " %d%%" % int(100 * lpos)
+ wk_lstop = "color-stop(%.03f, %s)" %(lpos, color_to_html(lcolor))
+ if lstop != last_stop:
+ stops.append(lstop)
+ wk_stops.append(wk_lstop)
+
+ rstop = color_to_html(rcolor) + " %d%%" % int(100 * rpos)
+ wk_rstop = "color-stop(%.03f, %s)" %(rpos, color_to_html(rcolor))
+
+ stops.append(rstop)
+ wk_stops.append(wk_rstop)
+ last_stop = rstop
+
+ final_text = w3c_template % ", ".join(stops)
+ final_text += moz_template % ",".join(stops)
+ final_text += webkit_template % ",".join(wk_stops)
+
+ with open(file_name, "wt") as file_:
+ file_.write(format_text(final_text))
+
+register(
+ "gradient-save-as-css",
+ "Creates a new palette from a given gradient",
+ "palette_from_gradient (gradient, number, segment_colors) -> None",
+ "Joao S. O. Bueno",
+ "(c) GPL V3.0 or later",
+ "2011",
+ "Save as CSS...",
+ "",
+ [
+ (PF_GRADIENT, "gradient", N_("Gradient to use"),""),
+ (PF_FILENAME, "file_name", N_("File Name"), ""),
+ ],
+ [],
+ gradient_css_save,
+ menu="<Gradients>",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+main() \ No newline at end of file
diff --git a/plug-ins/pygimp/plug-ins/histogram-export.py b/plug-ins/pygimp/plug-ins/histogram-export.py
new file mode 100755
index 0000000..11da1ba
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/histogram-export.py
@@ -0,0 +1,114 @@
+#!/usr/bin/env python2
+#coding: utf-8
+
+#
+# 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/>.
+
+"""
+Exports the image histogram to a text file,
+so that it can be used by other programs
+and loaded into spreadsheets.
+
+The resulting file is a CSV file (Comma Separated
+Values), which can be imported
+directly in most spreadsheet programs.
+
+The first two collums are the bucket boundaries,
+followed by the selected columns. The histogram
+refers to the selected image area, and
+can use either Sample Average data or data
+from the current drawable only.;
+
+The output is in "weighted pixels" - meaning
+all fully transparent pixels are not counted.
+
+Check the gimp-histogram call
+"""
+
+
+from gimpfu import *
+import csv
+import gettext
+
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def histogram_export(img, drw, filename,
+ bucket_size, sample_average, output_format):
+ if sample_average:
+ new_img = pdb.gimp_image_duplicate(img)
+ drw = pdb.gimp_image_merge_visible_layers(new_img, CLIP_TO_IMAGE)
+ # TODO: grey images, alpha and non alpha images.
+ channels_txt = ["Value"]
+ channels_gimp = [HISTOGRAM_VALUE]
+ if drw.is_rgb:
+ channels_txt += ["Red", "Green", "Blue"]
+ channels_gimp += [HISTOGRAM_RED, HISTOGRAM_GREEN, HISTOGRAM_BLUE]
+ if drw.has_alpha:
+ channels_txt += ["Alpha"]
+ channels_gimp += [HISTOGRAM_ALPHA]
+ with open(filename, "wt") as hfile:
+ writer = csv.writer(hfile)
+ #headers:
+ writer.writerow(["Range start"] + channels_txt)
+
+ # FIXME: Will need a specialized 'range' for FP color numbers
+ bucket_size = int(bucket_size)
+ for start_range in range(0, 256, bucket_size):
+ row = [start_range]
+ for channel in channels_gimp:
+ result = pdb.gimp_histogram(
+ drw, channel,
+ start_range,
+ min(start_range + bucket_size - 1, 255)
+ )
+ if output_format == "pixel count":
+ count = result[4]
+ else:
+ count = (result[4] / result[3]) if result[3] else 0
+ if output_format == "percent":
+ count = "%.2f%%" % (count * 100)
+ row.append(str(count))
+ writer.writerow(row)
+ if sample_average:
+ pdb.gimp_image_delete(new_img)
+
+register(
+ "histogram-export",
+ N_("Exports the image histogram to a text file (CSV)"),
+ globals()["__doc__"], # This includes the docstring, on the top of the file
+ "João S. O. Bueno",
+ "João S. O. Bueno, 2014",
+ "2014",
+ N_("_Export histogram..."),
+ "*",
+ [(PF_IMAGE, "img", _("_Image"), None),
+ (PF_DRAWABLE, "drw", _("_Drawable"), None),
+ (PF_FILENAME, "filename", _("Histogram _File"), ""),
+ (PF_FLOAT, "bucket_size", _("_Bucket Size"), 1.0),
+ (PF_BOOL, "sample_average", _("Sample _Average"), False),
+ (PF_RADIO, "output_format", _("Output format"), "pixel count",
+ ((_("Pixel count"), "pixel count"),
+ (_("Normalized"), "normalized"),
+ (_("Percent"), "percent"),
+ )
+ )
+ ],
+ [],
+ histogram_export,
+ menu="<Image>/Colors/Info",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/palette-offset.py b/plug-ins/pygimp/plug-ins/palette-offset.py
new file mode 100644
index 0000000..8ba0bfe
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/palette-offset.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+# 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/>.
+
+from gimpfu import *
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def palette_offset(palette, amount):
+ #If palette is read only, work on a copy:
+ editable = pdb.gimp_palette_is_editable(palette)
+ if not editable:palette = pdb.gimp_palette_duplicate (palette)
+
+ num_colors = pdb.gimp_palette_get_info (palette)
+
+ tmp_entry_array = []
+ for i in xrange (num_colors):
+ tmp_entry_array.append ((pdb.gimp_palette_entry_get_name (palette, i),
+ pdb.gimp_palette_entry_get_color (palette, i)))
+ for i in xrange (num_colors):
+ target_index = i + amount
+ if target_index >= num_colors:
+ target_index -= num_colors
+ elif target_index < 0:
+ target_index += num_colors
+ pdb.gimp_palette_entry_set_name (palette, target_index, tmp_entry_array[i][0])
+ pdb.gimp_palette_entry_set_color (palette, target_index, tmp_entry_array[i][1])
+ return palette
+
+
+register(
+ "python-fu-palette-offset",
+ N_("Offset the colors in a palette"),
+ "palette_offset (palette, amount) -> modified_palette",
+ "Joao S. O. Bueno Calligaris, Carol Spears",
+ "(c) Joao S. O. Bueno Calligaris",
+ "2004, 2006",
+ N_("_Offset Palette..."),
+ "",
+ [
+ (PF_PALETTE, "palette", _("Palette"), ""),
+ (PF_INT, "amount", _("Off_set"), 1),
+ ],
+ [(PF_PALETTE, "new-palette", "Result")],
+ palette_offset,
+ menu="<Palettes>",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main ()
diff --git a/plug-ins/pygimp/plug-ins/palette-sort.py b/plug-ins/pygimp/plug-ins/palette-sort.py
new file mode 100644
index 0000000..c21b8ad
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/palette-sort.py
@@ -0,0 +1,357 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+#
+# 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/>.
+
+from gimpfu import *
+# little known, colorsys is part of Python's stdlib
+from colorsys import rgb_to_yiq
+from textwrap import dedent
+from random import randint
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+AVAILABLE_CHANNELS = (_("Red"), _("Green"), _("Blue"),
+ _("Luma (Y)"),
+ _("Hue"), _("Saturation"), _("Value"),
+ _("Saturation (HSL)"), _("Lightness (HSL)"),
+ _("Index"),
+ _("Random"))
+
+GRAIN_SCALE = (1.0, 1.0 , 1.0,
+ 1.0,
+ 360., 100., 100.,
+ 100., 100.,
+ 16384.,
+ float(0x7ffffff),
+ 100., 256., 256.,
+ 256., 360.,)
+
+SELECT_ALL = 0
+SELECT_SLICE = 1
+SELECT_AUTOSLICE = 2
+SELECT_PARTITIONED = 3
+SELECTIONS = (SELECT_ALL, SELECT_SLICE, SELECT_AUTOSLICE, SELECT_PARTITIONED)
+
+
+def noop(v, i):
+ return v
+
+
+def to_hsv(v, i):
+ return v.to_hsv()
+
+
+def to_hsl(v, i):
+ return v.to_hsl()
+
+
+def to_yiq(v, i):
+ return rgb_to_yiq(*v[:-1])
+
+
+def to_index(v, i):
+ return (i,)
+
+def to_random(v, i):
+ return (randint(0, 0x7fffffff),)
+
+
+channel_getters = [ (noop, 0), (noop, 1), (noop, 2),
+ (to_yiq, 0),
+ (to_hsv, 0), (to_hsv, 1), (to_hsv, 2),
+ (to_hsl, 1), (to_hsl, 2),
+ (to_index, 0),
+ (to_random, 0)]
+
+
+try:
+ from colormath.color_objects import RGBColor, LabColor, LCHabColor
+ AVAILABLE_CHANNELS = AVAILABLE_CHANNELS + (_("Lightness (LAB)"),
+ _("A-color"), _("B-color"),
+ _("Chroma (LCHab)"),
+ _("Hue (LCHab)"))
+ to_lab = lambda v,i: RGBColor(*v[:-1]).convert_to('LAB').get_value_tuple()
+ to_lchab = (lambda v,i:
+ RGBColor(*v[:-1]).convert_to('LCHab').get_value_tuple())
+ channel_getters.extend([(to_lab, 0), (to_lab, 1), (to_lab, 2),
+ (to_lchab, 1), (to_lchab, 2)])
+except ImportError:
+ pass
+
+
+def parse_slice(s, numcolors):
+ """Parse a slice spec and return (start, nrows, length)
+ All items are optional. Omitting them makes the largest possible selection that
+ exactly fits the other items.
+
+ start:nrows,length
+
+
+ '' selects all items, as does ':'
+ ':4,' makes a 4-row selection out of all colors (length auto-determined)
+ ':4' also.
+ ':1,4' selects the first 4 colors
+ ':,4' selects rows of 4 colors (nrows auto-determined)
+ ':4,4' selects 4 rows of 4 colors
+ '4:' selects a single row of all colors after 4, inclusive.
+ '4:,4' selects rows of 4 colors, starting at 4 (nrows auto-determined)
+ '4:4,4' selects 4 rows of 4 colors (16 colors total), beginning at index 4.
+ '4' is illegal (ambiguous)
+
+
+ In general, slices are comparable to a numpy sub-array.
+ 'start at element START, with shape (NROWS, LENGTH)'
+
+ """
+ s = s.strip()
+
+ def notunderstood():
+ raise ValueError('Slice %r not understood. Should be in format'
+ ' START?:NROWS?,ROWLENGTH? eg. "0:4,16".' % s)
+ def _int(v):
+ try:
+ return int(v)
+ except ValueError:
+ notunderstood()
+ if s in ('', ':', ':,'):
+ return 0, 1, numcolors # entire palette, one row
+ if s.count(':') != 1:
+ notunderstood()
+ rowpos = s.find(':')
+ start = 0
+ if rowpos > 0:
+ start = _int(s[:rowpos])
+ numcolors -= start
+ nrows = 1
+ if ',' in s:
+ commapos = s.find(',')
+ nrows = s[rowpos+1:commapos]
+ length = s[commapos+1:]
+ if not nrows:
+ if not length:
+ notunderstood()
+ else:
+ length = _int(length)
+ if length == 0:
+ notunderstood()
+ nrows = numcolors // length
+ if numcolors % length:
+ nrows = -nrows
+ elif not length:
+ nrows = _int(nrows)
+ if nrows == 0:
+ notunderstood()
+ length = numcolors // nrows
+ if numcolors % nrows:
+ length = -length
+ else:
+ nrows = _int(nrows)
+ if nrows == 0:
+ notunderstood()
+ length = _int(length)
+ if length == 0:
+ notunderstood()
+ else:
+ nrows = _int(s[rowpos+1:])
+ if nrows == 0:
+ notunderstood()
+ length = numcolors // nrows
+ if numcolors % nrows:
+ length = -length
+ return start, nrows, length
+
+
+def quantization_grain(channel, g):
+ "Given a channel and a quantization, return the size of a quantization grain"
+ g = max(1.0, g)
+ if g <= 1.0:
+ g = 0.00001
+ else:
+ g = max(0.00001, GRAIN_SCALE[channel] / g)
+ return g
+
+
+def palette_sort(palette, selection, slice_expr, channel1, ascending1,
+ channel2, ascending2, quantize, pchannel, pquantize):
+
+ grain1 = quantization_grain(channel1, quantize)
+ grain2 = quantization_grain(channel2, quantize)
+ pgrain = quantization_grain(pchannel, pquantize)
+
+ #If palette is read only, work on a copy:
+ editable = pdb.gimp_palette_is_editable(palette)
+ if not editable:
+ palette = pdb.gimp_palette_duplicate (palette)
+
+ num_colors = pdb.gimp_palette_get_info (palette)
+
+ start, nrows, length = None, None, None
+ if selection == SELECT_AUTOSLICE:
+ def find_index(color, startindex=0):
+ for i in range(startindex, num_colors):
+ c = pdb.gimp_palette_entry_get_color (palette, i)
+ if c == color:
+ return i
+ return None
+ def hexcolor(c):
+ return "#%02x%02x%02x" % tuple(c[:-1])
+ fg = pdb.gimp_context_get_foreground()
+ bg = pdb.gimp_context_get_background()
+ start = find_index(fg)
+ end = find_index(bg)
+ if start is None:
+ raise ValueError("Couldn't find foreground color %r in palette" % list(fg))
+ if end is None:
+ raise ValueError("Couldn't find background color %r in palette" % list(bg))
+ if find_index(fg, start + 1):
+ raise ValueError('Autoslice cannot be used when more than one'
+ ' instance of an endpoint'
+ ' (%s) is present' % hexcolor(fg))
+ if find_index(bg, end + 1):
+ raise ValueError('Autoslice cannot be used when more than one'
+ ' instance of an endpoint'
+ ' (%s) is present' % hexcolor(bg))
+ if start > end:
+ end, start = start, end
+ length = (end - start) + 1
+ try:
+ _, nrows, _ = parse_slice(slice_expr, length)
+ nrows = abs(nrows)
+ if length % nrows:
+ raise ValueError('Total length %d not evenly divisible'
+ ' by number of rows %d' % (length, nrows))
+ length /= nrows
+ except ValueError:
+ # bad expression is okay here, just assume one row
+ nrows = 1
+ # remaining behaviour is implemented by SELECT_SLICE 'inheritance'.
+ selection= SELECT_SLICE
+ elif selection in (SELECT_SLICE, SELECT_PARTITIONED):
+ start, nrows, length = parse_slice(slice_expr, num_colors)
+
+ channels_getter_1, channel_index = channel_getters[channel1]
+ channels_getter_2, channel2_index = channel_getters[channel2]
+
+ def get_colors(start, end):
+ result = []
+ for i in range(start, end):
+ entry = (pdb.gimp_palette_entry_get_name (palette, i),
+ pdb.gimp_palette_entry_get_color (palette, i))
+ index1 = channels_getter_1(entry[1], i)[channel_index]
+ index2 = channels_getter_2(entry[1], i)[channel2_index]
+ index = ((index1 - (index1 % grain1)) * (1 if ascending1 else -1),
+ (index2 - (index2 % grain2)) * (1 if ascending2 else -1)
+ )
+ result.append((index, entry))
+ return result
+
+ if selection == SELECT_ALL:
+ entry_list = get_colors(0, num_colors)
+ entry_list.sort(key=lambda v:v[0])
+ for i in range(num_colors):
+ pdb.gimp_palette_entry_set_name (palette, i, entry_list[i][1][0])
+ pdb.gimp_palette_entry_set_color (palette, i, entry_list[i][1][1])
+
+ elif selection == SELECT_PARTITIONED:
+ if num_colors < (start + length * nrows) - 1:
+ raise ValueError('Not enough entries in palette to '
+ 'sort complete rows! Got %d, expected >=%d' %
+ (num_colors, start + length * nrows))
+ pchannels_getter, pchannel_index = channel_getters[pchannel]
+ for row in range(nrows):
+ partition_spans = [1]
+ rowstart = start + (row * length)
+ old_color = pdb.gimp_palette_entry_get_color (palette,
+ rowstart)
+ old_partition = pchannels_getter(old_color, rowstart)[pchannel_index]
+ old_partition = old_partition - (old_partition % pgrain)
+ for i in range(rowstart + 1, rowstart + length):
+ this_color = pdb.gimp_palette_entry_get_color (palette, i)
+ this_partition = pchannels_getter(this_color, i)[pchannel_index]
+ this_partition = this_partition - (this_partition % pgrain)
+ if this_partition == old_partition:
+ partition_spans[-1] += 1
+ else:
+ partition_spans.append(1)
+ old_partition = this_partition
+ base = rowstart
+ for size in partition_spans:
+ palette_sort(palette, SELECT_SLICE, '%d:1,%d' % (base, size),
+ channel1, ascending1, channel2, ascending2,
+ quantize, 0, 1.0)
+ base += size
+ else:
+ stride = length
+ if num_colors < (start + stride * nrows) - 1:
+ raise ValueError('Not enough entries in palette to sort '
+ 'complete rows! Got %d, expected >=%d' %
+ (num_colors, start + stride * nrows))
+
+ for row_start in range(start, start + stride * nrows, stride):
+ sublist = get_colors(row_start, row_start + stride)
+ sublist.sort(key=lambda v:v[0])
+ for i, entry in zip(range(row_start, row_start + stride), sublist):
+ pdb.gimp_palette_entry_set_name (palette, i, entry[1][0])
+ pdb.gimp_palette_entry_set_color (palette, i, entry[1][1])
+
+ return palette
+
+register(
+ "python-fu-palette-sort",
+ N_("Sort the colors in a palette"),
+ # FIXME: Write humanly readable help -
+ # (I can't figure out what the plugin does, or how to use the parameters after
+ # David's enhancements even looking at the code -
+ # let alone someone just using GIMP (JS) )
+ dedent("""\
+ palette_sort (palette, selection, slice_expr, channel,
+ channel2, quantize, ascending, pchannel, pquantize) -> new_palette
+ Sorts a palette, or part of a palette, using several options.
+ One can select two color channels over which to sort,
+ and several auxiliary parameters create a 2D sorted
+ palette with sorted rows, among other things.
+ One can optionally install colormath
+ (https://pypi.python.org/pypi/colormath/1.0.8)
+ to GIMP's Python to get even more channels to choose from.
+ """),
+ "João S. O. Bueno, Carol Spears, David Gowers",
+ "João S. O. Bueno, Carol Spears, David Gowers",
+ "2006-2014",
+ N_("_Sort Palette..."),
+ "",
+ [
+ (PF_PALETTE, "palette", _("Palette"), ""),
+ (PF_OPTION, "selections", _("Se_lections"), SELECT_ALL,
+ (_("All"), _("Slice / Array"), _("Autoslice (fg->bg)"),
+ _("Partitioned"))),
+ (PF_STRING, "slice-expr", _("Slice _expression"), ''),
+ (PF_OPTION, "channel1", _("Channel to _sort"), 3,
+ AVAILABLE_CHANNELS),
+ (PF_BOOL, "ascending1", _("_Ascending"), True),
+ (PF_OPTION, "channel2", _("Secondary Channel to s_ort"), 5,
+ AVAILABLE_CHANNELS),
+ (PF_BOOL, "ascending2", _("_Ascending"), True),
+ (PF_FLOAT, "quantize", _("_Quantization"), 0.0),
+ (PF_OPTION, "pchannel", _("_Partitioning channel"), 3,
+ AVAILABLE_CHANNELS),
+ (PF_FLOAT, "pquantize", _("Partition q_uantization"), 0.0),
+ ],
+ [],
+ palette_sort,
+ menu="<Palettes>",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main ()
diff --git a/plug-ins/pygimp/plug-ins/palette-to-gradient.py b/plug-ins/pygimp/plug-ins/palette-to-gradient.py
new file mode 100644
index 0000000..9b2da49
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/palette-to-gradient.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python2
+#
+# 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/>.
+
+from gimpfu import *
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def make_gradient(palette, num_segments, num_colors):
+ gradient = pdb.gimp_gradient_new(palette)
+
+ if (num_segments > 1):
+ pdb.gimp_gradient_segment_range_split_uniform(gradient, 0, -1,
+ num_segments)
+
+ for color_number in range(0,num_segments):
+ if (color_number == num_colors-1):color_number_next = 0
+ else: color_number_next = color_number + 1
+ color_left = pdb.gimp_palette_entry_get_color(palette,
+ color_number)
+ color_right = pdb.gimp_palette_entry_get_color(palette,
+ color_number_next)
+ pdb.gimp_gradient_segment_set_left_color(gradient,
+ color_number, color_left,
+ 100.0)
+ pdb.gimp_gradient_segment_set_right_color(gradient,
+ color_number, color_right,
+ 100.0)
+ pdb.gimp_context_set_gradient(gradient)
+ return gradient
+
+
+def palette_to_gradient_repeating(palette):
+ num_colors = pdb.gimp_palette_get_info(palette)
+ num_segments = num_colors
+ return make_gradient(palette, num_segments, num_colors)
+
+
+register(
+ "python-fu-palette-to-gradient-repeating",
+ N_("Create a repeating gradient using colors from the palette"),
+ "Create a new repeating gradient using colors from the palette.",
+ "Carol Spears, reproduced from previous work by Adrian Likins and Jeff Trefftz",
+ "Carol Spears",
+ "2006",
+ N_("Palette to _Repeating Gradient"),
+ "",
+ [(PF_PALETTE, "palette", _("Palette"), "")],
+ [(PF_GRADIENT, "new-gradient", "Result")],
+ palette_to_gradient_repeating,
+ menu="<Palettes>",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+
+def palette_to_gradient(palette):
+ num_colors = pdb.gimp_palette_get_info(palette)
+ num_segments = num_colors - 1
+ return make_gradient(palette, num_segments, num_colors)
+
+register(
+ "python-fu-palette-to-gradient",
+ N_("Create a gradient using colors from the palette"),
+ "Create a new gradient using colors from the palette.",
+ "Carol Spears, reproduced from previous work by Adrian Likins and Jeff Trefftz",
+ "Carol Spears",
+ "2006",
+ N_("Palette to _Gradient"),
+ "",
+ [(PF_PALETTE, "palette", _("Palette"), "")],
+ [(PF_GRADIENT, "new-gradient", "Result")],
+ palette_to_gradient,
+ menu="<Palettes>",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main ()
diff --git a/plug-ins/pygimp/plug-ins/py-slice.py b/plug-ins/pygimp/plug-ins/py-slice.py
new file mode 100755
index 0000000..90159aa
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/py-slice.py
@@ -0,0 +1,457 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+
+#Copyright (c) Manish Singh
+#javascript animation support by Joao S. O. Bueno Calligaris (2004)
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 2003, 2005 Manish Singh <yosh@gimp.org>
+#
+# 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/>.
+
+# (c) 2003 Manish Singh.
+#"Guillotine implemented ala python, with html output
+# (based on perlotine by Seth Burgess)",
+# Modified by João S. O. Bueno Calligaris to allow dhtml animations (2005)
+
+import os
+
+from gimpfu import *
+import os.path
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def pyslice(image, drawable, save_path, html_filename,
+ image_basename, image_extension, separate,
+ image_path, cellspacing, animate, skip_caps):
+
+ cellspacing = int (cellspacing)
+
+ if animate:
+ count = 0
+ drw = []
+ #image.layers is a reversed list of the layers on the image
+ #so, count indexes from number of layers to 0.
+ for i in xrange (len (image.layers) -1, -1, -1):
+ if image.layers[i].visible:
+ drw.append(image.layers[i])
+ count += 1
+ if count == 3:
+ break
+
+
+ vert, horz = get_guides(image)
+
+ if len(vert) == 0 and len(horz) == 0:
+ return
+
+ gimp.progress_init(_("Slice"))
+ progress_increment = 1 / ((len(horz) + 1) * (len(vert) + 1))
+ progress = 0.0
+
+ def check_path(path):
+ path = os.path.abspath(path)
+
+ if not os.path.exists(path):
+ os.mkdir(path)
+
+ return path
+
+ save_path = check_path(save_path)
+
+ if not os.path.isdir(save_path):
+ save_path = os.path.dirname(save_path)
+
+ if separate:
+ image_relative_path = image_path
+ if not image_relative_path.endswith("/"):
+ image_relative_path += "/"
+ image_path = check_path(os.path.join(save_path, image_path))
+ else:
+ image_relative_path = ''
+ image_path = save_path
+
+ tw = TableWriter(os.path.join(save_path, html_filename),
+ cellspacing=cellspacing, animate=animate)
+
+ top = 0
+
+ for i in range(0, len(horz) + 1):
+ if i == len(horz):
+ bottom = image.height
+ else:
+ bottom = image.get_guide_position(horz[i])
+
+ tw.row_start()
+
+ left = 0
+
+ for j in range(0, len(vert) + 1):
+ if j == len(vert):
+ right = image.width
+ else:
+ right = image.get_guide_position(vert[j])
+ if (skip_caps and
+ (
+ (len(horz) >= 2 and (i == 0 or i == len(horz) )) or
+ (len(vert) >= 2 and (j == 0 or j == len(vert) ))
+ )
+ ):
+ skip_stub = True
+ else:
+ skip_stub = False
+
+ if (not animate or skip_stub):
+ src = (image_relative_path +
+ slice (image, None, image_path,
+ image_basename, image_extension,
+ left, right, top, bottom, i, j, ""))
+ else:
+ src = []
+ for layer, postfix in zip (drw, ("", "hover", "clicked")):
+ src.append (image_relative_path +
+ slice(image, layer, image_path,
+ image_basename, image_extension,
+ left, right, top, bottom, i, j, postfix))
+
+ tw.cell(src, right - left, bottom - top, i, j, skip_stub)
+
+ left = right + cellspacing
+
+ progress += progress_increment
+ gimp.progress_update(progress)
+
+ tw.row_end()
+
+ top = bottom + cellspacing
+
+ tw.close()
+
+def slice(image, drawable, image_path, image_basename, image_extension,
+ left, right, top, bottom, i, j, postfix):
+ if postfix:
+ postfix = "_" + postfix
+ src = "%s_%d_%d%s.%s" % (image_basename, i, j, postfix, image_extension)
+ filename = os.path.join(image_path, src)
+
+ if not drawable:
+ temp_image = image.duplicate()
+ temp_drawable = temp_image.active_layer
+ else:
+ if image.base_type == INDEXED:
+ #gimp_layer_new_from_drawable doesn't work for indexed images.
+ #(no colormap on new images)
+ original_active = image.active_layer
+ image.active_layer = drawable
+ temp_image = image.duplicate()
+ temp_drawable = temp_image.active_layer
+ image.active_layer = original_active
+ temp_image.disable_undo()
+ #remove all layers but the intended one
+ while len (temp_image.layers) > 1:
+ if temp_image.layers[0] != temp_drawable:
+ pdb.gimp_image_remove_layer (temp_image, temp_image.layers[0])
+ else:
+ pdb.gimp_image_remove_layer (temp_image, temp_image.layers[1])
+ else:
+ temp_image = pdb.gimp_image_new (drawable.width, drawable.height,
+ image.base_type)
+ temp_drawable = pdb.gimp_layer_new_from_drawable (drawable, temp_image)
+ temp_image.insert_layer (temp_drawable)
+
+ temp_image.disable_undo()
+ temp_image.crop(right - left, bottom - top, left, top)
+ if image_extension == "gif" and image.base_type == RGB:
+ pdb.gimp_image_convert_indexed (temp_image, CONVERT_DITHER_NONE,
+ CONVERT_PALETTE_GENERATE, 255,
+ True, False, False)
+ if image_extension == "jpg" and image.base_type == INDEXED:
+ pdb.gimp_image_convert_rgb (temp_image)
+
+ pdb.gimp_file_save(temp_image, temp_drawable, filename, filename)
+
+ gimp.delete(temp_image)
+ return src
+
+class GuideIter:
+ def __init__(self, image):
+ self.image = image
+ self.guide = 0
+
+ def __iter__(self):
+ return iter(self.next_guide, 0)
+
+ def next_guide(self):
+ self.guide = self.image.find_next_guide(self.guide)
+ return self.guide
+
+def get_guides(image):
+ vguides = []
+ hguides = []
+
+ for guide in GuideIter(image):
+ orientation = image.get_guide_orientation(guide)
+
+ guide_position = image.get_guide_position(guide)
+
+ if guide_position > 0:
+ if orientation == ORIENTATION_VERTICAL:
+ if guide_position < image.width:
+ vguides.append((guide_position, guide))
+ elif orientation == ORIENTATION_HORIZONTAL:
+ if guide_position < image.height:
+ hguides.append((guide_position, guide))
+
+ def position_sort(x, y):
+ return cmp(x[0], y[0])
+
+ vguides.sort(position_sort)
+ hguides.sort(position_sort)
+
+ vguides = [g[1] for g in vguides]
+ hguides = [g[1] for g in hguides]
+
+ return vguides, hguides
+
+class TableWriter:
+ def __init__(self, filename, cellpadding=0, cellspacing=0, border=0,
+ animate=False):
+
+ self.filename = filename
+ self.table_attrs = {}
+
+ #Hellraisen IE 6 doesn't support CSS for table control.
+ self.table_attrs['cellpadding'] = cellpadding
+ self.table_attrs['cellspacing'] = cellspacing
+ self.table_attrs['border'] = border
+
+ self.image_prefix = os.path.basename (filename)
+ self.image_prefix = self.image_prefix.split(".")[0]
+ self.image_prefix = self.image_prefix.replace ("-", "_")
+ self.image_prefix = self.image_prefix.replace (" ", "_")
+
+
+ if animate:
+ self.animate = True
+ self.images = []
+ else:
+ self.animate = False
+
+ if os.path.exists (filename):
+ #The plug-in is running to overwrite a previous
+ #version of the file. This will parse the href targets already
+ #in the file to preserve them.
+ self.urls = self.parse_urls ()
+ else:
+ self.urls = []
+
+ self.url_index = 0
+
+ self.html = open(filename, 'wt')
+ self.open()
+
+ def next_url (self):
+ if self.url_index < len (self.urls):
+ self.url_index += 1
+ return self.urls [self.url_index - 1]
+ else:
+ #Default url to use in the anchor tags:
+ return ("#")
+
+ def write(self, s, vals=None):
+ if vals:
+ s = s % vals
+
+ self.html.write(s + '\n')
+
+ def open(self):
+ out = '''<!--HTML SNIPPET GENERATED BY GIMP
+
+WARNING!! This is NOT a fully valid HTML document, it is rather a piece of
+HTML generated by GIMP's py-slice plugin that should be embedded in an HTML
+or XHTML document to be valid.
+
+Replace the href targets in the anchor (<a >) for your URLS to have it working
+as a menu.
+ -->\n'''
+ out += '<table'
+
+ for attr, value in self.table_attrs.iteritems():
+ out += ' %s="%s"' % (attr, value)
+
+ out += '>'
+
+ self.write(out)
+
+ def close(self):
+ self.write('</table>\n')
+ prefix = self.image_prefix
+ if self.animate:
+ out = """
+<script language="javascript" type="text/javascript">
+/* Made with GIMP */
+
+/* Preload images: */
+ images_%s = new Array();
+ \n""" % prefix
+ for image in self.images:
+ for type_ in ("plain", "hover", "clicked"):
+ if image.has_key(type_):
+ image_index = ("%d_%d_%s" %
+ (image["index"][0],
+ image["index"][1], type_))
+ out += (" images_%s[\"%s\"] = new Image();\n" %
+ (prefix, image_index))
+ out += (" images_%s[\"%s\"].src = \"%s\";\n" %
+ (prefix, image_index, image[type_]))
+
+ out+= """
+function exchange (image, images_array_name, event)
+ {
+ name = image.name;
+ images = eval (images_array_name);
+
+ switch (event)
+ {
+ case 0:
+ image.src = images[name + "_plain"].src;
+ break;
+ case 1:
+ image.src = images[name + "_hover"].src;
+ break;
+ case 2:
+ image.src = images[name + "_clicked"].src;
+ break;
+ case 3:
+ image.src = images[name + "_hover"].src;
+ break;
+ }
+
+ }
+</script>
+<!--
+End of the part generated by GIMP
+-->
+"""
+ self.write (out)
+
+
+ def row_start(self):
+ self.write(' <tr>')
+
+ def row_end(self):
+ self.write('</tr>\n')
+
+ def cell(self, src, width, height, row=0, col=0, skip_stub = False):
+ if isinstance (src, list):
+ prefix = "images_%s" % self.image_prefix
+ self.images.append ({"index" : (row, col), "plain" : src[0]})
+
+ out = (' <td><a href="%s"><img alt="" src="%s" ' +
+ 'style="width: %dpx; height: %dpx; border-width: 0px" \n') %\
+ (self.next_url(), src[0], width, height)
+ out += 'name="%d_%d" \n' % (row, col)
+ if len(src) >= 2:
+ self.images[-1]["hover"] = src [1]
+ out += """ onmouseout="exchange(this, '%s', 0);"\n""" % \
+ prefix
+ out += """ onmouseover="exchange(this, '%s', 1);"\n""" % \
+ prefix
+ if len(src) >= 3:
+ self.images[-1]["clicked"] = src [2]
+ out += """ onmousedown="exchange(this, '%s', 2);"\n""" % \
+ prefix
+ out += """ onmouseup="exchange(this, '%s', 3);"\n""" % \
+ prefix
+
+
+
+ out += "/></a></td>\n"
+
+ else:
+ if skip_stub:
+ out = (' <td><img alt=" " src="%s" style="width: %dpx; ' +
+ ' height: %dpx; border-width: 0px;"></td>') % \
+ (src, width, height)
+ else:
+ out = (' <td><a href="#"><img alt=" " src="%s" ' +
+ ' style="width: %dpx; height: %dpx; border-width: 0px;">' +
+ '</a></td>') % (src, width, height)
+ self.write(out)
+ def parse_urls (self):
+ """
+ This will parse any url targets in the href="XX" fields
+ of the given file and return then as a list
+ """
+ import re
+ url_list = []
+ try:
+ html_file = open (self.filename)
+
+ # Regular expression to pick everything up to the next
+ # doublequote character after finding the sequence 'href="'.
+ # The found sequences will be returned as a list by the
+ # "findall" method.
+ expr = re.compile (r"""href\=\"([^\"]*?)\"""")
+ url_list = expr.findall (html_file.read (2 ** 18))
+ html_file.close()
+
+ except:
+ # silently ignore any errors parsing this. The file being
+ # overwritten may not be a file created by py-slice.
+ pass
+
+ return url_list
+
+
+register(
+ "python-fu-slice",
+ # table snippet means a small piece of HTML code here
+ N_("Cuts an image along its guides, creates images and a HTML table snippet"),
+ """Add guides to an image. Then run this. It will cut along the guides,
+ and give you the html to reassemble the resulting images. If you
+ choose to generate javascript for onmouseover and clicked events, it
+ will use the lower three visible layers on the image for normal,
+ onmouseover and clicked states, in that order. If skip caps is
+ enabled, table cells on the edge of the table won't become animated,
+ and its images will be taken from the active layer.""",
+ "Manish Singh",
+ "Manish Singh",
+ "2003",
+ _("_Slice..."),
+ "*",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_DIRNAME, "save-path", _("Path for HTML export"), os.getcwd()),
+ (PF_STRING, "html-filename", _("Filename for export"), "slice.html"),
+ (PF_STRING, "image-basename", _("Image name prefix"), "slice"),
+ (PF_RADIO, "image-extension", _("Image format"), "gif", (("gif", "gif"), ("jpg", "jpg"), ("png", "png"))),
+ (PF_TOGGLE, "separate-image-dir", _("Separate image folder"),
+ False),
+ (PF_STRING, "relative-image-path", _("Folder for image export"), "images"),
+ (PF_SPINNER, "cellspacing", _("Space between table elements"), 0,
+ (0,15,1)),
+ (PF_TOGGLE, "animate", _("Javascript for onmouseover and clicked"),
+ False),
+ # table caps are table cells on the edge of the table
+ (PF_TOGGLE, "skip-caps", _("Skip animation for table caps"), True)
+ ],
+ [],
+ pyslice,
+ menu="<Image>/Filters/Web",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/pyconsole.py b/plug-ins/pygimp/plug-ins/pyconsole.py
new file mode 100644
index 0000000..ee096d5
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/pyconsole.py
@@ -0,0 +1,749 @@
+#
+# pyconsole.py
+#
+# Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
+# Portions of code by Geoffrey French.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public version 2.1 as
+# published by the Free Software Foundation.
+#
+# See COPYING.lib file that comes with this distribution for full text
+# of the license.
+#
+
+# This module 'runs' python interpreter in a TextView widget.
+# The main class is Console, usage is:
+# Console(locals=None, banner=None, completer=None, use_rlcompleter=True, start_script='') -
+# it creates the widget and 'starts' interactive session; see the end
+# of this file. If start_script is not empty, it pastes it as it was
+# entered from keyboard.
+#
+# Console has "command" signal which is emitted when code is about to
+# be executed. You may connect to it using console.connect or
+# console.connect_after to get your callback ran before or after the
+# code is executed.
+#
+# To modify output appearance, set attributes of console.stdout_tag and
+# console.stderr_tag.
+#
+# Console may subclass a type other than gtk.TextView, to allow syntax
+# highlighting and stuff,
+# e.g.:
+# console_type = pyconsole.ConsoleType(moo.edit.TextView)
+# console = console_type(use_rlcompleter=False, start_script="import moo\nimport gtk\n")
+#
+# This widget is not a replacement for real terminal with python running
+# inside: GtkTextView is not a terminal.
+# The use case is: you have a python program, you create this widget,
+# and inspect your program interiors.
+
+import gtk
+import gtk.gdk as gdk
+import gobject
+import pango
+import gtk.keysyms as _keys
+import code
+import sys
+import keyword
+import re
+
+# commonprefix() from posixpath
+def _commonprefix(m):
+ "Given a list of pathnames, returns the longest common leading component"
+ if not m: return ''
+ prefix = m[0]
+ for item in m:
+ for i in range(len(prefix)):
+ if prefix[:i+1] != item[:i+1]:
+ prefix = prefix[:i]
+ if i == 0:
+ return ''
+ break
+ return prefix
+
+class _ReadLine(object):
+
+ class Output(object):
+ def __init__(self, console, tag_name):
+ object.__init__(self)
+ self.buffer = console.get_buffer()
+ self.tag_name = tag_name
+ def write(self, text):
+ pos = self.buffer.get_iter_at_mark(self.buffer.get_insert())
+ self.buffer.insert_with_tags_by_name(pos, text, self.tag_name)
+
+ class History(object):
+ def __init__(self):
+ object.__init__(self)
+ self.items = ['']
+ self.ptr = 0
+ self.edited = {}
+
+ def commit(self, text):
+ if text and self.items[-1] != text:
+ self.items.append(text)
+ self.ptr = 0
+ self.edited = {}
+
+ def get(self, dir, text):
+ if len(self.items) == 1:
+ return None
+
+ if text != self.items[self.ptr]:
+ self.edited[self.ptr] = text
+ elif self.edited.has_key(self.ptr):
+ del self.edited[self.ptr]
+
+ self.ptr = self.ptr + dir
+ if self.ptr >= len(self.items):
+ self.ptr = 0
+ elif self.ptr < 0:
+ self.ptr = len(self.items) - 1
+
+ try:
+ return self.edited[self.ptr]
+ except KeyError:
+ return self.items[self.ptr]
+
+ def __init__(self, quit_func=None):
+ object.__init__(self)
+
+ self.quit_func = quit_func
+
+ self.set_wrap_mode(gtk.WRAP_CHAR)
+ self.modify_font(pango.FontDescription("Monospace"))
+
+ self.buffer = self.get_buffer()
+ self.buffer.connect("insert-text", self.on_buf_insert)
+ self.buffer.connect("delete-range", self.on_buf_delete)
+ self.buffer.connect("mark-set", self.on_buf_mark_set)
+ self.do_insert = False
+ self.do_delete = False
+
+ self.stdout_tag = self.buffer.create_tag("stdout", foreground="#006000")
+ self.stderr_tag = self.buffer.create_tag("stderr", foreground="#B00000")
+ self._stdout = _ReadLine.Output(self, "stdout")
+ self._stderr = _ReadLine.Output(self, "stderr")
+
+ self.cursor = self.buffer.create_mark("cursor",
+ self.buffer.get_start_iter(),
+ False)
+ insert = self.buffer.get_insert()
+ self.cursor.set_visible(True)
+ insert.set_visible(False)
+
+ self.ps = ''
+ self.in_raw_input = False
+ self.in_modal_raw_input = False
+ self.run_on_raw_input = None
+ self.tab_pressed = 0
+ self.history = _ReadLine.History()
+ self.nonword_re = re.compile("[^\w\._]")
+
+ def freeze_undo(self):
+ try: self.begin_not_undoable_action()
+ except: pass
+
+ def thaw_undo(self):
+ try: self.end_not_undoable_action()
+ except: pass
+
+ def raw_input(self, ps=None):
+ '''Show prompt 'ps' and enter input mode until the current input
+ is committed.'''
+
+ if ps:
+ self.ps = ps
+ else:
+ self.ps = ''
+
+ iter = self.buffer.get_iter_at_mark(self.buffer.get_insert())
+
+ if ps:
+ self.freeze_undo()
+ self.buffer.insert(iter, self.ps)
+ self.thaw_undo()
+
+ self.__move_cursor_to(iter)
+ self.scroll_to_mark(self.cursor, 0.2)
+
+ self.in_raw_input = True
+
+ if self.run_on_raw_input:
+ run_now = self.run_on_raw_input
+ self.run_on_raw_input = None
+ self.buffer.insert_at_cursor(run_now + '\n')
+
+ def modal_raw_input(self, text):
+ '''Starts raw input in modal mode. The event loop is spinned until
+ the input is committed. Returns the text entered after the prompt.'''
+ orig_ps = self.ps
+
+ self.raw_input(text)
+ self.in_modal_raw_input = True
+
+ while self.in_modal_raw_input:
+ gtk.main_iteration()
+
+ self.ps = orig_ps
+ self.in_modal_raw_input = False
+ self.in_raw_input = False
+
+ return self.modal_raw_input_result
+
+ def modal_input(self, text):
+ return eval(self.modal_raw_input(text))
+
+ # Each time the insert mark is modified, move the cursor to it.
+ def on_buf_mark_set(self, buffer, iter, mark):
+ if mark is not buffer.get_insert():
+ return
+ start = self.__get_start()
+ end = self.__get_end()
+ if iter.compare(self.__get_start()) >= 0 and \
+ iter.compare(self.__get_end()) <= 0:
+ buffer.move_mark_by_name("cursor", iter)
+ self.scroll_to_mark(self.cursor, 0.2)
+
+ def __insert(self, iter, text):
+ self.do_insert = True
+ self.buffer.insert(iter, text)
+ self.do_insert = False
+
+ # Make sure that text insertions while in text input mode are properly
+ # committed to the history.
+ def on_buf_insert(self, buf, iter, text, len):
+ # Bail out if not in input mode.
+ if not self.in_raw_input or self.do_insert or not len:
+ return
+
+ buf.stop_emission("insert-text")
+ lines = text.splitlines()
+ need_eol = False
+ for l in lines:
+ if need_eol:
+ self._commit()
+ iter = self.__get_cursor()
+ else:
+ cursor = self.__get_cursor()
+ if iter.compare(self.__get_start()) < 0:
+ iter = cursor
+ elif iter.compare(self.__get_end()) > 0:
+ iter = cursor
+ else:
+ self.__move_cursor_to(iter)
+ need_eol = True
+ self.__insert(iter, l)
+ self.__move_cursor(0)
+
+ def __delete(self, start, end):
+ self.do_delete = True
+ self.buffer.delete(start, end)
+ self.do_delete = False
+
+ def on_buf_delete(self, buf, start, end):
+ if not self.in_raw_input or self.do_delete:
+ return
+
+ buf.stop_emission("delete-range")
+
+ start.order(end)
+ line_start = self.__get_start()
+ line_end = self.__get_end()
+
+ if start.compare(line_end) > 0:
+ return
+ if end.compare(line_start) < 0:
+ return
+
+ self.__move_cursor(0)
+
+ if start.compare(line_start) < 0:
+ start = line_start
+ if end.compare(line_end) > 0:
+ end = line_end
+ self.__delete(start, end)
+
+ # We overload the key press event handler to handle "special keys"
+ # when in input mode to make history browsing, completions, etc. work.
+ def do_key_press_event(self, event, parent_type):
+ if not self.in_raw_input:
+ return parent_type.do_key_press_event(self, event)
+
+ tab_pressed = self.tab_pressed
+ self.tab_pressed = 0
+ handled = True
+
+ state = event.state & (gdk.SHIFT_MASK |
+ gdk.CONTROL_MASK |
+ gdk.MOD1_MASK)
+ keyval = event.keyval
+
+ if not state:
+ if keyval == _keys.Escape:
+ pass
+ elif keyval == _keys.Return:
+ self._commit()
+ elif keyval == _keys.Up:
+ self.__history(-1)
+ elif keyval == _keys.Down:
+ self.__history(1)
+ elif keyval == _keys.Left:
+ self.__move_cursor(-1)
+ elif keyval == _keys.Right:
+ self.__move_cursor(1)
+ elif keyval == _keys.Home:
+ self.__move_cursor(-10000)
+ elif keyval == _keys.End:
+ self.__move_cursor(10000)
+ elif keyval == _keys.Tab:
+ cursor = self.__get_cursor()
+ if cursor.starts_line():
+ handled = False
+ else:
+ cursor.backward_char()
+ if cursor.get_char().isspace():
+ handled = False
+ else:
+ self.tab_pressed = tab_pressed + 1
+ self.__complete()
+ else:
+ handled = False
+ elif state == gdk.CONTROL_MASK:
+ if keyval == _keys.u:
+ start = self.__get_start()
+ end = self.__get_cursor()
+ self.__delete(start, end)
+ elif keyval == _keys.d:
+ if self.quit_func:
+ self.quit_func()
+ else:
+ handled = False
+ else:
+ handled = False
+
+ # Handle ordinary keys
+ if not handled:
+ return parent_type.do_key_press_event(self, event)
+ else:
+ return True
+
+ def __history(self, dir):
+ text = self._get_line()
+ new_text = self.history.get(dir, text)
+ if not new_text is None:
+ self.__replace_line(new_text)
+ self.__move_cursor(0)
+ self.scroll_to_mark(self.cursor, 0.2)
+
+ def __get_cursor(self):
+ '''Returns an iterator at the current cursor position.'''
+ return self.buffer.get_iter_at_mark(self.cursor)
+
+ def __get_start(self):
+ '''Returns an iterator at the start of the input on the current
+ cursor line.'''
+
+ iter = self.__get_cursor()
+ iter.set_line(iter.get_line())
+ iter.forward_chars(len(self.ps))
+ return iter
+
+ def __get_end(self):
+ '''Returns an iterator at the end of the cursor line.'''
+ iter = self.__get_cursor()
+ if not iter.ends_line():
+ iter.forward_to_line_end()
+ return iter
+
+ def __get_text(self, start, end):
+ '''Get text between 'start' and 'end' markers.'''
+ return self.buffer.get_text(start, end, False)
+
+ def __move_cursor_to(self, iter):
+ self.buffer.place_cursor(iter)
+ self.buffer.move_mark_by_name("cursor", iter)
+
+ def __move_cursor(self, howmany):
+ iter = self.__get_cursor()
+ end = self.__get_cursor()
+ if not end.ends_line():
+ end.forward_to_line_end()
+ line_len = end.get_line_offset()
+ move_to = iter.get_line_offset() + howmany
+ move_to = min(max(move_to, len(self.ps)), line_len)
+ iter.set_line_offset(move_to)
+ self.__move_cursor_to(iter)
+
+ def __delete_at_cursor(self, howmany):
+ iter = self.__get_cursor()
+ end = self.__get_cursor()
+ if not end.ends_line():
+ end.forward_to_line_end()
+ line_len = end.get_line_offset()
+ erase_to = iter.get_line_offset() + howmany
+ if erase_to > line_len:
+ erase_to = line_len
+ elif erase_to < len(self.ps):
+ erase_to = len(self.ps)
+ end.set_line_offset(erase_to)
+ self.__delete(iter, end)
+
+ def __get_width(self):
+ '''Estimate the number of characters that will fit in the area
+ currently allocated to this widget.'''
+
+ if not (self.flags() & gtk.REALIZED):
+ return 80
+
+ context = self.get_pango_context()
+ metrics = context.get_metrics(context.get_font_description(),
+ context.get_language())
+ pix_width = metrics.get_approximate_char_width()
+ return self.allocation.width * pango.SCALE / pix_width
+
+ def __print_completions(self, completions):
+ line_start = self.__get_text(self.__get_start(), self.__get_cursor())
+ line_end = self.__get_text(self.__get_cursor(), self.__get_end())
+ iter = self.buffer.get_end_iter()
+ self.__move_cursor_to(iter)
+ self.__insert(iter, "\n")
+
+ width = max(self.__get_width(), 4)
+ max_width = max([len(s) for s in completions])
+ n_columns = max(int(width / (max_width + 1)), 1)
+ col_width = int(width / n_columns)
+ total = len(completions)
+ col_length = total / n_columns
+ if total % n_columns:
+ col_length = col_length + 1
+ col_length = max(col_length, 1)
+
+ if col_length == 1:
+ n_columns = total
+ col_width = width / total
+
+ for i in range(col_length):
+ for j in range(n_columns):
+ ind = i + j*col_length
+ if ind < total:
+ if j == n_columns - 1:
+ n_spaces = 0
+ else:
+ n_spaces = col_width - len(completions[ind])
+ self.__insert(iter, completions[ind] + " " * n_spaces)
+ self.__insert(iter, "\n")
+
+ self.__insert(iter, "%s%s%s" % (self.ps, line_start, line_end))
+ iter.set_line_offset(len(self.ps) + len(line_start))
+ self.__move_cursor_to(iter)
+ self.scroll_to_mark(self.cursor, 0.2)
+
+ def __complete(self):
+ text = self.__get_text(self.__get_start(), self.__get_cursor())
+ start = ''
+ word = text
+ nonwords = self.nonword_re.findall(text)
+ if nonwords:
+ last = text.rfind(nonwords[-1]) + len(nonwords[-1])
+ start = text[:last]
+ word = text[last:]
+
+ completions = self.complete(word)
+
+ if completions:
+ prefix = _commonprefix(completions)
+ if prefix != word:
+ start_iter = self.__get_start()
+ start_iter.forward_chars(len(start))
+ end_iter = start_iter.copy()
+ end_iter.forward_chars(len(word))
+ self.__delete(start_iter, end_iter)
+ self.__insert(end_iter, prefix)
+ elif self.tab_pressed > 1:
+ self.freeze_undo()
+ self.__print_completions(completions)
+ self.thaw_undo()
+ self.tab_pressed = 0
+
+ def complete(self, text):
+ return None
+
+ def _get_line(self):
+ '''Return the current input behind the prompt.'''
+ start = self.__get_start()
+ end = self.__get_end()
+ return self.buffer.get_text(start, end, False)
+
+ def __replace_line(self, new_text):
+ '''Replace the current input with 'new_text' '''
+ start = self.__get_start()
+ end = self.__get_end()
+ self.__delete(start, end)
+ self.__insert(end, new_text)
+
+ def _commit(self):
+ '''Commit the input entered on the current line.'''
+
+ # Find iterator and end of cursor line.
+ end = self.__get_cursor()
+ if not end.ends_line():
+ end.forward_to_line_end()
+
+ # Get text at current line.
+ text = self._get_line()
+
+ # Move cursor to the end of the line, insert new line.
+ self.__move_cursor_to(end)
+ self.freeze_undo()
+ self.__insert(end, "\n")
+
+ self.history.commit(text)
+ if self.in_modal_raw_input:
+ self.in_modal_raw_input = False
+ self.modal_raw_input_result = text
+ else:
+ self.in_raw_input = False
+ self.do_raw_input(text)
+
+ self.thaw_undo()
+
+ def do_raw_input(self, text):
+ pass
+
+
+class _Console(_ReadLine, code.InteractiveInterpreter):
+ def __init__(self, locals=None, banner=None,
+ completer=None, use_rlcompleter=True,
+ start_script=None, quit_func=None):
+ _ReadLine.__init__(self, quit_func)
+
+ code.InteractiveInterpreter.__init__(self, locals)
+ self.locals["__console__"] = self
+
+ # The builtin raw_input function reads from stdin, we don't want
+ # this. Therefore, replace this function with our own modal raw
+ # input function.
+ exec "import __builtin__" in self.locals
+ self.locals['__builtin__'].__dict__['raw_input'] = lambda text='': self.modal_raw_input(text)
+ self.locals['__builtin__'].__dict__['input'] = lambda text='': self.modal_input(text)
+
+ self.start_script = start_script
+ self.completer = completer
+ self.banner = banner
+
+ if not self.completer and use_rlcompleter:
+ try:
+ import rlcompleter
+ self.completer = rlcompleter.Completer()
+ except ImportError:
+ pass
+
+ self.ps1 = ">>> "
+ self.ps2 = "... "
+ self.__start()
+ self.run_on_raw_input = start_script
+ self.raw_input(self.ps1)
+
+ def __start(self):
+ self.cmd_buffer = ""
+
+ self.freeze_undo()
+ self.thaw_undo()
+
+ self.do_delete = True
+ self.buffer.set_text("")
+ self.do_delete = False
+
+ if self.banner:
+ iter = self.buffer.get_start_iter()
+ self.buffer.insert_with_tags_by_name(iter, self.banner, "stdout")
+ if not iter.starts_line():
+ self.buffer.insert(iter, "\n")
+
+ def clear(self, start_script=None):
+ if start_script is None:
+ start_script = self.start_script
+ else:
+ self.start_script = start_script
+
+ self.__start()
+ self.run_on_raw_input = start_script
+ self.raw_input(self.ps1)
+
+ def do_raw_input(self, text):
+ if self.cmd_buffer:
+ cmd = self.cmd_buffer + "\n" + text
+ else:
+ cmd = text
+
+ saved_stdout, saved_stderr = sys.stdout, sys.stderr
+ sys.stdout, sys.stderr = self._stdout, self._stderr
+
+ if self.runsource(cmd):
+ self.cmd_buffer = cmd
+ ps = self.ps2
+ else:
+ self.cmd_buffer = ''
+ ps = self.ps1
+
+ sys.stdout, sys.stderr = saved_stdout, saved_stderr
+ self.raw_input(ps)
+
+ def do_command(self, code):
+ try:
+ eval(code, self.locals)
+ except SystemExit:
+ if self.quit_func:
+ self.quit_func()
+ else:
+ raise
+ except:
+ self.showtraceback()
+
+ def runcode(self, code):
+ if gtk.pygtk_version[1] < 8:
+ self.do_command(code)
+ else:
+ self.emit("command", code)
+
+ def complete_attr(self, start, end):
+ try:
+ obj = eval(start, self.locals)
+ strings = dir(obj)
+
+ if end:
+ completions = {}
+ for s in strings:
+ if s.startswith(end):
+ completions[s] = None
+ completions = completions.keys()
+ else:
+ completions = strings
+
+ completions.sort()
+ return [start + "." + s for s in completions]
+ except:
+ return None
+
+ def complete(self, text):
+ if self.completer:
+ completions = []
+ i = 0
+ try:
+ while 1:
+ s = self.completer.complete(text, i)
+ if s:
+ completions.append(s)
+ i = i + 1
+ else:
+ completions.sort()
+ return completions
+ except NameError:
+ return None
+
+ dot = text.rfind(".")
+ if dot >= 0:
+ return self.complete_attr(text[:dot], text[dot+1:])
+
+ completions = {}
+ strings = keyword.kwlist
+
+ if self.locals:
+ strings.extend(self.locals.keys())
+
+ try: strings.extend(eval("globals()", self.locals).keys())
+ except: pass
+
+ try:
+ exec "import __builtin__" in self.locals
+ strings.extend(eval("dir(__builtin__)", self.locals))
+ except:
+ pass
+
+ for s in strings:
+ if s.startswith(text):
+ completions[s] = None
+ completions = completions.keys()
+ completions.sort()
+ return completions
+
+
+def ReadLineType(t=gtk.TextView):
+ class readline(t, _ReadLine):
+ def __init__(self, *args, **kwargs):
+ t.__init__(self)
+ _ReadLine.__init__(self, *args, **kwargs)
+ def do_key_press_event(self, event):
+ return _ReadLine.do_key_press_event(self, event, t)
+ gobject.type_register(readline)
+ return readline
+
+def ConsoleType(t=gtk.TextView):
+ class console_type(t, _Console):
+ __gsignals__ = {
+ 'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (object,)),
+ 'key-press-event' : 'override'
+ }
+
+ def __init__(self, *args, **kwargs):
+ if gtk.pygtk_version[1] < 8:
+ gobject.GObject.__init__(self)
+ else:
+ t.__init__(self)
+ _Console.__init__(self, *args, **kwargs)
+
+ def do_command(self, code):
+ return _Console.do_command(self, code)
+
+ def do_key_press_event(self, event):
+ return _Console.do_key_press_event(self, event, t)
+
+ def get_default_size(self):
+ context = self.get_pango_context()
+ metrics = context.get_metrics(context.get_font_description(),
+ context.get_language())
+ width = metrics.get_approximate_char_width()
+ height = metrics.get_ascent() + metrics.get_descent()
+
+ # Default to a 80x40 console
+ width = pango.PIXELS(int(width * 80 * 1.05))
+ height = pango.PIXELS(height * 40)
+
+ return width, height
+
+ if gtk.pygtk_version[1] < 8:
+ gobject.type_register(console_type)
+
+ return console_type
+
+ReadLine = ReadLineType()
+Console = ConsoleType()
+
+def _make_window():
+ window = gtk.Window()
+ window.set_title("pyconsole.py")
+ swin = gtk.ScrolledWindow()
+ swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ window.add(swin)
+ console = Console(banner="Hello there!",
+ use_rlcompleter=False,
+ start_script="from gtk import *\n")
+ swin.add(console)
+
+ width, height = console.get_default_size()
+ sb_width, sb_height = swin.get_vscrollbar().size_request()
+
+ window.set_default_size(width + sb_width, height)
+ window.show_all()
+
+ if not gtk.main_level():
+ window.connect("destroy", gtk.main_quit)
+ gtk.main()
+
+ return console
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2 or sys.argv[1] != '-gimp':
+ _make_window()
diff --git a/plug-ins/pygimp/plug-ins/python-console.py b/plug-ins/pygimp/plug-ins/python-console.py
new file mode 100755
index 0000000..a8c7e4c
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/python-console.py
@@ -0,0 +1,245 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+from gimpfu import *
+
+t = gettext.translation('gimp20-python', gimp.locale_directory, fallback=True)
+_ = t.ugettext
+
+PROC_NAME = 'python-fu-console'
+
+RESPONSE_BROWSE, RESPONSE_CLEAR, RESPONSE_SAVE = range(3)
+
+def do_console():
+ import pygtk
+ pygtk.require('2.0')
+
+ import sys, gobject, gtk, gimpenums, gimpshelf, gimpui, pyconsole
+ gimpui.gimp_ui_init ()
+
+ namespace = {'__builtins__': __builtins__,
+ '__name__': '__main__', '__doc__': None,
+ 'gimp': gimp, 'pdb': gimp.pdb,
+ 'shelf': gimpshelf.shelf}
+
+ for s in gimpenums.__dict__.keys():
+ if s[0] != '_':
+ namespace[s] = getattr(gimpenums, s)
+
+ class GimpConsole(pyconsole.Console):
+ def __init__(self, quit_func=None):
+ banner = ('GIMP %s Python Console\nPython %s\n' %
+ (gimp.pdb.gimp_version(), sys.version))
+ pyconsole.Console.__init__(self,
+ locals=namespace, banner=banner,
+ quit_func=quit_func)
+ def _commit(self):
+ pyconsole.Console._commit(self)
+ gimp.displays_flush()
+
+ class ConsoleDialog(gimpui.Dialog):
+ def __init__(self):
+ gimpui.Dialog.__init__(self, title=_("Python Console"),
+ role=PROC_NAME, help_id=PROC_NAME,
+ buttons=(gtk.STOCK_SAVE, RESPONSE_SAVE,
+ gtk.STOCK_CLEAR, RESPONSE_CLEAR,
+ _("_Browse..."), RESPONSE_BROWSE,
+ gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
+
+ self.set_name (PROC_NAME)
+ self.set_alternative_button_order((gtk.RESPONSE_CLOSE,
+ RESPONSE_BROWSE,
+ RESPONSE_CLEAR,
+ RESPONSE_SAVE))
+
+ self.cons = GimpConsole(quit_func=lambda: gtk.main_quit())
+
+ self.style_set (None, None)
+
+ self.connect('response', self.response)
+ self.connect('style-set', self.style_set)
+
+ self.browse_dlg = None
+ self.save_dlg = None
+
+ vbox = gtk.VBox(False, 12)
+ vbox.set_border_width(12)
+ self.vbox.pack_start(vbox)
+
+ scrl_win = gtk.ScrolledWindow()
+ scrl_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ vbox.pack_start(scrl_win)
+
+ scrl_win.add(self.cons)
+
+ width, height = self.cons.get_default_size()
+ sb_width, sb_height = scrl_win.get_vscrollbar().size_request()
+
+ # Account for scrollbar width and border width to ensure
+ # the text view gets a width of 80 characters. We don't care
+ # so much whether the height will be exactly 40 characters.
+ self.set_default_size(width + sb_width + 2 * 12, height)
+
+ def style_set(self, old_style, user_data):
+ style = self.get_style ()
+ self.cons.stdout_tag.set_property ("foreground", style.text[gtk.STATE_NORMAL])
+ self.cons.stderr_tag.set_property ("foreground", style.text[gtk.STATE_INSENSITIVE])
+
+ def response(self, dialog, response_id):
+ if response_id == RESPONSE_BROWSE:
+ self.browse()
+ elif response_id == RESPONSE_CLEAR:
+ self.cons.banner = None
+ self.cons.clear()
+ elif response_id == RESPONSE_SAVE:
+ self.save_dialog()
+ else:
+ gtk.main_quit()
+
+ self.cons.grab_focus()
+
+ def browse_response(self, dlg, response_id):
+ if response_id != gtk.RESPONSE_APPLY:
+ dlg.hide()
+ return
+
+ proc_name = dlg.get_selected()
+
+ if not proc_name:
+ return
+
+ proc = pdb[proc_name]
+
+ cmd = ''
+
+ if len(proc.return_vals) > 0:
+ cmd = ', '.join([x[1].replace('-', '_')
+ for x in proc.return_vals]) + ' = '
+
+ cmd = cmd + 'pdb.%s' % proc.proc_name.replace('-', '_')
+
+ if len(proc.params) > 0 and proc.params[0][1] == 'run-mode':
+ params = proc.params[1:]
+ else:
+ params = proc.params
+
+ cmd = cmd + '(%s)' % ', '.join([x[1].replace('-', '_')
+ for x in params])
+
+ buffer = self.cons.buffer
+
+ lines = buffer.get_line_count()
+ iter = buffer.get_iter_at_line_offset(lines - 1, 4)
+ buffer.delete(iter, buffer.get_end_iter())
+ buffer.place_cursor(buffer.get_end_iter())
+ buffer.insert_at_cursor(cmd)
+
+ def browse(self):
+ if not self.browse_dlg:
+ dlg = gimpui.ProcBrowserDialog(_("Python Procedure Browser"),
+ role=PROC_NAME,
+ buttons=(gtk.STOCK_APPLY,
+ gtk.RESPONSE_APPLY,
+ gtk.STOCK_CLOSE,
+ gtk.RESPONSE_CLOSE))
+
+ dlg.set_default_response(gtk.RESPONSE_APPLY)
+ dlg.set_alternative_button_order((gtk.RESPONSE_CLOSE,
+ gtk.RESPONSE_APPLY))
+
+ dlg.connect('response', self.browse_response)
+ dlg.connect('row-activated',
+ lambda dlg: dlg.response(gtk.RESPONSE_APPLY))
+
+ self.browse_dlg = dlg
+
+ self.browse_dlg.present()
+
+ def save_response(self, dlg, response_id):
+ if response_id == gtk.RESPONSE_DELETE_EVENT:
+ self.save_dlg = None
+ return
+ elif response_id == gtk.RESPONSE_OK:
+ filename = dlg.get_filename()
+
+ try:
+ logfile = open(filename, 'w')
+ except IOError, e:
+ gimp.message(_("Could not open '%s' for writing: %s") %
+ (filename, e.strerror))
+ return
+
+ buffer = self.cons.buffer
+
+ start = buffer.get_start_iter()
+ end = buffer.get_end_iter()
+
+ log = buffer.get_text(start, end, False)
+
+ try:
+ logfile.write(log)
+ logfile.close()
+ except IOError, e:
+ gimp.message(_("Could not write to '%s': %s") %
+ (filename, e.strerror))
+ return
+
+ dlg.hide()
+
+ def save_dialog(self):
+ if not self.save_dlg:
+ dlg = gtk.FileChooserDialog(_("Save Python-Fu Console Output"),
+ parent=self,
+ action=gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE,
+ gtk.RESPONSE_OK))
+
+ dlg.set_default_response(gtk.RESPONSE_OK)
+ dlg.set_alternative_button_order((gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL))
+
+ dlg.connect('response', self.save_response)
+
+ self.save_dlg = dlg
+
+ self.save_dlg.present()
+
+ def run(self):
+ self.show_all()
+ gtk.main()
+
+ ConsoleDialog().run()
+
+register(
+ PROC_NAME,
+ N_("Interactive GIMP Python interpreter"),
+ "Type in commands and see results",
+ "James Henstridge",
+ "James Henstridge",
+ "1997-1999",
+ N_("_Console"),
+ "",
+ [],
+ [],
+ do_console,
+ menu="<Image>/Filters/Languages/Python-Fu",
+ domain=("gimp20-python", gimp.locale_directory))
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/python-eval.py b/plug-ins/pygimp/plug-ins/python-eval.py
new file mode 100755
index 0000000..9c1663d
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/python-eval.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 2006 Manish Singh <yosh@gimp.org>
+#
+# 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/>.
+
+from gimpfu import *
+
+def code_eval(code):
+ if code == '-':
+ import sys
+ code = sys.stdin
+ exec code in globals()
+
+register(
+ "python-fu-eval",
+ "Evaluate Python code",
+ "Evaluate python code under the python interpreter (primarily for batch mode)",
+ "Manish Singh",
+ "Manish Singh",
+ "2006",
+ None,
+ None,
+ [
+ (PF_STRING, "code", "The code to evaluate", "")
+ ],
+ [],
+ code_eval)
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/shadow_bevel.py b/plug-ins/pygimp/plug-ins/shadow_bevel.py
new file mode 100755
index 0000000..29a9246
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/shadow_bevel.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+from gimpfu import *
+
+gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
+
+def shadow_bevel(img, drawable, blur, bevel, do_shadow, drop_x, drop_y):
+ # disable undo for the image
+ img.undo_group_start()
+
+ # copy the layer
+ shadow = drawable.copy(True)
+ img.insert_layer(shadow, position=img.layers.index(drawable) + 1)
+ shadow.name = drawable.name + " shadow"
+ shadow.lock_alpha = False
+
+ # threshold the shadow layer to all white
+ pdb.gimp_threshold(shadow, 0, 255)
+
+ # blur the shadow layer
+ pdb.plug_in_gauss_iir(img, shadow, blur, True, True)
+
+ # do the bevel thing ...
+ if bevel:
+ pdb.plug_in_bump_map(img, drawable, shadow, 135, 45, 3,
+ 0, 0, 0, 0, True, False, 0)
+
+ # make the shadow layer black now ...
+ pdb.gimp_drawable_invert(shadow, False)
+
+ # translate the drop shadow
+ shadow.translate(drop_x, drop_y)
+
+ if not do_shadow:
+ # delete shadow ...
+ gimp.delete(shadow)
+
+ # enable undo again
+ img.undo_group_end()
+
+
+register(
+ "python-fu-shadow-bevel",
+ N_("Add a drop shadow to a layer, and optionally bevel it"),
+ "Add a drop shadow to a layer, and optionally bevel it",
+ "James Henstridge",
+ "James Henstridge",
+ "1999",
+ N_("_Drop Shadow and Bevel..."),
+ "RGBA, GRAYA",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_SLIDER, "blur", _("_Shadow blur"), 6, (1, 30, 1)),
+ (PF_BOOL, "bevel", _("_Bevel"), True),
+ (PF_BOOL, "shadow", _("_Drop shadow"), True),
+ (PF_INT, "drop-x", _("Drop shadow _X displacement"), 3),
+ (PF_INT, "drop-y", _("Drop shadow _Y displacement"), 6)
+ ],
+ [],
+ shadow_bevel,
+ menu="<Image>/Filters/Light and Shadow/Shadow",
+ domain=("gimp20-python", gimp.locale_directory)
+ )
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/sphere.py b/plug-ins/pygimp/plug-ins/sphere.py
new file mode 100755
index 0000000..889c3f7
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/sphere.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+import math
+from gimpfu import *
+
+def sphere(radius, light, shadow, foo, bg_colour, sphere_colour):
+ if radius < 1:
+ radius = 1
+
+ width = int(radius * 3.75)
+ height = int(radius * 2.5)
+
+ gimp.context_push()
+
+ img = gimp.Image(width, height, RGB)
+
+ drawable = gimp.Layer(img, "Sphere Layer", width, height,
+ RGB_IMAGE, 100, NORMAL_MODE)
+
+ radians = light * math.pi / 180
+
+ cx = width / 2
+ cy = height / 2
+
+ light_x = cx + radius * 0.6 * math.cos(radians)
+ light_y = cy - radius * 0.6 * math.sin(radians)
+
+ light_end_x = cx + radius * math.cos(math.pi + radians)
+ light_end_y = cy - radius * math.sin(math.pi + radians)
+
+ offset = radius * 0.1
+
+ img.disable_undo()
+ img.insert_layer(drawable)
+
+ gimp.set_foreground(sphere_colour)
+
+ gimp.set_background(bg_colour)
+ pdb.gimp_edit_fill(drawable, BACKGROUND_FILL)
+
+ gimp.set_background(20, 20, 20)
+
+ if (light >= 45 and light <= 75 or light <= 135 and
+ light >= 105) and shadow:
+ shadow_w = radius * 2.5 * math.cos(math.pi + radians)
+ shadow_h = radius * 0.5
+ shadow_x = cx
+ shadow_y = cy + radius * 0.65
+
+ if shadow_w < 0:
+ shadow_x = cx + shadow_w
+ shadow_w = -shadow_w
+
+ pdb.gimp_ellipse_select(img, shadow_x, shadow_y, shadow_w, shadow_h,
+ CHANNEL_OP_REPLACE, True, True, 7.5)
+ pdb.gimp_edit_bucket_fill(drawable, BG_BUCKET_FILL,
+ MULTIPLY_MODE, 100, 0, False, 0, 0)
+
+ pdb.gimp_ellipse_select(img, cx - radius, cy - radius, 2 * radius,
+ 2 * radius, CHANNEL_OP_REPLACE, True, False, 0)
+ pdb.gimp_edit_blend(drawable, FG_BG_RGB_MODE, NORMAL_MODE, GRADIENT_RADIAL,
+ 100, offset, REPEAT_NONE, False, False, 0, 0, True,
+ light_x, light_y, light_end_x, light_end_y)
+
+ pdb.gimp_selection_none(img)
+
+ img.enable_undo()
+
+ disp = gimp.Display(img)
+
+ gimp.context_pop()
+
+
+register(
+ "python-fu-sphere",
+ "Simple sphere with drop shadow",
+ "Simple sphere with drop shadow",
+ "James Henstridge",
+ "James Henstridge",
+ "1997-1999, 2007",
+ "_Sphere",
+ "",
+ [
+ (PF_INT, "radius", "Radius for sphere", 100),
+ (PF_SLIDER, "light", "Light angle", 45, (0,360,1)),
+ (PF_TOGGLE, "shadow", "Shadow?", 1),
+ (PF_RADIO, "foo", "Test", "foo", (("Foo", "foo"), ("Bar", "bar"))),
+ (PF_COLOR, "bg-color", "Background", (1.0, 1.0, 1.0)),
+ (PF_COLOR, "sphere-color", "Sphere", "orange")
+ ],
+ [],
+ sphere,
+ menu="<Image>/Filters/Languages/Python-Fu/Test")
+
+main()
diff --git a/plug-ins/pygimp/plug-ins/spyro_plus.py b/plug-ins/pygimp/plug-ins/spyro_plus.py
new file mode 100644
index 0000000..7d31c54
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/spyro_plus.py
@@ -0,0 +1,2212 @@
+#!/usr/bin/env python2
+
+# Draw Spyrographs, Epitrochoids, and Lissajous curves with interactive feedback.
+#
+# 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/>.
+
+from gimpshelf import shelf
+from gimpenums import *
+import gimp
+import gimpplugin
+import gimpui
+import gobject
+import gtk
+gdk = gtk.gdk
+
+from math import pi, sin, cos, atan, atan2, fmod, radians, sqrt
+import gettext
+import fractions
+import time
+
+
+# i18n
+t = gettext.translation("gimp20-python", gimp.locale_directory, fallback=True)
+_ = t.ugettext
+
+def N_(message):
+ return message
+
+
+pdb = gimp.pdb
+
+two_pi, half_pi = 2 * pi, pi / 2
+layer_name = _("Spyro Layer")
+path_name = _("Spyro Path")
+
+# "Enums"
+GEAR_NOTATION, TOY_KIT_NOTATION, VISUAL_NOTATION = range(3) # Pattern notations
+
+# Mapping of pattern notation to the corresponding tab in the pattern notation notebook.
+pattern_notation_page = {}
+
+# Save options of the dialog
+SAVE_AS_NEW_LAYER, SAVE_BY_REDRAW, SAVE_AS_PATH = range(3)
+save_options = [
+ _("Save\nas New Layer"),
+ _("Redraw on\nActive layer"),
+ _("Save\nas Path")
+]
+
+ring_teeth = [96, 144, 105, 150]
+
+# Moving gear. Each gear is a pair of (#teeth, #holes)
+# Hole #1 is closest to the edge of the wheel.
+# The last hole is closest to the center.
+wheel = [
+ (24, 5), (30, 8), (32, 9), (36, 11), (40, 13), (42, 14), (45, 16),
+ (48, 17), (50, 18), (52, 19), (56, 21), (60, 23), (63, 25), (64, 25),
+ (72, 29), (75, 31), (80, 33), (84, 35)
+]
+wheel_teeth = [wh[0] for wh in wheel]
+
+
+def lcm(a, b):
+ """ Least common multiplier """
+ return a * b // fractions.gcd(a, b)
+
+
+### Shapes
+
+
+class CanRotateShape:
+ pass
+
+
+class Shape:
+ def configure(self, img, pp, cp):
+ self.image, self.pp, self.cp = img, pp, cp
+
+ def can_equal_w_h(self):
+ return True
+
+ def has_sides(self):
+ return isinstance(self, SidedShape)
+
+ def can_rotate(self):
+ return isinstance(self, CanRotateShape)
+
+ def can_morph(self):
+ return self.has_sides()
+
+
+class CircleShape(Shape):
+ name = _("Circle")
+
+ def get_center_of_moving_gear(self, oangle, dist=None):
+ """
+ :return: x,y - position where the center of the moving gear should be,
+ after going over oangle/two_pi of a full cycle over the outer gear.
+ """
+ cp = self.cp
+ if dist is None:
+ dist = cp.moving_gear_radius
+
+ return (cp.x_center + (cp.x_half_size - dist) * cos(oangle),
+ cp.y_center + (cp.y_half_size - dist) * sin(oangle))
+
+
+class SidedShape(CanRotateShape, Shape):
+
+ def configure(self, img, pp, cp):
+ Shape.configure(self, img, pp, cp)
+ self.angle_of_each_side = two_pi / pp.sides
+ self.half_angle = self.angle_of_each_side / 2.0
+ self.cos_half_angle = cos(self.half_angle)
+
+ def get_center_of_moving_gear(self, oangle, dist=None):
+ if dist is None:
+ dist = self.cp.moving_gear_radius
+ shape_factor = self.get_shape_factor(oangle)
+ return (
+ self.cp.x_center +
+ (self.cp.x_half_size - dist) * shape_factor * cos(oangle),
+ self.cp.y_center +
+ (self.cp.y_half_size - dist) * shape_factor * sin(oangle)
+ )
+
+
+class PolygonShape(SidedShape):
+ name = _("Polygon-Star")
+
+ def get_shape_factor(self, oangle):
+ oangle_mod = fmod(oangle + self.cp.shape_rotation_radians, self.angle_of_each_side)
+ if oangle_mod > self.half_angle:
+ oangle_mod = self.angle_of_each_side - oangle_mod
+
+ # When oangle_mod = 0, the shape_factor will be cos(half_angle)) - which is the minimal shape_factor.
+ # When oangle_mod is near the half_angle, the shape_factor will near 1.
+ shape_factor = self.cos_half_angle / cos(oangle_mod)
+ shape_factor -= self.pp.morph * (1 - shape_factor) * (1 + (self.pp.sides - 3) * 2)
+ return shape_factor
+
+
+class SineShape(SidedShape):
+ # Sine wave on a circle ring.
+ name = _("Sine")
+
+ def get_shape_factor(self, oangle):
+ oangle_mod = fmod(oangle + self.cp.shape_rotation_radians, self.angle_of_each_side)
+ oangle_stretched = oangle_mod * self.pp.sides
+ return 1 - self.pp.morph * (cos(oangle_stretched) + 1)
+
+
+class BumpShape(SidedShape):
+ # Semi-circles, based on a polygon
+ name = _("Bumps")
+
+ def get_shape_factor(self, oangle):
+ oangle_mod = fmod(oangle + self.cp.shape_rotation_radians, self.angle_of_each_side)
+ # Stretch back to angle between 0 and pi
+ oangle_stretched = oangle_mod/2.0 * self.pp.sides
+
+ # Compute factor for polygon.
+ poly_angle = oangle_mod
+ if poly_angle > self.half_angle:
+ poly_angle = self.angle_of_each_side - poly_angle
+ # When poly_oangle = 0, the shape_factor will be cos(half_angle)) - the minimal shape_factor.
+ # When poly_angle is near the half_angle, the shape_factor will near 1.
+ polygon_factor = self.cos_half_angle / cos(poly_angle)
+
+ # Bump
+ return polygon_factor - self.pp.morph * (1 - abs(cos(oangle_stretched)))
+
+
+class ShapePart(object):
+ def set_bounds(self, start, end):
+ self.bound_start, self.bound_end = start, end
+ self.bound_diff = self.bound_end - self.bound_start
+
+
+class StraightPart(ShapePart):
+
+ def __init__(self, teeth, perp_direction, x1, y1, x2, y2):
+ self.teeth, self.perp_direction = max(teeth, 1), perp_direction
+ self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
+ self.x_diff = self.x2 - self.x1
+ self.y_diff = self.y2 - self.y1
+
+ angle = atan2(self.y_diff, self.x_diff) # - shape_rotation_radians
+ perp_angle = angle + perp_direction * half_pi
+ self.sin_angle = sin(perp_angle)
+ self.cos_angle = cos(perp_angle)
+
+ def perpendicular_at_oangle(self, oangle, perp_distance):
+ factor = (oangle - self.bound_start) / self.bound_diff
+ return (self.x1 + factor * self.x_diff + perp_distance * self.cos_angle,
+ self.y1 + factor * self.y_diff + perp_distance * self.sin_angle)
+
+
+class RoundPart(ShapePart):
+
+ def __init__(self, teeth, x, y, start_angle, end_angle):
+ self.teeth = max(teeth, 1)
+ self.start_angle, self.end_angle = start_angle, end_angle
+ self.x, self.y = x, y
+
+ self.diff_angle = self.end_angle - self.start_angle
+
+ def perpendicular_at_oangle(self, oangle, perp_distance):
+ angle = (
+ self.start_angle +
+ self.diff_angle * (oangle - self.bound_start) / self.bound_diff
+ )
+ return (self.x + perp_distance * cos(angle),
+ self.y + perp_distance * sin(angle))
+
+
+class ShapeParts(list):
+ """ A list of shape parts. """
+
+ def __init__(self):
+ list.__init__(self)
+ self.total_teeth = 0
+
+ def finish(self):
+ for part in self:
+ self.total_teeth += part.teeth
+ teeth = 0
+ bound_end = 0.0
+ for part in self:
+ bound_start = bound_end
+ teeth += part.teeth
+ bound_end = teeth/float(self.total_teeth) * two_pi
+ part.set_bounds(bound_start, bound_end)
+
+ def perpendicular_at_oangle(self, oangle, perp_distance):
+ for part in self:
+ if oangle <= part.bound_end:
+ return part.perpendicular_at_oangle(oangle, perp_distance)
+
+ # We shouldn't reach here
+ return 0.0, 0.0
+
+
+class AbstractShapeFromParts(Shape):
+ def __init__(self):
+ self.parts = None
+
+ def get_center_of_moving_gear(self, oangle, dist=None):
+ """
+ :param oangle: an angle in radians, between 0 and 2*pi
+ :return: x,y - position where the center of the moving gear should be,
+ after going over oangle/two_pi of a full cycle over the outer gear.
+ """
+ if dist is None:
+ dist = self.cp.moving_gear_radius
+ return self.parts.perpendicular_at_oangle(oangle, dist)
+
+
+class RackShape(CanRotateShape, AbstractShapeFromParts):
+ name = _("Rack")
+
+ def configure(self, img, pp, cp):
+ Shape.configure(self, img, pp, cp)
+
+ round_teeth = 12
+ side_teeth = (cp.fixed_gear_teeth - 2 * round_teeth) / 2
+
+ # Determine start and end points of rack.
+
+ cos_rot = cos(cp.shape_rotation_radians)
+ sin_rot = sin(cp.shape_rotation_radians)
+
+ x_size = cp.x2 - cp.x1 - cp.moving_gear_radius * 4
+ y_size = cp.y2 - cp.y1 - cp.moving_gear_radius * 4
+
+ size = ((x_size * cos_rot)**2 + (y_size * sin_rot)**2) ** 0.5
+
+ x1 = cp.x_center - size/2.0 * cos_rot
+ y1 = cp.y_center - size/2.0 * sin_rot
+ x2 = cp.x_center + size/2.0 * cos_rot
+ y2 = cp.y_center + size/2.0 * sin_rot
+
+ # Build shape from shape parts.
+ self.parts = ShapeParts()
+ self.parts.append(StraightPart(side_teeth, -1, x2, y2, x1, y1))
+ self.parts.append(
+ RoundPart(
+ round_teeth, x1, y1,
+ half_pi + cp.shape_rotation_radians,
+ 3 * half_pi + cp.shape_rotation_radians
+ )
+ )
+ self.parts.append(StraightPart(side_teeth, -1, x1, y1, x2, y2))
+ self.parts.append(
+ RoundPart(
+ round_teeth, x2, y2,
+ 3 * half_pi + cp.shape_rotation_radians,
+ 5 * half_pi + cp.shape_rotation_radians)
+ )
+ self.parts.finish()
+
+
+class FrameShape(AbstractShapeFromParts):
+ name = _("Frame")
+
+ def configure(self, img, pp, cp):
+ Shape.configure(self, img, pp, cp)
+
+ x1, x2 = cp.x1 + cp.moving_gear_radius, cp.x2 - cp.moving_gear_radius
+ y1, y2 = cp.y1 + cp.moving_gear_radius, cp.y2 - cp.moving_gear_radius
+ x_diff, y_diff = abs(x2 - x1), abs(y2 - y1)
+
+ # Build shape from shape parts.
+ self.parts = ShapeParts()
+ self.parts.append(StraightPart(x_diff, 1, x2, cp.y2, x1, cp.y2))
+ self.parts.append(StraightPart(y_diff, 1, cp.x1, y2, cp.x1, y1))
+ self.parts.append(StraightPart(x_diff, 1, x1, cp.y1, x2, cp.y1))
+ self.parts.append(StraightPart(y_diff, 1, cp.x2, y1, cp.x2, y2))
+ self.parts.finish()
+
+
+class SelectionToPath:
+ """ Converts a selection to a path """
+
+ def __init__(self, image):
+ self.image = image
+
+ # Compute hash of selection, so we can detect when it was modified.
+ self.last_selection_hash = self.compute_selection_hash()
+
+ self.convert_selection_to_path()
+
+ def convert_selection_to_path(self):
+
+ if pdb.gimp_selection_is_empty(self.image):
+ selection_was_empty = True
+ pdb.gimp_selection_all(self.image)
+ else:
+ selection_was_empty = False
+
+ pdb.plug_in_sel2path(self.image, self.image.active_layer)
+
+ self.path = self.image.vectors[0]
+
+ self.num_strokes, self.stroke_ids = pdb.gimp_vectors_get_strokes(self.path)
+ self.stroke_ids = list(self.stroke_ids)
+
+ # A path may contain several strokes. If so lets throw away a stroke that
+ # simply describes the borders of the image, if one exists.
+ if self.num_strokes > 1:
+ # Lets compute what a stroke of the image borders should look like.
+ w, h = float(self.image.width), float(self.image.height)
+ frame_strokes = [0.0] * 6 + [0.0, h] * 3 + [w, h] * 3 + [w, 0.0] * 3
+
+ for stroke in range(self.num_strokes):
+ strokes = self.path.strokes[stroke].points[0]
+ if strokes == frame_strokes:
+ del self.stroke_ids[stroke]
+ self.num_strokes -= 1
+ break
+
+ self.set_current_stroke(0)
+
+ if selection_was_empty:
+ # Restore empty selection if it was empty.
+ pdb.gimp_selection_none(self.image)
+
+ def compute_selection_hash(self):
+ px = self.image.selection.get_pixel_rgn(0, 0, self.image.width, self.image.height)
+ return px[0:self.image.width, 0:self.image.height].__hash__()
+
+ def regenerate_path_if_selection_changed(self):
+ current_selection_hash = self.compute_selection_hash()
+ if self.last_selection_hash != current_selection_hash:
+ self.last_selection_hash = current_selection_hash
+ self.convert_selection_to_path()
+
+ def get_num_strokes(self):
+ return self.num_strokes
+
+ def set_current_stroke(self, stroke_id=0):
+ # Compute path length.
+ self.path_length = pdb.gimp_vectors_stroke_get_length(self.path, self.stroke_ids[stroke_id], 1.0)
+ self.current_stroke = stroke_id
+
+ def point_at_angle(self, oangle):
+ oangle_mod = fmod(oangle, two_pi)
+ dist = self.path_length * oangle_mod / two_pi
+ return pdb.gimp_vectors_stroke_get_point_at_dist(self.path, self.stroke_ids[self.current_stroke], dist, 1.0)
+
+
+class SelectionShape(Shape):
+ name = _("Selection")
+
+ def __init__(self):
+ self.path = None
+
+ def process_selection(self, img):
+ if self.path is None:
+ self.path = SelectionToPath(img)
+ else:
+ self.path.regenerate_path_if_selection_changed()
+
+ def configure(self, img, pp, cp):
+ """ Set bounds of pattern """
+ Shape.configure(self, img, pp, cp)
+ self.drawing_no = cp.current_drawing
+ self.path.set_current_stroke(self.drawing_no)
+
+ def get_num_drawings(self):
+ return self.path.get_num_strokes()
+
+ def can_equal_w_h(self):
+ return False
+
+ def get_center_of_moving_gear(self, oangle, dist=None):
+ """
+ :param oangle: an angle in radians, between 0 and 2*pi
+ :return: x,y - position where the center of the moving gear should be,
+ after going over oangle/two_pi of a full cycle over the outer gear.
+ """
+ cp = self.cp
+ if dist is None:
+ dist = cp.moving_gear_radius
+ x, y, slope, valid = self.path.point_at_angle(oangle)
+ slope_angle = atan(slope)
+ # We want to find an angle perpendicular to the slope, but in which direction?
+ # Lets try both sides and see which of them is inside the selection.
+ perpendicular_p, perpendicular_m = slope_angle + half_pi, slope_angle - half_pi
+ step_size = 2 # The distance we are going to go in the direction of each angle.
+ xp, yp = x + step_size * cos(perpendicular_p), y + step_size * sin(perpendicular_p)
+ value_plus = pdb.gimp_selection_value(self.image, xp, yp)
+ xp, yp = x + step_size * cos(perpendicular_m), y + step_size * sin(perpendicular_m)
+ value_minus = pdb.gimp_selection_value(self.image, xp, yp)
+
+ perpendicular = perpendicular_p if value_plus > value_minus else perpendicular_m
+ return x + dist * cos(perpendicular), y + dist * sin(perpendicular)
+
+
+shapes = [
+ CircleShape(), RackShape(), FrameShape(), SelectionShape(),
+ PolygonShape(), SineShape(), BumpShape()
+]
+
+
+### Tools
+
+
+def get_gradient_samples(num_samples):
+ gradient_name = pdb.gimp_context_get_gradient()
+ reverse_mode = pdb.gimp_context_get_gradient_reverse()
+ repeat_mode = pdb.gimp_context_get_gradient_repeat_mode()
+
+ if repeat_mode == REPEAT_TRIANGULAR:
+ # Get two uniform samples, which are reversed from each other, and connect them.
+
+ samples = num_samples/2 + 1
+ num, color_samples = pdb.gimp_gradient_get_uniform_samples(gradient_name,
+ samples, reverse_mode)
+
+ color_samples = list(color_samples)
+ del color_samples[-4:] # Delete last color because it will appear in the next sample
+
+ # If num_samples is odd, lets get an extra sample this time.
+ if num_samples % 2 == 1:
+ samples += 1
+
+ num, color_samples2 = pdb.gimp_gradient_get_uniform_samples(gradient_name,
+ samples, 1 - reverse_mode)
+
+ color_samples2 = list(color_samples2)
+ del color_samples2[-4:] # Delete last color because it will appear in the very first sample
+
+ color_samples.extend(color_samples2)
+ color_samples = tuple(color_samples)
+ else:
+ num, color_samples = pdb.gimp_gradient_get_uniform_samples(gradient_name, num_samples, reverse_mode)
+
+ return color_samples
+
+
+class PencilTool():
+ name = _("Pencil")
+ can_color = True
+
+ def draw(self, layer, strokes, color=None):
+ if color:
+ pdb.gimp_context_push()
+ pdb.gimp_context_set_dynamics('Dynamics Off')
+ pdb.gimp_context_set_foreground(color)
+
+ pdb.gimp_pencil(layer, len(strokes), strokes)
+
+ if color:
+ pdb.gimp_context_pop()
+
+
+class AirBrushTool():
+ name = _("AirBrush")
+ can_color = True
+
+ def draw(self, layer, strokes, color=None):
+ if color:
+ pdb.gimp_context_push()
+ pdb.gimp_context_set_dynamics('Dynamics Off')
+ pdb.gimp_context_set_foreground(color)
+
+ pdb.gimp_airbrush_default(layer, len(strokes), strokes)
+
+ if color:
+ pdb.gimp_context_pop()
+
+
+class AbstractStrokeTool():
+
+ def draw(self, layer, strokes, color=None):
+ # We need to multiply every point by 3, because we are creating a path,
+ # where each point has two additional control points.
+ control_points = []
+ for i, k in zip(strokes[0::2], strokes[1::2]):
+ control_points += [i, k] * 3
+
+ # Create path
+ path = pdb.gimp_vectors_new(layer.image, 'temp_path')
+ pdb.gimp_image_add_vectors(layer.image, path, 0)
+ sid = pdb.gimp_vectors_stroke_new_from_points(path, 0, len(control_points),
+ control_points, False)
+
+ # Draw it.
+
+ pdb.gimp_context_push()
+
+ # Call template method to set the kind of stroke to draw.
+ self.prepare_stroke_context(color)
+
+ pdb.gimp_drawable_edit_stroke_item(layer, path)
+ pdb.gimp_context_pop()
+
+ # Get rid of the path.
+ pdb.gimp_image_remove_vectors(layer.image, path)
+
+
+# Drawing tool that should be quick, for purposes of previewing the pattern.
+class PreviewTool:
+
+ # Implementation using pencil. (A previous implementation using stroke was slower, and thus removed).
+ def draw(self, layer, strokes, color=None):
+ foreground = pdb.gimp_context_get_foreground()
+ pdb.gimp_context_push()
+ pdb.gimp_context_set_defaults()
+ pdb.gimp_context_set_foreground(foreground)
+ pdb.gimp_context_set_dynamics('Dynamics Off')
+ pdb.gimp_context_set_brush('1. Pixel')
+ pdb.gimp_context_set_brush_size(1.0)
+ pdb.gimp_context_set_brush_spacing(3.0)
+ pdb.gimp_pencil(layer, len(strokes), strokes)
+ pdb.gimp_context_pop()
+
+ name = _("Preview")
+ can_color = False
+
+
+class StrokeTool(AbstractStrokeTool):
+ name = _("Stroke")
+ can_color = True
+
+ def prepare_stroke_context(self, color):
+ if color:
+ pdb.gimp_context_set_dynamics('Dynamics Off')
+ pdb.gimp_context_set_foreground(color)
+
+ pdb.gimp_context_set_stroke_method(STROKE_LINE)
+
+
+class StrokePaintTool(AbstractStrokeTool):
+ def __init__(self, name, paint_method, can_color=True):
+ self.name = name
+ self.paint_method = paint_method
+ self.can_color = can_color
+
+ def prepare_stroke_context(self, color):
+ if self.can_color and color is not None:
+ pdb.gimp_context_set_dynamics('Dynamics Off')
+ pdb.gimp_context_set_foreground(color)
+
+ pdb.gimp_context_set_stroke_method(STROKE_PAINT_METHOD)
+ pdb.gimp_context_set_paint_method(self.paint_method)
+
+
+class SaveToPathTool():
+ """ This tool cannot be chosen by the user from the tools menu.
+ We dont add this to the list of tools. """
+
+ def __init__(self, img):
+ self.path = pdb.gimp_vectors_new(img, path_name)
+ pdb.gimp_image_add_vectors(img, self.path, 0)
+
+ def draw(self, layer, strokes, color=None):
+ # We need to multiply every point by 3, because we are creating a path,
+ # where each point has two additional control points.
+ control_points = []
+ for i, k in zip(strokes[0::2], strokes[1::2]):
+ control_points += [i, k] * 3
+
+ sid = pdb.gimp_vectors_stroke_new_from_points(self.path, 0, len(control_points),
+ control_points, False)
+
+
+tools = [
+ PreviewTool(),
+ StrokePaintTool(_("PaintBrush"), "gimp-paintbrush"),
+ PencilTool(), AirBrushTool(), StrokeTool(),
+ StrokePaintTool(_("Ink"), 'gimp-ink'),
+ StrokePaintTool(_("MyPaintBrush"), 'gimp-mybrush')
+ # Clone does not work properly when an image is not set. When that happens, drawing fails, and
+ # I am unable to catch the error. This causes the plugin to crash, and subsequent problems with undo.
+ # StrokePaintTool("Clone", 'gimp-clone', False)
+]
+
+
+class PatternParameters:
+ """
+ All the parameters that define a pattern live in objects of this class.
+ If you serialize and saved this class, you should reproduce
+ the pattern that the plugin would draw.
+ """
+ def __init__(self):
+ if not hasattr(self, 'curve_type'):
+ self.curve_type = 0
+
+ # Pattern
+ if not hasattr(self, 'pattern_notation'):
+ self.pattern_notation = 0
+ if not hasattr(self, 'outer_teeth'):
+ self.outer_teeth = 96
+ if not hasattr(self, 'inner_teeth'):
+ self.inner_teeth = 36
+ if not hasattr(self, 'pattern_rotation'):
+ self.pattern_rotation = 0
+ # Location of hole as a percent of the radius of the inner gear - runs between 0 and 100.
+ # A value of 0 means, the hole is at the center of the wheel, which would produce a boring circle.
+ # A value of 100 means the edge of the wheel.
+ if not hasattr(self, 'hole_percent'):
+ self.hole_percent = 100.0
+
+ # Toy Kit parameters
+ # Hole number in Toy Kit notation. Hole #1 is at the edge of the wheel, and the last hole is
+ # near the center of the wheel, but not exactly at the center.
+ if not hasattr(self, 'hole_number'):
+ self.hole_number = 1
+ if not hasattr(self, 'kit_fixed_gear_index'):
+ self.kit_fixed_gear_index = 1
+ if not hasattr(self, 'kit_moving_gear_index'):
+ self.kit_moving_gear_index = 1
+
+ # Visual notation parameters
+ if not hasattr(self, 'petals'):
+ self.petals = 5
+ if not hasattr(self, 'petal_skip'):
+ self.petal_skip = 2
+ if not hasattr(self, 'doughnut_hole'):
+ self.doughnut_hole = 50.0
+ if not hasattr(self, 'doughnut_width'):
+ self.doughnut_width = 50.0
+
+ # Shape
+ if not hasattr(self, 'shape_index'):
+ self.shape_index = 0 # Index in the shapes array
+ if not hasattr(self, 'sides'):
+ self.sides = 5
+ if not hasattr(self, 'morph'):
+ self.morph = 0.5
+ if not hasattr(self, 'shape_rotation'):
+ self.shape_rotation = 0
+
+ if not hasattr(self, 'equal_w_h'):
+ self.equal_w_h = False
+ if not hasattr(self, 'margin_pixels'):
+ self.margin_pixels = 0 # Distance between the drawn shape, and the selection borders.
+
+ # Drawing style
+ if not hasattr(self, 'tool_index'):
+ self.tool_index = 0 # Index in the tools array.
+ if not hasattr(self, 'long_gradient'):
+ self.long_gradient = False
+
+ if not hasattr(self, 'save_option'):
+ self.save_option = SAVE_AS_NEW_LAYER
+
+ def kit_max_hole_number(self):
+ return wheel[self.kit_moving_gear_index][1]
+
+
+# Handle shelving of plugin parameters
+
+def unshelf_parameters():
+ if shelf.has_key("p"):
+ parameters = shelf["p"]
+ parameters.__init__() # Fill in missing values with defaults.
+ return parameters
+
+ return PatternParameters()
+
+
+def shelf_parameters(pp):
+ shelf["p"] = pp
+
+
+class ComputedParameters:
+ """
+ Stores computations performed on a PatternParameters object.
+ The results of these computations are used to perform the drawing.
+ Having all these computations in one place makes it convenient to pass
+ around as a parameter.
+
+ If the pattern parameters should result in multiple pattern to be drawn, the
+ compute parameters also stores which one is currently being drawn.
+ """
+
+ def __init__(self, pp, img):
+
+ def compute_gradients():
+ self.use_gradient = self.pp.long_gradient and tools[self.pp.tool_index].can_color
+
+ # If gradient is used, determine how the lines are two be split to different colors.
+ if self.use_gradient:
+ # We want to use enough samples to be beautiful, but not too many, that would
+ # force us to make many separate calls for drawing the pattern.
+ if self.rotations > 30:
+ self.chunk_num = self.rotations
+ self.chunk_size_lines = self.fixed_gear_teeth
+ else:
+ # Lets try to find a chunk size, such that it divides num_lines, and we get at least 30 chunks.
+ # In the worse case, we will just use "1"
+ for chunk_size in range(self.fixed_gear_teeth - 1, 0, -1):
+ if self.num_lines % chunk_size == 0:
+ if self.num_lines / chunk_size > 30:
+ break
+
+ self.chunk_num = self.num_lines / chunk_size
+ self.chunk_size_lines = chunk_size
+
+ self.gradients = get_gradient_samples(self.chunk_num)
+ else:
+ self.chunk_num, self.chunk_size_lines = None, None
+
+ def compute_sizes():
+ # Get rid of the margins.
+ self.x1 = x1 + pp.margin_pixels
+ self.y1 = y1 + pp.margin_pixels
+ self.x2 = x2 - pp.margin_pixels
+ self.y2 = y2 - pp.margin_pixels
+
+ # Compute size and position of the pattern
+ self.x_half_size, self.y_half_size = (self.x2 - self.x1) / 2, (self.y2 - self.y1) / 2
+ self.x_center, self.y_center = (self.x1 + self.x2) / 2.0, (self.y1 + self.y2) / 2.0
+
+ if pp.equal_w_h:
+ if self.x_half_size < self.y_half_size:
+ self.y_half_size = self.x_half_size
+ self.y1, self.y2 = self.y_center - self.y_half_size, self.y_center + self.y_half_size
+ elif self.x_half_size > self.y_half_size:
+ self.x_half_size = self.y_half_size
+ self.x1, self.x2 = self.x_center - self.x_half_size, self.x_center + self.x_half_size
+
+ # Find the distance between the hole and the center of the inner circle.
+ # To do this, we compute the size of the gears, by the number of teeth.
+ # The circumference of the outer ring is 2 * pi * outer_R = #fixed_gear_teeth * tooth size.
+ outer_R = min(self.x_half_size, self.y_half_size)
+ if self.pp.pattern_notation == VISUAL_NOTATION:
+ doughnut_width = self.pp.doughnut_width
+ if doughnut_width + self.pp.doughnut_hole > 100:
+ doughnut_width = 100.0 - self.pp.doughnut_hole
+
+ # Let R, r be the radius of fixed and moving gear, and let hp be the hole percent.
+ # Let dwp, dhp be the doughnut width and hole in percents of R.
+ # The two sides of the following equation calculate how to reach the center of the moving
+ # gear from the center of the fixed gear:
+ # I) R * (dhp/100 + dwp/100/2) = R - r
+ # The following equation expresses which r and hp would generate a doughnut of width dw.
+ # II) R * dw/100 = 2 * r * hp/100
+ # We solve the two above equations to calculate hp and r:
+ self.hole_percent = doughnut_width / (2.0 * (1 - (self.pp.doughnut_hole + doughnut_width/2.0)/100.0))
+ self.moving_gear_radius = outer_R * doughnut_width / (2 * self.hole_percent)
+ else:
+ size_of_tooth_in_pixels = two_pi * outer_R / self.fixed_gear_teeth
+ self.moving_gear_radius = size_of_tooth_in_pixels * self.moving_gear_teeth / two_pi
+
+ self.hole_dist_from_center = self.hole_percent / 100.0 * self.moving_gear_radius
+
+ self.pp = pp
+
+ # Check if the shape is made of multiple shapes, as in using Selection as fixed gear.
+ if (isinstance(shapes[self.pp.shape_index], SelectionShape) and
+ curve_types[self.pp.curve_type].supports_shapes()):
+ shapes[self.pp.shape_index].process_selection(img)
+ pdb.gimp_displays_flush()
+ self.num_drawings = shapes[self.pp.shape_index].get_num_drawings()
+ else:
+ self.num_drawings = 1
+ self.current_drawing = 0
+
+ # Get bounds. We don't care weather a selection exists or not.
+ exists, x1, y1, x2, y2 = pdb.gimp_selection_bounds(img)
+
+ # Combine different ways to specify patterns, into a unified set of computed parameters.
+ self.num_notation_drawings = 1
+ self.current_notation_drawing = 0
+ if self.pp.pattern_notation == GEAR_NOTATION:
+ self.fixed_gear_teeth = int(round(pp.outer_teeth))
+ self.moving_gear_teeth = int(round(pp.inner_teeth))
+ self.petals = self.num_petals()
+ self.hole_percent = pp.hole_percent
+ elif self.pp.pattern_notation == TOY_KIT_NOTATION:
+ self.fixed_gear_teeth = ring_teeth[pp.kit_fixed_gear_index]
+ self.moving_gear_teeth = wheel[pp.kit_moving_gear_index][0]
+ self.petals = self.num_petals()
+ # We want to map hole #1 to 100% and hole of max_hole_number to 2.5%
+ # We don't want 0% because that would be the exact center of the moving gear,
+ # and that would create a boring pattern.
+ max_hole_number = wheel[pp.kit_moving_gear_index][1]
+ self.hole_percent = (max_hole_number - pp.hole_number) / float(max_hole_number - 1) * 97.5 + 2.5
+ elif self.pp.pattern_notation == VISUAL_NOTATION:
+ self.petals = pp.petals
+ self.fixed_gear_teeth = pp.petals
+ self.moving_gear_teeth = pp.petals - pp.petal_skip
+ if self.moving_gear_teeth < 20:
+ self.fixed_gear_teeth *= 10
+ self.moving_gear_teeth *= 10
+ self.hole_percent = 100.0
+ self.num_notation_drawings = fractions.gcd(pp.petals, pp.petal_skip)
+ self.notation_drawings_rotation = two_pi/pp.petals
+
+ # Rotations
+ self.shape_rotation_radians = self.radians_from_degrees(pp.shape_rotation)
+ self.pattern_rotation_start_radians = self.radians_from_degrees(pp.pattern_rotation)
+ self.pattern_rotation_radians = self.pattern_rotation_start_radians
+ # Additional fixed pattern rotation for lissajous.
+ self.lissajous_rotation = two_pi/self.petals/4.0
+
+ # Compute the total number of teeth we have to go over.
+ # Another way to view it is the total of lines we are going to draw.
+ # To find this we compute the Least Common Multiplier.
+ self.num_lines = lcm(self.fixed_gear_teeth, self.moving_gear_teeth)
+ # The number of points we are going to compute. This is the number of lines, plus 1, because to draw
+ # a line we need two points.
+ self.num_points = self.num_lines + 1
+
+ # Compute gradients.
+
+ # The number or rotations needed in order to complete the pattern.
+ # Each rotation has cp.fixed_gear_teeth points + 1 points.
+ self.rotations = self.num_lines / self.fixed_gear_teeth
+
+ compute_gradients()
+
+ # Computations needed for the actual drawing of the patterns - how much should we advance each angle
+ # in each step of the computation.
+
+ # How many radians is each tooth of outer gear. This is also the amount that we
+ # will step in the iterations that generate the points of the pattern.
+ self.oangle_factor = two_pi / self.fixed_gear_teeth
+ # How many radians should the moving gear be moved, for each tooth of the fixed gear
+ angle_factor = curve_types[pp.curve_type].get_angle_factor(self)
+ self.iangle_factor = self.oangle_factor * angle_factor
+
+ compute_sizes()
+
+ def num_petals(self):
+ """ The number of 'petals' (or points) that will be produced by a spirograph drawing. """
+ return lcm(self.fixed_gear_teeth, self.moving_gear_teeth) / self.moving_gear_teeth
+
+ def radians_from_degrees(self, degrees):
+ positive_degrees = degrees if degrees >= 0 else degrees + 360
+ return radians(positive_degrees)
+
+ def get_color(self, n):
+ return self.gradients[4*n:4*(n+1)]
+
+ def next_drawing(self):
+ """ Multiple drawings can be drawn either when the selection is used as a fixed
+ gear, and/or the visual tab is used, which causes multiple drawings
+ to be drawn at different rotations. """
+ if self.current_notation_drawing < self.num_notation_drawings - 1:
+ self.current_notation_drawing += 1
+ self.pattern_rotation_radians = self.pattern_rotation_start_radians + (
+ self.current_notation_drawing * self.notation_drawings_rotation)
+ else:
+ self.current_drawing += 1
+ self.current_notation_drawing = 0
+ self.pattern_rotation_radians = self.pattern_rotation_start_radians
+
+ def has_more_drawings(self):
+ return (self.current_notation_drawing < self.num_notation_drawings - 1 or
+ self.current_drawing < self.num_drawings - 1)
+
+
+### Curve types
+
+
+class CurveType:
+
+ def supports_shapes(self):
+ return True
+
+class RouletteCurveType(CurveType):
+
+ def get_strokes(self, p, cp):
+ strokes = []
+ for curr_tooth in range(cp.num_points):
+ iangle = fmod(curr_tooth * cp.iangle_factor + cp.pattern_rotation_radians, two_pi)
+ oangle = fmod(curr_tooth * cp.oangle_factor + cp.pattern_rotation_radians, two_pi)
+
+ x, y = shapes[p.shape_index].get_center_of_moving_gear(oangle)
+ strokes.append(x + cp.hole_dist_from_center * cos(iangle))
+ strokes.append(y + cp.hole_dist_from_center * sin(iangle))
+
+ return strokes
+
+
+class SpyroCurveType(RouletteCurveType):
+ name = _("Spyrograph")
+
+ def get_angle_factor(self, cp):
+ return - (cp.fixed_gear_teeth - cp.moving_gear_teeth) / float(cp.moving_gear_teeth)
+
+
+class EpitrochoidCurvetype(RouletteCurveType):
+ name = _("Epitrochoid")
+
+ def get_angle_factor(self, cp):
+ return (cp.fixed_gear_teeth + cp.moving_gear_teeth) / float(cp.moving_gear_teeth)
+
+
+class SineCurveType(CurveType):
+ name = _("Sine")
+
+ def get_angle_factor(self, cp):
+ return cp.fixed_gear_teeth / float(cp.moving_gear_teeth)
+
+ def get_strokes(self, p, cp):
+ strokes = []
+ for curr_tooth in range(cp.num_points):
+ iangle = curr_tooth * cp.iangle_factor
+ oangle = fmod(curr_tooth * cp.oangle_factor + cp.pattern_rotation_radians, two_pi)
+
+ dist = cp.moving_gear_radius + sin(iangle) * cp.hole_dist_from_center
+ x, y = shapes[p.shape_index].get_center_of_moving_gear(oangle, dist)
+ strokes.append(x)
+ strokes.append(y)
+
+ return strokes
+
+
+class LissaCurveType:
+ name = _("Lissajous")
+
+ def get_angle_factor(self, cp):
+ return cp.fixed_gear_teeth / float(cp.moving_gear_teeth)
+
+ def get_strokes(self, p, cp):
+ strokes = []
+ for curr_tooth in range(cp.num_points):
+ iangle = curr_tooth * cp.iangle_factor
+ # Adding the cp.lissajous_rotation rotation makes the pattern have the same number of curves
+ # as the other curve types. Without it, many lissajous patterns would redraw the same lines twice,
+ # and thus look less dense than the other curves.
+ oangle = fmod(curr_tooth * cp.oangle_factor + cp.pattern_rotation_radians + cp.lissajous_rotation, two_pi)
+
+ strokes.append(cp.x_center + cp.x_half_size * cos(oangle))
+ strokes.append(cp.y_center + cp.y_half_size * cos(iangle))
+
+ return strokes
+
+ def supports_shapes(self):
+ return False
+
+
+curve_types = [SpyroCurveType(), EpitrochoidCurvetype(), SineCurveType(), LissaCurveType()]
+
+# Drawing engine. Also implements drawing incrementally.
+# We don't draw the entire stroke, because it could take several seconds,
+# Instead, we break it into chunks. Incremental drawing is also used for drawing gradients.
+class DrawingEngine:
+
+ def __init__(self, img, p):
+ self.img, self.p = img, p
+ self.cp = None
+
+ # For incremental drawing
+ self.strokes = []
+ self.start = 0
+ self.chunk_size_lines = 600
+ self.chunk_no = 0
+ # We are aiming for the drawing time of a chunk to be no longer than max_time.
+ self.max_time_sec = 0.1
+
+ self.dynamic_chunk_size = True
+
+ def pre_draw(self):
+ """ Needs to be called before starting to draw a pattern. """
+
+ self.cp = ComputedParameters(self.p, self.img)
+
+ def draw_full(self, layer):
+ """ Non incremental drawing. """
+
+ self.pre_draw()
+ self.img.undo_group_start()
+
+ while true:
+ self.set_strokes()
+
+ if self.cp.use_gradient:
+ while self.has_more_strokes():
+ self.draw_next_chunk(layer, fetch_next_drawing=False)
+ else:
+ tools[self.p.tool_index].draw(layer, self.strokes)
+
+ if self.cp.has_more_drawings():
+ self.cp.next_drawing()
+ else:
+ break
+
+ self.img.undo_group_end()
+
+ pdb.gimp_displays_flush()
+
+ # Methods for incremental drawing.
+
+ def draw_next_chunk(self, layer, fetch_next_drawing=True, tool=None):
+ stroke_chunk, color = self.next_chunk(fetch_next_drawing)
+ if not tool:
+ tool = tools[self.p.tool_index]
+ tool.draw(layer, stroke_chunk, color)
+ return len(stroke_chunk)
+
+ def set_strokes(self):
+ """ Compute the strokes of the current pattern. The heart of the plugin. """
+
+ shapes[self.p.shape_index].configure(self.img, self.p, self.cp)
+
+ self.strokes = curve_types[self.p.curve_type].get_strokes(self.p, self.cp)
+
+ self.start = 0
+ self.chunk_no = 0
+
+ if self.cp.use_gradient:
+ self.chunk_size_lines = self.cp.chunk_size_lines
+ self.dynamic_chunk_size = False
+ else:
+ self.dynamic_chunk_size = True
+
+ def reset_incremental(self):
+ """ Setup incremental drawing to start drawing from scratch. """
+ self.pre_draw()
+ self.set_strokes()
+
+ def next_chunk(self, fetch_next_drawing):
+
+ # chunk_size_lines, is the number of lines we want to draw. We need 1 extra point to draw that.
+ end = self.start + (self.chunk_size_lines + 1) * 2
+ if end > len(self.strokes):
+ end = len(self.strokes)
+ result = self.strokes[self.start:end]
+ # Promote the start to the last point. This is the start of the first line to draw next time.
+ self.start = end - 2
+ color = self.cp.get_color(self.chunk_no) if self.cp.use_gradient else None
+
+ self.chunk_no += 1
+
+ # If self.strokes has ended, lets fetch strokes for the next drawing.
+ if fetch_next_drawing and not self.has_more_strokes():
+ if self.cp.has_more_drawings():
+ self.cp.next_drawing()
+ self.set_strokes()
+
+ return result, color
+
+ def has_more_strokes(self):
+ return self.start + 2 < len(self.strokes)
+
+ # Used for displaying progress.
+ def fraction_done(self):
+ return (self.start + 2.0) / len(self.strokes)
+
+ def report_time(self, time_sec):
+ """
+ Report the time it took, in seconds, to draw the last stroke chunk.
+ This helps to determine the size of chunks to return in future calls of 'next_chunk',
+ since we want the calls to be short, to not make the user interface feel stuck.
+ """
+ if time_sec != 0 and self.dynamic_chunk_size:
+ self.chunk_size_lines = int(self.chunk_size_lines * self.max_time_sec / time_sec)
+ # Don't let chunk size be too large or small.
+ self.chunk_size_lines = max(10, self.chunk_size_lines)
+ self.chunk_size_lines = min(1000, self.chunk_size_lines)
+
+
+# Constants for DoughnutWidget
+
+# Enum - When the mouse is pressed, which target value is being changed.
+TARGET_NONE, TARGET_HOLE, TARGET_WIDTH = range(3)
+
+CIRCLE_CENTER_X = 4
+RIGHT_MARGIN = 2
+TOTAL_MARGIN = CIRCLE_CENTER_X + RIGHT_MARGIN
+
+# A widget for displaying and setting the pattern of a spirograph, using a "doughnut" as
+# a visual metaphore. This widget replaces two scale widgets.
+class DoughnutWidget(gtk.DrawingArea):
+ __gtype_name__ = 'DoughnutWidget'
+
+ def __init__(self, *args, **kwds):
+ super(DoughnutWidget, self).__init__(*args, **kwds)
+ self.set_size_request(80, 40)
+
+ self.add_events(
+ gdk.BUTTON1_MOTION_MASK |
+ gdk.BUTTON_PRESS_MASK |
+ gdk.BUTTON_RELEASE_MASK |
+ gdk.POINTER_MOTION_MASK
+ )
+
+ self.default_cursor = self.get_screen().get_root_window().get_cursor()
+ self.resize_cursor = gdk.Cursor(gdk.SB_H_DOUBLE_ARROW)
+
+ self.button_pressed = False
+ self.target = TARGET_NONE
+
+ self.hole_radius = 30
+ self.doughnut_width = 30
+ self.connect("expose-event", self.expose)
+
+ def set_hole_radius(self, hole_radius):
+ self.queue_draw()
+ self.hole_radius = hole_radius
+
+ def get_hole_radius(self):
+ return self.hole_radius
+
+ def set_width(self, width):
+ self.queue_draw()
+ self.doughnut_width = width
+
+ def get_width(self):
+ return self.doughnut_width
+
+ def compute_doughnut(self):
+ """ Compute the location of the doughnut circles.
+ Returns (circle center x, circle center y, radius of inner circle, radius of outer circle) """
+ allocation = self.get_allocation()
+ alloc_width = allocation.width - TOTAL_MARGIN
+ return (
+ CIRCLE_CENTER_X, allocation.height / 2,
+ alloc_width * self.hole_radius / 100.0,
+ alloc_width * min(self.hole_radius + self.doughnut_width, 100.0) / 100.0
+ )
+
+ def set_cursor_h_resize(self):
+ """Set the mouse to be a double arrow."""
+ gdk_window = self.get_window()
+ gdk_window.set_cursor(self.resize_cursor)
+
+ def set_default_cursor(self):
+ gdk_window = self.get_window()
+ gdk_window.set_cursor(self.default_cursor)
+
+ def get_target(self, x, y):
+ # Find out if x, y is over one of the circle edges.
+
+ center_x, center_y, hole_radius, outer_radius = self.compute_doughnut()
+
+ # Compute distance from circle center to point
+ dist = sqrt((center_x - x) ** 2 + (center_y - y) ** 2)
+
+ if abs(dist - hole_radius) <= 3:
+ return TARGET_HOLE
+ if abs(dist - outer_radius) <= 3:
+ return TARGET_WIDTH
+
+ return TARGET_NONE
+
+ def expose(self, widget, event):
+
+ cr = widget.window.cairo_create()
+ center_x, center_y, hole_radius, outer_radius = self.compute_doughnut()
+ fg_color = gtk.widget_get_default_style().fg[gtk.STATE_NORMAL]
+
+ # Draw doughnut interior
+ arc = pi * 3 / 2.0
+ cr.set_source_rgba(fg_color.red, fg_color.green, fg_color.blue, 0.5)
+ cr.arc(center_x, center_y, hole_radius, -arc, arc)
+ cr.arc_negative(center_x, center_y, outer_radius, arc, -arc)
+ cr.close_path()
+ cr.fill()
+
+ # Draw doughnut border.
+ cr.set_source_rgb(fg_color.red, fg_color.green, fg_color.blue)
+ cr.set_line_width(3)
+ cr.arc_negative(center_x, center_y, outer_radius, arc, -arc)
+ cr.stroke()
+ if hole_radius < 1.0:
+ # If the radius is too small, nothing will be drawn, so draw a small cross marker instead.
+ cr.set_line_width(2)
+ cr.move_to(center_x - 4, center_y)
+ cr.line_to(center_x + 4, center_y)
+ cr.move_to(center_x, center_y - 4)
+ cr.line_to(center_x, center_y + 4)
+ else:
+ cr.arc(center_x, center_y, hole_radius, -arc, arc)
+ cr.stroke()
+
+ def compute_new_radius(self, x):
+ """ This method is called during mouse dragging of the widget.
+ Compute the new radius based on the current x location of the mouse pointer. """
+ allocation = self.get_allocation()
+
+ # How much does a single pixel difference in x, change the radius?
+ # Note that: allocation.width - TOTAL_MARGIN = 100 radius units,
+ radius_per_pixel = 100.0 / (allocation.width - TOTAL_MARGIN)
+ new_radius = self.start_radius + (x - self.start_x) * radius_per_pixel
+
+ if self.target == TARGET_HOLE:
+ self.hole_radius = max(min(new_radius, 99.0), 0.0)
+ else:
+ self.doughnut_width = max(min(new_radius, 100.0), 1.0)
+
+ self.queue_draw()
+
+ def do_button_press_event(self, event):
+ self.button_pressed = True
+
+ # If we clicked on one of the doughnut borders, remember which
+ # border we clicked on, and setup variable to start dragging it.
+ target = self.get_target(event.x, event.y)
+ if target == TARGET_HOLE or target == TARGET_WIDTH:
+ self.target = target
+ self.start_x = event.x
+ self.start_radius = (
+ self.hole_radius if target == TARGET_HOLE else
+ self.doughnut_width
+ )
+
+ def do_button_release_event(self, event):
+ # If one the doughnut borders was being dragged, recompute the doughnut size.
+ if self.target != TARGET_NONE:
+ self.compute_new_radius(event.x)
+ # Clip the width, if it is too large to fit.
+ if self.hole_radius + self.doughnut_width > 100:
+ self.doughnut_width = 100 - self.hole_radius
+ self.emit("values_changed", self.hole_radius, self.doughnut_width)
+
+ self.button_pressed = False
+ self.target = TARGET_NONE
+
+ def do_motion_notify_event(self, event):
+ if self.button_pressed:
+ # We are dragging one of the doughnut borders; recompute its size.
+ if self.target != TARGET_NONE:
+ self.compute_new_radius(event.x)
+ else:
+ # Set cursor according to whether we are over one of the
+ # doughnut borders.
+ target = self.get_target(event.x, event.y)
+ if target == TARGET_NONE:
+ self.set_default_cursor()
+ else:
+ self.set_cursor_h_resize()
+
+
+# Create signal that returns change parameters.
+gobject.type_register(DoughnutWidget)
+gobject.signal_new("values_changed", DoughnutWidget, gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT))
+
+
+class SpyroWindow(gtk.Window):
+
+ # Define signal to catch escape key.
+ __gsignals__ = dict(
+ myescape=(gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION,
+ None, # return type
+ (str,)) # arguments
+ )
+
+ class MyScale():
+ """ Combintation of scale and spin that control the same adjuster. """
+ def __init__(self, scale, spin):
+ self.scale, self.spin = scale, spin
+
+ def set_sensitive(self, val):
+ self.scale.set_sensitive(val)
+ self.spin.set_sensitive(val)
+
+ def __init__(self, img, layer):
+
+ def add_horizontal_separator(vbox):
+ hsep = gtk.HSeparator()
+ vbox.add(hsep)
+ hsep.show()
+
+ def add_vertical_space(vbox, height):
+ hbox = gtk.HBox()
+ hbox.set_border_width(height/2)
+ vbox.add(hbox)
+ hbox.show()
+
+ def add_to_box(box, w):
+ box.add(w)
+ w.show()
+
+ def create_table(rows, columns, border_width):
+ table = gtk.Table(rows=rows, columns=columns, homogeneous=False)
+ table.set_border_width(border_width)
+ table.set_col_spacings(10)
+ table.set_row_spacings(10)
+ return table
+
+ def label_in_table(label_text, table, row, tooltip_text=None, col=0, col_add=1):
+ """ Create a label and set it in first col of table. """
+ label = gtk.Label(label_text)
+ label.set_alignment(xalign=0.0, yalign=1.0)
+ if tooltip_text:
+ label.set_tooltip_text(tooltip_text)
+ table.attach(label, col, col + col_add, row, row + 1, xoptions=gtk.FILL, yoptions=0)
+ label.show()
+
+ def spin_in_table(adj, table, row, callback, digits=0, col=0):
+ spin = gtk.SpinButton(adj, climb_rate=0.5, digits=digits)
+ spin.set_numeric(True)
+ spin.set_snap_to_ticks(True)
+ spin.set_max_length(5)
+ spin.set_width_chars(5)
+ table.attach(spin, col, col + 1, row, row + 1, xoptions=0, yoptions=0)
+ spin.show()
+ adj.connect("value_changed", callback)
+ return spin
+
+ def hscale_in_table(adj, table, row, callback, digits=0, col=1, cols=1):
+ """ Create an hscale and a spinner using the same Adjustment, and set it in table. """
+ scale = gtk.HScale(adj)
+ scale.set_size_request(150, -1)
+ scale.set_digits(digits)
+ scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
+ table.attach(scale, col, col + cols, row, row + 1, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
+ scale.show()
+
+ spin = gtk.SpinButton(adj, climb_rate=0.5, digits=digits)
+ spin.set_numeric(True)
+ spin.set_snap_to_ticks(True)
+ spin.set_max_length(5)
+ spin.set_width_chars(5)
+ table.attach(spin, col + cols , col + cols + 1, row, row + 1, xoptions=0, yoptions=0)
+ spin.show()
+
+ adj.connect("value_changed", callback)
+
+ return self.MyScale(scale, spin)
+
+ def rotation_in_table(val, table, row, callback):
+ adj = gtk.Adjustment(val, -180.0, 180.0, 1.0)
+ myscale = hscale_in_table(adj, table, row, callback, digits=1)
+ myscale.scale.add_mark(0.0, gtk.POS_BOTTOM, None)
+ myscale.spin.set_max_length(6)
+ myscale.spin.set_width_chars(6)
+ return adj, myscale
+
+ def set_combo_in_table(txt_list, table, row, callback):
+ combo = gtk.combo_box_new_text()
+ for txt in txt_list:
+ combo.append_text(txt)
+ table.attach(combo, 1, 2, row, row + 1, xoptions=gtk.FILL, yoptions=0)
+ combo.show()
+ combo.connect("changed", callback)
+ return combo
+
+ # Return table which is at the top of the dialog, and has several major input widgets.
+ def top_table():
+
+ # Add table for displaying attributes, each having a label and an input widget.
+ table = create_table(2, 3, 10)
+
+ # Curve type
+ row = 0
+ label_in_table(_("Curve Type"), table, row,
+ _("An Epitrochoid pattern is when the moving gear is on the outside of the fixed gear."))
+ self.curve_type_combo = set_combo_in_table([ct.name for ct in curve_types], table, row,
+ self.curve_type_changed)
+
+ row += 1
+ label_in_table(_("Tool"), table, row,
+ _("The tool with which to draw the pattern. "
+ "The Preview tool just draws quickly."))
+ self.tool_combo = set_combo_in_table([tool.name for tool in tools], table, row,
+ self.tool_combo_changed)
+
+ self.long_gradient_checkbox = gtk.CheckButton(_("Long Gradient"))
+ self.long_gradient_checkbox.set_tooltip_text(
+ _("When unchecked, the current tool settings will be used. "
+ "When checked, will use a long gradient to match the length of the pattern, "
+ "based on current gradient and repeat mode from the gradient tool settings.")
+ )
+ self.long_gradient_checkbox.set_border_width(0)
+ table.attach(self.long_gradient_checkbox, 2, 3, row, row + 1, xoptions=0, yoptions=0)
+ self.long_gradient_checkbox.show()
+ self.long_gradient_checkbox.connect("toggled", self.long_gradient_changed)
+
+ return table
+
+ def pattern_notation_frame():
+
+ vbox = gtk.VBox(spacing=0, homogeneous=False)
+
+ add_vertical_space(vbox, 14)
+
+ hbox = gtk.HBox(spacing=5)
+ hbox.set_border_width(5)
+
+ label = gtk.Label(_("Specify pattern using one of the following tabs:"))
+ label.set_tooltip_text(_(
+ "The pattern is specified only by the active tab. Toy Kit is similar to Gears, "
+ "but it uses gears and hole numbers which are found in toy kits. "
+ "If you follow the instructions from the toy kit manuals, results should be similar."))
+ hbox.pack_start(label)
+ label.show()
+
+ alignment = gtk.Alignment(xalign=0.0, yalign=0.0, xscale=0.0, yscale=0.0)
+ alignment.add(hbox)
+ hbox.show()
+ vbox.add(alignment)
+ alignment.show()
+
+ self.pattern_notebook = gtk.Notebook()
+ self.pattern_notebook.set_border_width(0)
+ self.pattern_notebook.connect('switch-page', self.pattern_notation_tab_changed)
+
+ # "Gear" pattern notation.
+
+ # Add table for displaying attributes, each having a label and an input widget.
+ gear_table = create_table(3, 3, 5)
+
+ # Teeth
+ row = 0
+ fixed_gear_tooltip = _(
+ "Number of teeth of fixed gear. The size of the fixed gear is "
+ "proportional to the number of teeth."
+ )
+ label_in_table(_("Fixed Gear Teeth"), gear_table, row, fixed_gear_tooltip)
+ self.outer_teeth_adj = gtk.Adjustment(self.p.outer_teeth, 10, 180, 1)
+ hscale_in_table(self.outer_teeth_adj, gear_table, row, self.outer_teeth_changed)
+
+ row += 1
+ moving_gear_tooltip = _(
+ "Number of teeth of moving gear. The size of the moving gear is "
+ "proportional to the number of teeth."
+ )
+ label_in_table(_("Moving Gear Teeth"), gear_table, row, moving_gear_tooltip)
+ self.inner_teeth_adj = gtk.Adjustment(self.p.inner_teeth, 2, 100, 1)
+ hscale_in_table(self.inner_teeth_adj, gear_table, row, self.inner_teeth_changed)
+
+ row += 1
+ label_in_table(_("Hole percent"), gear_table, row,
+ _("How far is the hole from the center of the moving gear. "
+ "100% means that the hole is at the gear's edge."))
+ self.hole_percent_adj = gtk.Adjustment(self.p.hole_percent, 2.5, 100.0, 0.5)
+ self.hole_percent_myscale = hscale_in_table(self.hole_percent_adj, gear_table,
+ row, self.hole_percent_changed, digits=1)
+
+ # "Kit" pattern notation.
+
+ kit_table = create_table(3, 3, 5)
+
+ row = 0
+ label_in_table(_("Fixed Gear Teeth"), kit_table, row, fixed_gear_tooltip)
+ self.kit_outer_teeth_combo = set_combo_in_table([str(t) for t in ring_teeth], kit_table, row,
+ self.kit_outer_teeth_combo_changed)
+
+ row += 1
+ label_in_table(_("Moving Gear Teeth"), kit_table, row, moving_gear_tooltip)
+ self.kit_inner_teeth_combo = set_combo_in_table([str(t) for t in wheel_teeth], kit_table, row,
+ self.kit_inner_teeth_combo_changed)
+
+ row += 1
+ label_in_table(_("Hole Number"), kit_table, row,
+ _("Hole #1 is at the edge of the gear. "
+ "The maximum hole number is near the center. "
+ "The maximum hole number is different for each gear."))
+ self.kit_hole_adj = gtk.Adjustment(self.p.hole_number, 1, self.p.kit_max_hole_number(), 1)
+ self.kit_hole_myscale = hscale_in_table(self.kit_hole_adj, kit_table, row, self.kit_hole_changed)
+
+ # "Visual" pattern notation.
+
+ visual_table = create_table(3, 5, 5)
+
+ row = 0
+ label_in_table(_("Flower Petals"), visual_table, row, _("The number of petals in the pattern."))
+ self.petals_adj = gtk.Adjustment(self.p.petals, 2, 100, 1)
+ hscale_in_table(self.petals_adj, visual_table, row, self.petals_changed, cols=3)
+
+ row += 1
+ label_in_table(_("Petal Skip"), visual_table, row,
+ _("The number of petals to advance for drawing the next petal."))
+ self.petal_skip_adj = gtk.Adjustment(self.p.petal_skip, 1, 50, 1)
+ hscale_in_table(self.petal_skip_adj, visual_table, row, self.petal_skip_changed, cols=3)
+
+ row += 1
+ label_in_table(_("Hole Radius(%)"), visual_table, row,
+ _("The radius of the hole in the center of the pattern "
+ "where nothing will be drawn. Given as a percentage of the "
+ "size of the pattern. A value of 0 will produce no hole. "
+ "A Value of 99 will produce a thin line on the edge."))
+ self.doughnut_hole_adj = gtk.Adjustment(self.p.doughnut_hole, 0.0, 99.0, 0.1)
+ self.doughnut_hole_myscale = spin_in_table(self.doughnut_hole_adj,
+ visual_table, row, self.doughnut_hole_changed, 1, 1)
+
+ self.doughnut = DoughnutWidget()
+ visual_table.attach(self.doughnut, 2, 3, row, row+1, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
+ self.doughnut.connect('values_changed', self.doughnut_changed)
+ self.doughnut.show()
+
+ label_in_table(_("Width(%)"), visual_table, row,
+ _("The width of the pattern as a percentage of the "
+ "size of the pattern. A Value of 1 will just draw a thin pattern. "
+ "A Value of 100 will fill the entire fixed gear."), 3)
+ self.doughnut_width_adj = gtk.Adjustment(self.p.doughnut_width, 1.0, 100.0, 0.1)
+ self.doughnut_width_myscale = spin_in_table(self.doughnut_width_adj,
+ visual_table, row, self.doughnut_width_changed, 1, 4)
+
+ # Add tables as children of the pattern notebook
+
+ pattern_notation_page[VISUAL_NOTATION] = self.pattern_notebook.append_page(visual_table)
+ self.pattern_notebook.set_tab_label_text(visual_table, _("Visual"))
+ self.pattern_notebook.set_tab_label_packing(visual_table, 0, 0, gtk.PACK_END)
+ visual_table.show()
+
+ pattern_notation_page[TOY_KIT_NOTATION] = self.pattern_notebook.append_page(kit_table)
+ self.pattern_notebook.set_tab_label_text(kit_table, _("Toy Kit"))
+ self.pattern_notebook.set_tab_label_packing(kit_table, 0, 0, gtk.PACK_END)
+ kit_table.show()
+
+ pattern_notation_page[GEAR_NOTATION] = self.pattern_notebook.append_page(gear_table)
+ self.pattern_notebook.set_tab_label_text(gear_table, _("Gears"))
+ self.pattern_notebook.set_tab_label_packing(gear_table, 0, 0, gtk.PACK_END)
+ gear_table.show()
+
+ add_to_box(vbox, self.pattern_notebook)
+
+ add_vertical_space(vbox, 14)
+
+ hbox = gtk.HBox(spacing=5)
+ pattern_table = create_table(1, 3, 5)
+
+ row = 0
+ label_in_table(_("Rotation"), pattern_table, row,
+ _("Rotation of the pattern, in degrees. "
+ "The starting position of the moving gear in the fixed gear."))
+ self.pattern_rotation_adj, myscale = rotation_in_table(
+ self.p.pattern_rotation, pattern_table, row, self.pattern_rotation_changed
+ )
+
+ hbox.pack_end(pattern_table, expand=True, fill=True, padding=0)
+ pattern_table.show()
+
+ vbox.add(hbox)
+ hbox.show()
+
+ return vbox
+
+ def fixed_gear_page():
+
+ vbox = gtk.VBox(spacing=0, homogeneous=False)
+
+ add_vertical_space(vbox, 14)
+
+ table = create_table(4, 2, 10)
+
+ row = 0
+ label_in_table(_("Shape"), table, row,
+ _("The shape of the fixed gear to be used inside current selection. "
+ "Rack is a long round-edged shape provided in the toy kits. "
+ "Frame hugs the boundaries of the rectangular selection, "
+ "use hole=100 in Gear notation to touch boundary. "
+ "Selection will hug boundaries of current selection - try something non-rectangular."))
+ self.shape_combo = set_combo_in_table([shape.name for shape in shapes], table, row,
+ self.shape_combo_changed)
+
+ row += 1
+ label_in_table(_("Sides"), table, row, _("Number of sides of the shape."))
+ self.sides_adj = gtk.Adjustment(self.p.sides, 3, 16, 1)
+ self.sides_myscale = hscale_in_table(self.sides_adj, table, row, self.sides_changed)
+
+ row += 1
+ label_in_table(_("Morph"), table, row, _("Morph fixed gear shape. Only affects some of the shapes."))
+ self.morph_adj = gtk.Adjustment(self.p.morph, 0.0, 1.0, 0.01)
+ self.morph_myscale = hscale_in_table(self.morph_adj, table, row, self.morph_changed, digits=2)
+
+ row += 1
+ label_in_table(_("Rotation"), table, row, _("Rotation of the fixed gear, in degrees"))
+ self.shape_rotation_adj, self.shape_rotation_myscale = rotation_in_table(
+ self.p.shape_rotation, table, row, self.shape_rotation_changed
+ )
+
+ add_to_box(vbox, table)
+ return vbox
+
+ def size_page():
+
+ vbox = gtk.VBox(spacing=0, homogeneous=False)
+ add_vertical_space(vbox, 14)
+ table = create_table(2, 2, 10)
+
+ row = 0
+ label_in_table(_("Margin (px)"), table, row, _("Margin from edge of selection."))
+ self.margin_adj = gtk.Adjustment(self.p.margin_pixels, 0, max(img.height, img.width), 1)
+ hscale_in_table(self.margin_adj, table, row, self.margin_changed)
+
+ row += 1
+ self.equal_w_h_checkbox = gtk.CheckButton(_("Make width and height equal"))
+ self.equal_w_h_checkbox.set_tooltip_text(
+ _("When unchecked, the pattern will fill the current image or selection. "
+ "When checked, the pattern will have same width and height, and will be centered.")
+ )
+ self.equal_w_h_checkbox.set_border_width(15)
+ table.attach(self.equal_w_h_checkbox, 0, 2, row, row + 1)
+ self.equal_w_h_checkbox.show()
+ self.equal_w_h_checkbox.connect("toggled", self.equal_w_h_checkbox_changed)
+
+
+ add_to_box(vbox, table)
+ return vbox
+
+ def add_button_to_box(box, text, callback, tooltip_text=None):
+ btn = gtk.Button(text)
+ if tooltip_text:
+ btn.set_tooltip_text(tooltip_text)
+ box.add(btn)
+ btn.show()
+ btn.connect("clicked", callback)
+ return btn
+
+ def dialog_button_box():
+ hbox = gtk.HBox(homogeneous=True, spacing=20)
+
+ add_button_to_box(hbox, _("Re_draw"), self.redraw,
+ _("If you change the settings of a tool, change color, or change the selection, "
+ "press this to preview how the pattern looks."))
+ add_button_to_box(hbox, _("_Reset"), self.reset_params)
+ add_button_to_box(hbox, _("_Cancel"), self.cancel_window)
+ self.ok_btn = add_button_to_box(hbox, _("_OK"), self.ok_window)
+
+ self.save_option_combo = gtk.combo_box_new_text()
+ for txt in save_options:
+ self.save_option_combo.append_text(txt)
+ self.save_option_combo.set_tooltip_text(
+ _("Choose whether to save as new layer, redraw on last active layer, or save to path")
+ )
+ hbox.add(self.save_option_combo)
+ self.save_option_combo.show()
+ self.save_option_combo.connect("changed", self.save_option_changed)
+
+ return hbox
+
+ def create_ui():
+
+ # Create the dialog
+ gtk.Window.__init__(self)
+ self.set_title(_("Spyrogimp"))
+ self.set_default_size(350, -1)
+ self.set_border_width(10)
+ # self.set_keep_above(True) # keep the window on top
+
+ # Vertical box in which we will add all the UI elements.
+ vbox = gtk.VBox(spacing=10, homogeneous=False)
+ self.add(vbox)
+
+ box = gimpui.HintBox(_("Draw spyrographs using current tool settings and selection."))
+ vbox.pack_start(box, expand=False)
+ box.show()
+
+ add_horizontal_separator(vbox)
+
+ add_to_box(vbox, top_table())
+
+ self.main_notebook = gtk.Notebook()
+ self.main_notebook.set_show_tabs(True)
+ self.main_notebook.set_border_width(5)
+
+ pattern_frame = pattern_notation_frame()
+ self.main_notebook.append_page(pattern_frame, gtk.Label(_("Curve Pattern")))
+ pattern_frame.show()
+ fixed_g_page = fixed_gear_page()
+ self.main_notebook.append_page(fixed_g_page, gtk.Label(_("Fixed Gear")))
+ fixed_g_page.show()
+ size_p = size_page()
+ self.main_notebook.append_page(size_p, gtk.Label(_("Size")))
+ size_p.show()
+
+ vbox.add(self.main_notebook)
+ self.main_notebook.show()
+
+ add_horizontal_separator(vbox)
+
+ self.progress_bar = gtk.ProgressBar() # gimpui.ProgressBar() - causes gimppdbprogress error message.
+ self.progress_bar.set_size_request(-1, 30)
+ vbox.add(self.progress_bar)
+ self.progress_bar.show()
+
+ add_to_box(vbox, dialog_button_box())
+
+ vbox.show()
+ self.show()
+
+ self.enable_incremental_drawing = False
+
+ self.img = img
+ # Remember active layer, so we can restore it when the plugin is done.
+ self.active_layer = layer
+
+ self.p = unshelf_parameters() # Model
+
+ self.engine = DrawingEngine(img, self.p)
+
+ # Make a new GIMP layer to draw on
+ self.spyro_layer = gimp.Layer(img, layer_name, img.width, img.height,
+ layer.type_with_alpha, 100, NORMAL_MODE)
+ img.add_layer(self.spyro_layer, 0)
+
+ self.drawing_layer = self.spyro_layer
+
+ gimpui.gimp_ui_init()
+ create_ui()
+ self.update_view()
+
+ # Obey the window manager quit signal
+ self.connect("destroy", self.cancel_window)
+ # Connect Escape key to quit the window as well.
+ self.connect('myescape', self.cancel_window)
+
+ # Setup for Handling incremental/interactive drawing of pattern
+ self.idle_task = None
+ self.enable_incremental_drawing = True
+
+ # Draw pattern of the current settings.
+ self.start_new_incremental_drawing()
+
+ # Callbacks for closing the plugin
+
+ def clear_idle_task(self):
+ if self.idle_task:
+ gobject.source_remove(self.idle_task)
+ # Close the undo group in the likely case the idle task left it open.
+ self.img.undo_group_end()
+ self.idle_task = None
+
+ def ok_window(self, widget):
+ """ Called when clicking on the 'close' button. """
+
+ self.ok_btn.set_sensitive(False)
+
+ shelf_parameters(self.p)
+
+ if self.p.save_option == SAVE_AS_NEW_LAYER:
+ if self.spyro_layer in self.img.layers:
+ self.img.active_layer = self.spyro_layer
+
+ # If we are in the middle of incremental draw, we want to complete it, and only then to exit.
+ # However, in order to complete it, we need to create another idle task.
+ if self.idle_task:
+ def quit_dialog_on_completion():
+ while self.idle_task:
+ yield True
+
+ gtk.main_quit() # This will quit the dialog.
+ yield False
+
+ task = quit_dialog_on_completion()
+ gobject.idle_add(task.next)
+ else:
+ gtk.main_quit()
+ else:
+ # If there is an incremental drawing taking place, lets stop it.
+ self.clear_idle_task()
+
+ if self.spyro_layer in self.img.layers:
+ self.img.remove_layer(self.spyro_layer)
+ self.img.active_layer = self.active_layer
+
+ self.drawing_layer = self.active_layer
+
+ def draw_full(tool):
+ self.progress_start()
+ yield True
+
+ self.engine.reset_incremental()
+
+ self.img.undo_group_start()
+
+ while self.engine.has_more_strokes():
+ yield True
+ self.draw_next_chunk(tool=tool)
+
+ self.img.undo_group_end()
+
+ pdb.gimp_displays_flush()
+
+ gtk.main_quit()
+ yield False
+
+ tool = SaveToPathTool(self.img) if self.p.save_option == SAVE_AS_PATH else None
+ task = draw_full(tool)
+ gobject.idle_add(task.next)
+
+ def cancel_window(self, widget, what=None):
+ self.clear_idle_task()
+
+ # We want to delete the temporary layer, but as a precaution, lets ask first,
+ # maybe it was already deleted by the user.
+ if self.spyro_layer in self.img.layers:
+ self.img.remove_layer(self.spyro_layer)
+ pdb.gimp_displays_flush()
+ gtk.main_quit()
+
+ def update_view(self):
+ """ Update the UI to reflect the values in the Pattern Parameters. """
+ self.curve_type_combo.set_active(self.p.curve_type)
+ self.curve_type_side_effects()
+
+ self.pattern_notebook.set_current_page(pattern_notation_page[self.p.pattern_notation])
+
+ self.outer_teeth_adj.set_value(self.p.outer_teeth)
+ self.inner_teeth_adj.set_value(self.p.inner_teeth)
+ self.hole_percent_adj.set_value(self.p.hole_percent)
+ self.pattern_rotation_adj.set_value(self.p.pattern_rotation)
+
+ self.kit_outer_teeth_combo.set_active(self.p.kit_fixed_gear_index)
+ self.kit_inner_teeth_combo.set_active(self.p.kit_moving_gear_index)
+ self.kit_hole_adj.set_value(self.p.hole_number)
+ self.kit_inner_teeth_combo_side_effects()
+
+ self.petals_adj.set_value(self.p.petals)
+ self.petal_skip_adj.set_value(self.p.petal_skip)
+ self.doughnut_hole_adj.set_value(self.p.doughnut_hole)
+ self.doughnut.set_hole_radius(self.p.doughnut_hole)
+ self.doughnut_width_adj.set_value(self.p.doughnut_width)
+ self.doughnut.set_width(self.p.doughnut_width)
+ self.petals_changed_side_effects()
+
+ self.shape_combo.set_active(self.p.shape_index)
+ self.shape_combo_side_effects()
+ self.sides_adj.set_value(self.p.sides)
+ self.morph_adj.set_value(self.p.morph)
+ self.equal_w_h_checkbox.set_active(self.p.equal_w_h)
+ self.shape_rotation_adj.set_value(self.p.shape_rotation)
+
+ self.margin_adj.set_value(self.p.margin_pixels)
+ self.tool_combo.set_active(self.p.tool_index)
+ self.long_gradient_checkbox.set_active(self.p.long_gradient)
+ self.save_option_combo.set_active(self.p.save_option)
+
+ def reset_params(self, widget):
+ self.engine.p = self.p = PatternParameters()
+ self.update_view()
+
+ # Callbacks to handle changes in dialog parameters.
+
+ def curve_type_side_effects(self):
+ if curve_types[self.p.curve_type].supports_shapes():
+ self.shape_combo.set_sensitive(True)
+
+ self.sides_myscale.set_sensitive(shapes[self.p.shape_index].has_sides())
+ self.morph_myscale.set_sensitive(shapes[self.p.shape_index].can_morph())
+ self.shape_rotation_myscale.set_sensitive(shapes[self.p.shape_index].can_rotate())
+
+ self.hole_percent_myscale.set_sensitive(True)
+ self.kit_hole_myscale.set_sensitive(True)
+
+ self.doughnut_hole_myscale.set_sensitive(True)
+ self.doughnut_width_myscale.set_sensitive(True)
+ else:
+ # Lissajous curves do not have shapes, or holes for moving gear
+ self.shape_combo.set_sensitive(False)
+
+ self.sides_myscale.set_sensitive(False)
+ self.morph_myscale.set_sensitive(False)
+ self.shape_rotation_myscale.set_sensitive(False)
+
+ self.hole_percent_myscale.set_sensitive(False)
+ self.kit_hole_myscale.set_sensitive(False)
+
+ self.doughnut_hole_myscale.set_sensitive(False)
+ self.doughnut_width_myscale.set_sensitive(False)
+
+ def curve_type_changed(self, val):
+ self.p.curve_type = val.get_active()
+ self.curve_type_side_effects()
+ self.redraw()
+
+ def pattern_notation_tab_changed(self, notebook, page, page_num, user_param1=None):
+ if self.enable_incremental_drawing:
+ for notation in pattern_notation_page:
+ if pattern_notation_page[notation] == page_num:
+ self.p.pattern_notation = notation
+
+ self.redraw()
+
+ # Callbacks: pattern changes using the Toy Kit notation.
+
+ def kit_outer_teeth_combo_changed(self, val):
+ self.p.kit_fixed_gear_index = val.get_active()
+ self.redraw()
+
+ def kit_inner_teeth_combo_side_effects(self):
+ # Change the max hole number according to the newly activated wheel.
+ # We might also need to update the hole value, if it is larger than the new max.
+ max_hole_number = self.p.kit_max_hole_number()
+ if self.p.hole_number > max_hole_number:
+ self.p.hole_number = max_hole_number
+ self.kit_hole_adj.set_value(max_hole_number)
+ self.kit_hole_adj.set_upper(max_hole_number)
+
+ def kit_inner_teeth_combo_changed(self, val):
+ self.p.kit_moving_gear_index = val.get_active()
+ self.kit_inner_teeth_combo_side_effects()
+ self.redraw()
+
+ def kit_hole_changed(self, val):
+ self.p.hole_number = val.value
+ self.redraw()
+
+ # Callbacks: pattern changes using the Gears notation.
+
+ def outer_teeth_changed(self, val):
+ self.p.outer_teeth = val.value
+ self.redraw()
+
+ def inner_teeth_changed(self, val):
+ self.p.inner_teeth = val.value
+ self.redraw()
+
+ def hole_percent_changed(self, val):
+ self.p.hole_percent = val.value
+ self.redraw()
+
+ def pattern_rotation_changed(self, val):
+ self.p.pattern_rotation = val.value
+ self.redraw()
+
+ # Callbacks: pattern changes using the Visual notation.
+
+ def petals_changed_side_effects(self):
+ max_petal_skip = int(self.p.petals/2)
+ if self.p.petal_skip > max_petal_skip:
+ self.p.petal_skip = max_petal_skip
+ self.petal_skip_adj.set_value(max_petal_skip)
+ self.petal_skip_adj.set_upper(max_petal_skip)
+
+ def petals_changed(self, val):
+ self.p.petals = int(val.value)
+ self.petals_changed_side_effects()
+ self.redraw()
+
+ def petal_skip_changed(self, val):
+ self.p.petal_skip = int(val.value)
+ self.redraw()
+
+ def doughnut_hole_changed(self, val):
+ self.p.doughnut_hole = val.value
+ self.doughnut.set_hole_radius(val.value)
+ self.redraw()
+
+ def doughnut_width_changed(self, val):
+ self.p.doughnut_width = val.value
+ self.doughnut.set_width(val.value)
+ self.redraw()
+
+ def doughnut_changed(self, widget, hole, width):
+ self.doughnut_hole_adj.set_value(hole)
+ self.doughnut_width_adj.set_value(width)
+ # We don't need to redraw, because the callbacks of the doughnut hole and
+ # width spinners will be triggered by the above lines.
+
+ # Callbacks: Fixed gear
+
+ def shape_combo_side_effects(self):
+ self.sides_myscale.set_sensitive(shapes[self.p.shape_index].has_sides())
+ self.morph_myscale.set_sensitive(shapes[self.p.shape_index].can_morph())
+ self.shape_rotation_myscale.set_sensitive(shapes[self.p.shape_index].can_rotate())
+ self.equal_w_h_checkbox.set_sensitive(shapes[self.p.shape_index].can_equal_w_h())
+
+ def shape_combo_changed(self, val):
+ self.p.shape_index = val.get_active()
+ self.shape_combo_side_effects()
+ self.redraw()
+
+ def sides_changed(self, val):
+ self.p.sides = val.value
+ self.redraw()
+
+ def morph_changed(self, val):
+ self.p.morph = val.value
+ self.redraw()
+
+ def equal_w_h_checkbox_changed(self, val):
+ self.p.equal_w_h = val.get_active()
+ self.redraw()
+
+ def shape_rotation_changed(self, val):
+ self.p.shape_rotation = val.value
+ self.redraw()
+
+ def margin_changed(self, val) :
+ self.p.margin_pixels = val.value
+ self.redraw()
+
+ # Style callbacks
+
+ def tool_changed_side_effects(self):
+ self.long_gradient_checkbox.set_sensitive(tools[self.p.tool_index].can_color)
+
+ def tool_combo_changed(self, val):
+ self.p.tool_index = val.get_active()
+ self.tool_changed_side_effects()
+ self.redraw()
+
+ def long_gradient_changed(self, val):
+ self.p.long_gradient = val.get_active()
+ self.redraw()
+
+ def save_option_changed(self, val):
+ self.p.save_option = self.save_option_combo.get_active()
+
+ # Progress bar of plugin window.
+
+ def progress_start(self):
+ self.progress_bar.set_text(_("Rendering Pattern"))
+ self.progress_bar.set_fraction(0.0)
+ pdb.gimp_displays_flush()
+
+ def progress_end(self):
+ self.progress_bar.set_text("")
+ self.progress_bar.set_fraction(0.0)
+
+ def progress_update(self):
+ self.progress_bar.set_fraction(self.engine.fraction_done())
+
+ def progress_unknown(self):
+ self.progress_bar.set_text(_("Please wait : Rendering Pattern"))
+ self.progress_bar.pulse()
+ pdb.gimp_displays_flush()
+
+ # Incremental drawing.
+
+ def draw_next_chunk(self, tool=None):
+ """ Incremental drawing """
+
+ t = time.time()
+
+ chunk_size = self.engine.draw_next_chunk(self.drawing_layer, tool=tool)
+
+ draw_time = time.time() - t
+ self.engine.report_time(draw_time)
+ print("Chunk size " + str(chunk_size) + " time " + str(draw_time))
+
+ if self.engine.has_more_strokes():
+ self.progress_update()
+ else:
+ self.progress_end()
+
+ pdb.gimp_displays_flush()
+
+ def start_new_incremental_drawing(self):
+ """
+ Compute strokes for the current pattern, and store then in the IncrementalDraw object,
+ so they can be drawn in pieces without blocking the user.
+ Finally, draw the first chunk of strokes.
+ """
+
+ def incremental_drawing():
+ self.progress_start()
+ yield True
+ self.engine.reset_incremental()
+
+ self.img.undo_group_start()
+ while self.engine.has_more_strokes():
+ yield True
+ self.draw_next_chunk()
+ self.img.undo_group_end()
+
+ self.idle_task = None
+ yield False
+
+ # Start new idle task to perform incremental drawing in the background.
+ self.clear_idle_task()
+ task = incremental_drawing()
+ self.idle_task = gobject.idle_add(task.next)
+
+ def clear(self):
+ """ Clear current drawing. """
+ # pdb.gimp_edit_clear(self.spyro_layer)
+ self.spyro_layer.fill(FILL_TRANSPARENT)
+
+ def redraw(self, data=None):
+ if self.enable_incremental_drawing:
+ self.clear()
+ self.start_new_incremental_drawing()
+
+
+# Bind escape to the new signal we created, named "myescape".
+gobject.type_register(SpyroWindow)
+gtk.binding_entry_add_signal(SpyroWindow, gtk.keysyms.Escape, 0, 'myescape', str, 'escape')
+
+
+class SpyrogimpPlusPlugin(gimpplugin.plugin):
+
+ # Implementation of plugin.
+ def plug_in_spyrogimp(self, run_mode, image, layer,
+ curve_type=0, shape=0, sides=3, morph=0.0,
+ fixed_teeth=96, moving_teeth=36, hole_percent=100.0,
+ margin=0, equal_w_h=0,
+ pattern_rotation=0.0, shape_rotation=0.0,
+ tool=1, long_gradient=False):
+ if run_mode == RUN_NONINTERACTIVE:
+ pp = PatternParameters()
+ pp.curve_type = curve_type
+ pp.shape_index = shape
+ pp.sides = sides
+ pp.morph = morph
+ pp.outer_teeth = fixed_teeth
+ pp.inner_teeth = moving_teeth
+ pp.hole_percent = hole_percent
+ pp.margin_pixels = margin
+ pp.equal_w_h = equal_w_h
+ pp.pattern_rotation = pattern_rotation
+ pp.shape_rotation = shape_rotation
+ pp.tool_index = tool
+ pp.long_gradient = long_gradient
+
+ engine = DrawingEngine(image, pp)
+ engine.draw_full(layer)
+
+ elif run_mode == RUN_INTERACTIVE:
+ window = SpyroWindow(image, layer)
+ gtk.main()
+
+ elif run_mode == RUN_WITH_LAST_VALS:
+ pp = unshelf_parameters()
+ engine = DrawingEngine(image, pp)
+ engine.draw_full(layer)
+
+ def query(self):
+ plugin_name = "plug_in_spyrogimp"
+ label = N_("Spyrogimp...")
+ menu = "<Image>/Filters/Render/"
+
+ params = [
+ # (type, name, description
+ (PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"),
+ (PDB_IMAGE, "image", "Input image"),
+ (PDB_DRAWABLE, "drawable", "Input drawable"),
+ (PDB_INT32, "curve_type",
+ "The curve type { Spyrograph (0), Epitrochoid (1), Sine (2), Lissajous(3) }"),
+ (PDB_INT32, "shape", "Shape of fixed gear"),
+ (PDB_INT32, "sides", "Number of sides of fixed gear (3 or greater). Only used by some shapes."),
+ (PDB_FLOAT, "morph", "Morph shape of fixed gear, between 0 and 1. Only used by some shapes."),
+ (PDB_INT32, "fixed_teeth", "Number of teeth for fixed gear"),
+ (PDB_INT32, "moving_teeth", "Number of teeth for moving gear"),
+ (PDB_FLOAT, "hole_percent", "Location of hole in moving gear in percent, where 100 means that "
+ "the hole is at the edge of the gear, and 0 means the hole is at the center"),
+ (PDB_INT32, "margin", "Margin from selection, in pixels"),
+ (PDB_INT32, "equal_w_h", "Make height and width equal (TRUE or FALSE)"),
+ (PDB_FLOAT, "pattern_rotation", "Pattern rotation, in degrees"),
+ (PDB_FLOAT, "shape_rotation", "Shape rotation of fixed gear, in degrees"),
+ (PDB_INT32, "tool", "Tool to use for drawing the pattern."),
+ (PDB_INT32, "long_gradient",
+ "Whether to apply a long gradient to match the length of the pattern (TRUE or FALSE). "
+ "Only applicable to some of the tools.")
+ ]
+
+ gimp.domain_register("gimp20-python", gimp.locale_directory)
+
+ gimp.install_procedure(
+ plugin_name,
+ N_("Draw spyrographs using current tool settings and selection."),
+ "Uses current tool settings to draw Spyrograph patterns. "
+ "The size and location of the pattern is based on the current selection.",
+ "Elad Shahar",
+ "Elad Shahar",
+ "2018",
+ label,
+ "*",
+ PLUGIN,
+ params,
+ []
+ )
+
+ gimp.menu_register(plugin_name, menu)
+
+
+if __name__ == '__main__':
+ SpyrogimpPlusPlugin().start()
diff --git a/plug-ins/pygimp/plug-ins/whirlpinch.py b/plug-ins/pygimp/plug-ins/whirlpinch.py
new file mode 100755
index 0000000..6c50e89
--- /dev/null
+++ b/plug-ins/pygimp/plug-ins/whirlpinch.py
@@ -0,0 +1,227 @@
+#!/usr/bin/env python2
+
+# Gimp-Python - allows the writing of Gimp plugins in Python.
+# Copyright (C) 1997 James Henstridge <james@daa.com.au>
+#
+# 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/>.
+
+# Algorithms stolen from the whirl and pinch plugin distributed with Gimp,
+# by Federico Mena Quintero and Scott Goehring
+#
+# This version does the same thing, except there is no preview, and it is
+# written in python and is slower.
+
+import math, struct
+from gimpfu import *
+
+class pixel_fetcher:
+ def __init__(self, drawable):
+ self.col = -1
+ self.row = -1
+ self.img_width = drawable.width
+ self.img_height = drawable.height
+ self.img_bpp = drawable.bpp
+ self.img_has_alpha = drawable.has_alpha
+ self.tile_width = gimp.tile_width()
+ self.tile_height = gimp.tile_height()
+ self.bg_colour = '\0\0\0\0'
+ self.bounds = drawable.mask_bounds
+ self.drawable = drawable
+ self.tile = None
+ def set_bg_colour(self, r, g, b, a):
+ self.bg_colour = struct.pack('BBB', r,g,b)
+ if self.img_has_alpha:
+ self.bg_colour = self.bg_colour + chr(a)
+ def get_pixel(self, x, y):
+ sel_x1, sel_y1, sel_x2, sel_y2 = self.bounds
+ if x < sel_x1 or x >= sel_x2 or y < sel_y1 or y >= sel_y2:
+ return self.bg_colour
+ col = x / self.tile_width
+ coloff = x % self.tile_width
+ row = y / self.tile_height
+ rowoff = y % self.tile_height
+
+ if col != self.col or row != self.row or self.tile == None:
+ self.tile = self.drawable.get_tile(False, row, col)
+ self.col = col
+ self.row = row
+ return self.tile[coloff, rowoff]
+
+class Dummy:
+ pass
+
+def whirl_pinch(image, drawable, whirl, pinch, radius):
+ self = Dummy()
+ self.width = drawable.width
+ self.height = drawable.height
+ self.bpp = drawable.bpp
+ self.has_alpha = drawable.has_alpha
+ self.bounds = drawable.mask_bounds
+ self.sel_x1, self.sel_y1, self.sel_x2, self.sel_y2 = \
+ drawable.mask_bounds
+ self.sel_w = self.sel_x2 - self.sel_x1
+ self.sel_h = self.sel_y2 - self.sel_y1
+ self.cen_x = (self.sel_x1 + self.sel_x2 - 1) / 2.0
+ self.cen_y = (self.sel_y1 + self.sel_y2 - 1) / 2.0
+ xhsiz = (self.sel_w - 1) / 2.0
+ yhsiz = (self.sel_h - 1) / 2.0
+
+ if xhsiz < yhsiz:
+ self.scale_x = yhsiz / xhsiz
+ self.scale_y = 1.0
+ elif xhsiz > yhsiz:
+ self.scale_x = 1.0
+ self.scale_y = xhsiz / yhsiz
+ else:
+ self.scale_x = 1.0
+ self.scale_y = 1.0
+
+ self.radius = max(xhsiz, yhsiz);
+
+ if not drawable.is_rgb and not drawable.is_grey:
+ return
+
+ gimp.tile_cache_ntiles(2 * (1 + self.width / gimp.tile_width()))
+
+ whirl = whirl * math.pi / 180
+ dest_rgn = drawable.get_pixel_rgn(self.sel_x1, self.sel_y1,
+ self.sel_w, self.sel_h, True, True)
+ pft = pixel_fetcher(drawable)
+ pfb = pixel_fetcher(drawable)
+
+ bg_colour = gimp.get_background()
+
+ pft.set_bg_colour(bg_colour[0], bg_colour[1], bg_colour[2], 0)
+ pfb.set_bg_colour(bg_colour[0], bg_colour[1], bg_colour[2], 0)
+
+ progress = 0
+ max_progress = self.sel_w * self.sel_h
+
+ gimp.progress_init("Whirling and pinching")
+
+ self.radius2 = self.radius * self.radius * radius
+ pixel = ['', '', '', '']
+ values = [0,0,0,0]
+
+ for row in range(self.sel_y1, (self.sel_y1+self.sel_y2)/2+1):
+ top_p = ''
+ bot_p = ''
+ for col in range(self.sel_x1, self.sel_x2):
+ q, cx, cy = calc_undistorted_coords(self, col,
+ row, whirl, pinch,
+ radius)
+ if q:
+ if cx >= 0: ix = int(cx)
+ else: ix = -(int(-cx) + 1)
+ if cy >= 0: iy = int(cy)
+ else: iy = -(int(-cy) + 1)
+ pixel[0] = pft.get_pixel(ix, iy)
+ pixel[1] = pft.get_pixel(ix+1, iy)
+ pixel[2] = pft.get_pixel(ix, iy+1)
+ pixel[3] = pft.get_pixel(ix+1, iy+1)
+ for i in range(self.bpp):
+ values[0] = ord(pixel[0][i])
+ values[1] = ord(pixel[1][i])
+ values[2] = ord(pixel[2][i])
+ values[3] = ord(pixel[3][i])
+ top_p = top_p + bilinear(cx,cy, values)
+ cx = self.cen_x + (self.cen_x - cx)
+ cy = self.cen_y + (self.cen_y - cy)
+ if cx >= 0: ix = int(cx)
+ else: ix = -(int(-cx) + 1)
+ if cy >= 0: iy = int(cy)
+ else: iy = -(int(-cy) + 1)
+ pixel[0] = pfb.get_pixel(ix, iy)
+ pixel[1] = pfb.get_pixel(ix+1, iy)
+ pixel[2] = pfb.get_pixel(ix, iy+1)
+ pixel[3] = pfb.get_pixel(ix+1, iy+1)
+ tmp = ''
+ for i in range(self.bpp):
+ values[0] = ord(pixel[0][i])
+ values[1] = ord(pixel[1][i])
+ values[2] = ord(pixel[2][i])
+ values[3] = ord(pixel[3][i])
+ tmp = tmp + bilinear(cx,cy, values)
+ bot_p = tmp + bot_p
+ else:
+ top_p = top_p + pft.get_pixel(col, row)
+ bot_p = pfb.get_pixel((self.sel_x2 - 1) -
+ (col - self.sel_x1), (self.sel_y2-1) -
+ (row - self.sel_y1)) + bot_p
+
+ dest_rgn[self.sel_x1:self.sel_x2, row] = top_p
+ dest_rgn[self.sel_x1:self.sel_x2, (self.sel_y2 - 1)
+ - (row - self.sel_y1)] = bot_p
+
+ progress = progress + self.sel_w * 2
+ gimp.progress_update(float(progress) / max_progress)
+
+ drawable.flush()
+ drawable.merge_shadow(True)
+ drawable.update(self.sel_x1,self.sel_y1,self.sel_w,self.sel_h)
+
+def calc_undistorted_coords(self, wx, wy, whirl, pinch, radius):
+ dx = (wx - self.cen_x) * self.scale_x
+ dy = (wy - self.cen_y) * self.scale_y
+ d = dx * dx + dy * dy
+ inside = d < self.radius2
+
+ if inside:
+ dist = math.sqrt(d / radius) / self.radius
+ if (d == 0.0):
+ factor = 1.0
+ else:
+ factor = math.pow(math.sin(math.pi / 2 * dist),
+ -pinch)
+ dx = dx * factor
+ dy = dy * factor
+ factor = 1 - dist
+ ang = whirl * factor * factor
+ sina = math.sin(ang)
+ cosa = math.cos(ang)
+ x = (cosa * dx - sina * dy) / self.scale_x + self.cen_x
+ y = (sina * dx + cosa * dy) / self.scale_y + self.cen_y
+ else:
+ x = wx
+ y = wy
+ return inside, float(x), float(y)
+
+def bilinear(x, y, values):
+ x = x % 1.0
+ y = y % 1.0
+ m0 = values[0] + x * (values[1] - values[0])
+ m1 = values[2] + x * (values[3] - values[2])
+ return chr(int(m0 + y * (m1 - m0)))
+
+
+register(
+ "python-fu-whirl-pinch",
+ "Distorts an image by whirling and pinching",
+ "Distorts an image by whirling and pinching",
+ "James Henstridge (translated from C plugin)",
+ "James Henstridge",
+ "1997-1999",
+ "_Whirl and Pinch...",
+ "RGB*, GRAY*",
+ [
+ (PF_IMAGE, "image", "Input image", None),
+ (PF_DRAWABLE, "drawable", "Input drawable", None),
+ (PF_SLIDER, "whirl", "Whirl angle", 90, (-360, 360, 1)),
+ (PF_FLOAT, "pinch", "Pinch amount", 0),
+ (PF_FLOAT, "radius", "radius", 1)
+ ],
+ [],
+ whirl_pinch, menu="<Image>/Filters/Distorts")
+
+main()
diff --git a/plug-ins/pygimp/py-compile b/plug-ins/pygimp/py-compile
new file mode 100755
index 0000000..3448c71
--- /dev/null
+++ b/plug-ins/pygimp/py-compile
@@ -0,0 +1,72 @@
+#!/bin/sh
+# called as "py-compile [--basedir DIR] PY_FILES ...
+
+if [ -z "$PYTHON" ]; then
+ if [[ -x "$(command -v python2)" ]]; then
+ PYTHON=python2
+ else
+ # Let's hope it's Python2
+ PYTHON=python
+ fi
+fi
+
+basedir=
+
+case "$1" in
+ --basedir)
+ basedir=$2
+ shift 2
+ ;;
+ --help)
+ echo "Usage: py-compile [--basedir DIR] PY_FILES ..."
+ echo "Byte compile some python scripts. This should be performed"
+ echo "after they have been moved to the final installation location"
+ exit 0
+ ;;
+ --version)
+ echo "py-compile version 0.0"
+ exit 0
+ ;;
+esac
+
+if [ $# = 0 ]; then
+ echo "No files given to $0" 1>&2
+ exit 1
+fi
+
+# if basedir was given, then it should be prepended to filenames before
+# byte compilation.
+if [ -z "$basedir" ]; then
+ trans="path = file"
+else
+ trans="path = os.path.join('$basedir', file)"
+fi
+
+$PYTHON -c "
+import sys, os, string, py_compile
+
+files = '''$*'''
+print 'Byte-compiling python modules...'
+for file in string.split(files):
+ $trans
+ if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'):
+ continue
+ print file,
+ sys.stdout.flush()
+ py_compile.compile(path)
+print" || exit $?
+
+# this will fail for python < 1.5, but that doesn't matter ...
+$PYTHON -O -c "
+import sys, os, string, py_compile
+
+files = '''$*'''
+print 'Byte-compiling python modules (optimised versions) ...'
+for file in string.split(files):
+ $trans
+ if not os.path.exists(path) or not (len(path) >= 3 and path[-3:] == '.py'):
+ continue
+ print file,
+ sys.stdout.flush()
+ py_compile.compile(path)
+print" 2>/dev/null || :
diff --git a/plug-ins/pygimp/pygimp-api.h b/plug-ins/pygimp/pygimp-api.h
new file mode 100644
index 0000000..2b83222
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-api.h
@@ -0,0 +1,122 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifndef _PYGIMP_API_H_
+#define _PYGIMP_API_H_
+
+#include <Python.h>
+
+#include <libgimp/gimp.h>
+
+typedef struct {
+ PyObject_HEAD
+ gint32 ID;
+} PyGimpImage, PyGimpItem;
+
+typedef struct {
+ PyObject_HEAD
+ gint32 ID;
+} PyGimpDisplay;
+
+typedef struct {
+ PyObject_HEAD
+ gint32 ID;
+ GimpDrawable *drawable;
+} PyGimpDrawable, PyGimpLayer, PyGimpGroupLayer, PyGimpChannel;
+
+typedef struct {
+ PyObject_HEAD
+ gint32 ID;
+} PyGimpVectors;
+
+struct _PyGimp_Functions {
+ PyTypeObject *Image_Type;
+ PyObject *(* image_new)(gint32 ID);
+
+ PyTypeObject *Display_Type;
+ PyObject *(* display_new)(gint32 ID);
+
+ PyTypeObject *Item_Type;
+ PyObject *(* item_new)(gint32 ID);
+
+ PyTypeObject *Drawable_Type;
+ PyObject *(* drawable_new)(GimpDrawable *drawable, gint32 ID);
+
+ PyTypeObject *Layer_Type;
+ PyObject *(* layer_new)(gint32 ID);
+
+ PyTypeObject *GroupLayer_Type;
+ PyObject *(* group_layer_new)(gint32 ID);
+
+ PyTypeObject *Channel_Type;
+ PyObject *(* channel_new)(gint32 ID);
+
+ PyTypeObject *Vectors_Type;
+ PyObject *(* vectors_new)(gint32 ID);
+
+ PyObject *pygimp_error;
+};
+
+#ifndef _INSIDE_PYGIMP_
+
+#if defined(NO_IMPORT) || defined(NO_IMPORT_PYGIMP)
+extern struct _PyGimp_Functions *_PyGimp_API;
+#else
+struct _PyGimp_Functions *_PyGimp_API;
+#endif
+
+#define PyGimpImage_Type (_PyGimp_API->Image_Type)
+#define pygimp_image_new (_PyGimp_API->image_new)
+#define PyGimpDisplay_Type (_PyGimp_API->Display_Type)
+#define pygimp_display_new (_PyGimp_API->display_new)
+#define PyGimpItem_Type (_PyGimp_API->Item_Type)
+#define pygimp_item_new (_PyGimp_API->item_new)
+#define PyGimpDrawable_Type (_PyGimp_API->Drawable_Type)
+#define pygimp_drawable_new (_PyGimp_API->drawable_new)
+#define PyGimpLayer_Type (_PyGimp_API->Layer_Type)
+#define pygimp_layer_new (_PyGimp_API->layer_new)
+#define PyGimpGroupLayer_Type (_PyGimp_API->GroupLayer_Type)
+#define pygimp_group_layer_new (_PyGimp_API->group_layer_new)
+#define PyGimpChannel_Type (_PyGimp_API->Channel_Type)
+#define pygimp_channel_new (_PyGimp_API->channel_new)
+#define PyGimpVectors_Type (_PyGimp_API->Vectors_Type)
+#define pygimp_vectors_new (_PyGimp_API->vectors_new)
+#define pygimp_error (_PyGimp_API->pygimp_error)
+
+#define init_pygimp() G_STMT_START { \
+ PyObject *gimpmodule = PyImport_ImportModule("gimp"); \
+ if (gimpmodule != NULL) { \
+ PyObject *mdict = PyModule_GetDict(gimpmodule); \
+ PyObject *cobject = PyDict_GetItemString(mdict, "_PyGimp_API"); \
+ if (PyCObject_Check(cobject)) \
+ _PyGimp_API = PyCObject_AsVoidPtr(cobject); \
+ else { \
+ PyErr_SetString(PyExc_RuntimeError, \
+ "could not find _PyGimp_API object"); \
+ return; \
+ } \
+ } else { \
+ PyErr_SetString(PyExc_ImportError, \
+ "could not import gimp"); \
+ return; \
+ } \
+} G_STMT_END
+
+#endif /* ! _INSIDE_PYGIMP_ */
+
+#endif /* _PYGIMP_API_H_ */
diff --git a/plug-ins/pygimp/pygimp-colors.c b/plug-ins/pygimp/pygimp-colors.c
new file mode 100644
index 0000000..fe37b5d
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-colors.c
@@ -0,0 +1,2407 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005-2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#define NO_IMPORT_PYGOBJECT
+
+#include "pygimp.h"
+#include "pygimpcolor.h"
+
+#include <libgimpmath/gimpmath.h>
+
+static PyObject *
+rgb_set(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *r = NULL, *g = NULL, *b = NULL, *a = NULL;
+ GimpRGB tmprgb, *rgb;
+ static char *kwlist[] = { "r", "g", "b", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO:set", kwlist,
+ &r, &g, &b, &a))
+ return NULL;
+
+ if (!r && !g && !b && !a) {
+ PyErr_SetString(PyExc_TypeError, "must provide r,g,b or a arguments");
+ return NULL;
+ }
+
+ if ((r && (!g || !b)) ||
+ (g && (!r || !b)) ||
+ (b && (!r || !g))) {
+ PyErr_SetString(PyExc_TypeError, "must provide all 3 r,g,b arguments");
+ return NULL;
+ }
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+ tmprgb = *rgb;
+
+#define SET_MEMBER(m) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ tmprgb.m = (double) PyInt_AS_LONG(m) / 255.0; \
+ else if (PyFloat_Check(m)) \
+ tmprgb.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return NULL; \
+ } \
+} G_STMT_END
+
+ if (r) {
+ SET_MEMBER(r);
+ SET_MEMBER(g);
+ SET_MEMBER(b);
+ }
+
+ if (a)
+ SET_MEMBER(a);
+
+#undef SET_MEMBER
+
+ *rgb = tmprgb;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_set_alpha(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_a;
+ GimpRGB *rgb;
+ static char *kwlist[] = { "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:set_alpha", kwlist,
+ &py_a))
+ return NULL;
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ if (PyInt_Check(py_a))
+ rgb->a = (double) PyInt_AS_LONG(py_a) / 255.0;
+ else if (PyFloat_Check(py_a))
+ rgb->a = PyFloat_AS_DOUBLE(py_a);
+ else {
+ PyErr_SetString(PyExc_TypeError, "a must be an int or a float");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_add(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *color;
+ gboolean with_alpha = FALSE;
+ static char *kwlist[] = { "color", "with_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|i:add", kwlist,
+ &PyGimpRGB_Type, &color, &with_alpha))
+ return NULL;
+
+ if (with_alpha)
+ gimp_rgba_add(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB));
+ else
+ gimp_rgb_add(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_subtract(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *color;
+ gboolean with_alpha = FALSE;
+ static char *kwlist[] = { "color", "with_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|i:subtract", kwlist,
+ &PyGimpRGB_Type, &color, &with_alpha))
+ return NULL;
+
+ if (with_alpha)
+ gimp_rgba_subtract(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB));
+ else
+ gimp_rgb_subtract(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_multiply(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ double factor;
+ gboolean with_alpha = FALSE;
+ static char *kwlist[] = { "factor", "with_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d|i:multiply", kwlist,
+ &factor, &with_alpha))
+ return NULL;
+
+ if (with_alpha)
+ gimp_rgba_multiply(pyg_boxed_get(self, GimpRGB), factor);
+ else
+ gimp_rgb_multiply(pyg_boxed_get(self, GimpRGB), factor);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_distance(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *color;
+ gboolean alpha = FALSE;
+ double ret;
+ static char *kwlist[] = { "color", "alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|i:distance", kwlist,
+ &PyGimpRGB_Type, &color, &alpha))
+ return NULL;
+
+ ret = gimp_rgb_distance(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB));
+
+
+ return PyFloat_FromDouble(ret);
+}
+
+static PyObject *
+rgb_max(PyObject *self)
+{
+ return PyFloat_FromDouble(gimp_rgb_max(pyg_boxed_get(self, GimpRGB)));
+}
+
+static PyObject *
+rgb_min(PyObject *self)
+{
+ return PyFloat_FromDouble(gimp_rgb_min(pyg_boxed_get(self, GimpRGB)));
+}
+
+static PyObject *
+rgb_clamp(PyObject *self)
+{
+ gimp_rgb_clamp(pyg_boxed_get(self, GimpRGB));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_gamma(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ double gamma;
+ static char *kwlist[] = { "gamma", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d:gamma", kwlist, &gamma))
+ return NULL;
+
+ gimp_rgb_gamma(pyg_boxed_get(self, GimpRGB), gamma);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_luminance(PyObject *self)
+{
+ return PyFloat_FromDouble(gimp_rgb_luminance(pyg_boxed_get(self, GimpRGB)));
+}
+
+static PyObject *
+rgb_composite(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *color;
+ int mode = GIMP_RGB_COMPOSITE_NORMAL;
+ static char *kwlist[] = { "color", "mode", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|i:composite", kwlist,
+ &PyGimpRGB_Type, &color, &mode))
+ return NULL;
+
+ if (mode < GIMP_RGB_COMPOSITE_NONE || mode > GIMP_RGB_COMPOSITE_BEHIND) {
+ PyErr_SetString(PyExc_TypeError, "composite type is not valid");
+ return NULL;
+ }
+
+ gimp_rgb_composite(pyg_boxed_get(self, GimpRGB),
+ pyg_boxed_get(color, GimpRGB),
+ mode);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_parse_name(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *name;
+ int len;
+ gboolean success;
+ static char *kwlist[] = { "name", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:parse_name", kwlist,
+ &name, &len))
+ return NULL;
+
+ success = gimp_rgb_parse_name(pyg_boxed_get(self, GimpRGB), name, len);
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse color name");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_parse_hex(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *hex;
+ int len;
+ gboolean success;
+ static char *kwlist[] = { "hex", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#:parse_hex", kwlist,
+ &hex, &len))
+ return NULL;
+
+ success = gimp_rgb_parse_hex(pyg_boxed_get(self, GimpRGB), hex, len);
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse hex value");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_parse_css(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *css;
+ int len;
+ gboolean success, with_alpha = FALSE;
+ static char *kwlist[] = { "css", "with_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "s#|i:parse_css", kwlist,
+ &css, &len, &with_alpha))
+ return NULL;
+
+ if (with_alpha)
+ success = gimp_rgba_parse_css(pyg_boxed_get(self, GimpRGB), css, len);
+ else
+ success = gimp_rgb_parse_css(pyg_boxed_get(self, GimpRGB), css, len);
+
+ if (!success) {
+ PyErr_SetString(PyExc_ValueError, "unable to parse CSS color");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+rgb_to_hsv(PyObject *self)
+{
+ GimpRGB *rgb;
+ GimpHSV hsv;
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ gimp_rgb_to_hsv(rgb, &hsv);
+
+ return pygimp_hsv_new(&hsv);
+}
+
+static PyObject *
+rgb_to_hsl(PyObject *self)
+{
+ GimpRGB *rgb;
+ GimpHSL hsl;
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ gimp_rgb_to_hsl(rgb, &hsl);
+
+ return pygimp_hsl_new(&hsl);
+}
+
+static PyObject *
+rgb_to_cmyk(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ GimpRGB *rgb;
+ GimpCMYK cmyk;
+ gdouble pullout = 1.0;
+ static char *kwlist[] = { "pullout", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|d:to_cmyk", kwlist,
+ &pullout))
+ return NULL;
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ gimp_rgb_to_cmyk(rgb, pullout, &cmyk);
+
+ return pygimp_cmyk_new(&cmyk);
+}
+
+/* __getstate__ isn't exposed */
+static PyObject *
+rgb_getstate(PyObject *self)
+{
+ GimpRGB *rgb;
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ return Py_BuildValue("dddd", rgb->r, rgb->g, rgb->b, rgb->a);
+}
+
+static PyObject *
+rgb_reduce(PyObject *self)
+{
+ return Py_BuildValue("ON", self->ob_type, rgb_getstate(self));
+}
+
+static PyMethodDef rgb_methods[] = {
+ { "set", (PyCFunction)rgb_set, METH_VARARGS|METH_KEYWORDS },
+ { "set_alpha", (PyCFunction)rgb_set_alpha, METH_VARARGS|METH_KEYWORDS },
+ { "add", (PyCFunction)rgb_add, METH_VARARGS|METH_KEYWORDS },
+ { "subtract", (PyCFunction)rgb_subtract, METH_VARARGS|METH_KEYWORDS },
+ { "multiply", (PyCFunction)rgb_multiply, METH_VARARGS|METH_KEYWORDS },
+ { "distance", (PyCFunction)rgb_distance, METH_VARARGS|METH_KEYWORDS },
+ { "max", (PyCFunction)rgb_max, METH_NOARGS },
+ { "min", (PyCFunction)rgb_min, METH_NOARGS },
+ { "clamp", (PyCFunction)rgb_clamp, METH_NOARGS },
+ { "gamma", (PyCFunction)rgb_gamma, METH_VARARGS|METH_KEYWORDS },
+ { "luminance", (PyCFunction)rgb_luminance, METH_NOARGS },
+ { "composite", (PyCFunction)rgb_composite, METH_VARARGS|METH_KEYWORDS },
+ { "parse_name", (PyCFunction)rgb_parse_name, METH_VARARGS|METH_KEYWORDS },
+ { "parse_hex", (PyCFunction)rgb_parse_hex, METH_VARARGS|METH_KEYWORDS },
+ { "parse_css", (PyCFunction)rgb_parse_css, METH_VARARGS|METH_KEYWORDS },
+ { "to_hsv", (PyCFunction)rgb_to_hsv, METH_NOARGS },
+ { "to_hsl", (PyCFunction)rgb_to_hsl, METH_NOARGS },
+ { "to_cmyk", (PyCFunction)rgb_to_cmyk, METH_VARARGS|METH_KEYWORDS },
+ { "__reduce__", (PyCFunction)rgb_reduce, METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+#define MEMBER_ACCESSOR(m) \
+static PyObject * \
+rgb_get_ ## m(PyObject *self, void *closure) \
+{ \
+ return PyFloat_FromDouble(pyg_boxed_get(self, GimpRGB)->m); \
+} \
+static int \
+rgb_set_ ## m(PyObject *self, PyObject *value, void *closure) \
+{ \
+ GimpRGB *rgb = pyg_boxed_get(self, GimpRGB); \
+ if (value == NULL) { \
+ PyErr_SetString(PyExc_TypeError, "cannot delete value"); \
+ return -1; \
+ } \
+ else if (PyInt_Check(value)) \
+ rgb->m = (double) PyInt_AS_LONG(value) / 255.0; \
+ else if (PyFloat_Check(value)) \
+ rgb->m = PyFloat_AS_DOUBLE(value); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "type mismatch"); \
+ return -1; \
+ } \
+ return 0; \
+}
+
+MEMBER_ACCESSOR(r);
+MEMBER_ACCESSOR(g);
+MEMBER_ACCESSOR(b);
+MEMBER_ACCESSOR(a);
+
+#undef MEMBER_ACCESSOR
+
+static PyGetSetDef rgb_getsets[] = {
+ { "r", (getter)rgb_get_r, (setter)rgb_set_r },
+ { "g", (getter)rgb_get_g, (setter)rgb_set_g },
+ { "b", (getter)rgb_get_b, (setter)rgb_set_b },
+ { "a", (getter)rgb_get_a, (setter)rgb_set_a },
+ { "red", (getter)rgb_get_r, (setter)rgb_set_r },
+ { "green", (getter)rgb_get_g, (setter)rgb_set_g },
+ { "blue", (getter)rgb_get_b, (setter)rgb_set_b },
+ { "alpha", (getter)rgb_get_a, (setter)rgb_set_a },
+ { NULL, (getter)0, (setter)0 },
+};
+
+static Py_ssize_t
+rgb_length(PyObject *self)
+{
+ return 4;
+}
+
+static PyObject *
+rgb_getitem(PyObject *self, Py_ssize_t pos)
+{
+ GimpRGB *rgb;
+ double val;
+
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ switch (pos) {
+ case 0: val = rgb->r; break;
+ case 1: val = rgb->g; break;
+ case 2: val = rgb->b; break;
+ case 3: val = rgb->a; break;
+ default:
+ g_assert_not_reached();
+ return NULL;
+ }
+
+ return PyInt_FromLong(ROUND(CLAMP(val, 0.0, 1.0) * 255.0));
+}
+
+static int
+rgb_setitem(PyObject *self, Py_ssize_t pos, PyObject *value)
+{
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ switch (pos) {
+ case 0: return rgb_set_r(self, value, NULL);
+ case 1: return rgb_set_g(self, value, NULL);
+ case 2: return rgb_set_b(self, value, NULL);
+ case 3: return rgb_set_a(self, value, NULL);
+ default:
+ g_assert_not_reached();
+ return -1;
+ }
+}
+
+static PyObject *
+rgb_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
+{
+ PyTupleObject *ret;
+ Py_ssize_t i;
+
+ if (start < 0)
+ start = 0;
+ if (end > 4)
+ end = 4;
+ if (end < start)
+ end = start;
+
+ ret = (PyTupleObject *)PyTuple_New(end - start);
+ if (ret == NULL)
+ return NULL;
+
+ for (i = start; i < end; i++)
+ PyTuple_SET_ITEM(ret, i - start, rgb_getitem(self, i));
+
+ return (PyObject *)ret;
+}
+
+static PySequenceMethods rgb_as_sequence = {
+ rgb_length,
+ (binaryfunc)0,
+ 0,
+ rgb_getitem,
+ rgb_slice,
+ rgb_setitem,
+ 0,
+ (objobjproc)0,
+};
+
+static PyObject *
+rgb_subscript(PyObject *self, PyObject *item)
+{
+ if (PyInt_Check(item)) {
+ long i = PyInt_AS_LONG(item);
+ return rgb_getitem(self, i);
+ } else if (PyLong_Check(item)) {
+ long i = PyLong_AsLong(item);
+ if (i == -1 && PyErr_Occurred())
+ return NULL;
+ return rgb_getitem(self, i);
+ } else if (PySlice_Check(item)) {
+ Py_ssize_t start, stop, step, slicelength, cur, i;
+ PyObject *ret;
+
+ if (PySlice_GetIndicesEx((PySliceObject*)item, 4,
+ &start, &stop, &step, &slicelength) < 0)
+ return NULL;
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ } else {
+ ret = PyTuple_New(slicelength);
+ if (!ret)
+ return NULL;
+
+ for (cur = start, i = 0; i < slicelength; cur += step, i++)
+ PyTuple_SET_ITEM(ret, i, rgb_getitem(self, cur));
+
+ return ret;
+ }
+ } else if (PyString_Check(item)) {
+ char *s = PyString_AsString(item);
+
+ if (g_ascii_strcasecmp(s, "r") == 0 ||
+ g_ascii_strcasecmp(s, "red") == 0)
+ return rgb_get_r(self, NULL);
+ else if (g_ascii_strcasecmp(s, "g") == 0 ||
+ g_ascii_strcasecmp(s, "green") == 0)
+ return rgb_get_g(self, NULL);
+ else if (g_ascii_strcasecmp(s, "b") == 0 ||
+ g_ascii_strcasecmp(s, "blue") == 0)
+ return rgb_get_b(self, NULL);
+ else if (g_ascii_strcasecmp(s, "a") == 0 ||
+ g_ascii_strcasecmp(s, "alpha") == 0)
+ return rgb_get_a(self, NULL);
+ else {
+ PyErr_SetObject(PyExc_KeyError, item);
+ return NULL;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "indices must be integers");
+ return NULL;
+ }
+}
+
+static PyMappingMethods rgb_as_mapping = {
+ rgb_length,
+ (binaryfunc)rgb_subscript,
+ (objobjargproc)0
+};
+
+static long
+rgb_hash(PyObject *self)
+{
+ long ret = -1;
+
+ PyObject *temp = rgb_getstate(self);
+ if (temp != NULL) {
+ ret = PyObject_Hash(temp);
+ Py_DECREF(temp);
+ }
+
+ return ret;
+}
+
+static PyObject *
+rgb_richcompare(PyObject *self, PyObject *other, int op)
+{
+ GimpRGB *c1, *c2;
+ PyObject *ret;
+
+ if (!pygimp_rgb_check(other)) {
+ PyErr_Format(PyExc_TypeError,
+ "can't compare %s to %s",
+ self->ob_type->tp_name, other->ob_type->tp_name);
+ return NULL;
+ }
+
+ if (op != Py_EQ && op != Py_NE) {
+ PyErr_SetString(PyExc_TypeError,
+ "can't compare color values using <, <=, >, >=");
+ return NULL;
+ }
+
+ c1 = pyg_boxed_get(self, GimpRGB);
+ c2 = pyg_boxed_get(other, GimpRGB);
+
+ if ((c1->r == c2->r && c1->g == c2->g && c1->b == c2->b && c1->a == c2->a) == (op == Py_EQ))
+ ret = Py_True;
+ else
+ ret = Py_False;
+
+ Py_INCREF(ret);
+ return ret;
+}
+
+static PyObject *
+rgb_pretty_print(PyObject *self, gboolean inexact)
+{
+ GimpRGB *rgb;
+ PyObject *ret = NULL;
+ PyObject *r_f = NULL, *g_f = NULL, *b_f = NULL, *a_f = NULL;
+ PyObject *r = NULL, *g = NULL, *b = NULL, *a = NULL;
+ reprfunc repr;
+ const char *prefix;
+
+ if (inexact) {
+ repr = PyObject_Str;
+ prefix = "RGB ";
+ } else {
+ repr = PyObject_Repr;
+ prefix = self->ob_type->tp_name;
+ }
+
+ rgb = pyg_boxed_get(self, GimpRGB);
+
+ if ((r_f = PyFloat_FromDouble(rgb->r)) == NULL) goto cleanup;
+ if ((g_f = PyFloat_FromDouble(rgb->g)) == NULL) goto cleanup;
+ if ((b_f = PyFloat_FromDouble(rgb->b)) == NULL) goto cleanup;
+ if ((a_f = PyFloat_FromDouble(rgb->a)) == NULL) goto cleanup;
+
+ if ((r = repr(r_f)) == NULL) goto cleanup;
+ if ((g = repr(g_f)) == NULL) goto cleanup;
+ if ((b = repr(b_f)) == NULL) goto cleanup;
+ if ((a = repr(a_f)) == NULL) goto cleanup;
+
+ ret = PyString_FromFormat("%s(%s, %s, %s, %s)",
+ prefix,
+ PyString_AsString(r),
+ PyString_AsString(g),
+ PyString_AsString(b),
+ PyString_AsString(a));
+
+cleanup:
+ Py_XDECREF(r); Py_XDECREF(g); Py_XDECREF(b); Py_XDECREF(a);
+ Py_XDECREF(r_f); Py_XDECREF(g_f); Py_XDECREF(b_f); Py_XDECREF(a_f);
+
+ return ret;
+}
+
+static PyObject *
+rgb_repr(PyObject *self)
+{
+ return rgb_pretty_print(self, FALSE);
+}
+
+static PyObject *
+rgb_str(PyObject *self)
+{
+ return rgb_pretty_print(self, TRUE);
+}
+
+static int
+rgb_init(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *r, *g, *b, *a = NULL;
+ GimpRGB rgb;
+ static char *kwlist[] = { "r", "g", "b", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OOO|O:set", kwlist,
+ &r, &g, &b, &a))
+ return -1;
+
+#define SET_MEMBER(m) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ rgb.m = (double) PyInt_AS_LONG(m) / 255.0; \
+ else if (PyFloat_Check(m)) \
+ rgb.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return -1; \
+ } \
+} G_STMT_END
+
+ SET_MEMBER(r);
+ SET_MEMBER(g);
+ SET_MEMBER(b);
+
+ if (a)
+ SET_MEMBER(a);
+ else
+ rgb.a = 1.0;
+
+#undef SET_MEMBER
+
+ self->gtype = GIMP_TYPE_RGB;
+ self->free_on_dealloc = TRUE;
+ self->boxed = g_boxed_copy(GIMP_TYPE_RGB, &rgb);
+
+ return 0;
+}
+
+PyTypeObject PyGimpRGB_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpcolor.RGB", /* tp_name */
+ sizeof(PyGBoxed), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)rgb_repr, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ &rgb_as_sequence, /* tp_as_sequence */
+ &rgb_as_mapping, /* tp_as_mapping */
+ (hashfunc)rgb_hash, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)rgb_str, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)rgb_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ rgb_methods, /* tp_methods */
+ 0, /* tp_members */
+ rgb_getsets, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)rgb_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+PyObject *
+pygimp_rgb_new(const GimpRGB *rgb)
+{
+ return pyg_boxed_new(GIMP_TYPE_RGB, (gpointer)rgb, TRUE, TRUE);
+}
+
+
+static PyObject *
+hsv_set(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *h = NULL, *s = NULL, *v = NULL, *a = NULL;
+ GimpHSV tmphsv, *hsv;
+ static char *kwlist[] = { "h", "s", "v", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO:set", kwlist,
+ &h, &s, &v, &a))
+ return NULL;
+
+ if (!h && !s && !v && !a) {
+ PyErr_SetString(PyExc_TypeError, "must provide h,s,v or a arguments");
+ return NULL;
+ }
+
+ if ((h && (!s || !v)) ||
+ (s && (!h || !v)) ||
+ (v && (!h || !s))) {
+ PyErr_SetString(PyExc_TypeError, "must provide all 3 h,s,v arguments");
+ return NULL;
+ }
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+ tmphsv = *hsv;
+
+#define SET_MEMBER(m, s) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ tmphsv.m = (double) PyInt_AS_LONG(m) / s; \
+ else if (PyFloat_Check(m)) \
+ tmphsv.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be a float"); \
+ return NULL; \
+ } \
+} G_STMT_END
+
+ if (h) {
+ SET_MEMBER(h, 360.0);
+ SET_MEMBER(s, 100.0);
+ SET_MEMBER(v, 100.0);
+ }
+
+ if (a)
+ SET_MEMBER(a, 255.0);
+
+#undef SET_MEMBER
+
+ *hsv = tmphsv;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+hsv_set_alpha(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_a;
+ GimpHSV *hsv;
+ static char *kwlist[] = { "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:set_alpha", kwlist,
+ &py_a))
+ return NULL;
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+
+ if (PyInt_Check(py_a))
+ hsv->a = (double) PyInt_AS_LONG(py_a) / 255.0;
+ else if (PyFloat_Check(py_a))
+ hsv->a = PyFloat_AS_DOUBLE(py_a);
+ else {
+ PyErr_SetString(PyExc_TypeError, "a must be a float");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+hsv_clamp(PyObject *self)
+{
+ gimp_hsv_clamp(pyg_boxed_get(self, GimpHSV));
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+hsv_to_rgb(PyObject *self)
+{
+ GimpHSV *hsv;
+ GimpRGB rgb;
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+
+ gimp_hsv_to_rgb(hsv, &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+
+/* __getstate__ isn't exposed */
+static PyObject *
+hsv_getstate(PyObject *self)
+{
+ GimpHSV *hsv;
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+
+ return Py_BuildValue("dddd", hsv->h, hsv->s, hsv->v, hsv->a);
+}
+
+static PyObject *
+hsv_reduce(PyObject *self)
+{
+ return Py_BuildValue("ON", self->ob_type, hsv_getstate(self));
+}
+
+static PyMethodDef hsv_methods[] = {
+ { "set", (PyCFunction)hsv_set, METH_VARARGS|METH_KEYWORDS },
+ { "set_alpha", (PyCFunction)hsv_set_alpha, METH_VARARGS|METH_KEYWORDS },
+ { "clamp", (PyCFunction)hsv_clamp, METH_NOARGS },
+ { "to_rgb", (PyCFunction)hsv_to_rgb, METH_NOARGS },
+ { "__reduce__", (PyCFunction)hsv_reduce, METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+#define MEMBER_ACCESSOR(m, s) \
+static PyObject * \
+hsv_get_ ## m(PyObject *self, void *closure) \
+{ \
+ return PyFloat_FromDouble(pyg_boxed_get(self, GimpHSV)->m); \
+} \
+static int \
+hsv_set_ ## m(PyObject *self, PyObject *value, void *closure) \
+{ \
+ GimpHSV *hsv = pyg_boxed_get(self, GimpHSV); \
+ if (value == NULL) { \
+ PyErr_SetString(PyExc_TypeError, "cannot delete value"); \
+ return -1; \
+ } \
+ else if (PyInt_Check(value)) \
+ hsv->m = (double) PyInt_AS_LONG(value) / s; \
+ else if (PyFloat_Check(value)) \
+ hsv->m = PyFloat_AS_DOUBLE(value); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "type mismatch"); \
+ return -1; \
+ } \
+ return 0; \
+}
+
+MEMBER_ACCESSOR(h, 360.0);
+MEMBER_ACCESSOR(s, 100.0);
+MEMBER_ACCESSOR(v, 100.0);
+MEMBER_ACCESSOR(a, 255.0);
+
+#undef MEMBER_ACCESSOR
+
+static PyGetSetDef hsv_getsets[] = {
+ { "h", (getter)hsv_get_h, (setter)hsv_set_h },
+ { "s", (getter)hsv_get_s, (setter)hsv_set_s },
+ { "v", (getter)hsv_get_v, (setter)hsv_set_v },
+ { "a", (getter)hsv_get_a, (setter)hsv_set_a },
+ { "hue", (getter)hsv_get_h, (setter)hsv_set_h },
+ { "saturation", (getter)hsv_get_s, (setter)hsv_set_s },
+ { "value", (getter)hsv_get_v, (setter)hsv_set_v },
+ { "alpha", (getter)hsv_get_a, (setter)hsv_set_a },
+ { NULL, (getter)0, (setter)0 },
+};
+
+static Py_ssize_t
+hsv_length(PyObject *self)
+{
+ return 4;
+}
+
+static PyObject *
+hsv_getitem(PyObject *self, Py_ssize_t pos)
+{
+ GimpHSV *hsv;
+ double val, scale_factor;
+
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+
+ switch (pos) {
+ case 0: val = hsv->h; scale_factor = 360.0; break;
+ case 1: val = hsv->s; scale_factor = 100.0; break;
+ case 2: val = hsv->v; scale_factor = 100.0; break;
+ case 3: val = hsv->a; scale_factor = 255.0; break;
+ default:
+ g_assert_not_reached();
+ return NULL;
+ }
+
+ return PyInt_FromLong(ROUND(CLAMP(val, 0.0, 1.0) * scale_factor));
+}
+
+static int
+hsv_setitem(PyObject *self, Py_ssize_t pos, PyObject *value)
+{
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ switch (pos) {
+ case 0: return hsv_set_h(self, value, NULL);
+ case 1: return hsv_set_s(self, value, NULL);
+ case 2: return hsv_set_v(self, value, NULL);
+ case 3: return hsv_set_a(self, value, NULL);
+ default:
+ g_assert_not_reached();
+ return -1;
+ }
+}
+
+static PyObject *
+hsv_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
+{
+ PyTupleObject *ret;
+ Py_ssize_t i;
+
+ if (start < 0)
+ start = 0;
+ if (end > 4)
+ end = 4;
+ if (end < start)
+ end = start;
+
+ ret = (PyTupleObject *)PyTuple_New(end - start);
+ if (ret == NULL)
+ return NULL;
+
+ for (i = start; i < end; i++)
+ PyTuple_SET_ITEM(ret, i - start, hsv_getitem(self, i));
+
+ return (PyObject *)ret;
+}
+
+static PySequenceMethods hsv_as_sequence = {
+ hsv_length,
+ (binaryfunc)0,
+ 0,
+ hsv_getitem,
+ hsv_slice,
+ hsv_setitem,
+ 0,
+ (objobjproc)0,
+};
+
+static PyObject *
+hsv_subscript(PyObject *self, PyObject *item)
+{
+ if (PyInt_Check(item)) {
+ long i = PyInt_AS_LONG(item);
+ return hsv_getitem(self, i);
+ } else if (PyLong_Check(item)) {
+ long i = PyLong_AsLong(item);
+ if (i == -1 && PyErr_Occurred())
+ return NULL;
+ return hsv_getitem(self, i);
+ } else if (PySlice_Check(item)) {
+ Py_ssize_t start, stop, step, slicelength, cur, i;
+ PyObject *ret;
+
+ if (PySlice_GetIndicesEx((PySliceObject*)item, 4,
+ &start, &stop, &step, &slicelength) < 0)
+ return NULL;
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ } else {
+ ret = PyTuple_New(slicelength);
+ if (!ret)
+ return NULL;
+
+ for (cur = start, i = 0; i < slicelength; cur += step, i++)
+ PyTuple_SET_ITEM(ret, i, hsv_getitem(self, cur));
+
+ return ret;
+ }
+ } else if (PyString_Check(item)) {
+ char *s = PyString_AsString(item);
+
+ if (g_ascii_strcasecmp(s, "h") == 0 ||
+ g_ascii_strcasecmp(s, "hue") == 0)
+ return hsv_get_h(self, NULL);
+ else if (g_ascii_strcasecmp(s, "s") == 0 ||
+ g_ascii_strcasecmp(s, "saturation") == 0)
+ return hsv_get_s(self, NULL);
+ else if (g_ascii_strcasecmp(s, "v") == 0 ||
+ g_ascii_strcasecmp(s, "value") == 0)
+ return hsv_get_v(self, NULL);
+ else if (g_ascii_strcasecmp(s, "a") == 0 ||
+ g_ascii_strcasecmp(s, "alpha") == 0)
+ return hsv_get_a(self, NULL);
+ else {
+ PyErr_SetObject(PyExc_KeyError, item);
+ return NULL;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "indices must be integers");
+ return NULL;
+ }
+}
+
+static PyMappingMethods hsv_as_mapping = {
+ hsv_length,
+ (binaryfunc)hsv_subscript,
+ (objobjargproc)0
+};
+
+static long
+hsv_hash(PyObject *self)
+{
+ long ret = -1;
+
+ PyObject *temp = hsv_getstate(self);
+ if (temp != NULL) {
+ ret = PyObject_Hash(temp);
+ Py_DECREF(temp);
+ }
+
+ return ret;
+}
+
+static PyObject *
+hsv_richcompare(PyObject *self, PyObject *other, int op)
+{
+ GimpHSV *c1, *c2;
+ PyObject *ret;
+
+ if (!pygimp_hsv_check(other)) {
+ PyErr_Format(PyExc_TypeError,
+ "can't compare %s to %s",
+ self->ob_type->tp_name, other->ob_type->tp_name);
+ return NULL;
+ }
+
+ if (op != Py_EQ && op != Py_NE) {
+ PyErr_SetString(PyExc_TypeError,
+ "can't compare color values using <, <=, >, >=");
+ return NULL;
+ }
+
+ c1 = pyg_boxed_get(self, GimpHSV);
+ c2 = pyg_boxed_get(other, GimpHSV);
+
+ if ((c1->h == c2->h && c1->s == c2->s && c1->v == c2->v && c1->a == c2->a) == (op == Py_EQ))
+ ret = Py_True;
+ else
+ ret = Py_False;
+
+ Py_INCREF(ret);
+ return ret;
+}
+
+static PyObject *
+hsv_pretty_print(PyObject *self, gboolean inexact)
+{
+ GimpHSV *hsv;
+ PyObject *ret = NULL;
+ PyObject *h_f = NULL, *s_f = NULL, *v_f = NULL, *a_f = NULL;
+ PyObject *h = NULL, *s = NULL, *v = NULL, *a = NULL;
+ reprfunc repr;
+ const char *prefix;
+
+ if (inexact) {
+ repr = PyObject_Str;
+ prefix = "HSV ";
+ } else {
+ repr = PyObject_Repr;
+ prefix = self->ob_type->tp_name;
+ }
+
+ hsv = pyg_boxed_get(self, GimpHSV);
+
+ if ((h_f = PyFloat_FromDouble(hsv->h)) == NULL) goto cleanup;
+ if ((s_f = PyFloat_FromDouble(hsv->s)) == NULL) goto cleanup;
+ if ((v_f = PyFloat_FromDouble(hsv->v)) == NULL) goto cleanup;
+ if ((a_f = PyFloat_FromDouble(hsv->a)) == NULL) goto cleanup;
+
+ if ((h = repr(h_f)) == NULL) goto cleanup;
+ if ((s = repr(s_f)) == NULL) goto cleanup;
+ if ((v = repr(v_f)) == NULL) goto cleanup;
+ if ((a = repr(a_f)) == NULL) goto cleanup;
+
+ ret = PyString_FromFormat("%s(%s, %s, %s, %s)",
+ prefix,
+ PyString_AsString(h),
+ PyString_AsString(s),
+ PyString_AsString(v),
+ PyString_AsString(a));
+
+cleanup:
+ Py_XDECREF(h); Py_XDECREF(s); Py_XDECREF(v); Py_XDECREF(a);
+ Py_XDECREF(h_f); Py_XDECREF(s_f); Py_XDECREF(v_f); Py_XDECREF(a_f);
+
+ return ret;
+}
+
+static PyObject *
+hsv_repr(PyObject *self)
+{
+ return hsv_pretty_print(self, FALSE);
+}
+
+static PyObject *
+hsv_str(PyObject *self)
+{
+ return hsv_pretty_print(self, TRUE);
+}
+
+static int
+hsv_init(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *h, *s, *v, *a = NULL;
+ GimpHSV hsv;
+ static char *kwlist[] = { "h", "s", "v", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OOO|O:set", kwlist,
+ &h, &s, &v, &a))
+ return -1;
+
+#define SET_MEMBER(m, s) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ hsv.m = (double) PyInt_AS_LONG(m) / s; \
+ else if (PyFloat_Check(m)) \
+ hsv.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return -1; \
+ } \
+} G_STMT_END
+
+ SET_MEMBER(h, 360.0);
+ SET_MEMBER(s, 100.0);
+ SET_MEMBER(v, 100.0);
+
+ if (a)
+ SET_MEMBER(a, 255.0);
+ else
+ hsv.a = 1.0;
+
+#undef SET_MEMBER
+
+ self->gtype = GIMP_TYPE_HSV;
+ self->free_on_dealloc = TRUE;
+ self->boxed = g_boxed_copy(GIMP_TYPE_HSV, &hsv);
+
+ return 0;
+}
+
+PyTypeObject PyGimpHSV_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpcolor.HSV", /* tp_name */
+ sizeof(PyGBoxed), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)hsv_repr, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ &hsv_as_sequence, /* tp_as_sequence */
+ &hsv_as_mapping, /* tp_as_mapping */
+ (hashfunc)hsv_hash, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)hsv_str, /* tp_repr */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)hsv_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ hsv_methods, /* tp_methods */
+ 0, /* tp_members */
+ hsv_getsets, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)hsv_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+PyObject *
+pygimp_hsv_new(const GimpHSV *hsv)
+{
+ return pyg_boxed_new(GIMP_TYPE_HSV, (gpointer)hsv, TRUE, TRUE);
+}
+
+
+static PyObject *
+hsl_set(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *h = NULL, *s = NULL, *l = NULL, *a = NULL;
+ GimpHSL tmphsl, *hsl;
+ static char *kwlist[] = { "h", "s", "l", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO:set", kwlist,
+ &h, &s, &l, &a))
+ return NULL;
+
+ if (!h && !s && !l && !a) {
+ PyErr_SetString(PyExc_TypeError, "must provide h,s,l or a arguments");
+ return NULL;
+ }
+
+ if ((h && (!s || !l)) ||
+ (s && (!h || !l)) ||
+ (l && (!h || !s))) {
+ PyErr_SetString(PyExc_TypeError, "must provide all 3 h,s,l arguments");
+ return NULL;
+ }
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+ tmphsl = *hsl;
+
+#define SET_MEMBER(m, s) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ tmphsl.m = (double) PyInt_AS_LONG(m) / s; \
+ else if (PyFloat_Check(m)) \
+ tmphsl.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be a float"); \
+ return NULL; \
+ } \
+} G_STMT_END
+
+ if (h) {
+ SET_MEMBER(h, 360.0);
+ SET_MEMBER(s, 100.0);
+ SET_MEMBER(l, 100.0);
+ }
+
+ if (a)
+ SET_MEMBER(a, 255.0);
+
+#undef SET_MEMBER
+
+ *hsl = tmphsl;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+hsl_set_alpha(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_a;
+ GimpHSL *hsl;
+ static char *kwlist[] = { "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:set_alpha", kwlist,
+ &py_a))
+ return NULL;
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+
+ if (PyInt_Check(py_a))
+ hsl->a = (double) PyInt_AS_LONG(py_a) / 255.0;
+ else if (PyFloat_Check(py_a))
+ hsl->a = PyFloat_AS_DOUBLE(py_a);
+ else {
+ PyErr_SetString(PyExc_TypeError, "a must be a float");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+hsl_to_rgb(PyObject *self)
+{
+ GimpHSL *hsl;
+ GimpRGB rgb;
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+
+ gimp_hsl_to_rgb(hsl, &rgb);
+
+ return pygimp_rgb_new(&rgb);
+}
+
+/* __getstate__ isn't exposed */
+static PyObject *
+hsl_getstate(PyObject *self)
+{
+ GimpHSL *hsl;
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+
+ return Py_BuildValue("dddd", hsl->h, hsl->s, hsl->l, hsl->a);
+}
+
+static PyObject *
+hsl_reduce(PyObject *self)
+{
+ return Py_BuildValue("ON", self->ob_type, hsl_getstate(self));
+}
+
+static PyMethodDef hsl_methods[] = {
+ { "set", (PyCFunction)hsl_set, METH_VARARGS|METH_KEYWORDS },
+ { "set_alpha", (PyCFunction)hsl_set_alpha, METH_VARARGS|METH_KEYWORDS },
+ { "to_rgb", (PyCFunction)hsl_to_rgb, METH_NOARGS },
+ { "__reduce__", (PyCFunction)hsl_reduce, METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+#define MEMBER_ACCESSOR(m, s) \
+static PyObject * \
+hsl_get_ ## m(PyObject *self, void *closure) \
+{ \
+ return PyFloat_FromDouble(pyg_boxed_get(self, GimpHSL)->m); \
+} \
+static int \
+hsl_set_ ## m(PyObject *self, PyObject *value, void *closure) \
+{ \
+ GimpHSL *hsl = pyg_boxed_get(self, GimpHSL); \
+ if (value == NULL) { \
+ PyErr_SetString(PyExc_TypeError, "cannot delete value"); \
+ return -1; \
+ } \
+ else if (PyInt_Check(value)) \
+ hsl->m = (double) PyInt_AS_LONG(value) / s; \
+ else if (PyFloat_Check(value)) \
+ hsl->m = PyFloat_AS_DOUBLE(value); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "type mismatch"); \
+ return -1; \
+ } \
+ return 0; \
+}
+
+MEMBER_ACCESSOR(h, 360.0);
+MEMBER_ACCESSOR(s, 100.0);
+MEMBER_ACCESSOR(l, 100.0);
+MEMBER_ACCESSOR(a, 255.0);
+
+#undef MEMBER_ACCESSOR
+
+static PyGetSetDef hsl_getsets[] = {
+ { "h", (getter)hsl_get_h, (setter)hsl_set_h },
+ { "s", (getter)hsl_get_s, (setter)hsl_set_s },
+ { "l", (getter)hsl_get_l, (setter)hsl_set_l },
+ { "a", (getter)hsl_get_a, (setter)hsl_set_a },
+ { "hue", (getter)hsl_get_h, (setter)hsl_set_h },
+ { "saturation", (getter)hsl_get_s, (setter)hsl_set_s },
+ { "lightness", (getter)hsl_get_l, (setter)hsl_set_l },
+ { "alpha", (getter)hsl_get_a, (setter)hsl_set_a },
+ { NULL, (getter)0, (setter)0 },
+};
+
+static Py_ssize_t
+hsl_length(PyObject *self)
+{
+ return 4;
+}
+
+static PyObject *
+hsl_getitem(PyObject *self, Py_ssize_t pos)
+{
+ GimpHSL *hsl;
+ double val, scale_factor;
+
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+
+ switch (pos) {
+ case 0: val = hsl->h; scale_factor = 360.0; break;
+ case 1: val = hsl->s; scale_factor = 100.0; break;
+ case 2: val = hsl->l; scale_factor = 100.0; break;
+ case 3: val = hsl->a; scale_factor = 255.0; break;
+ default:
+ g_assert_not_reached();
+ return NULL;
+ }
+
+ return PyInt_FromLong(ROUND(CLAMP(val, 0.0, 1.0) * scale_factor));
+}
+
+static int
+hsl_setitem(PyObject *self, Py_ssize_t pos, PyObject *value)
+{
+ if (pos < 0)
+ pos += 4;
+
+ if (pos < 0 || pos >= 4) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ switch (pos) {
+ case 0: return hsl_set_h(self, value, NULL);
+ case 1: return hsl_set_s(self, value, NULL);
+ case 2: return hsl_set_l(self, value, NULL);
+ case 3: return hsl_set_a(self, value, NULL);
+ default:
+ g_assert_not_reached();
+ return -1;
+ }
+}
+
+static PyObject *
+hsl_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
+{
+ PyTupleObject *ret;
+ Py_ssize_t i;
+
+ if (start < 0)
+ start = 0;
+ if (end > 4)
+ end = 4;
+ if (end < start)
+ end = start;
+
+ ret = (PyTupleObject *)PyTuple_New(end - start);
+ if (ret == NULL)
+ return NULL;
+
+ for (i = start; i < end; i++)
+ PyTuple_SET_ITEM(ret, i - start, hsl_getitem(self, i));
+
+ return (PyObject *)ret;
+}
+
+static PySequenceMethods hsl_as_sequence = {
+ hsl_length,
+ (binaryfunc)0,
+ 0,
+ hsl_getitem,
+ hsl_slice,
+ hsl_setitem,
+ 0,
+ (objobjproc)0,
+};
+
+static PyObject *
+hsl_subscript(PyObject *self, PyObject *item)
+{
+ if (PyInt_Check(item)) {
+ long i = PyInt_AS_LONG(item);
+ return hsl_getitem(self, i);
+ } else if (PyLong_Check(item)) {
+ long i = PyLong_AsLong(item);
+ if (i == -1 && PyErr_Occurred())
+ return NULL;
+ return hsl_getitem(self, i);
+ } else if (PySlice_Check(item)) {
+ Py_ssize_t start, stop, step, slicelength, cur, i;
+ PyObject *ret;
+
+ if (PySlice_GetIndicesEx((PySliceObject*)item, 4,
+ &start, &stop, &step, &slicelength) < 0)
+ return NULL;
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ } else {
+ ret = PyTuple_New(slicelength);
+ if (!ret)
+ return NULL;
+
+ for (cur = start, i = 0; i < slicelength; cur += step, i++)
+ PyTuple_SET_ITEM(ret, i, hsl_getitem(self, cur));
+
+ return ret;
+ }
+ } else if (PyString_Check(item)) {
+ char *s = PyString_AsString(item);
+
+ if (g_ascii_strcasecmp(s, "h") == 0 ||
+ g_ascii_strcasecmp(s, "hue") == 0)
+ return hsl_get_h(self, NULL);
+ else if (g_ascii_strcasecmp(s, "s") == 0 ||
+ g_ascii_strcasecmp(s, "saturation") == 0)
+ return hsl_get_s(self, NULL);
+ else if (g_ascii_strcasecmp(s, "l") == 0 ||
+ g_ascii_strcasecmp(s, "lightness") == 0)
+ return hsl_get_l(self, NULL);
+ else if (g_ascii_strcasecmp(s, "a") == 0 ||
+ g_ascii_strcasecmp(s, "alpha") == 0)
+ return hsl_get_a(self, NULL);
+ else {
+ PyErr_SetObject(PyExc_KeyError, item);
+ return NULL;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "indices must be integers");
+ return NULL;
+ }
+}
+
+static PyMappingMethods hsl_as_mapping = {
+ hsl_length,
+ (binaryfunc)hsl_subscript,
+ (objobjargproc)0
+};
+
+static long
+hsl_hash(PyObject *self)
+{
+ long ret = -1;
+
+ PyObject *temp = hsl_getstate(self);
+ if (temp != NULL) {
+ ret = PyObject_Hash(temp);
+ Py_DECREF(temp);
+ }
+
+ return ret;
+}
+
+static PyObject *
+hsl_richcompare(PyObject *self, PyObject *other, int op)
+{
+ GimpHSL *c1, *c2;
+ PyObject *ret;
+
+ if (!pygimp_hsl_check(other)) {
+ PyErr_Format(PyExc_TypeError,
+ "can't compare %s to %s",
+ self->ob_type->tp_name, other->ob_type->tp_name);
+ return NULL;
+ }
+
+ if (op != Py_EQ && op != Py_NE) {
+ PyErr_SetString(PyExc_TypeError,
+ "can't compare color values using <, <=, >, >=");
+ return NULL;
+ }
+
+ c1 = pyg_boxed_get(self, GimpHSL);
+ c2 = pyg_boxed_get(other, GimpHSL);
+
+ if ((c1->h == c2->h && c1->s == c2->s && c1->l == c2->l && c1->a == c2->a) == (op == Py_EQ))
+ ret = Py_True;
+ else
+ ret = Py_False;
+
+ Py_INCREF(ret);
+ return ret;
+}
+
+static PyObject *
+hsl_pretty_print(PyObject *self, gboolean inexact)
+{
+ GimpHSL *hsl;
+ PyObject *ret = NULL;
+ PyObject *h_f = NULL, *s_f = NULL, *l_f = NULL, *a_f = NULL;
+ PyObject *h = NULL, *s = NULL, *l = NULL, *a = NULL;
+ reprfunc repr;
+ const char *prefix;
+
+ if (inexact) {
+ repr = PyObject_Str;
+ prefix = "HSL ";
+ } else {
+ repr = PyObject_Repr;
+ prefix = self->ob_type->tp_name;
+ }
+
+ hsl = pyg_boxed_get(self, GimpHSL);
+
+ if ((h_f = PyFloat_FromDouble(hsl->h)) == NULL) goto cleanup;
+ if ((s_f = PyFloat_FromDouble(hsl->s)) == NULL) goto cleanup;
+ if ((l_f = PyFloat_FromDouble(hsl->l)) == NULL) goto cleanup;
+ if ((a_f = PyFloat_FromDouble(hsl->a)) == NULL) goto cleanup;
+
+ if ((h = repr(h_f)) == NULL) goto cleanup;
+ if ((s = repr(s_f)) == NULL) goto cleanup;
+ if ((l = repr(l_f)) == NULL) goto cleanup;
+ if ((a = repr(a_f)) == NULL) goto cleanup;
+
+ ret = PyString_FromFormat("%s(%s, %s, %s, %s)",
+ prefix,
+ PyString_AsString(h),
+ PyString_AsString(s),
+ PyString_AsString(l),
+ PyString_AsString(a));
+
+cleanup:
+ Py_XDECREF(h); Py_XDECREF(s); Py_XDECREF(l); Py_XDECREF(a);
+ Py_XDECREF(h_f); Py_XDECREF(s_f); Py_XDECREF(l_f); Py_XDECREF(a_f);
+
+ return ret;
+}
+
+static PyObject *
+hsl_repr(PyObject *self)
+{
+ return hsl_pretty_print(self, FALSE);
+}
+
+static PyObject *
+hsl_str(PyObject *self)
+{
+ return hsl_pretty_print(self, TRUE);
+}
+
+static int
+hsl_init(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *h, *s, *l, *a = NULL;
+ GimpHSL hsl;
+ static char *kwlist[] = { "h", "s", "l", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OOO|O:set", kwlist,
+ &h, &s, &l, &a))
+ return -1;
+
+#define SET_MEMBER(m, s) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ hsl.m = (double) PyInt_AS_LONG(m) / s; \
+ else if (PyFloat_Check(m)) \
+ hsl.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be a float"); \
+ return -1; \
+ } \
+} G_STMT_END
+
+ SET_MEMBER(h, 360.0);
+ SET_MEMBER(s, 100.0);
+ SET_MEMBER(l, 100.0);
+
+ if (a)
+ SET_MEMBER(a, 255.0);
+ else
+ hsl.a = 1.0;
+
+#undef SET_MEMBER
+
+ self->gtype = GIMP_TYPE_HSL;
+ self->free_on_dealloc = TRUE;
+ self->boxed = g_boxed_copy(GIMP_TYPE_HSL, &hsl);
+
+ return 0;
+}
+
+PyTypeObject PyGimpHSL_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpcolor.HSL", /* tp_name */
+ sizeof(PyGBoxed), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)hsl_repr, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ &hsl_as_sequence, /* tp_as_sequence */
+ &hsl_as_mapping, /* tp_as_mapping */
+ (hashfunc)hsl_hash, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)hsl_str, /* tp_repr */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)hsl_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ hsl_methods, /* tp_methods */
+ 0, /* tp_members */
+ hsl_getsets, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)hsl_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+PyObject *
+pygimp_hsl_new(const GimpHSL *hsl)
+{
+ return pyg_boxed_new(GIMP_TYPE_HSL, (gpointer)hsl, TRUE, TRUE);
+}
+
+
+static PyObject *
+cmyk_set(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *c = NULL, *m = NULL, *y = NULL, *k = NULL, *a = NULL;
+ GimpCMYK tmpcmyk, *cmyk;
+ static char *kwlist[] = { "c", "m", "y", "k", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOOO:set", kwlist,
+ &c, &m, &y, &k, &a))
+ return NULL;
+
+ if (!c && !y && !m && !k && !a) {
+ PyErr_SetString(PyExc_TypeError, "must provide c,m,y,k or a arguments");
+ return NULL;
+ }
+
+ if ((c && (!m || !y || !k)) ||
+ (m && (!c || !y || !k)) ||
+ (y && (!c || !m || !k)) ||
+ (k && (!c || !m || !y))) {
+ PyErr_SetString(PyExc_TypeError, "must provide all 4 c,m,y,k arguments");
+ return NULL;
+ }
+
+ cmyk = pyg_boxed_get(self, GimpCMYK);
+ tmpcmyk = *cmyk;
+
+#define SET_MEMBER(m) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ tmpcmyk.m = (double) PyInt_AS_LONG(m) / 255.0; \
+ else if (PyFloat_Check(m)) \
+ tmpcmyk.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return NULL; \
+ } \
+} G_STMT_END
+
+ if (c) {
+ SET_MEMBER(c);
+ SET_MEMBER(y);
+ SET_MEMBER(m);
+ SET_MEMBER(k);
+ }
+
+ if (a)
+ SET_MEMBER(a);
+
+#undef SET_MEMBER
+
+ *cmyk = tmpcmyk;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+cmyk_set_alpha(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *py_a;
+ GimpCMYK *cmyk;
+ static char *kwlist[] = { "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O:set_alpha", kwlist,
+ &py_a))
+ return NULL;
+
+ cmyk = pyg_boxed_get(self, GimpCMYK);
+
+ if (PyInt_Check(py_a))
+ cmyk->a = (double) PyInt_AS_LONG(py_a) / 255.0;
+ else if (PyFloat_Check(py_a))
+ cmyk->a = PyFloat_AS_DOUBLE(py_a);
+ else {
+ PyErr_SetString(PyExc_TypeError, "a must be an int or a float");
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/* __getstate__ isn't exposed */
+static PyObject *
+cmyk_getstate(PyObject *self)
+{
+ GimpCMYK *cmyk;
+
+ cmyk = pyg_boxed_get(self, GimpCMYK);
+
+ return Py_BuildValue("ddddd", cmyk->c, cmyk->m, cmyk->y, cmyk->k, cmyk->a);
+}
+
+static PyObject *
+cmyk_reduce(PyObject *self)
+{
+ return Py_BuildValue("ON", self->ob_type, cmyk_getstate(self));
+}
+
+static PyMethodDef cmyk_methods[] = {
+ { "set", (PyCFunction)cmyk_set, METH_VARARGS|METH_KEYWORDS },
+ { "set_alpha", (PyCFunction)cmyk_set_alpha, METH_VARARGS|METH_KEYWORDS },
+ { "__reduce__", (PyCFunction)cmyk_reduce, METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+#define MEMBER_ACCESSOR(m) \
+static PyObject * \
+cmyk_get_ ## m(PyObject *self, void *closure) \
+{ \
+ return PyFloat_FromDouble(pyg_boxed_get(self, GimpCMYK)->m); \
+} \
+static int \
+cmyk_set_ ## m(PyObject *self, PyObject *value, void *closure) \
+{ \
+ GimpCMYK *cmyk = pyg_boxed_get(self, GimpCMYK); \
+ if (value == NULL) { \
+ PyErr_SetString(PyExc_TypeError, "cannot delete value"); \
+ return -1; \
+ } \
+ else if (PyInt_Check(value)) \
+ cmyk->m = (double) PyInt_AS_LONG(value) / 255.0; \
+ else if (PyFloat_Check(value)) \
+ cmyk->m = PyFloat_AS_DOUBLE(value); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "type mismatch"); \
+ return -1; \
+ } \
+ return 0; \
+}
+
+MEMBER_ACCESSOR(c);
+MEMBER_ACCESSOR(m);
+MEMBER_ACCESSOR(y);
+MEMBER_ACCESSOR(k);
+MEMBER_ACCESSOR(a);
+
+#undef MEMBER_ACCESSOR
+
+static PyGetSetDef cmyk_getsets[] = {
+ { "c", (getter)cmyk_get_c, (setter)cmyk_set_c },
+ { "m", (getter)cmyk_get_m, (setter)cmyk_set_m },
+ { "y", (getter)cmyk_get_y, (setter)cmyk_set_y },
+ { "k", (getter)cmyk_get_k, (setter)cmyk_set_k },
+ { "a", (getter)cmyk_get_a, (setter)cmyk_set_a },
+ { "cyan", (getter)cmyk_get_c, (setter)cmyk_set_c },
+ { "magenta", (getter)cmyk_get_m, (setter)cmyk_set_m },
+ { "yellow", (getter)cmyk_get_y, (setter)cmyk_set_y },
+ { "black", (getter)cmyk_get_k, (setter)cmyk_set_k },
+ { "alpha", (getter)cmyk_get_a, (setter)cmyk_set_a },
+ { NULL, (getter)0, (setter)0 },
+};
+
+static Py_ssize_t
+cmyk_length(PyObject *self)
+{
+ return 5;
+}
+
+static PyObject *
+cmyk_getitem(PyObject *self, Py_ssize_t pos)
+{
+ GimpCMYK *cmyk;
+ double val;
+
+ if (pos < 0)
+ pos += 5;
+
+ if (pos < 0 || pos >= 5) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ cmyk = pyg_boxed_get(self, GimpCMYK);
+
+ switch (pos) {
+ case 0: val = cmyk->c; break;
+ case 1: val = cmyk->m; break;
+ case 2: val = cmyk->y; break;
+ case 3: val = cmyk->k; break;
+ case 4: val = cmyk->a; break;
+ default:
+ g_assert_not_reached();
+ return NULL;
+ }
+
+ return PyInt_FromLong(ROUND(CLAMP(val, 0.0, 1.0) * 255.0));
+}
+
+static int
+cmyk_setitem(PyObject *self, Py_ssize_t pos, PyObject *value)
+{
+ if (pos < 0)
+ pos += 5;
+
+ if (pos < 0 || pos >= 5) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ switch (pos) {
+ case 0: return cmyk_set_c(self, value, NULL);
+ case 1: return cmyk_set_m(self, value, NULL);
+ case 2: return cmyk_set_y(self, value, NULL);
+ case 3: return cmyk_set_k(self, value, NULL);
+ case 4: return cmyk_set_a(self, value, NULL);
+ default:
+ g_assert_not_reached();
+ return -1;
+ }
+}
+
+static PyObject *
+cmyk_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
+{
+ PyTupleObject *ret;
+ Py_ssize_t i;
+
+ if (start < 0)
+ start = 0;
+ if (end > 5)
+ end = 5;
+ if (end < start)
+ end = start;
+
+ ret = (PyTupleObject *)PyTuple_New(end - start);
+ if (ret == NULL)
+ return NULL;
+
+ for (i = start; i < end; i++)
+ PyTuple_SET_ITEM(ret, i - start, cmyk_getitem(self, i));
+
+ return (PyObject *)ret;
+}
+
+static PySequenceMethods cmyk_as_sequence = {
+ cmyk_length,
+ (binaryfunc)0,
+ 0,
+ cmyk_getitem,
+ cmyk_slice,
+ cmyk_setitem,
+ 0,
+ (objobjproc)0,
+};
+
+static PyObject *
+cmyk_subscript(PyObject *self, PyObject *item)
+{
+ if (PyInt_Check(item)) {
+ long i = PyInt_AS_LONG(item);
+ return cmyk_getitem(self, i);
+ } else if (PyLong_Check(item)) {
+ long i = PyLong_AsLong(item);
+ if (i == -1 && PyErr_Occurred())
+ return NULL;
+ return cmyk_getitem(self, i);
+ } else if (PySlice_Check(item)) {
+ Py_ssize_t start, stop, step, slicelength, cur, i;
+ PyObject *ret;
+
+ if (PySlice_GetIndicesEx((PySliceObject*)item, 5,
+ &start, &stop, &step, &slicelength) < 0)
+ return NULL;
+
+ if (slicelength <= 0) {
+ return PyTuple_New(0);
+ } else {
+ ret = PyTuple_New(slicelength);
+ if (!ret)
+ return NULL;
+
+ for (cur = start, i = 0; i < slicelength; cur += step, i++)
+ PyTuple_SET_ITEM(ret, i, cmyk_getitem(self, cur));
+
+ return ret;
+ }
+ } else if (PyString_Check(item)) {
+ char *s = PyString_AsString(item);
+
+ if (g_ascii_strcasecmp(s, "c") == 0 ||
+ g_ascii_strcasecmp(s, "cyan") == 0)
+ return cmyk_get_c(self, NULL);
+ else if (g_ascii_strcasecmp(s, "m") == 0 ||
+ g_ascii_strcasecmp(s, "magenta") == 0)
+ return cmyk_get_m(self, NULL);
+ else if (g_ascii_strcasecmp(s, "y") == 0 ||
+ g_ascii_strcasecmp(s, "yellow") == 0)
+ return cmyk_get_y(self, NULL);
+ else if (g_ascii_strcasecmp(s, "k") == 0 ||
+ g_ascii_strcasecmp(s, "black") == 0)
+ return cmyk_get_k(self, NULL);
+ else if (g_ascii_strcasecmp(s, "a") == 0 ||
+ g_ascii_strcasecmp(s, "alpha") == 0)
+ return cmyk_get_a(self, NULL);
+ else {
+ PyErr_SetObject(PyExc_KeyError, item);
+ return NULL;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError,
+ "indices must be integers");
+ return NULL;
+ }
+}
+
+static PyMappingMethods cmyk_as_mapping = {
+ cmyk_length,
+ (binaryfunc)cmyk_subscript,
+ (objobjargproc)0
+};
+
+static long
+cmyk_hash(PyObject *self)
+{
+ long ret = -1;
+
+ PyObject *temp = cmyk_getstate(self);
+ if (temp != NULL) {
+ ret = PyObject_Hash(temp);
+ Py_DECREF(temp);
+ }
+
+ return ret;
+}
+
+static PyObject *
+cmyk_richcompare(PyObject *self, PyObject *other, int op)
+{
+ GimpCMYK *c1, *c2;
+ PyObject *ret;
+
+ if (!pygimp_cmyk_check(other)) {
+ PyErr_Format(PyExc_TypeError,
+ "can't compare %s to %s",
+ self->ob_type->tp_name, other->ob_type->tp_name);
+ return NULL;
+ }
+
+ if (op != Py_EQ && op != Py_NE) {
+ PyErr_SetString(PyExc_TypeError,
+ "can't compare color values using <, <=, >, >=");
+ return NULL;
+ }
+
+ c1 = pyg_boxed_get(self, GimpCMYK);
+ c2 = pyg_boxed_get(other, GimpCMYK);
+
+ if ((c1->c == c2->c && c1->m == c2->m && c1->y == c2->y && c1->k == c2->k && c1->a == c2->a) == (op == Py_EQ))
+ ret = Py_True;
+ else
+ ret = Py_False;
+
+ Py_INCREF(ret);
+ return ret;
+}
+
+static PyObject *
+cmyk_pretty_print(PyObject *self, gboolean inexact)
+{
+ GimpCMYK *cmyk;
+ PyObject *ret = NULL;
+ PyObject *c_f = NULL, *m_f = NULL, *y_f = NULL, *k_f = NULL, *a_f = NULL;
+ PyObject *c = NULL, *m = NULL, *y = NULL, *k = NULL, *a = NULL;
+ reprfunc repr;
+ const char *prefix;
+
+ if (inexact) {
+ repr = PyObject_Str;
+ prefix = "CMYK ";
+ } else {
+ repr = PyObject_Repr;
+ prefix = self->ob_type->tp_name;
+ }
+
+ cmyk = pyg_boxed_get(self, GimpCMYK);
+
+ if ((c_f = PyFloat_FromDouble(cmyk->c)) == NULL) goto cleanup;
+ if ((m_f = PyFloat_FromDouble(cmyk->m)) == NULL) goto cleanup;
+ if ((y_f = PyFloat_FromDouble(cmyk->y)) == NULL) goto cleanup;
+ if ((k_f = PyFloat_FromDouble(cmyk->k)) == NULL) goto cleanup;
+ if ((a_f = PyFloat_FromDouble(cmyk->a)) == NULL) goto cleanup;
+
+ if ((c = repr(c_f)) == NULL) goto cleanup;
+ if ((m = repr(m_f)) == NULL) goto cleanup;
+ if ((y = repr(y_f)) == NULL) goto cleanup;
+ if ((k = repr(k_f)) == NULL) goto cleanup;
+ if ((a = repr(a_f)) == NULL) goto cleanup;
+
+ ret = PyString_FromFormat("%s(%s, %s, %s, %s, %s)",
+ prefix,
+ PyString_AsString(c),
+ PyString_AsString(m),
+ PyString_AsString(y),
+ PyString_AsString(k),
+ PyString_AsString(a));
+
+cleanup:
+ Py_XDECREF(c); Py_XDECREF(m); Py_XDECREF(y); Py_XDECREF(k); Py_XDECREF(a);
+ Py_XDECREF(c_f); Py_XDECREF(m_f); Py_XDECREF(y_f); Py_XDECREF(k_f); Py_XDECREF(a_f);
+
+ return ret;
+}
+
+static PyObject *
+cmyk_repr(PyObject *self)
+{
+ return cmyk_pretty_print(self, FALSE);
+}
+
+static PyObject *
+cmyk_str(PyObject *self)
+{
+ return cmyk_pretty_print(self, TRUE);
+}
+
+static int
+cmyk_init(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+ PyObject *c, *m, *y, *k, *a = NULL;
+ GimpCMYK cmyk;
+ static char *kwlist[] = { "c", "m", "y", "k", "a", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "OOOO|O:set", kwlist,
+ &c, &m, &y, &k, &a))
+ return -1;
+
+#define SET_MEMBER(m) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ cmyk.m = (double) PyInt_AS_LONG(m) / 255.0; \
+ else if (PyFloat_Check(m)) \
+ cmyk.m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return -1; \
+ } \
+} G_STMT_END
+
+ SET_MEMBER(c);
+ SET_MEMBER(m);
+ SET_MEMBER(y);
+ SET_MEMBER(k);
+
+ if (a)
+ SET_MEMBER(a);
+ else
+ cmyk.a = 1.0;
+
+#undef SET_MEMBER
+
+ self->gtype = GIMP_TYPE_CMYK;
+ self->free_on_dealloc = TRUE;
+ self->boxed = g_boxed_copy(GIMP_TYPE_CMYK, &cmyk);
+
+ return 0;
+}
+
+PyTypeObject PyGimpCMYK_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimpcolor.CMYK", /* tp_name */
+ sizeof(PyGBoxed), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)0, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)cmyk_repr, /* tp_repr */
+ (PyNumberMethods*)0, /* tp_as_number */
+ &cmyk_as_sequence, /* tp_as_sequence */
+ &cmyk_as_mapping, /* tp_as_mapping */
+ (hashfunc)cmyk_hash, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)cmyk_str, /* tp_repr */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ (PyBufferProcs*)0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)cmyk_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ cmyk_methods, /* tp_methods */
+ 0, /* tp_members */
+ cmyk_getsets, /* tp_getset */
+ NULL, /* tp_base */
+ NULL, /* tp_dict */
+ (descrgetfunc)0, /* tp_descr_get */
+ (descrsetfunc)0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)cmyk_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+ (freefunc)0, /* tp_free */
+ (inquiry)0 /* tp_is_gc */
+};
+
+PyObject *
+pygimp_cmyk_new(const GimpCMYK *cmyk)
+{
+ return pyg_boxed_new(GIMP_TYPE_CMYK, (gpointer)cmyk, TRUE, TRUE);
+}
+
+int
+pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color)
+{
+ g_return_val_if_fail(color != NULL, FALSE);
+
+ if (pygimp_rgb_check(object)) {
+ *color = *pyg_boxed_get(object, GimpRGB);
+ return 1;
+ } else if (PyString_Check(object)) {
+ if (gimp_rgb_parse_css (color, PyString_AsString(object), -1)) {
+ return 1;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "unable to parse color string");
+ return 0;
+ }
+ } else if (PySequence_Check(object)) {
+ PyObject *r, *g, *b, *a = NULL;
+
+ if (!PyArg_ParseTuple(object, "OOO|O", &r, &g, &b, &a))
+ return 0;
+
+#define SET_MEMBER(m) G_STMT_START { \
+ if (PyInt_Check(m)) \
+ color->m = (double) PyInt_AS_LONG(m) / 255.0; \
+ else if (PyFloat_Check(m)) \
+ color->m = PyFloat_AS_DOUBLE(m); \
+ else { \
+ PyErr_SetString(PyExc_TypeError, \
+ #m " must be an int or a float"); \
+ return 0; \
+ } \
+} G_STMT_END
+
+ SET_MEMBER(r);
+ SET_MEMBER(g);
+ SET_MEMBER(b);
+
+ if (a)
+ SET_MEMBER(a);
+ else
+ color->a = 1.0;
+
+ gimp_rgb_clamp(color);
+
+ return 1;
+ }
+
+ PyErr_SetString(PyExc_TypeError, "could not convert to GimpRGB");
+ return 0;
+}
diff --git a/plug-ins/pygimp/pygimp-display.c b/plug-ins/pygimp/pygimp-display.c
new file mode 100644
index 0000000..cf138d3
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-display.c
@@ -0,0 +1,140 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pygimp.h"
+
+static PyMethodDef disp_methods[] = {
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+disp_get_ID(PyGimpDisplay *self, void *closure)
+{
+ return PyInt_FromLong(self->ID);
+}
+
+static PyGetSetDef disp_getsets[] = {
+ { "ID", (getter)disp_get_ID, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+/* ---------- */
+
+
+PyObject *
+pygimp_display_new(gint32 ID)
+{
+ PyGimpDisplay *self;
+
+ if (!gimp_display_is_valid(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ self = PyObject_NEW(PyGimpDisplay, &PyGimpDisplay_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+
+ return (PyObject *)self;
+}
+
+static void
+disp_dealloc(PyGimpDisplay *self)
+{
+ PyObject_DEL(self);
+}
+
+static PyObject *
+disp_repr(PyGimpDisplay *self)
+{
+ PyObject *s;
+
+ s = PyString_FromString("<display>");
+
+ return s;
+}
+
+static int
+disp_init(PyGimpDisplay *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+
+ if (!PyArg_ParseTuple(args, "O!:gimp.Display.__init__",
+ &PyGimpImage_Type, &img))
+ return -1;
+
+ self->ID = gimp_display_new(img->ID);
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error, "could not create display for image (ID %d)",
+ img->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+PyTypeObject PyGimpDisplay_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Display", /* tp_name */
+ sizeof(PyGimpDisplay), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)disp_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)disp_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ disp_methods, /* tp_methods */
+ 0, /* tp_members */
+ disp_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)disp_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
diff --git a/plug-ins/pygimp/pygimp-drawable.c b/plug-ins/pygimp/pygimp-drawable.c
new file mode 100644
index 0000000..9134d9b
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-drawable.c
@@ -0,0 +1,2459 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#define GIMP_DISABLE_DEPRECATION_WARNINGS
+#include "pygimp.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+#include <glib-object.h>
+
+#include <gegl.h>
+
+static void
+ensure_drawable(PyGimpDrawable *self)
+{
+ if (!self->drawable)
+ self->drawable = gimp_drawable_get(self->ID);
+}
+
+static PyObject *
+drw_flush(PyGimpDrawable *self)
+{
+ ensure_drawable(self);
+
+ gimp_drawable_flush(self->drawable);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+drw_update(PyGimpDrawable *self, PyObject *args)
+{
+ int x, y;
+ unsigned int w, h;
+
+ if (!PyArg_ParseTuple(args, "iiii:update", &x, &y, &w, &h))
+ return NULL;
+
+ if (!gimp_drawable_update(self->ID, x, y, w, h)) {
+ PyErr_Format(pygimp_error,
+ "could not update drawable (ID %d): "
+ "x=%d, y=%d, w=%d, h=%d",
+ self->ID, x, y, (int)w, (int)h);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+drw_merge_shadow(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ gboolean undo = FALSE;
+
+ static char *kwlist[] = { "undo", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:merge_shadow", kwlist,
+ &undo))
+ return NULL;
+
+ if (!gimp_drawable_merge_shadow(self->ID, undo)) {
+ PyErr_Format(pygimp_error,
+ "could not merge the shadow buffer on drawable (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_free_shadow(PyGimpDrawable *self)
+{
+ if (!gimp_drawable_free_shadow(self->ID)) {
+ PyErr_Format(pygimp_error, "could not free shadow tiles on drawable (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_fill(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int fill = GIMP_FILL_FOREGROUND;
+
+ static char *kwlist[] = { "fill", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:fill", kwlist, &fill))
+ return NULL;
+
+ if (!gimp_drawable_fill(self->ID, fill)) {
+ PyErr_Format(pygimp_error,
+ "could not fill drawable (ID %d) with fill mode %d",
+ self->ID, fill);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+drw_get_tile(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ GimpTile *t;
+ int shadow, row, col;
+
+ static char *kwlist[] = { "shadow", "row", "col", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:get_tile", kwlist,
+ &shadow, &row, &col))
+ return NULL;
+
+ ensure_drawable(self);
+
+ if(row < 0 || row >= self->drawable->ntile_rows ||
+ col < 0 || col >= self->drawable->ntile_cols) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ t = gimp_drawable_get_tile(self->drawable, shadow, row, col);
+ return pygimp_tile_new(t, self);
+}
+
+static PyObject *
+drw_get_tile2(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ GimpTile *t;
+ int shadow, x, y, row, col;
+
+ static char *kwlist[] = { "shadow", "x", "y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iii:get_tile2", kwlist,
+ &shadow, &x ,&y))
+ return NULL;
+
+ ensure_drawable(self);
+ if(x < 0 || x >= self->drawable->width ||
+ y < 0 || y >= self->drawable->height) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ col = x / gimp_tile_width ();
+ row = y / gimp_tile_height ();
+
+ t = gimp_drawable_get_tile(self->drawable, shadow, row, col);
+ return pygimp_tile_new(t, self);
+}
+
+static PyObject *
+drw_get_pixel_rgn(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int x, y, width, height, dirty = 1, shadow = 0;
+
+ static char *kwlist[] = { "x", "y", "width", "height", "dirty", "shadow",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "iiii|ii:get_pixel_rgn", kwlist,
+ &x, &y, &width, &height, &dirty, &shadow))
+ return NULL;
+
+ ensure_drawable(self);
+
+ return pygimp_pixel_rgn_new(self, x, y, width, height, dirty, shadow);
+}
+
+static PyObject *
+drw_offset(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int wrap_around;
+ GimpOffsetType fill_type;
+ int offset_x, offset_y;
+
+ static char *kwlist[] = { "wrap_around", "fill_type",
+ "offset_x", "offset_y",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iiii:offset", kwlist,
+ &wrap_around, &fill_type,
+ &offset_x, &offset_y))
+ return NULL;
+
+ if (!gimp_drawable_offset(self->ID, wrap_around, fill_type,
+ offset_x, offset_y)) {
+ PyErr_Format(pygimp_error,
+ "could not offset drawable (ID %d) by x: %d, y: %d",
+ self->ID, offset_x, offset_y);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_parasite_find(PyGimpDrawable *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
+ return NULL;
+
+ return pygimp_parasite_new(gimp_item_get_parasite(self->ID, name));
+}
+
+static PyObject *
+drw_parasite_attach(PyGimpDrawable *self, PyObject *args)
+{
+ PyGimpParasite *parasite;
+
+ if (!PyArg_ParseTuple(args, "O!:parasite_attach", &PyGimpParasite_Type,
+ &parasite))
+ return NULL;
+
+ if (!gimp_item_attach_parasite(self->ID, parasite->para)) {
+ PyErr_Format(pygimp_error,
+ "could not attach parasite '%s' on drawable (ID %d)",
+ gimp_parasite_name(parasite->para), self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_attach_new_parasite(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ char *name;
+ int flags, size;
+ guint8 *data;
+ GimpParasite *parasite;
+ gboolean success;
+
+ static char *kwlist[] = { "name", "flags", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "sis#:attach_new_parasite", kwlist,
+ &name, &flags, &data, &size))
+ return NULL;
+
+ parasite = gimp_parasite_new (name,
+ flags, size + 1, data);
+ success = gimp_item_attach_parasite (self->ID, parasite);
+ gimp_parasite_free (parasite);
+
+ if (!success) {
+ PyErr_Format(pygimp_error,
+ "could not attach new parasite '%s' to drawable (ID %d)",
+ name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_parasite_detach(PyGimpDrawable *self, PyObject *args)
+{
+ char *name;
+ if (!PyArg_ParseTuple(args, "s:detach_parasite", &name))
+ return NULL;
+
+ if (!gimp_item_detach_parasite(self->ID, name)) {
+ PyErr_Format(pygimp_error,
+ "could not detach parasite '%s' from drawable (ID %d)",
+ name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+drw_parasite_list(PyGimpDrawable *self)
+{
+ gint num_parasites;
+ gchar **parasites;
+ PyObject *ret;
+ gint i;
+
+ parasites = gimp_item_get_parasite_list(self->ID, &num_parasites);
+
+ ret = PyTuple_New(num_parasites);
+
+ for (i = 0; i < num_parasites; i++)
+ PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
+
+ g_strfreev(parasites);
+ return ret;
+}
+
+static PyObject *
+drw_get_pixel(PyGimpDrawable *self, PyObject *args)
+{
+ int x, y;
+ int num_channels, i;
+ guint8 *pixel;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, "(ii):get_pixel", &x, &y)) {
+ PyErr_Clear();
+ if (!PyArg_ParseTuple(args, "ii:get_pixel", &x, &y))
+ return NULL;
+ }
+
+ pixel = gimp_drawable_get_pixel(self->ID, x, y, &num_channels);
+
+ if (!pixel) {
+ PyErr_Format(pygimp_error,
+ "could not get pixel (%d, %d) on drawable (ID %d)",
+ x, y, self->ID);
+ return NULL;
+ }
+
+ ret = PyTuple_New(num_channels);
+
+ for (i = 0; i < num_channels; i++)
+ PyTuple_SetItem(ret, i, PyInt_FromLong(pixel[i]));
+
+ g_free(pixel);
+
+ return ret;
+}
+
+static PyObject *
+drw_set_pixel(PyGimpDrawable *self, PyObject *args)
+{
+ int x, y;
+ int num_channels, i, val;
+ guint8 *pixel;
+ PyObject *seq, *item;
+ gboolean is_string, error = TRUE;
+
+ if (!PyArg_ParseTuple(args, "(ii)O:set_pixel", &x, &y, &seq)) {
+ PyErr_Clear();
+ if (!PyArg_ParseTuple(args, "iiO:set_pixel", &x, &y, &seq))
+ return NULL;
+ }
+
+ if (!PyString_Check(seq)) {
+ if (!PySequence_Check(seq)) {
+ PyErr_SetString(PyExc_TypeError,
+ "pixel values must be a sequence");
+ return NULL;
+ }
+
+ is_string = FALSE;
+
+ num_channels = PySequence_Length(seq);
+ pixel = g_new(guint8, num_channels);
+
+ for (i = 0; i < num_channels; i++) {
+ item = PySequence_GetItem(seq, i);
+
+ if (!PyInt_Check(item)) {
+ PyErr_SetString(PyExc_TypeError,
+ "pixel values must be a sequence of ints");
+ goto out;
+ }
+
+ val = PyInt_AsLong(item);
+
+ if (val < 0 || val > 255) {
+ PyErr_SetString(PyExc_TypeError,
+ "pixel values must be between 0 and 255");
+ goto out;
+ }
+
+ pixel[i] = val;
+ }
+ } else {
+ is_string = TRUE;
+
+ num_channels = PyString_Size(seq);
+ pixel = (guint8 *)PyString_AsString(seq);
+ }
+
+ error = !gimp_drawable_set_pixel(self->ID, x, y, num_channels, pixel);
+
+ if (error)
+ PyErr_Format(pygimp_error,
+ "could not set %d-element pixel (%d, %d) on "
+ "drawable (ID %d)",
+ num_channels, x, y, self->ID);
+
+out:
+ if (!is_string)
+ g_free(pixel);
+
+ if (!error) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ } else
+ return NULL;
+}
+
+static PyObject *
+drw_mask_intersect(PyGimpDrawable *self)
+{
+ int x, y, width, height;
+
+ if (!gimp_drawable_mask_intersect(self->ID, &x, &y, &width, &height)) {
+ PyErr_Format(pygimp_error,
+ "could not get selection bounds of drawable (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ return Py_BuildValue("(iiii)", x, y, width, height);
+}
+
+static PyObject *
+transform_result(PyGimpDrawable *self, gint32 id, const char *err_desc)
+{
+ if (id == self->ID) {
+ Py_INCREF(self);
+ return (PyObject *)self;
+ } else if (id != -1) {
+ return pygimp_drawable_new(NULL, id);
+ } else {
+ PyErr_Format(pygimp_error, "could not %s drawable (ID %d)",
+ err_desc, self->ID);
+ return NULL;
+ }
+}
+
+static PyObject *
+drw_transform_flip(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1;
+ int transform_direction, interpolation, recursion_level = 3;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddddii|iii:transform_flip", kwlist,
+ &x0, &y0, &x1, &y1, &transform_direction,
+ &interpolation, &supersample,
+ &recursion_level, &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_flip (self->ID, x0, y0, x1, y1);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "flip");
+}
+
+static PyObject *
+drw_transform_flip_simple(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int flip_type;
+ gboolean auto_center, clip_result = FALSE;
+ double axis;
+ gint32 id;
+
+ static char *kwlist[] = { "flip_type", "auto_center", "axis",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "iid|i:transform_flip_simple", kwlist,
+ &flip_type, &auto_center, &axis,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_flip_simple (self->ID, flip_type,
+ auto_center, axis);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "flip");
+}
+
+static PyObject *
+drw_transform_flip_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", "interpolate",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddd|ii:transform_flip_default", kwlist,
+ &x0, &y0, &x1, &y1, &interpolate,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_flip (self->ID, x0, y0, x1, y1);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "flip");
+}
+
+static PyObject *
+drw_transform_perspective(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1, x2, y2, x3, y3;
+ int transform_direction, interpolation, recursion_level = 3;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", "x3", "y3",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddddddddii|iii:transform_perspective",
+ kwlist,
+ &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3,
+ &transform_direction, &interpolation,
+ &supersample, &recursion_level,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_perspective (self->ID,
+ x0, y0, x1, y1, x2, y2, x3, y3);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply perspective transform to");
+}
+
+static PyObject *
+drw_transform_perspective_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1, x2, y2, x3, y3;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", "x3", "y3",
+ "interpolate", "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddddddd|ii:transform_perspective_default",
+ kwlist,
+ &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3,
+ &interpolate, &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_perspective (self->ID,
+ x0, y0, x1, y1, x2, y2, x3, y3);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply perspective transform to");
+}
+
+static PyObject *
+drw_transform_rotate(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double angle;
+ gboolean auto_center, supersample = FALSE, clip_result = FALSE;
+ int center_x, center_y, transform_direction, interpolation,
+ recursion_level = 3;
+ gint32 id;
+
+ static char *kwlist[] = { "angle", "auto_center", "center_x", "center_y",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "diiiii|iii:transform_rotate", kwlist,
+ &angle, &auto_center, &center_x, &center_y,
+ &transform_direction, &interpolation,
+ &supersample, &recursion_level,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_rotate (self->ID, angle, auto_center,
+ center_x, center_y);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "rotate");
+}
+
+static PyObject *
+drw_transform_rotate_simple(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int rotate_type, center_x, center_y;
+ gboolean auto_center, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "rotate_type", "auto_center",
+ "center_x", "center_y",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "iiii|i:transform_rotate_simple", kwlist,
+ &rotate_type, &auto_center,
+ &center_x, &center_y,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_rotate_simple (self->ID, rotate_type,
+ auto_center,
+ center_x, center_y);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "rotate");
+}
+
+static PyObject *
+drw_transform_rotate_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double angle;
+ gboolean auto_center, interpolate = FALSE, clip_result = FALSE;
+ int center_x, center_y;
+ gint32 id;
+
+ static char *kwlist[] = { "angle", "auto_center", "center_x", "center_y",
+ "interpolate", "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddd|ii:transform_rotate_default", kwlist,
+ &angle, &auto_center, &center_x, &center_y,
+ &interpolate, &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_rotate (self->ID, angle, auto_center,
+ center_x, center_y);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "rotate");
+}
+
+static PyObject *
+drw_transform_scale(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1;
+ int transform_direction, interpolation, recursion_level = 3;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddddii|iii:transform_scale", kwlist,
+ &x0, &y0, &x1, &y1, &transform_direction,
+ &interpolation, &supersample,
+ &recursion_level, &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_scale (self->ID, x0, y0, x1, y1);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "scale");
+}
+
+static PyObject *
+drw_transform_scale_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", "interpolate",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddd|ii:transform_scale_default", kwlist,
+ &x0, &y0, &x1, &y1, &interpolate,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_scale (self->ID, x0, y0, x1, y1);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "scale");
+}
+
+static PyObject *
+drw_transform_shear(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int shear_type, transform_direction, interpolation, recursion_level = 3;
+ double magnitude;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "shear_type", "magnitude",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "idii|iii:transform_shear", kwlist,
+ &shear_type, &magnitude,
+ &transform_direction, &interpolation,
+ &supersample, &recursion_level,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_shear (self->ID, shear_type, magnitude);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "shear");
+}
+
+static PyObject *
+drw_transform_shear_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ int shear_type;
+ double magnitude;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "shear_type", "magnitude", "interpolate",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "id|ii:transform_shear_default", kwlist,
+ &shear_type, &magnitude, &interpolate,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_shear (self->ID, shear_type, magnitude);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "shear");
+}
+
+static PyObject *
+drw_transform_2d(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double source_x, source_y, scale_x, scale_y, angle, dest_x, dest_y;
+ int transform_direction, interpolation, recursion_level = 3;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "source_x", "source_y", "scale_x", "scale_y",
+ "angle", "dest_x", "dest_y",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddddddii|iii:transform_2d", kwlist,
+ &source_x, &source_y, &scale_x, &scale_y,
+ &angle, &dest_x, &dest_y,
+ &transform_direction, &interpolation,
+ &supersample, &recursion_level,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_2d (self->ID, source_x, source_y,
+ scale_x, scale_y, angle, dest_x, dest_y);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply 2d transform to");
+}
+
+static PyObject *
+drw_transform_2d_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double source_x, source_y, scale_x, scale_y, angle, dest_x, dest_y;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "source_x", "source_y", "scale_x", "scale_y",
+ "angle", "dest_x", "dest_y", "interpolate",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddddddd|ii:transform_2d_default", kwlist,
+ &source_x, &source_y, &scale_x, &scale_y,
+ &angle, &dest_x, &dest_y, &interpolate,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_2d (self->ID, source_x, source_y,
+ scale_x, scale_y, angle, dest_x, dest_y);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply 2d transform to");
+}
+
+static PyObject *
+drw_transform_matrix(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double coeff_0_0, coeff_0_1, coeff_0_2,
+ coeff_1_0, coeff_1_1, coeff_1_2,
+ coeff_2_0, coeff_2_1, coeff_2_2;
+ int transform_direction, interpolation, recursion_level = 3;
+ gboolean supersample = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "coeff_0_0", "coeff_0_1", "coeff_0_2",
+ "coeff_1_0", "coeff_1_1", "coeff_1_2",
+ "coeff_2_0", "coeff_2_1", "coeff_2_2",
+ "transform_direction", "interpolation",
+ "supersample", "recursion_level",
+ "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddddddddii|iii:transform_matrix", kwlist,
+ &coeff_0_0, &coeff_0_1, &coeff_0_2,
+ &coeff_1_0, &coeff_1_1, &coeff_1_2,
+ &coeff_2_0, &coeff_2_1, &coeff_2_2,
+ &transform_direction, &interpolation,
+ &supersample, &recursion_level,
+ &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ gimp_context_set_transform_direction (transform_direction);
+ gimp_context_set_interpolation (interpolation);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_matrix (self->ID,
+ coeff_0_0, coeff_0_1, coeff_0_2,
+ coeff_1_0, coeff_1_1, coeff_1_2,
+ coeff_2_0, coeff_2_1, coeff_2_2);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply 2d matrix transform to");
+}
+
+static PyObject *
+drw_transform_matrix_default(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ double coeff_0_0, coeff_0_1, coeff_0_2,
+ coeff_1_0, coeff_1_1, coeff_1_2,
+ coeff_2_0, coeff_2_1, coeff_2_2;
+ gboolean interpolate = FALSE, clip_result = FALSE;
+ gint32 id;
+
+ static char *kwlist[] = { "coeff_0_0", "coeff_0_1", "coeff_0_2",
+ "coeff_1_0", "coeff_1_1", "coeff_1_2",
+ "coeff_2_0", "coeff_2_1", "coeff_2_2",
+ "interpolate", "clip_result", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ddddddddd|ii:transform_matrix_default",
+ kwlist,
+ &coeff_0_0, &coeff_0_1, &coeff_0_2,
+ &coeff_1_0, &coeff_1_1, &coeff_1_2,
+ &coeff_2_0, &coeff_2_1, &coeff_2_2,
+ &interpolate, &clip_result))
+ return NULL;
+
+ gimp_context_push ();
+ if (! interpolate)
+ gimp_context_set_interpolation (GIMP_INTERPOLATION_NONE);
+ gimp_context_set_transform_resize (clip_result);
+
+ id = gimp_item_transform_matrix (self->ID,
+ coeff_0_0, coeff_0_1, coeff_0_2,
+ coeff_1_0, coeff_1_1, coeff_1_2,
+ coeff_2_0, coeff_2_1, coeff_2_2);
+
+ gimp_context_pop ();
+
+ return transform_result(self, id, "apply 2d matrix transform to");
+}
+
+static PyObject *
+drw_get_data(PyGimpDrawable *self, PyObject *args, PyObject *kwargs)
+{
+ static char *kwlist[] = { "format", NULL };
+ gchar *format = "RGBA float";
+ const Babl *bbl_format;
+ void *output_buffer;
+ GeglBuffer *buffer;
+ int bpp;
+ Py_ssize_t size;
+ PyObject *buffer_data, *ret;
+ PyObject *array_module;
+ PyObject *array_type;
+ char array_data_type;
+
+ if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+ "|s:get_data",
+ kwlist, &format
+ ))
+ return NULL;
+
+ if (g_str_has_suffix (format, "double")) {
+ array_data_type = 'd';
+ } else if (g_str_has_suffix (format, "float")) {
+ array_data_type = 'f';
+ }
+ else if (g_str_has_suffix (format, "u16")) {
+ array_data_type = 'H';
+ } else if (g_str_has_suffix (format, "u8")) {
+ array_data_type = 'B';
+ } else {
+ PyErr_Warn (PyExc_Warning,
+ "Could not find appropriate data format - returning raw bytes");
+ array_data_type = 'B';
+ }
+
+ bbl_format = babl_format (format);
+ bpp = babl_format_get_bytes_per_pixel (bbl_format);
+ ensure_drawable(self);
+ buffer = gimp_drawable_get_buffer (self->ID);
+ size = bpp * self->drawable->width * self->drawable->height;
+ output_buffer = g_malloc ((gsize) size);
+ if (output_buffer == NULL) {
+ return PyErr_NoMemory();
+ }
+ gegl_buffer_get (buffer,
+ GEGL_RECTANGLE (0, 0, self->drawable->width, self->drawable->height),
+ 1.0,
+ bbl_format,
+ output_buffer,
+ GEGL_AUTO_ROWSTRIDE,
+ GEGL_ABYSS_NONE);
+ buffer_data = PyString_FromStringAndSize (output_buffer, size);
+
+ array_module = PyImport_ImportModule ("array");
+ if (!array_module) {
+ PyErr_SetString (pygimp_error, "could not import array module");
+ return NULL;
+ }
+
+ array_type = PyObject_GetAttrString (array_module, "array");
+ Py_DECREF(array_module);
+ if (!array_type) {
+ PyErr_SetString (pygimp_error, "could not get array.array type");
+ return NULL;
+ }
+
+ ret = PyObject_CallFunction (array_type, "cO", array_data_type, buffer_data);
+ if (!ret) {
+ PyErr_SetString (pygimp_error, "could not create array object");
+ return NULL;
+ }
+
+ Py_DECREF (buffer_data);
+ g_free (output_buffer);
+
+ return ret;
+}
+
+
+/* for inclusion with the methods of layer and channel objects */
+static PyMethodDef drw_methods[] = {
+ {"flush", (PyCFunction)drw_flush, METH_NOARGS},
+ {"update", (PyCFunction)drw_update, METH_VARARGS},
+ {"merge_shadow", (PyCFunction)drw_merge_shadow, METH_VARARGS | METH_KEYWORDS},
+ {"free_shadow", (PyCFunction)drw_free_shadow, METH_NOARGS},
+ {"fill", (PyCFunction)drw_fill, METH_VARARGS | METH_KEYWORDS},
+ {"get_tile", (PyCFunction)drw_get_tile, METH_VARARGS | METH_KEYWORDS},
+ {"get_tile2", (PyCFunction)drw_get_tile2, METH_VARARGS | METH_KEYWORDS},
+ {"get_pixel_rgn", (PyCFunction)drw_get_pixel_rgn, METH_VARARGS | METH_KEYWORDS},
+ {"get_data", (PyCFunction)drw_get_data, METH_VARARGS | METH_KEYWORDS,
+ "Takes a BABL format string, returns a Python array.array object"},
+ {"offset", (PyCFunction)drw_offset, METH_VARARGS | METH_KEYWORDS},
+ {"parasite_find", (PyCFunction)drw_parasite_find, METH_VARARGS},
+ {"parasite_attach", (PyCFunction)drw_parasite_attach, METH_VARARGS},
+ {"attach_new_parasite",(PyCFunction)drw_attach_new_parasite,METH_VARARGS | METH_KEYWORDS},
+ {"parasite_detach", (PyCFunction)drw_parasite_detach, METH_VARARGS},
+ {"parasite_list", (PyCFunction)drw_parasite_list, METH_VARARGS},
+ {"get_pixel", (PyCFunction)drw_get_pixel, METH_VARARGS},
+ {"set_pixel", (PyCFunction)drw_set_pixel, METH_VARARGS},
+ {"mask_intersect", (PyCFunction)drw_mask_intersect, METH_NOARGS},
+ {"transform_flip", (PyCFunction)drw_transform_flip, METH_VARARGS | METH_KEYWORDS},
+ {"transform_flip_simple", (PyCFunction)drw_transform_flip_simple, METH_VARARGS | METH_KEYWORDS},
+ {"transform_flip_default", (PyCFunction)drw_transform_flip_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_perspective", (PyCFunction)drw_transform_perspective, METH_VARARGS | METH_KEYWORDS},
+ {"transform_perspective_default", (PyCFunction)drw_transform_perspective_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_rotate", (PyCFunction)drw_transform_rotate, METH_VARARGS | METH_KEYWORDS},
+ {"transform_rotate_simple", (PyCFunction)drw_transform_rotate_simple, METH_VARARGS | METH_KEYWORDS},
+ {"transform_rotate_default", (PyCFunction)drw_transform_rotate_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_scale", (PyCFunction)drw_transform_scale, METH_VARARGS | METH_KEYWORDS},
+ {"transform_scale_default", (PyCFunction)drw_transform_scale_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_shear", (PyCFunction)drw_transform_shear, METH_VARARGS | METH_KEYWORDS},
+ {"transform_shear_default", (PyCFunction)drw_transform_shear_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_2d", (PyCFunction)drw_transform_2d, METH_VARARGS | METH_KEYWORDS},
+ {"transform_2d_default", (PyCFunction)drw_transform_2d_default, METH_VARARGS | METH_KEYWORDS},
+ {"transform_matrix", (PyCFunction)drw_transform_matrix, METH_VARARGS | METH_KEYWORDS},
+ {"transform_matrix_default", (PyCFunction)drw_transform_matrix_default, METH_VARARGS | METH_KEYWORDS},
+ {NULL, NULL, 0}
+};
+
+static PyObject *
+drw_get_ID(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(self->ID);
+}
+
+static PyObject *
+drw_get_name(PyGimpDrawable *self, void *closure)
+{
+ return PyString_FromString(gimp_item_get_name(self->ID));
+}
+
+static int
+drw_set_name(PyGimpDrawable *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete name");
+ return -1;
+ }
+
+ if (!PyString_Check(value) && !PyUnicode_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_name(self->ID, PyString_AsString(value));
+
+ return 0;
+}
+
+static PyObject *
+drw_get_bpp(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_drawable_bpp(self->ID));
+}
+
+static PyObject *
+drw_get_has_alpha(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_drawable_has_alpha(self->ID));
+}
+
+static PyObject *
+drw_get_height(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_drawable_height(self->ID));
+}
+
+static PyObject *
+drw_get_image(PyGimpDrawable *self, void *closure)
+{
+ return pygimp_image_new(gimp_item_get_image(self->ID));
+}
+
+static PyObject *
+drw_get_is_rgb(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_drawable_is_rgb(self->ID));
+}
+
+static PyObject *
+drw_get_is_gray(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_drawable_is_gray(self->ID));
+}
+
+static PyObject *
+drw_get_is_indexed(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_drawable_is_indexed(self->ID));
+}
+
+static PyObject *
+drw_get_is_layer_mask(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_item_is_layer_mask(self->ID));
+}
+
+static PyObject *
+drw_get_mask_bounds(PyGimpDrawable *self, void *closure)
+{
+ gint x1, y1, x2, y2;
+
+ gimp_drawable_mask_bounds(self->ID, &x1, &y1, &x2, &y2);
+ return Py_BuildValue("(iiii)", x1, y1, x2, y2);
+}
+
+static PyObject *
+drw_get_mask_intersect(PyGimpDrawable *self, void *closure)
+{
+ gint x, y, w, h;
+
+ if(!gimp_drawable_mask_intersect(self->ID, &x, &y, &w, &h))
+ return Py_BuildValue("");
+ return Py_BuildValue("(iiii)", x, y, w, h);
+}
+
+static PyObject *
+drw_get_offsets(PyGimpDrawable *self, void *closure)
+{
+ gint x, y;
+
+ gimp_drawable_offsets(self->ID, &x, &y);
+
+ return Py_BuildValue("(ii)", x, y);
+}
+
+static PyObject *
+drw_get_type(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_drawable_type(self->ID));
+}
+
+static PyObject *
+drw_get_type_with_alpha(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_drawable_type_with_alpha(self->ID));
+}
+
+static PyObject *
+drw_get_width(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_drawable_width(self->ID));
+}
+
+static PyObject *
+drw_get_linked(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_item_get_linked(self->ID));
+}
+
+static int
+drw_set_linked(PyGimpDrawable *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete linked");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_linked(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+drw_get_tattoo(PyGimpDrawable *self, void *closure)
+{
+ return PyInt_FromLong(gimp_item_get_tattoo(self->ID));
+}
+
+static int
+drw_set_tattoo(PyGimpDrawable *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete tattoo");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_tattoo(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+drw_get_visible(PyGimpDrawable *self, void *closure)
+{
+ return PyBool_FromLong(gimp_item_get_visible(self->ID));
+}
+
+static int
+drw_set_visible(PyGimpDrawable *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete visible");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_visible(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyGetSetDef drw_getsets[] = {
+ { "ID", (getter)drw_get_ID, (setter)0 },
+ { "name", (getter)drw_get_name, (setter)drw_set_name },
+ { "bpp", (getter)drw_get_bpp, (setter)0 },
+ { "has_alpha", (getter)drw_get_has_alpha, (setter)0 },
+ { "height", (getter)drw_get_height, (setter)0 },
+ { "image", (getter)drw_get_image, (setter)0 },
+ { "is_rgb", (getter)drw_get_is_rgb, (setter)0 },
+ { "is_gray", (getter)drw_get_is_gray, (setter)0 },
+ { "is_grey", (getter)drw_get_is_gray, (setter)0 },
+ { "is_indexed", (getter)drw_get_is_indexed, (setter)0 },
+ { "is_layer_mask", (getter)drw_get_is_layer_mask, (setter)0 },
+ { "mask_bounds", (getter)drw_get_mask_bounds, (setter)0 },
+ { "mask_intersect", (getter)drw_get_mask_intersect, (setter)0 },
+ { "offsets", (getter)drw_get_offsets, (setter)0 },
+ { "type", (getter)drw_get_type, (setter)0 },
+ { "type_with_alpha", (getter)drw_get_type_with_alpha, (setter)0 },
+ { "width", (getter)drw_get_width, (setter)0 },
+ { "linked", (getter)drw_get_linked, (setter)drw_set_linked },
+ { "tattoo", (getter)drw_get_tattoo, (setter)drw_set_tattoo },
+ { "visible", (getter)drw_get_visible, (setter)drw_set_visible },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static void
+drw_dealloc(PyGimpDrawable *self)
+{
+ if (self->drawable)
+ gimp_drawable_detach(self->drawable);
+
+ PyObject_DEL(self);
+}
+
+static PyObject *
+drw_repr(PyGimpDrawable *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.Drawable '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+drw_cmp(PyGimpDrawable *self, PyGimpDrawable *other)
+{
+ if (self->ID == other->ID)
+ return 0;
+ if (self->ID > other->ID)
+ return -1;
+ return 1;
+}
+
+PyTypeObject PyGimpDrawable_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Drawable", /* tp_name */
+ sizeof(PyGimpDrawable), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)drw_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)drw_cmp, /* tp_compare */
+ (reprfunc)drw_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ drw_methods, /* tp_methods */
+ 0, /* tp_members */
+ drw_getsets, /* tp_getset */
+ &PyGimpItem_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+
+PyObject *
+pygimp_drawable_new(GimpDrawable *drawable, gint32 ID)
+{
+ PyObject *self;
+
+ if (drawable != NULL)
+ ID = drawable->drawable_id;
+
+ if (!gimp_item_is_valid(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ /* create the appropriate object type */
+ if (gimp_item_is_layer(ID))
+ self = pygimp_layer_new(ID);
+ else
+ self = pygimp_channel_new(ID);
+
+ if (self == NULL)
+ return NULL;
+
+ if (PyObject_TypeCheck(self, &PyGimpDrawable_Type))
+ ((PyGimpDrawable *)self)->drawable = drawable;
+
+ return self;
+}
+
+/* End of code for Drawable objects */
+/* -------------------------------------------------------- */
+
+
+static PyObject *
+lay_copy(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ int nreturn_vals;
+ GimpParam *return_vals;
+ gboolean add_alpha = FALSE;
+ gint32 id = -1;
+
+ static char *kwlist[] = { "add_alpha", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:copy", kwlist,
+ &add_alpha))
+ return NULL;
+
+ return_vals = gimp_run_procedure("gimp-layer-copy",
+ &nreturn_vals,
+ GIMP_PDB_LAYER, self->ID,
+ GIMP_PDB_INT32, add_alpha,
+ GIMP_PDB_END);
+
+ if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+ id = return_vals[1].data.d_layer;
+ else
+ PyErr_Format(pygimp_error,
+ "could not create new layer copy from layer (ID %d)",
+ self->ID);
+
+ gimp_destroy_params(return_vals, nreturn_vals);
+
+ return id != -1 ? pygimp_layer_new(id) : NULL;
+}
+
+
+static PyObject *
+lay_add_alpha(PyGimpLayer *self)
+{
+ if (!gimp_layer_add_alpha(self->ID)) {
+ PyErr_Format(pygimp_error, "could not add alpha to layer (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+lay_add_mask(PyGimpLayer *self, PyObject *args)
+{
+ PyGimpChannel *mask;
+
+ if (!PyArg_ParseTuple(args, "O!:add_mask", &PyGimpChannel_Type, &mask))
+ return NULL;
+
+ if (!gimp_layer_add_mask(self->ID, mask->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not add mask (ID %d) to layer (ID %d)",
+ mask->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+lay_create_mask(PyGimpLayer *self, PyObject *args)
+{
+ int type;
+ gint32 id;
+
+ if (!PyArg_ParseTuple(args, "i:create_mask", &type))
+ return NULL;
+
+ id = gimp_layer_create_mask(self->ID, type);
+
+ if (id == -1) {
+ PyErr_Format(pygimp_error,
+ "could not create mask of type %d on layer (ID %d)",
+ type, self->ID);
+ return NULL;
+ }
+
+ return pygimp_channel_new(id);
+}
+
+static PyObject *
+lay_remove_mask(PyGimpLayer *self, PyObject *args)
+{
+ int mode;
+
+ if (!PyArg_ParseTuple(args, "i:remove_mask", &mode))
+ return NULL;
+
+ if (!gimp_layer_remove_mask(self->ID, mode)) {
+ PyErr_Format(pygimp_error,
+ "could not remove mask from layer (ID %d) with mode %d",
+ self->ID, mode);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+lay_resize(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ unsigned int new_h, new_w;
+ int offs_x = 0, offs_y = 0;
+
+ static char *kwlist[] = { "width", "height", "offset_x", "offset_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:resize", kwlist,
+ &new_w, &new_h, &offs_x, &offs_y))
+ return NULL;
+
+ if (!gimp_layer_resize(self->ID, new_w, new_h, offs_x, offs_y)) {
+ PyErr_Format(pygimp_error,
+ "could not resize layer (ID %d) to size %dx%d "
+ "(offset %d, %d)",
+ self->ID, new_w, new_h, offs_x, offs_y);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+lay_resize_to_image_size(PyGimpLayer *self)
+{
+ if (!gimp_layer_resize_to_image_size(self->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not resize layer (ID %d) to image size",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+lay_scale(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ int new_width, new_height;
+ int interpolation = -1;
+ gboolean local_origin = FALSE;
+
+ static char *kwlist[] = { "width", "height", "local_origin",
+ "interpolation", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:scale", kwlist,
+ &new_width, &new_height,
+ &local_origin, &interpolation))
+ return NULL;
+
+ if (interpolation != -1) {
+ gimp_context_push();
+ gimp_context_set_interpolation(interpolation);
+ }
+
+ if (!gimp_layer_scale(self->ID, new_width, new_height, local_origin)) {
+ PyErr_Format(pygimp_error,
+ "could not scale layer (ID %d) to size %dx%d",
+ self->ID, new_width, new_height);
+ if (interpolation != -1) {
+ gimp_context_pop();
+ }
+ return NULL;
+ }
+
+ if (interpolation != -1) {
+ gimp_context_pop();
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+lay_translate(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ int offs_x, offs_y;
+
+ static char *kwlist[] = { "offset_x", "offset_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:translate", kwlist,
+ &offs_x, &offs_y))
+ return NULL;
+
+ if (!gimp_item_transform_translate(self->ID, offs_x, offs_y)) {
+ PyErr_Format(pygimp_error,
+ "could not translate layer (ID %d) to offset %d, %d",
+ self->ID, offs_x, offs_y);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+lay_set_offsets(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ int offs_x, offs_y;
+
+ static char *kwlist[] = { "offset_x", "offset_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_offsets", kwlist,
+ &offs_x, &offs_y))
+ return NULL;
+
+ if (!gimp_layer_set_offsets(self->ID, offs_x, offs_y)) {
+ PyErr_Format(pygimp_error,
+ "could not set offset %d, %d on layer (ID %d)",
+ offs_x, offs_y, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef lay_methods[] = {
+ {"copy", (PyCFunction)lay_copy, METH_VARARGS | METH_KEYWORDS},
+ {"add_alpha", (PyCFunction)lay_add_alpha, METH_NOARGS},
+ {"add_mask", (PyCFunction)lay_add_mask, METH_VARARGS},
+ {"create_mask", (PyCFunction)lay_create_mask, METH_VARARGS},
+ {"remove_mask", (PyCFunction)lay_remove_mask, METH_VARARGS},
+ {"resize", (PyCFunction)lay_resize, METH_VARARGS | METH_KEYWORDS},
+ {"resize_to_image_size", (PyCFunction)lay_resize_to_image_size, METH_NOARGS},
+ {"scale", (PyCFunction)lay_scale, METH_VARARGS | METH_KEYWORDS},
+ {"translate", (PyCFunction)lay_translate, METH_VARARGS | METH_KEYWORDS},
+ {"set_offsets", (PyCFunction)lay_set_offsets, METH_VARARGS | METH_KEYWORDS},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+lay_get_is_floating_sel(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_layer_is_floating_sel(self->ID));
+}
+
+static PyObject *
+lay_get_mask(PyGimpLayer *self, void *closure)
+{
+ gint32 id = gimp_layer_get_mask(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_channel_new(id);
+}
+
+static PyObject *
+lay_get_apply_mask(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_layer_get_apply_mask(self->ID));
+}
+
+static int
+lay_set_apply_mask(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete apply_mask");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_apply_mask(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set layer mask on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_edit_mask(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_layer_get_edit_mask(self->ID));
+}
+
+static int
+lay_set_edit_mask(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete edit_mask");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_edit_mask(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set layer mask active on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_mode(PyGimpLayer *self, void *closure)
+{
+ return PyInt_FromLong(gimp_layer_get_mode(self->ID));
+}
+
+static int
+lay_set_mode(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete mode");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_mode(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error, "could not set mode on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_opacity(PyGimpLayer *self, void *closure)
+{
+ return PyFloat_FromDouble(gimp_layer_get_opacity(self->ID));
+}
+
+static int
+lay_set_opacity(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete opacity");
+ return -1;
+ }
+
+ if (!PyFloat_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_opacity(self->ID, PyFloat_AsDouble(value))) {
+ PyErr_Format(pygimp_error, "could not set opacity on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_lock_alpha(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_layer_get_lock_alpha(self->ID));
+}
+
+static int
+lay_set_lock_alpha(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "cannot delete lock_alpha");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_lock_alpha(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set lock alpha setting on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_show_mask(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_layer_get_show_mask(self->ID));
+}
+
+static int
+lay_set_show_mask(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete show_mask");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_layer_set_show_mask(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set mask visibility on layer (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+lay_get_preserve_trans(PyGimpLayer *self, void *closure)
+{
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use lock_alpha attribute") < 0)
+ return NULL;
+
+ return lay_get_lock_alpha(self, closure);
+}
+
+static int
+lay_set_preserve_trans(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (PyErr_Warn(PyExc_DeprecationWarning, "use lock_alpha attribute") < 0)
+ return -1;
+
+ return lay_set_lock_alpha(self, value, closure);
+}
+
+static PyGetSetDef lay_getsets[] = {
+ { "is_floating_sel", (getter)lay_get_is_floating_sel, (setter)0 },
+ { "mask", (getter)lay_get_mask, (setter)0 },
+ { "apply_mask", (getter)lay_get_apply_mask, (setter)lay_set_apply_mask },
+ { "edit_mask", (getter)lay_get_edit_mask, (setter)lay_set_edit_mask },
+ { "mode", (getter)lay_get_mode, (setter)lay_set_mode },
+ { "opacity", (getter)lay_get_opacity, (setter)lay_set_opacity },
+ { "lock_alpha", (getter)lay_get_lock_alpha, (setter)lay_set_lock_alpha },
+ { "show_mask", (getter)lay_get_show_mask, (setter)lay_set_show_mask },
+ { "preserve_trans", (getter)lay_get_preserve_trans,
+ (setter)lay_set_preserve_trans },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static PyObject *
+lay_repr(PyGimpLayer *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.Layer '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+lay_init(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ char *name;
+ unsigned int width, height;
+ GimpImageType type = GIMP_RGB_IMAGE;
+ double opacity = 100.0;
+ GimpLayerMode mode = GIMP_LAYER_MODE_NORMAL;
+
+
+ if (!PyArg_ParseTuple(args, "O!sii|idi:gimp.Layer.__init__",
+ &PyGimpImage_Type, &img, &name, &width, &height,
+ &type, &opacity, &mode))
+ return -1;
+
+ self->ID = gimp_layer_new(img->ID, name, width, height,
+ type, opacity, mode);
+
+ self->drawable = NULL;
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error,
+ "could not create %dx%d layer '%s' of type %d on "
+ "image (ID %d)",
+ width, height, name, type, img->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+PyTypeObject PyGimpLayer_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Layer", /* tp_name */
+ sizeof(PyGimpLayer), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)drw_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)drw_cmp, /* tp_compare */
+ (reprfunc)lay_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ lay_methods, /* tp_methods */
+ 0, /* tp_members */
+ lay_getsets, /* tp_getset */
+ &PyGimpDrawable_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)lay_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_layer_new(gint32 ID)
+{
+ PyGimpLayer *self;
+
+ if (!gimp_item_is_valid(ID) || !gimp_item_is_layer(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+
+ if (gimp_item_is_group(ID)) {
+ self = PyObject_NEW(PyGimpGroupLayer, &PyGimpGroupLayer_Type);
+ }
+ else {
+ self = PyObject_NEW(PyGimpLayer, &PyGimpLayer_Type);
+ }
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+ self->drawable = NULL;
+
+ return (PyObject *)self;
+}
+
+/* End of code for Layer objects */
+/* -------------------------------------------------------- */
+
+/* Since this help will primarily be seen from within
+ * GIMP's Python console, we should make it fit in that
+ * window's default size.
+ */
+
+#define GROUPLAYER_DOC "" \
+"gimp.GroupLayer(img, name="", opacity=100.0, " \
+"mode=gimp.LAYER_MODE_NORMAL)\n" \
+"\n" \
+" Creates a new GroupLayer object that has to be \n" \
+"subsequently added to an image. Use Image.add_layer \n" \
+"or pdb.gimp_image_insert_layer calls to do that. \n" \
+
+static PyMethodDef grouplay_methods[] = {
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+grouplay_get_layers(PyGimpGroupLayer *self, void *closure)
+{
+ gint32 *layers;
+ gint n_layers, i;
+ PyObject *ret;
+
+ layers = gimp_item_get_children(self->ID, &n_layers);
+
+ ret = PyList_New(n_layers);
+
+ for (i = 0; i < n_layers; i++)
+ PyList_SetItem(ret, i, pygimp_group_layer_new(layers[i]));
+
+ g_free(layers);
+
+ return ret;
+}
+
+static PyGetSetDef grouplay_getsets[] = {
+ { "layers", (getter)grouplay_get_layers, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static PyObject *
+grouplay_repr(PyGimpLayer *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.GroupLayer '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+grouplay_init(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ char *name = "Layer Group";
+ GimpImageType type = GIMP_RGB_IMAGE;
+ double opacity = 100.0;
+ GimpLayerMode mode = GIMP_LAYER_MODE_NORMAL;
+
+
+ if (!PyArg_ParseTuple(args, "O!|sdi:gimp.Layer.__init__",
+ &PyGimpImage_Type, &img, &name,
+ &opacity, &mode))
+ return -1;
+
+ self->ID = gimp_layer_group_new(img->ID);
+
+ self->drawable = NULL;
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error,
+ "could not create layer group '%s' of type %d on "
+ "image (ID %d)",
+ name, type, img->ID);
+ return -1;
+ }
+
+ gimp_layer_set_opacity(self->ID, opacity);
+ gimp_layer_set_mode(self->ID, mode);
+
+ gimp_item_set_name(self->ID, name);
+
+ return 0;
+}
+
+PyTypeObject PyGimpGroupLayer_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.GroupLayer", /* tp_name */
+ sizeof(PyGimpGroupLayer), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)drw_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)drw_cmp, /* tp_compare */
+ (reprfunc)grouplay_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ GROUPLAYER_DOC, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ grouplay_methods, /* tp_methods */
+ 0, /* tp_members */
+ grouplay_getsets, /* tp_getset */
+ &PyGimpLayer_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)grouplay_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_group_layer_new(gint32 ID)
+{
+ PyGimpGroupLayer *self;
+
+ if (!gimp_item_is_valid(ID) || !gimp_item_is_layer(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ if (!gimp_item_is_group(ID)) {
+ return pygimp_layer_new(ID);
+ }
+
+ self = PyObject_NEW(PyGimpGroupLayer, &PyGimpGroupLayer_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+ self->drawable = NULL;
+
+ return (PyObject *)self;
+}
+
+/* End of code for GroupLayer objects */
+/* -------------------------------------------------------- */
+
+
+static PyObject *
+chn_copy(PyGimpChannel *self)
+{
+ gint32 id;
+
+ id = gimp_channel_copy(self->ID);
+
+ if (id == -1) {
+ PyErr_Format(pygimp_error,
+ "could not create new channel copy from channel (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ return pygimp_channel_new(id);
+}
+
+static PyObject *
+chn_combine_masks(PyGimpChannel *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpChannel *channel2;
+ GimpChannelOps operation;
+ int offx = 0, offy = 0;
+
+ static char *kwlist[] = { "channel", "operation", "offset_x", "offset_y",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!i|ii:combine_masks",
+ kwlist,
+ &PyGimpChannel_Type, &channel2,
+ &operation, &offx, &offy))
+ return NULL;
+
+ if (!gimp_channel_combine_masks(self->ID, channel2->ID, operation,
+ offx, offy)) {
+ PyErr_Format(pygimp_error,
+ "could not combine masks with channels (ID %d and ID %d) "
+ "with operation %d, offset %d, %d",
+ self->ID, channel2->ID, operation, offx, offy);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef chn_methods[] = {
+ {"copy", (PyCFunction)chn_copy, METH_NOARGS},
+ {"combine_masks", (PyCFunction)chn_combine_masks, METH_VARARGS},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+chn_get_color(PyGimpChannel *self, void *closure)
+{
+ GimpRGB rgb;
+
+ if (!gimp_channel_get_color(self->ID, &rgb)) {
+ PyErr_Format(pygimp_error,
+ "could not get compositing color of channel (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ return pygimp_rgb_new(&rgb);
+}
+
+static int
+chn_set_color(PyGimpChannel *self, PyObject *value, void *closure)
+{
+ guchar r, g, b;
+ GimpRGB tmprgb, *rgb;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete color");
+ return -1;
+ }
+
+ if (pygimp_rgb_check(value)) {
+ rgb = pyg_boxed_get(value, GimpRGB);
+ } else if (PyTuple_Check(value) &&
+ PyArg_ParseTuple(value, "(BBB)", &r, &g, &b)) {
+ gimp_rgb_set_uchar(&tmprgb, r, g, b);
+ rgb = &tmprgb;
+ } else {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_channel_set_color(self->ID, rgb)) {
+ PyErr_Format(pygimp_error,
+ "could not set compositing color on channel (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+chn_get_opacity(PyGimpLayer *self, void *closure)
+{
+ return PyFloat_FromDouble(gimp_channel_get_opacity(self->ID));
+}
+
+static int
+chn_set_opacity(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete opacity");
+ return -1;
+ }
+
+ if (!PyFloat_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_channel_set_opacity(self->ID, PyFloat_AsDouble(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set opacity on channel (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+chn_get_show_masked(PyGimpLayer *self, void *closure)
+{
+ return PyBool_FromLong(gimp_channel_get_show_masked(self->ID));
+}
+
+static int
+chn_set_show_masked(PyGimpLayer *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete show_masked");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_channel_set_show_masked(self->ID, PyInt_AsLong(value))) {
+ PyErr_Format(pygimp_error,
+ "could not set composite method on channel (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyGetSetDef chn_getsets[] = {
+ { "color", (getter)chn_get_color, (setter)chn_set_color },
+ { "colour", (getter)chn_get_color, (setter)chn_set_color },
+ { "opacity", (getter)chn_get_opacity, (setter)chn_set_opacity },
+ { "show_masked", (getter)chn_get_show_masked, (setter)chn_set_show_masked},
+ { NULL, (getter)0, (setter)0 }
+};
+
+static PyObject *
+chn_repr(PyGimpChannel *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.Channel '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+chn_init(PyGimpChannel *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ PyObject *color;
+ char *name;
+ unsigned int width, height, r, g, b;
+ double opacity;
+ GimpRGB tmprgb, *rgb;
+
+ if (!PyArg_ParseTuple(args, "O!siidO:gimp.Channel.__init__",
+ &PyGimpImage_Type, &img, &name, &width,
+ &height, &opacity, &color))
+ return -1;
+
+ if (pygimp_rgb_check(color)) {
+ rgb = pyg_boxed_get(color, GimpRGB);
+ } else if (PyTuple_Check(color) &&
+ PyArg_ParseTuple(color, "(BBB)", &r, &g, &b)) {
+ gimp_rgb_set_uchar(&tmprgb, r, g, b);
+ rgb = &tmprgb;
+ } else {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ self->ID = gimp_channel_new(img->ID, name, width, height, opacity, rgb);
+
+ self->drawable = NULL;
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error,
+ "could not create %dx%d channel '%s' on image (ID %d)",
+ width, height, name, img->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+PyTypeObject PyGimpChannel_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Channel", /* tp_name */
+ sizeof(PyGimpChannel), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)drw_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)drw_cmp, /* tp_compare */
+ (reprfunc)chn_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ chn_methods, /* tp_methods */
+ 0, /* tp_members */
+ chn_getsets, /* tp_getset */
+ &PyGimpDrawable_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)chn_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_channel_new(gint32 ID)
+{
+ PyGimpChannel *self;
+
+ if (!gimp_item_is_valid(ID) || !gimp_item_is_channel(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ self = PyObject_NEW(PyGimpChannel, &PyGimpChannel_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+ self->drawable = NULL;
+
+ return (PyObject *)self;
+}
diff --git a/plug-ins/pygimp/pygimp-image.c b/plug-ins/pygimp/pygimp-image.c
new file mode 100644
index 0000000..d8c0cbf
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-image.c
@@ -0,0 +1,1564 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pygimp.h"
+
+static PyObject *
+img_add_channel(PyGimpImage *self, PyObject *args)
+{
+ PyGimpChannel *chn;
+ int pos = -1;
+
+ if (!PyArg_ParseTuple(args, "O!|i:add_channel",
+ &PyGimpChannel_Type, &chn, &pos))
+ return NULL;
+
+ if (!gimp_image_insert_channel(self->ID, chn->ID, -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not add channel (ID %d) to image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_insert_channel(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpChannel *chn;
+ PyGimpChannel *parent = NULL;
+ int pos = -1;
+
+ static char *kwlist[] = { "channel", "parent", "position", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!i:insert_channel", kwlist,
+ &PyGimpChannel_Type, &chn,
+ &PyGimpChannel_Type, &parent,
+ &pos))
+ return NULL;
+
+ if (!gimp_image_insert_channel(self->ID,
+ chn->ID, parent ? parent->ID : -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not insert channel (ID %d) to image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_add_layer(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+ int pos = -1;
+
+ if (!PyArg_ParseTuple(args, "O!|i:add_layer", &PyGimpLayer_Type, &lay,
+ &pos))
+ return NULL;
+
+ if (!gimp_image_insert_layer(self->ID, lay->ID, -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not add layer (ID %d) to image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_insert_layer(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpLayer *lay;
+ PyGimpLayer *parent = NULL;
+ int pos = -1;
+
+ static char *kwlist[] = { "layer", "parent", "position", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!i:insert_layer", kwlist,
+ &PyGimpLayer_Type, &lay,
+ &PyGimpLayer_Type, &parent,
+ &pos))
+ return NULL;
+
+ if (!gimp_image_insert_layer(self->ID,
+ lay->ID, parent ? parent->ID : -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not insert layer (ID %d) to image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_new_layer(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ char *layer_name;
+ int layer_id;
+ int width, height;
+ int layer_type;
+ int offs_x = 0, offs_y = 0;
+ gboolean alpha = TRUE;
+ int pos = -1;
+ double opacity = 100.0;
+ GimpLayerMode mode = GIMP_LAYER_MODE_NORMAL;
+ GimpFillType fill_mode = -1;
+
+ static char *kwlist[] = { "name", "width", "height", "offset_x", "offset_y",
+ "alpha", "pos", "opacity", "mode", "fill_mode",
+ NULL };
+
+ layer_name = "New Layer";
+
+ width = gimp_image_width(self->ID);
+ height = gimp_image_height(self->ID);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|siiiiiidii:new_layer", kwlist,
+ &layer_name, &width, &height,
+ &offs_x, &offs_y, &alpha, &pos,
+ &opacity, &mode, &fill_mode))
+ return NULL;
+
+
+ switch (gimp_image_base_type(self->ID)) {
+ case GIMP_RGB:
+ layer_type = alpha ? GIMP_RGBA_IMAGE: GIMP_RGB_IMAGE;
+ break;
+ case GIMP_GRAY:
+ layer_type = alpha ? GIMP_GRAYA_IMAGE: GIMP_GRAY_IMAGE;
+ break;
+ case GIMP_INDEXED:
+ layer_type = alpha ? GIMP_INDEXEDA_IMAGE: GIMP_INDEXED_IMAGE;
+ break;
+ default:
+ PyErr_SetString(pygimp_error, "Unknown image base type");
+ return NULL;
+ }
+
+ if (fill_mode == -1)
+ fill_mode = alpha ? GIMP_FILL_TRANSPARENT: GIMP_FILL_BACKGROUND;
+
+
+ layer_id = gimp_layer_new(self->ID, layer_name, width, height,
+ layer_type, opacity, mode);
+
+ if (!layer_id) {
+ PyErr_Format(pygimp_error,
+ "could not create new layer in image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ if (!gimp_drawable_fill(layer_id, fill_mode)) {
+ gimp_item_delete(layer_id);
+ PyErr_Format(pygimp_error,
+ "could not fill new layer with fill mode %d",
+ fill_mode);
+ return NULL;
+ }
+
+ if (!gimp_image_insert_layer(self->ID, layer_id, -1, pos)) {
+ gimp_item_delete(layer_id);
+ PyErr_Format(pygimp_error,
+ "could not add layer (ID %d) to image (ID %d)",
+ layer_id, self->ID);
+ return NULL;
+ }
+
+ if (!gimp_layer_set_offsets(layer_id, offs_x, offs_y)) {
+ gimp_image_remove_layer(self->ID, layer_id);
+ PyErr_Format(pygimp_error,
+ "could not set offset %d, %d on layer (ID %d)",
+ offs_x, offs_y, layer_id);
+ return NULL;
+ }
+
+ return pygimp_group_layer_new(layer_id);
+}
+
+
+static PyObject *
+img_clean_all(PyGimpImage *self)
+{
+ if (!gimp_image_clean_all(self->ID)) {
+ PyErr_Format(pygimp_error, "could not clean all on image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_disable_undo(PyGimpImage *self)
+{
+ return PyBool_FromLong(gimp_image_undo_disable(self->ID));
+}
+
+static PyObject *
+img_enable_undo(PyGimpImage *self)
+{
+ return PyBool_FromLong(gimp_image_undo_enable(self->ID));
+}
+
+static PyObject *
+img_flatten(PyGimpImage *self)
+{
+ return pygimp_group_layer_new(gimp_image_flatten(self->ID));
+}
+
+static PyObject *
+img_lower_channel(PyGimpImage *self, PyObject *args)
+{
+ PyGimpChannel *chn;
+
+ if (!PyArg_ParseTuple(args, "O!:lower_channel", &PyGimpChannel_Type, &chn))
+ return NULL;
+
+ if (!gimp_image_lower_item(self->ID, chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not lower channel (ID %d) on image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_lower_layer(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+
+ if (!PyArg_ParseTuple(args, "O!:lower_layer", &PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_image_lower_item(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not lower layer (ID %d) on image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_lower_layer_to_bottom(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+
+ if (!PyArg_ParseTuple(args, "O!:lower_layer_to_bottom",
+ &PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_image_lower_item_to_bottom(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not lower layer (ID %d) to bottom on image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_merge_visible_layers(PyGimpImage *self, PyObject *args)
+{
+ gint32 id;
+ int merge;
+
+ if (!PyArg_ParseTuple(args, "i:merge_visible_layers", &merge))
+ return NULL;
+
+ id = gimp_image_merge_visible_layers(self->ID, merge);
+
+ if (id == -1) {
+ PyErr_Format(pygimp_error,
+ "could not merge visible layers on image (ID %d) "
+ "with merge type %d",
+ self->ID, merge);
+ return NULL;
+ }
+
+ return pygimp_group_layer_new(id);
+}
+
+static PyObject *
+img_merge_down(PyGimpImage *self, PyObject *args)
+{
+ gint32 id;
+ PyGimpLayer *layer;
+ int merge;
+
+ if (!PyArg_ParseTuple(args, "O!i:merge_down",
+ &PyGimpLayer_Type, &layer, &merge))
+ return NULL;
+
+ id = gimp_image_merge_down(self->ID, layer->ID, merge);
+
+ if (id == -1) {
+ PyErr_Format(pygimp_error,
+ "could not merge down layer (ID %d) on image (ID %d) "
+ "with merge type %d",
+ layer->ID, self->ID, merge);
+ return NULL;
+ }
+
+ return pygimp_group_layer_new(id);
+}
+
+static PyObject *
+img_pick_correlate_layer(PyGimpImage *self, PyObject *args)
+{
+ int x,y;
+ gint32 id;
+
+ if (!PyArg_ParseTuple(args, "ii:pick_correlate_layer", &x, &y))
+ return NULL;
+
+ id = gimp_image_pick_correlate_layer(self->ID, x, y);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_group_layer_new(id);
+}
+
+static PyObject *
+img_raise_channel(PyGimpImage *self, PyObject *args)
+{
+ PyGimpChannel *chn;
+
+ if (!PyArg_ParseTuple(args, "O!:raise_channel", &PyGimpChannel_Type, &chn))
+ return NULL;
+
+ if (!gimp_image_raise_item(self->ID, chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not raise channel (ID %d) on image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_raise_layer(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+
+ if (!PyArg_ParseTuple(args, "O!:raise_layer", &PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_image_raise_item(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not raise layer (ID %d) on image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_raise_layer_to_top(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+
+ if (!PyArg_ParseTuple(args, "O!:raise_layer_to_top",
+ &PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_image_raise_item_to_top(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not raise layer (ID %d) to top on image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_remove_channel(PyGimpImage *self, PyObject *args)
+{
+ PyGimpChannel *chn;
+
+ if (!PyArg_ParseTuple(args, "O!:remove_channel", &PyGimpChannel_Type, &chn))
+ return NULL;
+
+ if (!gimp_image_remove_channel(self->ID, chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not remove channel (ID %d) from image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_remove_layer(PyGimpImage *self, PyObject *args)
+{
+ PyGimpLayer *lay;
+
+ if (!PyArg_ParseTuple(args, "O!:remove_layer", &PyGimpLayer_Type, &lay))
+ return NULL;
+
+ if (!gimp_image_remove_layer(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not remove layer (ID %d) from image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_resize(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ int new_w, new_h;
+ int offs_x = 0, offs_y = 0;
+
+ static char *kwlist[] = { "width", "height", "offset_x", "offset_y",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:resize", kwlist,
+ &new_w, &new_h, &offs_x, &offs_y))
+ return NULL;
+
+ if (!gimp_image_resize(self->ID, new_w, new_h, offs_x, offs_y)) {
+ PyErr_Format(pygimp_error,
+ "could not resize image (ID %d) to %dx%d, offset %d, %d",
+ self->ID, new_w, new_h, offs_x, offs_y);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_resize_to_layers(PyGimpImage *self)
+{
+ if (!gimp_image_resize_to_layers(self->ID)) {
+ PyErr_Format(pygimp_error, "could not resize to layers on image "
+ "(ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_scale(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ int new_width, new_height;
+ int interpolation = -1;
+
+ static char *kwlist[] = { "width", "height", "interpolation", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:scale", kwlist,
+ &new_width, &new_height, &interpolation))
+ return NULL;
+
+ if (interpolation != -1) {
+ gimp_context_push();
+ gimp_context_set_interpolation(interpolation);
+ }
+
+ if (!gimp_image_scale(self->ID, new_width, new_height)) {
+ PyErr_Format(pygimp_error, "could not scale image (ID %d) to %dx%d",
+ self->ID, new_width, new_height);
+ if (interpolation != -1) {
+ gimp_context_pop();
+ }
+ return NULL;
+ }
+
+ if (interpolation != -1) {
+ gimp_context_pop();
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_crop(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ int new_w, new_h;
+ int offs_x = 0, offs_y = 0;
+
+ static char *kwlist[] = { "width", "height", "offset_x", "offset_y",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:crop", kwlist,
+ &new_w, &new_h, &offs_x, &offs_y))
+ return NULL;
+
+ if (!gimp_image_crop(self->ID, new_w, new_h, offs_x, offs_y)) {
+ PyErr_Format(pygimp_error,
+ "could not crop image (ID %d) to %dx%d, offset %d, %d",
+ self->ID, new_w, new_h, offs_x, offs_y);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_free_shadow(PyGimpImage *self)
+{
+ /* this procedure is deprecated and does absolutely nothing */
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_unset_active_channel(PyGimpImage *self)
+{
+ if (!gimp_image_unset_active_channel(self->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not unset active channel on image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_get_component_active(PyGimpImage *self, PyObject *args)
+{
+ int comp;
+
+ if (!PyArg_ParseTuple(args, "i:get_component_active", &comp))
+ return NULL;
+
+ return PyBool_FromLong(gimp_image_get_component_active(self->ID, comp));
+}
+
+
+static PyObject *
+img_get_component_visible(PyGimpImage *self, PyObject *args)
+{
+ int comp;
+
+ if (!PyArg_ParseTuple(args, "i:get_component_visible", &comp))
+ return NULL;
+
+ return PyBool_FromLong(gimp_image_get_component_visible(self->ID, comp));
+}
+
+
+static PyObject *
+img_set_component_active(PyGimpImage *self, PyObject *args)
+{
+ int comp, a;
+
+ if (!PyArg_ParseTuple(args, "ii:set_component_active", &comp, &a))
+ return NULL;
+
+ if (!gimp_image_set_component_active(self->ID, comp, a)) {
+ PyErr_Format(pygimp_error,
+ "could not set component (%d) %sactive on image (ID %d)",
+ comp, a ? "" : "in", self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_set_component_visible(PyGimpImage *self, PyObject *args)
+{
+ int comp, v;
+
+ if (!PyArg_ParseTuple(args, "ii:set_component_visible", &comp, &v))
+ return NULL;
+
+ if (!gimp_image_set_component_visible(self->ID, comp, v)) {
+ PyErr_Format(pygimp_error,
+ "could not set component (%d) %svisible on image (ID %d)",
+ comp, v ? "" : "in", self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_parasite_find(PyGimpImage *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
+ return NULL;
+
+ return pygimp_parasite_new (gimp_image_get_parasite (self->ID, name));
+}
+
+static PyObject *
+img_parasite_attach(PyGimpImage *self, PyObject *args)
+{
+ PyGimpParasite *parasite;
+
+ if (!PyArg_ParseTuple(args, "O!:parasite_attach", &PyGimpParasite_Type,
+ &parasite))
+ return NULL;
+
+ if (! gimp_image_attach_parasite (self->ID, parasite->para)) {
+ PyErr_Format(pygimp_error,
+ "could not attach parasite '%s' to image (ID %d)",
+ parasite->para->name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_attach_new_parasite(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ char *name;
+ int flags, size;
+ guint8 *data;
+ GimpParasite *parasite;
+ gboolean success;
+
+ static char *kwlist[] = { "name", "flags", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "sis#:attach_new_parasite", kwlist,
+ &name, &flags, &data, &size))
+ return NULL;
+
+ parasite = gimp_parasite_new (name, flags, size, data);
+ success = gimp_image_attach_parasite (self->ID, parasite);
+ gimp_parasite_free (parasite);
+
+ if (!success) {
+ PyErr_Format(pygimp_error,
+ "could not attach new parasite '%s' to image (ID %d)",
+ name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_parasite_detach(PyGimpImage *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_detach", &name))
+ return NULL;
+
+ if (!gimp_image_detach_parasite (self->ID, name)) {
+ PyErr_Format(pygimp_error,
+ "could not detach parasite '%s' from image (ID %d)",
+ name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_parasite_list(PyGimpImage *self)
+{
+ gint num_parasites;
+ gchar **parasites;
+ PyObject *ret;
+ gint i;
+
+ parasites = gimp_image_get_parasite_list (self->ID, &num_parasites);
+
+ ret = PyTuple_New(num_parasites);
+
+ for (i = 0; i < num_parasites; i++)
+ PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
+
+ g_strfreev(parasites);
+ return ret;
+}
+
+static PyObject *
+img_get_layer_by_tattoo(PyGimpImage *self, PyObject *args)
+{
+ int tattoo;
+
+ if (!PyArg_ParseTuple(args, "i:get_layer_by_tattoo", &tattoo))
+ return NULL;
+
+ return pygimp_group_layer_new(gimp_image_get_layer_by_tattoo(self->ID, tattoo));
+}
+
+static PyObject *
+img_get_channel_by_tattoo(PyGimpImage *self, PyObject *args)
+{
+ int tattoo;
+
+ if (!PyArg_ParseTuple(args, "i:get_channel_by_tattoo", &tattoo))
+ return NULL;
+
+ return pygimp_channel_new(gimp_image_get_channel_by_tattoo(self->ID,
+ tattoo));
+}
+
+static PyObject *
+img_add_hguide(PyGimpImage *self, PyObject *args)
+{
+ int ypos;
+
+ if (!PyArg_ParseTuple(args, "i:add_hguide", &ypos))
+ return NULL;
+
+ return PyInt_FromLong(gimp_image_add_hguide(self->ID, ypos));
+}
+
+static PyObject *
+img_add_vguide(PyGimpImage *self, PyObject *args)
+{
+ int xpos;
+
+ if (!PyArg_ParseTuple(args, "i:add_vguide", &xpos))
+ return NULL;
+
+ return PyInt_FromLong(gimp_image_add_vguide(self->ID, xpos));
+}
+
+static PyObject *
+img_delete_guide(PyGimpImage *self, PyObject *args)
+{
+ int guide;
+
+ if (!PyArg_ParseTuple(args, "i:delete_guide", &guide))
+ return NULL;
+
+ if (!gimp_image_delete_guide(self->ID, guide)) {
+ PyErr_Format(pygimp_error,
+ "could not delete guide (ID %d) from image (ID %d)",
+ guide, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_find_next_guide(PyGimpImage *self, PyObject *args)
+{
+ int guide;
+
+ if (!PyArg_ParseTuple(args, "i:find_next_guide", &guide))
+ return NULL;
+
+ return PyInt_FromLong(gimp_image_find_next_guide(self->ID, guide));
+}
+
+static PyObject *
+img_get_guide_orientation(PyGimpImage *self, PyObject *args)
+{
+ int guide;
+
+ if (!PyArg_ParseTuple(args, "i:get_guide_orientation", &guide))
+ return NULL;
+
+ return PyInt_FromLong(gimp_image_get_guide_orientation(self->ID, guide));
+}
+
+static PyObject *
+img_get_guide_position(PyGimpImage *self, PyObject *args)
+{
+ int guide;
+
+ if (!PyArg_ParseTuple(args, "i:get_guide_position", &guide))
+ return NULL;
+
+ return PyInt_FromLong(gimp_image_get_guide_position(self->ID, guide));
+}
+
+static PyObject *
+img_undo_is_enabled(PyGimpImage *self)
+{
+ return PyBool_FromLong(gimp_image_undo_is_enabled(self->ID));
+}
+
+static PyObject *
+img_undo_freeze(PyGimpImage *self)
+{
+ return PyBool_FromLong(gimp_image_undo_freeze(self->ID));
+}
+
+static PyObject *
+img_undo_thaw(PyGimpImage *self)
+{
+ return PyBool_FromLong(gimp_image_undo_thaw(self->ID));
+}
+
+static PyObject *
+img_duplicate(PyGimpImage *self)
+{
+ return pygimp_image_new(gimp_image_duplicate(self->ID));
+}
+
+static PyObject *
+img_undo_group_start(PyGimpImage *self)
+{
+ if (!gimp_image_undo_group_start(self->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not start undo group on image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_undo_group_end(PyGimpImage *self)
+{
+ if (!gimp_image_undo_group_end(self->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not end undo group on image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef img_methods[] = {
+ {"add_channel", (PyCFunction)img_add_channel, METH_VARARGS},
+ {"insert_channel", (PyCFunction)img_insert_channel, METH_VARARGS | METH_KEYWORDS},
+ {"add_layer", (PyCFunction)img_add_layer, METH_VARARGS},
+ {"insert_layer", (PyCFunction)img_insert_layer, METH_VARARGS | METH_KEYWORDS},
+ {"new_layer", (PyCFunction)img_new_layer, METH_VARARGS | METH_KEYWORDS},
+ {"clean_all", (PyCFunction)img_clean_all, METH_NOARGS},
+ {"disable_undo", (PyCFunction)img_disable_undo, METH_NOARGS},
+ {"enable_undo", (PyCFunction)img_enable_undo, METH_NOARGS},
+ {"flatten", (PyCFunction)img_flatten, METH_NOARGS},
+ {"lower_channel", (PyCFunction)img_lower_channel, METH_VARARGS},
+ {"lower_layer", (PyCFunction)img_lower_layer, METH_VARARGS},
+ {"lower_layer_to_bottom", (PyCFunction)img_lower_layer_to_bottom, METH_VARARGS},
+ {"merge_visible_layers", (PyCFunction)img_merge_visible_layers, METH_VARARGS},
+ {"merge_down", (PyCFunction)img_merge_down, METH_VARARGS},
+ {"pick_correlate_layer", (PyCFunction)img_pick_correlate_layer, METH_VARARGS},
+ {"raise_channel", (PyCFunction)img_raise_channel, METH_VARARGS},
+ {"raise_layer", (PyCFunction)img_raise_layer, METH_VARARGS},
+ {"raise_layer_to_top", (PyCFunction)img_raise_layer_to_top, METH_VARARGS},
+ {"remove_channel", (PyCFunction)img_remove_channel, METH_VARARGS},
+ {"remove_layer", (PyCFunction)img_remove_layer, METH_VARARGS},
+ {"resize", (PyCFunction)img_resize, METH_VARARGS | METH_KEYWORDS},
+ {"resize_to_layers", (PyCFunction)img_resize_to_layers, METH_NOARGS},
+ {"get_component_active", (PyCFunction)img_get_component_active, METH_VARARGS},
+ {"get_component_visible", (PyCFunction)img_get_component_visible, METH_VARARGS},
+ {"set_component_active", (PyCFunction)img_set_component_active, METH_VARARGS},
+ {"set_component_visible", (PyCFunction)img_set_component_visible, METH_VARARGS},
+ {"parasite_find", (PyCFunction)img_parasite_find, METH_VARARGS},
+ {"parasite_attach", (PyCFunction)img_parasite_attach, METH_VARARGS},
+ {"attach_new_parasite", (PyCFunction)img_attach_new_parasite, METH_VARARGS | METH_KEYWORDS},
+ {"parasite_detach", (PyCFunction)img_parasite_detach, METH_VARARGS},
+ {"parasite_list", (PyCFunction)img_parasite_list, METH_NOARGS},
+ {"get_layer_by_tattoo",(PyCFunction)img_get_layer_by_tattoo,METH_VARARGS},
+ {"get_channel_by_tattoo",(PyCFunction)img_get_channel_by_tattoo,METH_VARARGS},
+ {"add_hguide", (PyCFunction)img_add_hguide, METH_VARARGS},
+ {"add_vguide", (PyCFunction)img_add_vguide, METH_VARARGS},
+ {"delete_guide", (PyCFunction)img_delete_guide, METH_VARARGS},
+ {"find_next_guide", (PyCFunction)img_find_next_guide, METH_VARARGS},
+ {"get_guide_orientation",(PyCFunction)img_get_guide_orientation,METH_VARARGS},
+ {"get_guide_position", (PyCFunction)img_get_guide_position, METH_VARARGS},
+ {"scale", (PyCFunction)img_scale, METH_VARARGS | METH_KEYWORDS},
+ {"crop", (PyCFunction)img_crop, METH_VARARGS | METH_KEYWORDS},
+ {"free_shadow", (PyCFunction)img_free_shadow, METH_NOARGS},
+ {"unset_active_channel", (PyCFunction)img_unset_active_channel, METH_NOARGS},
+ {"undo_is_enabled", (PyCFunction)img_undo_is_enabled, METH_NOARGS},
+ {"undo_freeze", (PyCFunction)img_undo_freeze, METH_NOARGS},
+ {"undo_thaw", (PyCFunction)img_undo_thaw, METH_NOARGS},
+ {"duplicate", (PyCFunction)img_duplicate, METH_NOARGS},
+ {"undo_group_start", (PyCFunction)img_undo_group_start, METH_NOARGS},
+ {"undo_group_end", (PyCFunction)img_undo_group_end, METH_NOARGS},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+img_get_ID(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(self->ID);
+}
+
+static PyObject *
+img_get_active_channel(PyGimpImage *self, void *closure)
+{
+ gint32 id = gimp_image_get_active_channel(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_channel_new(id);
+}
+
+static int
+img_set_active_channel(PyGimpImage *self, PyObject *value, void *closure)
+{
+ PyGimpChannel *chn;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete active_channel");
+ return -1;
+ }
+
+ if (!pygimp_channel_check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ chn = (PyGimpChannel *)value;
+
+ if (!gimp_image_set_active_channel(self->ID, chn->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not set active channel (ID %d) on image (ID %d)",
+ chn->ID, self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_active_drawable(PyGimpImage *self, void *closure)
+{
+ gint32 id = gimp_image_get_active_drawable(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_drawable_new(NULL, id);
+}
+
+static PyObject *
+img_get_active_layer(PyGimpImage *self, void *closure)
+{
+ gint32 id = gimp_image_get_active_layer(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_group_layer_new(id);
+}
+
+static int
+img_set_active_layer(PyGimpImage *self, PyObject *value, void *closure)
+{
+ PyGimpLayer *lay;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete active_layer");
+ return -1;
+ }
+
+ if (!pygimp_layer_check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ lay = (PyGimpLayer *)value;
+
+ if (!gimp_image_set_active_layer(self->ID, lay->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not set active layer (ID %d) on image (ID %d)",
+ lay->ID, self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_base_type(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_base_type(self->ID));
+}
+
+static PyObject *
+img_get_channels(PyGimpImage *self, void *closure)
+{
+ gint32 *channels;
+ gint n_channels, i;
+ PyObject *ret;
+
+ channels = gimp_image_get_channels(self->ID, &n_channels);
+
+ ret = PyList_New(n_channels);
+
+ for (i = 0; i < n_channels; i++)
+ PyList_SetItem(ret, i, pygimp_channel_new(channels[i]));
+
+ g_free(channels);
+
+ return ret;
+}
+
+static PyObject *
+img_get_colormap(PyGimpImage *self, void *closure)
+{
+ guchar *cmap;
+ gint n_colours;
+ PyObject *ret;
+
+ cmap = gimp_image_get_colormap(self->ID, &n_colours);
+
+ if (cmap == NULL) {
+ PyErr_Format(pygimp_error, "could not get colormap for image (ID %d)",
+ self->ID);
+ return NULL;
+ }
+
+ ret = PyString_FromStringAndSize((char *)cmap, n_colours * 3);
+ g_free(cmap);
+
+ return ret;
+}
+
+static int
+img_set_colormap(PyGimpImage *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete colormap");
+ return -1;
+ }
+
+ if (!PyString_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_image_set_colormap(self->ID, (guchar *)PyString_AsString(value),
+ PyString_Size(value) / 3)) {
+ PyErr_Format(pygimp_error, "could not set colormap on image (ID %d)",
+ self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_is_dirty(PyGimpImage *self, void *closure)
+{
+ return PyBool_FromLong(gimp_image_is_dirty(self->ID));
+}
+
+static PyObject *
+img_get_filename(PyGimpImage *self, void *closure)
+{
+ gchar *filename;
+
+ filename = gimp_image_get_filename(self->ID);
+
+ if (filename) {
+ PyObject *ret = PyString_FromString(filename);
+ g_free(filename);
+ return ret;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static int
+img_set_filename(PyGimpImage *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete filename");
+ return -1;
+ }
+
+ if (!PyString_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_image_set_filename(self->ID, PyString_AsString(value))) {
+ PyErr_SetString(PyExc_TypeError, "could not set filename "
+ "(possibly bad encoding)");
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_uri(PyGimpImage *self, void *closure)
+{
+ gchar *uri;
+
+ uri = gimp_image_get_uri(self->ID);
+
+ if (uri) {
+ PyObject *ret = PyString_FromString(uri);
+ g_free(uri);
+ return ret;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_get_floating_selection(PyGimpImage *self, void *closure)
+{
+ gint32 id;
+
+ id = gimp_image_get_floating_sel(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_layer_new(id);
+}
+
+static PyObject *
+img_get_floating_sel_attached_to(PyGimpImage *self, void *closure)
+{
+ gint32 id;
+
+ id = gimp_image_floating_sel_attached_to(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_layer_new(id);
+}
+
+static PyObject *
+img_get_layers(PyGimpImage *self, void *closure)
+{
+ gint32 *layers;
+ gint n_layers, i;
+ PyObject *ret;
+
+ layers = gimp_image_get_layers(self->ID, &n_layers);
+
+ ret = PyList_New(n_layers);
+
+ for (i = 0; i < n_layers; i++)
+ PyList_SetItem(ret, i, pygimp_group_layer_new(layers[i]));
+
+ g_free(layers);
+
+ return ret;
+}
+
+static PyObject *
+img_get_name(PyGimpImage *self, void *closure)
+{
+ gchar *name;
+
+ name = gimp_image_get_name(self->ID);
+
+ if (name) {
+ PyObject *ret = PyString_FromString(name);
+ g_free(name);
+ return ret;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+img_get_selection(PyGimpImage *self, void *closure)
+{
+ return pygimp_channel_new(gimp_image_get_selection(self->ID));
+}
+
+static PyObject *
+img_get_tattoo_state(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_get_tattoo_state(self->ID));
+}
+
+static int
+img_set_tattoo_state(PyGimpImage *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete tattoo_state");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_image_set_tattoo_state(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+img_get_height(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_height(self->ID));
+}
+
+static PyObject *
+img_get_width(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_width(self->ID));
+}
+
+
+static PyObject *
+img_get_precision(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_get_precision(self->ID));
+}
+
+static PyObject *
+img_get_resolution(PyGimpImage *self, void *closure)
+{
+ double xres, yres;
+
+ gimp_image_get_resolution(self->ID, &xres, &yres);
+
+ return Py_BuildValue("(dd)", xres, yres);
+}
+
+static int
+img_set_resolution(PyGimpImage *self, PyObject *value, void *closure)
+{
+ gdouble xres, yres;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete resolution");
+ return -1;
+ }
+
+ if (!PySequence_Check(value) ||
+ !PyArg_ParseTuple(value, "dd", &xres, &yres)) {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_image_set_resolution(self->ID, xres, yres)) {
+ PyErr_SetString(PyExc_TypeError, "could not set resolution");
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_unit(PyGimpImage *self, void *closure)
+{
+ return PyInt_FromLong(gimp_image_get_unit(self->ID));
+}
+
+static int
+img_set_unit(PyGimpImage *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete unit");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ if (!gimp_image_set_unit(self->ID, PyInt_AsLong(value))) {
+ PyErr_SetString(PyExc_TypeError, "could not set unit");
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyObject *
+img_get_vectors(PyGimpImage *self, void *closure)
+{
+ int *vectors;
+ int i, num_vectors;
+ PyObject *ret;
+
+ vectors = gimp_image_get_vectors(self->ID, &num_vectors);
+
+ ret = PyList_New(num_vectors);
+
+ for (i = 0; i < num_vectors; i++)
+ PyList_SetItem(ret, i, pygimp_vectors_new(vectors[i]));
+
+ g_free(vectors);
+
+ return ret;
+}
+
+static PyObject *
+img_get_active_vectors(PyGimpImage *self, void *closure)
+{
+ gint32 id = gimp_image_get_active_vectors(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_vectors_new(id);
+}
+
+static int
+img_set_active_vectors(PyGimpImage *self, PyObject *value, void *closure)
+{
+ PyGimpVectors *vtr;
+
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete active_vectors");
+ return -1;
+ }
+
+ if (!pygimp_vectors_check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ vtr = (PyGimpVectors *)value;
+
+ if (!gimp_image_set_active_vectors(self->ID, vtr->ID)) {
+ PyErr_Format(pygimp_error,
+ "could not set active vectors (ID %d) on image (ID %d)",
+ vtr->ID, self->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyGetSetDef img_getsets[] = {
+ { "ID", (getter)img_get_ID, (setter)0 },
+ { "active_channel", (getter)img_get_active_channel,
+ (setter)img_set_active_channel },
+ { "active_drawable", (getter)img_get_active_drawable, (setter)0 },
+ { "active_layer", (getter)img_get_active_layer,
+ (setter)img_set_active_layer },
+ { "active_vectors", (getter)img_get_active_vectors,
+ (setter)img_set_active_vectors},
+ { "base_type", (getter)img_get_base_type, (setter)0 },
+ { "channels", (getter)img_get_channels, (setter)0 },
+ { "colormap", (getter)img_get_colormap, (setter)img_set_colormap },
+ { "dirty", (getter)img_get_is_dirty, (setter)0 },
+ { "filename", (getter)img_get_filename, (setter)img_set_filename },
+ { "floating_selection", (getter)img_get_floating_selection, (setter)0 },
+ { "floating_sel_attached_to", (getter)img_get_floating_sel_attached_to,
+ (setter)0 },
+ { "height", (getter)img_get_height, (setter)0 },
+ { "layers", (getter)img_get_layers, (setter)0 },
+ { "name", (getter)img_get_name, (setter)0 },
+ { "precision", (getter)img_get_precision, (setter)0 },
+ { "resolution", (getter)img_get_resolution, (setter)img_set_resolution },
+ { "selection", (getter)img_get_selection, (setter)0 },
+ { "tattoo_state", (getter)img_get_tattoo_state,
+ (setter)img_set_tattoo_state },
+ { "unit", (getter)img_get_unit, (setter)img_set_unit },
+ { "uri", (getter)img_get_uri, (setter)0 },
+ { "vectors", (getter)img_get_vectors, (setter)0 },
+ { "width", (getter)img_get_width, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+/* ---------- */
+
+
+PyObject *
+pygimp_image_new(gint32 ID)
+{
+ PyGimpImage *self;
+
+ if (!gimp_image_is_valid(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ self = PyObject_NEW(PyGimpImage, &PyGimpImage_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+
+ return (PyObject *)self;
+}
+
+
+static void
+img_dealloc(PyGimpImage *self)
+{
+ /* XXXX Add your own cleanup code here */
+ PyObject_DEL(self);
+}
+
+static PyObject *
+img_repr(PyGimpImage *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_image_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.Image '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+img_cmp(PyGimpImage *self, PyGimpImage *other)
+{
+ if (self->ID == other->ID)
+ return 0;
+
+ if (self->ID > other->ID)
+ return -1;
+
+ return 1;
+}
+
+static int
+img_init(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ guint width, height;
+ GimpImageBaseType type = GIMP_RGB;
+
+ static char *kwlist[] = { "width", "height", "type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ii|i:gimp.Image.__init__", kwlist,
+ &width, &height, &type))
+ return -1;
+
+ self->ID = gimp_image_new(width, height, type);
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error,
+ "could not create image (width: %d, height: %d, type: %d)",
+ width, height, type);
+ return -1;
+ }
+
+ return 0;
+}
+
+PyTypeObject PyGimpImage_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Image", /* tp_name */
+ sizeof(PyGimpImage), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)img_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)img_cmp, /* tp_compare */
+ (reprfunc)img_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ img_methods, /* tp_methods */
+ 0, /* tp_members */
+ img_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)img_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
diff --git a/plug-ins/pygimp/pygimp-intl.h b/plug-ins/pygimp/pygimp-intl.h
new file mode 100644
index 0000000..ef6fdf2
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-intl.h
@@ -0,0 +1,48 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * pygimp-intl.h
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef __PYGIMP_INTL_H__
+#define __PYGIMP_INTL_H__
+
+#ifndef GETTEXT_PACKAGE
+#error "config.h must be included prior to pygimp-intl.h"
+#endif
+
+#include <libintl.h>
+
+
+#define _(String) dgettext (GETTEXT_PACKAGE "-python", String)
+#define Q_(String) g_dpgettext (GETTEXT_PACKAGE "-python", String, 0)
+#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE "-python", Context "\004" String, strlen (Context) + 1)
+
+#undef gettext
+#define gettext(String) dgettext (GETTEXT_PACKAGE "-python", String)
+
+#undef ngettext
+#define ngettext(String1, String2, number) dngettext (GETTEXT_PACKAGE "-python", String1, String2, number)
+
+#ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+#else
+# define N_(String) (String)
+#endif
+
+
+#endif /* __PYGIMP_INTL_H__ */
diff --git a/plug-ins/pygimp/pygimp-item.c b/plug-ins/pygimp/pygimp-item.c
new file mode 100644
index 0000000..b3b0883
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-item.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include "pygimp.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+#include <glib-object.h>
+
+static PyObject *
+item_from_id(PyObject *not_used, PyObject *args)
+{
+ gint32 ID;
+
+ if (!PyArg_ParseTuple(args, "i", &ID))
+ return NULL;
+ return pygimp_item_new(ID);
+}
+
+static PyMethodDef item_methods[] = {
+ {"from_id", (PyCFunction)item_from_id, METH_VARARGS | METH_STATIC},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+item_get_parent(PyGimpLayer *self, void *closure)
+{
+ gint32 id = gimp_item_get_parent(self->ID);
+
+ if (id == -1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ return pygimp_item_new(id);
+}
+
+static PyObject *
+item_get_children(PyGimpLayer *self, void *closure)
+{
+ gint32 *children;
+ gint n_children, i;
+ PyObject *ret;
+
+ children = gimp_item_get_children(self->ID, &n_children);
+
+ ret = PyList_New(n_children);
+
+ for (i = 0; i < n_children; i++)
+ PyList_SetItem(ret, i, pygimp_item_new(children[i]));
+
+ g_free(children);
+
+ return ret;
+}
+
+static PyGetSetDef item_getsets[] = {
+ { "parent", (getter)item_get_parent, (setter)0 },
+ { "children", (getter) item_get_children, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+
+static void
+item_dealloc(PyGimpItem *self)
+{
+ PyObject_DEL(self);
+}
+
+static PyObject *
+item_repr(PyGimpItem *self)
+{
+ PyObject *s;
+
+ s = PyString_FromFormat("<gimp.Item '%d'>", self->ID);
+
+ return s;
+}
+
+static int
+item_init(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
+{
+ return -1;
+}
+
+
+
+PyTypeObject PyGimpItem_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Item", /* tp_name */
+ sizeof(PyGimpItem), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)item_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)item_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ item_methods, /* tp_methods */
+ 0, /* tp_members */
+ item_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)item_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+
+PyObject *
+pygimp_item_new(gint32 ID)
+{
+ PyObject *self;
+
+ if (!gimp_item_is_valid(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ /* create the appropriate object type */
+ if (gimp_item_is_drawable(ID)) {
+ if (gimp_item_is_group(ID)) {
+ self = pygimp_group_layer_new(ID);
+ }
+ else {
+ self = pygimp_drawable_new(NULL, ID);
+ }
+ }
+ else /* Vectors */
+ self = pygimp_vectors_new(ID);
+
+ if (self == NULL)
+ return NULL;
+
+ return self;
+}
diff --git a/plug-ins/pygimp/pygimp-logo.png b/plug-ins/pygimp/pygimp-logo.png
new file mode 100644
index 0000000..6f7ef4d
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-logo.png
Binary files differ
diff --git a/plug-ins/pygimp/pygimp-parasite.c b/plug-ins/pygimp/pygimp-parasite.c
new file mode 100644
index 0000000..279cfbd
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-parasite.c
@@ -0,0 +1,216 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pygimp.h"
+
+static PyObject *
+para_copy(PyGimpParasite *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":copy"))
+ return NULL;
+
+ return pygimp_parasite_new(gimp_parasite_copy(self->para));
+}
+
+static PyObject *
+para_is_type(PyGimpParasite *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:is_type", &name))
+ return NULL;
+
+ return PyInt_FromLong(gimp_parasite_is_type(self->para, name));
+}
+
+static PyObject *
+para_has_flag(PyGimpParasite *self, PyObject *args)
+{
+ int flag;
+
+ if (!PyArg_ParseTuple(args, "i:has_flag", &flag))
+ return NULL;
+
+ return PyInt_FromLong(gimp_parasite_has_flag(self->para, flag));
+}
+
+
+static PyMethodDef para_methods[] = {
+ {"copy", (PyCFunction)para_copy, METH_VARARGS},
+ {"is_type", (PyCFunction)para_is_type, METH_VARARGS},
+ {"has_flag",(PyCFunction)para_has_flag, METH_VARARGS},
+
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+para_get_is_persistent(PyGimpParasite *self, void *closure)
+{
+ return PyBool_FromLong(gimp_parasite_is_persistent(self->para));
+}
+
+static PyObject *
+para_get_is_undoable(PyGimpParasite *self, void *closure)
+{
+ return PyBool_FromLong(gimp_parasite_is_undoable(self->para));
+}
+
+static PyObject *
+para_get_flags(PyGimpParasite *self, void *closure)
+{
+ return PyInt_FromLong(gimp_parasite_flags(self->para));
+}
+
+static PyObject *
+para_get_name(PyGimpParasite *self, void *closure)
+{
+ return PyString_FromString(gimp_parasite_name(self->para));
+}
+
+static PyObject *
+para_get_data(PyGimpParasite *self, void *closure)
+{
+ return PyString_FromStringAndSize(gimp_parasite_data(self->para),
+ gimp_parasite_data_size(self->para));
+}
+
+static PyGetSetDef para_getsets[] = {
+ { "is_persistent", (getter)para_get_is_persistent, (setter)0 },
+ { "is_undoable", (getter)para_get_is_undoable, (setter)0 },
+ { "flags", (getter)para_get_flags, (setter)0 },
+ { "name", (getter)para_get_name, (setter)0 },
+ { "data", (getter)para_get_data, (setter)0 },
+ { NULL, (getter)0, (setter)0 },
+};
+
+static void
+para_dealloc(PyGimpParasite *self)
+{
+ gimp_parasite_free(self->para);
+ PyObject_DEL(self);
+}
+
+static PyObject *
+para_repr(PyGimpParasite *self)
+{
+ PyObject *s;
+
+ s = PyString_FromFormat("<parasite %s>", gimp_parasite_name(self->para));
+
+ return s;
+}
+
+static PyObject *
+para_str(PyGimpParasite *self)
+{
+ return PyString_FromStringAndSize(gimp_parasite_data(self->para),
+ gimp_parasite_data_size(self->para));
+}
+
+static int
+para_init(PyGimpParasite *self, PyObject *args, PyObject *kwargs)
+{
+ char *name;
+ int flags, size;
+ guint8 *data;
+
+ static char *kwlist[] = { "name", "flags", "data", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "sis#:gimp.Parasite.__init__", kwlist,
+ &name, &flags,
+ &data, &size))
+ return -1;
+
+ self->para = gimp_parasite_new(name, flags, size, data);
+
+ if (!self->para) {
+ PyErr_Format(pygimp_error, "could not create parasite '%s'", name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+PyTypeObject PyGimpParasite_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Parasite", /* tp_name */
+ sizeof(PyGimpParasite), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)para_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)para_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)para_str, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ para_methods, /* tp_methods */
+ 0, /* tp_members */
+ para_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)para_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_parasite_new(GimpParasite *para)
+{
+ PyGimpParasite *self;
+
+ if (!para) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ self = PyObject_NEW(PyGimpParasite, &PyGimpParasite_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->para = para;
+
+ return (PyObject *)self;
+}
diff --git a/plug-ins/pygimp/pygimp-pdb.c b/plug-ins/pygimp/pygimp-pdb.c
new file mode 100644
index 0000000..2ec0da0
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-pdb.c
@@ -0,0 +1,1110 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include "pygimp.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+#include <structmember.h>
+
+#include <glib-object.h>
+#include <glib/gprintf.h>
+
+#ifndef PG_DEBUG
+# define PG_DEBUG 0
+#endif
+
+/* ----------------------------------------------------- */
+
+/* Declarations for objects of type pdb */
+
+typedef struct {
+ PyObject_HEAD
+} PyGimpPDB;
+
+
+/* ---------------------------------------------------------------- */
+
+/* Declarations for objects of type pdbFunc */
+
+typedef struct {
+ PyObject_HEAD
+ char *name;
+ PyObject *proc_name, *proc_blurb, *proc_help, *proc_author,
+ *proc_copyright, *proc_date, *proc_type, *py_params,
+ *py_return_vals;
+ int nparams, nreturn_vals;
+ GimpParamDef *params, *return_vals;
+} PyGimpPDBFunction;
+
+static PyObject *pygimp_pdb_function_new_from_proc_db(char *name);
+
+/* ---------------------------------------------------------------- */
+
+/* routines to convert between Python tuples and gimp GimpParam's */
+
+#if PG_DEBUG > 0
+
+static void
+pygimp_param_print(int nparams, GimpParam *params)
+{
+ int i;
+
+ for (i = 0; i < nparams; i++) {
+ g_printf("param_print: type: %d, PDB_ITEM: %d\n", params[i].type, GIMP_PDB_ITEM);
+ switch(params[i].type) {
+ case GIMP_PDB_INT32:
+ g_printerr("%i. int %i\n", i,
+ params[i].data.d_int32);
+ break;
+ case GIMP_PDB_INT16:
+ g_printerr("%i. int %i\n", i,
+ params[i].data.d_int16);
+ break;
+ case GIMP_PDB_INT8:
+ g_printerr("%i. int %u\n", i,
+ params[i].data.d_int8);
+ break;
+ case GIMP_PDB_FLOAT:
+ g_printerr("%i. float %f\n", i,
+ params[i].data.d_float);
+ break;
+ case GIMP_PDB_STRING:
+ g_printerr("%i. string %s\n", i,
+ params[i].data.d_string);
+ break;
+ case GIMP_PDB_INT32ARRAY:
+ case GIMP_PDB_INT16ARRAY:
+ case GIMP_PDB_INT8ARRAY:
+ case GIMP_PDB_FLOATARRAY:
+ case GIMP_PDB_STRINGARRAY:
+ g_printerr("%i. array of type %i %s\n", i,
+ params[i].type,
+ params[i].data.d_int32array == NULL ? "(null)":"");
+ break;
+ case GIMP_PDB_STATUS:
+ g_printerr("%i. status %i\n", i,
+ params[i].data.d_status);
+ break;
+ default:
+ g_printerr("%i. other %i\n", i,
+ params[i].data.d_int32);
+ break;
+ }
+ }
+}
+
+#endif
+
+PyObject *
+pygimp_param_to_tuple(int nparams, const GimpParam *params)
+{
+ PyObject *args, *tmp;
+ int i, j, n;
+
+ args = PyTuple_New(nparams);
+ for (i = 0; i < nparams && params[i].type != GIMP_PDB_END; i++) {
+ PyObject *value = NULL;
+
+#if PG_DEBUG > 1
+ g_printf("param_to_tuple: type: %d, PDB_ITEM: %d\n", params[i].type, GIMP_PDB_ITEM);
+#endif
+
+ switch(params[i].type) {
+ case GIMP_PDB_INT32:
+ value = PyInt_FromLong(params[i].data.d_int32);
+ break;
+ case GIMP_PDB_INT16:
+ value = PyInt_FromLong(params[i].data.d_int16);
+ break;
+ case GIMP_PDB_INT8:
+ value = PyInt_FromLong(params[i].data.d_int8);
+ break;
+ case GIMP_PDB_FLOAT:
+ value = PyFloat_FromDouble(params[i].data.d_float);
+ break;
+ case GIMP_PDB_STRING:
+ if (params[i].data.d_string == NULL) {
+ Py_INCREF(Py_None);
+ value = Py_None;
+ } else
+ value = PyString_FromString(params[i].data.d_string);
+ break;
+
+ /* For these to work, the previous argument must have
+ * been an integer
+ */
+ case GIMP_PDB_INT32ARRAY:
+ if (params[i].data.d_int32array == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ PyInt_FromLong(params[i].data.d_int32array[j]));
+ break;
+ case GIMP_PDB_INT16ARRAY:
+ if (params[i].data.d_int16array == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ PyInt_FromLong(params[i].data.d_int16array[j]));
+ break;
+ case GIMP_PDB_INT8ARRAY:
+ if (params[i].data.d_int8array == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ PyInt_FromLong(params[i].data.d_int8array[j]));
+ break;
+ case GIMP_PDB_FLOATARRAY:
+ if (params[i].data.d_floatarray == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ PyFloat_FromDouble(params[i].data.d_floatarray[j]));
+ break;
+ case GIMP_PDB_STRINGARRAY:
+ if (params[i].data.d_stringarray == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ params[i].data.d_stringarray[j] ?
+ PyString_FromString(params[i].data.d_stringarray[j]) :
+ PyString_FromString(""));
+ break;
+ case GIMP_PDB_COLOR:
+ value = pygimp_rgb_new(&params[i].data.d_color);
+ break;
+ /*
+ GIMP_PDB_REGION is deprecated in libgimpbase/gimpbaseenums.h
+ and conflicts with GIMP_PDB_ITEM
+ case GIMP_PDB_REGION:
+ value = Py_BuildValue("(iiii)",
+ (int) params[i].data.d_region.x,
+ (int) params[i].data.d_region.y,
+ (int) params[i].data.d_region.width,
+ (int) params[i].data.d_region.height);
+ break;
+ */
+ case GIMP_PDB_DISPLAY:
+ value = pygimp_display_new(params[i].data.d_display);
+ break;
+ case GIMP_PDB_IMAGE:
+ value = pygimp_image_new(params[i].data.d_image);
+ break;
+ case GIMP_PDB_LAYER:
+ value = pygimp_layer_new(params[i].data.d_layer);
+ break;
+ case GIMP_PDB_CHANNEL:
+ value = pygimp_channel_new(params[i].data.d_channel);
+ break;
+ case GIMP_PDB_ITEM:
+ value = pygimp_item_new(params[i].data.d_item);
+ break;
+ case GIMP_PDB_DRAWABLE:
+ value = pygimp_drawable_new(NULL, params[i].data.d_drawable);
+ break;
+ case GIMP_PDB_SELECTION:
+ value = pygimp_channel_new(params[i].data.d_selection);
+ break;
+ case GIMP_PDB_COLORARRAY:
+ if (params[i].data.d_colorarray == NULL) {
+ value = PyTuple_New(0);
+ break;
+ }
+ if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
+ Py_DECREF(args);
+ return NULL;
+ }
+ if (!PyInt_Check(tmp)) {
+ PyErr_SetString(PyExc_TypeError,
+ "count type must be integer");
+ Py_DECREF(args);
+ return NULL;
+ }
+ n = PyInt_AsLong(tmp);
+ value = PyTuple_New(n);
+ for (j = 0; j < n; j++)
+ PyTuple_SetItem(value, j,
+ pygimp_rgb_new(&params[i].data.d_colorarray[j]));
+ break;
+ case GIMP_PDB_VECTORS:
+ value = pygimp_vectors_new(params[i].data.d_vectors);
+ break;
+ case GIMP_PDB_PARASITE:
+ value = pygimp_parasite_new(gimp_parasite_copy(
+ &(params[i].data.d_parasite)));
+ break;
+ case GIMP_PDB_STATUS:
+ value = PyInt_FromLong(params[i].data.d_status);
+ break;
+ case GIMP_PDB_END:
+ break;
+ }
+ PyTuple_SetItem(args, i, value);
+ }
+ return args;
+}
+
+GimpParam *
+pygimp_param_from_tuple(PyObject *args, const GimpParamDef *ptype, int nparams)
+{
+ PyObject *tuple, *item, *x, *y;
+ GimpParam *ret;
+ int i, j, len;
+ gint32 *i32a; gint16 *i16a; guint8 *i8a; gdouble *fa; gchar **sa;
+
+ if (nparams == 0)
+ tuple = PyTuple_New(0);
+ else if (!PyTuple_Check(args) && nparams == 1)
+ tuple = Py_BuildValue("(O)", args);
+ else {
+ Py_INCREF(args);
+ tuple = args;
+ }
+ if (!PyTuple_Check(tuple)) {
+ PyErr_SetString(PyExc_TypeError, "wrong type of parameter");
+ Py_DECREF(tuple);
+ return NULL;
+ }
+
+ if (PyTuple_Size(tuple) != nparams) {
+ PyErr_SetString(PyExc_TypeError, "wrong number of parameters");
+ Py_DECREF(tuple);
+ return NULL;
+ }
+
+ ret = g_new(GimpParam, nparams+1);
+ for (i = 0; i <= nparams; i++)
+ ret[i].type = GIMP_PDB_STATUS;
+#define check(expr) if (expr) { \
+ PyErr_SetString(PyExc_TypeError, "wrong parameter type"); \
+ Py_DECREF(tuple); \
+ gimp_destroy_params(ret, nparams); \
+ return NULL; \
+ }
+#define arraycheck(expr, ar) if (expr) { \
+ PyErr_SetString(PyExc_TypeError, "subscript of wrong type"); \
+ Py_DECREF(tuple); \
+ gimp_destroy_params(ret, nparams); \
+ g_free(ar); \
+ return NULL; \
+ }
+ for (i = 1; i <= nparams; i++) {
+ item = PyTuple_GetItem(tuple, i-1);
+#if PG_DEBUG > 1
+ g_printf("param_from_tuple: type: %d, PDB_ITEM: %d\n", ptype[i-1].type, GIMP_PDB_ITEM);
+#endif
+ switch (ptype[i-1].type) {
+ case GIMP_PDB_INT32:
+ check((x = PyNumber_Int(item)) == NULL);
+ ret[i].data.d_int32 = (gint32)PyInt_AsLong(x);
+ Py_DECREF(x);
+ break;
+ case GIMP_PDB_INT16:
+ check((x = PyNumber_Int(item)) == NULL);
+ ret[i].data.d_int16 = (gint16)PyInt_AsLong(x);
+ Py_DECREF(x);
+ break;
+ case GIMP_PDB_INT8:
+ check((x = PyNumber_Int(item)) == NULL);
+ ret[i].data.d_int8 = (guint8)PyInt_AsLong(x);
+ Py_DECREF(x);
+ break;
+ case GIMP_PDB_FLOAT:
+ check((x = PyNumber_Float(item)) == NULL);
+ ret[i].data.d_float = PyFloat_AsDouble(x);
+ Py_DECREF(x);
+ break;
+ case GIMP_PDB_STRING:
+ if (item == Py_None) {
+ ret[i].data.d_string = NULL;
+ break;
+ }
+ check((x = PyObject_Str(item)) == NULL);
+ ret[i].data.d_string = g_strdup(PyString_AsString(x));
+ Py_DECREF(x);
+ break;
+ case GIMP_PDB_INT32ARRAY:
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ i32a = g_new(gint32, len);
+ for (j = 0; j < len; j++) {
+ x = PySequence_GetItem(item, j);
+ arraycheck((y=PyNumber_Int(x))==NULL,
+ i32a);
+ i32a[j] = PyInt_AsLong(y);
+ Py_DECREF(y);
+ }
+ ret[i].data.d_int32array = i32a;
+ break;
+ case GIMP_PDB_INT16ARRAY:
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ i16a = g_new(gint16, len);
+ for (j = 0; j < len; j++) {
+ x = PySequence_GetItem(item, j);
+ arraycheck((y=PyNumber_Int(x))==NULL,
+ i16a);
+ i16a[j] = PyInt_AsLong(y);
+ Py_DECREF(y);
+ }
+ ret[i].data.d_int16array = i16a;
+ break;
+ case GIMP_PDB_INT8ARRAY:
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ i8a = g_new(guint8, len);
+ for (j = 0; j < len; j++) {
+ x = PySequence_GetItem(item, j);
+ arraycheck((y=PyNumber_Int(x))==NULL,
+ i8a);
+ i8a[j] = PyInt_AsLong(y);
+ Py_DECREF(y);
+ }
+ ret[i].data.d_int8array = i8a;
+ break;
+ case GIMP_PDB_FLOATARRAY:
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ fa = g_new(gdouble, len);
+ for (j = 0; j < len; j++) {
+ x = PySequence_GetItem(item, j);
+ arraycheck((y=PyNumber_Float(x))==NULL,
+ fa);
+ fa[j] = PyFloat_AsDouble(y);
+ Py_DECREF(y);
+ }
+ ret[i].data.d_floatarray = fa;
+ break;
+ case GIMP_PDB_STRINGARRAY:
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ sa = g_new(gchar *, len);
+ for (j = 0; j < len; j++) {
+ x = PySequence_GetItem(item, j);
+ if (x == Py_None) {
+ sa[j] = NULL;
+ continue;
+ }
+ arraycheck((y=PyObject_Str(x))==NULL,
+ sa);
+ sa[j] = g_strdup(PyString_AsString(y));
+ Py_DECREF(y);
+ }
+ ret[i].data.d_stringarray = sa;
+ break;
+ case GIMP_PDB_COLOR:
+ {
+ GimpRGB rgb;
+
+ if (!pygimp_rgb_from_pyobject(item, &rgb)) {
+ Py_DECREF(tuple);
+ gimp_destroy_params(ret, nparams);
+ return NULL;
+ }
+
+ ret[i].data.d_color = rgb;
+ }
+ break;
+/*
+ case GIMP_PDB_REGION:
+ check(!PySequence_Check(item) ||
+ PySequence_Length(item) < 4);
+ x = PySequence_GetItem(item, 0);
+ y = PySequence_GetItem(item, 1);
+ w = PySequence_GetItem(item, 2);
+ h = PySequence_GetItem(item, 3);
+ check(!PyInt_Check(x) || !PyInt_Check(y) ||
+ !PyInt_Check(w) || !PyInt_Check(h));
+ ret[i].data.d_region.x = PyInt_AsLong(x);
+ ret[i].data.d_region.y = PyInt_AsLong(y);
+ ret[i].data.d_region.width = PyInt_AsLong(w);
+ ret[i].data.d_region.height = PyInt_AsLong(h);
+ break;
+*/
+ case GIMP_PDB_DISPLAY:
+ if (item == Py_None) {
+ ret[i].data.d_display = -1;
+ break;
+ }
+ check(!pygimp_display_check(item));
+ ret[i].data.d_display = ((PyGimpDisplay *)item)->ID;
+ break;
+ case GIMP_PDB_IMAGE:
+ if (item == Py_None) {
+ ret[i].data.d_image = -1;
+ break;
+ }
+ check(!pygimp_image_check(item));
+ ret[i].data.d_image = ((PyGimpImage *)item)->ID;
+ break;
+ case GIMP_PDB_LAYER:
+ if (item == Py_None) {
+ ret[i].data.d_layer = -1;
+ break;
+ }
+ check(!pygimp_layer_check(item));
+ ret[i].data.d_layer = ((PyGimpLayer *)item)->ID;
+ break;
+ case GIMP_PDB_CHANNEL:
+ if (item == Py_None) {
+ ret[i].data.d_channel = -1;
+ break;
+ }
+ check(!pygimp_channel_check(item));
+ ret[i].data.d_channel = ((PyGimpChannel *)item)->ID;
+ break;
+ case GIMP_PDB_ITEM:
+ if (item == Py_None) {
+ ret[i].data.d_channel = -1;
+ break;
+ }
+ check(!pygimp_item_check(item));
+ ret[i].data.d_item = ((PyGimpItem *)item)->ID;
+ break;
+ case GIMP_PDB_DRAWABLE:
+ if (item == Py_None) {
+ ret[i].data.d_channel = -1;
+ break;
+ }
+ check(!pygimp_drawable_check(item));
+ ret[i].data.d_channel = ((PyGimpDrawable *)item)->ID;
+ break;
+ case GIMP_PDB_SELECTION:
+ if (item == Py_None) {
+ ret[i].data.d_channel = -1;
+ break;
+ }
+ check(!pygimp_channel_check(item));
+ ret[i].data.d_selection = ((PyGimpChannel *)item)->ID;
+ break;
+ case GIMP_PDB_COLORARRAY:
+ {
+ GimpRGB *rgb;
+
+ check(!PySequence_Check(item));
+ len = PySequence_Length(item);
+ rgb = g_new(GimpRGB, len);
+ for (j = 0; j < len; j++) {
+ if (!pygimp_rgb_from_pyobject(item, &rgb[j])) {
+ Py_DECREF(tuple);
+ g_free(rgb);
+ gimp_destroy_params(ret, nparams);
+ return NULL;
+ }
+ }
+ ret[i].data.d_colorarray = rgb;
+ }
+ break;
+ case GIMP_PDB_VECTORS:
+ if (item == Py_None) {
+ ret[i].data.d_vectors = -1;
+ break;
+ }
+ check(!pygimp_vectors_check(item));
+ ret[i].data.d_vectors = ((PyGimpVectors *)item)->ID;
+ break;
+ case GIMP_PDB_PARASITE:
+ /* can't do anything, since size of GimpParasite is not known */
+ break;
+ case GIMP_PDB_STATUS:
+ check(!PyInt_Check(item));
+ ret[i].data.d_status = PyInt_AsLong(item);
+ break;
+ case GIMP_PDB_END:
+ break;
+ }
+#undef check
+#undef arraycheck
+ ret[i].type = ptype[i-1].type;
+ }
+
+ Py_DECREF(tuple);
+ return ret;
+}
+
+/* ---------------------------------------------------------------- */
+
+static PyObject *
+pdb_query(PyGimpPDB *self, PyObject *args)
+{
+ char *n=".*", *b=".*", *h=".*", *a=".*", *c=".*", *d=".*", *t=".*";
+ int num, i;
+ char **names;
+ PyObject *ret;
+
+ if (!PyArg_ParseTuple(args, "|zzzzzzz:gimp.pdb.query", &n, &b, &h, &a,
+ &c, &d, &t))
+ return NULL;
+
+ gimp_procedural_db_query(n, b, h, a, c, d, t, &num, &names);
+
+ ret = PyList_New(num);
+
+ for (i = 0; i < num; i++)
+ PyList_SetItem(ret, i, PyString_FromString(names[i]));
+
+ g_strfreev(names);
+
+ return ret;
+}
+
+static PyMethodDef pdb_methods[] = {
+ {"query", (PyCFunction)pdb_query, METH_VARARGS},
+ {NULL, NULL} /* sentinel */
+};
+
+/* ---------- */
+
+
+PyObject *
+pygimp_pdb_new(void)
+{
+ PyGimpPDB *self = PyObject_NEW(PyGimpPDB, &PyGimpPDB_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ return (PyObject *)self;
+}
+
+
+static void
+pdb_dealloc(PyGimpPDB *self)
+{
+ PyObject_DEL(self);
+}
+
+static PyObject *
+pdb_repr(PyGimpPDB *self)
+{
+ return PyString_FromString("<gimp procedural database>");
+}
+
+/* Code to access pdb objects as mappings */
+
+static PyObject *
+pdb_subscript(PyGimpPDB *self, PyObject *key)
+{
+ PyObject *r;
+
+ if (!PyString_Check(key)) {
+ PyErr_SetString(PyExc_TypeError, "Subscript must be a string");
+ return NULL;
+ }
+
+ r = (PyObject *)pygimp_pdb_function_new_from_proc_db(PyString_AsString(key));
+
+ if (r == NULL) {
+ PyErr_Clear();
+ PyErr_SetObject(PyExc_KeyError, key);
+ }
+
+ return r;
+}
+
+static PyMappingMethods pdb_as_mapping = {
+ (lenfunc)0, /*mp_length*/
+ (binaryfunc)pdb_subscript, /*mp_subscript*/
+ (objobjargproc)0, /*mp_ass_subscript*/
+};
+
+/* -------------------------------------------------------- */
+
+static PyObject *
+build_procedure_list(void)
+{
+ int num, i;
+ char **names, *name, *p;
+ PyObject *ret;
+
+ gimp_procedural_db_query(".*", ".*", ".*", ".*", ".*", ".*", ".*",
+ &num, &names);
+
+ ret = PyList_New(num);
+
+ for (i = 0; i < num; i++) {
+ name = g_strdup(names[i]);
+ for (p = name; *p != '\0'; p++) {
+ if (*p == '-')
+ *p = '_';
+ }
+ PyList_SetItem(ret, i, PyString_FromString(name));
+ }
+
+ g_strfreev(names);
+
+ return ret;
+}
+
+static PyObject *
+pdb_getattro(PyGimpPDB *self, PyObject *attr)
+{
+ char *attr_name;
+ PyObject *ret;
+
+ attr_name = PyString_AsString(attr);
+ if (!attr_name) {
+ PyErr_Clear();
+ return PyObject_GenericGetAttr((PyObject *)self, attr);
+ }
+
+ if (attr_name[0] == '_') {
+ if (!strcmp(attr_name, "__members__")) {
+ return build_procedure_list();
+ } else {
+ return PyObject_GenericGetAttr((PyObject *)self, attr);
+ }
+ }
+
+ ret = PyObject_GenericGetAttr((PyObject *)self, attr);
+ if (ret)
+ return ret;
+
+ PyErr_Clear();
+
+ return pygimp_pdb_function_new_from_proc_db(attr_name);
+}
+
+PyTypeObject PyGimpPDB_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.PDB", /* tp_name */
+ sizeof(PyGimpPDB), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)pdb_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)pdb_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ &pdb_as_mapping, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)pdb_getattro, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ pdb_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+/* End of code for pdb objects */
+/* -------------------------------------------------------- */
+
+
+static PyObject *
+pygimp_pdb_function_new_from_proc_db(char *name)
+{
+ PyObject *ret;
+ char *b,*h,*a,*c,*d;
+ int np, nr;
+ GimpPDBProcType pt;
+ GimpParamDef *p, *r;
+
+ if (!gimp_procedural_db_proc_info (name, &b, &h, &a, &c, &d, &pt,
+ &np, &nr, &p, &r)) {
+ PyErr_SetString(pygimp_error, "procedure not found");
+ return NULL;
+ }
+
+ ret = pygimp_pdb_function_new(name, b, h, a, c, d, pt, np, nr, p, r);
+
+ g_free(b); g_free(h); g_free(a); g_free(c); g_free(d);
+
+ return ret;
+}
+
+static void
+pf_dealloc(PyGimpPDBFunction *self)
+{
+ g_free(self->name);
+
+ Py_DECREF(self->proc_name);
+ Py_DECREF(self->proc_blurb);
+ Py_DECREF(self->proc_help);
+ Py_DECREF(self->proc_author);
+ Py_DECREF(self->proc_copyright);
+ Py_DECREF(self->proc_date);
+ Py_DECREF(self->proc_type);
+ Py_DECREF(self->py_params);
+ Py_DECREF(self->py_return_vals);
+
+ gimp_destroy_paramdefs(self->params, self->nparams);
+ gimp_destroy_paramdefs(self->return_vals, self->nreturn_vals);
+
+ PyObject_DEL(self);
+}
+
+#define OFF(x) offsetof(PyGimpPDBFunction, x)
+static struct PyMemberDef pf_members[] = {
+ {"proc_name", T_OBJECT, OFF(proc_name), RO},
+ {"proc_blurb", T_OBJECT, OFF(proc_blurb), RO},
+ {"proc_help", T_OBJECT, OFF(proc_help), RO},
+ {"proc_author", T_OBJECT, OFF(proc_author), RO},
+ {"proc_copyright", T_OBJECT, OFF(proc_copyright), RO},
+ {"proc_date", T_OBJECT, OFF(proc_date), RO},
+ {"proc_type", T_OBJECT, OFF(proc_type), RO},
+ {"nparams", T_INT, OFF(nparams), RO},
+ {"nreturn_vals", T_INT, OFF(nreturn_vals), RO},
+ {"params", T_OBJECT, OFF(py_params), RO},
+ {"return_vals", T_OBJECT, OFF(py_return_vals), RO},
+ {NULL} /* Sentinel */
+};
+#undef OFF
+
+static PyObject *
+pf_repr(PyGimpPDBFunction *self)
+{
+ return PyString_FromFormat("<pdb function '%s'>",
+ PyString_AsString(self->proc_name));
+}
+
+static PyObject *
+pf_call(PyGimpPDBFunction *self, PyObject *args, PyObject *kwargs)
+{
+ GimpParam *params, *ret;
+ int nret;
+ PyObject *t = NULL, *r;
+ GimpRunMode run_mode = GIMP_RUN_NONINTERACTIVE;
+
+#if PG_DEBUG > 0
+ g_printerr("--- %s --- ", PyString_AsString(self->proc_name));
+#endif
+
+ if (kwargs) {
+ Py_ssize_t len, pos;
+ PyObject *key, *val;
+
+ len = PyDict_Size(kwargs);
+
+ if (len == 1) {
+ pos = 0;
+ PyDict_Next(kwargs, &pos, &key, &val);
+
+ if (!PyString_Check(key)) {
+ PyErr_SetString(PyExc_TypeError,
+ "keyword argument name is not a string");
+ return NULL;
+ }
+
+ if (strcmp(PyString_AsString(key), "run_mode") != 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "only 'run_mode' keyword argument accepted");
+ return NULL;
+ }
+
+ if (pyg_enum_get_value(GIMP_TYPE_RUN_MODE, val, (gpointer)&run_mode))
+ return NULL;
+ } else if (len != 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "expecting at most one keyword argument");
+ return NULL;
+ }
+ }
+
+ if (self->nparams > 0 && !strcmp(self->params[0].name, "run-mode")) {
+ params = pygimp_param_from_tuple(args, self->params + 1,
+ self->nparams - 1);
+
+ if (params == NULL)
+ return NULL;
+
+ params[0].type = self->params[0].type;
+ params[0].data.d_int32 = run_mode;
+
+#if PG_DEBUG > 1
+ pygimp_param_print(self->nparams, params);
+#endif
+
+ ret = gimp_run_procedure2(self->name, &nret, self->nparams, params);
+ } else {
+ params = pygimp_param_from_tuple(args, self->params, self->nparams);
+
+ if (params == NULL)
+ return NULL;
+
+#if PG_DEBUG > 1
+ pygimp_param_print(self->nparams, params+1);
+#endif
+
+ ret = gimp_run_procedure2(self->name, &nret, self->nparams, params + 1);
+ }
+
+ gimp_destroy_params(params, self->nparams);
+
+ if (!ret) {
+ PyErr_SetString(pygimp_error, "no status returned");
+#if PG_DEBUG >= 1
+ g_printerr("ret == NULL\n");
+#endif
+ return NULL;
+ }
+
+ switch(ret[0].data.d_status) {
+ case GIMP_PDB_SUCCESS:
+#if PG_DEBUG > 0
+ g_printerr("success\n");
+#endif
+ t = pygimp_param_to_tuple(nret-1, ret+1);
+ gimp_destroy_params(ret, nret);
+
+ if (t == NULL) {
+ PyErr_SetString(pygimp_error, "could not make return value");
+ return NULL;
+ }
+ break;
+
+ case GIMP_PDB_EXECUTION_ERROR:
+#if PG_DEBUG > 0
+ g_printerr("execution error\n");
+#endif
+ PyErr_SetString(PyExc_RuntimeError, gimp_get_pdb_error());
+ gimp_destroy_params(ret, nret);
+ return NULL;
+
+ case GIMP_PDB_CALLING_ERROR:
+#if PG_DEBUG > 0
+ g_printerr("calling error\n");
+#endif
+ PyErr_SetString(PyExc_RuntimeError, gimp_get_pdb_error());
+ gimp_destroy_params(ret, nret);
+ return NULL;
+
+ case GIMP_PDB_CANCEL:
+#if PG_DEBUG > 0
+ g_printerr("cancel\n");
+#endif
+ PyErr_SetString(PyExc_RuntimeError, gimp_get_pdb_error());
+ gimp_destroy_params(ret, nret);
+ return NULL;
+
+ default:
+#if PG_DEBUG > 0
+ g_printerr("unknown - %i (type %i)\n",
+ ret[0].data.d_status, ret[0].type);
+#endif
+ PyErr_SetString(pygimp_error, "unknown return code");
+ return NULL;
+ }
+
+ if (PyTuple_Size(t) == 1) {
+ r = PyTuple_GetItem(t, 0);
+ Py_INCREF(r);
+ Py_DECREF(t);
+ return r;
+ }
+
+ if (PyTuple_Size(t) == 0) {
+ r = Py_None;
+ Py_INCREF(r);
+ Py_DECREF(t);
+ return r;
+ }
+
+ return t;
+}
+
+
+PyTypeObject PyGimpPDBFunction_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.PDBFunction", /* tp_name */
+ sizeof(PyGimpPDBFunction), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)pf_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)pf_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)pf_call, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ 0, /* tp_methods */
+ pf_members, /* tp_members */
+ 0, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_pdb_function_new(const char *name, const char *blurb, const char *help,
+ const char *author, const char *copyright,
+ const char *date, GimpPDBProcType proc_type,
+ int n_params, int n_return_vals,
+ GimpParamDef *params, GimpParamDef *return_vals)
+{
+ PyGimpPDBFunction *self;
+ int i;
+
+ self = PyObject_NEW(PyGimpPDBFunction, &PyGimpPDBFunction_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->name = g_strdup(name);
+ self->proc_name = PyString_FromString(name ? name : "");
+ self->proc_blurb = PyString_FromString(blurb ? blurb : "");
+ self->proc_help = PyString_FromString(help ? help : "");
+ self->proc_author = PyString_FromString(author ? author : "");
+ self->proc_copyright = PyString_FromString(copyright ? copyright : "");
+ self->proc_date = PyString_FromString(date ? date : "");
+ self->proc_type = PyInt_FromLong(proc_type);
+ self->nparams = n_params;
+ self->nreturn_vals = n_return_vals;
+ self->params = params;
+ self->return_vals = return_vals;
+
+ self->py_params = PyTuple_New(n_params);
+ for (i = 0; i < n_params; i++)
+ PyTuple_SetItem(self->py_params, i,
+ Py_BuildValue("(iss)",
+ params[i].type,
+ params[i].name,
+ params[i].description));
+
+ self->py_return_vals = PyTuple_New(n_return_vals);
+ for (i = 0; i < n_return_vals; i++)
+ PyTuple_SetItem(self->py_return_vals, i,
+ Py_BuildValue("(iss)",
+ return_vals[i].type,
+ return_vals[i].name,
+ return_vals[i].description));
+
+ return (PyObject *)self;
+}
diff --git a/plug-ins/pygimp/pygimp-tile.c b/plug-ins/pygimp/pygimp-tile.c
new file mode 100644
index 0000000..b4f3722
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-tile.c
@@ -0,0 +1,1046 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define GIMP_DISABLE_DEPRECATION_WARNINGS
+
+#include "pygimp.h"
+
+#define NO_IMPORT_PYGIMPCOLOR
+#include "pygimpcolor-api.h"
+
+#include <structmember.h>
+
+static PyObject *
+tile_flush(PyGimpTile *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":flush"))
+ return NULL;
+
+ gimp_tile_flush(self->tile);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyMethodDef tile_methods[] = {
+ {"flush", (PyCFunction)tile_flush, METH_VARARGS},
+ {NULL, NULL} /* sentinel */
+};
+
+/* ---------- */
+
+
+PyObject *
+pygimp_tile_new(GimpTile *t, PyGimpDrawable *drw)
+{
+ PyGimpTile *self;
+
+ self = PyObject_NEW(PyGimpTile, &PyGimpTile_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ gimp_tile_ref(t);
+
+ self->tile = t;
+
+ Py_INCREF(drw);
+ self->drawable = drw;
+
+ return (PyObject *)self;
+}
+
+
+static void
+tile_dealloc(PyGimpTile *self)
+{
+ gimp_tile_unref(self->tile, FALSE);
+
+ Py_DECREF(self->drawable);
+ PyObject_DEL(self);
+}
+
+static PyObject *
+tile_get_uint_field(PyGimpTile *self, void *closure)
+{
+ gint offset = GPOINTER_TO_INT(closure);
+ guint value;
+ gchar *addr;
+
+ addr = (gchar *)self->tile;
+ addr += offset;
+ value = *(guint *)addr;
+
+ return PyInt_FromLong(value);
+}
+
+static PyObject *
+tile_get_dirty(PyGimpTile *self, void *closure)
+{
+ return PyBool_FromLong(self->tile->dirty);
+}
+
+static PyObject *
+tile_get_shadow(PyGimpTile *self, void *closure)
+{
+ return PyBool_FromLong(self->tile->shadow);
+}
+
+static PyObject *
+tile_get_drawable(PyGimpTile *self, void *closure)
+{
+ return pygimp_drawable_new(self->tile->drawable, 0);
+}
+
+
+#define OFF(x) GINT_TO_POINTER(offsetof(GimpTile, x))
+static PyGetSetDef tile_getsets[] = {
+ { "ewidth", (getter)tile_get_uint_field, 0, NULL, OFF(ewidth) },
+ { "eheight", (getter)tile_get_uint_field, 0, NULL, OFF(eheight) },
+ { "bpp", (getter)tile_get_uint_field, 0, NULL, OFF(bpp) },
+ { "tile_num", (getter)tile_get_uint_field, 0, NULL, OFF(tile_num) },
+ { "dirty", (getter)tile_get_dirty, 0, NULL },
+ { "shadow", (getter)tile_get_shadow, 0, NULL },
+ { "drawable", (getter)tile_get_drawable, 0, NULL },
+ { NULL, (getter)0, (setter)0 }
+};
+#undef OFF
+
+static PyObject *
+tile_repr(PyGimpTile *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->tile->drawable->drawable_id);
+
+ if (self->tile->shadow)
+ s = PyString_FromFormat("<gimp.Tile for drawable '%s' (shadow)>", name);
+ else
+ s = PyString_FromFormat("<gimp.Tile for drawable '%s'>", name);
+
+ g_free(name);
+
+ return s;
+}
+
+static Py_ssize_t
+tile_length(PyObject *self)
+{
+ return ((PyGimpTile*)self)->tile->ewidth * ((PyGimpTile*)self)->tile->eheight;
+}
+
+static PyObject *
+tile_subscript(PyGimpTile *self, PyObject *sub)
+{
+ GimpTile *tile = self->tile;
+ int bpp = tile->bpp;
+ long x, y;
+
+ if (PyInt_Check(sub)) {
+ x = PyInt_AsLong(sub);
+
+ if (x < 0 || x >= tile->ewidth * tile->eheight) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ return PyString_FromStringAndSize
+ ((char *)tile->data + bpp * x, bpp);
+ }
+
+ if (PyTuple_Check(sub)) {
+ if (!PyArg_ParseTuple(sub, "ll", &x, &y))
+ return NULL;
+
+ if (x < 0 || y < 0 || x >= tile->ewidth || y>=tile->eheight) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return NULL;
+ }
+
+ return PyString_FromStringAndSize
+ ((char *)tile->data + bpp * (x + y * tile->ewidth), bpp);
+ }
+
+ PyErr_SetString(PyExc_TypeError, "tile subscript not int or 2-tuple");
+ return NULL;
+}
+
+static int
+tile_ass_sub(PyGimpTile *self, PyObject *v, PyObject *w)
+{
+ GimpTile *tile = self->tile;
+ int bpp = tile->bpp, i;
+ long x, y;
+ guchar *pix, *data;
+
+ if (w == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "can not delete pixels in tile");
+ return -1;
+ }
+
+ if (!PyString_Check(w) && PyString_Size(w) == bpp) {
+ PyErr_SetString(PyExc_TypeError, "invalid subscript");
+ return -1;
+ }
+
+ pix = (guchar *)PyString_AsString(w);
+
+ if (PyInt_Check(v)) {
+ x = PyInt_AsLong(v);
+
+ if (x < 0 || x >= tile->ewidth * tile->eheight) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ data = tile->data + x * bpp;
+
+ for (i = 0; i < bpp; i++)
+ data[i] = pix[i];
+
+ tile->dirty = TRUE;
+
+ return 0;
+ }
+
+ if (PyTuple_Check(v)) {
+ if (!PyArg_ParseTuple(v, "ll", &x, &y))
+ return -1;
+
+ if (x < 0 || y < 0 || x >= tile->ewidth || y>=tile->eheight) {
+ PyErr_SetString(PyExc_IndexError, "index out of range");
+ return -1;
+ }
+
+ data = tile->data + bpp * (x + y * tile->ewidth);
+
+ for (i = 0; i < bpp; i++)
+ data[i] = pix[i];
+
+ tile->dirty = TRUE;
+
+ return 0;
+ }
+
+ PyErr_SetString(PyExc_TypeError, "tile subscript not int or 2-tuple");
+ return -1;
+}
+
+static PyMappingMethods tile_as_mapping = {
+ tile_length, /*length*/
+ (binaryfunc)tile_subscript, /*subscript*/
+ (objobjargproc)tile_ass_sub, /*ass_sub*/
+};
+
+PyTypeObject PyGimpTile_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Tile", /* tp_name */
+ sizeof(PyGimpTile), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)tile_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)tile_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ &tile_as_mapping, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ tile_methods, /* tp_methods */
+ 0, /* tp_members */
+ tile_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+/* End of code for Tile objects */
+/* -------------------------------------------------------- */
+
+
+static PyObject *
+pr_resize(PyGimpPixelRgn *self, PyObject *args)
+{
+ int x, y, w, h;
+
+ if (!PyArg_ParseTuple(args, "iiii:resize", &x, &y, &w, &h))
+ return NULL;
+
+ gimp_pixel_rgn_resize(&(self->pr), x, y, w, h);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+
+static PyMethodDef pr_methods[] = {
+ {"resize", (PyCFunction)pr_resize, METH_VARARGS},
+
+ {NULL, NULL} /* sentinel */
+};
+
+/* ---------- */
+
+
+PyObject *
+pygimp_pixel_rgn_new(PyGimpDrawable *drawable, int x, int y,
+ int width, int height, int dirty, int shadow)
+{
+ PyGimpPixelRgn *self;
+ int drw_width;
+ int drw_height;
+
+ self = PyObject_NEW(PyGimpPixelRgn, &PyGimpPixelRgn_Type);
+
+ if (self == NULL || drawable == NULL)
+ return NULL;
+
+ drw_width = gimp_drawable_width(drawable->ID);
+ drw_height = gimp_drawable_height(drawable->ID);
+
+ if(x < 0) x = 0;
+ if(y < 0) y = 0;
+ if(width < 0) width = drw_width - x;
+ if(height < 0) height = drw_height - y;
+ if(x >= drw_width) x = drw_width - 1;
+ if(y >= drw_height) y = drw_height - 1;
+ if(x + width > drw_width) width = drw_width - x;
+ if(y + height > drw_height) height = drw_height - y;
+
+ gimp_pixel_rgn_init(&(self->pr), drawable->drawable, x, y, width, height,
+ dirty, shadow);
+
+ self->drawable = drawable;
+ Py_INCREF(drawable);
+
+ return (PyObject *)self;
+}
+
+
+static void
+pr_dealloc(PyGimpPixelRgn *self)
+{
+ Py_DECREF(self->drawable);
+ PyObject_DEL(self);
+}
+
+/* Code to access pr objects as mappings */
+
+static Py_ssize_t
+pr_length(PyObject *self)
+{
+ PyErr_SetString(pygimp_error, "Can't get size of pixel region");
+ return -1;
+}
+
+static PyObject *
+pr_subscript(PyGimpPixelRgn *self, PyObject *key)
+{
+ GimpPixelRgn *pr = &(self->pr);
+ PyObject *x, *y;
+ Py_ssize_t x1, y1, x2, y2, xs, ys;
+ PyObject *ret;
+
+ if (!PyTuple_Check(key) || PyTuple_Size(key) != 2) {
+ PyErr_SetString(PyExc_TypeError, "subscript must be a 2-tuple");
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(key, "OO", &x, &y))
+ return NULL;
+
+ if (PyInt_Check(x)) {
+ x1 = PyInt_AsSsize_t(x);
+
+ if (x1 < pr->x || x1 >= pr->x + pr->w) {
+ PyErr_SetString(PyExc_IndexError, "x subscript out of range");
+ return NULL;
+ }
+
+ if (PyInt_Check(y)) {
+ y1 = PyInt_AsSsize_t(y);
+
+ if (y1 < pr->y || y1 >= pr->y + pr->h) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return NULL;
+ }
+
+ ret = PyString_FromStringAndSize(NULL, pr->bpp);
+ gimp_pixel_rgn_get_pixel(pr, (guchar*)PyString_AS_STRING(ret),
+ x1, y1);
+
+ } else if (PySlice_Check(y)) {
+ if (PySlice_GetIndices((PySliceObject*)y, pr->y + pr->h,
+ &y1, &y2, &ys) ||
+ y1 >= y2 || ys != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid y slice");
+ return NULL;
+ }
+
+ if(y1 == 0)
+ y1 = pr->y;
+
+ if(y1 < pr->y || y2 < pr->y) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return NULL;
+ }
+
+ ret = PyString_FromStringAndSize(NULL, pr->bpp * (y2 - y1));
+ gimp_pixel_rgn_get_col(pr, (guchar*)PyString_AS_STRING(ret),
+ x1, y1, y2-y1);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "invalid y subscript");
+ return NULL;
+ }
+ } else if (PySlice_Check(x)) {
+ if (PySlice_GetIndices((PySliceObject *)x, pr->x + pr->w,
+ &x1, &x2, &xs) ||
+ x1 >= x2 || xs != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid x slice");
+ return NULL;
+ }
+ if (x1 == 0)
+ x1 = pr->x;
+ if(x1 < pr->x || x2 < pr->x) {
+ PyErr_SetString(PyExc_IndexError, "x subscript out of range");
+ return NULL;
+ }
+
+ if (PyInt_Check(y)) {
+ y1 = PyInt_AsSsize_t(y);
+ if (y1 < pr->y || y1 >= pr->y + pr->h) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return NULL;
+ }
+ ret = PyString_FromStringAndSize(NULL, pr->bpp * (x2 - x1));
+ gimp_pixel_rgn_get_row(pr, (guchar*)PyString_AS_STRING(ret),
+ x1, y1, x2 - x1);
+
+ } else if (PySlice_Check(y)) {
+ if (PySlice_GetIndices((PySliceObject*)y, pr->y + pr->h,
+ &y1, &y2, &ys) ||
+ y1 >= y2 || ys != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid y slice");
+ return NULL;
+ }
+
+ if(y1 == 0)
+ y1 = pr->y;
+ if(y1 < pr->y || y2 < pr->y) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return NULL;
+ }
+
+ ret = PyString_FromStringAndSize(NULL,
+ pr->bpp * (x2 - x1) * (y2 - y1));
+ gimp_pixel_rgn_get_rect(pr, (guchar*)PyString_AS_STRING(ret),
+ x1, y1, x2 - x1, y2 - y1);
+ }
+ else {
+ PyErr_SetString(PyExc_TypeError, "invalid y subscript");
+ return NULL;
+ }
+
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid x subscript");
+ return NULL;
+ }
+ return ret;
+}
+
+static int
+pr_ass_sub(PyGimpPixelRgn *self, PyObject *v, PyObject *w)
+{
+ GimpPixelRgn *pr = &(self->pr);
+ PyObject *x, *y;
+ const guchar *buf;
+ Py_ssize_t len, x1, x2, xs, y1, y2, ys;
+
+ if (w == NULL) {
+ PyErr_SetString(PyExc_TypeError, "can't delete subscripts");
+ return -1;
+ }
+
+ if (!PyString_Check(w)) {
+ PyErr_SetString(PyExc_TypeError, "must assign string to subscript");
+ return -1;
+ }
+
+ if (!PyTuple_Check(v) || PyTuple_Size(v) != 2) {
+ PyErr_SetString(PyExc_TypeError, "subscript must be a 2-tuple");
+ return -1;
+ }
+
+ if (!PyArg_ParseTuple(v, "OO", &x, &y))
+ return -1;
+
+ buf = (const guchar *)PyString_AsString(w);
+ len = PyString_Size(w);
+ if (!buf || len > INT_MAX) {
+ return -1;
+ }
+
+ if (PyInt_Check(x)) {
+ x1 = PyInt_AsSsize_t(x);
+ if (x1 < pr->x || x1 >= pr->x + pr->w) {
+ PyErr_SetString(PyExc_IndexError, "x subscript out of range");
+ return -1;
+ }
+
+ if (PyInt_Check(y)) {
+ y1 = PyInt_AsSsize_t(y);
+
+ if (y1 < pr->y || y1 >= pr->y + pr->h) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return -1;
+ }
+
+ if (len != pr->bpp) {
+ PyErr_SetString(PyExc_TypeError, "string is wrong length");
+ return -1;
+ }
+ gimp_pixel_rgn_set_pixel(pr, buf, x1, y1);
+
+ } else if (PySlice_Check(y)) {
+ if (PySlice_GetIndices((PySliceObject *)y, pr->y + pr->h,
+ &y1, &y2, &ys) ||
+ y1 >= y2 || ys != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid y slice");
+ return -1;
+ }
+ if (y1 == 0)
+ y1 = pr->y;
+
+ if(y1 < pr->y || y2 < pr->y) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return -1;
+ }
+ if (len != pr->bpp * (y2 - y1)) {
+ PyErr_SetString(PyExc_TypeError, "string is wrong length");
+ return -1;
+ }
+ gimp_pixel_rgn_set_col(pr, buf, x1, y1, y2 - y1);
+
+ } else {
+ PyErr_SetString(PyExc_IndexError,"invalid y subscript");
+ return -1;
+ }
+ } else if (PySlice_Check(x)) {
+ if (PySlice_GetIndices((PySliceObject *)x, pr->x + pr->w,
+ &x1, &x2, &xs) ||
+ x1 >= x2 || xs != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid x slice");
+ return -1;
+ }
+ if(x1 == 0)
+ x1 = pr->x;
+
+ if(x1 < pr->x || x2 < pr->x) {
+ PyErr_SetString(PyExc_IndexError, "x subscript out of range");
+ return -1;
+ }
+
+ if (PyInt_Check(y)) {
+ y1 = PyInt_AsSsize_t(y);
+
+ if (y1 < pr->y || y1 >= pr->y + pr->h) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return -1;
+ }
+
+ if (len != pr->bpp * (x2 - x1)) {
+ PyErr_SetString(PyExc_TypeError, "string is wrong length");
+ return -1;
+ }
+ gimp_pixel_rgn_set_row(pr, buf, x1, y1, x2 - x1);
+
+ } else if (PySlice_Check(y)) {
+ if (PySlice_GetIndices((PySliceObject *)y, pr->y + pr->h,
+ &y1, &y2, &ys) ||
+ y1 >= y2 || ys != 1) {
+ PyErr_SetString(PyExc_IndexError, "invalid y slice");
+ return -1;
+ }
+ if (y1 == 0)
+ y1 = pr->y;
+
+ if(y1 < pr->y || y2 < pr->y) {
+ PyErr_SetString(PyExc_IndexError, "y subscript out of range");
+ return -1;
+ }
+ if (len != pr->bpp * (x2 - x1) * (y2 - y1)) {
+ PyErr_SetString(PyExc_TypeError, "string is wrong length");
+ return -1;
+ }
+ gimp_pixel_rgn_set_rect(pr, buf, x1, y1, x2 - x1, y2 - y1);
+
+ } else {
+ PyErr_SetString(PyExc_IndexError,"invalid y subscript");
+ return -1;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid x subscript");
+ return -1;
+ }
+ return 0;
+}
+
+static PyMappingMethods pr_as_mapping = {
+ pr_length, /*mp_length*/
+ (binaryfunc)pr_subscript, /*mp_subscript*/
+ (objobjargproc)pr_ass_sub, /*mp_ass_subscript*/
+};
+
+/* -------------------------------------------------------- */
+
+static PyObject *
+pr_get_drawable(PyGimpPixelRgn *self, void *closure)
+{
+ return pygimp_drawable_new(self->pr.drawable, 0);
+}
+
+static PyObject *
+pr_get_uint_field(PyGimpPixelRgn *self, void *closure)
+{
+ gint offset = GPOINTER_TO_INT(closure);
+ guint value;
+ gchar *addr;
+
+ addr = (gchar *)&self->pr;
+ addr += offset;
+ value = *(guint *)addr;
+
+ return PyInt_FromLong(value);
+}
+
+static PyObject *
+pr_get_dirty(PyGimpPixelRgn *self, void *closure)
+{
+ return PyBool_FromLong(self->pr.dirty);
+}
+
+static PyObject *
+pr_get_shadow(PyGimpPixelRgn *self, void *closure)
+{
+ return PyBool_FromLong(self->pr.shadow);
+}
+
+#define OFF(x) GINT_TO_POINTER(offsetof(GimpPixelRgn, x))
+static PyGetSetDef pr_getsets[] = {
+ { "drawable", (getter)pr_get_drawable, 0, NULL },
+ { "bpp", (getter)pr_get_uint_field, 0, NULL, OFF(bpp) },
+ { "rowstride", (getter)pr_get_uint_field, 0, NULL, OFF(rowstride) },
+ { "x", (getter)pr_get_uint_field, 0, NULL, OFF(x) },
+ { "y", (getter)pr_get_uint_field, 0, NULL, OFF(y) },
+ { "w", (getter)pr_get_uint_field, 0, NULL, OFF(w) },
+ { "h", (getter)pr_get_uint_field, 0, NULL, OFF(h) },
+ { "dirty", (getter)pr_get_dirty, 0, NULL },
+ { "shadow", (getter)pr_get_shadow, 0, NULL },
+ { NULL, (getter)0, (setter)0 },
+};
+#undef OFF
+
+static PyObject *
+pr_repr(PyGimpPixelRgn *self)
+{
+ PyObject *s;
+ gchar *name;
+
+ name = gimp_item_get_name(self->drawable->drawable->drawable_id);
+ s = PyString_FromFormat("<gimp.PixelRgn for drawable '%s'>", name);
+ g_free(name);
+
+ return s;
+}
+
+PyTypeObject PyGimpPixelRgn_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.PixelRgn", /* tp_name */
+ sizeof(PyGimpPixelRgn), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)pr_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)pr_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ &pr_as_mapping, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ pr_methods, /* tp_methods */
+ 0, /* tp_members */
+ pr_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+static PyObject *
+pf_get_pixel(PyGimpPixelFetcher *self, PyObject *args, PyObject *kwargs)
+{
+ int x, y;
+ guchar pixel[4];
+ static char *kwlist[] = { "x", "y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "ii:get_pixel", kwlist,
+ &x, &y))
+ return NULL;
+
+ gimp_pixel_fetcher_get_pixel(self->pf, x, y, pixel);
+
+ return PyString_FromStringAndSize((char *)pixel, self->bpp);
+}
+
+static PyObject *
+pf_put_pixel(PyGimpPixelFetcher *self, PyObject *args, PyObject *kwargs)
+{
+ int x, y, len;
+ guchar *pixel;
+ static char *kwlist[] = { "x", "y", "pixel", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "iis#:put_pixel", kwlist,
+ &x, &y, &pixel, &len))
+ return NULL;
+
+ if (len != self->bpp) {
+ PyErr_Format(PyExc_TypeError, "pixel must be %d bpp", self->bpp);
+ return NULL;
+ }
+
+ gimp_pixel_fetcher_put_pixel(self->pf, x, y, pixel);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef pf_methods[] = {
+ {"get_pixel", (PyCFunction)pf_get_pixel, METH_VARARGS | METH_KEYWORDS},
+ {"put_pixel", (PyCFunction)pf_put_pixel, METH_VARARGS | METH_KEYWORDS},
+ {NULL, NULL}
+};
+
+static int
+pf_length(PyGimpPixelFetcher *self)
+{
+ PyErr_SetString(pygimp_error, "Can't get size of pixel fetcher");
+ return -1;
+}
+
+static PyObject *
+pf_subscript(PyGimpPixelFetcher *self, PyObject *key)
+{
+ PyObject *py_x, *py_y;
+ int x, y;
+ guchar pixel[4];
+
+ if (!PyTuple_Check(key) || PyTuple_Size(key) != 2) {
+ PyErr_SetString(PyExc_TypeError, "subscript must be a 2-tuple");
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(key, "OO", &py_x, &py_y))
+ return NULL;
+
+ if (PyInt_Check(py_x)) {
+ if (PyInt_Check(py_y)) {
+ x = PyInt_AsLong(py_x);
+ y = PyInt_AsLong(py_y);
+
+ gimp_pixel_fetcher_get_pixel(self->pf, x, y, pixel);
+ return PyString_FromStringAndSize((char *)pixel, self->bpp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid y subscript");
+ return NULL;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid x subscript");
+ return NULL;
+ }
+}
+
+static int
+pf_ass_sub(PyGimpPixelFetcher *self, PyObject *v, PyObject *w)
+{
+ PyObject *py_x, *py_y;
+ int x, y, len;
+ guchar *pixel;
+
+ if (w == NULL) {
+ PyErr_SetString(PyExc_TypeError, "can't delete subscripts");
+ return -1;
+ }
+
+ if (!PyString_Check(w)) {
+ PyErr_SetString(PyExc_TypeError, "must assign string to subscript");
+ return -1;
+ }
+
+ if (!PyTuple_Check(v) || PyTuple_Size(v) != 2) {
+ PyErr_SetString(PyExc_TypeError, "subscript must be a 2-tuple");
+ return -1;
+ }
+
+ if (!PyArg_ParseTuple(v, "OO", &py_x, &py_y))
+ return -1;
+
+ pixel = (guchar *)PyString_AsString(w);
+ len = PyString_Size(w);
+
+ if (len != self->bpp) {
+ PyErr_Format(PyExc_TypeError, "pixel must be %d bpp", self->bpp);
+ return -1;
+ }
+
+ if (PyInt_Check(py_x)) {
+ if (PyInt_Check(py_y)) {
+ x = PyInt_AsLong(py_x);
+ y = PyInt_AsLong(py_y);
+
+ gimp_pixel_fetcher_put_pixel(self->pf, x, y, pixel);
+ return 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid y subscript");
+ return -1;
+ }
+ } else {
+ PyErr_SetString(PyExc_TypeError, "invalid x subscript");
+ return -1;
+ }
+}
+
+static PyMappingMethods pf_as_mapping = {
+ (lenfunc)pf_length,
+ (binaryfunc)pf_subscript,
+ (objobjargproc)pf_ass_sub,
+};
+
+static PyObject *
+pf_get_bg_color(PyGimpPixelFetcher *self, void *closure)
+{
+ return pygimp_rgb_new(&self->bg_color);
+}
+
+static int
+pf_set_bg_color(PyGimpPixelFetcher *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete bg_color");
+ return -1;
+ }
+
+ if (!pygimp_rgb_from_pyobject(value, &self->bg_color))
+ return -1;
+
+ gimp_pixel_fetcher_set_bg_color(self->pf, &self->bg_color);
+
+ return 0;
+}
+
+static PyObject *
+pf_get_edge_mode(PyGimpPixelFetcher *self, void *closure)
+{
+ return PyInt_FromLong(self->edge_mode);
+}
+
+static int
+pf_set_edge_mode(PyGimpPixelFetcher *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete edge_mode");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ self->edge_mode = PyInt_AsLong(value);
+
+ gimp_pixel_fetcher_set_edge_mode(self->pf, self->edge_mode);
+
+ return 0;
+}
+
+static PyGetSetDef pf_getsets[] = {
+ { "bg_color", (getter)pf_get_bg_color, (setter)pf_set_bg_color },
+ { "edge_mode", (getter)pf_get_edge_mode, (setter)pf_set_edge_mode },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static void
+pf_dealloc(PyGimpPixelFetcher *self)
+{
+ gimp_pixel_fetcher_destroy(self->pf);
+
+ Py_XDECREF(self->drawable);
+
+ PyObject_DEL(self);
+}
+
+static PyObject *
+pf_repr(PyGimpPixelFetcher *self)
+{
+ PyObject *s;
+ char *name;
+
+ name = gimp_item_get_name(self->drawable->drawable->drawable_id);
+
+ if (self->shadow)
+ s = PyString_FromFormat("<gimp.PixelFetcher for drawable '%s' (shadow)>", name);
+ else
+ s = PyString_FromFormat("<gimp.PixelFetcher for drawable '%s'>", name);
+
+ g_free(name);
+
+ return s;
+}
+
+static int
+pf_init(PyGimpPixelFetcher *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpDrawable *drw;
+ gboolean shadow = FALSE;
+ GimpRGB bg_color = { 0.0, 0.0, 0.0, 1.0 };
+ GimpPixelFetcherEdgeMode edge_mode = GIMP_PIXEL_FETCHER_EDGE_NONE;
+ static char *kwlist[] = { "drawable", "shadow", "bg_color", "edge_mode",
+ NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|iO&i:gimp.PixelFetcher.__init__",
+ kwlist,
+ &PyGimpDrawable_Type, &drw, &shadow,
+ pygimp_rgb_from_pyobject, &bg_color,
+ &edge_mode))
+ return -1;
+
+ if(!drw->drawable)
+ drw->drawable = gimp_drawable_get(drw->ID);
+
+ self->pf = gimp_pixel_fetcher_new(drw->drawable, shadow);
+
+ Py_INCREF(drw);
+ self->drawable = drw;
+
+ self->shadow = shadow;
+ self->bg_color = bg_color;
+ self->edge_mode = edge_mode;
+
+ self->bpp = gimp_drawable_bpp(drw->drawable->drawable_id);
+
+ gimp_pixel_fetcher_set_bg_color(self->pf, &bg_color);
+ gimp_pixel_fetcher_set_edge_mode(self->pf, edge_mode);
+
+ return 0;
+}
+
+PyTypeObject PyGimpPixelFetcher_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.PixelFetcher", /* tp_name */
+ sizeof(PyGimpPixelFetcher), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)pf_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)0, /* tp_compare */
+ (reprfunc)pf_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ &pf_as_mapping, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ pf_methods, /* tp_methods */
+ 0, /* tp_members */
+ pf_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pf_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
diff --git a/plug-ins/pygimp/pygimp-util.h b/plug-ins/pygimp/pygimp-util.h
new file mode 100644
index 0000000..9a06432
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-util.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifndef _PYGIMP_UTIL_H_
+#define _PYGIMP_UTIL_H_
+
+#include <Python.h>
+
+#include <glib-object.h>
+
+#include <pygobject.h>
+
+#define pygimp_init_pygobject() G_STMT_START { \
+ PyObject *pygtkmodule = PyImport_ImportModule("pygtk"); \
+ if (pygtkmodule != NULL) { \
+ PyObject *mdict, *require_obj, *require_ver, *require_res; \
+ mdict = PyModule_GetDict(pygtkmodule); \
+ require_obj = PyDict_GetItemString(mdict, "require"); \
+ require_ver = PyString_FromString("2.0"); \
+ require_res = PyObject_CallFunctionObjArgs(require_obj, require_ver, \
+ NULL); \
+ Py_XDECREF(require_ver); \
+ if (require_res) { \
+ Py_DECREF(require_res); \
+ if (PyErr_Occurred()) \
+ return; \
+ } else { \
+ return; \
+ } \
+ } else { \
+ PyErr_SetString(PyExc_ImportError, \
+ "could not import pygtk"); \
+ return; \
+ } \
+ init_pygobject(); \
+} G_STMT_END
+
+#endif /* _PYGIMP_UTIL_H_ */
diff --git a/plug-ins/pygimp/pygimp-vectors.c b/plug-ins/pygimp/pygimp-vectors.c
new file mode 100644
index 0000000..7ac400a
--- /dev/null
+++ b/plug-ins/pygimp/pygimp-vectors.c
@@ -0,0 +1,992 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pygimp.h"
+
+
+static PyObject *vectors_bezier_stroke_new(PyGimpVectors *vectors, int stroke);
+
+
+typedef struct {
+ PyObject_HEAD
+ gint32 vectors_ID;
+ int stroke;
+} PyGimpVectorsStroke;
+
+static PyObject *
+vs_get_length(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double precision;
+ double length;
+
+ static char *kwlist[] = { "precision", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d:get_length", kwlist,
+ &precision))
+ return NULL;
+
+ length = gimp_vectors_stroke_get_length(self->vectors_ID, self->stroke,
+ precision);
+
+ return PyFloat_FromDouble(length);
+}
+
+static PyObject *
+vs_get_point_at_dist(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double dist, precision;
+ double x, y, slope;
+ gboolean valid;
+ PyObject *ret;
+
+ static char *kwlist[] = { "dist", "precision", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dd:get_point_at_dist", kwlist,
+ &dist, &precision))
+ return NULL;
+
+ gimp_vectors_stroke_get_point_at_dist(self->vectors_ID, self->stroke,
+ dist, precision,
+ &x, &y, &slope, &valid);
+
+ ret = PyTuple_New(4);
+ if (ret == NULL)
+ return NULL;
+
+ PyTuple_SetItem(ret, 0, PyFloat_FromDouble(x));
+ PyTuple_SetItem(ret, 1, PyFloat_FromDouble(y));
+ PyTuple_SetItem(ret, 2, PyFloat_FromDouble(slope));
+ PyTuple_SetItem(ret, 3, PyBool_FromLong(valid));
+
+ return ret;
+}
+
+static PyObject *
+vs_close(PyGimpVectorsStroke *self)
+{
+ gimp_vectors_stroke_close(self->vectors_ID, self->stroke);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static PyObject *
+vs_translate(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double off_x, off_y;
+
+ static char *kwlist[] = { "off_x", "off_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dd:translate", kwlist,
+ &off_x, &off_y))
+ return NULL;
+
+ gimp_vectors_stroke_translate(self->vectors_ID, self->stroke, off_x, off_y);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vs_scale(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double scale_x, scale_y;
+
+ static char *kwlist[] = { "scale_x", "scale_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dd:scale", kwlist,
+ &scale_x, &scale_y))
+ return NULL;
+
+ gimp_vectors_stroke_scale(self->vectors_ID, self->stroke, scale_x, scale_y);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vs_rotate(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double center_x, center_y, angle;
+
+ static char *kwlist[] = { "center_x", "center_y", "angle", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ddd:rotate", kwlist,
+ &center_x, &center_y, &angle))
+ return NULL;
+
+ gimp_vectors_stroke_rotate(self->vectors_ID, self->stroke, center_x,
+ center_y, angle);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vs_flip(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ int flip_type;
+ double axis;
+
+ static char *kwlist[] = { "flip_type", "axis", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "id:flip", kwlist,
+ &flip_type, &axis))
+ return NULL;
+
+ gimp_vectors_stroke_flip(self->vectors_ID, self->stroke, flip_type, axis);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vs_flip_free(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double x1,y1,x2,y2;
+
+ static char *kwlist[] = { "x1", "y1", "x2", "y2", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "dddd:flip_free", kwlist,
+ &x1, &y1, &x2, &y2))
+ return NULL;
+
+ gimp_vectors_stroke_flip_free(self->vectors_ID, self->stroke,
+ x1, y1, x2, y2);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+
+static PyObject *
+vs_interpolate(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double precision;
+ double *coords;
+ int i, num_coords;
+ gboolean closed;
+ PyObject *ret, *ret_coords;
+
+ static char *kwlist[] = { "precision", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "d:interpolate", kwlist,
+ &precision))
+ return NULL;
+
+ coords = gimp_vectors_stroke_interpolate(self->vectors_ID, self->stroke,
+ precision, &num_coords, &closed);
+
+ ret = PyTuple_New(2);
+ if (ret == NULL)
+ return NULL;
+
+ ret_coords = PyList_New(num_coords);
+ if (ret_coords == NULL) {
+ Py_DECREF(ret);
+ return NULL;
+ }
+
+ for (i = 0; i < num_coords; i++)
+ PyList_SetItem(ret_coords, i, PyFloat_FromDouble(coords[i]));
+
+ PyTuple_SetItem(ret, 0, ret_coords);
+ PyTuple_SetItem(ret, 1, PyBool_FromLong(closed));
+
+ return ret;
+}
+
+static PyMethodDef vs_methods[] = {
+ { "get_length", (PyCFunction)vs_get_length, METH_VARARGS | METH_KEYWORDS },
+ { "get_point_at_dist", (PyCFunction)vs_get_point_at_dist, METH_VARARGS | METH_KEYWORDS },
+ { "close", (PyCFunction)vs_close, METH_NOARGS },
+ { "translate", (PyCFunction)vs_translate, METH_VARARGS | METH_KEYWORDS },
+ { "scale", (PyCFunction)vs_scale, METH_VARARGS | METH_KEYWORDS },
+ { "rotate", (PyCFunction)vs_rotate, METH_VARARGS | METH_KEYWORDS },
+ { "flip", (PyCFunction)vs_flip, METH_VARARGS | METH_KEYWORDS },
+ { "flip_free", (PyCFunction)vs_flip_free, METH_VARARGS | METH_KEYWORDS },
+ { "interpolate", (PyCFunction)vs_interpolate, METH_VARARGS | METH_KEYWORDS },
+ { NULL, NULL, 0 }
+};
+
+static PyObject *
+vs_get_ID(PyGimpVectorsStroke *self, void *closure)
+{
+ return PyInt_FromLong(self->stroke);
+}
+
+static PyObject *
+vs_get_vectors_ID(PyGimpVectorsStroke *self, void *closure)
+{
+ return PyInt_FromLong(self->vectors_ID);
+}
+
+static PyObject *
+vs_get_points(PyGimpVectorsStroke *self, void *closure)
+{
+ double *controlpoints;
+ int i, num_points;
+ gboolean closed;
+ PyObject *ret, *ret_points;
+
+ gimp_vectors_stroke_get_points(self->vectors_ID, self->stroke,
+ &num_points, &controlpoints, &closed);
+
+ ret = PyTuple_New(2);
+ if (ret == NULL)
+ return NULL;
+
+ ret_points = PyList_New(num_points);
+ if (ret_points == NULL) {
+ Py_DECREF(ret);
+ return NULL;
+ }
+
+ for (i = 0; i < num_points; i++)
+ PyList_SetItem(ret_points, i, PyFloat_FromDouble(controlpoints[i]));
+
+ PyTuple_SetItem(ret, 0, ret_points);
+ PyTuple_SetItem(ret, 1, PyBool_FromLong(closed));
+
+ return ret;
+}
+
+static PyGetSetDef vs_getsets[] = {
+ { "ID", (getter)vs_get_ID, (setter)0 },
+ { "vectors_ID", (getter)vs_get_vectors_ID, (setter)0 },
+ { "points", (getter)vs_get_points, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static void
+vs_dealloc(PyGimpVectorsStroke *self)
+{
+ PyObject_DEL(self);
+}
+
+static PyObject *
+vs_repr(PyGimpVectorsStroke *self)
+{
+ PyObject *s;
+ char *name;
+
+ name = gimp_item_get_name(self->vectors_ID);
+ s = PyString_FromFormat("<gimp.VectorsStroke %d of gimp.Vectors '%s'>",
+ self->stroke, name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+vs_cmp(PyGimpVectorsStroke *self, PyGimpVectorsStroke *other)
+{
+ if (self->vectors_ID == other->vectors_ID) {
+ if (self->stroke == other->stroke)
+ return 0;
+ if (self->stroke > other->stroke)
+ return -1;
+ return 1;
+ }
+ if (self->vectors_ID > other->vectors_ID)
+ return -1;
+ return 1;
+}
+
+PyTypeObject PyGimpVectorsStroke_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.VectorsStroke", /* tp_name */
+ sizeof(PyGimpVectorsStroke), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)vs_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)vs_cmp, /* tp_compare */
+ (reprfunc)vs_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ vs_methods, /* tp_methods */
+ 0, /* tp_members */
+ vs_getsets, /* tp_getset */
+ (PyTypeObject *)0, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)0, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+
+static PyObject *
+vbs_new_moveto(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+{
+ PyGimpVectors *vectors;
+ double x0, y0;
+ int stroke;
+
+ static char *kwlist[] = { "vectors", "x0", "y0", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!dd:new_moveto", kwlist,
+ &PyGimpVectors_Type, &vectors,
+ &x0, &y0))
+ return NULL;
+
+ stroke = gimp_vectors_bezier_stroke_new_moveto(vectors->ID, x0, y0);
+
+ return vectors_bezier_stroke_new(vectors, stroke);
+}
+
+static PyObject *
+vbs_new_ellipse(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+{
+ PyGimpVectors *vectors;
+ double x0, y0, radius_x, radius_y, angle;
+ int stroke;
+
+ static char *kwlist[] = { "vectors", "x0", "y0", "radius_x", "radius_y",
+ "angle", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!ddddd:new_ellipse", kwlist,
+ &PyGimpVectors_Type, &vectors,
+ &x0, &y0, &radius_x, &radius_y, &angle))
+ return NULL;
+
+ stroke = gimp_vectors_bezier_stroke_new_ellipse(vectors->ID, x0, y0,
+ radius_x, radius_y, angle);
+
+ return vectors_bezier_stroke_new(vectors, stroke);
+}
+
+static PyObject *
+vbs_lineto(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0;
+
+ static char *kwlist[] = { "x0", "y0", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dd:lineto", kwlist,
+ &x0, &y0))
+ return NULL;
+
+ gimp_vectors_bezier_stroke_lineto(self->vectors_ID, self->stroke, x0, y0);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vbs_conicto(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddd:conicto", kwlist,
+ &x0, &y0, &x1, &y1))
+ return NULL;
+
+ gimp_vectors_bezier_stroke_conicto(self->vectors_ID, self->stroke,
+ x0, y0, x1, y1);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vbs_cubicto(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ double x0, y0, x1, y1, x2, y2;
+
+ static char *kwlist[] = { "x0", "y0", "x1", "y1", "x2", "y2", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "dddddd:cubicto", kwlist,
+ &x0, &y0, &x1, &y1, &x2, &y2))
+ return NULL;
+
+ gimp_vectors_bezier_stroke_cubicto(self->vectors_ID, self->stroke,
+ x0, y0, x1, y1, x2, y2);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef vbs_methods[] = {
+ { "new_moveto", (PyCFunction)vbs_new_moveto, METH_VARARGS | METH_KEYWORDS | METH_CLASS },
+ { "new_ellipse", (PyCFunction)vbs_new_ellipse, METH_VARARGS | METH_KEYWORDS | METH_CLASS },
+ { "lineto", (PyCFunction)vbs_lineto, METH_VARARGS | METH_KEYWORDS },
+ { "conicto", (PyCFunction)vbs_conicto, METH_VARARGS | METH_KEYWORDS },
+ { "cubicto", (PyCFunction)vbs_cubicto, METH_VARARGS | METH_KEYWORDS },
+ { NULL, NULL, 0 }
+};
+
+static PyObject *
+vbs_repr(PyGimpVectorsStroke *self)
+{
+ PyObject *s;
+ char *name;
+
+ name = gimp_item_get_name(self->vectors_ID);
+ s = PyString_FromFormat("<gimp.VectorsBezierStroke %d of gimp.Vectors '%s'>",
+ self->stroke, name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+vbs_init(PyGimpVectorsStroke *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpVectors *vectors;
+ double *controlpoints;
+ gboolean closed = FALSE;
+ PyObject *py_controlpoints, *item;
+ int i, num_points;
+
+ static char *kwlist[] = { "vectors", "controlpoints", "closed", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!O|i:gimp.VectorsBezierStroke.__init__",
+ kwlist,
+ &PyGimpVectors_Type, &vectors,
+ &py_controlpoints, &closed))
+ return -1;
+
+ if (!PySequence_Check(py_controlpoints)) {
+ PyErr_SetString(PyExc_TypeError,
+ "controlpoints must be a sequence");
+ return -1;
+ }
+
+ num_points = PySequence_Length(py_controlpoints);
+ controlpoints = g_new(gdouble, num_points);
+
+ for (i = 0; i < num_points; i++) {
+ item = PySequence_GetItem(py_controlpoints, i);
+
+ if (!PyFloat_Check(item)) {
+ PyErr_SetString(PyExc_TypeError,
+ "controlpoints must be a sequence of floats");
+ g_free(controlpoints);
+ return -1;
+ }
+
+ controlpoints[i] = PyFloat_AsDouble(item);
+ }
+
+ self->vectors_ID = vectors->ID;
+ self->stroke =
+ gimp_vectors_stroke_new_from_points(self->vectors_ID,
+ GIMP_VECTORS_STROKE_TYPE_BEZIER,
+ num_points, controlpoints, closed);
+
+ g_free(controlpoints);
+
+ return 0;
+}
+
+PyTypeObject PyGimpVectorsBezierStroke_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.VectorsBezierStroke", /* tp_name */
+ sizeof(PyGimpVectorsStroke), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)vs_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)vs_cmp, /* tp_compare */
+ (reprfunc)vbs_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ vbs_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ &PyGimpVectorsStroke_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)vbs_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+static PyObject *
+vectors_bezier_stroke_new(PyGimpVectors *vectors, int stroke)
+{
+ PyGimpVectorsStroke *self;
+
+ self = PyObject_NEW(PyGimpVectorsStroke, &PyGimpVectorsBezierStroke_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->vectors_ID = vectors->ID;
+ self->stroke = stroke;
+
+ return (PyObject *)self;
+}
+
+
+static PyObject *
+vectors_remove_stroke(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
+{
+ int stroke_id ;
+ /* PyGimpVectorsStroke *stroke; */
+ PyObject *stroke = NULL;
+
+ static char *kwlist[] = { "stroke", NULL };
+
+ PyArg_ParseTupleAndKeywords(args, kwargs, "O:remove_stroke", kwlist, &stroke);
+
+ if (PyInt_Check(stroke))
+ stroke_id = PyInt_AsLong(stroke);
+ else if (PyObject_IsInstance(stroke, (PyObject *) &PyGimpVectorsStroke_Type))
+ stroke_id = ((PyGimpVectorsStroke *) stroke)->stroke;
+ else {
+ PyErr_SetString(PyExc_TypeError, "stroke must be a gimp.VectorsBezierStroke object or an Integer");
+ return NULL;
+ }
+
+ gimp_vectors_remove_stroke(self->ID, stroke_id);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vectors_to_selection(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
+{
+ GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
+ gboolean antialias = TRUE, feather = FALSE;
+ double feather_radius_x = 0.0, feather_radius_y = 0.0;
+
+ static char *kwlist[] = { "operation", "antialias", "feather",
+ "feather_radius_x", "feather_radius_y", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|iiidd:to_selection", kwlist,
+ &operation, &antialias, &feather,
+ &feather_radius_x, &feather_radius_y))
+ return NULL;
+
+ gimp_context_push();
+ gimp_context_set_antialias(antialias);
+ gimp_context_set_feather(feather);
+ gimp_context_set_feather_radius(feather_radius_x, feather_radius_y);
+ gimp_image_select_item(gimp_item_get_image(self->ID), operation, self->ID);
+ gimp_context_pop();
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vectors_parasite_find(PyGimpVectors *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_find", &name))
+ return NULL;
+
+ return pygimp_parasite_new(gimp_item_get_parasite(self->ID, name));
+}
+
+static PyObject *
+vectors_parasite_attach(PyGimpVectors *self, PyObject *args)
+{
+ PyGimpParasite *parasite;
+
+ if (!PyArg_ParseTuple(args, "O!:parasite_attach", &PyGimpParasite_Type,
+ &parasite))
+ return NULL;
+
+ if (!gimp_item_attach_parasite(self->ID, parasite->para)) {
+ PyErr_Format(pygimp_error,
+ "could not attach parasite '%s' to vectors (ID %d)",
+ parasite->para->name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vectors_parasite_detach(PyGimpVectors *self, PyObject *args)
+{
+ char *name;
+
+ if (!PyArg_ParseTuple(args, "s:parasite_detach", &name))
+ return NULL;
+
+ if (!gimp_item_detach_parasite(self->ID, name)) {
+ PyErr_Format(pygimp_error,
+ "could not detach parasite '%s' from vectors (ID %d)",
+ name, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+vectors_parasite_list(PyGimpVectors *self)
+{
+ gint num_parasites;
+ gchar **parasites;
+ PyObject *ret;
+ gint i;
+
+ parasites = gimp_item_get_parasite_list(self->ID, &num_parasites);
+
+ ret = PyTuple_New(num_parasites);
+
+ for (i = 0; i < num_parasites; i++)
+ PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
+
+ g_strfreev(parasites);
+ return ret;
+}
+
+static PyMethodDef vectors_methods[] = {
+ { "remove_stroke",
+ (PyCFunction)vectors_remove_stroke,
+ METH_VARARGS | METH_KEYWORDS },
+ { "to_selection",
+ (PyCFunction)vectors_to_selection,
+ METH_VARARGS | METH_KEYWORDS },
+ { "parasite_find",
+ (PyCFunction)vectors_parasite_find,
+ METH_VARARGS },
+ { "parasite_attach",
+ (PyCFunction)vectors_parasite_attach,
+ METH_VARARGS },
+ { "parasite_detach",
+ (PyCFunction)vectors_parasite_detach,
+ METH_VARARGS },
+ { "parasite_list",
+ (PyCFunction)vectors_parasite_list,
+ METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+static PyObject *
+vectors_get_image(PyGimpVectors *self, void *closure)
+{
+ return pygimp_image_new(gimp_item_get_image(self->ID));
+}
+
+static PyObject *
+vectors_get_ID(PyGimpVectors *self, void *closure)
+{
+ return PyInt_FromLong(self->ID);
+}
+
+static PyObject *
+vectors_get_name(PyGimpVectors *self, void *closure)
+{
+ return PyString_FromString(gimp_item_get_name(self->ID));
+}
+
+static int
+vectors_set_name(PyGimpVectors *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete name");
+ return -1;
+ }
+
+ if (!PyString_Check(value) && !PyUnicode_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_name(self->ID, PyString_AsString(value));
+
+ return 0;
+}
+
+static PyObject *
+vectors_get_visible(PyGimpVectors *self, void *closure)
+{
+ return PyBool_FromLong(gimp_item_get_visible(self->ID));
+}
+
+static int
+vectors_set_visible(PyGimpVectors *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete visible");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_visible(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+vectors_get_linked(PyGimpVectors *self, void *closure)
+{
+ return PyBool_FromLong(gimp_item_get_linked(self->ID));
+}
+
+static int
+vectors_set_linked(PyGimpVectors *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete linked");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_linked(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+vectors_get_tattoo(PyGimpVectors *self, void *closure)
+{
+ return PyInt_FromLong(gimp_item_get_tattoo(self->ID));
+}
+
+static int
+vectors_set_tattoo(PyGimpVectors *self, PyObject *value, void *closure)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "cannot delete tattoo");
+ return -1;
+ }
+
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "type mismatch");
+ return -1;
+ }
+
+ gimp_item_set_tattoo(self->ID, PyInt_AsLong(value));
+
+ return 0;
+}
+
+static PyObject *
+vectors_get_strokes(PyGimpVectors *self, void *closure)
+{
+ int *strokes;
+ int i, num_strokes;
+ PyObject *ret;
+
+ strokes = gimp_vectors_get_strokes(self->ID, &num_strokes);
+
+ ret = PyList_New(num_strokes);
+ if (ret == NULL)
+ return NULL;
+
+ for (i = 0; i < num_strokes; i++)
+ PyList_SetItem(ret, i, vectors_bezier_stroke_new(self, strokes[i]));
+
+ g_free(strokes);
+
+ return ret;
+}
+
+static PyGetSetDef vectors_getsets[] = {
+ { "ID", (getter)vectors_get_ID, (setter)0 },
+ { "image", (getter)vectors_get_image, (setter)0 },
+ { "name", (getter)vectors_get_name, (setter)vectors_set_name },
+ { "visible", (getter)vectors_get_visible, (setter)vectors_set_visible },
+ { "linked", (getter)vectors_get_linked, (setter)vectors_set_linked },
+ { "tattoo", (getter)vectors_get_tattoo, (setter)vectors_set_tattoo },
+ { "strokes", (getter)vectors_get_strokes, (setter)0 },
+ { NULL, (getter)0, (setter)0 }
+};
+
+static void
+vectors_dealloc(PyGimpVectors *self)
+{
+ PyObject_DEL(self);
+}
+
+static PyObject *
+vectors_repr(PyGimpVectors *self)
+{
+ PyObject *s;
+ char *name;
+
+ name = gimp_item_get_name(self->ID);
+ s = PyString_FromFormat("<gimp.Vectors '%s'>", name ? name : "(null)");
+ g_free(name);
+
+ return s;
+}
+
+static int
+vectors_cmp(PyGimpVectors *self, PyGimpVectors *other)
+{
+ if (self->ID == other->ID)
+ return 0;
+ if (self->ID > other->ID)
+ return -1;
+ return 1;
+}
+
+static int
+vectors_init(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpImage *img;
+ char *name;
+
+ static char *kwlist[] = { "image", "name", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!s:gimp.Vectors.__init__",
+ kwlist,
+ &PyGimpImage_Type, &img, &name))
+ return -1;
+
+ self->ID = gimp_vectors_new(img->ID, name);
+
+ if (self->ID < 0) {
+ PyErr_Format(pygimp_error,
+ "could not create vectors '%s' on image (ID %d)",
+ name, img->ID);
+ return -1;
+ }
+
+ return 0;
+}
+
+PyTypeObject PyGimpVectors_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "gimp.Vectors", /* tp_name */
+ sizeof(PyGimpVectors), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)vectors_dealloc, /* tp_dealloc */
+ (printfunc)0, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)vectors_cmp, /* tp_compare */
+ (reprfunc)vectors_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)0, /* tp_str */
+ (getattrofunc)0, /* tp_getattro */
+ (setattrofunc)0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ NULL, /* Documentation string */
+ (traverseproc)0, /* tp_traverse */
+ (inquiry)0, /* tp_clear */
+ (richcmpfunc)0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)0, /* tp_iter */
+ (iternextfunc)0, /* tp_iternext */
+ vectors_methods, /* tp_methods */
+ 0, /* tp_members */
+ vectors_getsets, /* tp_getset */
+ &PyGimpItem_Type, /* tp_base */
+ (PyObject *)0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)vectors_init, /* tp_init */
+ (allocfunc)0, /* tp_alloc */
+ (newfunc)0, /* tp_new */
+};
+
+PyObject *
+pygimp_vectors_new(gint32 ID)
+{
+ PyGimpVectors *self;
+
+ if (!gimp_item_is_valid(ID)) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ self = PyObject_NEW(PyGimpVectors, &PyGimpVectors_Type);
+
+ if (self == NULL)
+ return NULL;
+
+ self->ID = ID;
+
+ return (PyObject *)self;
+}
diff --git a/plug-ins/pygimp/pygimp.h b/plug-ins/pygimp/pygimp.h
new file mode 100644
index 0000000..c7d927b
--- /dev/null
+++ b/plug-ins/pygimp/pygimp.h
@@ -0,0 +1,139 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 1997-2002 James Henstridge <james@daa.com.au>
+ *
+ * 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/>.
+ */
+
+#ifndef _PYGIMP_H_
+#define _PYGIMP_H_
+
+#include <Python.h>
+
+#include <libgimp/gimp.h>
+
+#define _INSIDE_PYGIMP_
+#include "pygimp-api.h"
+
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
+#endif
+
+G_BEGIN_DECLS
+
+extern PyObject *pygimp_error;
+
+PyObject *pygimp_param_to_tuple(int nparams, const GimpParam *params);
+GimpParam *pygimp_param_from_tuple(PyObject *args, const GimpParamDef *ptype,
+ int nparams);
+
+
+extern PyTypeObject PyGimpPDB_Type;
+#define pygimp_pdb_check(v) (PyObject_TypeCheck(v, &PyGimpPDB_Type))
+PyObject *pygimp_pdb_new(void);
+
+extern PyTypeObject PyGimpPDBFunction_Type;
+#define pygimp_pdb_function_check(v) (PyObject_TypeCheck(v, &PyGimpPDBFunction_Type))
+PyObject *pygimp_pdb_function_new(const char *name, const char *blurb,
+ const char *help, const char *author,
+ const char *copyright, const char *date,
+ GimpPDBProcType proc_type,
+ int n_params, int n_return_vals,
+ GimpParamDef *params,
+ GimpParamDef *return_vals);
+
+extern PyTypeObject PyGimpImage_Type;
+#define pygimp_image_check(v) (PyObject_TypeCheck(v, &PyGimpImage_Type))
+PyObject *pygimp_image_new(gint32 ID);
+
+extern PyTypeObject PyGimpDisplay_Type;
+#define pygimp_display_check(v) (PyObject_TypeCheck(v, &PyGimpDisplay_Type))
+PyObject *pygimp_display_new(gint32 ID);
+
+extern PyTypeObject PyGimpItem_Type;
+#define pygimp_item_check(v) (PyObject_TypeCheck(v, &PyGimpItem_Type))
+PyObject *pygimp_item_new(gint32 ID);
+
+extern PyTypeObject PyGimpDrawable_Type;
+#define pygimp_drawable_check(v) (PyObject_TypeCheck(v, &PyGimpDrawable_Type))
+PyObject *pygimp_drawable_new(GimpDrawable *drawable, gint32 ID);
+
+extern PyTypeObject PyGimpLayer_Type;
+#define pygimp_layer_check(v) (PyObject_TypeCheck(v, &PyGimpLayer_Type))
+PyObject *pygimp_layer_new(gint32 ID);
+
+extern PyTypeObject PyGimpGroupLayer_Type;
+#define pygimp_layer__group_check(v) (PyObject_TypeCheck(v, &PyGimpGroupLayer_Type))
+PyObject *pygimp_group_layer_new(gint32 ID);
+
+extern PyTypeObject PyGimpChannel_Type;
+#define pygimp_channel_check(v) (PyObject_TypeCheck(v, &PyGimpChannel_Type))
+PyObject *pygimp_channel_new(gint32 ID);
+
+typedef struct {
+ PyObject_HEAD
+ GimpTile *tile;
+ PyGimpDrawable *drawable; /* we keep a reference to the drawable */
+} PyGimpTile;
+
+extern PyTypeObject PyGimpTile_Type;
+#define pygimp_tile_check(v) (PyObject_TypeCheck(v, &PyGimpTile_Type))
+PyObject *pygimp_tile_new(GimpTile *tile, PyGimpDrawable *drw);
+
+typedef struct {
+ PyObject_HEAD
+ GimpPixelRgn pr;
+ PyGimpDrawable *drawable; /* keep the drawable around */
+} PyGimpPixelRgn;
+
+extern PyTypeObject PyGimpPixelRgn_Type;
+#define pygimp_pixel_rgn_check(v) (PyObject_TypeCheck(v, &PyGimpPixelRgn_Type))
+PyObject *pygimp_pixel_rgn_new(PyGimpDrawable *drw, int x, int y,
+ int w, int h, int dirty, int shadow);
+
+typedef struct {
+ PyObject_HEAD
+ GimpParasite *para;
+} PyGimpParasite;
+
+extern PyTypeObject PyGimpParasite_Type;
+#define pygimp_parasite_check(v) (PyObject_TypeCheck(v, &PyGimpParasite_Type))
+PyObject *pygimp_parasite_new(GimpParasite *para);
+
+extern PyTypeObject PyGimpVectors_Type;
+#define pygimp_vectors_check(v) (PyObject_TypeCheck(v, &PyGimpVectors_Type))
+PyObject *pygimp_vectors_new(gint32 vectors_ID);
+
+extern PyTypeObject PyGimpVectorsStroke_Type;
+extern PyTypeObject PyGimpVectorsBezierStroke_Type;
+
+typedef struct {
+ PyObject_HEAD
+ GimpPixelFetcher *pf;
+ PyGimpDrawable *drawable; /* keep the drawable around */
+ gboolean shadow;
+ GimpRGB bg_color;
+ GimpPixelFetcherEdgeMode edge_mode;
+ int bpp;
+} PyGimpPixelFetcher;
+
+extern PyTypeObject PyGimpPixelFetcher_Type;
+#define pygimp_pixel_fetcher_check(v) (PyObject_TypeCheck(v, &PyGimpPixelFetcher_Type))
+
+G_END_DECLS
+
+#endif
diff --git a/plug-ins/pygimp/pygimpcolor-api.h b/plug-ins/pygimp/pygimpcolor-api.h
new file mode 100644
index 0000000..b741538
--- /dev/null
+++ b/plug-ins/pygimp/pygimpcolor-api.h
@@ -0,0 +1,84 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2005-2006 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifndef _PYGIMPCOLOR_API_H_
+#define _PYGIMPCOLOR_API_H_
+
+#include <Python.h>
+
+#include <libgimpcolor/gimpcolor.h>
+
+struct _PyGimpColor_Functions {
+ PyTypeObject *RGB_Type;
+ PyObject *(* rgb_new)(const GimpRGB *rgb);
+ PyTypeObject *HSV_Type;
+ PyObject *(* hsv_new)(const GimpHSV *hsv);
+ PyTypeObject *HSL_Type;
+ PyObject *(* hsl_new)(const GimpHSL *hsl);
+ PyTypeObject *CMYK_Type;
+ PyObject *(* cmyk_new)(const GimpCMYK *cmyk);
+ int (* rgb_from_pyobject)(PyObject *object, GimpRGB *color);
+};
+
+#ifndef _INSIDE_PYGIMPCOLOR_
+
+#if defined(NO_IMPORT) || defined(NO_IMPORT_PYGIMPCOLOR)
+extern struct _PyGimpColor_Functions *_PyGimpColor_API;
+#else
+struct _PyGimpColor_Functions *_PyGimpColor_API;
+#endif
+
+#define PyGimpRGB_Type (_PyGimpColor_API->RGB_Type)
+#define PyGimpHSV_Type (_PyGimpColor_API->HSV_Type)
+#define PyGimpHSL_Type (_PyGimpColor_API->HSL_Type)
+#define PyGimpCMYK_Type (_PyGimpColor_API->CMYK_Type)
+
+#define pygimp_rgb_check(v) (pyg_boxed_check((v), GIMP_TYPE_RGB))
+#define pygimp_hsv_check(v) (pyg_boxed_check((v), GIMP_TYPE_HSV))
+#define pygimp_hsl_check(v) (pyg_boxed_check((v), GIMP_TYPE_HSL))
+#define pygimp_cmyk_check(v) (pyg_boxed_check((v), GIMP_TYPE_CMYK))
+
+#define pygimp_rgb_new (_PyGimpColor_API->rgb_new)
+#define pygimp_hsv_new (_PyGimpColor_API->hsv_new)
+#define pygimp_hsl_new (_PyGimpColor_API->hsl_new)
+#define pygimp_cmyk_new (_PyGimpColor_API->cmyk_new)
+
+#define pygimp_rgb_from_pyobject (_PyGimpColor_API->rgb_from_pyobject)
+
+#define init_pygimpcolor() G_STMT_START { \
+ PyObject *gimpcolormodule = PyImport_ImportModule("gimpcolor"); \
+ if (gimpcolormodule != NULL) { \
+ PyObject *mdict = PyModule_GetDict(gimpcolormodule); \
+ PyObject *cobject = PyDict_GetItemString(mdict, "_PyGimpColor_API"); \
+ if (PyCObject_Check(cobject)) \
+ _PyGimpColor_API = PyCObject_AsVoidPtr(cobject); \
+ else { \
+ PyErr_SetString(PyExc_RuntimeError, \
+ "could not find _PyGimpColor_API object"); \
+ return; \
+ } \
+ } else { \
+ PyErr_SetString(PyExc_ImportError, \
+ "could not import gimpcolor"); \
+ return; \
+ } \
+} G_STMT_END
+
+#endif /* ! _INSIDE_PYGIMPCOLOR_ */
+
+#endif /* _PYGIMPCOLOR_API_H_ */
diff --git a/plug-ins/pygimp/pygimpcolor.h b/plug-ins/pygimp/pygimpcolor.h
new file mode 100644
index 0000000..2e98329
--- /dev/null
+++ b/plug-ins/pygimp/pygimpcolor.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * Gimp-Python - allows the writing of Gimp plugins in Python.
+ * Copyright (C) 2003 Manish Singh <yosh@gimp.org>
+ *
+ * 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/>.
+ */
+
+#ifndef _PYGIMPCOLOR_H_
+#define _PYGIMPCOLOR_H_
+
+#include <Python.h>
+
+#include <pygobject.h>
+
+#include <libgimp/gimp.h>
+
+G_BEGIN_DECLS
+
+extern PyTypeObject PyGimpRGB_Type;
+#define pygimp_rgb_check(v) (pyg_boxed_check((v), GIMP_TYPE_RGB))
+PyObject *pygimp_rgb_new(const GimpRGB *rgb);
+
+extern PyTypeObject PyGimpHSV_Type;
+#define pygimp_hsv_check(v) (pyg_boxed_check((v), GIMP_TYPE_HSV))
+PyObject *pygimp_hsv_new(const GimpHSV *hsv);
+
+extern PyTypeObject PyGimpHSL_Type;
+#define pygimp_hsl_check(v) (pyg_boxed_check((v), GIMP_TYPE_HSL))
+PyObject *pygimp_hsl_new(const GimpHSL *hsl);
+
+extern PyTypeObject PyGimpCMYK_Type;
+#define pygimp_cmyk_check(v) (pyg_boxed_check((v), GIMP_TYPE_CMYK))
+PyObject *pygimp_cmyk_new(const GimpCMYK *cmyk);
+
+int pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color);
+
+G_END_DECLS
+
+#endif