summaryrefslogtreecommitdiff
path: root/src/modules/illume-indicator/e_mod_main.c
blob: 15ee34aeb1c6a56970a63069f67fb61617ecce1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include "e_mod_ind_win.h"

#ifdef HAVE_ENOTIFY
# include "e_mod_notify.h"
#endif

/* local variables */
static Eina_List *iwins = NULL;

/* external variables */
const char *_ind_mod_dir = NULL;

EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume-Indicator" };

EAPI void *
e_modapi_init(E_Module *m) 
{
   const Eina_List *l;
   E_Comp *comp;

   /* set module priority so we load before others */
   e_module_priority_set(m, 90);

   /* set module directory variable */
   _ind_mod_dir = eina_stringshare_add(m->dir);

   /* init config subsystem */
   if (!il_ind_config_init()) 
     {
        /* clear module directory variable */
        if (_ind_mod_dir) eina_stringshare_del(_ind_mod_dir);
        _ind_mod_dir = NULL;
        return NULL;
     }

#ifdef HAVE_ENOTIFY
   if (!(e_mod_notify_init())) 
     {
        /* shutdown config */
        il_ind_config_shutdown();

        /* clear module directory variable */
        if (_ind_mod_dir) eina_stringshare_del(_ind_mod_dir);
        _ind_mod_dir = NULL;
        return NULL;
     }
#endif

   EINA_LIST_FOREACH(e_comp_list(), l, comp)
     {
        E_Zone *zone;
        Eina_List *zl;

        /* TODO: Make this configurable so illume2 can be run
         * on just one zone/screen/etc */

        /* for each zone, create an indicator window */
        EINA_LIST_FOREACH(comp->zones, zl, zone) 
          {
             Ind_Win *iwin;

             /* try to create new indicator window */
             if (!(iwin = e_mod_ind_win_new(zone))) continue;
             iwins = eina_list_append(iwins, iwin);
          }
     }

   return m;
}

EAPI int 
e_modapi_shutdown(E_Module *m __UNUSED__) 
{
   Ind_Win *iwin;

   /* destroy the indicator windows */
   EINA_LIST_FREE(iwins, iwin)
     e_object_del(E_OBJECT(iwin));

   /* reset indicator geometry for conformant apps */
   ecore_x_e_illume_indicator_geometry_set(ecore_x_window_root_first_get(), 
                                           0, 0, 0, 0);

#ifdef HAVE_ENOTIFY
   e_mod_notify_shutdown();
#endif

   /* shutdown config */
   il_ind_config_shutdown();

   /* clear module directory variable */
   if (_ind_mod_dir) eina_stringshare_del(_ind_mod_dir);
   _ind_mod_dir = NULL;

   return 1;
}

EAPI int 
e_modapi_save(E_Module *m __UNUSED__) 
{
   return il_ind_config_save();
}