1/* -*- Mode: C; c-basic-offset: 4 -*-
2 * pygtk- Python bindings for the GTK toolkit.
3 * Copyright (C) 2007  Paul Pogonyshev
4 *
5 *   gtkrcstyle.override: overrides for the gtk.RcStyle 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23%%
24override-attr GtkRcStyle.name
25static int
26_wrap_gtk_rc_style__set_name(PyGObject *self, PyObject *value, void *closure)
27{
28    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
29    gchar *name;
30    PyObject *as_string;
31
32    if (value == Py_None)
33        name = NULL;
34    else if ((as_string = PyObject_Str(value)) != NULL) {
35        name = g_strdup(PyString_AsString(as_string));
36        Py_DECREF(as_string);
37    }
38    else
39        return -1;
40
41    g_free(rc_style->name);
42    rc_style->name = name;
43    return 0;
44}
45
46%%
47override-attr GtkRcStyle.bg_pixmap_name
48static PyObject *
49_wrap_gtk_rc_style__get_bg_pixmap_name(PyGObject *self, void *closure)
50{
51    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
52
53    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_STRING_ARRAY, rc_style->bg_pixmap_name, 0);
54}
55
56%%
57override-attr GtkRcStyle.font_desc
58static int
59_wrap_gtk_rc_style__set_font_desc(PyGObject *self, PyObject *value, void *closure)
60{
61    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
62    PangoFontDescription *font_desc;
63
64    if (value == Py_None)
65        font_desc = NULL;
66    else if (pyg_boxed_check(value, PANGO_TYPE_FONT_DESCRIPTION))
67        font_desc = pango_font_description_copy(pyg_boxed_get(value, PangoFontDescription));
68    else {
69        PyErr_SetString(PyExc_TypeError, "can only assign a pango.FontDescription or None");
70        return -1;
71    }
72
73    pango_font_description_free(rc_style->font_desc);
74    rc_style->font_desc = font_desc;
75    return 0;
76}
77
78%%
79override-attr GtkRcStyle.fg
80static PyObject *
81_wrap_gtk_rc_style__get_fg(PyGObject *self, void *closure)
82{
83    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
84
85    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->fg, GTK_RC_FG);
86}
87
88%%
89override-attr GtkRcStyle.bg
90static PyObject *
91_wrap_gtk_rc_style__get_bg(PyGObject *self, void *closure)
92{
93    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
94
95    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->bg, GTK_RC_BG);
96}
97
98%%
99override-attr GtkRcStyle.text
100static PyObject *
101_wrap_gtk_rc_style__get_text(PyGObject *self, void *closure)
102{
103    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
104
105    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->text, GTK_RC_TEXT);
106}
107
108%%
109override-attr GtkRcStyle.base
110static PyObject *
111_wrap_gtk_rc_style__get_base(PyGObject *self, void *closure)
112{
113    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
114
115    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->base, GTK_RC_BASE);
116}
117
118%%
119override-attr GtkRcStyle.xthickness
120static int
121_wrap_gtk_rc_style__set_xthickness(PyGObject *self, PyObject *value, void *closure)
122{
123    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
124
125    if (PyInt_Check(value)) {
126        rc_style->xthickness = PyInt_AsLong(value);
127        return 0;
128    }
129    else {
130        PyErr_SetString(PyExc_TypeError, "can only assign an int");
131        return -1;
132    }
133}
134
135%%
136override-attr GtkRcStyle.ythickness
137static int
138_wrap_gtk_rc_style__set_ythickness(PyGObject *self, PyObject *value, void *closure)
139{
140    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
141
142    if (PyInt_Check(value)) {
143        rc_style->ythickness = PyInt_AsLong(value);
144        return 0;
145    }
146    else {
147        PyErr_SetString(PyExc_TypeError, "can only assign an int");
148        return -1;
149    }
150}
151