2004-12-09 05:56:06 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
2007-03-24 15:53:16 -07:00
|
|
|
/* TODO:
|
|
|
|
* - Need some kind of "wait for exit" system, maybe register with
|
|
|
|
* e_config? startup and restart apps could also be in e_config
|
|
|
|
*/
|
|
|
|
|
2004-12-09 05:56:06 -08:00
|
|
|
/* local subsystem functions */
|
2012-11-14 01:57:11 -08:00
|
|
|
static void _e_startup(void);
|
|
|
|
static void _e_startup_next_cb(void *data);
|
2011-01-27 13:14:30 -08:00
|
|
|
static Eina_Bool _e_startup_event_cb(void *data, int ev_type, void *ev);
|
2004-12-09 05:56:06 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
2011-01-19 23:51:46 -08:00
|
|
|
static E_Order *startup_apps = NULL;
|
|
|
|
static int start_app_pos = -1;
|
2011-01-27 13:14:30 -08:00
|
|
|
static Ecore_Event_Handler *desktop_cache_update_handler = NULL;
|
2004-12-09 05:56:06 -08:00
|
|
|
|
|
|
|
/* externally accessible functions */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2004-12-09 05:56:06 -08:00
|
|
|
e_startup(E_Startup_Mode mode)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2011-01-19 23:51:46 -08:00
|
|
|
|
2004-12-09 05:56:06 -08:00
|
|
|
if (mode == E_STARTUP_START)
|
2009-04-10 23:20:11 -07:00
|
|
|
{
|
2012-11-14 01:57:11 -08:00
|
|
|
e_user_dir_concat_static(buf, "applications/startup/.order");
|
|
|
|
if (!ecore_file_exists(buf))
|
|
|
|
e_prefix_data_concat_static(buf, "data/applications/startup/.order");
|
2009-04-10 23:20:11 -07:00
|
|
|
}
|
2004-12-09 05:56:06 -08:00
|
|
|
else if (mode == E_STARTUP_RESTART)
|
2009-04-10 23:20:11 -07:00
|
|
|
{
|
2012-11-14 01:57:11 -08:00
|
|
|
e_user_dir_concat_static(buf, "applications/restart/.order");
|
|
|
|
if (!ecore_file_exists(buf))
|
|
|
|
e_prefix_data_concat_static(buf, "data/applications/restart/.order");
|
2009-04-10 23:20:11 -07:00
|
|
|
}
|
2011-01-27 13:14:30 -08:00
|
|
|
desktop_cache_update_handler =
|
2012-11-14 01:57:11 -08:00
|
|
|
ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_BUILD,
|
|
|
|
_e_startup_event_cb,
|
|
|
|
strdup(buf));
|
2007-09-23 18:16:47 -07:00
|
|
|
e_init_undone();
|
2004-12-09 05:56:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_startup(void)
|
|
|
|
{
|
2007-03-24 15:53:16 -07:00
|
|
|
Efreet_Desktop *desktop;
|
2012-08-22 00:02:41 -07:00
|
|
|
char buf[8192];
|
2011-01-19 23:51:46 -08:00
|
|
|
|
2005-06-22 07:09:17 -07:00
|
|
|
if (!startup_apps)
|
|
|
|
{
|
2012-11-14 01:57:11 -08:00
|
|
|
e_init_done();
|
|
|
|
return;
|
2005-06-22 07:09:17 -07:00
|
|
|
}
|
2008-10-22 04:49:33 -07:00
|
|
|
desktop = eina_list_nth(startup_apps->desktops, start_app_pos);
|
2004-12-09 05:56:06 -08:00
|
|
|
start_app_pos++;
|
2007-03-24 15:53:16 -07:00
|
|
|
if (!desktop)
|
2004-12-09 05:56:06 -08:00
|
|
|
{
|
2012-11-14 01:57:11 -08:00
|
|
|
e_object_del(E_OBJECT(startup_apps));
|
|
|
|
startup_apps = NULL;
|
|
|
|
start_app_pos = -1;
|
|
|
|
e_init_done();
|
|
|
|
return;
|
2004-12-09 05:56:06 -08:00
|
|
|
}
|
2007-03-24 15:53:16 -07:00
|
|
|
e_exec(NULL, desktop, NULL, NULL, NULL);
|
2013-01-05 14:54:51 -08:00
|
|
|
snprintf(buf, sizeof(buf), _("Starting %s"), desktop->name);
|
2011-02-27 03:09:49 -08:00
|
|
|
e_init_status_set(buf);
|
2007-03-24 15:53:16 -07:00
|
|
|
ecore_job_add(_e_startup_next_cb, NULL);
|
2004-12-09 05:56:06 -08:00
|
|
|
}
|
|
|
|
|
2007-03-24 15:53:16 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_startup_next_cb(void *data EINA_UNUSED)
|
2004-12-09 05:56:06 -08:00
|
|
|
{
|
|
|
|
_e_startup();
|
|
|
|
}
|
2011-01-27 13:14:30 -08:00
|
|
|
|
2014-11-07 05:34:00 -08:00
|
|
|
static void
|
|
|
|
_e_startup_error_dialog(const char *msg)
|
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
|
|
|
|
dia = e_dialog_new(NULL, "E", "_startup_error_dialog");
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(dia);
|
|
|
|
|
|
|
|
e_dialog_title_set(dia, "ERROR!");
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, msg);
|
|
|
|
e_dialog_button_add(dia, _("Close"), NULL, NULL, NULL);
|
2014-11-02 18:35:13 -08:00
|
|
|
elm_win_center(dia->win, 1, 1);
|
|
|
|
e_win_no_remember_set(dia->win, 1);
|
2014-11-07 05:34:00 -08:00
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
|
2011-01-27 13:14:30 -08:00
|
|
|
static Eina_Bool
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_startup_event_cb(void *data, int ev_type EINA_UNUSED, void *ev)
|
2011-01-27 13:14:30 -08:00
|
|
|
{
|
|
|
|
char *buf;
|
2012-12-07 12:27:27 -08:00
|
|
|
Efreet_Event_Cache_Update *e;
|
2011-01-27 13:14:30 -08:00
|
|
|
|
2012-12-07 12:27:27 -08:00
|
|
|
e = ev;
|
|
|
|
if ((e) && (e->error))
|
2014-11-07 05:34:00 -08:00
|
|
|
{
|
|
|
|
fprintf(stderr, "E: efreet couldn't build cache\n");
|
2014-11-02 18:35:13 -08:00
|
|
|
_e_startup_error_dialog("E: Efreet could not build cache. "
|
2014-11-07 05:34:00 -08:00
|
|
|
"Please check your DBus setup");
|
|
|
|
}
|
2011-01-27 13:14:30 -08:00
|
|
|
ecore_event_handler_del(desktop_cache_update_handler);
|
|
|
|
buf = data;
|
|
|
|
startup_apps = e_order_new(buf);
|
|
|
|
if (startup_apps)
|
2012-11-14 01:57:11 -08:00
|
|
|
start_app_pos = 0;
|
2011-01-27 13:14:30 -08:00
|
|
|
free(buf);
|
|
|
|
_e_startup();
|
2011-02-27 08:30:44 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2011-01-27 13:14:30 -08:00
|
|
|
}
|
2012-11-14 01:57:11 -08:00
|
|
|
|