~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/pygimp/gimpenumsmodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset: 4 -*-
 
2
    Gimp-Python - allows the writing of Gimp plugins in Python.
 
3
    Copyright (C) 2005  Manish Singh <yosh@gimp.org>
 
4
 
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 2 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software
 
17
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
18
    02111-1307, USA.
 
19
 */
 
20
 
 
21
#ifdef HAVE_CONFIG_H
 
22
#  include <config.h>
 
23
#endif
 
24
 
 
25
#include <Python.h>
 
26
 
 
27
#include <glib-object.h>
 
28
 
 
29
#include <pygobject.h>
 
30
 
 
31
#include "pygimp-api.h"
 
32
#include "pygimp-util.h"
 
33
 
 
34
 
 
35
static void
 
36
add_misc_enums(PyObject *m)
 
37
{
 
38
    PyModule_AddIntConstant(m, "PARASITE_PERSISTENT",
 
39
                            GIMP_PARASITE_PERSISTENT);
 
40
    PyModule_AddIntConstant(m, "PARASITE_UNDOABLE",
 
41
                            GIMP_PARASITE_UNDOABLE);
 
42
    PyModule_AddIntConstant(m, "PARASITE_ATTACH_PARENT",
 
43
                            GIMP_PARASITE_ATTACH_PARENT);
 
44
    PyModule_AddIntConstant(m, "PARASITE_PARENT_PERSISTENT",
 
45
                            GIMP_PARASITE_PARENT_PERSISTENT);
 
46
    PyModule_AddIntConstant(m, "PARASITE_PARENT_UNDOABLE",
 
47
                            GIMP_PARASITE_PARENT_UNDOABLE);
 
48
    PyModule_AddIntConstant(m, "PARASITE_ATTACH_GRANDPARENT",
 
49
                            GIMP_PARASITE_ATTACH_GRANDPARENT);
 
50
    PyModule_AddIntConstant(m, "PARASITE_GRANDPARENT_PERSISTENT",
 
51
                            GIMP_PARASITE_GRANDPARENT_PERSISTENT);
 
52
    PyModule_AddIntConstant(m, "PARASITE_GRANDPARENT_UNDOABLE",
 
53
                            GIMP_PARASITE_GRANDPARENT_UNDOABLE);
 
54
 
 
55
    PyModule_AddIntConstant(m, "UNIT_PIXEL",
 
56
                            GIMP_UNIT_PIXEL);
 
57
    PyModule_AddIntConstant(m, "UNIT_INCH",
 
58
                            GIMP_UNIT_INCH);
 
59
    PyModule_AddIntConstant(m, "UNIT_MM",
 
60
                            GIMP_UNIT_MM);
 
61
    PyModule_AddIntConstant(m, "UNIT_POINT",
 
62
                            GIMP_UNIT_POINT);
 
63
    PyModule_AddIntConstant(m, "UNIT_PICA",
 
64
                            GIMP_UNIT_PICA);
 
65
 
 
66
    PyModule_AddIntConstant(m, "MIN_IMAGE_SIZE",
 
67
                            GIMP_MIN_IMAGE_SIZE);
 
68
    PyModule_AddIntConstant(m, "MAX_IMAGE_SIZE",
 
69
                            GIMP_MAX_IMAGE_SIZE);
 
70
 
 
71
    PyModule_AddObject(m, "MIN_RESOLUTION",
 
72
                       PyFloat_FromDouble(GIMP_MIN_RESOLUTION));
 
73
    PyModule_AddObject(m, "MAX_RESOLUTION",
 
74
                       PyFloat_FromDouble(GIMP_MAX_RESOLUTION));
 
75
 
 
76
    PyModule_AddObject(m, "MAX_MEMSIZE",
 
77
                       PyLong_FromUnsignedLongLong(GIMP_MAX_MEMSIZE));
 
78
}
 
79
 
 
80
static void
 
81
add_registered_enums(PyObject *m)
 
82
{
 
83
    int num_names, i;
 
84
    const char **names;
 
85
 
 
86
    names = gimp_enums_get_type_names(&num_names);
 
87
 
 
88
    pyg_enum_add_constants(m, GIMP_TYPE_CHECK_SIZE, "GIMP_");
 
89
    pyg_enum_add_constants(m, GIMP_TYPE_CHECK_TYPE, "GIMP_");
 
90
 
 
91
    for (i = 0; i < num_names; i++)
 
92
        pyg_enum_add_constants(m, g_type_from_name(names[i]), "GIMP_");
 
93
}
 
94
 
 
95
 
 
96
/* Initialization function for the module (*must* be called initgimpenums) */
 
97
 
 
98
static char gimpenums_doc[] =
 
99
"This module provides interfaces to allow you to write gimp plugins"
 
100
;
 
101
 
 
102
DL_EXPORT(void)
 
103
init_gimpenums(void)
 
104
{
 
105
    PyObject *m;
 
106
 
 
107
    pygimp_init_pygobject();
 
108
 
 
109
    init_pygimp();
 
110
 
 
111
    gimp_enums_init();
 
112
 
 
113
    /* Create the module and add the functions */
 
114
    m = Py_InitModule3("_gimpenums", NULL, gimpenums_doc);
 
115
 
 
116
    add_misc_enums(m);
 
117
    add_registered_enums(m);
 
118
 
 
119
    /* Check for errors */
 
120
    if (PyErr_Occurred())
 
121
        Py_FatalError("can't initialize module _gimpenums");
 
122
}