summaryrefslogtreecommitdiff
path: root/src/bin/e_init.c
blob: 28c1b723e7f35760b0561c5f01c6c1343352ea1a (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "e.h"

E_API int E_EVENT_INIT_DONE = 0;

/* local variables */
static int done = 0;
static int undone = 0;
static Evas_Object *_e_init_object = NULL;
static Eina_List *splash_objs = NULL;
static Ecore_Timer *_e_init_timeout_timer = NULL;

static Eina_Bool
_e_init_cb_timeout(void *data EINA_UNUSED)
{
   _e_init_timeout_timer = NULL;
   e_init_hide();
   return ECORE_CALLBACK_CANCEL;
}

static void
_e_init_cb_signal_done_ok(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
{
   e_init_hide();
}

static void
_e_init_render_pre(void *data EINA_UNUSED, Evas *e, void *info EINA_UNUSED)
{
   Eina_List *l;
   Evas_Object *o;

   evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, _e_init_render_pre);
   EINA_LIST_FOREACH(splash_objs, l, o)
     {
        evas_object_show(o);
     }
}

/* public functions */
EINTERN int
e_init_init(void)
{
   E_EVENT_INIT_DONE = ecore_event_type_new();

   done = 0;
   return 1;
}

EINTERN int
e_init_shutdown(void)
{
   /* if not killed, kill init */
   e_init_hide();
   return 1;
}

E_API void
e_init_show(void)
{
   Evas_Object *o;
   E_Zone *zone;
   Eina_List *l;
   /* exec init */

   EINA_LIST_FOREACH(e_comp->zones, l, zone)
     {
        o = edje_object_add(e_comp->evas);
        if (!zone->num)
          {
             e_theme_edje_object_set(o, NULL, "e/init/splash");
             evas_object_name_set(o, "_e_init_object");
             _e_init_object = o;
          }
        else
          {
             e_theme_edje_object_set(o, NULL, "e/init/extra_screen");
             evas_object_name_set(o, "_e_init_extra_screen");
          }
        evas_object_clip_set(o, zone->bg_clip_object);
        evas_object_move(o, zone->x, zone->y);
        evas_object_resize(o, zone->w, zone->h);
        evas_object_layer_set(o, E_LAYER_MAX - 1000);
        splash_objs = eina_list_append(splash_objs, o);
     }
   evas_event_callback_add
     (e_comp->evas, EVAS_CALLBACK_RENDER_PRE, _e_init_render_pre, NULL);
   edje_object_part_text_set(_e_init_object, "e.text.disable_text",
                             "Disable splash screen");
   edje_object_signal_callback_add(_e_init_object, "e,state,done_ok", "e",
                                   _e_init_cb_signal_done_ok, NULL);
   _e_init_timeout_timer = ecore_timer_loop_add(240.0, _e_init_cb_timeout, NULL);
   e_init_title_set(_("Enlightenment"));
   e_init_version_set(VERSION);
}

E_API void
e_init_hide(void)
{
   E_FREE_LIST(splash_objs, evas_object_del);
   e_comp_shape_queue();
   _e_init_object = NULL;
   E_FREE_FUNC(_e_init_timeout_timer, ecore_timer_del);
}

E_API void
e_init_title_set(const char *str)
{
   if (!_e_init_object) return;
   edje_object_part_text_set(_e_init_object, "e.text.title", str);
}

E_API void
e_init_version_set(const char *str)
{
   if (!_e_init_object) return;
   edje_object_part_text_set(_e_init_object, "e.text.version", str);
}

E_API void
e_init_status_set(const char *str)
{
   if (!_e_init_object) return;
   edje_object_part_text_set(_e_init_object, "e.text.status", str);
}

E_API void
e_init_done(void)
{
   Eina_List *l;
   Evas_Object *o;

   undone--;
   if (undone > 0) return;
   if (!done)
     {
        done = 1;
        ecore_event_add(E_EVENT_INIT_DONE, NULL, NULL, NULL);
        EINA_LIST_FOREACH(splash_objs, l, o)
          {
             edje_object_signal_emit(o, "e,state,done", "e");
          }
     }
}

E_API void
e_init_undone(void)
{
   undone++;
}

E_API int
e_init_count_get(void)
{
   return undone;
}