File: osk_module.c

package info (click to toggle)
onboard 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 30,984 kB
  • ctags: 4,786
  • sloc: python: 28,228; cpp: 5,965; ansic: 5,519; xml: 956; sh: 163; makefile: 36
file content (94 lines) | stat: -rw-r--r-- 2,630 bytes parent folder | download
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
/*
 * Copyright © 2011, 2013 Gerd Kohlberger <lowfi@chello.at>
 * Copyright © 2011-2013, 2016 marmuta <marmvta@gmail.com>
 *
 * This file is part of Onboard.
 *
 * Onboard is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Onboard 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gdk/gdk.h>

#include "osk_module.h"

PyObject *__osk_error;

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

#if PY_MAJOR_VERSION >= 3
    static struct PyModuleDef moduledef = {
        PyModuleDef_HEAD_INIT,
        "osk",                /* m_name */
        "osk utility module", /* m_doc */
        -1,                   /* m_size */
        osk_methods,          /* m_methods */
        NULL,                 /* m_reload */
        NULL,                 /* m_traverse */
        NULL,                 /* m_clear */
        NULL,                 /* m_free */
    };
#endif

static PyObject *
moduleinit (void)
{
    PyObject *module;

    #if PY_MAJOR_VERSION >= 3
        module = PyModule_Create(&moduledef);
    #else
        module = Py_InitModule("osk", osk_methods);
    #endif
    if (module == NULL)
        Py_FatalError ("Failed to initialize the \"osk\" module.");

    __osk_error = PyErr_NewException ("osk.error", NULL, NULL);
    if (__osk_error == NULL)
        Py_FatalError ("Failed to create the \"osk.error\" exception.");

    Py_INCREF (__osk_error);
    PyModule_AddObject (module, "error", __osk_error);

    gdk_init (NULL, NULL);

    __osk_virtkey_register_type (module);
    __osk_devices_register_type (module);
    __osk_device_event_register_type (module);
    __osk_util_register_type (module);
    __osk_click_mapper_register_type (module);
    __osk_dconf_register_type (module);
    __osk_struts_register_type (module);
    __osk_audio_register_type (module);
    __osk_hunspell_register_type (module);
    __osk_uinput_register_type (module);

    return module;
}

#if PY_MAJOR_VERSION < 3
    PyMODINIT_FUNC
    initosk(void)
    {
        moduleinit();
    }
#else
    PyMODINIT_FUNC
    PyInit_osk(void)
    {
        return moduleinit();
    }
#endif