Commit 20efe460 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

plug-ins/pygimp/Makefile.am plug-ins/pygimp/gimpthumb.defs

2006-09-17  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/Makefile.am
        * plug-ins/pygimp/gimpthumb.defs
        * plug-ins/pygimp/gimpthumb.override
        * plug-ins/pygimp/gimpthumbmodule.c: Bindings for libgimpthumb.
parent 152af52b
2006-09-17 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/Makefile.am
* plug-ins/pygimp/gimpthumb.defs
* plug-ins/pygimp/gimpthumb.override
* plug-ins/pygimp/gimpthumbmodule.c: Bindings for libgimpthumb.
2006-09-17 Sven Neumann <sven@gimp.org>
* app/core/gimp-user-install.c (user_install_migrate_files):
......
......@@ -15,3 +15,4 @@ INSTALL
mkinstalldirs
install-sh
gimpui.c
gimpthumb.c
......@@ -7,6 +7,7 @@ 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
......@@ -26,7 +27,7 @@ pygimpbase = python
pygimpdir = $(gimpplugindir)/$(pygimpbase)
pygimp_LTLIBRARIES = gimp.la _gimpenums.la gimpcolor.la _gimpui.la \
gimpprocbrowser.la
gimpthumb.la gimpprocbrowser.la
gimp_la_SOURCES = \
gimpmodule.c \
......@@ -100,6 +101,18 @@ _gimpui_la_LIBADD = \
$(RT_LIBS) \
$(INTLLIBS)
gimpthumb_la_SOURCES = \
gimpthumbmodule.c \
gimpthumb.c
gimpthumb_la_LDFLAGS = -module -avoid-version $(no_undefined) \
-export-symbols-regex initgimpthumb
gimpthumb_la_LIBADD = \
$(libgimpthumb) \
$(GDK_PIXBUF_LIBS) \
$(PYLINK_LIBS)
gimpprocbrowser_la_SOURCES = \
procbrowser.c
......@@ -159,7 +172,9 @@ EXTRA_DIST = \
gimpui.c: gimpui.defs gimpui.override gimpcolor-types.defs gimpenums-types.defs
CLEANFILES = gimpui.c
gimpthumb.c: gimpthumb.defs gimpthumb.override
CLEANFILES = gimpui.c gimpthumb.c
.defs.c:
(cd $(srcdir) \
......
;; -*- 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")
)
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgimpthumb/gimpthumb.h>
%%
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));
}
/* -*- 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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#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 plugins"
;
DL_EXPORT(void)
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");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment