]> git.decadent.org.uk Git - ion3.git/blob - mod_tiling/main.c
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / mod_tiling / main.c
1 /*
2  * ion/mod_tiling/main.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #include <libtu/map.h>
10
11 #include <ioncore/common.h>
12 #include <ioncore/reginfo.h>
13 #include <libextl/readconfig.h>
14 #include <ioncore/framep.h>
15 #include <ioncore/bindmaps.h>
16 #include <ioncore/bindmaps.h>
17
18 #include "main.h"
19 #include "tiling.h"
20 #include "placement.h"
21 #include "exports.h"
22
23
24 /*{{{ Module information */
25
26
27 #include "../version.h"
28
29 char mod_tiling_ion_api_version[]=ION_API_VERSION;
30
31
32 /*}}}*/
33
34
35 /*{{{ Bindmaps and configuration variables */
36
37
38 WBindmap *mod_tiling_tiling_bindmap=NULL;
39
40 int mod_tiling_raise_delay=CF_RAISE_DELAY;
41
42
43 /*}}}*/
44
45
46 /*{{{ Configuration */
47
48
49 /*EXTL_DOC
50  * Set parameters. Currently only \var{raise_delay} (in milliseconds)
51  * is supported.
52  */
53 EXTL_EXPORT
54 void mod_tiling_set(ExtlTab tab)
55 {
56     int d;
57     if(extl_table_gets_i(tab, "raise_delay", &d)){
58         if(d>=0)
59             mod_tiling_raise_delay=d;
60     }
61 }
62
63
64 /*EXTL_DOC
65  * Get parameters. For details see \fnref{mod_tiling.set}.
66  */
67 EXTL_SAFE
68 EXTL_EXPORT
69 ExtlTab mod_tiling_get()
70 {
71     ExtlTab tab=extl_create_table();
72     
73     extl_table_sets_i(tab, "raise_delay", mod_tiling_raise_delay);
74     
75     return tab;
76 }
77
78
79
80 /*}}}*/
81
82
83
84 /*{{{ Module init & deinit */
85
86
87 void mod_tiling_deinit()
88 {
89     mod_tiling_unregister_exports();
90     ioncore_unregister_regclass(&CLASSDESCR(WTiling));
91     
92     if(mod_tiling_tiling_bindmap!=NULL){
93         ioncore_free_bindmap("WTiling", mod_tiling_tiling_bindmap);
94         mod_tiling_tiling_bindmap=NULL;
95     }
96     
97     if(tiling_placement_alt!=NULL){
98         destroy_obj((Obj*)tiling_placement_alt);
99         tiling_placement_alt=NULL;
100     }
101 }
102
103
104 static bool register_regions()
105 {
106     if(!ioncore_register_regclass(&CLASSDESCR(WTiling),
107                                   (WRegionLoadCreateFn*)tiling_load)){
108         return FALSE;
109     }
110     
111     return TRUE;
112 }
113
114
115 #define INIT_HOOK_(NM)                             \
116     NM=mainloop_register_hook(#NM, create_hook()); \
117     if(NM==NULL) return FALSE;
118
119
120 static bool init_hooks()
121 {
122     INIT_HOOK_(tiling_placement_alt);
123     return TRUE;
124 }
125
126
127 bool mod_tiling_init()
128 {
129     if(!init_hooks())
130         goto err;
131             
132     mod_tiling_tiling_bindmap=ioncore_alloc_bindmap("WTiling", NULL);
133
134     if(mod_tiling_tiling_bindmap==NULL)
135         goto err;
136
137     if(!mod_tiling_register_exports())
138         goto err;
139
140     if(!register_regions())
141         goto err;
142     
143     extl_read_config("cfg_tiling", NULL, TRUE);
144
145     return TRUE;
146     
147 err:
148     mod_tiling_deinit();
149     return FALSE;
150 }
151
152
153 /*}}}*/
154