plug-ins: get rid of pygimp!

It's done, all Python plug-ins have been either ported to the new API +
Python 3, or they have been discarded (and moved to gimp-data-extras for
whoever wants to salvage them).
Let's get rid of the outdated pygimp directory (whose code has not been
built in the master branch for years now anyway)! Woohoo!
This commit is contained in:
Jehan 2020-09-21 18:17:18 +02:00
parent 2271b5bbdb
commit 0ec5ee4394
58 changed files with 4 additions and 35380 deletions

View File

@ -3053,10 +3053,6 @@ plug-ins/map-object/Makefile
plug-ins/metadata/Makefile
plug-ins/pagecurl/Makefile
plug-ins/print/Makefile
]
dnl plug-ins/pygimp/Makefile
dnl plug-ins/pygimp/plug-ins/Makefile
[
plug-ins/python/Makefile
plug-ins/python/python-console/Makefile
plug-ins/screenshot/Makefile

View File

@ -13,7 +13,6 @@ print = print
endif
if BUILD_PYTHON
pygimp = pygimp
python = python
endif
@ -27,7 +26,6 @@ endif
SUBDIRS = \
script-fu \
## $(pygimp) \
file-bmp \
$(file_darktable) \
file-dds \

View File

@ -1,22 +0,0 @@
/Makefile
/Makefile.in
/*.pyc
/*.pyo
/*.so
/*.lo
/*.la
/configure
/config.log
/config.h
/config.cache
/stamp-h
/config.h.in
/stamp-h.in
/aclocal.m4
/INSTALL
/mkinstalldirs
/install-sh
/gimpui.c
/gimpthumb.c
/.libs
/.deps

View File

@ -1,297 +0,0 @@
2006-04-28 Sven Neumann <sven@gimp.org>
* doc/pygimp.sgml: applied documentation patch contributed by
Sylvain Fourmanoit (bug #339886).
2005-10-04 Sven Neumann <sven@gimp.org>
* plug-ins/benchmark-foreground-extract.py (benchmark): removed
run-mode parameters again. Seems to have been fixed in pygimp.
2005-09-27 Sven Neumann <sven@gimp.org>
* gimpmodule.c (pygimp_progress_install): undeprecated.
2005-08-19 Sven Neumann <sven@gimp.org>
* gimpmodule.c
* gimp-drawable.c: use canonical procedure names with
gimp_run_procedure().
2005-08-06 Sven Neumann <sven@gimp.org>
* plug-ins/benchmark-foreground-extract.py: pass run-mode to PDB
calls.
2005-08-03 Sven Neumann <sven@gimp.org>
* pygimp-rgb.c: added wrapper for gimp_rgb_luminance().
2005-07-29 Sven Neumann <sven@gimp.org>
* plug-ins/benchmark-foreground-extract.py: follow PDB API change.
2005-07-18 Sven Neumann <sven@gimp.org>
* plug-ins/benchmark-foreground-extract.py: allow to have the
output images saved, made the code more robust, corrected some
mistakes.
2005-07-16 Sven Neumann <sven@gimp.org>
* plug-ins/benchmark-foreground-extract.py: show elapsed time.
2005-07-16 Sven Neumann <sven@gimp.org>
* Makefile.am
* plug-ins/benchmark-foreground-extract.py: added a rough
implementation of the foreground extraxtion benchmark as proposed
in the GrabCut paper. See comments in the file for details.
2005-06-22 Sven Neumann <sven@gimp.org>
* plug-ins/foggify.py: fixed capitalization of menu label.
2004-12-19 Sven Neumann <sven@gimp.org>
* Makefile.am: added $(pygimp_DATA) to EXTRA_DIST.
2003-02-08 Manish Singh <yosh@gimp.org>
* gimpui.py: use dialog.run() for sub dialogs, since the main dialog
is also doing that. This does break consistency with the rest of
gimp, but will do for now. I wish there was a similar API that didn't
set the dialog modal. Fixed brush and pattern list to use the new
PDB names. Also make the filesel really have a title of "Files"
* gimpshelf.py: minor clean up, use cStringIO if available
* gimpfu.py: add support for Load/Save plug-ins. Use GtkImage
instead of deprecated GtkPixmap.
* gimpenums.py: regenerated
* plug-ins/Makefile.am
* plug-ins/colorhtml.py: the return of colorhtml to 1.3
2003-01-08 Manish Singh <yosh@gimp.org>
* plug-ins/gimpcons.py: import gtkcons only when we're about to use
it. This and below allows plug-in query to work even without an
interface.
* plug-ins/pdbbrowse.py: define BrowseWin (which needs gtk) only
when we need it and are guaranteed a gui setup.
2002-11-08 Sven Neumann <sven@gimp.org>
* plug-ins/Makefile.am (EXTRA_DIST): added missing file (#98034).
2002-08-31 James Henstridge <james@daa.com.au>
* gimpfu.py (RadioEntry): add PF_RADIO support to gimpfu based on
Yosh's patch.
(_interact): swap order of buttons to match other dialogs.
2002-08-30 James Henstridge <james@daa.com.au>
* pygimp-*.c: update to list all methods. Convert no arg
functions to METH_NOARG (slight code size reduction).
* pygimp-drawable.c (PyGimpDrawable_Type): add getsets for common
drawable attributes.
(PyGimpLayer_Type): convert getattr and setattr to getsets.
(PyGimpChannel_Type): convert to getsets.
* gimpmodule.c (new_parasite): remove. Superceded by
gimp.Parasite constructor.
(pygimp_image_list): rename to match actual API.
* pygimp-parasite.c (PyGimpParasite_Type): switch to getsets.
(para_init): add constructor.
* pygimp-tile.c (PyGimpPixelRgn_Type): convert to use getsets.
(PyGimpTile_Type): convert to use getsets.
* pygimp-image.c (PyGimpImage_Type): convert getattr and setattr
routines into getsets.
2002-08-29 James Henstridge <james@daa.com.au>
* pygimp-image.c (img_repr): check if gimp_image_get_filename()
returns NULL.
* plug-ins/gimpcons.py: fix up plugin, so that I can test the rest
of pygimp.
* *.py, plug-ins/*.py: many updates to Python code to work with
new PyGTK. I can start a plug in now.
2002-08-28 James Henstridge <james@daa.com.au>
* *.c, pygimp.h: split module into multiple files, and convert
types to Python 2.2 style types. Still need to fix some of the
getattr routines.
* gimpmodule.c: various updates to get it to compile with latest
gimp. Still need to merge in changes to toplevel configure.in.
2000-09-23 Kevin Turner <acapnotic@users.sourceforge.net>
* gimpmodule.c (newpfobject): use correct type for enums
* plug-ins/gtkcons.py (Console.run): set _ after evaluating a
statement, so _ may be used as it is in the python interpreter.
2000-09-20 Kevin Turner <acapnotic@users.sourceforge.net>
* plug-ins/pdbbrowse.py (pars): Oops. When we did
s/PARAM_/PDB_/, we forgot to do s/6/4/ (the length
of the prefix changed).
* gimpmodule.c: Filter this through remove_cruft,
finishing the libgimp renaming (and further ensuring
that it won't work with older libgimps).
2000-08-10 Kevin Turner <acapnotic@users.sourceforge.net>
* gimpenums.py: This file now autogenerated by
tools/pdbgen/enumcode-py.pl
* gimpfu.py:
* gimpmodule.c: renaming fixes for libgimp 1.2
* plug-ins/pdbbrowse.py (pars): s/PARAM_/PDB_/
2000-08-09 Kevin Turner <acapnotic@users.sourceforge.net>
* gimpmodule.c (chn_getattr): under "layer", remove the call to
gimp_channel_get_layer_id() as this function does not exist. It
would be well for someone who knows pygimp better than I to review
this change, but it keeps pygimp from being *completely* broken.
1999-11-11 James Henstridge <james@daa.com.au>
* doc/pygimp.sgml: updated documentation.
* gimpmodule.c: applied patches from Hans Breuer to fix portability
problems and also win32 compatibility.
(lay_getattr): take is_rgb as a synonym for is_color/is_colour.
(drw_parasite_attach):
(drw_parasite_detach): change to new naming scheme.
(img_parasite_attach):
(img_parasite_detach): same here.
(gimp_Parasite_find):
(gimp_Parasite_attach):
(gimp_Parasite_detach): same here.
(chn_getattr): added is_rgb as a synonym for is_colour, and
is_layer_mask as a synonym for layer_mask.
1999-07-08 James Henstridge <james@daa.com.au>
* plug-ins/shadow_bevel.py: added {disable,enable}_undo() calls. Also
made it possible to turn off the creation of a shadow.
* plug-ins/foggify.py: added disable_undo() and enable_undo() calls
round the plugin code.
* plug-ins/Makefile.am: forgot to add foggify and shadow_bevel to
the EXTRA_DIST list.
* gimpui.py: fixed some small bugs that caused an exception when
loading on some versions of python. Weird thing is, it did not
cause problems on my computer (using 1.5.1)
1999-07-05 James Henstridge <james@daa.com.au>
* plug-ins/foggify.py, plug-ins/shadow_bevel.py: two new example
scripts.
1999-07-04 James Henstridge <james@daa.com.au>
* gimpmodule.c: added support for parasites. This new code is
conditionally compiled if GIMP_HAVE_PARASITES is defined.
Added other gimp 1.1 features to gimpmodule.
1999-07-03 James Henstridge <james@daa.com.au>
* gimpmodule.c (initgimp): added {major,minor,micro}_version constants
to gimpmodule.
(*) removed all the empty __doc__ strings -- they were just wasting
space, and I have other docs in there now.
* plug-ins/clothify.py (python_clothify): same here.
* plug-ins/sphere.py (python_sphere): some small hacks to get the
plugin to work with both gimp 1.0 and 1.1 -- using the pattern
"if pdb.gimp_whatever.nparams == n" to check if the img parameter
should be removed.
* plug-ins/pdbbrowse.py (BrowseWin.extension_pdb_browse): fixed
small bug.
1999-07-02 James Henstridge <james@daa.com.au>
* plug-ins/whirlpinch.py (python_whirl_pinch): adjusted plug in to
work with drawable changes.
* gimpmodule.c: removed the drawable type -- now only layer or channel
types are used. Also moved the drawable type's methods to both the
layer and channel object types. Also added some of the attributes of
the drawable object to layer and channel objects (some aren't needed
anymore, since layers are clearly defined as layers, and channels
as channels).
Make tile and pixel region objects keep a reference to their
associated drawable.
Added attributes has_alpha, is_colour, is_grey and is_indexed to
layer and channel objects.
1999-06-22 James Henstridge <james@daa.com.au>
* gimpplugin.py: renamed from plugin.py. This is mainly to reduce
namespace pollution.
* getvals.py: removed file. It has been replaced by the much more
functional gimpfu module.
* plug-ins/gimpcons.py: added a browse button that will display the
pdbbrowse window, which can then be used to choose a pdb function.
The selected pdb function gets its prototype inserted on the
command line.
* plug-ins/pdbbrowse.py: converted to use GTK+ widgets and gimpfu.
* plug-ins/gimpcons.py: converted to use gimpfu and gtkcons.py.
* plug-ings/gtkcons.py: a GTK replacement for tkcons.py.
* plug-ins/whirlpinch.py, plug-ins/sphere.py: converted these two
to use gimpfu.
* gimpshelf.py (shelf): some changes so that the gimp internal types
will pickle correctly.
* gimpmodule.c (initgimp): export the type objects for gimpmodule's
internal types. This is mainly to help get pickling to work
correctly.
(_id2*): new functions to help convert id's to the builtin types.
* plug-ins/clothify.py: converted to use gimpfu module.
1999-06-21 James Henstridge <james@daa.com.au>
* gimpfu.py: a simplified interface to writing GIMP plugins. It
handles all the user interaction stuff and saving the last used
values. It uses pygtk, so should match the interface of the rest
of gimp.
* gimpui.py: new file that implements a number of useful widgets
for use with the interfaces of plugins. It requires pygtk.
* gimpmodule.c (tuple_to_GParam): accept None for layer, channel
or drawable arguments to PDB functions. This value gets treated
like an ID of -1.
(img_cmp, lay_cmp, chn_cmp, drw_cmp): added compare functions so
that the == operator works as expected with those object types.

View File

@ -1,179 +0,0 @@
## 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
pyenvfile = $(pyenvdir)/pygimp.env
install-env-file:
$(mkinstalldirs) '$(DESTDIR)$(pyenvdir)'
echo '$(path_separator) PYTHONPATH=$${gimp_plug_in_dir}/$(pygimpbase)' > '$(DESTDIR)$(pyenvfile)'
install-data-local: install-env-file
uninstall-local:
rm -f '$(DESTDIR)$(pyenvfile)'
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

View File

@ -1,2 +0,0 @@
/Makefile
/Makefile.in

View File

@ -1,32 +0,0 @@
noinst_DATA = pygimp.html
EXTRA_DIST = \
pygimp.sgml \
pygimp.html \
structure-of-plugin.html \
procedural-database.html \
gimp-module-procedures.html \
gimp-objects.html \
support-modules.html \
end-note.html
printed: pygimp.ps pygimp.pdf
#clean:
# rm -f *.html pygimp.ps pygimp.pdf
pygimp.ps: pygimp.sgml
db2ps $(srcdir)/pygimp.sgml
pygimp.pdf: pygimp.sgml
db2pdf $(srcdir)/pygimp.sgml
pygimp.html: pygimp.sgml
cd $(srcdir) && db2html --nochunks pygimp.sgml
cd $(srcdir) && mv pygimp/*.html .
rm -rf $(srcdir)/pygimp
.PHONY: printed #clean

View File

@ -1,123 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
<HTML
><HEAD
><TITLE
>End Note</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet"><LINK
REL="HOME"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="PREVIOUS"
TITLE="Support Modules"
HREF="support-modules.html"></HEAD
><BODY
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gimp Python Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="support-modules.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
>&nbsp;</TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="END-NOTE"
>End Note</A
></H1
><P
>This package is not yet complete, but it has enough in it to
be useful for writing plugins for Gimp. If you write any plugins
that might be useful as examples, please mail me at <A
HREF="mailto:james@daa.com.au"
TARGET="_top"
>james@daa.com.au</A
>.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="support-modules.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="pygimp.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Support Modules</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
pygimp_ps = custom_target('pygimp.ps',
input : [ 'pygimp.sgml' ],
output: [ 'pygimp.ps' ],
command: [
'db2ps',
'@INPUT@'
],
)
pygimp_pdf = custom_target('pygimp.pdf',
input : [ 'pygimp.sgml' ],
output: [ 'pygimp.pdf' ],
command: [
'db2pdf',
'@INPUT@'
],
)
pygimp_html = custom_target('pygimp.html',
input : [ 'pygimp.sgml' ],
output: [ 'pygimp.html' ],
command: [
'db2html', '--nochunks',
'@INPUT@'
],
)

View File

@ -1,361 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
<HTML
><HEAD
><TITLE
>The Procedural Database</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet"><LINK
REL="HOME"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="PREVIOUS"
TITLE="The Structure Of A Plugin"
HREF="structure-of-plugin.html"><LINK
REL="NEXT"
TITLE="Gimp Module Procedures"
HREF="gimp-module-procedures.html"></HEAD
><BODY
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gimp Python Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="structure-of-plugin.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="gimp-module-procedures.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="PROCEDURAL-DATABASE"
>The Procedural Database</A
></H1
><P
>The procedural database is a registry of things gimp and its
plugins can do. When you install a procedure for your plugin, you
are extending the procedural database.</P
><P
>The procedural database is self documenting, in that when
you install a procedure in it, you also add documentation for it,
its parameters and return values.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMP-PYTHON-MODEL"
>The Gimp-Python Model</A
></H2
><P
>In Gimp-Python, the procedural database is represented by
the object <TT
CLASS="PARAMETER"
><I
>gimp.pdb</I
></TT
>. In most of my
plugins, I make an assignment from <TT
CLASS="PARAMETER"
><I
>gimp.pdb</I
></TT
>
to <TT
CLASS="PARAMETER"
><I
>pdb</I
></TT
> for convenience.</P
><P
>You can query the procedural database with
<TT
CLASS="PARAMETER"
><I
>pdb</I
></TT
>'s method <TT
CLASS="FUNCTION"
><B
>query</B
></TT
>. Its
specification is:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>pdb.query(name, [blurb, [help, [author, [copyright, [date, [type]]]]]])</PRE
></TD
></TR
></TABLE
><P
>Each parameter is a regular expression that is checked
against the corresponding field in the procedural database. The
method returns a list of the names of matching procedures. If
<TT
CLASS="FUNCTION"
><B
>query</B
></TT
> is called without any arguments, it will
return every procedure in the database.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="PDB-PROCEDURES"
>Procedural Database Procedures</A
></H2
><P
>Procedures can be accessed as procedures, or by treating
<TT
CLASS="PARAMETER"
><I
>pdb</I
></TT
> as a mapping objest. As an example,
the probedure <TT
CLASS="FUNCTION"
><B
>gimp_edit_fill</B
></TT
> can be
accessed as either <TT
CLASS="FUNCTION"
><B
>pdb.gimp_edit_fill</B
></TT
> or
<TT
CLASS="FUNCTION"
><B
>pdb['gimp_edit_fill']</B
></TT
>. The second form is
mainly for procedures whose names are not valid Python names (eg
in script-fu-..., the dashes are interpreted as minuses).</P
><P
>These procedure objects have a number of attribute:</P
><P
></P
><DL
><DT
>proc_name</DT
><DD
><P
>The name of the procedure.</P
></DD
><DT
>proc_blurb</DT
><DD
><P
>A short piece of information about the procedure.</P
></DD
><DT
>proc_help</DT
><DD
><P
>More detailed information about the procedure.</P
></DD
><DT
>proc_author</DT
><DD
><P
>The author of the procedure.</P
></DD
><DT
>proc_copyright</DT
><DD
><P
>The copyright holder for the procedure (usually the
same as the author).</P
></DD
><DT
>proc_date</DT
><DD
><P
>The date when the procedure was written.</P
></DD
><DT
>proc_type</DT
><DD
><P
>The type of procedure. This will be one of
PROC_PLUG_IN, PROC_EXTENSION or PROC_TEMPORARY.</P
></DD
><DT
>nparams</DT
><DD
><P
>The number of parameters the procedure takes.</P
></DD
><DT
>nreturn_vals</DT
><DD
><P
>The number of return values the procedure gives.</P
></DD
><DT
>params</DT
><DD
><P
>A description of parameters of the procedure. It
takes the form of a tuple of 3-tuples, where each 3-tuple
describes a parameter. The items in the 3-tuple are a
parameter type (one of the PARAM_* constants), a
name for the parameter, and a description of the
parameter.</P
></DD
><DT
>return_vals</DT
><DD
><P
>A description of the return values. It takes the
same form as the <TT
CLASS="LITERAL"
>params</TT
>
attribute.</P
></DD
></DL
><P
>A procedure object may also be called. At this point,
Gimp-Python doesn't support keyword arguments for PDB
procedures. Arguments are passed to the procedure in the normal
method. The return depends on the number of return values:</P
><P
></P
><UL
><LI
><P
>If there are zero return values,
<TT
CLASS="LITERAL"
>None</TT
> is returned.</P
></LI
><LI
><P
>If there is only a single return value, it is
returned.</P
></LI
><LI
><P
>If there are more return values, then they are
returned as a tuple.</P
></LI
></UL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="MORE-INFORMATION"
>More Information</A
></H2
><P
>For more information on invoking PDB procedures, please
see the example plugins. For information on individual
procedures, please see the PDB Browser plugin (in the Xtns
menu). It allows you to peruse the database
interactively.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="structure-of-plugin.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="pygimp.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="gimp-module-procedures.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>The Structure Of A Plugin</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Gimp Module Procedures</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,573 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
<HTML
><HEAD
><TITLE
>The Structure Of A Plugin</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet"><LINK
REL="HOME"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="PREVIOUS"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="NEXT"
TITLE="The Procedural Database"
HREF="procedural-database.html"></HEAD
><BODY
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gimp Python Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="pygimp.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="procedural-database.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="STRUCTURE-OF-PLUGIN"
>The Structure Of A Plugin</A
></H1
><P
>The majority of code in this package resides in
<TT
CLASS="FILENAME"
>gimpmodule.c</TT
>, but this provides a poor
interface for implementing some portions of a plugin. For this
reason, there is a python module called
<TT
CLASS="FILENAME"
>plugin.py</TT
> that sets out a structure for
plugins and implements some things that were either too difficult
or impossible to do in C.</P
><P
>The main purpose of <TT
CLASS="FILENAME"
>plugin.py</TT
> was to
implement an object oriented structure for plug-ins. As well as
this, it handles tracebacks, which are otherwise ignored by
<TT
CLASS="FILENAME"
>libgimp</TT
>, and gives a method to call
other Gimp-Python plug-ins without going through the procedural
database.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="EXAMPLE-PLUGIN"
>An Example Plugin</A
></H2
><P
>As in a lot of manuals, the first thing you examine is an
example, so here is an example. I have included it before
explaining what it does to allow more advanced programmers to
see the structure up front. It is a translation of the clothify
Script-Fu extension:</P
><DIV
CLASS="EXAMPLE"
><P
><B
>Example 1. A sample python plugin</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#!/usr/bin/python
import math
from gimpfu import *
have_gimp11 = gimp.major_version &#62; 1 or \
gimp.major_version == 1 and gimp.minor_version &#62;= 1
def python_clothify(timg, tdrawable, bx=9, by=9,
azimuth=135, elevation=45, depth=3):
bx = 9 ; by = 9 ; azimuth = 135 ; elevation = 45 ; depth = 3
width = tdrawable.width
height = tdrawable.height
img = gimp.image(width, height, RGB)
layer_one = gimp.layer(img, "X Dots", width, height, RGB_IMAGE,
100, NORMAL_MODE)
img.disable_undo()
if have_gimp11:
pdb.gimp_edit_fill(layer_one)
else:
pdb.gimp_edit_fill(img, layer_one)
img.add_layer(layer_one, 0)
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.add_layer(layer_two, 0)
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 specified layer look like it is printed on cloth",
"Make the specified layer look like it is printed on cloth",
"James Henstridge",
"James Henstridge",
"1997-1999",
"&#60;Image&#62;/Filters/Artistic/Clothify",
"RGB*, GRAY*",
[
(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)
],
[],
python_clothify)
main()</PRE
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="IMPORTANT-MODULES"
>Import Modules</A
></H2
><P
>In this plugin, a number of modules are imported. The
important ones are:</P
><P
></P
><UL
><LI
><P
><TT
CLASS="FILENAME"
>gimpfu</TT
>: this module provides a
simple interface for writing plugins, similar to what
script-fu provides. It provides the GUI for entering in
parameters in interactive mode and performs some sanity
checks when registering the plugin.</P
><P
>By using "from gimpfu import *", this module also
provides an easy way to get all the commonly used symbols
into the plugin's namespace.</P
></LI
><LI
><P
><TT
CLASS="FILENAME"
>gimp</TT
>: the main part of the gimp
extension. This is imported with gimpfu.</P
></LI
><LI
><P
><TT
CLASS="FILENAME"
>gimpenums</TT
>: a number of useful
constants. This is also automatically imported with
gimpfu.</P
></LI
></UL
><P
>The pdb variable is a variable for accessing the
procedural database. It is imported into the plugin's namespace
with gimpfu for convenience.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="PLUGIN-FRAMEWORK"
>Plugin Framework</A
></H2
><P
>With pygimp-0.4, the gimpfu module was introduced. It
simplifies writing plugins a lot. It handles the run mode
(interactive, non interactive or run with last values),
providing a GUI for interactive mode and saving the last used
settings.</P
><P
>Using the gimpfu plugin, all you need to do is write the
function that should be run, make a call to
<TT
CLASS="FUNCTION"
><B
>register</B
></TT
>, and finally a call to
<TT
CLASS="FUNCTION"
><B
>main</B
></TT
> to get the plugin started.</P
><P
>If the plugin is to be run on an image, the first
parameter to the plugin function should be the image, and the
second should be the current drawable (do not worry about the
run_mode parameter). Plugins that do not act on an existing
image (and hence go in the toolbox's menus) do not need these
parameters. Any other parameters are specific to the
plugin.</P
><P
>After defining the plugin function, you need to call
<TT
CLASS="FUNCTION"
><B
>register</B
></TT
> to register the plugin with gimp
(When the plugin is run to query it, this information is passed
to gimp. When it is run interactively, this information is used
to construct the GUI). The parameters to
<TT
CLASS="FUNCTION"
><B
>register</B
></TT
> are:</P
><P
></P
><TABLE
BORDER="0"
><TR
><TD
>name</TD
></TR
><TR
><TD
>blurb</TD
></TR
><TR
><TD
>help</TD
></TR
><TR
><TD
>author</TD
></TR
><TR
><TD
>copyright</TD
></TR
><TR
><TD
>date</TD
></TR
><TR
><TD
>menupath</TD
></TR
><TR
><TD
>imagetypes</TD
></TR
><TR
><TD
>params</TD
></TR
><TR
><TD
>results</TD
></TR
><TR
><TD
>function</TD
></TR
></TABLE
><P
></P
><P
>Most of these parameters are quite self explanatory. The
menupath option should start with &#60;Image%gt;/ for image
plugins and &#60;Toolbox&#62;/ for toolbox plugins. The remainder
of the menupath is a slash separated path to its menu item.</P
><P
>The params parameter holds a list parameters for the
function. It is a list of tuples. Note that you do not have to
specify the run_type, image or drawable parameters, as gimpfu
will add these automatically for you. The tuple format is
(type, name, description, default [, extra]). The allowed type
codes are:</P
><P
></P
><TABLE
BORDER="0"
><TR
><TD
>PF_INT8</TD
></TR
><TR
><TD
>PF_INT16</TD
></TR
><TR
><TD
>PF_INT32</TD
></TR
><TR
><TD
>PF_INT</TD
></TR
><TR
><TD
>PF_FLOAT</TD
></TR
><TR
><TD
>PF_STRING</TD
></TR
><TR
><TD
>PF_VALUE</TD
></TR
><TR
><TD
>PF_INT8ARRAY</TD
></TR
><TR
><TD
>PF_INT16ARRAY</TD
></TR
><TR
><TD
>PF_INT32ARRAY</TD
></TR
><TR
><TD
>PF_INTARRAY</TD
></TR
><TR
><TD
>PF_FLOATARRAY</TD
></TR
><TR
><TD
>PF_STRINGARRAY</TD
></TR
><TR
><TD
>PF_COLOR</TD
></TR
><TR
><TD
>PF_COLOUR</TD
></TR
><TR
><TD
>PF_REGION</TD
></TR
><TR
><TD
>PF_IMAGE</TD
></TR
><TR
><TD
>PF_LAYER</TD
></TR
><TR
><TD
>PF_CHANNEL</TD
></TR
><TR
><TD
>PF_DRAWABLE</TD
></TR
><TR
><TD
>PF_TOGGLE</TD
></TR
><TR
><TD
>PF_BOOL</TD
></TR
><TR
><TD
>PF_SLIDER</TD
></TR
><TR
><TD
>PF_SPINNER</TD
></TR
><TR
><TD
>PF_ADJUSTMENT</TD
></TR
><TR
><TD
>PF_FONT</TD
></TR
><TR
><TD
>PF_FILE</TD
></TR
><TR
><TD
>PF_BRUSH</TD
></TR
><TR
><TD
>PF_PATTERN</TD
></TR
><TR
><TD
>PF_GRADIENT</TD
></TR
></TABLE
><P
></P
><P
>These values map onto the standard PARAM_* constants. The
reason to use the extra constants is that they give gimpfu more
information, so it can produce a better interface (for instance,
the PF_FONT type is equivalent to PARAM_STRING, but in the GUI
you get a small button that will bring up a font selection
dialog).</P
><P
>The PF_SLIDER, PF_SPINNER and PF_ADJUSTMENT types require
the extra parameter. It is of the form (min, max, step), and
gives the limits for the spin button or slider.</P
><P
>The results parameter is a list of 3-tuples of the form
(type, name, description). It defines the return values for the
function. If there is only a single return value, the plugin
function should return just that value. If there is more than
one, the plugin function should return a tuple of results.</P
><P
>The final parameter to <TT
CLASS="FUNCTION"
><B
>register</B
></TT
> is
the plugin function itself.</P
><P
>After registering one or more plugin functions, you must
call the <TT
CLASS="FUNCTION"
><B
>main</B
></TT
> function. This will cause
the plugin to start running. A GUI will be displayed when
needed, and your plugin function will be called at the
appropriate times.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="pygimp.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="pygimp.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="procedural-database.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Gimp Python Documentation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>The Procedural Database</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

View File

@ -1,259 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
<HTML
><HEAD
><TITLE
>Support Modules</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet"><LINK
REL="HOME"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="PREVIOUS"
TITLE="Gimp Objects"
HREF="gimp-objects.html"><LINK
REL="NEXT"
TITLE="End Note"
HREF="end-note.html"></HEAD
><BODY
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gimp Python Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="gimp-objects.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="end-note.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SUPPORT-MODULES"
>Support Modules</A
></H1
><P
>This section describes the modules that help make using the
<TT
CLASS="FILENAME"
>gimp</TT
> module easier. These range from a set
of constants to storing persistent data.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPENUMS-MODULE"
>The gimpenums Module</A
></H2
><P
>This module contains all the constants found in the header
<TT
CLASS="FILENAME"
>libgimp/gimpenums.h</TT
>, as well as some extra
constants that are available in Script-Fu.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1468"
>The gimpfu Module</A
></H2
><P
>This module was fully described in an earlier section. It
provides an easy interface for writing plugins, where you do not
need to worry about run_modes, GUI's and saving previous values.
It is the recommended module for writing plugins.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPPLUGIN-MODULE"
>The gimpplugin Module</A
></H2
><P
>This module provides the framework for writing Gimp
plugins in Python. It gives more flexibility for writing
plugins than the gimpfu module, but does not offer as many
features (such as automatic GUI building).</P
><P
>To use this framework you subclass
<TT
CLASS="FUNCTION"
><B
>gimpplugin.plugin</B
></TT
> like so:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>import gimpplugin
class myplugin(gimpplugin.plugin):
def init(self):
# initialisation routines
# called when gimp starts.
def quit(self):
# clean up routines
# called when gimp exits (normally).
def query(self):
# called to find what functionality the plugin provides.
gimp.install_procedure("procname", ...)
# note that this method name matches the first arg of
# gimp.install_procedure
def procname(self, arg1, ...):
# do what ever this plugin should do</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPSHELF-MODULE"
>The gimpshelf Module</A
></H2
><P
>This module gives a nicer interface to the persistent
storage interface for Gimp plugins. Due to the complicated
nature of Python objects (there is often a lot of connections
between them), it can be difficult to work out what to store in
gimp's persistent storage. The python interface only allows
storage of strings, so this module wraps pickle and unpickle to
allow persistentstorage of any python object.</P
><P
>Here is some examples of using this module:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>&#62;&#62;&#62; from gimpshelf import shelf
&#62;&#62;&#62; shelf['james'] = ['forty-two', (42, 42L, 42.0)]
&#62;&#62;&#62; shelf.has_key('james')
1
&#62;&#62;&#62; shelf['james']
['forty-two', (42, 42L, 42.0)]</PRE
></TD
></TR
></TABLE
><P
>Anything you store with
<TT
CLASS="FUNCTION"
><B
>gimpshelf.shelf</B
></TT
> will exist until Gimp
exits. This makes this interface perfect for when a plugin is
executed with the run mode
<TT
CLASS="LITERAL"
>RUN_WITH_LAST_VALS</TT
>.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="gimp-objects.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="pygimp.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="end-note.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Gimp Objects</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>End Note</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

View File

@ -1,9 +0,0 @@
;; -*- scheme -*-
;; from libgimpbase, implemented manually in pygimp-parasite.c
(define-boxed GimpParasite
(in-module "Gimp")
(c-name "GimpParasite")
(gtype-id "GIMP_TYPE_PARASITE")
)

View File

@ -1,25 +0,0 @@
;; -*- 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")
)

View File

@ -1,433 +0,0 @@
/* -*- 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");
}

View File

@ -1,338 +0,0 @@
;; -*- 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")
)
)

View File

@ -1,50 +0,0 @@
# 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

View File

@ -1,174 +0,0 @@
/* -*- 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");
}

View File

@ -1,873 +0,0 @@
# 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):
"""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)
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) = _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 ...
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) = _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) = _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()
grid = gtk.Grid ()
grid.set_row_spacing(6)
grid.set_column_spacing(6)
vbox.pack_start(grid, expand=False)
grid.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)
grid.attach(label, 1, i, 1, 1)
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)
grid.attach(wid, 2, i, 1, 1)
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]
min_args = 0
if len(params) > 1:
for i in range(1, len(params)):
param_type = _obj_mapping[script_params[i - 1][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[1:])
except CancelError:
return
else:
res = apply(func, params[1:])
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

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
# 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()

View File

@ -1,92 +0,0 @@
# 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

View File

@ -1,312 +0,0 @@
;; -*- 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")
)

View File

@ -1,102 +0,0 @@
%%
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));
}

View File

@ -1,60 +0,0 @@
/* -*- 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");
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,227 +0,0 @@
# 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()

View File

@ -1,97 +0,0 @@
/* -*- 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");
}

View File

@ -1,155 +0,0 @@
if have_python
subdir('doc')
subdir('plug-ins')
# pwd = meson.current_source_dir()
# pygtk_generator = generator(pygobjectcodegen,
# arguments: [
# '--override', pwd / '@BASENAME@.override',
# '--register', pygtk_defsdir / 'gdk-types.defs',
# '--register', pygtk_defsdir / 'gtk-types.defs',
# '--register', pwd / 'gimp-types.defs',
# '--register', pwd / 'gimpcolor-types.defs',
# '--register', pwd / 'gimpenums-types.defs',
# '--prefix', '@BASENAME@',
# '@INPUT@',
# ],
# output: '@BASENAME@.c',
# capture: true,
# )
python_so_libs = [
{
'name': 'gimp',
'srcs': [
'gimpmodule.c',
'pygimp-display.c',
'pygimp-drawable.c',
'pygimp-image.c',
'pygimp-item.c',
'pygimp-parasite.c',
'pygimp-pdb.c',
'pygimp-tile.c',
'pygimp-vectors.c',
],
'deps': [
py2cairo,
cairo,
gtk3,
],
'link': [
libgimp,
libgimpbase,
libgimpcolor,
libgimpui,
],
},
{ 'name': '_gimpenums',
'srcs': 'gimpenumsmodule.c',
'deps': [
gobject,
cairo,
gtk3,
],
'link': [
libgimp,
libgimpbase,
],
},
{ 'name': '_gimpui',
'srcs': 'gimpuimodule.c',
'deps': [
py2cairo,
gtk3,
],
'link': [
libgimp,
libgimpbase,
libgimpcolor,
libgimpconfig,
libgimpui,
libgimpwidgets
],
},
{ 'name': 'gimpcolor',
'srcs': [
'gimpcolormodule.c',
'pygimp-colors.c',
],
'deps': [
cairo
],
'link': [
libgimpcolor,
],
},
{ 'name': 'gimpthumb',
'srcs': 'gimpthumbmodule.c',
'deps': [],
'link': [
libgimpthumb,
],
},
]
foreach pylib : python_so_libs
name = pylib.get('name')
srcs = pylib.get('srcs')
deps = pylib.get('deps')
link = pylib.get('link')
shared_library(name,
srcs,
include_directories: [ rootInclude, ],
dependencies: deps + [
libpython2, py2gobject,
gdk_pixbuf, gegl,
],
link_with: link,
c_args: '-DGIMP_DEPRECATED_REPLACE_NEW_API',
name_prefix: '',
install: true,
install_dir: gimpplugindir / 'python',
)
endforeach
install_data([
'gimpenums.py',
'gimpfu.py',
'gimpplugin.py',
'gimpshelf.py',
'gimpui.py',
'pygimp-logo.png',
],
install_dir: gimpplugindir / 'python',
)
path_separator = platform_windows ? ';' : ':'
custom_target('pygimp.env',
output: [ 'pygimp.env' ],
command: [
'echo', path_separator + ' PYTHONPATH=${gimp_plug_in_dir}/python'
],
capture: true,
install: true,
install_dir: gimpplugindir / 'environ',
)
custom_target('pygimp.interp',
output: [ 'pygimp.interp' ],
command: [ 'echo',
'python=' + python2.path() + '\n' +
'python2=' + python2.path() + '\n' +
'/usr/bin/python=' + python2.path() + '\n' +
':Python:E::py::python2:'
],
capture: true,
install: true,
install_dir: gimpplugindir / 'interpreters',
)
endif

View File

@ -1,19 +0,0 @@
/Makefile
/Makefile.in
/*.pyc
/*.pyo
/benchmark-foreground-extract/benchmark-foreground-extract.py
/clothify/clothify.py
/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
/shadow_bevel/shadow_bevel.py
/sphere/sphere.py
/whirlpinch/whirlpinch.py

View File

@ -1,27 +0,0 @@
plugins = [
'colorxhtml',
'foggify',
'gradients-save-as-css',
'histogram-export',
'palette-sort',
'py-slice',
'python-eval',
'spyro_plus',
]
if not stable
plugins += [
'benchmark-foreground-extract',
'clothify',
'shadow_bevel',
'sphere',
'whirlpinch',
]
endif
foreach plugin : plugins
name = plugin
srcs = name + '.py'
install_data(srcs, install_dir: gimpplugindir / name)
endforeach

View File

@ -1,72 +0,0 @@
#!/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 || :

View File

@ -1,122 +0,0 @@
/* -*- 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_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,140 +0,0 @@
/* -*- 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 */
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
/* 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__ */

View File

@ -1,181 +0,0 @@
/* -*- 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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,216 +0,0 @@
/* -*- 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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
/* -*- 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_ */

View File

@ -1,992 +0,0 @@
/* -*- 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;
}

View File

@ -1,139 +0,0 @@
/* -*- 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

View File

@ -1,50 +0,0 @@
%define ver 0.3
%define prefix /usr
%define py_ver 1.5
%define gimp_ver 1.0
Name: pygimp
Version: %ver
Release: 1
Summary: A python extension allowing you to write Gimp plugins in Python
Copyright: GPL
Group: X11/Applications/Graphics
Packager: James Henstridge <james@daa.com.au>
Requires: gimp python
Source: ftp://ftp.daa.com.au/pub/james/pygimp/pygimp-%{ver}.tar.gz
BuildRoot: /tmp/pygimp-root
%description
pygimp allows you to write Gimp plugins with the python language. Unlike
script-fu scripts which only have access to functions in the PDB (procedural
database), pygimp plugins have access to all functionality that C plugins
have, including direct pixel manipulation that is required for many plugins.
%prep
%setup
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix}
%build
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%files
%{prefix}/lib/python%{py_ver}/site-packages/gimpmodule.so
%{prefix}/lib/python%{py_ver}/site-packages/gimpenums.py*
%{prefix}/lib/python%{py_ver}/site-packages/plugin.py*
%{prefix}/lib/python%{py_ver}/site-packages/gimpshelf.py*
%{prefix}/lib/python%{py_ver}/site-packages/getvals.py*
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/clothify.py
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/tkcons.py
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/gimpcons.py
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/pdbbrowse.py
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/sphere.py
%{prefix}/lib/gimp/%{gimp_ver}/plug-ins/whirlpinch.py
%doc README NEWS COPYING doc/*.html

View File

@ -1,84 +0,0 @@
/* -*- 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_ */

View File

@ -1,50 +0,0 @@
/* -*- 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

View File

@ -22,7 +22,6 @@ plug-ins/imagemap/imap_csim_parse.c
plug-ins/imagemap/imap_ncsa_parse.c
plug-ins/imagemap/y.tab.c
plug-ins/metadata/interface.c
plug-ins/pygimp
plug-ins/python
plug-ins/script-fu
tools

View File

@ -3,18 +3,15 @@
[encoding: UTF-8]
#plug-ins/pygimp/gimpfu.py
#plug-ins/pygimp/gimpui.py
#plug-ins/pygimp/plug-ins/histogram-export.py
#plug-ins/pygimp/plug-ins/palette-sort.py
#plug-ins/pygimp/plug-ins/shadow_bevel.py
plug-ins/python/benchmark-foreground-extract.py
plug-ins/python/colorxhtml.py
plug-ins/python/foggify.py
plug-ins/python/gradients-save-as-css.py
plug-ins/python/histogram-export.py
plug-ins/python/palette-offset.py
plug-ins/python/palette-sort.py
plug-ins/python/palette-to-gradient.py
plug-ins/python/py-slice.py
plug-ins/python/python-console/python-console.py
plug-ins/python/python-eval.py
plug-ins/python/spyro-plus.py

View File

@ -55,5 +55,3 @@ plug-ins/twain
plug-ins/ui
plug-ins/win-snap
tools
plug-ins/pygimp

View File

@ -46,7 +46,6 @@ plug-ins/map-object
plug-ins/metadata
plug-ins/pagecurl
plug-ins/print
plug-ins/pygimp
plug-ins/python
plug-ins/screenshot
plug-ins/script-fu/scripts/contactsheet.scm