initial upload for tizen 2.0 beta
[apps/home/gallery.git] / src / features / gl-listview.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #include "gl-debug.h"
18 #include "gl-ui-util.h"
19 #include "gl-util.h"
20 #include "gl-albums.h"
21 #include "gl-listview.h"
22 #include "gl-ext-ug-load.h"
23 #include "gl-ext-exec.h"
24 #include "gl-data.h"
25 #include "gl-drm.h"
26 #include "gl-controlbar.h"
27 #include "gl-button.h"
28 #include "gl-nocontents.h"
29 #include "gl-notify.h"
30 #include "gl-progressbar.h"
31 #include "gl-video.h"
32 #include "gl-strings.h"
33 #include "gl-popup.h"
34
35 static void __gl_list_item_check_changed(void *data, Evas_Object * obj, void *event_info)
36 {
37         GL_CHECK(obj);
38         GL_CHECK(data);
39         gl_item *gitem = (gl_item *) data;
40         GL_CHECK(gitem);
41         GL_CHECK(gitem->item);
42         GL_CHECK(gitem->ad);
43         gl_appdata *ad = (gl_appdata *)gitem->ad;
44         int view_mode = gl_get_view_mode(ad);
45         gl_dbg("");
46
47         if (view_mode != GL_VIEW_VIDEOLIST_EDIT)
48         {
49                 gl_dbg("ViewMode.%d. now return.", view_mode);
50                 return;
51         }
52         else
53         {
54                 gl_dbg("Edit Mode");
55         }
56
57         int cnt = 0;
58         Eina_Bool checked = elm_check_state_get(obj);
59         gitem->checked = checked;
60         if (checked)
61         {
62                 gl_dbg("Append:%s", gitem->item->file_url);
63                 _gl_data_selected_list_append(ad, gitem);
64         }
65         else
66         {
67                 gl_dbg("Remove:%s", gitem->item->file_url);
68                 _gl_data_selected_list_remove(ad, gitem);
69         }
70
71         cnt = _gl_data_selected_list_count(ad);
72
73         /* Display selectioninfo */
74         _gl_notify_create_selinfo(ad, ad->gridinfo.edit_layout,
75                                   ad->gridinfo.nf_it_edit,
76                                   ad->listinfo.videos_cnt, cnt, false);
77 }
78
79 static void __gl_list_share_cb(void *data, Evas_Object *obj, void *event_info)
80 {
81         gl_dbg("");
82         GL_CHECK(data);
83         gl_item *gitem = (gl_item *)data;
84         GL_CHECK(gitem->ad);
85         gl_popup_create_title_popup(gitem->ad, GL_POPUP_THUMB_SHARE,
86                                     GL_STR_SHARE, NULL);
87 }
88
89 static void __gl_list_del_cb(void *data, Evas_Object *obj, void *event_info)
90 {
91         gl_dbg("");
92         GL_CHECK(data);
93         _gl_popup_create_video_del_popup(data);
94 }
95
96 static char *__gl_list_get_text(void *data, Evas_Object *obj, const char *part)
97 {
98         GL_CHECK_NULL(part);
99         GL_CHECK_NULL(data);
100         gl_item *gitem = (gl_item *) data;
101         GL_CHECK_NULL(gitem->item);
102         GL_CHECK_NULL(gitem->ad);
103
104         if (!g_strcmp0(part, GL_VIDEO_PART_TITLE) ||
105             !g_strcmp0(part, GL_VIDEO_PART_SLIDE_TITLE)) {
106                 if (gitem->item->display_name) {
107                         return strdup(gitem->item->display_name);
108                 } else {
109                         gl_dbgE("Invalid name!");
110                         return NULL;
111                 }
112         } else if (!g_strcmp0(part, GL_VIDEO_PART_DURATION)) {
113                 /* Running time of the video */
114                 unsigned int v_dur = 0;
115
116                 if (gitem->item->video_info == NULL) {
117                 } else {
118                         v_dur = gitem->item->video_info->duration;
119                 }
120
121                 char *dur_str = _gl_get_duration_string(v_dur);
122                 return dur_str;
123         }
124
125         return NULL;
126 }
127
128 static Evas_Object *__gl_list_get_content(void *data, Evas_Object *obj, const char *part)
129 {
130         GL_CHECK_NULL(obj);
131         GL_CHECK_NULL(part);
132         GL_CHECK_NULL(data);
133         gl_item *gitem = (gl_item *) data;
134         GL_CHECK_NULL(gitem->item);
135         GL_CHECK_NULL(gitem->ad);
136         gl_appdata *ad = (gl_appdata *)gitem->ad;
137         bool is_expired_drm = false;
138
139         if (!g_strcmp0(part, GL_VIDEO_PART_CHECKBOX)) {
140                 Evas_Object *ck = NULL;
141                 ck = _gl_video_show_part_checkbox(obj, gitem->checked,
142                                                   __gl_list_item_check_changed,
143                                                   data);
144                 gitem->check_obj = ck;
145                 return ck;
146         } else if (!g_strcmp0(part, GL_VIDEO_PART_ICON)) {
147                 /* Is it DRM file? Has a valid RO? */
148                 char *path = NULL;
149                 if(gl_drm_is_drm_file(gitem->item->file_url) &&
150                    gl_drm_check_valid_ro(gitem->item->file_url, gl_drm_get_permtype(gitem->item->type)) == false) {
151                         path = GL_DEFAULT_THUMB_ICON;
152                         is_expired_drm = true;
153                 } else {
154                         path = _GETICON(gitem->item->thumb_url);
155                 }
156
157                 Evas_Object *bg = NULL;
158                 bg = _gl_video_show_part_icon(obj, path, 0, GL_VIDEO_ICON_WIDTH,
159                                               GL_VIDEO_ICON_HEIGHT);
160                 return bg;
161         } else if (!g_strcmp0(part, GL_VIDEO_PART_PLAY)) {
162                 Evas_Object *icon = NULL;
163                 icon = _gl_video_show_part_play(obj);
164                 return icon;
165         } else if (!g_strcmp0(part, GL_VIDEO_PART_BOOKMARK)) {
166                 Evas_Object *icon = NULL;
167                 int bk_len = 0;
168                 if (gitem->item->video_info)
169                         bk_len = gitem->item->video_info->bookmarks;
170
171                 gl_dbg("%s has %d bookmark(s)", gitem->item->file_url, bk_len);
172                 if (bk_len) {
173                         icon = _gl_video_show_part_bookmark(obj);
174                 }
175                 return icon;
176         } else if (!g_strcmp0(part, GL_VIDEO_PART_PBAR)) {
177                 return _gl_video_show_pbar(obj, gitem);
178         } else if (!g_strcmp0(part, GL_VIDEO_PART_SLIDE1)) {
179                 Evas_Object *share_btn = NULL;
180                 share_btn = _gl_but_create_but(obj, GL_BUT_SHARE,
181                                                GL_BUTTON_STYLE_SWEEP);
182                 GL_CHECK_NULL(share_btn);
183                 evas_object_smart_callback_add(share_btn, "clicked",
184                                                __gl_list_share_cb, data);
185
186                 if (ad->listinfo.sweep_file_path) {
187                         free(ad->listinfo.sweep_file_path);
188                         ad->listinfo.sweep_file_path = NULL;
189                 }
190                 /* Save sweep item */
191                 if (gitem->item->file_url)
192                         ad->listinfo.sweep_file_path = strdup(gitem->item->file_url);
193                 ad->listinfo.share_btn = share_btn;
194                 return share_btn;
195         } else if (!g_strcmp0(part, GL_VIDEO_PART_SLIDE3)) {
196                 Evas_Object *del_btn = NULL;
197                 del_btn = _gl_but_create_but(obj, GL_BUT_DEL,
198                                              GL_BUTTON_STYLE_SWEEP_DELETE);
199                 GL_CHECK_NULL(del_btn);
200                 evas_object_smart_callback_add(del_btn, "clicked",
201                                                __gl_list_del_cb, data);
202                 ad->listinfo.del_btn = del_btn;
203                 return del_btn;
204         }
205
206         return NULL;
207 }
208
209 static void __gl_list_del(void *data, Evas_Object *obj)
210 {
211         gl_dbg("");
212 }
213
214 static void __gl_list_genlist_sel(void *data, Evas_Object * obj, void *event_info)
215 {
216         gl_dbg("");
217 }
218
219 static void __gl_list_flick_left_cb(void *data, Evas_Object *obj, void *event_info)
220 {
221         elm_object_scroll_freeze_push(obj);
222 }
223
224 static void __gl_list_flick_right_cb(void *data, Evas_Object *obj, void *event_info)
225 {
226         elm_object_scroll_freeze_push(obj);
227 }
228
229 static void __gl_list_flick_stop_cb(void *data, Evas_Object *obj, void *event_info)
230 {
231         elm_object_scroll_freeze_pop(obj);
232 }
233
234 static void __gl_list_set_sweep(void *data, Evas_Object *obj, void *event_info)
235 {
236         gl_dbg("");
237         GL_CHECK(obj);
238         GL_CHECK(event_info);
239         GL_CHECK(data);
240         gl_appdata *ad = (gl_appdata *)data;
241         /* Disable sweep if in wrong view mode */
242         if (gl_get_view_mode(ad) != GL_VIEW_VIDEOLIST) {
243                 gl_dbgE("Wrong view mode!");
244                 return;
245         }
246         /* Finish other swept item */
247         Elm_Object_Item *it = NULL;
248         it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj);
249         if (it) {
250                 gl_dbg("Reset previous swept item first.");
251                 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
252                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
253         }
254         /* Start genlist sweep */
255         elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_TRUE);
256         elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_NONE);
257 }
258
259 static void __gl_list_unset_sweep(void *data, Evas_Object *obj, void *event_info)
260 {
261         gl_dbg("");
262         GL_CHECK(obj);
263         GL_CHECK(event_info);
264         GL_CHECK(data);
265         gl_appdata *ad = (gl_appdata *)data;
266         /* Disable sweep if in wrong view mode */
267         if (gl_get_view_mode(ad) != GL_VIEW_VIDEOLIST) {
268                 gl_dbgE("Wrong view mode!");
269                 return;
270         }
271         if (ad->listinfo.sweep_file_path) {
272                 free(ad->listinfo.sweep_file_path);
273                 ad->listinfo.sweep_file_path = NULL;
274         }
275         /* Finish genlist sweep */
276         elm_genlist_item_decorate_mode_set(event_info, "slide", EINA_FALSE);
277         elm_genlist_item_select_mode_set(event_info, ELM_OBJECT_SELECT_MODE_DEFAULT);
278 }
279
280 static void __gl_list_cancel_sweep(void *data, Evas_Object *obj, void *event_info)
281 {
282         gl_dbg("");
283         GL_CHECK(obj);
284         GL_CHECK(data);
285         gl_appdata *ad = (gl_appdata *)data;
286         if (ad->listinfo.sweep_file_path) {
287                 free(ad->listinfo.sweep_file_path);
288                 ad->listinfo.sweep_file_path = NULL;
289         }
290         /* Get sweeped item */
291         Elm_Object_Item *it = NULL;
292         it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj);
293         /* Finish genlist sweep */
294         if (it) {
295                 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
296                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
297         }
298 }
299
300 static int __gl_list_add_sweep_cbs(void *data, Evas_Object *obj)
301 {
302         GL_CHECK_VAL(obj, -1);
303         /* Stop flicking(up/down direction) when sweep list item*/
304         evas_object_smart_callback_add(obj, "drag,start,left",
305                                        __gl_list_flick_left_cb, data);
306         evas_object_smart_callback_add(obj, "drag,start,right",
307                                        __gl_list_flick_right_cb, data);
308         evas_object_smart_callback_add(obj, "drag,stop",
309                                        __gl_list_flick_stop_cb, data);
310         /* Add callback for sweeping */
311         evas_object_smart_callback_add(obj, "drag,start,right",
312                                        __gl_list_set_sweep, data);
313         evas_object_smart_callback_add(obj, "drag,start,left",
314                                        __gl_list_unset_sweep, data);
315         evas_object_smart_callback_add(obj, "drag,start,up",
316                                        __gl_list_cancel_sweep, data);
317         evas_object_smart_callback_add(obj, "drag,start,down",
318                                        __gl_list_cancel_sweep, data);
319         return 0;
320 }
321
322 static void
323 _gl_list_sel(void *data, Evas_Object * obj, void *event_info)
324 {
325         GL_CHECK(obj);
326         GL_CHECK(data);
327         gl_item *gitem = (gl_item *) data;
328         GL_CHECK(gitem->item);
329         GL_CHECK(gitem->ad);
330         gl_appdata *ad = (gl_appdata *)gitem->ad;
331         int view_mode = gl_get_view_mode(ad);
332         gl_dbg("");
333
334         Elm_Object_Item *gen_item = elm_genlist_selected_item_get(obj);
335         if (gen_item)
336         {
337                 elm_genlist_item_selected_set(gen_item, EINA_FALSE);
338         }
339
340         if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
341         {
342                 if (gitem->check_obj == NULL)
343                 {
344                         gl_dbg("item or check_obj is NULL");
345                         return;
346                 }
347
348                 gitem->checked = !gitem->checked;
349                 elm_check_state_set(gitem->check_obj, gitem->checked);
350
351                 if (gitem->checked)
352                 {
353                         gl_dbg("Append:%s", gitem->item->file_url);
354                         _gl_data_selected_list_append(ad, gitem);
355                 }
356                 else
357                 {
358                         gl_dbg("Remove:%s", gitem->item->file_url);
359                         _gl_data_selected_list_remove(ad, gitem);
360                 }
361
362                 int cnt = _gl_data_selected_list_count(ad);
363                 /* Display selectioninfo */
364                 _gl_notify_create_selinfo(ad, ad->gridinfo.edit_layout,
365                                           ad->gridinfo.nf_it_edit,
366                                           ad->listinfo.videos_cnt, cnt, false);
367         }
368         else
369         {
370                 /* Finish other swept item */
371                 Elm_Object_Item *it = NULL;
372                 it = (Elm_Object_Item *)elm_genlist_decorated_item_get(obj);
373                 if (it) {
374                         gl_dbg("Reset previous sweeped item first.");
375                         elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
376                         elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
377                 }
378
379                 GL_CHECK(gitem->item->uuid);
380                 if (ad->listinfo.played_uuid) {
381                         free(ad->listinfo.played_uuid);
382                         ad->listinfo.played_uuid = NULL;
383                 }
384                 ad->listinfo.played_uuid = strdup(gitem->item->uuid);
385                 /* Starting to play the video */
386                 gl_dbg("Starting to play the video");
387                 gl_ext_exec(data, GL_APP_VIDEOPLAYER);
388         }
389 }
390
391 static void
392 _gl_list_update_view(void *data, Evas_Object * obj, void *event_info)
393 {
394         GL_CHECK(obj);
395         GL_CHECK(data);
396         gl_appdata *ad = (gl_appdata *)data;
397         Evas_Object *genlist = obj;
398         int item_cnt = 0;
399         int view_mode = gl_get_view_mode(ad);
400         gl_dbg("");
401
402         elm_genlist_clear(genlist);
403
404         /* Get all medias count of current album */
405         int cnt = ad->maininfo.medias_cnt;
406         int i = 0;
407         gl_item *gitem = NULL;
408         bool it_showed = false;
409         Elm_Genlist_Item_Class *plic = NULL;
410         if (view_mode == GL_VIEW_VIDEOLIST_EDIT) {
411                 plic = &(ad->listinfo.videolic);
412                 ad->listinfo.videolic.item_style = GL_GENLIST_ITEM_STYLE_VIDEO_EDIT;
413         } else {
414                 ad->listinfo.videolic.item_style = GL_GENLIST_ITEM_STYLE_VIDEO;
415                 plic = &(ad->listinfo.sweeplic);
416         }
417
418         for (i = 1; i <= cnt; i++) {
419                 _gl_data_get_item_by_index(ad, i, false, &gitem);
420                 if (gitem == NULL || gitem->item == NULL) {
421                         gl_dbgE("gitem == NULL || gitem->item == NULL");
422                         continue;
423                 }
424                 if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) {
425                         gl_dbg("%s inserted", gitem->item->file_url);
426                         gitem->elm_item = elm_genlist_item_append(genlist, plic,
427                                                                   (void *)gitem,
428                                                                   NULL,
429                                                                   ELM_GENLIST_ITEM_NONE,
430                                                                   _gl_list_sel,
431                                                                   gitem);
432                         item_cnt++;
433                         gitem->sequence = item_cnt;
434                         if (ad->listinfo.played_uuid && !it_showed &&
435                             !g_strcmp0(ad->listinfo.played_uuid, gitem->item->uuid)) {
436                                 it_showed = true;
437                                 /*Move played item to middle position of view */
438                                 elm_genlist_item_show(gitem->elm_item,
439                                                       ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
440                         }
441                 }
442         }
443
444         if (ad->listinfo.played_uuid) {
445                 free(ad->listinfo.played_uuid);
446                 ad->listinfo.played_uuid = NULL;
447         }
448
449         if (ad->listinfo.sweep_file_path) {
450                 if (ecore_file_exists(ad->listinfo.sweep_file_path) &&
451                     (ecore_file_size(ad->listinfo.sweep_file_path) > 0)) {
452                         if (ad->popupinfo.popup) {
453                                 /* Remove popup */
454                                 evas_object_del(ad->popupinfo.popup);
455                                 ad->popupinfo.popup = NULL;
456                         }
457                 }
458                 free(ad->listinfo.sweep_file_path);
459                 ad->listinfo.sweep_file_path = NULL;
460         }
461
462         ad->listinfo.videos_cnt = item_cnt;
463         if (item_cnt > 0) {
464                 evas_object_smart_callback_add(genlist, "selected",
465                                                __gl_list_genlist_sel, NULL);
466
467                 if (view_mode != GL_VIEW_VIDEOLIST_EDIT) {
468                         if (ad->listinfo.videos_nocontents)
469                         {
470                                 evas_object_hide(ad->listinfo.videos_nocontents);
471                                 gl_list_clear_view(ad);
472                         }
473                         ad->listinfo.videos_view = genlist;
474                 } else {
475                         ad->gridinfo.edit_view = genlist;
476                 }
477         } else {
478                 evas_object_del(genlist);
479
480                 if (view_mode == GL_VIEW_VIDEOLIST_EDIT) {
481                         ad->gridinfo.edit_view = NULL;
482                         ad->gridinfo.edit_layout = NULL;
483                         elm_naviframe_item_pop(ad->maininfo.naviframe);
484                 }
485
486                 if (ad->listinfo.videos_nocontents) {
487                         gl_dbg("Nocontents view already created...");
488                         return;
489                 }
490
491                 if (ad->listinfo.videos_view) {
492                         evas_object_hide(ad->listinfo.videos_view);
493                         gl_list_clear_view(ad);
494                 }
495
496                 _gl_ctrl_disable_toolbar_item(ad, true, GL_NAVI_THUMBS,
497                                               false);
498                 Evas_Object *noc = _gl_nocontents_create(ad);
499                 evas_object_show(noc);
500                 ad->listinfo.videos_view = noc;
501                 ad->listinfo.videos_nocontents = noc;
502
503                 elm_object_part_content_unset(ad->gridinfo.layout,
504                                               "elm.swallow.view");
505                 elm_object_part_content_set(ad->gridinfo.layout,
506                                             "elm.swallow.view",
507                                             ad->listinfo.videos_view);
508         }
509 }
510
511 int _gl_list_clear_data(void *data)
512 {
513         GL_CHECK_VAL(data, -1);
514         gl_appdata *ad = (gl_appdata *)data;
515
516         if (ad->listinfo.played_uuid) {
517                 free(ad->listinfo.played_uuid);
518                 ad->listinfo.played_uuid = NULL;
519         }
520
521         if (ad->listinfo.sweep_file_path) {
522                 free(ad->listinfo.sweep_file_path);
523                 ad->listinfo.sweep_file_path = NULL;
524         }
525         return 0;
526 }
527
528 Evas_Object *
529 gl_list_create_view(void *data, Evas_Object * parent)
530 {
531         GL_CHECK_NULL(data);
532         gl_appdata *ad = (gl_appdata *)data;
533         Evas_Object *genlist = NULL;
534         int item_cnt = 0;
535         gl_item *gitem = NULL;
536         /* Get all medias count of current album */
537         int cnt = ad->maininfo.medias_cnt;
538         int view_mode = gl_get_view_mode(ad);
539         int i = 0;
540         Elm_Genlist_Item_Class *plic = NULL;
541
542         gl_dbg("view mode=%d", view_mode);
543         if (view_mode == GL_VIEW_VIDEOLIST_EDIT) {
544                 ad->listinfo.videolic.item_style = GL_GENLIST_ITEM_STYLE_VIDEO_EDIT;
545                 plic = &(ad->listinfo.videolic);
546         } else {
547                 ad->listinfo.videolic.item_style = GL_GENLIST_ITEM_STYLE_VIDEO;
548                 /* Sweep class */
549                 ad->listinfo.sweeplic.item_style = GL_GENLIST_ITEM_STYLE_VIDEO;
550                 ad->listinfo.sweeplic.decorate_item_style = GL_GENLIST_ITEM_STYLE_SWEEP3;
551                 ad->listinfo.sweeplic.func.text_get = __gl_list_get_text;
552                 ad->listinfo.sweeplic.func.content_get = __gl_list_get_content;
553                 plic = &(ad->listinfo.sweeplic);
554         }
555         ad->listinfo.videolic.func.text_get = __gl_list_get_text;
556         ad->listinfo.videolic.func.content_get = __gl_list_get_content;
557         ad->listinfo.videolic.func.del = __gl_list_del;
558
559         genlist = _gl_video_add_genlist(parent);
560
561         for (i = 1; i <= cnt; i++) {
562                 _gl_data_get_item_by_index(ad, i, false, &gitem);
563                 if (gitem == NULL || gitem->item == NULL ||
564                     gitem->item->uuid == NULL ) {
565                         gl_dbgE("Invalid gitem!");
566                         continue;
567                 }
568
569                 if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) {
570                         gl_dbg("%s inserted", gitem->item->file_url);
571                         gitem->elm_item = elm_genlist_item_append(genlist, plic,
572                                                                   (void *)gitem,
573                                                                    NULL,
574                                                                    ELM_GENLIST_ITEM_NONE,
575                                                                    _gl_list_sel,
576                                                                    gitem);
577                         item_cnt++;
578                         gitem->sequence = item_cnt;
579                 }
580
581         }
582
583         ad->listinfo.videos_cnt = item_cnt;
584         if (item_cnt > 0) {
585                 if (view_mode == GL_VIEW_VIDEOLIST)
586                         __gl_list_add_sweep_cbs(ad, genlist);
587
588                 evas_object_smart_callback_add(genlist, "selected",
589                                                __gl_list_genlist_sel, ad);
590                 ad->listinfo.videos_nocontents = NULL;
591                 return genlist;
592         }
593
594         /* There are none video files, show nocontents */
595         evas_object_del(genlist);
596         genlist = NULL;
597
598         Evas_Object *noc = _gl_nocontents_create(ad);
599         evas_object_show(noc);
600         ad->listinfo.videos_nocontents = noc;
601         return noc;
602 }
603
604 int gl_list_clear_view(void *data)
605 {
606         GL_CHECK_VAL(data, -1);
607         gl_appdata *ad = (gl_appdata *)data;
608          ad->listinfo.share_btn = NULL;
609          ad->listinfo.del_btn = NULL;
610
611         if (ad->listinfo.played_uuid) {
612                 free(ad->listinfo.played_uuid);
613                 ad->listinfo.played_uuid = NULL;
614         }
615
616         if (ad->listinfo.sweep_file_path) {
617                 free(ad->listinfo.sweep_file_path);
618                 ad->listinfo.sweep_file_path = NULL;
619         }
620
621         if (ad->listinfo.videos_view) {
622                 evas_object_del(ad->listinfo.videos_view);
623                 ad->listinfo.videos_view = NULL;
624                 ad->listinfo.videos_nocontents = NULL;
625         }
626
627         return 0;
628 }
629
630 /* Update normal list view */
631 int gl_list_update_view(void *data)
632 {
633         GL_CHECK_VAL(data, -1);
634         gl_appdata *ad = (gl_appdata *)data;
635
636         if (ad->listinfo.videos_view == NULL ||
637             ad->listinfo.videos_nocontents) {
638                 gl_dbgW("Remove list nocontents view!");
639                 if (ad->listinfo.videos_nocontents) {
640                         evas_object_hide(ad->listinfo.videos_nocontents);
641                         gl_list_clear_view(ad);
642                 }
643
644                 Evas_Object *list_view = NULL;
645                 list_view = gl_list_create_view(ad, ad->maininfo.naviframe);
646                 ad->listinfo.videos_view = list_view;
647
648                 /* Enable edit button if it's not nocontents view */
649                 if (ad->listinfo.videos_nocontents == NULL)
650                         _gl_ctrl_disable_toolbar_item(ad, false, GL_NAVI_THUMBS,
651                                                       false);
652
653                 elm_object_part_content_unset(ad->gridinfo.layout,
654                                               "elm.swallow.view");
655                 evas_object_show(ad->listinfo.videos_view);
656                 elm_object_part_content_set(ad->gridinfo.layout,
657                                             "elm.swallow.view",
658                                             ad->listinfo.videos_view);
659         } else {
660                 _gl_list_update_view(ad, ad->listinfo.videos_view, NULL);
661         }
662
663         return 0;
664 }
665
666 int gl_list_change_to_edit(void *data)
667 {
668         GL_CHECK_VAL(data, -1);
669         gl_appdata *ad = (gl_appdata *)data;
670         gl_dbg("");
671         gl_set_view_mode(ad, GL_VIEW_VIDEOLIST_EDIT);
672         _gl_list_update_view(ad, ad->gridinfo.edit_view, NULL);
673         return 0;
674 }
675
676 int gl_list_change_to_view(void *data)
677 {
678         GL_CHECK_VAL(data, -1);
679         gl_appdata *ad = (gl_appdata *)data;
680         gl_dbg("");
681
682         if (ad->uginfo.ug_called_by_me == NULL && ad->listinfo.videos_view == NULL)
683         {
684                 //special process when cancel edit after hide effect in _gl_ext_destroy_ug()
685                 ad->listinfo.videos_view = gl_list_create_view(ad, ad->maininfo.naviframe);
686                 evas_object_show(ad->listinfo.videos_view);
687                 elm_object_part_content_set(ad->gridinfo.layout,
688                                             "elm.swallow.view",
689                                             ad->listinfo.videos_view);
690         }
691         else
692         {
693                 gl_set_view_mode(ad, GL_VIEW_VIDEOLIST);
694                 _gl_list_update_view(ad, ad->listinfo.videos_view, NULL);
695         }
696
697         return 0;
698 }
699