remove e_comp_list(), deprecate all related functions for pending removal
[platform/upstream/enlightenment.git] / src / modules / illume2 / e_mod_main.c
1 #include "e_illume_private.h"
2 #include "e_mod_main.h"
3
4 /* NB: Initially I had done this rewrite with eina_logging enabled, but it 
5  * degraded performance so much that it was just not worth it. So now this 
6  * module just uses printfs on the console to report things */
7
8 /* external variables */
9 const char *_e_illume_mod_dir = NULL;
10 E_Illume_Keyboard *_e_illume_kbd = NULL;
11 Eina_List *_e_illume_qps = NULL;
12
13 EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume2" };
14
15 EAPI void *
16 e_modapi_init(E_Module *m) 
17 {
18    E_Zone *zone;
19    Ecore_X_Window *zones;
20    int zcount = 0;
21
22    /* check if illume is loaded and bail out if it is.
23     * Illume1 and illume2 both cannot be loaded @ the same time */
24    if (e_module_find("illume")) return NULL;
25
26    /* set module priority so we load first */
27    e_module_priority_set(m, 100);
28
29    /* set module directory variable */
30    _e_illume_mod_dir = eina_stringshare_add(m->dir);
31
32    /* try to initialize the config subsystem */
33    if (!e_mod_illume_config_init()) 
34      {
35         /* clear module directory variable */
36         if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
37         _e_illume_mod_dir = NULL;
38
39         return NULL;
40      }
41
42    /* try to initialize the policy subsystem */
43    if (!e_mod_policy_init()) 
44      {
45         /* shutdown the config subsystem */
46         e_mod_illume_config_shutdown();
47
48         /* clear module directory variable */
49         if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
50         _e_illume_mod_dir = NULL;
51
52         return NULL;
53      }
54
55    /* initialize the keyboard subsystem */
56    e_mod_kbd_init();
57
58    /* initialize the quickpanel subsystem */
59    e_mod_quickpanel_init();
60
61    /* create a new vkbd & hide it initially */
62    _e_illume_kbd = e_mod_kbd_new();
63    e_mod_kbd_hide();
64
65    /* loop zones and get count */
66    zcount = eina_list_count(e_comp->zones);
67
68    /* allocate enough zones */
69    zones = calloc(zcount, sizeof(Ecore_X_Window));
70    if (!zones) 
71      {
72         /* free the keyboard */
73         E_FREE(_e_illume_kbd);
74
75         /* shutdown quickpanel & kbd sub-systems */
76         e_mod_quickpanel_shutdown();
77         e_mod_kbd_shutdown();
78
79         /* shutdown the config subsystem */
80         e_mod_illume_config_shutdown();
81
82         /* clear module directory variable */
83         if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
84         _e_illume_mod_dir = NULL;
85
86         return NULL;
87      }
88
89    zcount = 0;
90
91    /* loop the zones and create quickpanels for each one */
92    EINA_LIST_FOREACH(e_comp->zones, zl, zone) 
93      {
94         E_Illume_Quickpanel *qp;
95
96         /* set zone window in list of zones */
97         zones[zcount] = zone->black_win;
98
99         /* increment zone count */
100         zcount++;
101
102         /* try to create a new quickpanel for this zone */
103         if (!(qp = e_mod_quickpanel_new(zone))) continue;
104
105         /* append new qp to list */
106         _e_illume_qps = eina_list_append(_e_illume_qps, qp);
107      }
108    /* set the zone list on this root. This is needed for some 
109     * elm apps like elm_indicator so that they know how many 
110     * indicators to create at startup */
111    ecore_x_e_illume_zone_list_set(comp->man->root, zones, zcount);
112
113    /* free zones variable */
114    free(zones);
115
116    return m;
117 }
118
119 EAPI int 
120 e_modapi_shutdown(E_Module *m __UNUSED__) 
121 {
122    E_Illume_Quickpanel *qp;
123
124    /* delete the quickpanels */
125    EINA_LIST_FREE(_e_illume_qps, qp)
126      e_object_del(E_OBJECT(qp));
127
128    /* shutdown the quickpanel subsystem */
129    e_mod_quickpanel_shutdown();
130
131    /* delete the keyboard object */
132    if (_e_illume_kbd) e_object_del(E_OBJECT(_e_illume_kbd));
133    _e_illume_kbd = NULL;
134
135    /* shutdown the keyboard subsystem */
136    e_mod_kbd_shutdown();
137
138    /* shutdown the policy subsystem */
139    e_mod_policy_shutdown();
140
141    /* shutdown the config subsystem */
142    e_mod_illume_config_shutdown();
143
144    /* clear module directory variable */
145    if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
146    _e_illume_mod_dir = NULL;
147
148    return 1;
149 }
150
151 EAPI int 
152 e_modapi_save(E_Module *m __UNUSED__) 
153 {
154    return e_mod_illume_config_save();
155 }