Sync with deluge changes upto r2047.
[python-gnt.git] / gntmodule.c
blob82cef1722441efc17c64e5a0ed6b29b60a72c7d8
1 #include <pygobject.h>
2 #include "gnt.h"
3 #include "common.h"
5 void gnt_register_classes (PyObject *d);
6 extern PyMethodDef gnt_functions[];
8 static void
9 gnt_add_string_constants(PyObject *module)
11 #define define_key(x) if (GNT_KEY_##x && *(GNT_KEY_##x)) PyModule_AddStringConstant(module, "KEY_" #x, GNT_KEY_##x)
13 define_key(POPUP);
15 define_key(LEFT);
16 define_key(RIGHT);
17 define_key(UP);
18 define_key(DOWN);
20 define_key(CTRL_UP);
21 define_key(CTRL_DOWN);
22 define_key(CTRL_RIGHT);
23 define_key(CTRL_LEFT);
25 define_key(PGUP);
26 define_key(PGDOWN);
27 define_key(HOME);
28 define_key(END);
30 define_key(ENTER);
32 define_key(BACKSPACE);
33 define_key(DEL);
34 define_key(INS);
35 define_key(BACK_TAB);
37 define_key(CTRL_A);
38 define_key(CTRL_B);
39 define_key(CTRL_D);
40 define_key(CTRL_E);
41 define_key(CTRL_F);
42 define_key(CTRL_G);
43 define_key(CTRL_H);
44 define_key(CTRL_I);
45 define_key(CTRL_J);
46 define_key(CTRL_K);
47 define_key(CTRL_L);
48 define_key(CTRL_M);
49 define_key(CTRL_N);
50 define_key(CTRL_O);
51 define_key(CTRL_P);
52 define_key(CTRL_R);
53 define_key(CTRL_T);
54 define_key(CTRL_U);
55 define_key(CTRL_V);
56 define_key(CTRL_W);
57 define_key(CTRL_X);
58 define_key(CTRL_Y);
60 define_key(F1);
61 define_key(F2);
62 define_key(F3);
63 define_key(F4);
64 define_key(F5);
65 define_key(F6);
66 define_key(F7);
67 define_key(F8);
68 define_key(F9);
69 define_key(F10);
70 define_key(F11);
71 define_key(F12);
74 DL_EXPORT(void)
75 initgnt(void)
77 PyObject *m, *d;
79 init_pygobject ();
80 bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
82 m = Py_InitModule ("gnt", gnt_functions);
83 d = PyModule_GetDict (m);
85 gnt_register_classes (d);
86 gnt_add_constants(m, "GNT_");
88 if (PyErr_Occurred ()) {
89 Py_FatalError ("can't initialise module sad");
92 gnt_init();
93 gnt_add_string_constants(m);