summaryrefslogtreecommitdiff
path: root/src/modules/illume-softkey/e_mod_main.c
blob: 4ccf737b088ac742c34227ac6f31f2a9ed76218b (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
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include "e_mod_sft_win.h"

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

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

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

EAPI void *
e_modapi_init(E_Module *m) 
{
   E_Manager *man;
   Eina_List *ml;

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

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

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

   /* loop through the managers (root windows) */
   EINA_LIST_FOREACH(e_manager_list(), ml, man) 
     {
        E_Container *con;
        Eina_List *cl;

        /* loop through containers */
        EINA_LIST_FOREACH(man->containers, cl, con) 
          {
             E_Zone *zone;
             Eina_List *zl;

             /* for each zone, create a softkey window */
             EINA_LIST_FOREACH(con->zones, zl, zone) 
               {
                  Sft_Win *swin;

                  /* try to create new softkey window */
                  if (!(swin = e_mod_sft_win_new(zone))) continue;
                  swins = eina_list_append(swins, swin);
               }
          }
     }

   return m;
}

EAPI int 
e_modapi_shutdown(E_Module *m __UNUSED__) 
{
   Sft_Win *swin;

   /* destroy the softkey windows */
   EINA_LIST_FREE(swins, swin)
     e_object_del(E_OBJECT(swin));

   /* reset softkey geometry for conformant apps */
   ecore_x_e_illume_softkey_geometry_set(ecore_x_window_root_first_get(), 
                                         0, 0, 0, 0);

   /* shutdown config */
   il_sft_config_shutdown();

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

   return 1;
}

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