2 * Copyright (c) 2012 Samsung Electronics Co., Ltd
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
8 * http://floralicense.org/license/
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.
18 #include "gl-thumbs.h"
19 #include "gl-ui-util.h"
22 #include "gl-albums.h"
24 #include "gl-ext-ug-load.h"
25 #include "gl-ext-exec.h"
26 #include "gl-controlbar.h"
27 #include "gl-nocontents.h"
28 #include "gl-notify.h"
29 #include "gl-strings.h"
36 /* Icon swallowed to part "elm.swallow.icon" */
37 #define GL_GRID_TOUCH_RANGE 20
38 typedef struct _gl_thumb_data_t gl_thumb_data_s;
40 struct _gl_thumb_data_t{
45 static void __gl_thumbs_open_file(void *data)
49 gl_item *gitem = (gl_item *)data;
50 GL_CHECK(gitem->item);
51 GL_CHECK(gitem->item->file_url);
52 GL_CHECK(strlen(gitem->item->file_url));
54 gl_appdata *ad = (gl_appdata *)gitem->ad;
55 int view_mode = gl_get_view_mode(ad);
56 if (view_mode != GL_VIEW_THUMBS) {
57 gl_dbgE("Error view mode!");
61 if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS) {
62 gl_dbg("Loading VIDEO-PLAYER");
63 gl_ext_exec(gitem, GL_APP_VIDEOPLAYER);
65 gl_dbg("Loading UG-IMAGE(VIDEO)-VIEWER");
66 gl_ext_load_iv_ug(ad, gitem, GL_UG_IV);
70 static void __gl_thumbs_sel_cb(void *data, Evas_Object *obj, void *event_info)
72 _gl_ui_save_scroller_pos(obj);
73 __gl_thumbs_open_file(data);
76 static void __gl_thumbs_longpressed(void *data, Evas_Object *obj,
80 void *it_data = elm_object_item_data_get(event_info);
83 if (gl_get_view_mode(data) == GL_VIEW_THUMBS)
84 __gl_thumbs_open_file(it_data);
87 static void __gl_thumbs_check_changed(void *data, Evas_Object *obj,
92 gl_item *gitem = (gl_item *) data;
94 gl_appdata *ad = (gl_appdata *)gitem->ad;
95 int view_mode = gl_get_view_mode(ad);
96 Evas_Object *view_ly = NULL;
97 Elm_Object_Item *nf_it = NULL;
100 if (view_mode == GL_VIEW_THUMBS_EDIT) {
101 view_ly = ad->gridinfo.navi_content_edit_ly;
102 nf_it = ad->gridinfo.nf_it_edit;
103 } else if (view_mode == GL_VIEW_THUMBS_SELECT) {
104 view_ly = ad->gridinfo.select_view_ly;
105 nf_it = ad->gridinfo.nf_it_select;
111 Eina_Bool checked = elm_check_state_get(obj);
112 gitem->checked = checked;
114 gl_dbg("Append:%s", gitem->item->file_url);
115 _gl_data_selected_list_append(ad, gitem);
117 gl_dbg("Remove:%s", gitem->item->file_url);
118 _gl_data_selected_list_remove(ad, gitem);
121 /* Display selectioninfo */
122 int sel_cnt = _gl_data_selected_list_count(ad);
123 _gl_notify_create_selinfo(ad, view_ly, nf_it, ad->gridinfo.thumbs_cnt,
127 /* Only for local medias */
128 static void __gl_thumbs_create_thumb_cb(media_content_error_e error,
129 const char *path, void *user_data)
132 gl_thumb_data_s *thumb_data = (gl_thumb_data_s *)user_data;
133 GL_CHECK(thumb_data->ad);
134 gl_appdata *ad = (gl_appdata *)thumb_data->ad;
135 gl_item *gitem = thumb_data->item;
138 if (gl_get_view_mode(ad) != GL_VIEW_THUMBS &&
139 gl_get_view_mode(ad) != GL_VIEW_THUMBS_EDIT)
143 GL_CHECK(gitem->item);
144 if (GL_FILE_EXISTS(path)) {
145 gl_dbg("Update item with new thumb path[%s]", path);
146 /* Update thumb path */
147 GL_FREEIF(gitem->item->thumb_url);
148 gitem->item->thumb_url = strdup(path);
149 elm_gengrid_item_update(gitem->elm_item);
151 gl_dbgE("Invalid thumb path!");
155 /* Use file to create new thumb if possible */
156 static int __gl_thumbs_create_thumb(gl_item *gitem)
158 GL_CHECK_VAL(gitem, -1);
159 GL_CHECK_VAL(gitem->item, -1);
160 GL_CHECK_VAL(gitem->item->file_url, -1);
162 if (GL_FILE_EXISTS(gitem->item->file_url)) {
163 gl_thumb_data_s *thumb_data = NULL;
164 thumb_data = (gl_thumb_data_s *)calloc(1, sizeof(gl_thumb_data_s));
165 GL_CHECK_VAL(thumb_data, -1);
166 thumb_data->ad = gitem->ad;
167 thumb_data->item = gitem;
168 _gl_data_create_thumb(gitem, __gl_thumbs_create_thumb_cb,
175 static Evas_Object *__gl_thumbs_get_content(void *data, Evas_Object *obj,
179 GL_CHECK_NULL(strlen(part));
181 gl_item *gitem = (gl_item *)data;
182 GL_CHECK_NULL(gitem->item);
183 GL_CHECK_NULL(gitem->ad);
184 gl_appdata *ad = (gl_appdata *)gitem->ad;
185 int view_mode = gl_get_view_mode(ad);
186 int item_size = ad->gridinfo.icon_size;
187 bool is_expired_drm = false;
189 if (!g_strcmp0(part, GL_THUMB_ICON)) {
190 Evas_Object *layout = NULL;
192 char *drm_path = NULL;
193 unsigned int orient = 0;
195 /* Is it DRM file? Has a valid RO? */
196 if(_gl_get_icon_type(gitem) == GL_ICON_EXPIRED_DRM) {
197 path = GL_DEFAULT_THUMB_ICON;
198 is_expired_drm = true;
199 /* Only one photo in a (normal, not web) album */
200 } else if (ad->maininfo.medias_cnt < 2 &&
201 gitem->item->type == MEDIA_CONTENT_TYPE_IMAGE) {
202 if (!g_strcmp0(GL_DB_DEFAULT_THUMB, gitem->item->thumb_url)) {
203 path = GL_DEFAULT_THUMB_ICON;
205 drm_path = gl_drm_get_file_path(gitem);
206 path = _GET_ICON(drm_path);
207 if (gl_is_image_valid(ad, path) == false)
208 path = _GET_ICON(gitem->item->thumb_url);
209 #ifdef _USE_ROTATE_BG
210 /* Rotate bg if it's created from original file */
211 if (!g_strcmp0(path, gitem->item->file_url))
212 _gl_exif_get_orientation(path, &orient);
216 /* Use default image */
217 if (GL_FILE_EXISTS(gitem->item->thumb_url)) {
218 path = gitem->item->thumb_url;
220 path = GL_DEFAULT_THUMB_ICON;
221 __gl_thumbs_create_thumb(gitem);
225 if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) {
226 unsigned int v_dur = 0;
227 if (gitem->item->video_info) {
228 v_dur = gitem->item->video_info->duration;
231 if (gitem->item->video_info == NULL)
234 bk_len = gitem->item->video_info->bookmarks;
235 layout = _gl_thumb_show_part_icon_video(obj, path,
237 gitem->item->favorite,
241 layout = _gl_thumb_show_part_icon_image(obj, path,
243 gitem->item->favorite,
250 } else if (!g_strcmp0(part, GL_THUMB_CHECKBOX) &&
251 (view_mode == GL_VIEW_THUMBS_EDIT ||
252 view_mode == GL_VIEW_THUMBS_SELECT)) {
253 Evas_Object *ck = NULL;
254 ck = _gl_thumb_show_part_checkbox(obj, gitem->checked,
255 __gl_thumbs_check_changed,
259 gitem->check_obj = ck;
266 static int __gl_thumbs_set_type(void *data)
268 GL_CHECK_VAL(data, -1);
269 gl_appdata *ad = (gl_appdata *)data;
271 ad->gridinfo.grid_type = GL_GRID_T_NONE;;
272 if (ad->ctrlinfo.tab_mode == GL_CTRL_TAB_TAGS) {
273 ad->gridinfo.grid_type = GL_GRID_T_TAGS;
275 gl_cluster *cur_album = ad->albuminfo.current_album;
276 GL_CHECK_VAL(cur_album, -1);
277 GL_CHECK_VAL(cur_album->cluster, -1);
279 if (cur_album->cluster->type == GL_STORE_T_PHONE ||
280 cur_album->cluster->type == GL_STORE_T_MMC)
281 ad->gridinfo.grid_type = GL_GRID_T_LOCAL;
282 else if (cur_album->cluster->type == GL_STORE_T_ALL)
283 ad->gridinfo.grid_type = GL_GRID_T_ALLALBUMS;
285 gl_dbgE("Wrong cluster storage type!");
287 gl_dbg("Gridview type: %d", ad->gridinfo.grid_type);
291 static bool __gl_thumbs_create_items(void *data, Evas_Object *parent)
293 GL_CHECK_FALSE(data);
294 GL_CHECK_FALSE(parent);
295 gl_appdata *ad = (gl_appdata *)data;
298 gl_item *gitem = NULL;
300 /* Get all medias count of current album */
301 int cnt = ad->maininfo.medias_cnt;
302 gl_dbg("List count : %d gv_mode : %d", cnt, ad->gridinfo.view_mode);
304 ad->gridinfo.thumbgic.item_style = GL_GENGRID_ITEM_STYLE_THUMBNAIL;
305 ad->gridinfo.thumbgic.func.text_get = NULL;
306 ad->gridinfo.thumbgic.func.content_get = __gl_thumbs_get_content;
308 if (elm_gengrid_items_count(parent) > 0) {
309 /* Save scroller position before clearing gengrid */
310 _gl_ui_save_scroller_pos(parent);
311 elm_gengrid_clear(parent);
314 for (i = 1; i <= cnt; i++) {
315 _gl_data_get_item_by_index(ad, i, false, &gitem);
316 if (gitem == NULL || gitem->item == NULL ||
317 gitem->item->uuid == NULL) {
318 gl_dbgE("Invalid gitem. continue...");
322 /* For PTP Album, file_url is NULL untill the file is saved from camera */
323 if (!gitem->item->file_url) {
324 gl_dbg("file_url is invalid.");
325 ret = _gl_data_delete_media(ad, gitem->item);
328 _gl_data_selected_list_remove(ad, gitem);
329 _gl_data_item_list_remove(ad, gitem);
336 if (ad->gridinfo.back_to_normal) {
337 gitem->checked = false;
338 //gitem->check_obj = NULL;
341 if (ad->gridinfo.view_mode == GL_THUMB_IMAGES &&
342 gitem->item->type != MEDIA_CONTENT_TYPE_IMAGE)
344 if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS &&
345 gitem->item->type != MEDIA_CONTENT_TYPE_VIDEO)
347 gitem->elm_item = elm_gengrid_item_append(parent,
348 &(ad->gridinfo.thumbgic),
353 gitem->sequence = item_cnt;
357 _gl_ui_restore_scroller_pos(parent);
358 ad->gridinfo.thumbs_cnt = item_cnt;
359 ad->gridinfo.back_to_normal = false;
368 * Set new view to all/image_grid_view.
370 * b_noc, true: it's nocontents view, false: normal view.
372 static int __gl_thumbs_set_view(void *data, Evas_Object *view, bool b_noc)
374 GL_CHECK_VAL(data, -1);
375 gl_appdata *ad = (gl_appdata *)data;
376 ad->gridinfo.all_grid_view = view;
378 _gl_thumbs_set_nocontents(ad, view);
380 _gl_thumbs_set_nocontents(ad, NULL);
386 * When select album, show first (GL_FIRST_VIEW_END_POS+1) medias.
387 * Then use idler to get other medias from DB and appened
389 * In order to reduce transit time of first show of thumbnails view.
390 * Cause most of time is spent for getting records from DB,
391 * so we get first (GL_FIRST_VIEW_END_POS+1) items and show thumbnails view,
392 * it will accelerate view show.
394 static int __gl_thumbs_idler_append_items(void *data)
396 GL_CHECK_VAL(data, -1);
397 gl_appdata *ad = (gl_appdata *)data;
398 GL_CHECK_VAL(ad->albuminfo.current_album, -1);
399 GL_CHECK_VAL(ad->gridinfo.all_grid_view, -1);
402 gl_item *gitem = NULL;
403 /* Get all medias count of current album */
404 int cnt = ad->maininfo.medias_cnt;
407 gl_dbg("First view medias count: %d; girdview mode: %d",
408 cnt, ad->gridinfo.view_mode);
409 if (ad->maininfo.medias_cnt != (GL_FIRST_VIEW_END_POS + 1)) {
410 gl_dbg("No any more items, return!");
413 /* Get other items from DB */
414 ret = _gl_data_get_item_list(ad, GL_CATEGORY_FOLDER,
415 ad->albuminfo.current_album,
416 (GL_FIRST_VIEW_END_POS + 1),
417 GL_GET_UNTIL_LAST_RECORD);
419 gl_dbgE("Get items list failed[%d]!", ret);
423 cnt = ad->maininfo.medias_cnt;
424 gl_dbg("Grid view all medias count: %d", cnt);
426 if (ad->gridinfo.view_mode != GL_THUMB_ALL) {
427 /* Event gridview mode is wrong, we still need to get other records */
428 gl_dbg("Gridview mode is wrong, return!");
432 /* From (GL_FIRST_VIEW_END_POS + 2)th item to last one */
433 i = GL_FIRST_VIEW_END_POS + 2;
435 for (; i <= cnt; i++) {
436 _gl_data_get_item_by_index(ad, i, false, &gitem);
437 if (gitem == NULL || gitem->item == NULL ||
438 gitem->item->uuid == NULL ) {
439 gl_dbgE("Invalid gitem, continue...");
443 if (!gitem->item->file_url) {
444 gl_dbg("file_url is invalid.");
445 _gl_data_delete_media(ad, gitem->item);
446 _gl_data_selected_list_remove(ad, gitem);
447 _gl_data_item_list_remove(ad, gitem);
454 if (ad->gridinfo.view_mode == GL_THUMB_IMAGES &&
455 gitem->item->type != MEDIA_CONTENT_TYPE_IMAGE)
457 if (ad->gridinfo.view_mode == GL_THUMB_VIDEOS &&
458 gitem->item->type != MEDIA_CONTENT_TYPE_VIDEO)
460 gitem->elm_item = elm_gengrid_item_append(ad->gridinfo.all_grid_view,
461 &(ad->gridinfo.thumbgic),
466 gitem->sequence = item_cnt + GL_FIRST_VIEW_END_POS + 1;
469 gl_dbgW("\tUse idler to append other medias--Done!");
473 ad->gridinfo.thumbs_cnt = item_cnt + GL_FIRST_VIEW_END_POS + 1;
474 gl_dbg("All count appended: %d", ad->gridinfo.thumbs_cnt);
479 static Eina_Bool __gl_thumbs_append_items_idler_cb(void *data)
481 GL_CHECK_CANCEL(data);
483 /* Try to get other medias from DB and append them to gridview */
484 if (__gl_thumbs_idler_append_items(data) < 0) {
485 gl_dbgE("Failed to append grid items!");
487 gl_dbg("Successful to append grid items!");
490 /* Remove idler after all items appended */
491 _gl_thumbs_del_append_idler(data);
493 return ECORE_CALLBACK_CANCEL;
496 void _gl_thumbs_mouse_down(void *data, Evas *e, Evas_Object *obj,
500 GL_CHECK(event_info);
502 gl_item *gitem = (gl_item *) data;
504 gl_appdata *ad = (gl_appdata *)gitem->ad;
505 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
507 ad->gridinfo.grid_touch_info.x = ev->output.x;
508 ad->gridinfo.grid_touch_info.y = ev->output.y;
511 void _gl_thumbs_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
514 gl_item *gitem = (gl_item *) data;
516 gl_appdata *ad = (gl_appdata *)gitem->ad;
518 if (!event_info || !obj)
521 Evas_Event_Mouse_Up *ev = event_info;
522 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD ||
523 ev->event_flags & EVAS_EVENT_FLAG_ON_SCROLL)
526 if ((abs(ad->gridinfo.grid_touch_info.x - ev->output.x) > GL_GRID_TOUCH_RANGE) ||
527 (abs(ad->gridinfo.grid_touch_info.y - ev->output.y) > GL_GRID_TOUCH_RANGE))
531 __gl_thumbs_open_file(data);
538 Evas_Object *_gl_thumbs_add_grid(void *data, Evas_Object *parent,
539 gl_thumb_mode mode, bool b_use_idler)
541 GL_CHECK_NULL(parent);
543 gl_appdata *ad = (gl_appdata *)data;
544 Evas_Object *grid = NULL;
545 ad->gridinfo.view_mode = mode;
546 grid = _gl_thumb_add_gengrid(parent);
547 evas_object_smart_callback_add(grid, "realized", NULL, data);
548 evas_object_smart_callback_add(grid, "unrealized", NULL, data);
549 evas_object_smart_callback_add(grid, "longpressed",
550 __gl_thumbs_longpressed, data);
552 /* Set grid view type */
553 __gl_thumbs_set_type(ad);
554 _gl_ui_reset_scroller_pos(grid);
556 int view_mode = gl_get_view_mode(ad);
558 if (!__gl_thumbs_create_items(ad, grid)) {
559 _gl_ui_del_scroller_pos(grid);
560 evas_object_del(grid);
562 Evas_Object *noc = _gl_nocontents_create(ad);
563 _gl_thumbs_set_nocontents(ad, noc);
564 evas_object_show(noc);
568 gl_dbg("thumbs_cnt : %d", ad->gridinfo.thumbs_cnt);
569 _gl_thumbs_set_size(ad, grid);
570 if (view_mode != GL_VIEW_THUMBS_SELECT)
571 _gl_thumbs_set_nocontents(ad, NULL);
572 evas_object_show(grid);
575 ad->maininfo.medias_cnt == (GL_FIRST_VIEW_END_POS + 1)) {
576 gl_dbgW("\tUse idler to append other medias--Start");
578 _gl_thumbs_del_append_idler(ad);
580 ad->gridinfo.grid_append_idler = ecore_idler_add(__gl_thumbs_append_items_idler_cb,
587 int _gl_thumbs_show_edit_view(void *data)
589 GL_CHECK_VAL(data, -1);
590 gl_appdata *ad = (gl_appdata *)data;
591 int view_mode = gl_get_view_mode(ad);
593 Evas_Object *view = NULL;
594 gl_dbg("view_mode: %d", view_mode);
596 if (view_mode == GL_VIEW_THUMBS_EDIT) {
597 view = ad->gridinfo.navi_content_edit_view;
598 } else if (view_mode == GL_VIEW_THUMBS_SELECT) {
599 view = ad->gridinfo.select_view;
601 gl_dbgE("Wrong view mode!");
604 GL_CHECK_VAL(view, -1);
605 b_ret = __gl_thumbs_create_items(ad, view);
606 _gl_thumbs_set_size(ad, NULL);
609 gl_dbgE("Create items failed!");
616 int _gl_thumbs_show_view(void *data)
618 GL_CHECK_VAL(data, -1);
619 gl_appdata *ad = (gl_appdata *)data;
620 int gridview_mode = ad->gridinfo.view_mode;
622 gl_dbg("gridview_mode: %d", gridview_mode);
624 if (ad->gridinfo.all_grid_view == NULL) {
625 gl_dbg("Error : Any gridview doesn't exist");
629 /* Come back from edit mode, save state */
630 ad->gridinfo.back_to_normal = true;
631 b_ret = __gl_thumbs_create_items(ad,
632 ad->gridinfo.all_grid_view);
633 _gl_thumbs_set_size(ad, NULL);
636 gl_dbgE("Create items failed!");
643 Eina_Bool _gl_thumbs_update_view(void *data)
645 GL_CHECK_FALSE(data);
646 gl_appdata *ad = (gl_appdata *)data;
647 Eina_Bool res = EINA_FALSE;
648 Evas_Object *gv = NULL;
649 int view_mode = gl_get_view_mode(ad);
653 if (view_mode == GL_VIEW_THUMBS_EDIT) {
654 gl_dbg("\n\nEdit_Mode\n");
655 gv = ad->gridinfo.navi_content_edit_view;
657 b_view = _gl_thumbs_get_view(ad, &gv);
661 res = __gl_thumbs_create_items(ad, gv);
663 gl_dbg("__gl_thumbs_create_items() return false...");
664 evas_object_hide(gv);
665 _gl_ui_del_scroller_pos(gv);
667 __gl_thumbs_set_view(ad, NULL, false);
668 Evas_Object *noc = _gl_nocontents_create(ad);
669 evas_object_show(noc);
670 __gl_thumbs_set_view(ad, noc, true);
672 elm_object_part_content_unset(ad->gridinfo.navi_content_ly,
674 elm_object_part_content_set(ad->gridinfo.navi_content_ly,
675 "elm.swallow.view", noc);
677 _gl_thumbs_set_size(ad, gv);
680 gl_dbg("Remove nocontents view.");
681 evas_object_hide(gv);
682 _gl_ui_del_scroller_pos(gv);
684 __gl_thumbs_set_view(ad, NULL, false);
686 int view_m = ad->gridinfo.view_mode;
688 Evas_Object *view = NULL;
689 view = _gl_thumbs_add_grid(ad, ad->gridinfo.navi_content_ly,
691 if (ad->gridinfo.all_grid_nocontents)
694 /* No nocotents removed, gridview created, enable edit button */
696 /* When nocontents removed from webalbum,
697 * it means this empty album was just refreshed
698 * to download photo from web, progressbr showed.
700 _gl_ctrl_disable_btn(ad, false, GL_NAVI_THUMBS);
702 __gl_thumbs_set_view(ad, view, b_noc);
704 elm_object_part_content_unset(ad->gridinfo.navi_content_ly,
706 elm_object_part_content_set(ad->gridinfo.navi_content_ly,
707 "elm.swallow.view", view);
713 int _gl_thumbs_create_view(void *data, int nf_mode, char *title, bool b_idler,
716 GL_CHECK_VAL(data, -1);
717 gl_appdata *ad = (gl_appdata *)data;
718 GL_CHECK_VAL(ad->maininfo.naviframe, -1);
719 Evas_Object *layout = NULL;
720 Evas_Object *view = NULL;
722 gl_set_view_mode(data, GL_VIEW_THUMBS);
723 layout = gl_ctrl_create_ctrlbar_view(ad->maininfo.naviframe);
724 GL_CHECK_VAL(layout, -1);
725 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
727 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
728 view = _gl_thumbs_add_grid(ad, layout, GL_THUMB_ALL, b_idler);
730 evas_object_del(layout);
731 gl_dbgE("Failed to add gridview!");
735 elm_object_part_content_set(layout, "elm.swallow.view", view);
736 ad->gridinfo.all_grid_view = view;
737 ad->gridinfo.navi_content_ly = layout;
739 gl_ui_create_title_and_push(ad, ad->maininfo.naviframe, layout, nf_mode,
742 Evas_Object *bk_btn = NULL;
743 bk_btn = elm_object_item_part_content_get(ad->gridinfo.nf_it,
744 GL_NAVIFRAME_PREV_BTN);
745 elm_object_style_set(bk_btn, GL_BUTTON_STYLE_NAVI_PRE);
746 evas_object_smart_callback_add(bk_btn, "clicked", func, ad);
748 edje_object_signal_emit(_EDJ(layout), GL_SIGNAL_VIEW_DEFAULT, "elm");
753 int _gl_thumbs_update_count(void *data, int new_cnt)
755 GL_CHECK_VAL(data, -1);
756 gl_appdata *ad = (gl_appdata *)data;
758 gl_dbg("gridview display item count=%d", new_cnt);
759 ad->gridinfo.updated_thumbs_cnt = new_cnt;
765 * Get all/image_grid_view.
767 * True returned if it's normal view, if it's nocontents view return false.
769 bool _gl_thumbs_get_view(void *data, Evas_Object **view)
771 GL_CHECK_FALSE(data);
772 gl_appdata *ad = (gl_appdata *)data;
773 Evas_Object *gv = NULL;
776 gv = ad->gridinfo.all_grid_view;
777 if (gv && ad->gridinfo.all_grid_nocontents == NULL)
782 gl_dbg("Previous view is Nocontents...");
791 /* Assign new value to all/image_grid_nocontents */
792 int _gl_thumbs_set_nocontents(void *data, Evas_Object *noc)
794 GL_CHECK_VAL(data, -1);
795 gl_appdata *ad = (gl_appdata *)data;
797 ad->gridinfo.all_grid_nocontents = noc;
802 int _gl_thumbs_set_size(void *data, Evas_Object *gridview)
804 GL_CHECK_VAL(data, -1);
805 gl_appdata *ad = (gl_appdata *)data;
807 Evas_Object *gv = NULL;
808 int view_mode = gl_get_view_mode(ad);
814 if (view_mode == GL_VIEW_THUMBS_EDIT) {
816 gv = ad->gridinfo.navi_content_edit_view;
817 } else if (view_mode == GL_VIEW_THUMBS_SELECT) {
819 gv = ad->gridinfo.select_view;
821 b_view = _gl_thumbs_get_view(ad, &gv);
824 if (!b_view || !gv) {
825 gl_dbgE("gridview is invalid!");
830 if (ad->gridinfo.updated_thumbs_cnt <= 0) {
831 cnt = ad->gridinfo.thumbs_cnt;
833 cnt = ad->gridinfo.updated_thumbs_cnt;
834 ad->gridinfo.updated_thumbs_cnt = 0;
837 return _gl_thumb_set_size(ad, gv, cnt, &(ad->gridinfo.icon_size));
840 int _gl_thumbs_clear_cbs(Evas_Object *grid)
842 GL_CHECK_VAL(grid, -1);
843 evas_object_smart_callback_del(grid, "longpressed",
844 __gl_thumbs_longpressed);
848 int _gl_thumbs_delete_view(void *data)
850 GL_CHECK_VAL(data, -1);
851 gl_appdata *ad = (gl_appdata *)data;
854 _gl_thumbs_del_append_idler(data);
856 if (ad->gridinfo.all_grid_view != NULL) {
857 _gl_ui_del_scroller_pos(ad->gridinfo.all_grid_view);
858 _gl_thumbs_clear_cbs(ad->gridinfo.all_grid_view);
859 evas_object_del(ad->gridinfo.all_grid_view);
860 ad->gridinfo.all_grid_view = NULL;
862 ad->gridinfo.grid_type = GL_GRID_T_NONE;
863 ad->gridinfo.all_grid_nocontents = NULL;
864 ad->gridinfo.edit_btn = NULL;
868 /* Update griditem size */
869 int _gl_thumbs_update_size(void *data, Evas_Object *view)
871 GL_CHECK_VAL(data, -1);
872 gl_appdata *ad = (gl_appdata *)data;
873 Evas_Object *_view = NULL;
874 int view_mode = gl_get_view_mode(ad);
877 if (ad->gridinfo.thumbs_cnt <= GL_GRID_ITEM_ZOOM_LEVEL_02_CNT) {
878 gl_dbgW("Thumbs count is less than 7!");
886 if (view_mode == GL_VIEW_THUMBS_EDIT) {
888 _view = ad->gridinfo.navi_content_edit_view;
889 } else if (view_mode == GL_VIEW_THUMBS_SELECT) {
891 _view = ad->gridinfo.select_view;
893 b_view = _gl_thumbs_get_view(ad, &_view);
896 if (!b_view || !_view) {
897 gl_dbgE("gridview is invalid!");
902 _gl_thumbs_set_size(data, _view);
904 _gl_thumb_update_gengrid(_view);
909 int _gl_thumbs_del_append_idler(void *data)
911 GL_CHECK_VAL(data, -1);
912 gl_appdata *ad = (gl_appdata *)data;
914 if (ad->gridinfo.grid_append_idler) {
915 ecore_idler_del(ad->gridinfo.grid_append_idler);
916 ad->gridinfo.grid_append_idler = NULL;