1/* -*- Mode: C; c-basic-offset: 4 -*-
2 * pygtk- Python bindings for the GTK toolkit.
3 * Copyright (C) 1998-2003  James Henstridge
4 *
5 *   gtkstyle.override: overrides for the gtk.Style object.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 */
22%%
23override-attr GtkStyle.fg
24static PyObject *
25_wrap_gtk_style__get_fg(PyGObject *self, void *closure)
26{
27    GtkStyle *style = GTK_STYLE(self->obj);
28
29    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->fg);
30}
31%%
32override-attr GtkStyle.bg
33static PyObject *
34_wrap_gtk_style__get_bg(PyGObject *self, void *closure)
35{
36    GtkStyle *style = GTK_STYLE(self->obj);
37
38    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->bg);
39}
40%%
41override-attr GtkStyle.light
42static PyObject *
43_wrap_gtk_style__get_light(PyGObject *self, void *closure)
44{
45    GtkStyle *style = GTK_STYLE(self->obj);
46
47    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->light);
48}
49%%
50override-attr GtkStyle.dark
51static PyObject *
52_wrap_gtk_style__get_dark(PyGObject *self, void *closure)
53{
54    GtkStyle *style = GTK_STYLE(self->obj);
55
56    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->dark);
57}
58%%
59override-attr GtkStyle.mid
60static PyObject *
61_wrap_gtk_style__get_mid(PyGObject *self, void *closure)
62{
63    GtkStyle *style = GTK_STYLE(self->obj);
64
65    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->mid);
66}
67%%
68override-attr GtkStyle.text
69static PyObject *
70_wrap_gtk_style__get_text(PyGObject *self, void *closure)
71{
72    GtkStyle *style = GTK_STYLE(self->obj);
73
74    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text);
75}
76%%
77override-attr GtkStyle.base
78static PyObject *
79_wrap_gtk_style__get_base(PyGObject *self, void *closure)
80{
81    GtkStyle *style = GTK_STYLE(self->obj);
82
83    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->base);
84}
85%%
86override-attr GtkStyle.text_aa
87static PyObject *
88_wrap_gtk_style__get_text_aa(PyGObject *self, void *closure)
89{
90    GtkStyle *style = GTK_STYLE(self->obj);
91
92    return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text_aa);
93}
94%%
95override-attr GtkStyle.white
96static PyObject *
97_wrap_gtk_style__get_white(PyGObject *self, void *closure)
98{
99    GtkStyle *style = GTK_STYLE(self->obj);
100
101    return pyg_boxed_new(GDK_TYPE_COLOR, &style->white, TRUE, TRUE);
102}
103static int
104_wrap_gtk_style__set_white(PyGObject *self, PyObject *value, void *closure)
105{
106    GtkStyle *style = GTK_STYLE(self->obj);
107
108    if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) {
109        PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor");
110        return -1;
111    }
112    style->white = *pyg_boxed_get(value, GdkColor);
113    return 0;
114}
115%%
116override-attr GtkStyle.black
117static PyObject *
118_wrap_gtk_style__get_black(PyGObject *self, void *closure)
119{
120    GtkStyle *style = GTK_STYLE(self->obj);
121
122    return pyg_boxed_new(GDK_TYPE_COLOR, &style->black, TRUE, TRUE);
123}
124static int
125_wrap_gtk_style__set_black(PyGObject *self, PyObject *value, void *closure)
126{
127    GtkStyle *style = GTK_STYLE(self->obj);
128
129    if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) {
130        PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor");
131        return -1;
132    }
133    style->black = *pyg_boxed_get(value, GdkColor);
134    return 0;
135}
136%%
137override-attr GtkStyle.fg_gc
138static PyObject *
139_wrap_gtk_style__get_fg_gc(PyGObject *self, void *closure)
140{
141    GtkStyle *style = GTK_STYLE(self->obj);
142
143    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->fg_gc);
144}
145%%
146override-attr GtkStyle.bg_gc
147static PyObject *
148_wrap_gtk_style__get_bg_gc(PyGObject *self, void *closure)
149{
150    GtkStyle *style = GTK_STYLE(self->obj);
151
152    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->bg_gc);
153}
154%%
155override-attr GtkStyle.light_gc
156static PyObject *
157_wrap_gtk_style__get_light_gc(PyGObject *self, void *closure)
158{
159    GtkStyle *style = GTK_STYLE(self->obj);
160
161    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->light_gc);
162}
163%%
164override-attr GtkStyle.dark_gc
165static PyObject *
166_wrap_gtk_style__get_dark_gc(PyGObject *self, void *closure)
167{
168    GtkStyle *style = GTK_STYLE(self->obj);
169
170    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->dark_gc);
171}
172%%
173override-attr GtkStyle.mid_gc
174static PyObject *
175_wrap_gtk_style__get_mid_gc(PyGObject *self, void *closure)
176{
177    GtkStyle *style = GTK_STYLE(self->obj);
178
179    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->mid_gc);
180}
181%%
182override-attr GtkStyle.text_gc
183static PyObject *
184_wrap_gtk_style__get_text_gc(PyGObject *self, void *closure)
185{
186    GtkStyle *style = GTK_STYLE(self->obj);
187
188    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_gc);
189}
190%%
191override-attr GtkStyle.base_gc
192static PyObject *
193_wrap_gtk_style__get_base_gc(PyGObject *self, void *closure)
194{
195    GtkStyle *style = GTK_STYLE(self->obj);
196
197    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->base_gc);
198}
199%%
200override-attr GtkStyle.text_aa_gc
201static PyObject *
202_wrap_gtk_style__get_text_aa_gc(PyGObject *self, void *closure)
203{
204    GtkStyle *style = GTK_STYLE(self->obj);
205
206    return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_aa_gc);
207}
208%%
209override-attr GtkStyle.white_gc
210static PyObject *
211_wrap_gtk_style__get_white_gc(PyGObject *self, void *closure)
212{
213    GtkStyle *style = GTK_STYLE(self->obj);
214
215    return pygobject_new((GObject *)style->white_gc);
216}
217static int
218_wrap_gtk_style__set_white_gc(PyGObject *self, PyObject *value, void *closure)
219{
220    GtkStyle *style = GTK_STYLE(self->obj);
221
222    if (!pygobject_check(value, &PyGdkGC_Type)) {
223        PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC");
224        return -1;
225    }
226    style->white_gc = GDK_GC(pygobject_get(value));
227    return 0;
228}
229%%
230override-attr GtkStyle.black_gc
231static PyObject *
232_wrap_gtk_style__get_black_gc(PyGObject *self, void *closure)
233{
234    GtkStyle *style = GTK_STYLE(self->obj);
235
236    return pygobject_new((GObject *)style->black_gc);
237}
238static int
239_wrap_gtk_style__set_black_gc(PyGObject *self, PyObject *value, void *closure)
240{
241    GtkStyle *style = GTK_STYLE(self->obj);
242
243    if (!pygobject_check(value, &PyGdkGC_Type)) {
244        PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC");
245        return -1;
246    }
247    style->black_gc = GDK_GC(pygobject_get(value));
248    return 0;
249}
250%%
251override-attr GtkStyle.bg_pixmap
252static PyObject *
253_wrap_gtk_style__get_bg_pixmap(PyGObject *self, void *closure)
254{
255    GtkStyle *style = GTK_STYLE(self->obj);
256
257    return _pygtk_style_helper_new(style, STYLE_PIXMAP_ARRAY, style->bg_pixmap);
258}
259%%
260override gtk_style_lookup_color kwargs
261static PyObject *
262_wrap_gtk_style_lookup_color(PyGObject *self, PyObject *args, PyObject *kwargs)
263{
264    static char *kwlist[] = { "color_name", NULL };
265    char *color_name;
266    GdkColor color;
267
268    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GtkStyle.lookup_color",
269                                     kwlist, &color_name))
270        return NULL;
271
272    if (gtk_style_lookup_color(GTK_STYLE(self->obj), color_name, &color))
273        return pyg_boxed_new(GDK_TYPE_COLOR, &color, TRUE, TRUE);
274
275    Py_INCREF(Py_None);
276    return Py_None;
277}
278