~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

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) 1997-2002  James Henstridge <james@daa.com.au>
 
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., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#  include <config.h>
 
22
#endif
 
23
#include "pygimp.h"
 
24
 
 
25
static PyMethodDef disp_methods[] = {
 
26
    {NULL,              NULL}           /* sentinel */
 
27
};
 
28
 
 
29
static void
 
30
disp_dealloc(PyGimpDisplay *self)
 
31
{
 
32
    PyObject_DEL(self);
 
33
}
 
34
 
 
35
static PyObject *
 
36
disp_repr(PyGimpDisplay *self)
 
37
{
 
38
    PyObject *s;
 
39
 
 
40
    s = PyString_FromString("<display>");
 
41
    return s;
 
42
}
 
43
 
 
44
static int
 
45
disp_init(PyGimpDisplay *self, PyObject *args, PyObject *kwargs)
 
46
{
 
47
    PyGimpImage *img;
 
48
 
 
49
    if (!PyArg_ParseTuple(args, "O!:gimp.Display.__init__",
 
50
                          &PyGimpImage_Type, &img))
 
51
        return -1;
 
52
    self->ID = gimp_display_new(img->ID);
 
53
    if (self->ID < 0) {
 
54
        PyErr_SetString(pygimp_error, "could not create image");
 
55
        return -1;
 
56
    }
 
57
    return 0;
 
58
}
 
59
 
 
60
PyTypeObject PyGimpDisplay_Type = {
 
61
    PyObject_HEAD_INIT(NULL)
 
62
    0,                                  /* ob_size */
 
63
    "gimp.Display",                     /* tp_name */
 
64
    sizeof(PyGimpDisplay),              /* tp_basicsize */
 
65
    0,                                  /* tp_itemsize */
 
66
    /* methods */
 
67
    (destructor)disp_dealloc,           /* tp_dealloc */
 
68
    (printfunc)0,                       /* tp_print */
 
69
    (getattrfunc)0,                     /* tp_getattr */
 
70
    (setattrfunc)0,                     /* tp_setattr */
 
71
    (cmpfunc)0,                         /* tp_compare */
 
72
    (reprfunc)disp_repr,                /* tp_repr */
 
73
    0,                                  /* tp_as_number */
 
74
    0,                                  /* tp_as_sequence */
 
75
    0,                                  /* tp_as_mapping */
 
76
    (hashfunc)0,                        /* tp_hash */
 
77
    (ternaryfunc)0,                     /* tp_call */
 
78
    (reprfunc)0,                        /* tp_str */
 
79
    (getattrofunc)0,                    /* tp_getattro */
 
80
    (setattrofunc)0,                    /* tp_setattro */
 
81
    0,                                  /* tp_as_buffer */
 
82
    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
 
83
    NULL, /* Documentation string */
 
84
    (traverseproc)0,                    /* tp_traverse */
 
85
    (inquiry)0,                         /* tp_clear */
 
86
    (richcmpfunc)0,                     /* tp_richcompare */
 
87
    0,                                  /* tp_weaklistoffset */
 
88
    (getiterfunc)0,                     /* tp_iter */
 
89
    (iternextfunc)0,                    /* tp_iternext */
 
90
    disp_methods,                       /* tp_methods */
 
91
    0,                                  /* tp_members */
 
92
    0,                                  /* tp_getset */
 
93
    (PyTypeObject *)0,                  /* tp_base */
 
94
    (PyObject *)0,                      /* tp_dict */
 
95
    0,                                  /* tp_descr_get */
 
96
    0,                                  /* tp_descr_set */
 
97
    0,                                  /* tp_dictoffset */
 
98
    (initproc)disp_init,                /* tp_init */
 
99
    (allocfunc)0,                       /* tp_alloc */
 
100
    (newfunc)0,                         /* tp_new */
 
101
};
 
102
 
 
103
PyObject *
 
104
pygimp_display_new(gint32 ID)
 
105
{
 
106
    PyGimpDisplay *self;
 
107
        
 
108
    self = PyObject_NEW(PyGimpDisplay, &PyGimpDisplay_Type);
 
109
    if (self == NULL)
 
110
        return NULL;
 
111
    self->ID = ID;
 
112
    return (PyObject *)self;
 
113
}