]> git.decadent.org.uk Git - ion3.git/blob - mod_panews/main.c
[svn-inject] Installing original source of ion3
[ion3.git] / mod_panews / main.c
1 /*
2  * ion/panews/main.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2006. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #include <libtu/map.h>
13
14 #include <ioncore/common.h>
15 #include <ioncore/reginfo.h>
16 #include <libextl/readconfig.h>
17 #include <ioncore/framep.h>
18 #include <ioncore/bindmaps.h>
19 #include <ioncore/bindmaps.h>
20
21 #include "main.h"
22 #include "panews.h"
23 #include "placement.h"
24 #include "exports.h"
25
26
27 /*{{{ Module information */
28
29
30 #include "../version.h"
31
32 char mod_panews_ion_api_version[]=ION_API_VERSION;
33
34
35 /*}}}*/
36
37
38 /*{{{ Bindmaps */
39
40
41 WBindmap *mod_panews_panews_bindmap=NULL;
42 WBindmap *mod_panews_frame_bindmap=NULL;
43 WBindmap *mod_panews_unusedwin_bindmap=NULL;
44
45
46 /*}}}*/
47
48
49 /*{{{ Module init & deinit */
50
51
52 void mod_panews_deinit()
53 {
54     mod_panews_unregister_exports();
55     ioncore_unregister_regclass(&CLASSDESCR(WPaneWS));
56     
57     if(mod_panews_panews_bindmap!=NULL){
58         ioncore_free_bindmap("WPaneWS", mod_panews_panews_bindmap);
59         mod_panews_panews_bindmap=NULL;
60     }
61
62     if(mod_panews_unusedwin_bindmap!=NULL){
63         ioncore_free_bindmap("WUnusedWin", mod_panews_unusedwin_bindmap);
64         mod_panews_unusedwin_bindmap=NULL;
65     }
66     
67     if(mod_panews_frame_bindmap!=NULL){
68         ioncore_free_bindmap("WFrame-on-WPaneWS", mod_panews_frame_bindmap);
69         mod_panews_frame_bindmap=NULL;
70     }
71     
72     if(panews_init_layout_alt!=NULL){
73         destroy_obj((Obj*)panews_init_layout_alt);
74         panews_init_layout_alt=NULL;
75     }
76
77     if(panews_make_placement_alt!=NULL){
78         destroy_obj((Obj*)panews_make_placement_alt);
79         panews_make_placement_alt=NULL;
80     }
81 }
82
83
84 static bool register_regions()
85 {
86     if(!ioncore_register_regclass(&CLASSDESCR(WPaneWS),
87                                   (WRegionLoadCreateFn*)panews_load)){
88         return FALSE;
89     }
90     
91     return TRUE;
92 }
93
94
95 #define INIT_HOOK_(NM)                             \
96     NM=mainloop_register_hook(#NM, create_hook()); \
97     if(NM==NULL) return FALSE;
98
99
100 static bool init_hooks()
101 {
102     INIT_HOOK_(panews_init_layout_alt);
103     INIT_HOOK_(panews_make_placement_alt);
104     return TRUE;
105 }
106
107
108
109 bool mod_panews_init()
110 {
111     if(!init_hooks())
112         goto err;
113
114     mod_panews_panews_bindmap=ioncore_alloc_bindmap("WPaneWS", NULL);
115     mod_panews_unusedwin_bindmap=ioncore_alloc_bindmap_frame("WUnusedWin");
116     mod_panews_frame_bindmap=ioncore_alloc_bindmap_frame("WFrame-on-WPaneWS");
117
118     if(mod_panews_panews_bindmap==NULL ||
119        mod_panews_unusedwin_bindmap==NULL ||
120        mod_panews_frame_bindmap==NULL){
121         goto err;
122     }
123
124     if(!mod_panews_register_exports())
125         goto err;
126     
127     if(!register_regions())
128         goto err;
129     
130     /*ioncore_read_config("cfg_panews", NULL, FALSE);*/
131
132     return TRUE;
133     
134 err:
135     mod_panews_deinit();
136     return FALSE;
137 }
138
139
140 /*}}}*/
141