2 * Copyright 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://www.tizenopensource.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 <vconf-keys.h>
22 #include "gl-ui-util.h"
24 #include "gl-ext-ug-load.h"
25 #include "gl-ext-exec.h"
26 #include "gl-button.h"
27 #include "gl-gridview.h"
28 #include "gl-controlbar.h"
29 #include "gl-albums.h"
30 #include "gl-listview.h"
32 #include "gl-db-handler.h"
33 #include "gl-thread-util.h"
35 #include "gl-progressbar.h"
36 #include "gl-strings.h"
38 #define GL_CBAR_OCCUPIED_SEGMENT 4
40 #define GL_EDITFIELD_STYLE_DEFAULT GL_CHECKBOX_STYLE_DEFAULT
41 #define GL_ENTRY_STYLE_DEFAULT GL_CHECKBOX_STYLE_DEFAULT
42 #define GL_NAVIBAR_STYLE_DEFAULT GL_CHECKBOX_STYLE_DEFAULT
43 #define GL_TRANS_FINISHED "transition,finished"
45 static void _gl_ui_newalbum_cancel_cb(void *data, Evas_Object * obj,
47 void __gl_ui_entry_space_check_cb(void *data, Evas_Object *obj, void *event_info);
48 void __gl_ui_entry_maxlen_reached_cb(void *data, Evas_Object *obj, void *event_info);
49 static void __gl_editfield_focused_cb(void *data, Evas_Object *obj, void *event_info);
50 static void __gl_editfield_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
51 static void __gl_editfield_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
54 _gl_ui_create_editfield(void *data, Evas_Object * parent, char *default_label)
57 gl_appdata *ad = (gl_appdata *)data;
59 Evas_Object *editfield_ly = NULL;
60 Evas_Object *lay = NULL;
61 Evas_Object *entry = NULL;
62 static Elm_Entry_Filter_Limit_Size limit_filter_data;
64 lay = elm_layout_add(parent);
66 evas_object_size_hint_weight_set(lay, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 elm_layout_file_set(lay, GL_EDJ_FILE, GL_GRP_ENTRY);
69 /* Single line with no title */
70 editfield_ly = elm_layout_add(lay);
71 if (editfield_ly == NULL) {
72 gl_dbgE("elm_editfield_add failed!");
76 elm_layout_theme_set(editfield_ly, "layout", "editfield", "gallery");
77 evas_object_size_hint_weight_set(editfield_ly, 1, 1);
78 evas_object_size_hint_align_set(editfield_ly, 1, 0.5);
79 /* Set editfield layout to view layout */
80 elm_object_part_content_set(lay, "entry_part", editfield_ly);
82 entry = elm_entry_add(editfield_ly);
84 gl_dbgE("elm_entry_add failed!");
88 elm_object_style_set(entry, GL_ENTRY_STYLE_DEFAULT);
89 elm_entry_scrollable_set(entry, EINA_TRUE);
90 elm_entry_single_line_set(entry, EINA_TRUE);
91 /* Set entry to editfield layout */
92 elm_object_part_content_set(editfield_ly, "elm.swallow.content", entry);
94 /* Album name, the length is limited to 255 Chars*/
95 limit_filter_data.max_char_count = GL_ENTRY_STR_CHAR_MAX;
96 limit_filter_data.max_byte_count = 0;
97 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size,
100 if (gl_set_entry_text(entry, default_label) != 0) {
101 gl_dbgE("gl_set_entry_text failed!");
102 evas_object_del(lay);
106 ad->entryinfo.imf_entry = entry;
107 ad->entryinfo.imf_context = elm_entry_imf_context_get(ad->entryinfo.imf_entry);
109 gl_dbg("view mode=%d", gl_get_view_mode(ad));
110 evas_object_smart_callback_add(entry, "maxlength,reached",
111 __gl_ui_entry_maxlen_reached_cb, ad);
113 /* Add space check callback */
114 evas_object_smart_callback_add(entry, "changed",
115 __gl_ui_entry_space_check_cb,
117 evas_object_smart_callback_add(entry, "focused",
118 __gl_editfield_focused_cb, editfield_ly);
119 evas_object_smart_callback_add(entry, "unfocused",
120 __gl_editfield_unfocused_cb,
122 elm_object_signal_callback_add(editfield_ly, "elm,eraser,clicked", "elm",
123 __gl_editfield_eraser_clicked_cb, entry);
125 ad->entryinfo.editfield = editfield_ly;
131 _gl_ui_selinfo_destroy_cb(void *data, Evas_Object * obj, void *event_info)
134 gl_appdata *ad = (gl_appdata *)data;
135 int view_mode = gl_get_view_mode(ad);
137 gl_ui_destroy_selinfo(ad);
139 if (view_mode == GL_VIEW_ALBUMS_EDIT)
141 edje_object_signal_emit(_EDJ(ad->albuminfo.edit_layout),
142 "elm,swallow_view,state,default", "elm");
143 } else if (view_mode == GL_VIEW_THUMBS_EDIT ||
144 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
145 edje_object_signal_emit(_EDJ(ad->gridinfo.edit_layout),
146 "elm,swallow_view,state,thumb_edit_default",
149 gl_dbgE("Wrong view mode!");
153 /* Hide input panel and entry cursor */
154 static int _gl_ui_hide_imf_input_panel(void *data)
156 GL_CHECK_VAL(data, -1);
157 gl_appdata* ad = (gl_appdata*)data;
159 if (ad->entryinfo.imf_context)
160 ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context);
161 /* Unfocus to hide cursor */
162 elm_object_focus_set(ad->entryinfo.imf_entry, FALSE);
168 * Check album name is valid and remove unuseful characters
169 * 1) not only includes space;
170 * 2) contains invalid character;
174 * true: add a new album ; false: rename a album.
176 * true: Enter key pressed ; false: Button Done clicked.
179 static int _gl_ui_get_valid_album_name(void *data, char* album_name,
180 bool b_new, bool b_enter)
182 GL_CHECK_VAL(album_name, -1);
183 GL_CHECK_VAL(data, -1);
184 gl_appdata* ad = (gl_appdata*)data;
186 gl_dbg("Input album name: %s", album_name);
188 popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, sizeof(char));
189 if (popup_desc == NULL) {
190 gl_dbg("memory allocation fail");
193 /* Check album name length */
194 if (strlen(album_name) == 0) {
195 gl_dbgW("Inserted text is empty!");
197 gl_dbg("Enter key pressed.");
198 goto INVALID_ALBUM_NAME;
203 mode = GL_POPUP_ALBUM_NEW_EMPTY;
205 mode = GL_POPUP_ALBUM_RENAME_EMPTY;
206 snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.<br>%s",
207 GL_STR_ENTRY_IS_EMPTY, GL_STR_RETRY_Q);
208 popup_desc[strlen(popup_desc)] = '\0';
209 gl_popup_create_popup(ad, mode, popup_desc);
210 goto INVALID_ALBUM_NAME;
212 gl_dbg("Inserted album name: %s, length: %d", album_name, strlen(album_name));
214 /* Removes leading and trailing whitespace */
215 g_strstrip((gchar*)album_name);
216 if (strlen(album_name) == 0) {
217 gl_dbgW("Album name includes only space!");
219 gl_dbg("Enter key pressed.");
220 goto INVALID_ALBUM_NAME;
224 mode = GL_POPUP_ALBUM_NEW_EMPTY;
226 mode = GL_POPUP_ALBUM_RENAME_EMPTY;
227 snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.<br>%s",
228 GL_STR_INVALID_INPUT_PARAMETER, GL_STR_RETRY_Q);
229 popup_desc[strlen(popup_desc)] = '\0';
230 gl_popup_create_popup(ad, mode, popup_desc);
231 goto INVALID_ALBUM_NAME;
234 /* Check if there is any invalid character in string */
235 if (gl_validate_album_name(album_name) == false) {
236 gl_dbgW("Album name includes invalid character!");
238 mode = GL_POPUP_ALBUM_NEW_INVALID;
240 mode = GL_POPUP_ALBUM_RENAME_INVALID;
241 snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.<br>%s",
242 GL_STR_INVALID_INPUT_PARAMETER, GL_STR_RETRY_Q);
243 popup_desc[strlen(popup_desc)] = '\0';
244 gl_popup_create_popup(ad, mode, popup_desc);
245 goto INVALID_ALBUM_NAME;
259 * True: Enter key on Keyboard pressed, False: Button Done clicked
261 static int _gl_ui_newalbum_done(void *data, bool b_enter)
263 gl_dbg("b_enter: %d", b_enter);
264 GL_CHECK_VAL(data, -1);
265 gl_appdata *ad = (gl_appdata *)data;
267 if (ad->entryinfo.imf_entry == NULL) {
268 gl_dbgE("Entry is NULL");
269 goto NEW_ALBUM_FAILED;
272 if (ad->entryinfo.imf_context)
273 ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context);
275 Evas_Object *entry = ad->entryinfo.imf_entry;
276 char album_name[GL_ALBUM_NAME_LEN_MAX] = { 0, };
278 /* Get utf8 format string */
279 if (gl_get_entry_text(entry, album_name, GL_ALBUM_NAME_LEN_MAX) != 0) {
280 gl_dbgE("Get entry text failed!");
281 goto NEW_ALBUM_FAILED;
285 if (_gl_ui_get_valid_album_name(ad, album_name, true, b_enter) != 0) {
287 _gl_ui_hide_imf_input_panel(ad);
290 gl_dbg("Valid album name: %s", album_name);
292 /* Check whether the new folder exist */
293 char path[GL_DIR_PATH_LEN_MAX] = { 0, };
294 char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, };
296 /* Get default images path, make new album under it */
297 if (gl_get_default_images_path(dir_path) != 0) {
298 gl_dbgE("Failed to get default image dir path!");
299 goto NEW_ALBUM_FAILED;
302 /* Make dir full path of new album */
303 snprintf(path, GL_DIR_PATH_LEN_MAX, "%s/%s", dir_path, album_name);
304 path[strlen(path)] = '\0';
305 gl_dbg("New dir path: %s", path);
307 int res = ecore_file_dir_is_empty(path);
308 gl_dbg("ecore_file_dir_is_empty return value: %d", res);
310 * If dir is empty, 1 is returned,
311 * if it contains at least 1 file, 0 is returned.
312 * On failure, -1 is returned.
316 popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, sizeof(char));
317 if (popup_desc == NULL) {
318 gl_dbg("memory allocation fail");
322 snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.<br>%s",
323 GL_STR_SAME_NAME_ALREADY_IN_USE, GL_STR_RETRY_Q);
324 popup_desc[strlen(popup_desc)] = '\0';
325 gl_popup_create_popup(ad, GL_POPUP_ALBUM_NEW_DUPLICATE,
328 gl_dbgW("New folder already exists and not NULL, return!");
332 /* Save new album name */
333 char* new_album = ad->albuminfo.new_album_name;
334 g_strlcpy(new_album, album_name, GL_ALBUM_NAME_LEN_MAX);
335 new_album[GL_ALBUM_NAME_LEN_MAX - 1] = '\0';
336 gl_ui_destroy_imf(ad);
337 /* Move files to dest album */
338 gl_move_to_album(ad);
342 _gl_ui_newalbum_cancel_cb(ad, NULL, NULL);
346 static void _gl_ui_newalbum_enter_cb(void *data, Evas_Object * obj, void *event_info)
350 gl_appdata *ad = (gl_appdata *)data;
351 /* Unfocus to hide cursor */
352 elm_object_focus_set(ad->entryinfo.imf_entry, FALSE);
354 _gl_ui_newalbum_done(data, true);
357 static void _gl_ui_newalbum_done_cb(void *data, Evas_Object * obj, void *event_info)
360 _gl_ui_newalbum_done(data, false);
364 _gl_ui_newalbum_cancel_cb(void *data, Evas_Object * obj, void *event_info)
367 gl_appdata *ad = (gl_appdata *)data;
370 elm_naviframe_item_pop(ad->maininfo.navi_bar);
371 gl_ui_destroy_imf(ad);
372 gl_ui_update_select_widgets(ad);
375 static void __gl_ui_rename_album_cancel_cb(void *data, Evas_Object * obj, void *event_info)
378 gl_appdata *ad = (gl_appdata *)data;
379 GL_CHECK(ad->maininfo.navi_bar);
382 ad->albuminfo.selected_album = NULL;
383 gl_set_view_mode(ad, GL_VIEW_ALBUMS_EDIT);
384 /* manually popup view after rename album */
385 elm_naviframe_item_pop(ad->maininfo.navi_bar);
386 /* Recover the previous UI */
387 gl_ui_destroy_imf(ad);
388 /* Update edit view */
389 gl_albums_update_items(ad);
395 * True: Enter key on Keyboard pressed, False: Button Done clicked
397 static int __gl_ui_rename_album_done(void *data, bool b_enter)
399 gl_dbg("b_enter: %d", b_enter);
400 GL_CHECK_VAL(data, -1);
401 gl_appdata *ad = (gl_appdata *)data;
402 bool b_root_path = false;
403 gl_cluster *album_item = NULL;
405 if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS_RENAME) {
406 gl_dbgE("View mode is wrong!");
410 album_item = ad->albuminfo.selected_album;
411 if (album_item == NULL || album_item->cluster == NULL ||
412 album_item->cluster->uuid == NULL) {
413 gl_dbgE("selected_album is NULL!");
417 char etxt[GL_FILE_NAME_LEN_MAX] = { 0, };
418 /* Get utf8 format string */
420 ret = gl_get_entry_text(ad->entryinfo.imf_entry, etxt,
421 GL_FILE_NAME_LEN_MAX);
423 gl_dbgE("Get entry text failed!");
428 if (_gl_ui_get_valid_album_name(ad, etxt, false, b_enter) != 0) {
430 _gl_ui_hide_imf_input_panel(ad);
434 gl_dbg("Valid album name: %s", etxt);
435 /* Get src folder path */
436 char dir_path[GL_DIR_PATH_LEN_MAX] = { 0, };
437 ret = gl_db_get_folder_fullpath(ad, album_item->cluster->uuid, dir_path);
439 gl_dbgE("gl_db_get_folder_fullpath failed(%d)!", ret);
442 gl_dbg("Src folder: %s", dir_path);
443 if (gl_db_is_root_path(ad, NULL, dir_path)) {
445 * Root path, couldn't rename root path,
446 * make the new dest folder
447 * and move all files for root path to it.
449 gl_dbg("Rename [No Name] album's name.");
454 /* Get dest folder path */
455 char temp_dir_path[GL_DIR_PATH_LEN_MAX] = { 0, };
458 /* Get default images path, make dest foler under it */
459 memset(dir_path, 0x00, GL_DIR_PATH_LEN_MAX);
460 if (gl_get_default_images_path(dir_path) != 0) {
461 gl_dbgW("Failed to get default images path!");
465 snprintf(temp_dir_path, GL_DIR_PATH_LEN_MAX, "%s/%s", dir_path, etxt);
466 temp_dir_path[strlen(temp_dir_path)] = '\0';
471 memcpy(temp_dir_path, dir_path, GL_DIR_PATH_LEN_MAX);
472 length = strlen(dir_path);
474 for (i = length; i >= 0; i--) {
475 if (temp_dir_path[i] == '/') {
476 gl_dbg("length=%d, i=%d", length, i);
477 /* Path like "/root/abc/" */
480 memcpy(&temp_dir_path[i + 1], etxt,
482 temp_dir_path[i + 1+ strlen(etxt)] = '\0';
487 gl_dbg("Dest folder: %s", temp_dir_path);
489 /* Get selected folder path for rename */
490 char rename_dir_path[GL_DIR_PATH_LEN_MAX] = { 0, };
491 gl_db_get_folder_fullpath(ad, album_item->cluster->uuid, rename_dir_path);
492 if (!g_strcmp0(rename_dir_path, temp_dir_path)) {
493 gl_dbgW("Same as current name!");
498 * If dir is empty, 1 is returned,
499 * if it contains at least 1 file, 0 is returned.
500 * On failure, -1 is returned.
502 if (ecore_file_dir_is_empty(temp_dir_path) == 0) {
504 popup_desc = (char*)calloc(GL_POPUP_STRING_MAX, sizeof(char));
505 if (popup_desc == NULL) {
506 gl_dbg("memory allocation fail");
510 snprintf(popup_desc, GL_POPUP_STRING_MAX, "%s.<br>%s",
511 GL_STR_SAME_NAME_ALREADY_IN_USE, GL_STR_RETRY_Q);
512 popup_desc[strlen(popup_desc)] = '\0';
513 gl_popup_create_popup(ad, GL_POPUP_ALBUM_RENAME_DUPLICATE,
516 gl_dbgW("New folder already exists and not NULL, return!");
522 * Case 1: Rename virtual album 'No Name'.
523 * It couldn't be done by updating album record in DB directly.
524 * Cuz it would change the folder path of all folder records,
525 * to make them invalid.
527 * Create new folder under default images path,
528 * Move all medias under root path to new folder.
530 if (gl_make_new_album(etxt) != 0) {
531 gl_popup_create_popup(ad, GL_POPUP_NOBUT,
532 GL_STR_UNABLE_TO_RENAME);
533 gl_dbgE("Failed to make a new directory!");
537 /* Move medias from 'No Name' album to new album */
538 if (gl_move_root_album(ad, album_item, temp_dir_path) != 0) {
539 gl_dbg("gl_move_root_album failed!");
540 gl_popup_create_popup(ad, GL_POPUP_NOBUT,
541 GL_STR_UNABLE_TO_RENAME);
544 gl_dbg("New album added, update albums list.");
545 ad->albuminfo.selected_album = NULL;
546 gl_db_update_cluster_list(ad);
550 * Case 2: Rename normal album.
552 * Update album record in DB.
554 ret = minfo_update_cluster_name(ad->maininfo.db_handle,
555 album_item->cluster->uuid, etxt);
557 gl_dbg("minfo_update_cluster_name failed (%d)!", ret);
562 * Change folder name in file system
563 * for some special name, DB update success, but file mv failed.
566 if (ecore_file_mv(dir_path, temp_dir_path) == EINA_FALSE) {
567 gl_dbgE("ecore_file_mv failed!");
568 gl_popup_create_popup(ad, GL_POPUP_NOBUT,
569 GL_STR_UNABLE_TO_RENAME);
574 g_strlcpy(album_item->cluster->display_name, etxt,
575 GL_FILE_NAME_LEN_MAX);
576 __gl_ui_rename_album_cancel_cb(ad, NULL, NULL);
580 __gl_ui_rename_album_cancel_cb(ad, NULL, NULL);
584 static void __gl_ui_rename_album_enter_cb(void *data, Evas_Object * obj, void *event_info)
588 gl_appdata *ad = (gl_appdata *)data;
589 /* Unfocus to hide cursor */
590 elm_object_focus_set(ad->entryinfo.imf_entry, FALSE);
592 __gl_ui_rename_album_done(data, true);
595 static void __gl_ui_rename_album_done_cb(void *data, Evas_Object * obj, void *event_info)
598 __gl_ui_rename_album_done(data, false);
602 _gl_ui_display_nocontents(void *data)
604 GL_CHECK_FALSE(data);
605 gl_appdata *ad = (gl_appdata *)data;
606 bool is_video_file_existing = false;
607 bool is_image_file_existing = false;
608 int grid_view_mode = ad->gridinfo.grid_view_mode;
609 gl_item *gitem = NULL;
612 int view_mode = gl_get_view_mode(ad);
613 /* Get all medias count of current album */
614 int cnt = ad->maininfo.medias_cnt;
616 if (grid_view_mode == GL_CTRL_SEG_VIDEOS ||
617 grid_view_mode == GL_CTRL_SEG_IMAGES) /*only check in video or image segment. */
619 for (i = 1; i <= cnt; i++)
621 gl_db_get_item_by_index(ad, i, false, &gitem);
622 if (gitem == NULL || gitem->item == NULL)
624 gl_dbg("gitem == NULL || gitem->item == NULL");
628 if (grid_view_mode == GL_CTRL_SEG_VIDEOS &&
629 !is_video_file_existing &&
630 gitem->item->type == MINFO_ITEM_VIDEO)
632 is_video_file_existing = true;
635 else if (grid_view_mode == GL_CTRL_SEG_IMAGES
636 && !is_image_file_existing &&
637 gitem->item->type == MINFO_ITEM_IMAGE)
639 is_image_file_existing = true;
645 gl_dbg("video file exists->%d, image file exists->%d",
646 is_video_file_existing, is_image_file_existing);
647 if (grid_view_mode == GL_CTRL_SEG_VIDEOS && !is_video_file_existing)
649 if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
651 gl_dbg("In edit mode, back to normal view.");
652 gl_ui_edit_cancel(ad);
655 gl_dbg("None video files, show nocontents...");
658 else if (grid_view_mode == GL_CTRL_SEG_IMAGES && !is_image_file_existing)
660 if (view_mode == GL_VIEW_THUMBS_EDIT)
662 gl_dbg("In edit mode, back to normal view.");
663 gl_ui_edit_cancel(ad);
666 gl_dbg("None image files, show nocontents...");
667 Evas_Object *noc = gl_ui_create_nocontents_full(ad);
668 if (ad->gridinfo.image_view)
670 evas_object_del(ad->gridinfo.image_view);
671 ad->gridinfo.image_view = NULL;
673 ad->gridinfo.image_view = noc;
674 ad->gridinfo.image_nocontents = noc;
675 elm_object_part_content_unset(ad->gridinfo.layout, "elm.swallow.view");
676 evas_object_hide(ad->listinfo.video_view);
677 evas_object_hide(ad->gridinfo.all_view);
678 evas_object_show(ad->gridinfo.image_view);
679 elm_object_part_content_set(ad->gridinfo.layout,
680 "elm.swallow.view", ad->gridinfo.image_view);
681 gl_ui_disable_toolbar_item(ad, true, GL_NAVI_THUMBS, false);
689 /* Select-all checkbox selected/deselected */
690 static void _gl_ui_selall_check_changed(void *data, Evas_Object *obj,
695 gl_appdata *ad = (gl_appdata *)data;
696 int view_mode = gl_get_view_mode(ad);
697 gl_dbg("view_mode: %d.", view_mode);
699 gl_item *current = NULL;
703 Eina_Bool state = EINA_FALSE;
704 state = elm_check_state_get(obj);
705 gl_dbg("Checkbox state: %d.", state);
706 /* Get all medias count of current album */
707 item_cnt = ad->maininfo.medias_cnt;
708 sel_all_cnt = item_cnt;
709 gl_ctrl_seg_mode seg_mode = ad->albuminfo.seg_mode;
710 minfo_file_type file_type = MINFO_ITEM_NONE;
711 if (view_mode == GL_VIEW_THUMBS_EDIT)
713 if (seg_mode == GL_CTRL_SEG_IMAGES)
715 file_type = MINFO_ITEM_IMAGE;
718 else if (seg_mode == GL_CTRL_SEG_VIDEOS)
720 file_type = MINFO_ITEM_VIDEO;
724 else if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
726 file_type = MINFO_ITEM_VIDEO;
730 gl_dbg("seg_mode=%d", seg_mode);
731 for (i = 0; i < item_cnt; i++)
733 gl_db_get_item_by_index(ad, i + 1, false, ¤t);
735 GL_CHECK(current->item);
737 if (current->checked == state && seg_mode == GL_CTRL_SEG_ALL)
742 if (view_mode == GL_VIEW_THUMBS_EDIT)
744 if ((seg_mode == GL_CTRL_SEG_IMAGES) ||
745 (seg_mode == GL_CTRL_SEG_VIDEOS))
747 if (current->item->type != file_type)
753 if (current->checked == state)
759 else if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
761 if (current->item->type != file_type)
767 if (current->checked == state)
773 current->checked = state;
775 if (view_mode == GL_VIEW_THUMBS_EDIT)
776 elm_gengrid_item_update(current->elm_item);
778 if (state == EINA_TRUE)
779 gl_db_selected_list_append(ad, current);
781 gl_db_selected_list_remove(ad, current);
785 /* Update all realized items */
786 if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
787 elm_genlist_realized_items_update(ad->gridinfo.edit_view);
789 /* Recreate selection info for both cases */
790 if (state == EINA_FALSE)
792 gl_ui_create_selinfo(ad, ad->gridinfo.edit_layout,
793 ad->gridinfo.nf_it_edit, item_cnt,
797 /* Select-all background click, selected/deselected checkbox */
798 static void _gl_ui_selall_bg_click_cb(void *data, Evas_Object *o,
799 const char *emission,
803 gl_appdata *ad = (gl_appdata *)data;
804 int view_mode = gl_get_view_mode(ad);
805 Evas_Object *ly = NULL;
806 gl_dbg("view_mode: %d.", view_mode);
808 if (view_mode == GL_VIEW_THUMBS_EDIT ||
809 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
810 ly = ad->gridinfo.edit_layout;
812 gl_dbgE("Wrong view!");
816 Evas_Object *check = elm_object_part_content_get(ly, "selectall_check");
818 Eina_Bool new_state = EINA_FALSE;
819 Eina_Bool ck_state = elm_check_state_get(check);
821 if (ck_state == EINA_FALSE)
822 new_state = EINA_TRUE;
824 elm_check_state_set(check, new_state);
826 _gl_ui_selall_check_changed(ad, check, NULL);
828 gl_dbgE("Get select all checkbox object failed!");
834 _gl_ui_edit_cancel_cb(void *data, Evas_Object * obj, void *event_info)
837 gl_appdata *ad = (gl_appdata *)data;
838 int view_mode = gl_get_view_mode(ad);
841 if (view_mode == GL_VIEW_ALBUMS_EDIT)
843 if (ad->albuminfo.edit_view)
845 evas_object_del(ad->albuminfo.edit_view);
846 ad->albuminfo.edit_view = NULL;
847 ad->albuminfo.edit_layout = NULL;
850 gl_db_finalize_albums_selected_list(ad);
852 * after back to albums view from albums edit view,
853 * option header should be defaultly closed
856 gl_db_get_cluster_list(ad);
857 GL_CHECK(ad->albuminfo.cluster_list);
859 gl_albums_change_to_view(ad);
860 gl_ui_destroy_selinfo(ad);
861 if (gl_check_gallery_empty(ad)) {
862 gl_ui_disable_toolbar_item(ad, true, GL_NAVI_ALBUMS,
865 if (ad->albuminfo.cluster_list->edit_cnt == 0) {
866 gl_dbg("None editable albums, disable items.");
867 gl_ui_disable_toolbar_item(ad, true,
873 else if (view_mode == GL_VIEW_THUMBS_EDIT)
875 _gl_destroy_thumbs_edit_view(ad);
876 gl_db_selected_list_finalize(ad);
878 gl_set_view_mode(ad, GL_VIEW_THUMBS);
879 if (ad->albuminfo.update_albums_list)
882 * Update albums list if MMC added/removed,
884 ad->albuminfo.update_albums_list = false;
885 gl_refresh_albums_list(ad);
888 gl_grid_change_to_view(ad);
889 gl_ui_destroy_selinfo(ad);
891 else if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
893 _gl_destroy_thumbs_edit_view(ad);
894 gl_db_selected_list_finalize(ad);
895 gl_set_view_mode(ad, GL_VIEW_VIDEOLIST);
896 if (ad->albuminfo.update_albums_list)
899 * Update albums list if MMC added/removed
901 ad->albuminfo.update_albums_list = false;
902 gl_refresh_albums_list(ad);
905 gl_list_change_to_view(ad);
906 gl_ui_destroy_selinfo(ad);
910 /* callback after user tap Cancel button in option header in edit view */
911 static void __gl_ui_click_cancel_edit_cb(void *data, Evas_Object *obj, void *event_info)
915 gl_appdata *ad = (gl_appdata *)data;
916 elm_naviframe_item_pop(ad->maininfo.navi_bar);
917 _gl_ui_edit_cancel_cb(data, obj, event_info);
922 _gl_ui_edit_cb(void *data, Evas_Object * obj, void *event_info)
925 gl_appdata *ad = (gl_appdata *)data;
927 if (ad->uginfo.ug_called_by_me || ad->gridinfo.append_idler)
930 * Prevent changed to edit view in wrong way.
931 * 1. When invoke imageviewer UG;
932 * 2. First show thumbnails view, use idler to append other medias.
934 gl_dbg("UG invoked or appending gridview.");
938 int view_mode = gl_get_view_mode(ad);
939 gl_dbg("mode: %d", view_mode);
940 if (view_mode == GL_VIEW_THUMBS_EDIT)
942 /* Fixme: maybe we should disable edit button until grid append idler is done */
944 * Happen in quickly tap edit button,
945 * it will invoke _gl_ui_edit_cb several time
946 * and push some unuseful views.
948 gl_dbg("Already in edit mode, return.");
952 gl_ui_destroy_notiinfo(ad);
954 if (view_mode == GL_VIEW_ALBUMS)
956 gl_set_view_mode(ad, GL_VIEW_ALBUMS_EDIT);
958 ad->albuminfo.edit_layout = gl_ui_create_view_ly(ad->maininfo.navi_bar);
959 ad->albuminfo.edit_view = gl_albums_create_view(ad, ad->albuminfo.edit_layout);
960 elm_object_part_content_set(ad->albuminfo.edit_layout,
962 ad->albuminfo.edit_view);
963 edje_object_signal_emit(_EDJ(ad->albuminfo.edit_layout),
964 "elm,swallow_view,state,default", "elm");
965 gl_ui_create_title_and_push(ad, ad->maininfo.navi_bar,
966 ad->albuminfo.edit_layout,
968 GL_STR_SELECT_ALBUM);
971 else if (view_mode == GL_VIEW_THUMBS)
973 gl_set_view_mode(ad, GL_VIEW_THUMBS_EDIT);
974 if (ad->gridinfo.grid_view_mode == GL_GRID_ALL)
975 ad->gridinfo.edit_view = gl_grid_create_view(ad,
976 ad->maininfo.navi_bar,
979 ad->gridinfo.edit_view = gl_grid_create_view(ad,
980 ad->maininfo.navi_bar,
983 else if (view_mode == GL_VIEW_VIDEOLIST)
985 gl_set_view_mode(ad, GL_VIEW_VIDEOLIST_EDIT);
986 ad->gridinfo.edit_view = gl_list_create_view(ad, ad->maininfo.navi_bar);
989 ad->gridinfo.edit_layout = gl_ui_create_view_ly(ad->maininfo.navi_bar);
990 evas_object_size_hint_weight_set(ad->gridinfo.edit_layout,
991 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
992 evas_object_size_hint_align_set(ad->gridinfo.edit_layout,
993 EVAS_HINT_FILL, EVAS_HINT_FILL);
995 elm_object_part_content_set(ad->gridinfo.edit_layout,
996 "elm.swallow.view", ad->gridinfo.edit_view);
997 gl_ui_create_title_and_push(ad, ad->maininfo.navi_bar,
998 ad->gridinfo.edit_layout,
999 GL_NAVI_THUMBS_EDIT, GL_STR_SELECT_ITEM);
1000 edje_object_signal_emit(_EDJ(ad->gridinfo.edit_layout),
1001 "elm,swallow_view,state,thumb_edit_default",
1003 gl_ui_show_selall(ad);
1008 /* move media to album in edit view */
1009 int gl_ui_move_media_to_album(gl_appdata *ad)
1011 GL_CHECK_VAL(ad, -1);
1012 int view_mode = gl_get_view_mode(ad);
1015 if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me)
1017 gl_dbg("UG or APP is already loaded, return.");
1021 if ((view_mode == GL_VIEW_THUMBS_EDIT) ||
1022 (view_mode == GL_VIEW_VIDEOLIST_EDIT))
1025 int cnt = gl_db_selected_list_count(ad);
1028 gl_dbg("No thumbs selected, return!");
1029 gl_popup_create_popup(ad, GL_POPUP_NOBUT,
1030 GL_STR_NO_FILES_SELECTED);
1034 gl_popup_create_title_popup(ad, GL_POPUP_THUMB_MOVE,
1040 gl_dbg("Unknow mode!");
1046 _gl_ui_medias_del_cb(void *data, Evas_Object * obj, void *event_info)
1049 gl_appdata *ad = (gl_appdata *)data;
1052 if (ad->uginfo.ug_called_by_me || ad->uginfo.app_called_by_me)
1054 gl_dbg("UG or APP is already loaded, return.");
1058 int view_mode = gl_get_view_mode(ad);
1059 if ((view_mode == GL_VIEW_THUMBS_EDIT) ||
1060 (view_mode == GL_VIEW_VIDEOLIST_EDIT))
1062 int cnt = gl_db_selected_list_count(ad);
1065 gl_dbg("No thumbs selected, return!");
1066 gl_popup_create_popup(ad, GL_POPUP_NOBUT, GL_STR_NO_FILES_SELECTED);
1074 gl_dbg("Unknow mode!");
1079 _gl_ui_albums_del_cb(void *data, Evas_Object * obj, void *event_info)
1082 gl_appdata *ad = (gl_appdata *)data;
1085 if ((gl_get_view_mode(ad) == GL_VIEW_ALBUMS_EDIT))
1087 int cnt = gl_db_get_albums_selected_cnt(ad);
1090 gl_dbg("No albums selected, return!");
1091 gl_popup_create_popup(ad, GL_POPUP_NOBUT,
1092 GL_STR_NO_ALBUMS_SELECTED);
1095 gl_popup_create_albums_del_popup(ad);
1099 gl_dbg("Unknow mode!");
1104 _gl_ui_notiinfo_destroy_cb(void *data, Evas_Object * obj, void *event_info)
1107 gl_appdata *ad = (gl_appdata *)data;
1110 gl_ui_destroy_notiinfo(ad);
1113 static int _gl_ui_enable_toolbar_items(gl_appdata *ad, Elm_Object_Item *nf_it)
1115 GL_CHECK_VAL(ad, -1);
1116 GL_CHECK_VAL(nf_it, -1);
1118 Elm_Object_Item *cbar_it = NULL;
1119 Evas_Object *ctlbar = _gl_ctrl_get_toolbar(nf_it);
1120 GL_CHECK_VAL(ctlbar, -1);
1121 cbar_it = elm_toolbar_first_item_get(ctlbar);
1123 gl_ui_enable_cbar_item(cbar_it);
1124 cbar_it = elm_toolbar_item_next_get(cbar_it);
1130 static int _gl_ui_disable_toolbar_item(void *data, gl_navi_mode mode, bool edit)
1132 GL_CHECK_VAL(data, -1);
1133 gl_appdata *ad = (gl_appdata *)data;
1135 if (mode == GL_NAVI_ALBUMS) {
1136 gl_dbg("GL_NAVI_ALBUMS");
1137 /* disable 'edit' item */
1138 gl_ui_disable_cbar_item(ad->albuminfo.edit_it);
1139 }else if (mode == GL_NAVI_THUMBS) {
1140 gl_dbg("GL_NAVI_THUMBS");
1141 /* disable 'edit' item */
1142 gl_ui_disable_cbar_item(ad->gridinfo.edit_it);
1144 gl_dbgE("Unkonw mode");
1150 static int _gl_ui_enable_toolbar_item(void *data, gl_navi_mode mode)
1152 GL_CHECK_VAL(data, -1);
1153 gl_appdata *ad = (gl_appdata *)data;
1154 gl_dbg("mode: %d", mode);
1155 if (mode == GL_NAVI_ALBUMS) {
1156 gl_dbg("GL_NAVI_ALBUMS");
1157 /* enable 'edit' item */
1158 if (!gl_check_gallery_empty(ad) &&
1159 ad->albuminfo.cluster_list->edit_cnt)
1160 gl_ui_enable_cbar_item(ad->albuminfo.edit_it);
1162 gl_ui_disable_cbar_item(ad->albuminfo.edit_it);
1163 } else if (mode == GL_NAVI_THUMBS) {
1164 gl_dbg("GL_NAVI_THUMBS");
1165 /* enable 'edit' item */
1166 gl_ui_enable_cbar_item(ad->gridinfo.edit_it);
1168 gl_dbgE("Unkonw mode");
1176 * Update checkbox state in select-all widget
1178 static int _gl_ui_update_selall(void *data, int all_cnt, int selected_cnt)
1180 GL_CHECK_VAL(data, -1);
1181 gl_appdata *ad = (gl_appdata *)data;
1183 gl_item *gitem = NULL;
1186 gl_ctrl_seg_mode ctl_seg = GL_CTRL_SEG_ALL;
1187 minfo_file_type file_type = MINFO_ITEM_NONE;
1188 int view_mode = gl_get_view_mode(ad);
1190 if (view_mode == GL_VIEW_THUMBS_EDIT ||
1191 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
1192 /* Get all medias count */
1193 db_all_cnt = ad->maininfo.medias_cnt;
1194 ctl_seg = ad->albuminfo.seg_mode;
1195 if (ctl_seg == GL_CTRL_SEG_ALL) {
1196 _all_cnt = db_all_cnt;
1198 /* Get all count in diff segments */
1199 if (ctl_seg == GL_CTRL_SEG_IMAGES)
1200 file_type = MINFO_ITEM_IMAGE;
1201 else if (ctl_seg == GL_CTRL_SEG_VIDEOS)
1202 file_type = MINFO_ITEM_VIDEO;
1204 for (i = 1; i <= db_all_cnt; i++) {
1205 gl_db_get_item_by_index(ad, i, false,
1207 if (gitem && gitem->item &&
1208 (gitem->item->type == file_type))
1213 gl_dbg("Wrong view mode!");
1218 * Set checkbox state
1219 * except in albums edit view and selectioninfo view
1221 gl_dbg("selected_cnt/_all_cnt = %d/%d", selected_cnt, _all_cnt);
1222 Evas_Object *ly = NULL;
1223 Evas_Object *check = NULL;
1224 Eina_Bool state = EINA_FALSE;
1226 if (selected_cnt == _all_cnt) {
1227 /* Set checkbox checked */
1230 /* Set checkbox unchecked */
1234 ly = ad->gridinfo.edit_layout;
1235 check = elm_object_part_content_get(ly, "selectall_check");
1237 elm_check_state_set(check, state);
1245 * Update selectioinfo widget and view related to it
1247 static int _gl_ui_update_view_selinfo(void *data, int selected_cnt)
1249 GL_CHECK_VAL(data, -1);
1250 gl_appdata *ad = (gl_appdata *)data;
1251 Evas_Object *sel_edj = NULL;
1252 const char *emis = NULL;
1253 Evas_Object *v_edj = NULL;
1254 const char *v_emis = NULL;
1255 int view_mode = gl_get_view_mode(ad);
1257 sel_edj = _EDJ(ad->popupinfo.selinfo_ly);
1259 if (selected_cnt > 0) {
1260 if (view_mode == GL_VIEW_THUMBS_EDIT ||
1261 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
1262 v_edj = _EDJ(ad->gridinfo.edit_layout);
1263 v_emis = "elm,swallow_view,state,moveup_view";
1264 } else if (view_mode == GL_VIEW_ALBUMS_EDIT) {
1265 emis = "elm,selectioninfo,portrait";
1266 v_emis = "elm,swallow_view,state,moveup_albums_default";
1267 v_edj = _EDJ(ad->albuminfo.edit_layout);
1269 /* Set selectioninfo widget style */
1270 edje_object_signal_emit(sel_edj, emis, "elm");
1271 /* Move view up while selectioninfo shown. */
1272 edje_object_signal_emit(v_edj, v_emis, "elm");
1274 if (view_mode == GL_VIEW_THUMBS_EDIT ||
1275 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
1276 v_edj = _EDJ(ad->gridinfo.edit_layout);
1277 v_emis = "elm,swallow_view,state,thumb_edit_default";
1278 } else if (view_mode == GL_VIEW_ALBUMS_EDIT) {
1279 v_edj = _EDJ(ad->albuminfo.edit_layout);
1280 v_emis = "elm,swallow_view,state,default";
1282 /* Restore view while selectioninfo vanished. */
1283 edje_object_signal_emit(v_edj, v_emis, "elm");
1289 * Create a new notify widget
1290 * b_selinfo, True: Create selectioninfo, False: Create notificationinfo.
1292 static int _gl_ui_add_notify(void *data, Evas_Object *parent, bool b_selinfo)
1294 gl_dbg("b_selinfo: %d.", b_selinfo);
1295 GL_CHECK_VAL(parent, -1);
1296 GL_CHECK_VAL(data, -1);
1297 gl_appdata *ad = (gl_appdata *)data;
1300 gl_ui_destroy_selinfo(ad);
1302 gl_ui_destroy_notiinfo(ad);
1304 ad->popupinfo.selinfo = elm_notify_add(parent);
1305 elm_notify_orient_set(ad->popupinfo.selinfo,
1306 ELM_NOTIFY_ORIENT_BOTTOM);
1307 evas_object_size_hint_weight_set(ad->popupinfo.selinfo,
1310 evas_object_size_hint_align_set(ad->popupinfo.selinfo,
1314 ad->popupinfo.selinfo_ly = elm_layout_add(parent);
1315 /* Set custom theme to notify layout */
1316 elm_layout_theme_set(ad->popupinfo.selinfo_ly, "standard",
1318 "selectioninfo_viewer");
1320 evas_object_size_hint_weight_set(ad->popupinfo.selinfo_ly,
1323 evas_object_size_hint_align_set(ad->popupinfo.selinfo_ly,
1326 /* Set the content of the notify widget */
1327 elm_object_content_set(ad->popupinfo.selinfo,
1328 ad->popupinfo.selinfo_ly);
1331 /* Add callbacks for notificationinfo */
1332 evas_object_smart_callback_add(ad->popupinfo.selinfo,
1334 _gl_ui_notiinfo_destroy_cb,
1336 elm_notify_timeout_set(ad->popupinfo.selinfo, 2);
1338 /* Add callbacks for selectioninfo */
1339 evas_object_smart_callback_add(ad->popupinfo.selinfo,
1341 _gl_ui_selinfo_destroy_cb, ad);
1342 elm_notify_timeout_set(ad->popupinfo.selinfo, 3);
1347 static void __gl_ui_move_cb(void *data, Evas_Object *obj, void *event_info)
1350 gl_ui_move_media_to_album(data);
1354 /* pause gallery and change view to background after tap Back button in albums view */
1355 static void __gl_ui_change_to_background_cb(void *data, Evas_Object * obj, void *event_info)
1357 gl_dbg("Back button clicked, change view to background.");
1359 Evas_Object *win = (Evas_Object *) data;
1364 static int __gl_ui_append_object_item(Evas_Object *cbar, Evas_Object *object)
1366 Elm_Object_Item *item = elm_toolbar_item_append(cbar, NULL, NULL, NULL,
1369 elm_object_item_part_content_set(item, "object", object);
1372 elm_object_item_disabled_set(item, EINA_TRUE);
1376 static void __gl_ui_trans_finished_cb(void *data, Evas_Object *obj, void *event_info)
1379 gl_appdata *ad = (gl_appdata *)data;
1380 int view_mode = gl_get_view_mode(ad);
1381 gl_dbgW("view_mode: %d", view_mode);
1382 evas_object_smart_callback_del(obj, GL_TRANS_FINISHED,
1383 __gl_ui_trans_finished_cb);
1385 if (view_mode == GL_VIEW_ALBUMS_EDIT) {
1386 elm_gengrid_clear(ad->albuminfo.view);
1387 } else if (view_mode == GL_VIEW_ALBUMS_RENAME) {
1388 elm_gengrid_clear(ad->albuminfo.edit_view);
1389 } else if (view_mode == GL_VIEW_THUMBS_EDIT) {
1390 if (ad->entryinfo.entry_mode != GL_ENTRY_NONE)
1392 if (ad->albuminfo.seg_mode == GL_CTRL_SEG_ALL)
1393 elm_gengrid_clear(ad->gridinfo.all_view);
1394 else if (ad->albuminfo.seg_mode == GL_CTRL_SEG_IMAGES)
1395 elm_gengrid_clear(ad->gridinfo.image_view);
1396 } else if (view_mode == GL_VIEW_VIDEOLIST_EDIT) {
1397 if (ad->entryinfo.entry_mode != GL_ENTRY_NONE)
1399 elm_genlist_clear(ad->listinfo.video_view);
1404 * Use naviframe api to push albums view to stack.
1405 * @param obj is the content to be pushed.
1407 static int __gl_ui_push_view_albums(void *data, Evas_Object *parent,
1408 Evas_Object *obj, char *title)
1410 gl_dbg("GL_NAVI_ALBUMS");
1411 GL_CHECK_VAL(obj, -1);
1412 GL_CHECK_VAL(parent, -1);
1413 GL_CHECK_VAL(data, -1);
1414 gl_appdata *ad = (gl_appdata *)data;
1415 Elm_Object_Item *nf_it = NULL;
1416 Elm_Object_Item *edit_it = NULL;
1417 Elm_Object_Item *add_it = NULL;
1418 Evas_Object *end_btn = NULL;
1419 Evas_Object *bot_bar = NULL;
1421 /* create tool controlbar downside */
1422 bot_bar = _gl_ctrl_create_toolbar(ad, obj);
1423 GL_CHECK_VAL(bot_bar, -1);
1425 edit_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_EDIT, NULL,
1426 _gl_ui_edit_cb, ad);
1427 ad->albuminfo.edit_it = edit_it;
1428 gl_ui_enable_cbar_item(edit_it);
1429 __gl_ui_append_object_item(bot_bar, NULL);
1430 __gl_ui_append_object_item(bot_bar, NULL);
1433 * add End button in navigation var first view in galery
1434 * with style "naviframe/back_btn/gallery"
1435 * so after tap this button,gallery is paused
1436 * but change view to background
1438 GL_CHECK_VAL(ad->maininfo.win, -1);
1439 end_btn = _gl_but_create_but(obj, GL_BUT_NONE, GL_BUTTON_STYLE_NAVI_PRE);
1440 evas_object_smart_callback_add(end_btn, "clicked",
1441 __gl_ui_change_to_background_cb,
1444 /* Disable items in exit mode */
1445 if (ad->maininfo.app_exit_mode) {
1446 gl_ui_disable_cbar_item(edit_it);
1447 gl_ui_disable_cbar_item(add_it);
1449 /* Push view to stack */
1450 nf_it = elm_naviframe_item_push(parent, title, end_btn, NULL, obj, NULL);
1451 ad->albuminfo.nf_it = nf_it;
1452 /* Set tool controlbar to bottom */
1453 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_CONTROLBAR,
1459 * Use naviframe api to push albums edit view to stack.
1460 * @param obj is the content to be pushed.
1462 static int __gl_ui_push_view_albums_edit(void *data, Evas_Object *parent,
1463 Evas_Object *obj, char *title)
1465 gl_dbg("GL_NAVI_ALBUMS_EDIT");
1466 GL_CHECK_VAL(obj, -1);
1467 GL_CHECK_VAL(parent, -1);
1468 GL_CHECK_VAL(data, -1);
1469 gl_appdata *ad = (gl_appdata *)data;
1470 Elm_Object_Item *nf_it = NULL;
1471 Elm_Object_Item *cancel_it = NULL;
1472 Elm_Object_Item *del_it = NULL;
1473 Evas_Object *bot_bar = NULL;
1475 /* create tool controlbar downside */
1476 bot_bar = _gl_ctrl_create_toolbar(ad, obj);
1477 GL_CHECK_VAL(bot_bar, -1);
1479 /* Add delete item */
1480 del_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_DELETE, NULL,
1481 _gl_ui_albums_del_cb, ad);
1482 gl_ui_disable_cbar_item(del_it);
1483 __gl_ui_append_object_item(bot_bar, NULL);
1484 __gl_ui_append_object_item(bot_bar, NULL);
1486 /* use Cancel button */
1487 cancel_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_CANCEL, NULL,
1488 __gl_ui_click_cancel_edit_cb, ad);
1489 /* Add transition finished callback */
1490 evas_object_smart_callback_add(parent, GL_TRANS_FINISHED,
1491 __gl_ui_trans_finished_cb, ad);
1493 nf_it = elm_naviframe_item_push(parent, title, NULL, NULL,
1495 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_PREB_BTN, NULL);
1497 ad->albuminfo.nf_it_edit = nf_it;
1498 /* Set tool bar to bottom */
1499 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_CONTROLBAR,
1505 * Use naviframe api to push thumbnails view to stack.
1506 * @param obj is the content to be pushed.
1508 static int __gl_ui_push_view_thumbs(void *data, Evas_Object *parent,
1509 Evas_Object *obj, char *title)
1511 gl_dbg("GL_NAVI_THUMBS");
1512 GL_CHECK_VAL(obj, -1);
1513 GL_CHECK_VAL(parent, -1);
1514 GL_CHECK_VAL(data, -1);
1515 gl_appdata *ad = (gl_appdata *)data;
1516 Elm_Object_Item *nf_it = NULL;
1517 Elm_Object_Item *edit_it = NULL;
1518 Evas_Object *bot_bar = NULL;
1519 Evas_Object *segment = NULL;
1521 /* create tool controlbar downside */
1522 bot_bar = _gl_ctrl_create_toolbar(ad, obj);
1523 GL_CHECK_VAL(bot_bar, -1);
1524 /* add 'Back' item */
1525 if (ad->maininfo.medias_cnt) {
1526 /* add 'Edit' item */
1527 edit_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_EDIT,
1528 NULL, _gl_ui_edit_cb, ad);
1529 ad->gridinfo.edit_it = edit_it;
1531 segment = _gl_ctrl_create_segment(ad, bot_bar);
1533 __gl_ui_append_object_item(bot_bar, segment);
1536 nf_it = elm_naviframe_top_item_get(parent);
1537 /* For the instant transition, use the xxx_insert_after API */
1538 nf_it = elm_naviframe_item_insert_after(parent, nf_it, title,
1539 NULL, NULL, obj, NULL);
1542 nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj, NULL);
1544 ad->gridinfo.nf_it = nf_it;
1545 /* Set tool bar to bottom */
1546 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_CONTROLBAR,
1553 * Use naviframe api to push thumbnails eidt view to stack.
1554 * @param obj is the content to be pushed.
1556 static int __gl_ui_push_view_thumbs_edit(void *data, Evas_Object *parent,
1557 Evas_Object *obj, char *title)
1559 gl_dbg("GL_NAVI_THUMBS_EDIT");
1560 GL_CHECK_VAL(obj, -1);
1561 GL_CHECK_VAL(parent, -1);
1562 GL_CHECK_VAL(data, -1);
1563 gl_appdata *ad = (gl_appdata *)data;
1564 Elm_Object_Item *nf_it = NULL;
1565 Elm_Object_Item *del_it = NULL;
1566 Elm_Object_Item *move_it = NULL;
1567 Elm_Object_Item *cancel_it = NULL;
1568 Evas_Object *bot_bar = NULL;
1570 /* create tool controlbar downside */
1571 bot_bar = _gl_ctrl_create_toolbar(ad, obj);
1572 GL_CHECK_VAL(bot_bar, -1);
1573 /* Add 'Delete' item */
1574 del_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_DELETE, NULL,
1575 _gl_ui_medias_del_cb, ad);
1576 gl_ui_disable_cbar_item(del_it);
1577 /* Add 'Move' item */
1578 move_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_MOVE, NULL,
1579 __gl_ui_move_cb, ad);
1580 gl_ui_disable_cbar_item(move_it);
1581 /* use Cancel button */
1582 cancel_it = elm_toolbar_item_append(bot_bar, GL_CBAR_ICON_CANCEL, NULL,
1583 __gl_ui_click_cancel_edit_cb, ad);
1584 /* Add transition finished callback */
1585 evas_object_smart_callback_add(parent, GL_TRANS_FINISHED,
1586 __gl_ui_trans_finished_cb, ad);
1588 nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj,
1590 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_PREB_BTN, NULL);
1592 ad->gridinfo.nf_it_edit = nf_it;
1593 /* Set tool bar to bottom */
1594 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_CONTROLBAR,
1601 * Use naviframe api to push albums rename view to stack.
1602 * @param obj is the content to be pushed.
1604 static int __gl_ui_push_view_albums_rename(void *data, Evas_Object *parent,
1605 Evas_Object *obj, char *title)
1607 gl_dbg("GL_NAVI_ALBUMS_RENAME");
1608 GL_CHECK_VAL(obj, -1);
1609 GL_CHECK_VAL(parent, -1);
1610 GL_CHECK_VAL(data, -1);
1611 gl_appdata *ad = (gl_appdata *)data;
1612 Elm_Object_Item *nf_it = NULL;
1613 Evas_Object *done_btn = NULL;
1614 Evas_Object *cancel_btn = NULL;
1616 /* Add transition finished callback */
1617 evas_object_smart_callback_add(parent, GL_TRANS_FINISHED,
1618 __gl_ui_trans_finished_cb, ad);
1619 nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj, NULL);
1620 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_PREB_BTN, NULL);
1621 /* Add 'Cancel' button */
1622 cancel_btn = _gl_but_create_but(obj, GL_BUT_CANCEL,
1623 GL_BUTTON_STYLE_NAVI_TITLE);
1624 GL_CHECK_VAL(cancel_btn, -1);
1625 evas_object_smart_callback_add(cancel_btn, "clicked",
1626 __gl_ui_rename_album_cancel_cb, ad);
1627 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_TITLE_RIGHT_BTN,
1629 /* Add 'Done' button */
1630 done_btn = _gl_but_create_but(obj, GL_BUT_DONE,
1631 GL_BUTTON_STYLE_NAVI_TITLE);
1632 GL_CHECK_VAL(done_btn, -1);
1633 evas_object_smart_callback_add(done_btn, "clicked",
1634 __gl_ui_rename_album_done_cb, ad);
1635 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_TITLE_LEFT_BTN,
1637 ad->entryinfo.done_btn = done_btn;
1642 * Use naviframe api to push new album view to stack.
1643 * @param obj is the content to be pushed.
1645 static int __gl_ui_push_view_albums_new(void *data, Evas_Object *parent,
1646 Evas_Object *obj, char *title)
1648 gl_dbg("GL_NAVI_ALBUMS_NEW");
1649 GL_CHECK_VAL(obj, -1);
1650 GL_CHECK_VAL(parent, -1);
1651 GL_CHECK_VAL(data, -1);
1652 gl_appdata *ad = (gl_appdata *)data;
1653 Elm_Object_Item *nf_it = NULL;
1654 Evas_Object *done_btn = NULL;
1655 Evas_Object *cancel_btn = NULL;
1657 nf_it = elm_naviframe_item_push(parent, title, NULL, NULL, obj, NULL);
1658 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_PREB_BTN, NULL);
1659 /* Add 'Cancel' button */
1660 cancel_btn = _gl_but_create_but(obj, GL_BUT_CANCEL,
1661 GL_BUTTON_STYLE_NAVI_TITLE);
1662 GL_CHECK_VAL(cancel_btn, -1);
1663 evas_object_smart_callback_add(cancel_btn, "clicked",
1664 _gl_ui_newalbum_cancel_cb, ad);
1665 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_TITLE_RIGHT_BTN,
1667 /* Add 'Done' button */
1668 done_btn = _gl_but_create_but(obj, GL_BUT_DONE,
1669 GL_BUTTON_STYLE_NAVI_TITLE);
1670 GL_CHECK_VAL(done_btn, -1);
1671 evas_object_smart_callback_add(done_btn, "clicked",
1672 _gl_ui_newalbum_done_cb, ad);
1673 elm_object_item_part_content_set(nf_it, GE_NAVIFRAME_TITLE_LEFT_BTN,
1675 ad->entryinfo.done_btn = done_btn;
1679 int gl_ui_reset_toolbar_item(void *data, gl_ctrl_seg_mode seg_mode, bool force)
1681 GL_CHECK_VAL(data, -1);
1682 gl_appdata *ad = (gl_appdata *)data;
1683 bool is_zero = false;
1685 gl_dbg("changed between tool tab(all/image/video)");
1686 if (seg_mode == GL_CTRL_SEG_VIDEOS)
1687 is_zero = gl_db_is_item_cnt_zero(ad, MINFO_ITEM_VIDEO);
1688 else if (seg_mode == GL_CTRL_SEG_IMAGES)
1689 is_zero = gl_db_is_item_cnt_zero(ad, MINFO_ITEM_IMAGE);
1691 Elm_Object_Item *ctl_it = NULL;
1692 ctl_it = ad->gridinfo.edit_it;
1694 /* none items, disable 'edit' item */
1696 gl_ui_disable_cbar_item(ctl_it);
1698 gl_ui_enable_cbar_item(ctl_it);
1703 int gl_ui_disable_toolbar_item(void *data, bool disabled, gl_navi_mode mode,
1706 GL_CHECK_VAL(data, -1);
1707 gl_dbg("Title button disabled: %d.", disabled);
1709 _gl_ui_disable_toolbar_item(data, mode, edit);
1711 _gl_ui_enable_toolbar_item(data, mode);
1716 int gl_ui_disable_cbar_item(Elm_Object_Item *it)
1719 elm_object_item_disabled_set(it, EINA_TRUE);
1723 int gl_ui_enable_cbar_item(Elm_Object_Item *it)
1726 elm_object_item_disabled_set(it, EINA_FALSE);
1730 int gl_ui_disable_toolbar_items(void *data, Elm_Object_Item *nf_it)
1732 GL_CHECK_VAL(data, -1);
1733 GL_CHECK_VAL(nf_it, -1);
1735 Elm_Object_Item *cbar_it = NULL;
1736 Evas_Object *ctlbar = _gl_ctrl_get_toolbar(nf_it);
1737 cbar_it = elm_toolbar_last_item_get(ctlbar);
1738 GL_CHECK_VAL(cbar_it, -1);
1739 cbar_it = elm_toolbar_item_prev_get(cbar_it);
1741 gl_ui_disable_cbar_item(cbar_it);
1742 cbar_it = elm_toolbar_item_prev_get(cbar_it);
1748 /* The maximun length reached callback */
1749 void __gl_ui_entry_maxlen_reached_cb(void *data, Evas_Object *obj, void *event_info)
1751 gl_dbg("Entry maximum length reached, vibrate device.");
1753 /* Vibrate device if maximum length reached */
1754 gl_play_vibration(data);
1757 static void __gl_editfield_focused_cb(void *data, Evas_Object *obj, void *event_info)
1761 if (!elm_entry_is_empty(obj)) {
1762 gl_dbg("Show eraser.");
1763 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1767 static void __gl_editfield_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1770 gl_dbg("Hide eraser.");
1771 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1774 static void __gl_editfield_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1777 gl_dbg("Clear emtry after eraser clicked.");
1778 elm_entry_entry_set(data, "");
1782 * Callback registered to signal 'changed' of entry.
1783 * It would get the entry string and check whether it's different
1784 * with original string or not, if so, enable 'Done' button, other disable it.
1786 void __gl_ui_entry_space_check_cb(void *data, Evas_Object *obj, void *event_info)
1788 gl_appdata *ad = (gl_appdata *)data;
1790 GL_CHECK(ad->entryinfo.editfield);
1791 GL_CHECK(ad->entryinfo.done_btn);
1792 const char *entry_str = NULL;
1794 /* Show/hide eraser */
1795 if (elm_object_focus_get(ad->entryinfo.editfield)) {
1796 if (elm_entry_is_empty(obj)) {
1797 gl_dbg("Show eraser.");
1798 elm_object_signal_emit(ad->entryinfo.editfield,
1799 "elm,state,eraser,hide", "elm");
1801 gl_dbg("Hide eraser.");
1802 elm_object_signal_emit(ad->entryinfo.editfield,
1803 "elm,state,eraser,show", "elm");
1807 /* Get entry string. */
1808 GL_CHECK(ad->entryinfo.imf_entry);
1809 entry_str = elm_entry_entry_get(ad->entryinfo.imf_entry);
1810 GL_CHECK(entry_str);
1812 * Changes entry string to utf-8 encoding format,
1813 * other some special characters cannot be showed correctly.
1815 char *entry_utf8 = elm_entry_markup_to_utf8(entry_str);
1816 GL_CHECK(entry_utf8);
1818 * Removes leading and trailing whitespace
1819 * to avoid showing popup when new name is only composed by space
1820 * or avoid showing popup in the case when after trip leading and trailing space,
1821 * new name is same as existing name
1823 g_strstrip((gchar*)entry_utf8);
1824 GL_CHECK(entry_utf8);
1825 gl_dbg("New entry string without space: [%s]", entry_utf8);
1827 bool b_disabled = false;
1829 * If entry string is empty, disable 'Done' button,
1830 * including create album and rename album.
1832 if (!strlen(entry_utf8)) {
1833 gl_dbg("Entry string is empty!");
1837 gl_dbg("En/Disable Done button[%d]", b_disabled);
1838 elm_object_disabled_set(ad->entryinfo.done_btn, b_disabled);
1840 /* Free string got from elm_entry_markup_to_utf8() */
1847 int gl_ui_cancel_rename_album(void *data)
1849 GL_CHECK_VAL(data, -1);
1851 __gl_ui_rename_album_cancel_cb(data, NULL, NULL);
1857 gl_ui_cancel_new_album(void *data)
1859 GL_CHECK_VAL(data, -1);
1861 _gl_ui_newalbum_cancel_cb(data, NULL, NULL);
1867 gl_ui_move_to_newalbum(void *data)
1869 GL_CHECK_VAL(data, -1);
1870 gl_appdata *ad = (gl_appdata *)data;
1871 Evas_Object *editfield_ly = NULL;
1874 ad->entryinfo.entry_mode = GL_ENTRY_NEW_ALBUM;
1875 editfield_ly = gl_ui_create_view_ly(ad->maininfo.navi_bar);
1876 Evas_Object *entry_ly = _gl_ui_create_editfield(ad, editfield_ly, NULL);
1877 evas_object_smart_callback_add(ad->entryinfo.imf_entry, "activated",
1878 _gl_ui_newalbum_enter_cb, ad);
1879 elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry_ly);
1880 edje_object_signal_emit(_EDJ(editfield_ly),
1881 "elm,swallow_view,state,default", "elm");
1882 ad->entryinfo.imf_ly = NULL;
1883 gl_ui_create_title_and_push(ad, ad->maininfo.navi_bar, editfield_ly,
1884 GL_NAVI_ALBUMS_NEW, GL_STR_NEW_ALBUM);
1885 elm_entry_cursor_line_end_set(ad->entryinfo.imf_entry);
1886 elm_object_focus_set(ad->entryinfo.imf_entry, TRUE);
1887 ecore_imf_context_input_panel_show(ad->entryinfo.imf_context);
1892 int gl_ui_rename_album(gl_cluster *album_item)
1894 GL_CHECK_VAL(album_item, -1);
1895 GL_CHECK_VAL(album_item->cluster, -1);
1896 GL_CHECK_VAL(album_item->cluster->display_name, -1);
1897 GL_CHECK_VAL(album_item->ad, -1);
1898 gl_appdata *ad = (gl_appdata *)album_item->ad;
1899 int view_mode = gl_get_view_mode(ad);
1900 Evas_Object *editfield_ly = NULL;
1901 Evas_Object *entry_ly = NULL;
1903 if(ad->maininfo.rename_album_job) {
1904 ecore_job_del(ad->maininfo.rename_album_job);
1905 ad->maininfo.rename_album_job = NULL;
1907 if (view_mode != GL_VIEW_ALBUMS_EDIT) {
1908 gl_dbgE("Unexpected view mode(%d)!", view_mode);
1912 /* save album selected for rename */
1913 ad->albuminfo.selected_album = album_item;
1915 gl_set_view_mode(ad, GL_VIEW_ALBUMS_RENAME);
1917 editfield_ly = gl_ui_create_view_ly(ad->maininfo.navi_bar);
1918 entry_ly = _gl_ui_create_editfield(ad, editfield_ly,
1919 album_item->cluster->display_name);
1920 evas_object_smart_callback_add(ad->entryinfo.imf_entry, "activated",
1921 __gl_ui_rename_album_enter_cb, ad);
1922 elm_object_part_content_set(editfield_ly, "elm.swallow.view", entry_ly);
1923 edje_object_signal_emit(_EDJ(editfield_ly),
1924 "elm,swallow_view,state,default", "elm");
1925 ad->entryinfo.imf_ly = NULL;
1926 gl_ui_create_title_and_push(ad, ad->maininfo.navi_bar, editfield_ly,
1927 GL_NAVI_ALBUMS_RENAME, GL_STR_CHNAGE_NAME);
1928 elm_entry_cursor_line_end_set(ad->entryinfo.imf_entry);
1929 elm_object_focus_set(ad->entryinfo.editfield, TRUE);
1930 ecore_imf_context_input_panel_show(ad->entryinfo.imf_context);
1934 int gl_ui_create_title_and_push(void *data, Evas_Object *parent,
1935 Evas_Object *obj, gl_navi_mode mode, char *title)
1937 GL_CHECK_VAL(obj, -1);
1938 GL_CHECK_VAL(parent, -1);
1939 GL_CHECK_VAL(data, -1);
1941 if (mode == GL_NAVI_ALBUMS)
1942 __gl_ui_push_view_albums(data, parent, obj, title);
1943 else if (mode == GL_NAVI_ALBUMS_EDIT)
1944 __gl_ui_push_view_albums_edit(data, parent, obj, title);
1945 else if (mode == GL_NAVI_THUMBS)
1946 __gl_ui_push_view_thumbs(data, parent, obj, title);
1947 else if (mode == GL_NAVI_THUMBS_EDIT)
1948 __gl_ui_push_view_thumbs_edit(data, parent, obj, title);
1949 else if (mode == GL_NAVI_ALBUMS_RENAME)
1950 __gl_ui_push_view_albums_rename(data, parent, obj, title);
1951 else if (mode == GL_NAVI_ALBUMS_NEW)
1952 __gl_ui_push_view_albums_new(data, parent, obj, title);
1958 gl_ui_display_nocontents(void *data)
1960 GL_CHECK_VAL(data, -1);
1961 gl_appdata *ad = (gl_appdata *)data;
1963 return _gl_ui_display_nocontents(ad);
1967 gl_ui_load_edj(Evas_Object * parent, const char *file, const char *group)
1969 Evas_Object *eo = NULL;
1972 eo = elm_layout_add(parent);
1975 r = elm_layout_file_set(eo, file, group);
1978 evas_object_del(eo);
1982 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1983 evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
1989 int gl_ui_edit_cancel(void *data)
1991 GL_CHECK_VAL(data, -1);
1992 gl_appdata *ad = (gl_appdata *)data;
1993 int view_mode = gl_get_view_mode(ad);
1994 Elm_Object_Item *nf_it = NULL;
1996 if (view_mode == GL_VIEW_ALBUMS_EDIT ||
1997 view_mode == GL_VIEW_ALBUMS_RENAME) {
1998 if (view_mode != GL_VIEW_ALBUMS_EDIT) {
1999 gl_dbg("GL_VIEW_ALBUMS_xxx->Edit");
2000 gl_set_view_mode(ad, GL_VIEW_ALBUMS_EDIT);
2002 nf_it = ad->albuminfo.nf_it;
2003 } else if (view_mode == GL_VIEW_THUMBS_EDIT ||
2004 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
2005 nf_it = ad->gridinfo.nf_it;
2007 elm_naviframe_item_pop_to(nf_it);
2008 _gl_ui_edit_cancel_cb(ad, NULL, NULL);
2013 /* Back to normal thumbnail view */
2014 int gl_ui_back_to_normal(void *data)
2016 GL_CHECK_VAL(data, -1);
2017 gl_appdata *ad = (gl_appdata *)data;
2018 _gl_destroy_thumbs_edit_view(ad);
2019 elm_naviframe_item_pop_to(ad->gridinfo.nf_it);
2020 _gl_ui_edit_cancel_cb(ad, NULL, NULL);
2025 Evas_Object *gl_ui_create_nocontents_full(void *data)
2027 GL_CHECK_NULL(data);
2028 gl_appdata *ad = (gl_appdata *)data;
2029 Evas_Object *noc_lay = NULL;
2030 char label_str[GL_POPUP_DESC_LEN_MAX] = { 0, };
2032 if (ad->maininfo.app_exit_mode == GL_APP_EXIT_NONE) {
2033 int grid_mode = ad->gridinfo.grid_view_mode;
2034 switch (grid_mode) {
2036 snprintf(label_str, sizeof(label_str), "%s",
2037 (char *)(GL_STR_NO_ITEMS));
2039 case GL_GRID_VIDEOS:
2040 snprintf(label_str, sizeof(label_str), "%s",
2041 (char *)(GL_STR_NO_VIDEOS));
2043 case GL_GRID_IMAGES:
2044 snprintf(label_str, sizeof(label_str), "%s",
2045 (char *)(GL_STR_NO_IMAGES));
2047 case GL_GRID_ALBUMS:
2048 snprintf(label_str, sizeof(label_str), "%s",
2049 (char *)(GL_STR_NO_ALBUMS));
2052 snprintf(label_str, sizeof(label_str), "%s",
2053 (char *)(GL_STR_NO_CONTENTS));
2057 /* It's in Usb Mass Storage mode */
2058 snprintf(label_str, sizeof(label_str), "%s<br>%s",
2059 (char *)(GL_STR_NO_CONTENTS),
2060 (char *)(GL_STR_UNABLE_USE_IN_UMS_MODE));
2063 gl_dbg("Nocontents label: %s", label_str);
2064 /* Full view nocontents */
2065 noc_lay = elm_layout_add(ad->maininfo.navi_bar);
2066 GL_CHECK_NULL(noc_lay);
2067 elm_object_part_text_set(noc_lay, "elm.text", label_str);
2068 elm_layout_theme_set(noc_lay, "layout", "nocontents", "gallery");
2074 * Add new notify widget, select-all widget and set view state.
2076 * b_update, if true, update text only, other recreate notify widget
2078 int gl_ui_create_selinfo(void *data, Evas_Object *parent, Elm_Object_Item *nf_it,
2079 int all_cnt, int selected_cnt, bool b_update)
2081 GL_CHECK_VAL(parent, -1);
2082 GL_CHECK_VAL(data, -1);
2083 GL_CHECK_VAL(nf_it, -1);
2084 gl_appdata *ad = (gl_appdata *)data;
2085 char text[GL_POPUP_DESC_LEN_MAX] = { 0, };
2087 gl_dbg("selected_cnt/all_cnt = %d/%d", selected_cnt, all_cnt);
2088 if (selected_cnt > all_cnt) {
2089 gl_ui_destroy_selinfo(ad);
2090 gl_dbgE("selected_cnt > all_cnt!");
2094 /* Create new notify widget */
2095 if (b_update == false)
2096 _gl_ui_add_notify(ad, parent, true);
2098 /* Reuse old notify widget in update case */
2099 GL_CHECK_VAL(ad->popupinfo.selinfo, -1);
2100 GL_CHECK_VAL(ad->popupinfo.selinfo_ly, -1);
2102 /* Update state of checkbox in select-all widget */
2103 _gl_ui_update_selall(ad, all_cnt, selected_cnt);
2105 /* Update notify widget and view related to it */
2106 _gl_ui_update_view_selinfo(ad, selected_cnt);
2108 if (selected_cnt > 0) {
2109 /* Enable/Disable control bar buttons */
2110 _gl_ui_enable_toolbar_items(ad, nf_it);
2111 snprintf(text, sizeof(text), "%s (%d)", GL_STR_SELECTED,
2113 /* Set the text for notify */
2114 edje_object_part_text_set(_EDJ(ad->popupinfo.selinfo_ly),
2116 evas_object_show(ad->popupinfo.selinfo);
2118 /* Disable control bar buttons */
2119 gl_ui_disable_toolbar_items(ad, nf_it);
2120 gl_ui_destroy_selinfo(ad);
2127 gl_ui_destroy_selinfo(void *data)
2129 GL_CHECK_VAL(data, -1);
2130 gl_appdata *ad = (gl_appdata *)data;
2132 /* The selectioninfo_ly was filled in selectioninfo, so delete selectioninfo_ly first. */
2133 if (ad->popupinfo.selinfo_ly)
2135 evas_object_del(ad->popupinfo.selinfo_ly);
2136 ad->popupinfo.selinfo_ly = NULL;
2139 if (ad->popupinfo.selinfo)
2141 evas_object_smart_callback_del(ad->popupinfo.selinfo,
2142 "timeout", _gl_ui_selinfo_destroy_cb);
2143 evas_object_del(ad->popupinfo.selinfo);
2144 ad->popupinfo.selinfo = NULL;
2151 * Update checkbox state and add click signal to Select-all widget.
2152 * Show arrow button in thumbnails/list edit mode.
2154 int gl_ui_show_selall(void *data)
2156 GL_CHECK_VAL(data, -1);
2157 gl_appdata *ad = (gl_appdata *)data;
2158 int view_mode = gl_get_view_mode(ad);
2159 Eina_Bool ck_state = EINA_FALSE;
2160 Evas_Object *view_ly = NULL;
2161 char *sig = "selectall_show";
2163 gl_dbg("view_mode: %d.", view_mode);
2164 if (view_mode == GL_VIEW_THUMBS_EDIT ||
2165 view_mode == GL_VIEW_VIDEOLIST_EDIT) {
2166 view_ly = ad->gridinfo.edit_layout;
2167 if (ad->maininfo.medias_cnt == gl_db_selected_list_count(ad))
2168 ck_state = EINA_TRUE;
2169 if (view_mode == GL_VIEW_VIDEOLIST_EDIT)
2170 sig = "selectall_show_video";
2172 gl_dbgE("Wrong view!");
2176 const char *text = NULL;
2177 text = edje_object_part_text_get(_EDJ(view_ly), "selectall_text");
2178 if (text == NULL || g_strcmp0(text, GL_STR_SELECT_ALL))
2179 edje_object_part_text_set(_EDJ(view_ly), "selectall_text",
2182 Evas_Object *old_check = NULL;
2183 old_check = elm_object_part_content_unset(view_ly, "selectall_check");
2185 evas_object_del(old_check);
2187 Evas_Object *check = elm_check_add(view_ly);
2188 elm_object_style_set(check, GL_CHECKBOX_STYLE_DEFAULT);
2189 evas_object_propagate_events_set(check, EINA_FALSE);
2190 elm_check_state_set(check, ck_state);
2192 elm_object_part_content_set(view_ly, "selectall_check", check);
2193 evas_object_smart_callback_add(check, "changed",
2194 _gl_ui_selall_check_changed, ad);
2195 edje_object_signal_emit(_EDJ(view_ly), sig, "elm");
2197 /* Add signal to select-all bg */
2198 edje_object_signal_callback_del(_EDJ(view_ly), "elm,action,click",
2200 _gl_ui_selall_bg_click_cb);
2201 edje_object_signal_callback_add(_EDJ(view_ly), "elm,action,click",
2203 _gl_ui_selall_bg_click_cb, ad);
2208 /* Update checkbox state of Select-all and selectioninfo */
2209 int gl_ui_update_select_widgets(void *data)
2211 GL_CHECK_VAL(data, -1);
2212 gl_appdata *ad = (gl_appdata *)data;
2213 /* Update checkbox state of Select-all */
2214 gl_ui_show_selall(ad);
2215 /* Update selectioninfo */
2216 int cnt = ad->maininfo.medias_cnt;
2217 int sel_cnt = gl_db_selected_list_count(ad);
2218 gl_ui_create_selinfo(ad, ad->gridinfo.edit_layout,
2219 ad->gridinfo.nf_it_edit, cnt, sel_cnt, false);
2223 int gl_ui_create_notiinfo(void *data, Evas_Object *parent,
2224 gl_ui_notify_mode n_mode)
2226 GL_CHECK_VAL(parent, -1);
2227 GL_CHECK_VAL(data, -1);
2228 gl_appdata *ad = (gl_appdata *)data;
2229 const char *text = NULL;
2232 _gl_ui_add_notify(ad, parent, false);
2233 GL_CHECK_VAL(ad->popupinfo.selinfo, -1);
2234 GL_CHECK_VAL(ad->popupinfo.selinfo_ly, -1);
2236 edje_object_signal_emit(_EDJ(ad->popupinfo.selinfo_ly),
2237 "elm,selectioninfo,portrait", "elm");
2240 case GL_UI_NOTIFY_DELETED:
2241 text = GL_STR_DELETED;
2243 case GL_UI_NOTIFY_REMOVED:
2244 text = GL_STR_REMOVED;
2246 case GL_UI_NOTIFY_ADDED:
2247 text = GL_STR_ADDED;
2249 case GL_UI_NOTIFY_MOVED:
2250 text = GL_STR_MOVED;
2253 gl_dbgE("GL_UI_NOTIFY_xxx, Error mode!");
2257 edje_object_part_text_set(_EDJ(ad->popupinfo.selinfo_ly), "elm.text",
2259 evas_object_show(ad->popupinfo.selinfo);
2265 gl_ui_destroy_notiinfo(void *data)
2267 GL_CHECK_VAL(data, -1);
2268 gl_appdata *ad = (gl_appdata *)data;
2270 /* The selectioninfo_ly was filled in selectioninfo, so delete selectioninfo_ly first. */
2271 if (ad->popupinfo.selinfo_ly)
2273 evas_object_del(ad->popupinfo.selinfo_ly);
2274 ad->popupinfo.selinfo_ly = NULL;
2277 if (ad->popupinfo.selinfo)
2279 evas_object_smart_callback_del(ad->popupinfo.selinfo,
2280 "timeout", _gl_ui_notiinfo_destroy_cb);
2281 evas_object_del(ad->popupinfo.selinfo);
2282 ad->popupinfo.selinfo = NULL;
2288 int gl_ui_destroy_imf(void *data)
2290 GL_CHECK_VAL(data, -1);
2291 gl_appdata *ad = (gl_appdata *)data;
2292 int view_mode = gl_get_view_mode(ad);
2293 gl_dbg("view_mode = %d", view_mode);
2295 if (ad->entryinfo.imf_entry) {
2296 evas_object_smart_callback_del(ad->entryinfo.imf_entry,
2297 "maxlength,reached",
2298 __gl_ui_entry_maxlen_reached_cb);
2299 if (ad->entryinfo.entry_mode == GL_ENTRY_NEW_ALBUM)
2300 evas_object_smart_callback_del(ad->entryinfo.imf_entry,
2302 _gl_ui_newalbum_enter_cb);
2304 evas_object_smart_callback_del(ad->entryinfo.imf_entry,
2306 __gl_ui_entry_space_check_cb);
2308 ad->entryinfo.entry_mode = GL_ENTRY_NONE;
2310 if (ad->entryinfo.imf_context)
2311 ecore_imf_context_input_panel_hide(ad->entryinfo.imf_context);
2313 if (ad->entryinfo.editfield)
2314 evas_object_hide(ad->entryinfo.editfield);
2316 if (ad->entryinfo.imf_ly) {
2317 evas_object_del(ad->entryinfo.imf_ly);
2318 ad->entryinfo.imf_ly = NULL;
2321 ad->entryinfo.imf_entry = NULL;
2322 ad->entryinfo.imf_context = NULL;
2323 ad->entryinfo.editfield = NULL;
2328 Evas_Object *gl_ui_create_main_ly(Evas_Object *parent)
2330 GL_CHECK_NULL(parent);
2331 Evas_Object *layout = NULL;
2333 layout = elm_layout_add(parent);
2334 GL_CHECK_NULL(layout);
2336 elm_layout_theme_set(layout, "layout", "application", "default");
2337 evas_object_size_hint_weight_set(layout,
2338 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2339 elm_win_resize_object_add(parent, layout);
2340 evas_object_show(layout);
2345 Evas_Object *gl_ui_create_naviframe(Evas_Object *parent)
2347 GL_CHECK_NULL(parent);
2348 Evas_Object *navi_bar = NULL;
2350 navi_bar = elm_naviframe_add(parent);
2351 gl_dbg("elm_naviframe_add:done");
2352 /* Use custom style to set bg color black(0 0 0 255). */
2353 elm_object_style_set(navi_bar, GL_NAVIBAR_STYLE_DEFAULT);
2354 evas_object_show(navi_bar);
2355 gl_dbg("elm_object_style_set: done");
2360 Evas_Object *gl_ui_create_view_ly(Evas_Object *parent)
2363 GL_CHECK_NULL(parent);
2365 Evas_Object *layout = NULL;
2366 layout = gl_ui_load_edj(parent, GL_EDJ_FILE, GL_GRP_VIEW_LAYOUT);
2367 GL_CHECK_NULL(layout);
2368 evas_object_show(layout);
2373 int _gl_ui_elm_bg_file_set(Evas_Object *bg, gl_item *git)
2375 if (git == NULL || git->item == NULL || git->ad == NULL) {
2376 gl_dbgE("Invalid item :%p", git);
2377 elm_bg_file_set(bg, GL_DEFAULT_THUMB_ICON, NULL);
2382 path = _gl_get_thumb(git->ad, git->item->file_url,
2383 &git->item->thumb_url);
2385 elm_bg_file_set(bg, path, NULL);
2389 elm_bg_file_set(bg, git->item->thumb_url, NULL);