summaryrefslogtreecommitdiff
path: root/gio/gfileattribute.override
blob: e51ec63cc8376604178ec9a94bf2a5ac8e7642ea (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
151
152
153
/* -*- Mode: C; c-basic-offset: 4 -*-
 * pygobject - Python bindings for GObject
 * Copyright (C) 2008  Gian Mario Tagliaretti
 *
 *   gfileattribute.override: module overrides for GFileAttribute*
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA
 */
%%
headers

extern PyTypeObject PyGFileAttributeInfo_Type;

typedef struct {
    PyObject_HEAD
    const GFileAttributeInfo *info;
} PyGFileAttributeInfo;

static PyObject *
pygio_file_attribute_info_tp_new(PyTypeObject *type)
{
    PyGFileAttributeInfo *self;
    GFileAttributeInfo *info = NULL;

    self = (PyGFileAttributeInfo *) PyObject_NEW(PyGFileAttributeInfo,
                                              &PyGFileAttributeInfo_Type);
    self->info = info;
    return (PyObject *) self;
}

static PyMethodDef pyg_file_attribute_info_methods[] = {
    { NULL,  0, 0 }
};

static PyObject *
pyg_file_attribute_info__get_name(PyObject *self, void *closure)
{
    const gchar *ret;

    ret = ((PyGFileAttributeInfo*)self)->info->name;
    if (ret)
        return PyString_FromString(ret);
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject *
pyg_file_attribute_info__get_type(PyObject *self, void *closure)
{
    gint ret;

    ret = ((PyGFileAttributeInfo*)self)->info->type;
    return pyg_enum_from_gtype(G_TYPE_FILE_ATTRIBUTE_TYPE, ret);
}

static PyObject *
pyg_file_attribute_info__get_flags(PyObject *self, void *closure)
{
    guint ret;

    ret = ((PyGFileAttributeInfo*)self)->info->flags;
    return pyg_flags_from_gtype(G_TYPE_FILE_ATTRIBUTE_INFO_FLAGS, ret);
}

static const PyGetSetDef pyg_file_attribute_info_getsets[] = {
    { "name", (getter)pyg_file_attribute_info__get_name, (setter)0 },
    { "type", (getter)pyg_file_attribute_info__get_type, (setter)0 },
    { "flags", (getter)pyg_file_attribute_info__get_flags, (setter)0 },
    { NULL, (getter)0, (setter)0 },
};

PyTypeObject PyGFileAttributeInfo_Type = {
    PyObject_HEAD_INIT(NULL)
    0,                                  /* ob_size */
    "gio.FileAttributeInfo",            /* tp_name */
    sizeof(PyGFileAttributeInfo),      /* tp_basicsize */
    0,                                  /* tp_itemsize */
    /* methods */
    (destructor)0,                      /* tp_dealloc */
    (printfunc)0,                       /* tp_print */
    (getattrfunc)0,                     /* tp_getattr */
    (setattrfunc)0,                     /* tp_setattr */
    (cmpfunc)0,                         /* tp_compare */
    (reprfunc)0,                        /* tp_repr */
    0,                                  /* tp_as_number */
    0,                                  /* tp_as_sequence */
    0,                                  /* tp_as_mapping */
    (hashfunc)0,                        /* tp_hash */
    (ternaryfunc)0,                     /* tp_call */
    (reprfunc)0,                        /* tp_str */
    (getattrofunc)0,                    /* tp_getattro */
    (setattrofunc)0,                    /* tp_setattro */
    0,                                  /* tp_as_buffer */
    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
    "Holds information about an attribute", /* Documentation string */
    (traverseproc)0,                    /* tp_traverse */
    (inquiry)0,                         /* tp_clear */
    (richcmpfunc)0,                     /* tp_richcompare */
    0,                                  /* tp_weaklistoffset */
    (getiterfunc)0,                     /* tp_iter */
    (iternextfunc)0,                    /* tp_iternext */
    (struct PyMethodDef*)pyg_file_attribute_info_methods,    /* tp_methods */
    0,                                  /* tp_members */
    (struct PyGetSetDef*)pyg_file_attribute_info_getsets,    /* tp_getset */
    (PyTypeObject *)0,                  /* tp_base */
    (PyObject *)0,                      /* tp_dict */
    0,                                  /* tp_descr_get */
    0,                                  /* tp_descr_set */
    0,                                  /* tp_dictoffset */
    (initproc)0,                        /* tp_init */
    0,                                  /* tp_alloc */
    (newfunc)pygio_file_attribute_info_tp_new,   /* tp_new */
    0,                                  /* tp_free */
    (inquiry)0,                         /* tp_is_gc */
    (PyObject *)0,                      /* tp_bases */
};

PyObject*
pyg_file_attribute_info_new(const GFileAttributeInfo *info)
{
    PyGFileAttributeInfo *self;

    self = (PyGFileAttributeInfo *)PyObject_NEW(PyGFileAttributeInfo,
                                             &PyGFileAttributeInfo_Type);
    if (G_UNLIKELY(self == NULL))
        return NULL;
    if (info)
        self->info = info;
    return (PyObject *)self;
}

%%
init
if (PyType_Ready(&PyGFileAttributeInfo_Type) < 0) {
    g_return_if_reached();
}
if (PyDict_SetItemString(d, "FileAttributeInfo",
                         (PyObject *)&PyGFileAttributeInfo_Type) < 0) {
    g_return_if_reached();
}