1 #include "e_illume_private.h"
2 #include "e_mod_main.h"
3 #include "e_mod_config.h"
4 #include "e_mod_policy.h"
6 #include "e_mod_quickpanel.h"
8 /* NB: Initially I had done this rewrite with eina_logging enabled, but it
9 * degraded performance so much that it was just not worth it. So now this
10 * module just uses printfs on the console to report things */
12 /* external variables */
13 const char *_e_illume_mod_dir = NULL;
14 E_Illume_Keyboard *_e_illume_kbd = NULL;
15 Eina_List *_e_illume_qps = NULL;
17 EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume2" };
20 e_modapi_init(E_Module *m)
22 Eina_List *ml, *cl, *zl;
26 Ecore_X_Window *zones;
29 /* check if illume is loaded and bail out if it is.
30 * Illume1 and illume2 both cannot be loaded @ the same time */
31 if (e_module_find("illume")) return NULL;
33 /* set module priority so we load first */
34 e_module_priority_set(m, 100);
36 /* set module directory variable */
37 _e_illume_mod_dir = eina_stringshare_add(m->dir);
39 /* try to initialize the config subsystem */
40 if (!e_mod_illume_config_init())
42 /* clear module directory variable */
43 if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
44 _e_illume_mod_dir = NULL;
49 /* try to initialize the policy subsystem */
50 if (!e_mod_policy_init())
52 /* shutdown the config subsystem */
53 e_mod_illume_config_shutdown();
55 /* clear module directory variable */
56 if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
57 _e_illume_mod_dir = NULL;
62 /* initialize the keyboard subsystem */
65 /* initialize the quickpanel subsystem */
66 e_mod_quickpanel_init();
68 /* create a new vkbd & hide it initially */
69 _e_illume_kbd = e_mod_kbd_new();
72 /* loop zones and get count */
73 EINA_LIST_FOREACH(e_manager_list(), ml, man)
74 EINA_LIST_FOREACH(man->containers, cl, con)
75 EINA_LIST_FOREACH(con->zones, zl, zone)
78 /* allocate enough zones */
79 zones = calloc(zcount, sizeof(Ecore_X_Window));
82 /* free the keyboard */
83 E_FREE(_e_illume_kbd);
85 /* shutdown quickpanel & kbd sub-systems */
86 e_mod_quickpanel_shutdown();
89 /* shutdown the config subsystem */
90 e_mod_illume_config_shutdown();
92 /* clear module directory variable */
93 if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
94 _e_illume_mod_dir = NULL;
101 /* loop the zones and create quickpanels for each one */
102 EINA_LIST_FOREACH(e_manager_list(), ml, man)
104 EINA_LIST_FOREACH(man->containers, cl, con)
106 EINA_LIST_FOREACH(con->zones, zl, zone)
108 E_Illume_Quickpanel *qp;
110 /* set zone window in list of zones */
111 zones[zcount] = zone->black_win;
113 /* increment zone count */
116 /* try to create a new quickpanel for this zone */
117 if (!(qp = e_mod_quickpanel_new(zone))) continue;
119 /* append new qp to list */
120 _e_illume_qps = eina_list_append(_e_illume_qps, qp);
123 /* set the zone list on this root. This is needed for some
124 * elm apps like elm_indicator so that they know how many
125 * indicators to create at startup */
126 ecore_x_e_illume_zone_list_set(man->root, zones, zcount);
129 /* free zones variable */
136 e_modapi_shutdown(E_Module *m __UNUSED__)
138 E_Illume_Quickpanel *qp;
140 /* delete the quickpanels */
141 EINA_LIST_FREE(_e_illume_qps, qp)
142 e_object_del(E_OBJECT(qp));
144 /* shutdown the quickpanel subsystem */
145 e_mod_quickpanel_shutdown();
147 /* delete the keyboard object */
148 if (_e_illume_kbd) e_object_del(E_OBJECT(_e_illume_kbd));
149 _e_illume_kbd = NULL;
151 /* shutdown the keyboard subsystem */
152 e_mod_kbd_shutdown();
154 /* shutdown the policy subsystem */
155 e_mod_policy_shutdown();
157 /* shutdown the config subsystem */
158 e_mod_illume_config_shutdown();
160 /* clear module directory variable */
161 if (_e_illume_mod_dir) eina_stringshare_del(_e_illume_mod_dir);
162 _e_illume_mod_dir = NULL;
168 e_modapi_save(E_Module *m __UNUSED__)
170 return e_mod_illume_config_save();