[E_BORDER] Add missing code to delete timer when the window gets DEICONIFY_APPROVE...
[platform/core/uifw/e17.git] / src / bin / e_startup.c
1 #include "e.h"
2
3 /* TODO:
4  * - Need some kind of "wait for exit" system, maybe register with
5  *   e_config? startup and restart apps could also be in e_config
6  */
7
8 /* local subsystem functions */
9 static void _e_startup(void);
10 static void _e_startup_next_cb(void *data);
11 static Eina_Bool _e_startup_event_cb(void *data, int ev_type, void *ev);
12
13 /* local subsystem globals */
14 static E_Order *startup_apps = NULL;
15 static int start_app_pos = -1;
16 static Ecore_Event_Handler *desktop_cache_update_handler = NULL;
17
18 /* externally accessible functions */
19 EAPI void
20 e_startup(E_Startup_Mode mode)
21 {
22    char buf[PATH_MAX];
23
24    if (mode == E_STARTUP_START)
25      {
26         e_user_dir_concat_static(buf, "applications/startup/.order");
27         if (!ecore_file_exists(buf))
28           e_prefix_data_concat_static(buf, "data/applications/startup/.order");
29      }
30    else if (mode == E_STARTUP_RESTART)
31      {
32         e_user_dir_concat_static(buf, "applications/restart/.order");
33         if (!ecore_file_exists(buf))
34           e_prefix_data_concat_static(buf, "data/applications/restart/.order");
35      }
36    desktop_cache_update_handler =
37       ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_BUILD,
38                               _e_startup_event_cb,
39                               strdup(buf));
40    e_init_undone();
41 }
42
43 /* local subsystem functions */
44 static void
45 _e_startup(void)
46 {
47    Efreet_Desktop *desktop;
48    char buf[8192];
49
50    if (!startup_apps)
51      {
52         e_init_done();
53         return;
54      }
55    desktop = eina_list_nth(startup_apps->desktops, start_app_pos);
56    start_app_pos++;
57    if (!desktop)
58      {
59         e_object_del(E_OBJECT(startup_apps));
60         startup_apps = NULL;
61         start_app_pos = -1;
62         e_init_done();
63         return;
64      }
65    e_exec(NULL, desktop, NULL, NULL, NULL);
66    snprintf(buf, sizeof(buf), "%s %s", _("Starting"), desktop->name);
67    e_init_status_set(buf);
68    ecore_job_add(_e_startup_next_cb, NULL);
69 }
70
71 static void
72 _e_startup_next_cb(void *data __UNUSED__)
73 {
74    _e_startup();
75 }
76
77 static Eina_Bool
78 _e_startup_event_cb(void *data, int ev_type __UNUSED__, void *ev __UNUSED__)
79 {
80    char *buf;
81
82    ecore_event_handler_del(desktop_cache_update_handler);
83    buf = data;
84    startup_apps = e_order_new(buf);
85    if (startup_apps)
86       start_app_pos = 0;
87    free(buf);
88    _e_startup();
89    return ECORE_CALLBACK_PASS_ON;
90 }