summaryrefslogtreecommitdiff
path: root/src/box.c
blob: b61a5065cdb0eed7b539b856c37ef4c3a5863c1f (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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
/*
 *  Indicator
 *
 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

//#include <Ecore_X.h>
#include <Eina.h>
#include <display.h>

#include "common.h"
#include "box.h"
#include "icon.h"
#include "list.h"
#include "main.h"
#include "indicator_gui.h"
#include "util.h"
#include "message.h"
#include "log.h"

#define FIXED_BOX_PART_NAME		"elm.swallow.fixed"
#define SYSTEM_BOX_PART_NAME	"elm.swallow.system"
#define MINICTRL_BOX_PART_NAME	"elm.swallow.minictrl"
#define NOTI_BOX_PART_NAME	"elm.swallow.noti"
#define DIGIT_BOX_PART_NAME "percentage.digit.box"

#define CORRECTION 10
#define MORE_NOTI "more_notify"

Eina_List *_view_fixed_list;
Eina_List *_view_system_list;
Eina_List *_view_minictrl_list;
Eina_List *_view_noti_list;
Eina_List *_view_alarm_list;

/* FIXME */
#if 0
win_info *_win;
#endif
static int icon_show_state = 0;
int previous_noti_count = 0;



static Evas_Object *_box_add(Evas_Object * parent)
{
	Evas_Object *obj = NULL;

	retv_if(!parent, NULL);

	obj = elm_box_add(parent);
	retv_if(!obj, NULL);
	evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_fill_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);

	/* Align to left-top */
	elm_box_horizontal_set(obj, EINA_TRUE);
	evas_object_show(obj);

	return obj;
}


#if 0
static void _update_window(win_info *win)
{
	int root_w, root_h;
	Ecore_X_Window xwin, root;

	retif(win == NULL, , "Invalid parameter!");

	xwin = elm_win_xwindow_get(win->win);
	if (!xwin) return;
	root = ecore_x_window_root_get(xwin);
	if (!root) return;
	ecore_x_window_size_get(root, &root_w, &root_h);

	if (win->angle == 0 || win->angle == 180) win->w = root_w;
	else win->w = root_h;

	switch (win->angle) {
	case 0:
		ecore_x_window_shape_input_rectangle_set(xwin, root_w - win->w, 0, win->w, win->h);
		break;
	case 90:
		ecore_x_window_shape_input_rectangle_set(xwin, 0, 0, win->h, win->w);
		break;
	case 180:
		ecore_x_window_shape_input_rectangle_set(xwin, 0, 0, win->w, win->h);
		break;
	case 270:
		ecore_x_window_shape_input_rectangle_set(xwin, 0, root_h - win->w, win->h, win->w);
		break;
	default:
		break;
	}
}
#endif

#if 0
void box_delete_noti_icon_all(win_info *win)
{
	icon_s *icon;
	Eina_List *l;

	elm_box_unpack_all(win->_noti_box);

	EINA_LIST_FOREACH(_view_noti_list, l, icon) {
		if (icon->obj_exist == EINA_TRUE) {
			if (icon_del(icon) == EINA_TRUE) {
				icon->obj_exist = EINA_FALSE;
			}
		}
	}
}
#endif


static void _fixed_box_pack_icon(win_info *win, icon_s *icon)
{
	ret_if(!win);
	ret_if(!icon);

	switch (icon->type) {
		case INDICATOR_IMG_ICON:
			evas_object_show(icon->img_obj.obj);
			elm_box_pack_start(win->_fixed_box[icon->priority], icon->img_obj.obj);
			break;
		case INDICATOR_TXT_ICON:
			break;
		case INDICATOR_TXT_WITH_IMG_ICON:
			break;
		case INDICATOR_DIGIT_ICON:
			switch(icon->digit_area) {
				case DIGIT_UNITY:
					evas_object_show(icon->img_obj.obj);
					elm_box_pack_end(win->_digit_box, icon->img_obj.obj);
					break;
				case DIGIT_DOZENS:
					evas_object_show(icon->img_obj.obj);
					elm_box_pack_end(win->_digit_box, icon->img_obj.obj);
					break;
				case DIGIT_DOZENS_UNITY:
					evas_object_show(icon->img_obj.obj);
					elm_box_pack_end(win->_digit_box, icon->img_obj.obj);
					break;
				case DIGIT_HUNDREDS:
					evas_object_show(icon->img_obj.obj);
					elm_box_pack_end(win->_digit_box, icon->img_obj.obj);
					break;
				default:
					_E("default");
					break;
			}
			break;
		default:
			_E("default");
			break;
	}
#ifdef _SUPPORT_SCREEN_READER
	util_icon_access_register(icon);
#endif
}



static void _box_pack_icon(icon_s *icon, Evas_Object *box)
{
	ret_if(!icon);
	ret_if(!box);

	switch (icon->type) {
	case INDICATOR_IMG_ICON:
		evas_object_show(icon->img_obj.obj);
		elm_box_pack_end(box, icon->img_obj.obj);
		break;
	case INDICATOR_TXT_ICON:
		break;
	case INDICATOR_TXT_WITH_IMG_ICON:
		break;
	case INDICATOR_DIGIT_ICON:
		evas_object_show(icon->img_obj.obj);
		elm_box_pack_end(box, icon->img_obj.obj);
		break;
	default:
		_E("default");
		break;
	}
#ifdef _support_screen_reader
	util_icon_access_register(icon);
#endif
	if (icon->area == INDICATOR_ICON_AREA_NOTI || icon->area == INDICATOR_ICON_AREA_ALARM) {
		util_start_noti_ani(icon);
	}
}



static void _create_img_obj(icon_s *icon)
{
	Evas_Object *img_eo = NULL;

	ret_if(!icon);

	img_eo = evas_object_data_get(icon->img_obj.obj, DATA_KEY_IMG_ICON);
	evas_object_size_hint_min_set(img_eo, ELM_SCALE_SIZE(icon->img_obj.width), ELM_SCALE_SIZE(icon->img_obj.height));
	box_handle_animated_gif(icon);
}



static void _update_icon(win_info *win, Eina_List *list)
{
	icon_s *icon;
	Eina_List *l;

	ret_if(!win);
	ret_if(!list);

	EINA_LIST_FOREACH(list, l, icon) {
		if (icon->obj_exist == EINA_FALSE) {
			icon_add(win, icon);
		}

		if (icon->obj_exist == EINA_TRUE) {
			if (icon->area == INDICATOR_ICON_AREA_FIXED
			&& icon->priority <= INDICATOR_PRIORITY_FIXED_MAX) {
				_create_img_obj(icon);
				_fixed_box_pack_icon(win, icon);
			}
			if (icon->area == INDICATOR_ICON_AREA_SYSTEM
			&& icon->priority >= INDICATOR_PRIORITY_SYSTEM_MIN
			&& icon->priority <= INDICATOR_PRIORITY_SYSTEM_MAX) {
				_create_img_obj(icon);
				_box_pack_icon(icon, win->_non_fixed_box);
			}
			if (icon->area == INDICATOR_ICON_AREA_MINICTRL
			&& icon->priority >= INDICATOR_PRIORITY_MINICTRL_MIN
			&& icon->priority <= INDICATOR_PRIORITY_MINICTRL_MAX) {
				_create_img_obj(icon);
				_box_pack_icon(icon, win->_minictrl_box);
			}
			if (icon->area == INDICATOR_ICON_AREA_NOTI) {
				_create_img_obj(icon);
				_box_pack_icon(icon, win->_noti_box);
			}
			if (icon->area == INDICATOR_ICON_AREA_ALARM) {
				_create_img_obj(icon);
				_box_pack_icon(icon, win->_alarm_box);
			}
		}
	}
}



extern unsigned int box_get_count(Box_List list)
{
	int count = 0;

	switch (list) {
	case FIXED_LIST:
		count = eina_list_count(_view_fixed_list);
		break;
	case SYSTEM_LIST:
		count = eina_list_count(_view_system_list);
		break;
	case MINICTRL_LIST:
		count = eina_list_count(_view_minictrl_list);
		break;
	case NOTI_LIST:
		count = eina_list_count(_view_noti_list);
		break;
	default:
		_D("List dose not exist");
		break;
	}

	return count;
}



static void _update_display(win_info *win)
{
	int i = 0;

	ret_if(!win);

	if (box_get_count(SYSTEM_LIST)) {
		util_signal_emit(win->data, "indicator.system.show", "indicator.prog");
	} else {
		util_signal_emit(win->data, "indicator.system.hide", "indicator.prog");
	}

	if (box_get_count(MINICTRL_LIST)) {
		util_signal_emit(win->data, "indicator.minictrl.show", "indicator.prog");
	} else {
		util_signal_emit(win->data, "indicator.minictrl.hide", "indicator.prog");
	}

	if (box_get_count(NOTI_LIST)) {
		util_signal_emit(win->data, "indicator.noti.show", "indicator.prog");
	} else {
		util_signal_emit(win->data, "indicator.noti.hide", "indicator.prog");
	}


	if (message_ani_playing_check() == 1) {
		return;
	}

	for (i = 0; i < FIXED_COUNT; ++i) {
		elm_box_unpack_all(win->_fixed_box[i]);
	}

	elm_box_unpack_all(win->_non_fixed_box);
	elm_box_unpack_all(win->_minictrl_box);
	elm_box_unpack_all(win->_noti_box);
	elm_box_unpack_all(win->_alarm_box);
	elm_box_unpack_all(win->_digit_box);

	_update_icon(win, _view_fixed_list);
	_update_icon(win, _view_system_list);
	_update_icon(win, _view_minictrl_list);
	_update_icon(win, _view_noti_list);
	_update_icon(win, _view_alarm_list);

#if 0
	if (win) _update_window(win);
#endif
}



extern void box_update_display(win_info *win)
{
	ret_if(!win);

#if 0
	_update_window(win);
#endif
	icon_reset_list();
	_update_display(win);
	icon_handle_more_notify_icon(win);
}



extern int box_pack(icon_s *icon)
{
	struct appdata *ad = NULL;
	int noti_count = 0;

	retv_if(!icon, 0);

	ad = (struct appdata*)icon->ad;

	if (box_exist_icon(icon)) return OK;

	if (INDICATOR_ICON_AREA_FIXED == icon->area) {
		icon->exist_in_view = EINA_TRUE;
		_view_fixed_list = eina_list_append(_view_fixed_list, icon);
	} else if(INDICATOR_ICON_AREA_SYSTEM == icon->area) {
		icon_s *data;
		Eina_List *l = NULL;

		EINA_LIST_FOREACH(_view_system_list, l, data) {
			if (data->priority <= icon->priority) {
				icon->exist_in_view = EINA_TRUE;
				_view_system_list = eina_list_append_relative_list(_view_system_list, icon, l);
				DBG("System (eina_list_append_relative_list) %s",icon->name);
				goto __CATCH;
			}
		}

		/* if finding condition is failed, append it at tail */
		icon->exist_in_view = EINA_TRUE;
		_view_system_list = eina_list_prepend(_view_system_list, icon);
		DBG("System prepend (Priority low) : %s",icon->name);
	} else if(INDICATOR_ICON_AREA_MINICTRL == icon->area) {
		INFO("Pack to MINICTRL list : %s", icon->name);
		icon_s *data;
		Eina_List *l;

		EINA_LIST_FOREACH(_view_minictrl_list, l, data) {
			if (data->priority <= icon->priority) {
				icon->exist_in_view = EINA_TRUE;
				_view_minictrl_list = eina_list_append_relative_list(_view_minictrl_list, icon, l);
				goto __CATCH;
			}
		}

		/* if finding condition is failed, append it at tail */
		icon->exist_in_view = EINA_TRUE;
		_view_minictrl_list = eina_list_append(_view_minictrl_list, icon);
	} else if(INDICATOR_ICON_AREA_NOTI == icon->area) {
		if(strncmp(icon->name, MORE_NOTI, strlen(MORE_NOTI))==0)
		{
			icon->exist_in_view = EINA_TRUE;
			_view_noti_list = eina_list_prepend(_view_noti_list, icon);
			goto __CATCH;
		}

		/* if finding condition is failed, append it at tail */
		icon->exist_in_view = EINA_TRUE;
		_view_noti_list = eina_list_append(_view_noti_list, icon);
	} else {
		icon->exist_in_view = EINA_TRUE;
		_view_alarm_list = eina_list_append(_view_alarm_list, icon);
	}

__CATCH:
	previous_noti_count = noti_count;
	if (icon->area == INDICATOR_ICON_AREA_NOTI
			|| icon->area == INDICATOR_ICON_AREA_SYSTEM
			|| icon->area == INDICATOR_ICON_AREA_MINICTRL) {
		int bDisplay = 0;
		bDisplay = 1;

		if (ad->opacity_mode == INDICATOR_OPACITY_TRANSPARENT
				&& bDisplay == 1) {
			util_send_status_message_start(ad,2.5);
		}
	}

	return OK;
}



extern int box_pack_append(icon_s *icon)
{
	Eina_List *l;
	icon_s *data;

	retv_if(!icon, 0);

	if (box_exist_icon(icon)) return OK;

	switch (icon->area) {
	case INDICATOR_ICON_AREA_FIXED:
		icon->exist_in_view = EINA_TRUE;
		_view_fixed_list = eina_list_append(_view_fixed_list, icon);
		break;
	case INDICATOR_ICON_AREA_SYSTEM:
		icon->exist_in_view = EINA_TRUE;
		_view_system_list = eina_list_append(_view_system_list, icon);
		break;
	case INDICATOR_ICON_AREA_MINICTRL:
		icon->exist_in_view = EINA_TRUE;
		_view_minictrl_list = eina_list_append(_view_minictrl_list, icon);
		break;
	case INDICATOR_ICON_AREA_NOTI:
		EINA_LIST_FOREACH(_view_noti_list, l, data) {
			if (strncmp(data->name, MORE_NOTI, strlen(MORE_NOTI)) == 0) {
				icon->exist_in_view = EINA_TRUE;
				_view_noti_list = eina_list_append_relative_list(_view_noti_list, icon, l);
				return OK;
			}
		}
		icon->exist_in_view = EINA_TRUE;
		_view_noti_list = eina_list_append(_view_noti_list, icon);
		break;
	default:
		_D("Icon area does not exists");
		break;
	}

	return OK;
}



int box_unpack(icon_s *icon)
{
	retv_if(!icon, 0);

	switch (icon->area) {
	case INDICATOR_ICON_AREA_FIXED:
		icon->exist_in_view = EINA_FALSE;
		_view_fixed_list = eina_list_remove(_view_fixed_list, icon);
		break;
	case INDICATOR_ICON_AREA_SYSTEM:
		icon->exist_in_view = EINA_FALSE;
		_view_system_list = eina_list_remove(_view_system_list, icon);
		break;
	case INDICATOR_ICON_AREA_MINICTRL:
		icon->exist_in_view = EINA_FALSE;
		_view_minictrl_list = eina_list_remove(_view_minictrl_list, icon);
		break;
	case INDICATOR_ICON_AREA_NOTI:
		icon->exist_in_view = EINA_FALSE;
		_view_noti_list = eina_list_remove(_view_noti_list, icon);
		break;
	case INDICATOR_ICON_AREA_ALARM:
		icon->exist_in_view = EINA_FALSE;
		_view_alarm_list = eina_list_remove(_view_alarm_list, icon);
		break;
	default:
		_D("icon area dose not exists");
		break;
	}

#if 0
	int noti_count = 0;

	noti_count = box_get_count(NOTI_LIST);
	if (noti_count > 0) {
		util_signal_emit(_win->data, "indicator.noti.show", "indicator.prog");
	} else {
		DBG("Need to stop blink animation and hide icon");
		util_signal_emit_by_win(_win->data,"indicator.noti.hide", "indicator.prog");
	}
#endif
#ifdef _SUPPORT_SCREEN_READER
	util_icon_access_unregister(icon);
#endif

	if (icon->obj_exist == EINA_TRUE) {
		if (icon_del(icon) == EINA_TRUE) {
			icon->obj_exist = EINA_FALSE;
		}
	}

	return OK;
}



extern void box_init(win_info *win)
{
	char *str_text = NULL;
	int i = 0;

	ret_if(!win);

	/* Make Fixed Box Object */
	for (i = 0; i < FIXED_COUNT; ++i) {
		if (win->_fixed_box[i] == NULL) {
			win->_fixed_box[i] = _box_add(win->layout);
			ret_if(!(win->_fixed_box[i]));

			Eina_Strbuf *temp_str = eina_strbuf_new();
			eina_strbuf_append_printf(temp_str, "%s%d", FIXED_BOX_PART_NAME, i);
			str_text = eina_strbuf_string_steal(temp_str);

			edje_object_part_swallow(elm_layout_edje_get(win->layout), str_text, win->_fixed_box[i]);
			eina_strbuf_free(temp_str);
			free(str_text);
		}
	}

	/* Make Non Fixed Box(SYSTEM) Object */
	win->_non_fixed_box = _box_add(win->layout);
	ret_if(!(win->_non_fixed_box));

	evas_object_size_hint_align_set(win->_non_fixed_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	edje_object_part_swallow(elm_layout_edje_get(win->layout), SYSTEM_BOX_PART_NAME, win->_non_fixed_box);

	/* Make Non Fixed Box(MINICTRL) Object */
	win->_minictrl_box = _box_add(win->layout);
	ret_if(!(win->_minictrl_box));

	evas_object_size_hint_align_set(win->_minictrl_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	edje_object_part_swallow(elm_layout_edje_get(win->layout), MINICTRL_BOX_PART_NAME, win->_minictrl_box);

	/* Make Non Fixed Box(NOTI) Box Object */
	win->_noti_box = _box_add(win->layout);
	ret_if(!(win->_noti_box));

	evas_object_size_hint_align_set(win->_noti_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	edje_object_part_swallow(elm_layout_edje_get(win->layout), NOTI_BOX_PART_NAME, win->_noti_box);

	win->_alarm_box = _box_add(win->layout);
	ret_if(!(win->_alarm_box));

	evas_object_size_hint_align_set(win->_alarm_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	edje_object_part_swallow(elm_layout_edje_get(win->layout), "indicator.alarm.icon", win->_alarm_box);

	win->_digit_box = _box_add(win->layout);
	ret_if(!(win->_digit_box));

	evas_object_size_hint_align_set(win->_digit_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
	edje_object_part_swallow(elm_layout_edje_get(win->layout), DIGIT_BOX_PART_NAME, win->_digit_box);

	return;
}




extern void box_fini(win_info *win)
{
	int i = 0;

	ret_if(!win);
	ret_if(!(win->layout));

	if (win->_digit_box != NULL) {
		edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_digit_box);
		elm_box_unpack_all(win->_digit_box);
		evas_object_del(win->_digit_box);
		win->_digit_box = NULL;
	}

	if (win->_non_fixed_box != NULL) {
		edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_non_fixed_box);
		elm_box_unpack_all(win->_non_fixed_box);
		evas_object_del(win->_non_fixed_box);
		win->_non_fixed_box = NULL;
	}

	if (win->_minictrl_box != NULL) {
		edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_minictrl_box);
		elm_box_unpack_all(win->_minictrl_box);
		evas_object_del(win->_minictrl_box);
		win->_minictrl_box = NULL;
	}

	if (win->_noti_box != NULL) {
		edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_noti_box);
		elm_box_unpack_all(win->_noti_box);
		evas_object_del(win->_noti_box);
		win->_noti_box = NULL;
	}

	if (win->_alarm_box != NULL) {
		edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_alarm_box);
		elm_box_unpack_all(win->_alarm_box);
		evas_object_del(win->_alarm_box);
		win->_alarm_box = NULL;
	}

	for (i = 0; i < FIXED_COUNT; ++i) {
		if (win->_fixed_box[i] != NULL) {
			edje_object_part_unswallow(elm_layout_edje_get(win->layout), win->_fixed_box[i]);
			elm_box_unpack_all(win->_fixed_box[i]);
			evas_object_del(win->_fixed_box[i]);
			win->_fixed_box[i] = NULL;
		}
	}

	return;
}



unsigned int box_get_count_in_noti_list_except_minictrl(void)
{
	icon_s *data;
	Eina_List *l;
	int count = 0;

	EINA_LIST_FOREACH(_view_noti_list, l, data) {
		if (data->priority != INDICATOR_PRIORITY_NOTI_1) {
			count++;
		}
	}
	return count;

}



int box_get_enabled_noti_count(void)
{
	int enabled_noti_cnt = 0;

	int system_cnt = box_get_count(SYSTEM_LIST);
	int minictrl_cnt = box_get_count(MINICTRL_LIST);
	DBG("System Count : %d, Minictrl Count : %d", system_cnt, minictrl_cnt);

	enabled_noti_cnt = MAX_NOTI_ICONS_PORT - system_cnt - minictrl_cnt;
	if(enabled_noti_cnt <= 0) {
		enabled_noti_cnt = 1;    // Notification icon must show at least 1.
	}

	DBG("Notification icon enabled_noti_cnt %d",enabled_noti_cnt);

	return enabled_noti_cnt;
}



int box_get_enabled_system_count(void)
{
	int system_cnt = 0;
	int noti_cnt = box_get_count(NOTI_LIST);
	int minictrl_cnt = box_get_count(MINICTRL_LIST);

	_D("Noti count : %d , MiniCtrl count : %d", noti_cnt, minictrl_cnt);

	system_cnt = PORT_SYSTEM_ICON_COUNT;  // MAX = 5.

	if(noti_cnt > 0) {
		system_cnt--;    // Notification icon must show at least 1.
	}

	if(minictrl_cnt > 0) {
		system_cnt--;    // Minictrl icon must show at least 1.
	}

	return system_cnt;
}



int box_get_minictrl_list(void)
{
	int icon_count = 0;
	int noti_count = box_get_count(NOTI_LIST);
	int system_count = box_get_count(SYSTEM_LIST);

	icon_count = PORT_MINICTRL_ICON_COUNT; // = 2.    MIN (1) / MAX (3)

	if(noti_count) {	// noti_count >= 1
		if(system_count >= 3) {
			icon_count--;	// icon_count = 2 -> 1
		} else if(system_count <= 1) {
			icon_count++;	// icon_count = 2 -> 3
		}
	} else {	// noti_count == 0
		if(system_count >= 4) {
			icon_count--;	// icon_count = 2 -> 1
		} else if(system_count <= 2) {
			icon_count++;	// icon_count = 2 -> 3
		}
	}

	_D("Noti count : %d, System count : %d, Minictrl count : %d", noti_count, system_count, icon_count);

	return icon_count;
}



int box_get_max_count_in_non_fixed_list(void)
{
	return PORT_NONFIXED_ICON_COUNT;
}



Icon_AddType box_is_enable_to_insert_in_non_fixed_list(icon_s *obj)
{
	icon_s *icon;
	Eina_List *l;

	int higher_cnt = 0;
	int same_cnt = 0;
	int same_top_cnt = 0;
	int lower_cnt = 0;
	int noti_cnt = box_get_count(NOTI_LIST);
	Eina_List * tmp_list = NULL;

	retv_if(!obj, 0);

	switch (obj->area) {
	case INDICATOR_ICON_AREA_SYSTEM:
		tmp_list = _view_system_list;
		break;
	case INDICATOR_ICON_AREA_MINICTRL:
		tmp_list = _view_minictrl_list;
		break;
	case INDICATOR_ICON_AREA_NOTI:
		tmp_list = _view_noti_list;
		break;
	default:
		_D("obj area does not exists");
		break;
	}

	EINA_LIST_FOREACH(tmp_list, l, icon) {
		/* If same Icon exist in non-fixed view list, it need not to add icon */
		if (!strcmp(icon->name, obj->name)) {
			return CANNOT_ADD;
		}

		if (icon->priority > obj->priority) {
			++higher_cnt;
		} else if (icon->priority == obj->priority) {
			++same_cnt;
			if (icon->always_top == EINA_TRUE) {
				++same_top_cnt;
			}
		} else {
			lower_cnt++;
		}
	}

	if (obj->area == INDICATOR_ICON_AREA_SYSTEM) {
		if (higher_cnt + same_cnt + lower_cnt >= box_get_enabled_system_count()) {
			if (obj->always_top == EINA_TRUE) {
				if(same_top_cnt >= box_get_enabled_system_count()) {
					return CANNOT_ADD;
				} else {
					return CAN_ADD_WITH_DEL_SYSTEM;
				}
			} else {
				if (higher_cnt >= box_get_enabled_system_count()) {
					return CANNOT_ADD;
				} else if (higher_cnt+same_cnt >= box_get_enabled_system_count()) {
					return CAN_ADD_WITH_DEL_SYSTEM;
				} else {
					return CAN_ADD_WITH_DEL_SYSTEM;
				}
			}
		} else {
			return CAN_ADD_WITHOUT_DEL;
		}
	} else if (obj->area == INDICATOR_ICON_AREA_MINICTRL) {
		if (higher_cnt + same_cnt + lower_cnt >= box_get_minictrl_list()) {
			if (obj->always_top == EINA_TRUE) {
				if (same_top_cnt >= box_get_minictrl_list()) {
					return CANNOT_ADD;
				} else {
					return CAN_ADD_WITH_DEL_MINICTRL;
				}
			} else {
				if (higher_cnt >= box_get_minictrl_list()) {
					return CANNOT_ADD;
				} else if (higher_cnt+same_cnt >= box_get_minictrl_list()) {
					return CAN_ADD_WITH_DEL_MINICTRL;
				} else {
					return CAN_ADD_WITH_DEL_MINICTRL;
				}
			}
		} else {
			return CAN_ADD_WITHOUT_DEL;
		}
	} else {
		if (noti_cnt > MAX_NOTI_ICONS_PORT) {
			return CAN_ADD_WITH_DEL_NOTI;
		} else {
			return CAN_ADD_WITHOUT_DEL;
		}
	}

	return CANNOT_ADD;
}



int box_get_priority_in_move_area(win_info *win, Evas_Coord curr_x, Evas_Coord curr_y)
{
	Evas_Coord x, y, h, w;

	/* Home Area Check for launching home */
	evas_object_geometry_get(win->_fixed_box[INDICATOR_PRIORITY_FIXED1], &x, &y, &h, &w);

	if (curr_x >= x - CORRECTION && curr_x <= x+h + CORRECTION) {
		if (curr_y == -1) {
			return INDICATOR_PRIORITY_FIXED1;
		} else if (curr_y >= y - CORRECTION && curr_y <= y+h + CORRECTION) {
			return INDICATOR_PRIORITY_FIXED1;
		}
	}

	/* Non Fixed Area check for show/hide quickpanel */
	return -1;
}



int box_check_indicator_area(win_info *win, Evas_Coord curr_x, Evas_Coord curr_y)
{
	Evas_Coord x, y, w, h;

	/* Home Area Check for launching home */
	evas_object_geometry_get(win->layout, &x, &y, &w, &h);

	if (curr_x >= x && curr_x < x + w && curr_y >= y && curr_y < y + h) {
		return 1;
	}

	return 0;
}



int box_check_home_icon_area(win_info *win, Evas_Coord curr_x, Evas_Coord curr_y)
{
	Evas_Coord x, y, w, h;

	/* Home Area Check for launching home */
	evas_object_geometry_get(win->_fixed_box[INDICATOR_PRIORITY_FIXED7], &x, &y, &w, &h);

	if (curr_x >= x && curr_x < x + w && curr_y >= y && curr_y < y + h) {
		return 1;
	}

	return 0;
}



int box_check_more_icon_area(win_info *win, Evas_Coord curr_x, Evas_Coord curr_y)
{
	Evas_Coord x, y, w, h;

	/* Home Area Check for launching home */
	evas_object_geometry_get(win->_fixed_box[INDICATOR_PRIORITY_FIXED11], &x, &y, &w, &h);

	if (curr_x >= x && curr_x < x + w && curr_y >= y && curr_y < y + h) {
		return 1;
	}

	return 0;
}



void box_icon_state_set(int bShow, char* file, int line)
{
	icon_show_state = bShow;
}



int box_icon_state_get(void)
{
	return icon_show_state;
}



extern Eina_Bool box_exist_icon(icon_s *obj)
{
	retv_if(!obj, ECORE_CALLBACK_CANCEL);

	switch (obj->area) {
	case INDICATOR_ICON_AREA_FIXED:
		if (eina_list_data_find(_view_fixed_list, obj)) {
			return EINA_TRUE;
		} else {
			return EINA_FALSE;
		}
		break;
	case INDICATOR_ICON_AREA_SYSTEM:
		if (eina_list_data_find(_view_system_list, obj)) {
			return EINA_TRUE;
		} else {
			return EINA_FALSE;
		}
		break;
	case INDICATOR_ICON_AREA_MINICTRL:
		if (eina_list_data_find(_view_minictrl_list, obj)) {
			return EINA_TRUE;
		} else {
			return EINA_FALSE;
		}
		break;
	case INDICATOR_ICON_AREA_NOTI:
		if (eina_list_data_find(_view_noti_list, obj)) {
			return EINA_TRUE;
		} else {
			return EINA_FALSE;
		}
		break;
	default:
		break;
	}

	return EINA_FALSE;
}



int box_handle_animated_gif(icon_s *icon)
{
	display_state_e state;
	Evas_Object *icon_eo = evas_object_data_get(icon->img_obj.obj, DATA_KEY_IMG_ICON);

	retif(icon == NULL, FAIL, "Invalid parameter!");

	if (elm_image_animated_available_get(icon_eo) == EINA_FALSE) {
		return FAIL;
	}

	int ret = device_display_get_state(&state);
	if (ret != DEVICE_ERROR_NONE) {
		ERR("device_display_get_state failed: %s", get_error_message(ret));
		return FAIL;
	}

	switch (state) {
	case DISPLAY_STATE_SCREEN_OFF:	//LCD OFF
		elm_image_animated_play_set(icon_eo, EINA_FALSE);
		break;
	case DISPLAY_STATE_NORMAL:	//LCD ON
	default:
		elm_image_animated_set(icon_eo, EINA_TRUE);
		if (!elm_image_animated_play_get(icon_eo))
			elm_image_animated_play_set(icon_eo, EINA_TRUE);
		break;
	}

	return OK;
}



void box_noti_ani_handle(int bStart)
{
	icon_s *icon;
	Eina_List *l;

	EINA_LIST_FOREACH(_view_noti_list, l, icon) {
		if (icon->obj_exist == EINA_TRUE) {
			if (bStart == 1) {
				util_start_noti_ani(icon);
			} else {
				util_stop_noti_ani(icon);
			}
		}
	}
}

/* End of file */