summaryrefslogtreecommitdiff
path: root/main/src/view/ivug-main-view.c
blob: 75af879b8d2810d343f967e61595d87e92ef0b26 (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
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
 *
 * 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 <ui-gadget-module.h>		// ug_destroy_me, ug_send_result
#include <media-svc.h>
#include <vconf.h>
#include <vconf-keys.h>
#include <utilX.h>			// Key event

#include "ivug-common.h"
#include "ivug-parameter.h"

#include "ivug-main-view.h"
#include "ivug-util.h"
#include "ivug-data.h"
#include "ivug-ext-ug.h"
#include "ivug-popup.h"
#include "ivug-slider-item.h"
#include "ivug-slider.h"
#include "ivug-main.h"

#include "ivug-setas-view.h"
#include "ivug-details-view.h"

#include "ivug-data.h"

#define ELM_INTERNAL_API_ARGESFSDFEFC

#include <elm_widget.h>		// elm_selection_set
#include <appsvc.h> // app service

#undef HIDE_INDICATOR		// For testing.

#define CONTROL_ICON_DIRECTORY_PATH 	IMAGE_PATH"/01_Control icon"

#define ICON_PATH_DELETE 		CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_delete.png"
#define ICON_PATH_SLIDESHOW 		CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_slideshow.png"
#define ICON_PATH_INFO	 		CONTROL_ICON_DIRECTORY_PATH"/T01_controlbar_icon_info.png"

#define ICON_PATH_OPTIONTRAY		IMAGE_PATH"/T01_btn_optiontray.png"

// EDJE
#define IVUG_MAIN_EDJ 	EDJ_PATH"/ivug-main.edj"

#define IVUG_RESPONSE_OK	(1)

#undef TEST_MOUSE_EVENT

void
_ivug_main_view_show_menu_bar(Ivug_MainView *pMainView);

void
_ivug_main_view_hide_menu_bar(Ivug_MainView *pMainView);

static void
_ivug_main_view_back_cb(void *data, Evas_Object *obj, void *event_info);

Evas_Object *_create_tool_bar(Evas_Object *parent);

static void
_ivug_main_view_navibar_detail_cb(void *data, Evas_Object *obj, void *event_info);

static void
_ivug_main_view_navibar_detail_close_cb(void *data, Evas_Object *obj, void *event_info);

static enum CTRL_BAR_TYPE
_get_ctrl_bar_type(ivug_mode mode, Media_Type slide_type);
static enum NAVI_BAR_TYPE
_get_tool_bar_type(ivug_mode mode, Media_Type slide_type );

#define IVUG_MAIN_DESTROY_ME(a) _ivug_main_view_destroy_me(a, __func__, __LINE__);

static void
_ivug_main_view_destroy_me(Ivug_MainView *pMainView, const char *fname, int nLine)
{
	ivug_ret_if(!pMainView);

	MSG_MAIN_WARN("Main view request ug_destroy_me at [%s:%d]", fname, nLine);

	int x = 0;
	int y = 0;
	int w = 0;
	int h = 0;

	MSG_MAIN_WARN("Apply event blocker");
	pMainView->event_blocker = evas_object_rectangle_add(evas_object_evas_get(pMainView->layout));
	evas_object_geometry_get(pMainView->layout, &x, &y, &w, &h);
	evas_object_move(pMainView->event_blocker, x, y);
	evas_object_resize(pMainView->event_blocker, w, h);
	evas_object_color_set(pMainView->event_blocker, 0, 0, 0, 0);
	evas_object_show(pMainView->event_blocker);

	ug_destroy_me(pMainView->ugHandle);
}

static void
_selection_info_deleted(void * data, Evas * e, Evas_Object * obj, void * event_info)
{
	ivug_retm_if(!data, "data is NULL");
	MSG_MAIN_WARN("selection info deleted");
	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	pMainView->selectioninfo = NULL;

	return;
}

static inline void
_main_view_create_selection_info(Ivug_MainView *pMainView, const char *string)
{
	IV_ASSERT(pMainView != NULL);
	if(pMainView->selectioninfo)
	{
		evas_object_event_callback_del(pMainView->selectioninfo, EVAS_CALLBACK_DEL,
			       _selection_info_deleted);
		evas_object_del(pMainView->selectioninfo);
		pMainView->selectioninfo = NULL;
	}
	pMainView->selectioninfo = ivug_popup_selectioninfo(pMainView->layout, string);
	ivug_retm_if(pMainView->selectioninfo == NULL, "selectioninfo is NULL");
	evas_object_event_callback_add(pMainView->selectioninfo, EVAS_CALLBACK_DEL,
		_selection_info_deleted, pMainView);
}


//copy popup
static void
_ivug_main_copy_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
{
	int response_id = (int)event_info;
	IV_ASSERT(data != NULL);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	MSG_MAIN_HIGH("Copy popup response : %d", response_id);

	if (pMainView->copy_popup)
	{
		evas_object_del(pMainView->copy_popup);
		pMainView->copy_popup = NULL;
	}
	else
	{
		MSG_MAIN_WARN("copy popup is NULL");
	}
}

static void
_ivug_main_copy_popup_selected_cb(void *data, Evas_Object *obj, void *event_info)
{
	ivug_ret_if(!data);
	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	//get current file path.
	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);

	if (mdata == NULL)
	{
		MSG_MAIN_ERROR("slider data is NULL");
		return;
	}

	char *path = NULL;
	int len = 0;
	// This Will add to the article
	char buf[IVUG_MAX_FILE_PATH_LEN] = {0,};

	path = mdata->filepath;
	len = strlen(mdata->filepath)+strlen("file://")+1;
	snprintf(buf, IVUG_MAX_FILE_PATH_LEN, "file://%s", mdata->filepath);

	if (len < IVUG_MAX_FILE_PATH_LEN)
	{
		MSG_MAIN_HIGH("file path = %s, file url =%s", path, buf);
		if ( pMainView->parent)
		{
			elm_cnp_selection_set(pMainView->layout, ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_IMAGE, buf, sizeof(buf));
		}
	}
	else
	{
		MSG_MAIN_ERROR("slider file path is too long");
	}

	evas_object_del(pMainView->copy_popup);
	pMainView->copy_popup = NULL;
}

Evas_Object*
_ivug_main_create_copy_popup_create(Ivug_MainView *pMainView, int x, int y)
{
	ivug_retv_if(!pMainView, NULL);

	Evas_Object* ctx_popup = NULL;
	ctx_popup = elm_ctxpopup_add(pMainView->layout);
	elm_ctxpopup_item_append(ctx_popup, IDS_COPY,  NULL, _ivug_main_copy_popup_selected_cb, pMainView);
	evas_object_smart_callback_add( ctx_popup, "hide", _ivug_main_copy_popup_response_cb, pMainView);

	//evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed_cb, ctxpopup);
	evas_object_move(ctx_popup, x, y);

	evas_object_show(ctx_popup);

	return ctx_popup;
}

static void
_ivug_main_view_navibar_detail_close_cb(void *data, Evas_Object *obj, void *event_info)
{
	IV_ASSERT(data != NULL);

	MSG_MAIN_HIGH("ENTER : Btn detail close clicked. obj=0x%08x data=0x%08x", obj, data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	IV_ASSERT( pMainView->navi_bar != NULL);

	evas_object_smart_callback_del(obj, "clicked", _ivug_main_view_navibar_detail_close_cb);

	elm_object_item_part_content_unset(pMainView->navi_it, "elm.swallow.detail");

	MSG_MAIN_HIGH("Delete detail view");
	ivug_details_view_destroy(pMainView->pDetailsView);  // Delete detail view.
	pMainView->pDetailsView = NULL;

// Enable detail view button callback
	evas_object_smart_callback_add(pMainView->btn_detail, "clicked", _ivug_main_view_navibar_detail_cb, pMainView->btn_detail_data);
	elm_object_disabled_set(pMainView->btn_detail, EINA_FALSE);

	Evas_Object *btn_close = elm_object_item_part_content_unset(pMainView->navi_it, "title_right_btn");
	evas_object_del(btn_close);

	MSG_MAIN_HIGH("LEAVE : Btn detail close clicked. obj=0x%08x data=0x%08x", obj, data);
}

static void _update_title(Ivug_MainView *pMainView)
{
	static char title[256];

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);

	if (mdata == NULL)
	{
		MSG_MAIN_ERROR("slider data is NULL");
		return;
	}

	if ( pMainView->mode == IVUG_MODE_NORMAL)
	{
		snprintf(title, sizeof(title), "%d/%d",
			ivug_slider_get_current_slide_count(pMainView->slider),
			ivug_slider_get_total_slide_count(pMainView->slider));	//get title.
	}
	else if(mdata->filepath != NULL)
	{
		const char* filename = ivug_get_filename(mdata->filepath);
		if(filename)
		{
			snprintf(title, sizeof(title), "%s", filename);
		}
	}

	IV_ASSERT(pMainView->navi_bar != NULL);

	MSG_MAIN_HIGH("Update title : %s", title);

	elm_object_item_text_set(pMainView->navi_it, title);

}

static void
_ivug_main_view_navibar_detail_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("ENTER : Btn detail view clicked. obj=0x%08x data=0x%08x", obj, data);
	ivug_ret_if(!obj||!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	if(pMainView->pDetailsView)
	{
		MSG_MAIN_ERROR("details view already created");
		return;
	}

	pMainView->btn_detail_data = evas_object_smart_callback_del(obj, "clicked", _ivug_main_view_navibar_detail_cb);
	pMainView->btn_detail = obj;

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);

	if (mdata == NULL)
	{
		MSG_MAIN_ERROR("slider data is NULL");
		return;
	}

	pMainView->pDetailsView = ivug_details_view_screen_create(pMainView->navi_bar, mdata, pMainView->view_by);

	if(!pMainView->pDetailsView)
	{
		MSG_MAIN_ERROR("create details view failed");
		return;
	}

	elm_object_item_part_content_set(pMainView->navi_it, "elm.swallow.detail", ivug_details_view_object_get(pMainView->pDetailsView));

// Transition effect does not comming ocassionally when instant mode is used.
//	evas_object_smart_callback_add(pMainView->navi_bar, "transition,finished", _ivug_main_view_details_transit_finished_cb, pMainView);
	PERF_CHECK_BEGIN(LVL1 "Update title");

	_update_title(pMainView);

	PERF_CHECK_END(LVL1 "Update title");

	_ctrl_bar_type ctrlbar_type;
	ctrlbar_type = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
	if(ctrlbar_type == CTRL_BAR_TYPE_FILE || ctrlbar_type == CTRL_BAR_TYPE_CAMERA_IMAGE
		|| ctrlbar_type == CTRL_BAR_TYPE_CAMERA_VIDEO)
	{
		MSG_MAIN_HIGH("Disable details button ");

		/* Disable details button in controlbar */
		if(pMainView->ctrl_bar_item[1])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_TRUE);
	}
	else if(ctrlbar_type == CTRL_BAR_TYPE_IMAGE || ctrlbar_type == CTRL_BAR_TYPE_VIDEO)
	{
		/* Disable details button in controlbar */
		if(pMainView->ctrl_bar_item[2])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_TRUE);
	}

	MSG_MAIN_HIGH("LEAVE : Btn detail view clicked. obj=0x%08x data=0x%08x", obj, data);
}

#define ZOOM_LEVEL_STEP (0.7)
#define ZOOM_LEVEL_MAX (3)

static void _show_zoom_icon(void *data)
{
	ivug_ret_if(!data);

	MSG_MAIN_ERROR("_show_zoom_icon");

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	if(!sitem)
	{
		MSG_MAIN_ERROR("sitem is NULL");
		return;
	}

	if(sitem->zoom_level == 0)
	{
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,disable","elm");
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,enable","elm");
	}
	else if(sitem->zoom_level == ZOOM_LEVEL_MAX)
	{
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,disable","elm");
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,enable","elm");
	}
	else
	{
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,enable","elm");
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,enable","elm");
	}
}

static void
_ivug_main_view_zoom_out_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
{
	ivug_ret_if(!obj);
	ivug_ret_if(!data);

	MSG_MAIN_ERROR("_ivug_main_view_zoom_out_cb");

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	if(!sitem)
	{
		MSG_MAIN_ERROR("sitem is NULL");
		return;
	}

	if(sitem->zoom_level == 0)
	{
		MSG_MAIN_ERROR("zoom_level is 0");
		return;
	}

	double zoom = 0.0;
	Evas_Coord ix = 0, iy= 0, iw= 0, ih= 0;

	evas_object_geometry_get(sitem->photocam, &ix, &iy, &iw, &ih);

	zoom = ivug_slider_item_zoom_get(sitem);
	zoom /= ZOOM_LEVEL_STEP;
	ivug_slider_item_zoom_set(sitem, zoom, iw/2, ih/2);

	ivug_slider_item_hold_set(sitem, EINA_FALSE);

	sitem->zoom_level--;

	_show_zoom_icon(data);
}

static void
_ivug_main_view_zoom_in_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
{
	ivug_ret_if(!obj);
	ivug_ret_if(!data);

	MSG_MAIN_ERROR("_ivug_main_view_zoom_in_cb");

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	if(!sitem)
	{
		MSG_MAIN_ERROR("sitem is NULL");
		return;
	}

	if(sitem->zoom_level > ZOOM_LEVEL_MAX)
	{
		MSG_MAIN_ERROR("zoom_level is %d", sitem->zoom_level);
		return;
	}

	double zoom = 0.0;
	Evas_Coord ix = 0, iy= 0, iw= 0, ih= 0;

	evas_object_geometry_get(sitem->photocam, &ix, &iy, &iw, &ih);

	zoom = ivug_slider_item_zoom_get(sitem);
	zoom *= ZOOM_LEVEL_STEP;
	ivug_slider_item_zoom_set(sitem, zoom, iw/2, ih/2);

	ivug_slider_item_hold_set(sitem, EINA_FALSE);

	sitem->zoom_level++;

	_show_zoom_icon(data);
}

static void
_ivug_main_view_update_details_item(Ivug_MainView *pMainView)
{
	ivug_retm_if(!pMainView, "pMainView is NULL");
	ivug_retm_if(!pMainView->slider, "pMainView->slider is NULL");

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	if(!sitem)
	{
		MSG_MAIN_ERROR("sitem is NULL");
		return;
	}

	Media_Data *mdata = ivug_data_get_data(sitem->mitem);
	if(!mdata)
	{
		MSG_MAIN_ERROR("mdata is NULL");
		return;
	}

	_ctrl_bar_type ctrlBarType;
	ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
	if(ctrlBarType == CTRL_BAR_TYPE_FILE || ctrlBarType == CTRL_BAR_TYPE_CAMERA_IMAGE ||
	   ctrlBarType == CTRL_BAR_TYPE_CAMERA_VIDEO)
	{
		/* Enable details button in control bar*/
		if(pMainView->ctrl_bar_item[1])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);
	}
	else if(ctrlBarType == CTRL_BAR_TYPE_IMAGE || ctrlBarType == CTRL_BAR_TYPE_VIDEO)
	{
		/* Enable details button in control bar*/
		if(pMainView->ctrl_bar_item[2])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_FALSE);
	}
}

static void
_ivug_main_view_delete_photo_cb(void *data, Evas_Object *obj, void *event_info)
{
	IVUG_FUNC_ENTER();
	ivug_ret_if(!obj||!data||!event_info);

	int response_id = (int)event_info;

	Ivug_MainView *pMainView = (Ivug_MainView *)data;
	if ( response_id == POPUP_RESPONSE_OK )
	{
		MSG_MAIN_HIGH("Removing current slide.");

		if(pMainView->pDetailsView)
		{
			MSG_MAIN_HIGH("Exit details view");
			_ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);

			_ivug_main_view_update_details_item(pMainView);
		}

		ivug_slider_delete_current_slide(pMainView->slider);
	}

	evas_object_del(obj);	//delete popup

}

static void
_ivug_main_view_ctrlbar_delete_cb(void *data, Evas_Object *obj, void *event_info)
{
	IVUG_FUNC_ENTER();
	ivug_ret_if(!obj||!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	ivug_popup_question(pMainView->layout, NULL,
			IDS_DELETE_MSG, _ivug_main_view_delete_photo_cb, pMainView);

	IVUG_FUNC_LEAVE();
	return;
}

static void
_ivug_main_view_ctrlbar_slide_show_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Start slide show");

	IV_ASSERT(data != NULL);
	ivug_ret_if(!event_info);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	Elm_Object_Item *ctrl_bar_item = (Elm_Object_Item *)event_info;

	if(elm_object_item_disabled_get(ctrl_bar_item) == EINA_TRUE)
	{
		MSG_MAIN_WARN("Slide show already started");
		return;
	}

	elm_object_item_disabled_set(ctrl_bar_item, EINA_TRUE);

	if(pMainView->pDetailsView) {
		MSG_MAIN_HIGH("Exit details view");
		_ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);
	}

	ivug_prohibit_lcd_off();

	_ivug_main_view_hide_menu_bar(pMainView);

	ivug_slider_start_slide_show(pMainView->slider, EINA_TRUE);

}


static void
_ivug_main_view_back_cb(void *data, Evas_Object *obj, void *event_info)
{
	ivug_ret_if(!obj||!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;
	ivug_retm_if(!pMainView->navi_bar, "%s", "navigation value is NULL");

	MSG_MAIN_WARN("Back key pressed");

	if( pMainView->pDetailsView == NULL)	// Detail view is not showed,.
	{
		evas_object_smart_callback_del(pMainView->back_btn, "clicked", _ivug_main_view_back_cb);
		IVUG_MAIN_DESTROY_ME(pMainView);
		return;
	}

	/* Back from details view */

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	ivug_retm_if(!sitem, "sitem is NULL");

	Media_Data *mdata = ivug_data_get_data(sitem->mitem);
	ivug_retm_if(!mdata, "mdata is NULL");

	_ctrl_bar_type ctrlBarType;
	ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
	if(ctrlBarType == CTRL_BAR_TYPE_FILE ||
		ctrlBarType == CTRL_BAR_TYPE_CAMERA_IMAGE ||
		ctrlBarType == CTRL_BAR_TYPE_CAMERA_VIDEO)
	{
		// In case that called by my file, camera,  UG doest not removed.
		_ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);

		MSG_MAIN_HIGH("Enable details button");
		if(pMainView->ctrl_bar_item[1])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);

		return;
	}
	else if(ctrlBarType == CTRL_BAR_TYPE_IMAGE || ctrlBarType == CTRL_BAR_TYPE_VIDEO)
	{
		// In case that called by my file, camera,  UG doest not removed.
		_ivug_main_view_navibar_detail_close_cb(pMainView, NULL, NULL);

		MSG_MAIN_HIGH("Enable details button");
		if(pMainView->ctrl_bar_item[2])
			elm_object_item_disabled_set(pMainView->ctrl_bar_item[2], EINA_FALSE);
	}
	else	// otherwise, from gallery, ug will be terminated
	{
		evas_object_smart_callback_del(pMainView->back_btn, "clicked", _ivug_main_view_back_cb);
		IVUG_MAIN_DESTROY_ME(pMainView);
		return;
	}
}



static void
_send_result(struct ui_gadget *ug, bool selected)
{
//result bundle key
#define IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT "Result"

//result bundle value
#define IVUG_RESULT_BUNDLE_VALUE_OK			"Ok"
#define IVUG_RESULT_BUNDLE_VALUE_CANCEL		"Cancel"

	ivug_ret_if(!ug);

	bundle *b;
	b = bundle_create();

	if (selected)
	{
		bundle_add(b, IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT, IVUG_RESULT_BUNDLE_VALUE_OK);
	}
	else
	{
		bundle_add(b, IVUG_RESULT_BUNDLE_KEY_SELECTION_RESULT, IVUG_RESULT_BUNDLE_VALUE_CANCEL);
	}

	ug_send_result(ug, b);

	bundle_free(b);
}


//select button
void
_ivug_main_view_select_ok_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Select OK");
	ivug_ret_if(!obj||!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	//send result.
	_send_result(pMainView->ugHandle, true);

	IVUG_MAIN_DESTROY_ME(pMainView);
}

void
_ivug_main_view_select_cancel_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Select Cancel");

	ivug_ret_if(!obj||!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	//send result.
	_send_result(pMainView->ugHandle, false);

	IVUG_MAIN_DESTROY_ME(pMainView);
}


static bool _is_mmc_inserted(void)
{
	int noti_message;
	int ret = -1;

	ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &noti_message);

	if ( ret != 0 ) // falied
	{
		MSG_NOTI_ERROR("Get %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
		return false;
	}

	if(noti_message==VCONFKEY_SYSMAN_MMC_MOUNTED)
	{
 		return true;
	}

	return false;

}

static Eina_Bool _key_down_cb(void *user_data, int type, void *event)
{
	if (!user_data) {
		MSG_IMAGEVIEW_ERROR("user data is NULL");
		return ECORE_CALLBACK_PASS_ON;
	}

	Ecore_Event_Key *key_event = (Ecore_Event_Key *) event;

	Ivug_MainView *main_view = (Ivug_MainView *)user_data;

	MSG_IMAGEVIEW_HIGH("Key down : %s", key_event->keyname);

	if (!strcmp(key_event->keyname, KEY_END))
	{
		MSG_IMAGEVIEW_HIGH("Bakc(End) key");
	}
	else if (!strcmp(key_event->keyname, KEY_SELECT))
	{
		MSG_IMAGEVIEW_HIGH("Home key");
	}
	else if (!strcmp(key_event->keyname, KEY_POWER))
	{
		MSG_IMAGEVIEW_HIGH("Power key");
		ivug_slider_stop_slide_show(main_view->slider);
	}
	return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool _on_exit_timer_expired(void *data)
{
	ivug_retv_if(!data, ECORE_CALLBACK_CANCEL);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	pMainView->exit_timer = NULL;

	IVUG_MAIN_DESTROY_ME(pMainView);

	return ECORE_CALLBACK_CANCEL;
}

static void _on_mmc_state_changed(keynode_t* node, void *data)
{
	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	if(_is_mmc_inserted() == false	)
	{
		MSG_IMAGEVIEW_WARN("MMC Removed!. Request destroy UG=0x%08x", gGetUGHandle());

		if ( pMainView->ext_ug )
		{
			MSG_IMAGEVIEW_HIGH("Extern UG is running");
		}

		ivug_show_popup(pMainView->layout, IDS_ERROR, IDS_SD_CARD_REMOVED, NULL, NULL);
		pMainView->exit_timer = ecore_timer_add(0.2, _on_exit_timer_expired, data);
	}
}

static enum NAVI_BAR_TYPE
_get_tool_bar_type(ivug_mode mode, Media_Type slide_type )
{
	enum NAVI_BAR_TYPE tool_bar_type = NAVI_BAR_TYPE_NONE;

	//calc navi bar style , temporary code.
	static  const char *szType[] = {
		"[ INVALID  ]",
		"[          ]",
		"[Set,  Info]",
		"[Ok, Cancel]",
	};


	switch (mode)
	{
		case IVUG_MODE_NORMAL:
			tool_bar_type = NAVI_BAR_TYPE_EMPTY;
			if (slide_type == SLIDE_TYPE_IMAGE)
			{
				tool_bar_type = NAVI_BAR_TYPE_IMAGE;
			}
			else if (slide_type == SLIDE_TYPE_VIDEO)
			{
				tool_bar_type = NAVI_BAR_TYPE_VIDEO;
			}
			else
			{
				tool_bar_type = NAVI_BAR_TYPE_EMPTY;
			}
		break;
		case IVUG_MODE_SINGLE:
		case IVUG_MODE_FILE:
			tool_bar_type = NAVI_BAR_TYPE_EMPTY;

		break;
		case IVUG_MODE_DISPLAY:
			tool_bar_type = NAVI_BAR_TYPE_SELECT;

		break;
		case IVUG_MODE_CAMERA:
			tool_bar_type = NAVI_BAR_TYPE_EMPTY;
			break;
		default:
			MSG_MAIN_ERROR("Unhandled mode : %d", mode);
			tool_bar_type = NAVI_BAR_TYPE_EMPTY;

			break;
	}

	MSG_MAIN_MED("Mode=%d Slide=%d ToolBar=%s", mode, slide_type, szType[tool_bar_type]);

	return tool_bar_type;
}


static enum CTRL_BAR_TYPE
_get_ctrl_bar_type(ivug_mode mode, Media_Type slide_type)
{
	// this is temporary code.
	enum CTRL_BAR_TYPE type = CTRL_BAR_TYPE_FILE;

	static const char *szType[] = {
		"[ Invalid ]",
		"[ None ]",
		"[Delete,Info]",
		"[Delete,Info]",
		"[Delete,Info]",
		"[Delete,Slide show]",
		"[Delete,Slide show]",
	};

	switch (mode)
	{
		case IVUG_MODE_NORMAL:
			if (slide_type == SLIDE_TYPE_IMAGE)
			{
				type = CTRL_BAR_TYPE_IMAGE;
			}
			else if (slide_type == SLIDE_TYPE_VIDEO)
			{
				type = CTRL_BAR_TYPE_VIDEO;
			}
			else if (slide_type == SLIDE_TYPE_UNKNOWN)
			{
				type = CTRL_BAR_TYPE_IMAGE;		// TODO : Need to check. when web image is invalid????
			}
			else
			{
				MSG_MAIN_ERROR("Unhandled slide type : %d", slide_type);
				type = CTRL_BAR_TYPE_FILE;
			}
		break;
		case IVUG_MODE_SINGLE:
		case IVUG_MODE_FILE:
			type = CTRL_BAR_TYPE_FILE;
		break;
		case IVUG_MODE_CAMERA:
			if (slide_type == SLIDE_TYPE_IMAGE)
			{
				type = CTRL_BAR_TYPE_CAMERA_IMAGE;
			}
			else if (slide_type == SLIDE_TYPE_VIDEO)
			{
				type = CTRL_BAR_TYPE_CAMERA_VIDEO;
			}
			else
			{
				MSG_MAIN_ERROR("Unhandled slide type : %d", slide_type);
				type = CTRL_BAR_TYPE_FILE;
			}
		break;
		case IVUG_MODE_DISPLAY:
			type = CTRL_BAR_TYPE_EMPTY;
		break;
		default:
			MSG_MAIN_ERROR("Unhandled mode : %d", mode);
			type = CTRL_BAR_TYPE_FILE;
	}

	MSG_MAIN_MED("Mode=%d Slide=%d CtrlBar=%s", mode, slide_type, szType[type]);

	return type;

}

Evas_Object *_create_ctrl_bar(Evas_Object *parent, Elm_Theme *th)
{
	Evas_Object *toolbar = elm_toolbar_add(parent);

//create control bar
	if (toolbar == NULL)
	{
		MSG_MAIN_ERROR("controlbar create failed");
		return NULL;
	}

	elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_EXPAND);

#ifdef USE_CUSTOM_STYLE
	elm_object_theme_set(toolbar, th);

	char *ctrlStyle = NULL;

	ctrlStyle = "ivug-toolbar/default";

	Eina_Bool bstyle = elm_object_style_set(toolbar, ctrlStyle);
	MSG_MAIN_HIGH("toolbar elm_object_style_set result = %d", bstyle);
#endif

	MSG_MAIN_HIGH("Create ctrl_bar. Obj=0x%08x", toolbar);

	return toolbar;

}

void
_update_tool_bar(Ivug_MainView *pMainView, enum NAVI_BAR_TYPE barType)
{

/*
   |-------------------|
   |naviframe(tool_bar)|
   |-------------------|
   |				   |
   |				   |
   |				   |
   |				   |
   |-------------------|
   |	ctrl_bar 	   |
   |-------------------|
*/

	MSG_MAIN_HIGH("Update tool_bar. Type=%d", barType);
//remove old control bar item.
	int i = 0;

	for ( i = 0 ; i < MAX_NAVI_ITEM_CNT ; i ++)
	{
		if (pMainView->tool_bar_item[i])
		{
			evas_object_del(pMainView->tool_bar_item[i]);
			pMainView->tool_bar_item[i] = NULL;
		}
	}

	if ( barType != NAVI_BAR_TYPE_SELECT )
	{
		/* other type don't need toolbar */
		return;
	}

	pMainView->tool_bar_item[0] = ivug_button_add(pMainView->navi_bar, "naviframe/title/default" , IDS_OK,
			NULL, _ivug_main_view_select_ok_cb, pMainView );

	pMainView->tool_bar_item[1] = ivug_button_add(pMainView->navi_bar, "naviframe/title/default" , IDS_CANCEL,
		NULL, _ivug_main_view_select_cancel_cb, pMainView );

	elm_object_item_part_content_set(pMainView->navi_it, "title_left_btn", pMainView->tool_bar_item[0]);
	elm_object_item_part_content_set(pMainView->navi_it, "title_right_btn", pMainView->tool_bar_item[1]);

	pMainView->option_show = EINA_TRUE;
}



void
_update_ctrl_bar(Ivug_MainView *pMainView, enum CTRL_BAR_TYPE barType)
{
	MSG_MAIN_HIGH("Update ctrl_bar. barType=%d", barType);

//remove old control bar item.
	Evas_Object* ctrl_bar = pMainView->ctrl_bar;

	int i = 0;

	for ( i = 0 ; i < MAX_CTRL_ITEM_CNT ; i ++)
	{
		if (pMainView->ctrl_bar_item[i])
		{
		    elm_object_item_del(pMainView->ctrl_bar_item[i]);
		    pMainView->ctrl_bar_item[i] = NULL;
		}
	}

/*
	IVUG_MODE_NORMAL =>
		Depends on content
			Image [Delete, Slide show, Detail]  -> CTRL_BAR_TYPE_IMAGE
			Video [Delete, Slide show, Detail]  -> CTRL_BAR_TYPE_VIDEO

	IVUG_MODE_SINGLE, IVUG_MODE_FILE,  => CTRL_BAR_TYPE_FILE [Delete,Info]
	IVUG_MODE_DISPLAY => CTRL_BAR_TYPE_EMPTY

	if ((mode == IVUG_MODE_FILE) || (mode == IVUG_MODE_SINGLE))
		barType == CTRL_BAR_TYPE_FILE

*/
	switch(barType)
	{
	case CTRL_BAR_TYPE_FILE:
		pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
		pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
		break;

	case CTRL_BAR_TYPE_CAMERA_IMAGE:
		pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
		pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
		break;

	case CTRL_BAR_TYPE_CAMERA_VIDEO:
		pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
		pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
		break;

	case CTRL_BAR_TYPE_IMAGE:
		pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
		pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_SLIDESHOW, NULL, _ivug_main_view_ctrlbar_slide_show_cb, pMainView);
		pMainView->ctrl_bar_item[2] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
		break;

	case CTRL_BAR_TYPE_VIDEO:
		pMainView->ctrl_bar_item[0] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_DELETE, NULL, _ivug_main_view_ctrlbar_delete_cb, pMainView);
		pMainView->ctrl_bar_item[1] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_SLIDESHOW, NULL, _ivug_main_view_ctrlbar_slide_show_cb, pMainView);
		pMainView->ctrl_bar_item[2] = elm_toolbar_item_append(ctrl_bar,
			ICON_PATH_INFO, NULL, _ivug_main_view_navibar_detail_cb, pMainView);
		break;

	default:
		MSG_MAIN_ERROR("Unhandled ctrl bar type=%d", barType);
		break;
	}

}

static void _update_main_view(Ivug_MainView *pMainView, Slide_Item *sitem)
{
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);
	if(mdata == NULL)
	{
		MSG_MAIN_ERROR("mdata is NULL");
		return;
	}

	PERF_CHECK_BEGIN(LVL6 "Set menu title");

	_update_title(pMainView);

	PERF_CHECK_END(LVL6 "Set menu title");

	if(pMainView->pDetailsView)
	{
		MSG_MAIN_ERROR("In details view, skip update toolbar/controlbar");
		return;
	}

	enum CTRL_BAR_TYPE ctrlBarType;
	enum NAVI_BAR_TYPE toolBarType;

	ctrlBarType = _get_ctrl_bar_type(pMainView->mode, mdata->slide_type);
	toolBarType = _get_tool_bar_type(pMainView->mode, mdata->slide_type);

	if ( toolBarType != pMainView->tool_bar_type )		// when change toolbar Type
	{
		PERF_CHECK_BEGIN(LVL6 "add toolbar item");

		MSG_MAIN_HIGH("ToolBar update. Old=%d Cur=%d", toolBarType , pMainView->tool_bar_type);
		_update_tool_bar(pMainView, toolBarType);
		pMainView->tool_bar_type = toolBarType;

		PERF_CHECK_END(LVL6 "add toolbar item");
	}

	if ( ctrlBarType != pMainView->ctrl_bar_type )	// when change ctrlbar Type
	{
		PERF_CHECK_BEGIN(LVL6 "add contolbar item");

		MSG_MAIN_HIGH("CtrlBar update. Old=%d Cur=%d", ctrlBarType , pMainView->ctrl_bar_type);
		_update_ctrl_bar(pMainView, ctrlBarType);
		pMainView->ctrl_bar_type = ctrlBarType;

		PERF_CHECK_END(LVL6 "add contolbar item");
	}

// If Inavalid image, disable all buttons.

	slide_state_t state = ivug_slider_item_get_state(sitem);

	Elm_Object_Item *item = NULL;
	if ( state == SLIDE_STATE_ERROR)
	{
		const char *item_label = NULL;
		Evas_Object *object = NULL;

		/* Disable all toolbar items */
		int i = 0;
		for(i=0; i<MAX_NAVI_ITEM_CNT; i++)
		{
			if(pMainView->tool_bar_item[i] && (item_label = elm_object_text_get(pMainView->tool_bar_item[i])) )
			{
				if(!strncmp(item_label, IDS_DETAILS, strlen(item_label)))
				{
					MSG_MAIN_HIGH("Skip %s", item_label);
					continue;
				}
			}
			elm_object_disabled_set(pMainView->tool_bar_item[i], EINA_TRUE);
		}

		/* Disable all controlbar items */
#ifdef _USE_LABEL_
		item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
		for(; item!=NULL; item=elm_toolbar_item_next_get(item)){
			item_label = elm_object_item_text_get(item);
			if(item_label && (!strncmp(item_label, IDS_DELETE, strlen(item_label)) ||
				!strncmp(item_label, IDS_DETAILS, strlen(item_label)) ||
				!strncmp(item_label, IDS_SLIDE_SHOW, strlen(item_label))))
			{
				MSG_MAIN_HIGH("Skip %s", item_label);
				continue;
			}

			elm_object_item_disabled_set(item, EINA_TRUE);
		}
#else
		const char *icon_file = NULL;
		item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
		for(; item!=NULL; item=elm_toolbar_item_next_get(item))
		{
			object = elm_toolbar_item_icon_object_get(item);
			if(!object)
				continue;

			elm_icon_file_get(object, &icon_file, NULL);

			if(icon_file && (!strncmp(icon_file, ICON_PATH_DELETE, strlen(icon_file)) ||
				!strncmp(icon_file, ICON_PATH_INFO, strlen(icon_file)) ||
				!strncmp(icon_file, ICON_PATH_SLIDESHOW, strlen(icon_file))))
			{
				MSG_MAIN_HIGH("Skip %s", icon_file);
				continue;
			}

			elm_object_item_disabled_set(item, EINA_TRUE);
		}
#endif
		return ;
	}
	else
	{
		int i = 0;
		/* Enable all toolbar items */
		for(i=0; i<MAX_NAVI_ITEM_CNT; i++)
		{
			if(pMainView->tool_bar_item[i])
			{
				elm_object_disabled_set(pMainView->tool_bar_item[i], EINA_FALSE);
			}
		}

		/* Enable all controlbar items */
		item = elm_toolbar_first_item_get(pMainView->ctrl_bar);
		for(; item!=NULL; item=elm_toolbar_item_next_get(item))
		{
			elm_object_item_disabled_set(item, EINA_FALSE);
		}
	}

	if(mdata->slide_type == SLIDE_TYPE_IMAGE)
	{
		_show_zoom_icon(pMainView);
	}
	else
	{
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,hide","elm");
		edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,hide","elm");
	}
}

void
_ivug_main_view_show_menu_bar(Ivug_MainView *pMainView)
{
	MSG_MAIN_HIGH("Show Menu");

	pMainView->bShowMenu = EINA_TRUE;
	evas_object_show(pMainView->ctrl_bar);
	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);

	_update_main_view(pMainView, sitem);

#ifdef HIDE_INDICATOR
	elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_HIDE);
#else
	elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_SHOW);
#endif

	Media_Data *mdata = ivug_data_get_data(sitem->mitem);
	if(mdata == NULL)
	{
		MSG_MAIN_ERROR("mdata is NULL");
		return;
	}

	if(mdata->slide_type == SLIDE_TYPE_IMAGE)
	{
		_show_zoom_icon(pMainView);
	}

	elm_naviframe_item_title_visible_set(pMainView->navi_it, EINA_TRUE);
	elm_object_item_signal_emit(pMainView->navi_it, "elm,state,controlbar,open", "");

#ifdef TEST_MOUSE_EVENT
	Eina_List *l = evas_object_clipees_get(pMainView->navi_bar);

	MSG_MAIN_HIGH("Clipper clips %i objects", eina_list_count(l));

	Evas_Object *obj;
	Eina_List *l1;

	EINA_LIST_FOREACH(l, l1, obj)
	{

	MSG_MAIN_HIGH("Object Type : %s", evas_object_name_get(obj));

	}
	Evas_Object *above;
	Evas_Object *below;


	above = evas_object_above_get(pMainView->navi_bar);
	MSG_MAIN_HIGH("Navi Above : 0x%08x %s %s", above, evas_object_name_get(above), evas_object_type_get(above));

	below = evas_object_below_get(pMainView->navi_bar);
	MSG_MAIN_HIGH("Navi Below : 0x%08x %s %s", below, evas_object_name_get(below), evas_object_type_get(below));

	above = evas_object_above_get(pMainView->slider);
	MSG_MAIN_HIGH("Slider Above : 0x%08x %s %s", above, evas_object_name_get(above), evas_object_type_get(above));

	below = evas_object_below_get(pMainView->slider);
	MSG_MAIN_HIGH("Slider Below : 0x%08x %s %s", below, evas_object_name_get(below), evas_object_type_get(below));
#endif


}


void
_ivug_main_view_hide_menu_bar(Ivug_MainView *pMainView)
{
	MSG_MAIN_HIGH("Hide Menu");

	pMainView->bShowMenu = EINA_FALSE;
	elm_widget_disabled_set(pMainView->ctrl_bar, EINA_TRUE);

	elm_win_indicator_mode_set(ug_get_window(), ELM_WIN_INDICATOR_HIDE);
	edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_out,hide","elm");
	edje_object_signal_emit(_EDJ(pMainView->empty_layout), "elm,state,btn_zoom_in,hide","elm");
	elm_naviframe_item_title_visible_set(pMainView->navi_it, EINA_FALSE);
	elm_object_item_signal_emit(pMainView->navi_it, "elm,state,controlbar,close", "");
}


static void
_ivug_main_view_clicked(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Main View Clicked");
	IV_ASSERT(data != NULL);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

// TODO : Bug. menu bar is blinking when stopping slide show.
	if (pMainView->bShowMenu)
	{
		_ivug_main_view_hide_menu_bar(pMainView);
	}
	else
	{
		_ivug_main_view_show_menu_bar(pMainView);
	}

}

static void
_ivug_main_view_icon_clicked(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Main View Video icon Clicked");
	IV_ASSERT(data != NULL);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);

	if (mdata == NULL)
	{
		MSG_MAIN_ERROR("slide data is NULL");
		return;
	}

	if (pMainView->mode == IVUG_MODE_FILE || pMainView->mode == IVUG_MODE_DISPLAY || pMainView->mode == IVUG_MODE_SINGLE )
	{
		MSG_MAIN_HIGH("Launching simple video player. Mode=%d", pMainView->mode);
		ivug_ext_aul_launch(pMainView->layout, IVUG_EXT_AUL_SIMPLE_VIDEOPLAYER, mdata->filepath, NULL);
	}
	else
	{
		MSG_MAIN_HIGH("Launching normal video player");
		ivug_ext_aul_launch(pMainView->layout, IVUG_EXT_AUL_VIDEOPLAYER, mdata->filepath, NULL);
	}

}

static void
_ivug_main_view_long_pressed(void *data, Evas_Object *obj, void *event_info)
{
	Evas_Coord_Point* down_pose = (Evas_Coord_Point*)event_info;
	ivug_ret_if(!data||!down_pose);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	MSG_MAIN_HIGH("LongPressed XY(%d,%d)", down_pose->x, down_pose->y);

	int x = down_pose->x;
	int y =  down_pose->y;

	Slide_Item *si = ivug_slider_get_current_slide_item(pMainView->slider);
	IV_ASSERT(si != NULL);

	if ( ivug_slider_item_get_state(si) != SLIDE_STATE_LOADED)
	{
		MSG_MAIN_ERROR("Long pressed. but state is not ready");
		return;
	}

	pMainView->copy_popup = _ivug_main_create_copy_popup_create(pMainView, x, y);
	if (pMainView->copy_popup == NULL)
	{
		IVUG_DEBUG_WARNING("copy popup create failed");
		return ;
	}

}


static void
_ivug_main_view_slider_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Image slider changed callback. ");

	ivug_ret_if(!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;
	Slide_Item *sitem = (Slide_Item *)event_info;

	if ( sitem == NULL || sitem->mitem == NULL)
	{
		// There is no item existed. terminate UG
		MSG_MAIN_ERROR("No item is remained. exit UG. Sitem=0x%08x", sitem);
		IVUG_MAIN_DESTROY_ME(pMainView);
		return;
	}

	if(pMainView->selectioninfo != NULL)
	{
		MSG_MAIN_MED("Delete small noti");
		evas_object_del(pMainView->selectioninfo);
		pMainView->selectioninfo = NULL;
	}
	if (pMainView->copy_popup)
	{
		MSG_MAIN_MED("Delete copy popup");
		evas_object_del(pMainView->copy_popup);
		pMainView->copy_popup = NULL;
	}

// Update Main View.
	if ( pMainView->bShowMenu == true )
	{
		PERF_CHECK_BEGIN(LVL5 "Update main view");
		_update_main_view(pMainView, sitem);
		PERF_CHECK_END(LVL5 "Update main view");
	}

}


static void
_ivug_main_view_slider_item_state_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Image slider item state changed callback. ");
	ivug_ret_if(!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;
	Slide_Item *sitem = (Slide_Item *)event_info;

	if ( sitem == NULL || sitem->mitem == NULL)
	{
		// There is no item existed. terminate UG
		MSG_MAIN_ERROR("No item is remained. exit UG");
		IVUG_MAIN_DESTROY_ME(pMainView);
		return;
	}

// Update Main View.
	if ( pMainView->bShowMenu == true )
	{
		_update_main_view(pMainView, sitem);
	}
}


static void
_ivug_main_view_slider_deleted_cb(void *data, Evas_Object *obj, void *event_info)
{
	MSG_MAIN_HIGH("Image slider deleted callback. ");
	ivug_ret_if(!data);

	Ivug_MainView *pMainView = (Ivug_MainView *)data;
	Slide_Item *sitem = (Slide_Item *)event_info;

	if ( sitem == NULL || sitem->mitem == NULL )
	{
		// There is no item existed. terminate UG
		MSG_MAIN_ERROR("No item is remained. exit UG");
		IVUG_MAIN_DESTROY_ME(pMainView);
		return;
	}

	_main_view_create_selection_info(pMainView, IDS_DELETED);

	if ( pMainView->bShowMenu == true )
	{
		_update_main_view(pMainView, sitem);
	}

}


static void
_ivug_main_view_slider_slideshow_finished_cb(void *data, Evas_Object *obj, void *event_info)
{
	IV_ASSERT(data != NULL);
	MSG_MAIN_HIGH("Slide show finished callback. ");

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	ivug_allow_lcd_off();
	ivug_slider_stop_slide_show(pMainView->slider);

	elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);

	_ivug_main_view_show_menu_bar(pMainView);
}

static void
_ivug_main_view_slider_slideshow_interrupted_cb(void *data, Evas_Object *obj, void *event_info)
{
	IV_ASSERT(data != NULL);
	MSG_MAIN_HIGH("Slide show interrupted callback. ");

	Ivug_MainView *pMainView = (Ivug_MainView *)data;

	ivug_allow_lcd_off();

	elm_object_item_disabled_set(pMainView->ctrl_bar_item[1], EINA_FALSE);

	_ivug_main_view_show_menu_bar(pMainView);
}



#ifdef TEST_MOUSE_EVENT
void _on_receive_mouse_move (void *data, Evas *e, Evas_Object *obj, void *event_info)
{
	char *tt = data;
	MSG_MAIN_HIGH("Hmm!!! %s", tt);
}
#endif

static void
_on_menu_state_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
{
	Ivug_MainView *pMainView = data;

	MSG_MAIN_HIGH("Receive %s %s", emission, source);

	if ( strncmp(emission, "menu,show,finished", strlen(emission)) == 0 )
	{
		elm_widget_disabled_set(pMainView->ctrl_bar, EINA_FALSE);
	}
	else
	{
		evas_object_hide(pMainView->ctrl_bar);
		elm_widget_disabled_set(pMainView->ctrl_bar, EINA_TRUE);
	}
}

bool
ivug_main_view_load_list(Ivug_MainView *pMainView, ivug_parameter* ivug_param)
{
	MSG_MAIN_HIGH("Load media list.");

	PERF_CHECK_BEGIN(LVL1 "create media list");

	Media_Data *mdata = ivug_slider_create_media_list(pMainView->slider, ivug_param);
	if (mdata == NULL)
	{
		MSG_MAIN_ERROR("Creating media list is failed");
		return false;
	}

	PERF_CHECK_END(LVL1 "create media list");

	return true;
}

Ivug_MainView *
ivug_main_view_create(Evas_Object* parent, 	ivug_mode mode, ivug_view_by view_by)
{
	IV_ASSERT(parent != NULL);

	MSG_MAIN_HIGH("Creating main view. Parent=0x%08x Mode=%d ViewBy=%d", parent, mode, view_by);

	PERF_CHECK_BEGIN(LVL2 "Create layout");

//create main view layout
	Ivug_MainView *pMainView = calloc(1, sizeof(Ivug_MainView) );
	IV_ASSERT(pMainView != NULL);

// Set default value
	pMainView->parent = parent;
	pMainView->bShowMenu = true;
	pMainView->ugHandle = gGetUGHandle();
	pMainView->mode = mode;
	pMainView->view_by = view_by;

	Evas_Object *layout;
	layout = elm_layout_add(parent);
	if ( layout == NULL)	//if failed
	{
		MSG_MAIN_ERROR("main layout create failed");
		free(pMainView);
		return NULL;
	}

	pMainView->layout = layout;

	PERF_CHECK_END(LVL2 "Create layout");

	PERF_CHECK_BEGIN(LVL2 "load EDJ");

	if (elm_layout_file_set(layout, IVUG_MAIN_EDJ, "mainview") == EINA_FALSE)
	{
		MSG_MAIN_ERROR("edj loading fail, file=%s group=%s", IVUG_MAIN_EDJ, IVUG_MAIN_EDJ);
		evas_object_del(layout);
		free(pMainView);
		return NULL;
	}

	edje_object_signal_callback_add(_EDJ(pMainView->layout),
				"menu,hide,finished",
				"edc",
				_on_menu_state_changed,
				(void *)pMainView);

	edje_object_signal_callback_add(_EDJ(pMainView->layout),
				"menu,show,finished",
				"edc",
				_on_menu_state_changed,
				(void *)pMainView);

	evas_object_show(layout);

// Navigation bar
	pMainView->navi_bar = elm_naviframe_add(layout);
	if ( pMainView->navi_bar == NULL)
	{
		MSG_MAIN_ERROR("navigation bar failed");
		ivug_main_view_destroy(pMainView);
		return NULL;
	}

// Layout life cycle is controlled by application explictily.
	elm_naviframe_content_preserve_on_pop_set(pMainView->navi_bar, EINA_TRUE);

#ifdef USE_CUSTOM_STYLE
	elm_object_theme_set(pMainView->navi_bar, gGetSystemTheme() );
	Eina_Bool bstyle = elm_object_style_set(pMainView->navi_bar, "ivug/default");
	MSG_MAIN_HIGH("navi_bar elm_object_style_set result = %d", bstyle);
#endif

	elm_object_part_content_set(layout, "mainview.navibar", pMainView->navi_bar);	//swallow

	pMainView->empty_layout = elm_layout_add(layout);	//create centents layout.
	if (elm_layout_file_set(pMainView->empty_layout, IVUG_MAIN_EDJ, "navi_content"))
	{
		MSG_MAIN_HIGH("create Empty layout for navigation bar. Navi=0x%08x Empty Layout=0x%08x", pMainView->navi_bar, pMainView->empty_layout);
	}
	else
	{
		IVUG_DEBUG_WARNING("layout sawllow failed");
		ivug_main_view_destroy(pMainView);
		return NULL;
	}

	//create slider
	pMainView->slider = ivug_slider_add(pMainView->empty_layout);
	if (pMainView->slider == NULL)
	{
		MSG_MAIN_ERROR("image slider create failed");
		ivug_main_view_destroy(pMainView);
		return NULL;
	}
	elm_object_part_content_set(pMainView->empty_layout, "mainview.slider", pMainView->slider);	//swallow

	Evas_Object *back_btn = elm_button_add(pMainView->navi_bar);
	elm_object_text_set(back_btn, IDS_BACK );	//elm_button_icon_set
	elm_object_style_set(back_btn, "naviframe/end_btn/default");

	evas_object_smart_callback_add(back_btn, "clicked", _ivug_main_view_back_cb, pMainView);

	pMainView->navi_it = elm_naviframe_item_push(pMainView->navi_bar, IDS_LOADING , back_btn, NULL, pMainView->empty_layout, NULL);

	pMainView->back_btn = back_btn;

	if (pMainView->mode != IVUG_MODE_DISPLAY)		// Display mode has no control bar in bottom.
	{
		pMainView->ctrl_bar = _create_ctrl_bar(pMainView->navi_bar, gGetSystemTheme());
		elm_object_item_part_content_set(pMainView->navi_it, "controlbar", pMainView->ctrl_bar);
	}

	PERF_CHECK_END(LVL2 "load EDJ");

	PERF_CHECK_BEGIN(LVL2 "add slider");

	//elm_object_part_content_set(layout, "mainview.slider", pMainView->slider);	//swallow

//register mouse call back.
	evas_object_smart_callback_add(pMainView->slider, "slider,clicked", _ivug_main_view_clicked, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,longpressed", _ivug_main_view_long_pressed, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,clicked,icon", _ivug_main_view_icon_clicked, pMainView);

	evas_object_smart_callback_add(pMainView->slider, "slider,item,changed", _ivug_main_view_slider_changed_cb, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,item,deleted", _ivug_main_view_slider_deleted_cb, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,slideshow,finished", _ivug_main_view_slider_slideshow_finished_cb, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,slideshow,interrupted", _ivug_main_view_slider_slideshow_interrupted_cb, pMainView);
	evas_object_smart_callback_add(pMainView->slider, "slider,item,state,changed", _ivug_main_view_slider_item_state_changed_cb, pMainView);

#ifdef TEST_MOUSE_EVENT
	evas_object_event_callback_add(pMainView->navi_bar, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "navigarion");
	evas_object_event_callback_add(pMainView->layout, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "layout");
	evas_object_event_callback_add(pMainView->parent, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "base");
	evas_object_event_callback_add(pMainView->slider, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "slider");
	evas_object_event_callback_add(edje_object_part_object_get(_EDJ(pMainView->layout) , "clip"), EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "clip");
	evas_object_event_callback_add(edje_object_part_object_get(_EDJ(pMainView->layout) , "mainview.navibar"), EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "navi swallow");
	evas_object_event_callback_add(pMainView->ctrl_bar, EVAS_CALLBACK_MOUSE_MOVE, _on_receive_mouse_move, "controlbar");
#endif

	PERF_CHECK_END(LVL2 "add slider");

	PERF_CHECK_BEGIN(LVL2 "add event handler");

	edje_object_signal_callback_add(_EDJ(pMainView->empty_layout),
					"mainview,zoom_out,clicked",
					"",
					_ivug_main_view_zoom_out_cb,
					(void *)pMainView);
	edje_object_signal_callback_add(_EDJ(pMainView->empty_layout),
					"mainview,zoom_in,clicked",
					"",
					_ivug_main_view_zoom_in_cb,
					(void *)pMainView);

	_show_zoom_icon(pMainView);

	int ret = -1;
	MSG_IMAGEVIEW_HIGH("Register System notifications");
	ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _on_mmc_state_changed, pMainView);
	if ( ret == -1 )
	{
		MSG_IMAGEVIEW_ERROR("Register %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
	}

	pMainView->keydown_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
							    (void *)_key_down_cb,
				 				(void *)pMainView);

	MSG_MAIN_HIGH("Main View starting");

// For debugging.
	DELETE_NOTIFY(pMainView->layout);

	PERF_CHECK_END(LVL2 "add event handler");

	return pMainView;

}


Evas_Object *
ivug_main_view_object_get(Ivug_MainView *pMainView)
{
	IV_ASSERT(pMainView != NULL);

	return pMainView->layout;
}

void
ivug_main_view_update(Ivug_MainView *pMainView)
{
	IV_ASSERT(pMainView != NULL);

	MSG_MAIN_HIGH("Main View Update");

	Slide_Item *sitem = ivug_slider_get_current_slide_item(pMainView->slider);
	Media_Data *mdata = ivug_data_get_data(sitem->mitem);

	ivug_ret_if(!mdata);

// TODO : Check this routine!.
// TODO : Should implement again!!

	if (mdata->slide_type == SLIDE_TYPE_IMAGE || mdata->slide_type == SLIDE_TYPE_VIDEO )
	{
		if(mdata->filepath && ecore_file_exists(mdata->filepath)) // Current file is not deleted
		{
			MSG_MAIN_HIGH("Current filepath : %s", mdata->filepath);
		}
		else
		{
			/*if file is not exist ug terminated temporally */
			MSG_MAIN_ERROR("Center slide file is not exist");
			IVUG_MAIN_DESTROY_ME(pMainView);
			return ;
		}
	}

// When resume, menu bar will be appeared.
	_ivug_main_view_show_menu_bar(pMainView);
}


void
ivug_main_view_destroy(Ivug_MainView *pMainView)
{
	IV_ASSERT(pMainView != NULL);

	MSG_MAIN_HIGH("ENTER : Main View Destroy. pMainView=0x%08x", pMainView);

	if( pMainView->event_blocker )
	{
		MSG_MAIN_HIGH("delete event blocker");
		evas_object_del(pMainView->event_blocker);
		pMainView->event_blocker = NULL;
	}

	if(pMainView->ext_ug)
	{
		MSG_MAIN_HIGH("destroy ug");
		ug_destroy(pMainView->ext_ug);
		pMainView->ext_ug = NULL;
	}

	if( pMainView->pDetailsView )
	{
		MSG_MAIN_HIGH("Details View Destroy");

		ivug_details_view_destroy(pMainView->pDetailsView);
		pMainView->pDetailsView = NULL;
	}

	if(pMainView->layout)		// Remove topmost parent in main view.
	{
		evas_object_del(pMainView->layout);
		pMainView->layout = NULL;
	}

	if (pMainView->exit_timer)
	{
		ecore_timer_del(pMainView->exit_timer);
		pMainView->exit_timer = NULL;
	}

	int ret = -1;

	MSG_IMAGEVIEW_HIGH("Unregister system notifications");

	if(pMainView->keydown_handler)
	{
		ecore_event_handler_del(pMainView->keydown_handler);
		pMainView->keydown_handler = NULL;
	}

	ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, _on_mmc_state_changed);
	if ( ret == -1 )
	{
		MSG_IMAGEVIEW_ERROR("Unegister %s is failed", VCONFKEY_SYSMAN_MMC_STATUS);
	}

	free(pMainView);

	MSG_MAIN_HIGH("LEAVE : Main View Destroy.");

	return ;
}