Fixed structures definition, removed print line from setup.py.
[python-purple] / core / core.pxd
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
6 #  python-purple is free software: you can redistribute it and/or modify
7 #  it under the terms of the GNU General Public License as published by
8 #  the Free Software Foundation, either version 3 of the License, or
9 #  (at your option) any later version.
10 #
11 #  python-purple is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY = None without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 cdef extern from "libpurple/core.h":
21     ctypedef struct PurpleCoreUiOps:
22         void (*ui_prefs_init) ()
23         void (*debug_ui_init) ()
24         void (*ui_init) ()
25         void (*quit) ()
26         GHashTable* (*get_ui_info) ()
27
28     cdef gboolean c_purple_core_init "purple_core_init" (const_char_ptr ui)
29     cdef void c_purple_core_quit "purple_core_quit" ()
30     cdef gboolean c_purple_core_migrate "purple_core_migrate" ()
31     cdef void c_purple_core_set_ui_ops "purple_core_set_ui_ops" (PurpleCoreUiOps *ops)
32
33 """ CoreUiOps class """
34 __core_uiops = None
35
36 cdef void ui_prefs_init():
37     global __core_uiops
38     if __core_uiops and __core_uiops.ui_prefs_init:
39         __core_uiops.ui_prefs_init()
40
41 cdef void debug_ui_init():
42     global __core_uiops
43     if __core_uiops and __core_uiops.debug_ui_init:
44         __core_uiops.debug_ui_init()
45
46 cdef void ui_init():
47     global __core_uiops
48     if __core_uiops and __core_uiops.ui_init:
49         __core_uiops.ui_init()
50
51 cdef void quit():
52     global __core_uiops
53     if __core_uiops and __core_uiops.quit:
54         __core_uiops.quit()
55
56 cdef GHashTable *get_ui_info():
57     global __core_uiops
58     if __core_uiops and __core_uiops.get_ui_info:
59         __core_uiops.get_ui_info()
60
61
62 class CoreUiOps(object):
63     def __init__(self):
64         self.ui_prefs_init = None
65         self.debug_ui_init = None
66         self.ui_init = None
67         self.quit = None
68         self.get_ui_info = None
69
70
71 def core_set_ui_ops(core_uiops):
72     global __core_uiops
73     cdef PurpleCoreUiOps c_core_uiops
74
75     c_core_uiops.ui_prefs_init = ui_prefs_init
76     c_core_uiops.debug_ui_init = debug_ui_init
77     c_core_uiops.ui_init = ui_init
78     c_core_uiops.quit = quit
79     c_core_uiops.get_ui_info = get_ui_info
80
81     __core_uiops = core_uiops
82
83     c_purple_core_set_ui_ops(&c_core_uiops)
84
85 def core_init(ui):
86     c_purple_core_init(ui)
87