summaryrefslogtreecommitdiff
path: root/src/bin/e_main.c
blob: 8ef5b6ad8d90dd465e7975a44d0c0e43c263ef0e (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"
#include "config.h"

/* local subsystem functions */
static void _e_main_shutdown_push(int (*func)(void));
static void _e_main_shutdown(int errorcode);

static int  _e_main_x_shutdown(void);
static int  _e_main_dirs_init(void);
static int  _e_main_dirs_shutdown(void);
static int  _e_main_screens_init(void);
static int  _e_main_screens_shutdown(void);
static int  _e_main_path_init(void);
static int  _e_main_path_shutdown(void);
static int  _e_main_ipc_init(void);
static int  _e_main_ipc_shutdown(void);

static void _e_main_cb_x_fatal(void *data);
static int  _e_main_cb_signal_exit(void *data, int ev_type, void *ev);
static int  _e_main_cb_signal_hup(void *data, int ev_type, void *ev);
static int  _e_main_cb_x_flusher(void *data);
static int  _e_main_cb_idler_before(void *data);
static int  _e_main_cb_idler_after(void *data);

static int  _e_main_cb_startup_fake_status(void *data);
static int  _e_main_cb_startup_fake_end(void *data);

E_Path *path_data    = NULL;
E_Path *path_images  = NULL;
E_Path *path_fonts   = NULL;
E_Path *path_themes  = NULL;
E_Path *path_init    = NULL;
E_Path *path_icons   = NULL;
int     restart      = 0;

/* local subsystem globals */
#define MAX_LEVEL 32
static int (*_e_main_shutdown_func[MAX_LEVEL]) (void);
static int _e_main_level = 0;

static Evas_List *_e_main_idler_before_list = NULL;

static Ecore_Idle_Enterer *_e_main_idle_enterer_before  = NULL;
static Ecore_Idle_Enterer *_e_main_idle_enterer_after   = NULL;
static Ecore_Idle_Enterer *_e_main_idle_enterer_flusher = NULL;

/* externally accessible functions */
int
main(int argc, char **argv)
{
   int ipc_failed = 0;
   int i;
   int nosplash = 0;
   int nostartup = 0;
   int nowelcome = 0;
   int after_restart = 0; 
   char buf[1024];
   char *s;
   /* install the signal handlers. */ 
   struct sigaction sigsegv_action;
   sigsegv_action.sa_sigaction=&e_sigseg_act;
   sigsegv_action.sa_flags=0;
   sigaction(SIGSEGV, &sigsegv_action, NULL);


   /* for debugging by redirecting stdout of e to a log file to tail */
   setvbuf(stdout, NULL, _IONBF, 0);
      
   if (getenv("NOSPLASH")) nosplash = 1;
   if (getenv("NOSTARTUP")) nostartup = 1;
   if (getenv("NOWELCOME")) nowelcome = 1;
   
   if (getenv("RESTART"))
     {
	printf("after restart!!!\n");
	after_restart = 1;
     }
   putenv("RESTART=1");
   
   /* handle some command-line parameters */
   for (i = 1; i < argc; i++)
     {
	if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
	  {
	     i++;
	     
	     snprintf(buf, sizeof(buf), "DISPLAY=%s", argv[i]);
	     putenv(buf);
	  }
     }

   /* fix up DISPLAY to be :N.0 if no .screen is in it */
   s = getenv("DISPLAY");
   if (s)
     {
	char *p;
	
	p = strrchr(s, ':');
	if (!p)
	  {
	     snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s);
	     putenv(buf);
	  }
	else
	  {
	     p = strrchr(p, '.');
	     if (!p)
	       {
		  snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s);
		  putenv(buf);
	       }
	  }
     }
   
   /* init edje and set it up in frozen mode */
   edje_init();
   edje_freeze();
   
   /* basic ecore init */
   if (!ecore_init())
     {
	e_error_message_show("Enlightenment cannot Initialize Ecore!\n"
			     "Perhaps you are out of memory?");
	exit(-1);
     }
   _e_main_shutdown_push(ecore_shutdown);
   /* setup my args */
   ecore_app_args_set((int)argc, (const char **)argv);
   /* setup a handler for when e is asked to exit via a system signal */
   if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _e_main_cb_signal_exit, NULL))
     {
	e_error_message_show("Enlightenment cannot set up an exit signal handler.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   if(!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL))
     {
	e_error_message_show("Enlightenment cannot set up a HUP signal handler.\n"
                             "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }

   /* an idle enterer to be called before all others */
   _e_main_idle_enterer_before = ecore_idle_enterer_add(_e_main_cb_idler_before, NULL);
   
   /* init x */
   if (!ecore_x_init(NULL))
     {
	e_error_message_show("Enlightenment cannot initialize its X connection.\n"
			     "Have you set your DISPLAY variable?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(_e_main_x_shutdown);
   
   ecore_x_grab();
   
   ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);

   /* Init window manager hints */
   e_hints_init();
   
   /* init generic communications */
   if (!ecore_con_init())
     {
	e_error_message_show("Enlightenment cannot initialize the connections system.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(ecore_con_shutdown);
   /* init ipc */
   if (!ecore_ipc_init())
     {
	e_error_message_show("Enlightenment cannot initialize the ipc system.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(ecore_ipc_shutdown);
   /* init the evas wrapper */
   if (!ecore_evas_init())
     {
	e_error_message_show("Enlightenment cannot initialize the evas system.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(ecore_evas_shutdown);
   
   /* setup directories we will be using for configurations sotrage etc. */
   if (!_e_main_dirs_init())
     {
	e_error_message_show("Enlightenment cannot create directories in your home directory.\n"
			     "Perhaps you have no home directory or the disk is full?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(_e_main_dirs_shutdown);
   /* setup paths for finding things */
   if (!_e_main_path_init())
     {
	e_error_message_show("Enlightenment cannot set up paths for finding files.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(_e_main_path_shutdown);
   /* init config system */
   if (!e_config_init())
     {
	e_error_message_show("Enlightenment cannot set up its config system.");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(e_config_shutdown);
   
   /* setup edje to animate @ e_config->framerate frames per sec. */
   edje_frametime_set(1.0 / e_config->framerate);
   e_canvas_recache();
   
   /* setup init status window/screen */
   if (!e_init_init())
     {
	e_error_message_show("Enlightenment cannot set up init screen.\n"
			     "Perhaps you are out of memory?");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(e_init_shutdown);
   /* manage the root window */
   if (!_e_main_screens_init())
     {
	e_error_message_show("Enlightenment set up window management for all the screens on your system\n"
			     "failed. Perhaps another window manager is running?\n");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(_e_main_screens_shutdown);
   /* init app system */
   if (!e_app_init())
     {
	e_error_message_show("Enlightenment cannot set up its app system.");
	_e_main_shutdown(-1);
     }
   _e_main_shutdown_push(e_app_shutdown);

   /* tell the error system that it can use gui dialogs now */
   e_error_gui_set(1);
   
   /* setup e ipc service */
   if (!_e_main_ipc_init())
     {
	e_error_message_show(
			     "Enlightenment cannot set up the IPC socket.\n"
			     "It likely is already in use by an exisiting copy of Enlightenment.\n"
			     "Double check to see if Enlightenment is not already on this display,\n"
			     "but if that fails try deleting all files in ~/.ecore/enlightenment-*\n"
			     "and try running again.");
	ipc_failed = 1;
     }
   else
     _e_main_shutdown_push(_e_main_ipc_shutdown);

   /* setup module loading etc. FIXME: check return value */
   e_module_init();

   if (!e_iconify_init())
     {
	e_error_message_show("Enlightenment cannot setup its iconify system.");
	_e_main_shutdown(-1);	
     }
   else
     _e_main_shutdown_push(e_iconify_shutdown);

   if (!nowelcome)
     {
	/* explicitly show a gui dialog */
	e_error_dialog_show("Welcome to Enlightenment 0.17",
			    "This is program has barely been started on, so it is not complete by a long\n"
			    "shot. Please do NOT expect anything to work properly at this stage. It's\n"
			    "being worked on.\n"
			    "\n"
			    "Hit \"OK\" to dismiss this dialog and continue using Enlightenment 0.17.");
     }
   
   if (ipc_failed)
     e_error_dialog_show("Enlightenment IPC setup error!",
			 "Enlightenment cannot set up the IPC socket.\n"
			 "It likely is already in use by an exisiting copy of Enlightenment.\n"
			 "Double check to see if Enlightenment is not already on this display,\n"
			 "but if that fails try deleting all files in ~/.ecore/enlightenment-*\n"
			 "and try running again.");
   
   /* add in a handler that just before we go idle we flush x */
   _e_main_idle_enterer_flusher = ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
      
   /* an intle enterer to be called after all others */
   _e_main_idle_enterer_after = ecore_idle_enterer_add(_e_main_cb_idler_after, NULL);

   ecore_x_ungrab();
   
   e_init_title_set("Enlightenment");
   e_init_version_set(VERSION);
   e_init_status_set("Enlightenment Starting. Please wait.");
   
   if (!nostartup)
     {
	if (after_restart) e_startup(E_STARTUP_RESTART);
	else e_startup(E_STARTUP_START);
     }
   
   if ((nosplash) || (after_restart))
     {
	ecore_timer_add(0.0, _e_main_cb_startup_fake_end, NULL);
     }
   else
     {
	ecore_timer_add( 3.0, _e_main_cb_startup_fake_status, "Artificially slowing startup so you can see it all.");
	ecore_timer_add( 7.5, _e_main_cb_startup_fake_status, "This is development code, so be warned.");
	ecore_timer_add(12.0, _e_main_cb_startup_fake_status, "Most features do not work yet, and those that do are buggy.");
	ecore_timer_add(16.0, _e_main_cb_startup_fake_end, NULL);
     }
   
   /* start our main loop */
   ecore_main_loop_begin();
   
   /* ask all modules to save their config and then shutdown */
   /* NB: no need to do this as config shutdown will flush any saves */
   /*     and all changed config was already saved before */
   e_config_save_flush();
   e_module_shutdown();

   /* unroll our stack of shutdown functions with exit code of 0 */
   _e_main_shutdown(0);
   
   /* if we were flagged to restart, then  restart. */
   if (restart)
     {
	printf("Restart...\n");
	ecore_app_restart();
	printf("eh? restart failed!\n");
     }
   
   /* just return 0 to keep the compiler quiet */
   return 0;
}

/* FIXME: make save to deleet within a callback */
E_Before_Idler *
e_main_idler_before_add(int (*func) (void *data), void *data, int once)
{
   E_Before_Idler *eb;
   
   eb = calloc(1, sizeof(E_Before_Idler));
   eb->func = func;
   eb->data = data;
   eb->once = once;
   _e_main_idler_before_list = evas_list_append(_e_main_idler_before_list, eb);
   return eb;
}

void
e_main_idler_before_del(E_Before_Idler *eb)
{
   eb->delete_me = 1;
}

/* local subsystem functions */
static void
_e_main_shutdown_push(int (*func) (void))
{
   _e_main_level++;
   if (_e_main_level > MAX_LEVEL)
     {
	_e_main_level--;
	e_error_message_show("WARNING: too many init levels. MAX = %i", MAX_LEVEL);
	return;
     }
   _e_main_shutdown_func[_e_main_level - 1] = func;
}

static void
_e_main_shutdown(int errorcode)
{
   int i;
   
   printf("E17: Begin shutdown procedure!\n");
   if (_e_main_idle_enterer_before)
     {
	ecore_idle_enterer_del(_e_main_idle_enterer_before);
	_e_main_idle_enterer_before = NULL;
     }
   if (_e_main_idle_enterer_after)
     {
	ecore_idle_enterer_del(_e_main_idle_enterer_after);
	_e_main_idle_enterer_after = NULL;
     }
   if (_e_main_idle_enterer_flusher)
     {
	ecore_idle_enterer_del(_e_main_idle_enterer_flusher);
	_e_main_idle_enterer_flusher = NULL;
     }
   for (i = _e_main_level - 1; i >= 0; i--)
     (*_e_main_shutdown_func[i])();
   if (errorcode < 0) exit(errorcode);
}

static int
_e_main_x_shutdown(void)
{
   ecore_x_ungrab();
   ecore_x_focus_reset();
   ecore_x_events_allow_all();

   ecore_x_shutdown();

   return 1;
}

static int
_e_main_dirs_init(void)
{
   char *homedir;
   char buf[PATH_MAX];
   const char *dirs[] =
     {
	"%s/.e",
	"%s/.e/e",
	"%s/.e/e/images",
	"%s/.e/e/fonts",
	"%s/.e/e/themes",
	"%s/.e/e/init",
	"%s/.e/e/icons",
	"%s/.e/e/backgrounds",
	"%s/.e/e/applications",
	"%s/.e/e/applications/all",
	"%s/.e/e/applications/favorite",
	"%s/.e/e/applications/bar",
	"%s/.e/e/applications/startup",
	"%s/.e/e/applications/restart",
	"%s/.e/e/modules",
	"%s/.e/e/config"
     };
   int i;
   
   homedir = e_user_homedir_get();
   if (!homedir) return 0;
   for (i = 0; i < (int)(sizeof(dirs) / sizeof(char *)); i++)
     {
	snprintf(buf, sizeof(buf), dirs[i], homedir);
	if (!e_file_mkpath(buf))
	  {
	     e_error_message_show("Error creating directory:\n"
				  "%s",
				  buf);
	     free(homedir);
	     return 0;
	  }
     }
   
   /* FIXME: THIS is a hack to get people started!!! */
   /* err dont just disable it - replace it with a proper wizard tool */
   /* outside e's main source to populate these directories from gnome/kde */
   /* app menu data etc. */
   snprintf(buf, sizeof(buf), "%s/.e/e/applications/all/eterm.eapp", homedir);
   if (!e_file_exists(buf))
     {
	printf("GETTING YOU STARTED!\n");
	snprintf(buf, sizeof(buf), 
		 "gzip -d -c < %s/data/other/applications.tar.gz | "
		 "(cd %s/.e/e/ ; tar -xf -)", 
		 PACKAGE_DATA_DIR,
		 homedir);
	system(buf);
     }
   free(homedir);
   
   return 1;
}

static int
_e_main_dirs_shutdown(void)
{
   return 1;
}

static int
_e_main_screens_init(void)
{
   Ecore_X_Window *roots;
   int num, i;

   if (!e_atoms_init()) return 0;
   if (!e_manager_init()) return 0;
   if (!e_container_init()) return 0;
   if (!e_zone_init()) return 0;
   if (!e_desk_init()) return 0;
   if (!e_gadman_init()) return 0;
   if (!e_menu_init()) return 0;
   
   num = 0;
   roots = ecore_x_window_root_list(&num);
   if ((!roots) || (num <= 0))
     {
	e_error_message_show("X reports there are no root windows and %i screens!\n", 
			     num);
	return 0;
     }
   if (!e_focus_init()) return 0;
   if (!e_border_init()) return 0;
   for (i = 0; i < num; i++)
     {
	E_Manager *man;
	E_Container *con;
	
	man = e_manager_new(roots[i]);
	e_init_show();
	if (man) e_manager_show(man);
	else
	  {
	     e_error_message_show("Cannot create manager object for screen %i\n", 
				  i);
	     return 0;
	  }
	con = e_container_new(man);
	if (con)
	  {
	     e_manager_manage_windows(man);
	     ecore_x_netwm_desk_roots_set(man->root, 1, &(con->win));
	     e_container_show(con);
	  }
	else
	  {
	     e_error_message_show("Cannot create desktop object for manager on screen %i\n", 
				  i);
	     return 0;
	  }
	/* FIXME
	 * This should be removed!
	  {
	     E_Gadman_Client *gmc;
	     
	     gmc = e_gadman_client_new(con->gadman);
	     gmc->x = 0;
	     gmc->y = 300;
	     gmc->w = 100;
	     gmc->h = 100;
	     e_gadman_client_policy_set(gmc, 
//					E_GADMAN_POLICY_EDGES | 
					E_GADMAN_POLICY_ANYWHERE |
					E_GADMAN_POLICY_HMOVE | 
					E_GADMAN_POLICY_VMOVE |
					E_GADMAN_POLICY_HSIZE | 
					E_GADMAN_POLICY_VSIZE);
	     e_gadman_client_min_size_set(gmc, 20, 20);
	     e_gadman_client_auto_size_set(gmc, 50, 200);
	     e_gadman_client_align_set(gmc, 0.0, 0.5);
	     e_client_gadman_edge_set(gmc, E_GADMAN_EDGE_LEFT);
	     e_gadman_client_domain_set(gmc, "test", 0);
	     e_gadman_client_load(gmc);

	     gmc = e_gadman_client_new(con->gadman);
	     gmc->x = 0;
	     gmc->y = 400;
	     gmc->w = 100;
	     gmc->h = 100;
	     e_gadman_client_policy_set(gmc, 
//					E_GADMAN_POLICY_EDGES | 
					E_GADMAN_POLICY_ANYWHERE |
					E_GADMAN_POLICY_HMOVE | 
					E_GADMAN_POLICY_VMOVE |
					E_GADMAN_POLICY_HSIZE | 
					E_GADMAN_POLICY_VSIZE);
	     e_gadman_client_min_size_set(gmc, 20, 20);
	     e_gadman_client_auto_size_set(gmc, 50, 200);
	     e_gadman_client_align_set(gmc, 0.0, 0.5);
	     e_client_gadman_edge_set(gmc, E_GADMAN_EDGE_LEFT);
	     e_gadman_client_domain_set(gmc, "test", 1);
	     e_gadman_client_load(gmc);

	     gmc = e_gadman_client_new(con->gadman);
	     gmc->x = 0;
	     gmc->y = 500;
	     gmc->w = 100;
	     gmc->h = 100;
	     e_gadman_client_policy_set(gmc, 
//					E_GADMAN_POLICY_EDGES | 
					E_GADMAN_POLICY_ANYWHERE |
					E_GADMAN_POLICY_HMOVE | 
					E_GADMAN_POLICY_VMOVE |
					E_GADMAN_POLICY_HSIZE | 
					E_GADMAN_POLICY_VSIZE);
	     e_gadman_client_min_size_set(gmc, 20, 20);
	     e_gadman_client_auto_size_set(gmc, 50, 200);
	     e_gadman_client_align_set(gmc, 0.0, 0.5);
	     e_client_gadman_edge_set(gmc, E_GADMAN_EDGE_LEFT);
	     e_gadman_client_domain_set(gmc, "test", 2);
	     e_gadman_client_load(gmc);
	  }
	 */
     }
   free(roots);
   ecore_x_sync();
   return 1;
}

static int
_e_main_screens_shutdown(void)
{
   e_border_shutdown();
   e_focus_shutdown();
   e_menu_shutdown();
   e_gadman_shutdown();
   e_desk_shutdown();
   e_zone_shutdown();
   e_container_shutdown();
   e_manager_shutdown();
   e_atoms_shutdown();
   return 1;
}

static int
_e_main_path_init(void)
{
   path_data = e_path_new();
   if (!path_data)
     {
	e_error_message_show("Cannot allocate path for path_data\n");
	return 0;
     }
   e_path_path_append(path_data, PACKAGE_DATA_DIR"/data");
   path_images = e_path_new();
   if (!path_images)
     {
	e_error_message_show("Cannot allocate path for path_images\n");
	return 0;
     }
   e_path_path_append(path_images, "~/.e/e/images");
   e_path_path_append(path_images, PACKAGE_DATA_DIR"/data/images");
   path_fonts = e_path_new();
   if (!path_fonts)
     {
	e_error_message_show("Cannot allocate path for path_fonts\n");
	return 0;
     }
   e_path_path_append(path_fonts, "~/.e/e/fonts");
   e_path_path_append(path_fonts, PACKAGE_DATA_DIR"/data/fonts");
   path_themes = e_path_new();
   if (!path_themes)
     {
	e_error_message_show("Cannot allocate path for path_themes\n");
	return 0;
     }
   e_path_path_append(path_themes, "~/.e/e/themes");
   e_path_path_append(path_themes, PACKAGE_DATA_DIR"/data/themes");
   path_icons = e_path_new();
   if (!path_icons)
     {
	e_error_message_show("Cannot allocate path for path_icons\n");
	return 0;
     }
   e_path_path_append(path_icons, "~/.e/e/icons");
   e_path_path_append(path_icons, PACKAGE_DATA_DIR"/data/icons");
   path_init = e_path_new();
   if (!path_init)
     {
	e_error_message_show("Cannot allocate path for path_init\n");
	return 0;
     }
   e_path_path_append(path_init, "~/.e/e/init");
   e_path_path_append(path_init, PACKAGE_DATA_DIR"/data/init");
   return 1;
}

static int
_e_main_path_shutdown(void)
{
   if (path_data)
     {
	e_object_del(E_OBJECT(path_data));
	path_data = NULL;
     }
   if (path_images)
     {
	e_object_del(E_OBJECT(path_images));
	path_images = NULL;
     }
   if (path_fonts)
     {
	e_object_del(E_OBJECT(path_fonts));
	path_fonts = NULL;
     }
   if (path_themes)
     {
	e_object_del(E_OBJECT(path_themes));
	path_themes = NULL;
     }
   if (path_icons)
     {
	e_object_del(E_OBJECT(path_icons));
	path_icons = NULL;
     }
   if (path_init)
     {
	e_object_del(E_OBJECT(path_init));
	path_init = NULL;
     }
   return 1;
}

static int
_e_main_ipc_init(void)
{
   if (!e_ipc_init())
     {
	e_error_message_show("Cannot init IPC subsystem!\n");
	return 0;
     }
   return 1;
}

static int
_e_main_ipc_shutdown(void)
{
   e_ipc_shutdown();
   return 1;
}

static void
_e_main_cb_x_fatal(void *data)
{
   e_error_gui_set(0);
   e_error_message_show("Lost X connection.");
   ecore_main_loop_quit();
   _e_main_shutdown(-1);
}

static int
_e_main_cb_signal_exit(void *data, int ev_type, void *ev)
{
   /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
   ecore_main_loop_quit();
   return 1;
}

static int
_e_main_cb_signal_hup(void *data, int ev_type, void *ev)
{
   /* called on SIGHUP to restart Enlightenment */
   printf("RESTART ON!\n");
   restart = 1;
   ecore_main_loop_quit();
   return 1;
}

static int
_e_main_cb_x_flusher(void *data)
{
   ecore_x_flush();
   return 1;
}

static int
_e_main_cb_idler_before(void *data)
{
   Evas_List *l, *pl;
   
   e_menu_idler_before();
   e_focus_idler_before();
   e_border_idler_before();
   for (l = _e_main_idler_before_list; l; l = l->next)
     {
	E_Before_Idler *eb;
	
	eb = l->data;
	if (!eb->delete_me)
	  {
	     if (!eb->func(eb->data)) eb->delete_me = 1;
	  }
     }
   for (l = _e_main_idler_before_list; l;)
     {
	E_Before_Idler *eb;
	
	eb = l->data;
	pl = l;
	l = l->next;
	if ((eb->once) || (eb->delete_me))
	  {
	     _e_main_idler_before_list =
	       evas_list_remove_list(_e_main_idler_before_list, pl);
	     free(eb);
	  }
     }
   edje_thaw();
//   printf("IN to idle... %3.3f\n", ecore_time_get());
   return 1;
}

static int
_e_main_cb_idler_after(void *data)
{
//   printf("OUT of idle... %3.3f\n", ecore_time_get());
   edje_freeze();
   return 1;
}

static int
_e_main_cb_startup_fake_status(void *data)
{
   e_init_status_set((const char *)data);
   return 0;
}

static int
_e_main_cb_startup_fake_end(void *data)
{
   e_init_hide();
   return 0;
}