summaryrefslogtreecommitdiff
path: root/gtk/gtkrcstyle.override
blob: 1d77af8bfbc726326bbdc829df79c80159bdd58e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* -*- Mode: C; c-basic-offset: 4 -*-
 * pygtk- Python bindings for the GTK toolkit.
 * Copyright (C) 2007  Paul Pogonyshev
 *
 *   gtkrcstyle.override: overrides for the gtk.RcStyle object.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

%%
override-attr GtkRcStyle.name
static int
_wrap_gtk_rc_style__set_name(PyGObject *self, PyObject *value, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
    gchar *name;
    PyObject *as_string;

    if (value == Py_None)
        name = NULL;
    else if ((as_string = PyObject_Str(value)) != NULL) {
        name = g_strdup(PyString_AsString(as_string));
        Py_DECREF(as_string);
    }
    else
        return -1;

    g_free(rc_style->name);
    rc_style->name = name;
    return 0;
}

%%
override-attr GtkRcStyle.bg_pixmap_name
static PyObject *
_wrap_gtk_rc_style__get_bg_pixmap_name(PyGObject *self, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_STRING_ARRAY, rc_style->bg_pixmap_name, 0);
}

%%
override-attr GtkRcStyle.font_desc
static int
_wrap_gtk_rc_style__set_font_desc(PyGObject *self, PyObject *value, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);
    PangoFontDescription *font_desc;

    if (value == Py_None)
        font_desc = NULL;
    else if (pyg_boxed_check(value, PANGO_TYPE_FONT_DESCRIPTION))
        font_desc = pango_font_description_copy(pyg_boxed_get(value, PangoFontDescription));
    else {
        PyErr_SetString(PyExc_TypeError, "can only assign a pango.FontDescription or None");
        return -1;
    }

    pango_font_description_free(rc_style->font_desc);
    rc_style->font_desc = font_desc;
    return 0;
}

%%
override-attr GtkRcStyle.fg
static PyObject *
_wrap_gtk_rc_style__get_fg(PyGObject *self, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->fg, GTK_RC_FG);
}

%%
override-attr GtkRcStyle.bg
static PyObject *
_wrap_gtk_rc_style__get_bg(PyGObject *self, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->bg, GTK_RC_BG);
}

%%
override-attr GtkRcStyle.text
static PyObject *
_wrap_gtk_rc_style__get_text(PyGObject *self, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->text, GTK_RC_TEXT);
}

%%
override-attr GtkRcStyle.base
static PyObject *
_wrap_gtk_rc_style__get_base(PyGObject *self, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    return _pygtk_rc_style_helper_new(rc_style, RC_STYLE_COLOUR_ARRAY, rc_style->base, GTK_RC_BASE);
}

%%
override-attr GtkRcStyle.xthickness
static int
_wrap_gtk_rc_style__set_xthickness(PyGObject *self, PyObject *value, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    if (PyInt_Check(value)) {
        rc_style->xthickness = PyInt_AsLong(value);
        return 0;
    }
    else {
        PyErr_SetString(PyExc_TypeError, "can only assign an int");
        return -1;
    }
}

%%
override-attr GtkRcStyle.ythickness
static int
_wrap_gtk_rc_style__set_ythickness(PyGObject *self, PyObject *value, void *closure)
{
    GtkRcStyle *rc_style = GTK_RC_STYLE(self->obj);

    if (PyInt_Check(value)) {
        rc_style->ythickness = PyInt_AsLong(value);
        return 0;
    }
    else {
        PyErr_SetString(PyExc_TypeError, "can only assign an int");
        return -1;
    }
}