2 * Copyright 2013 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.
22 #include "mf-widget.h"
23 #include "mf-gengrid.h"
26 #include "mf-fm-svc-wrapper.h"
27 #include "mf-launch.h"
28 #include "mf-language-mgr.h"
29 #include "mf-tray-item.h"
31 #define MF_SEARCH_OPTION_DEF (MF_SEARCH_OPT_DIR | MF_SEARCH_OPT_FILE)
32 #define MF_SEARCH_ROOT_NUM 1
33 #define MF_SEARCH_TIMER_INTERVAL 0.5
35 extern Elm_Genlist_Item_Class itc, userfolderitc;
36 extern Elm_Genlist_Item_Class categoryitc;
38 extern Elm_Gengrid_Item_Class gic;
39 extern Elm_Gengrid_Item_Class search_itc;
40 extern int flagSearchMsg;
41 extern pthread_mutex_t gLockSearchMsg;
42 extern pthread_cond_t gCondSearchMsg;
44 Elm_Gengrid_Item_Class g_search_all_itc;
45 Elm_Gengrid_Item_Class search_all_itc;
50 } mf_search_detail_infor_s;
52 static void __mf_search_bar_click_item(struct appdata *data, GString * path)
55 struct appdata *ap = data;
57 if (ap->mf_Status.path == NULL || ap->mf_Status.path->str == NULL) {
60 GString *new_path = NULL;
66 if (ap->mf_Status.more == MORE_RENAME) {
67 mf_genlist_rename_done(ap, NULL, NULL);
70 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
71 mf_retm_if(pNavi_s == NULL, "get navi structure failed");
72 if (ap->mf_Status.search_handler > 0) {
73 mf_search_stop(ap->mf_Status.search_handler);
74 mf_search_finalize(&ap->mf_Status.search_handler);
77 error_code = mf_util_is_mmc_on(&mmc_card);
79 if (mf_fm_svc_wrapper_is_dir(path)) {
81 if (ap->mf_FileOperation.search_result_list) {
82 mf_util_free_eina_list_with_data(&(ap->mf_FileOperation.search_result_list), MYFILE_TYPE_CHAR);
84 elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_FALSE);
86 ap->mf_Status.view_type = mf_view_normal;
87 ap->mf_Status.more = MORE_DEFAULT;
88 new_path = g_string_new(path->str);
89 mf_debug("path is %s\n", ap->mf_Status.path->str);
92 g_string_free(ap->mf_Status.path, TRUE);
93 ap->mf_Status.path = NULL;
95 ap->mf_Status.path = new_path;
97 if (pNavi_s->pCurrentPath != NULL) {
98 free(pNavi_s->pCurrentPath);
99 pNavi_s->pCurrentPath = NULL;
101 pNavi_s->pCurrentPath = g_strdup(new_path->str);
103 mf_widget_refresh_view(ap);
105 struct timeval mytime;
106 gettimeofday(&mytime, NULL);
107 mf_debug("[myfiles click time] %ld sec %ld usec \n", mytime.tv_sec, mytime.tv_usec);
110 ret = mf_launch_service(ap, path->str);
111 mf_debug("ret is %d\n", ret);
113 ap->mf_MainWindow.pNormalPopup =
114 mf_popup_create_popup(ap, POPMODE_TEXT, NULL, GET_SYS_STR(MF_LABEL_UNSUPPORT_FILE_TYPE), NULL, NULL, NULL, NULL, NULL);
120 static void __mf_search_bar_item_sel(void *data, Evas_Object * obj, void *event_info)
125 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
127 mfItemData_s *selected = (mfItemData_s *) elm_object_item_data_get(item);
129 elm_genlist_item_selected_set(item, FALSE);
130 __mf_search_bar_click_item(data, selected->m_ItemName);
134 static void __mf_search_bar_grid_item_sel(void *data, Evas_Object * obj, void *event_info)
136 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
138 mfItemData_s *selected = (mfItemData_s *) elm_object_item_data_get(item);
139 mf_retm_if(selected == NULL, "selected is NULL");
140 mf_retm_if(selected->m_ItemName == NULL, "selected->m_ItemName is NULL");
141 mf_retm_if(selected->m_ItemName->str == NULL, "selected->m_ItemName->str is NULL");
143 __mf_search_bar_click_item(data, selected->m_ItemName);
147 static void __mf_search_bar_sel_search_all(void *data, Evas_Object * obj, void *event_info)
149 mf_search_bar_search_started_callback(data, NULL, NULL);
152 static Evas_Object *_gl_content_get(void *data, Evas_Object * obj, const char *part)
155 mf_debug("part is [%s]", part);
156 if (!strcmp(part, "elm.icon")) {
157 Evas_Object *btn = elm_button_add(obj);
158 elm_object_text_set(btn, GET_STR(MF_LABEL_SEARCH_ALL));
159 evas_object_smart_callback_add(btn, "clicked", __mf_search_bar_sel_search_all, data);
162 } else if(!strcmp(part, "elm.swallow.icon")) {
163 Evas_Object *btn = elm_button_add(obj);
164 elm_object_text_set(btn, GET_STR(MF_LABEL_SEARCH_ALL));
165 evas_object_smart_callback_add(btn, "clicked", __mf_search_bar_sel_search_all, data);
172 void mf_search_bar_search_all_item_append(void *data)
176 struct appdata *ap = (struct appdata *)data;
177 mf_retm_if(ap == NULL, "input data error");
179 if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_THUMBNAIL) {
181 Elm_Gengrid_Item_Class *itc = elm_gengrid_item_class_new();
182 itc->item_style = "default_gridtext";
183 itc->func.text_get = NULL;
184 itc->func.content_get = _gl_content_get;
185 itc->func.state_get = NULL;
186 itc->func.del = NULL;
188 elm_gengrid_item_append(ap->mf_MainWindow.pNaviGengrid, itc, ap, NULL, NULL);
191 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
192 itc->item_style = "1icon";
193 itc->func.text_get = NULL;
194 itc->func.content_get = _gl_content_get;
195 itc->func.state_get = NULL;
196 itc->func.del = NULL;
197 elm_genlist_item_append(ap->mf_MainWindow.pNaviGenlist, itc, ap, NULL,
198 ELM_GENLIST_ITEM_NONE, NULL, NULL);
200 ap->mf_Status.flagSearchAll = EINA_TRUE;
202 void mf_search_bar_item_append(void *data, void *user_data)
205 struct appdata *ap = (struct appdata *)user_data;
206 mf_retm_if(ap == NULL, "input data error");
207 char *item_name = (char *)data;
208 mf_retm_if(item_name == NULL, "input item_name error");
209 mfItemData_s *m_TempItem = NULL;
211 GString *search_path = g_string_new(item_name);
213 g_string_free(search_path, TRUE);
215 if (ap->mf_Status.view_type == mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) {
216 mf_util_generate_list(&ap->mf_FileOperation.category_list, item_name, FILE_TYPE_FILE);
218 m_TempItem = (mfItemData_s *) malloc(sizeof(mfItemData_s));
220 if (m_TempItem == NULL) {
223 memset(m_TempItem, 0, sizeof(mfItemData_s));
225 m_TempItem->m_ItemName = g_string_new(item_name);
226 m_TempItem->size = NULL;
227 m_TempItem->create_date = NULL;
228 m_TempItem->m_checked = FALSE;
229 m_TempItem->pCheckBox = NULL;
230 m_TempItem->thumb_path = NULL;
231 m_TempItem->real_thumb_flag = FALSE;
232 m_TempItem->unregister_lang_mgr = TRUE;
233 m_TempItem->media = NULL;
236 /*delete timer if exists*/
238 if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_THUMBNAIL) {
239 Elm_Object_Item *git = NULL;
240 git = elm_gengrid_item_append(ap->mf_MainWindow.pNaviGengrid, &gic, m_TempItem, __mf_search_bar_grid_item_sel, ap);
241 mf_language_mgr_register_gengrid_item(git);
242 m_TempItem->item = git;
246 Elm_Object_Item *it = NULL;
247 if (ap->mf_Status.view_type == mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) {
248 it = elm_genlist_item_append(ap->mf_MainWindow.pNaviGenlist, &categoryitc, m_TempItem, NULL,
249 ELM_GENLIST_ITEM_NONE, mf_genlist_gl_sel, m_TempItem);
251 it = elm_genlist_item_append(ap->mf_MainWindow.pNaviGenlist, &search_itc, m_TempItem, NULL,
252 ELM_GENLIST_ITEM_NONE, __mf_search_bar_item_sel, ap);
254 m_TempItem->item = it;
257 mf_debug("get is [%d]", elm_genlist_items_count(ap->mf_MainWindow.pNaviGenlist));
262 static void __mf_search_bar_genlist_del_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
265 struct appdata *ap = (struct appdata *)data;
266 mf_retm_if(ap == NULL, "ap is NULL");
267 if(ap->mf_MainWindow.pSearchViewTimer) {
268 ecore_timer_del(ap->mf_MainWindow.pSearchViewTimer);
269 ap->mf_MainWindow.pSearchViewTimer = NULL;
274 static void __mf_search_bar_result_cb(mf_search_result_t *result, void *user_data)
277 mf_retm_if(result == NULL, "result is NULL");
279 struct appdata *ap = (struct appdata *)user_data;
280 mf_retm_if(ap == NULL, "ap is NULL");
282 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
283 mf_retm_if(pNavi_s == NULL, "pNavi_s is NULL");
285 Evas_Object *pSearchBarLabel = NULL;
287 if (ap->mf_Status.view_type != mf_view_root_category) {
288 elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_TRUE);
291 #ifdef MYFILE_SPLIT_VIEW
292 if (ap->mf_FileOperation.search_result_list) {
293 mf_util_free_eina_list_with_data(&(ap->mf_FileOperation.search_result_list), MYFILE_TYPE_CHAR);
296 if (ap->mf_Status.view_type == mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) {
297 if (ap->mf_FileOperation.category_list) {
298 mf_util_free_eina_list_with_data(&(ap->mf_FileOperation.category_list), MYFILE_TYPE_FSNODE);
302 if (g_list_length(result->dir_list) + g_list_length(result->file_list) == 0) {
304 Evas_Object *parent = NULL;
305 parent = ap->mf_MainWindow.pNaviLayout;
306 ap->mf_Status.flagNoContent = EINA_TRUE;
307 pSearchBarLabel = mf_widget_create_no_content(parent);
308 elm_object_part_text_set(pSearchBarLabel, "elm.text", GET_SYS_STR(LABEL_NO_RESULT));
310 if (ap->mf_Status.view_type != mf_view_root_category) {
311 elm_object_part_content_set(parent, "content", pSearchBarLabel);
313 elm_object_part_content_set(parent, "content", pSearchBarLabel);
314 Evas_Object *btn = mf_widget_get_part_content(ap->mf_MainWindow.pNaviBar, NAVI_BOTTOM_BUTTON_1_PART);
315 elm_object_disabled_set(btn, EINA_TRUE);
319 ap->mf_Status.flagNoContent = EINA_FALSE;
320 if (ap->mf_Status.view_type == mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) {
321 mf_genlist_set_category_list_style();
322 mf_navi_bar_title_set(ap);
324 if (ap->mf_Status.flagViewType == MF_VIEW_STYLE_LIST || ap->mf_Status.flagViewType == MF_VIEW_SYTLE_LIST_DETAIL) {
325 if (ap->mf_MainWindow.pNaviGenlist == NULL) {
326 ap->mf_MainWindow.pNaviGenlist = elm_genlist_add(ap->mf_MainWindow.pNaviLayout);
328 elm_genlist_clear(ap->mf_MainWindow.pNaviGenlist);
330 elm_genlist_mode_set(ap->mf_MainWindow.pNaviGenlist, ELM_LIST_COMPRESS);
331 elm_object_focus_set(ap->mf_MainWindow.pNaviGenlist, EINA_FALSE);
332 evas_object_size_hint_weight_set(ap->mf_MainWindow.pNaviGenlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
333 evas_object_size_hint_align_set(ap->mf_MainWindow.pNaviGenlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
335 //elm_genlist_homogeneous_set(ap->mf_MainWindow.pNaviGenlist, EINA_TRUE);
336 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,right", mf_genlist_gl_mode_sweep_set, ap);
337 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,left", mf_genlist_gl_mode_sweep_unset, ap);
338 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,up", mf_genlist_gl_mode_cancel, ap);
339 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,start,down", mf_genlist_gl_mode_cancel, ap);
340 //evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "drag,stop", mf_genlist_gl_mode_sweep_stop, NULL);
341 if (ap->mf_Status.view_type == mf_view_root_category && ap->mf_Status.more != MORE_SEARCH) {
342 evas_object_smart_callback_add(ap->mf_MainWindow.pNaviGenlist, "selected", mf_genlist_gl_selected, ap);
344 evas_object_event_callback_add(ap->mf_MainWindow.pNaviGenlist,EVAS_CALLBACK_FREE, __mf_search_bar_genlist_del_cb, ap);
345 evas_object_show(ap->mf_MainWindow.pNaviGenlist);
346 mfNaviBarSetContent(ap, ap->mf_MainWindow.pNaviLayout, ap->mf_MainWindow.pNaviGenlist);
348 if (ap->mf_MainWindow.pNaviGengrid == NULL) {
349 ap->mf_MainWindow.pNaviGengrid = mf_gengrid_create_grid(ap->mf_MainWindow.pNaviLayout);
351 elm_gengrid_clear(ap->mf_MainWindow.pNaviGengrid);
352 if (MF_SCALE_FACTORY == 1) {
353 elm_gengrid_item_size_set(ap->mf_MainWindow.pNaviGengrid, MF_HD_GENGRID_ITEM_WIDTH, MF_HD_GENGRID_ITEM_HEIGTH);
355 elm_gengrid_item_size_set(ap->mf_MainWindow.pNaviGengrid, MF_WVGA_GENGRID_ITEM_WIDTH, MF_WVGA_GENGRID_ITEM_HEIGTH);
357 evas_object_show(ap->mf_MainWindow.pNaviGengrid);
358 mfNaviBarSetContent(ap, ap->mf_MainWindow.pNaviLayout, ap->mf_MainWindow.pNaviGengrid);
360 if (result->dir_list != NULL) {
361 g_list_foreach(result->dir_list, mf_search_bar_item_append, ap);
363 if (result->file_list != NULL) {
364 g_list_foreach(result->file_list, mf_search_bar_item_append, ap);
370 static void __mf_search_bar_stop_cb(void *data, Evas_Object * obj, void *event_info)
372 struct appdata *ap = (struct appdata *)data;
373 mf_retm_if(ap == NULL, "input data error");
375 Evas_Object *btn = (Evas_Object *)obj;
376 const char *label = elm_object_text_get(btn);
378 if (g_strcmp0(label, GET_SYS_STR(LABEL_CANCEL)) == 0 ) {
379 if (ap->mf_FileOperation.sync_pipe != NULL) {
380 ecore_pipe_del(ap->mf_FileOperation.sync_pipe);
381 ap->mf_FileOperation.sync_pipe = NULL;
384 __mf_search_bar_result_cb(((ms_handle_t *) ap->mf_Status.search_handler)->result, ap);
386 if (ap->mf_Status.search_handler > 0) {
387 mf_search_stop(ap->mf_Status.search_handler);
390 evas_object_del(ap->mf_MainWindow.pNormalPopup);
391 ap->mf_MainWindow.pNormalPopup = NULL;
393 if (ap->mf_Status.search_handler > 0) {
394 mf_search_finalize(&ap->mf_Status.search_handler);
399 static int __mf_search_bar_idle_search_msg_cope_finished(void *data)
401 pthread_mutex_lock(&gLockSearchMsg);
402 if (flagSearchMsg == 0) {
404 pthread_cond_signal(&gCondSearchMsg);
406 pthread_mutex_unlock(&gLockSearchMsg);
408 return ECORE_CALLBACK_CANCEL;
411 static void __mf_search_bar_pipe_cb(void *data, void *buffer, unsigned int nbyte)
414 struct appdata *ap = (struct appdata *)data;
416 mf_debug("input ap is NULL");
417 goto MF_CONTINURE_SEARCH;
420 mf_search_pipe_msg *pSearchMsg = (mf_search_pipe_msg *) buffer;
421 if (pSearchMsg == NULL) {
422 mf_debug("received message is NULL");
423 goto MF_CONTINURE_SEARCH;
426 if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_RESULT_REPORT) {
427 mf_debug("result get");
428 } else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_ROOT_CHANGE) {
429 mf_debug("path change %s", pSearchMsg->current_path);
430 char *new_desc = mf_fm_svc_wrapper_translate_path(pSearchMsg->current_path, MF_TRANS_OPTION_POPUP);
431 elm_object_text_set(ap->mf_MainWindow.pSearchLabel, new_desc);
432 if (pSearchMsg->current_path) {
433 free(pSearchMsg->current_path);
434 pSearchMsg->current_path = NULL;
436 if (new_desc != NULL) {
440 } else if (pSearchMsg->mf_sp_msg_type == MF_SEARCH_PIPE_MSG_FINISHED) {
441 evas_object_del(ap->mf_MainWindow.pNormalPopup);
442 ap->mf_MainWindow.pNormalPopup = NULL;
443 __mf_search_bar_result_cb((mf_search_result_t *) pSearchMsg->report_result, data);
447 ecore_idler_add((Ecore_Task_Cb)__mf_search_bar_idle_search_msg_cope_finished, NULL);
451 void mf_search_bar_category_search_start(void *data, int category)
454 mf_retm_if(data == NULL, "data is NULL");
455 struct appdata *ap = (struct appdata *)data;
456 int root_num = MF_SEARCH_ROOT_NUM;
458 mf_genlist_create_search_itc();
461 const char *SearchRoot[3] = {0};
462 SearchRoot[0] = PHONE_FOLDER;
463 if (ap->mf_Status.iStorageState & MYFILE_MMC) {
464 SearchRoot[root_num] = MEMORY_FOLDER;
467 if (ap->mf_Status.iStorageState & MYFILE_OTG) {
468 SearchRoot[root_num] = OTG_FOLDER;
472 char *new_desc = NULL;
473 /*Start Search routine*/
474 if (!mf_search_start(ap->mf_Status.search_handler, SearchRoot, root_num, \
475 NULL, MF_SEARCH_OPT_FILE, (void *)ap, mf_tray_item_type, category)) {
476 /*generate the popup used to show search path
477 **it's sure that new_desc is not NULL even if original path is NULL*/
478 new_desc = mf_fm_svc_wrapper_translate_path(ap->mf_Status.path->str, MF_TRANS_OPTION_POPUP);
479 ap->mf_MainWindow.pNormalPopup = mf_ug_popup_create_search(ap, __mf_search_bar_stop_cb, ap);
480 //mf_popup_create_popup(ap, POPMODE_TEXT_BTN_SEARCH, NULL, new_desc, NULL, NULL, NULL, __mf_search_bar_stop_cb, ap);
482 mf_debug("search failed");
485 if (new_desc != NULL) {
492 static bool __mf_search_bar_idle_search_start(void *data)
494 struct appdata *ap = (struct appdata *)data;
497 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
498 if (pNavi_s == NULL) {
499 ap->mf_FileOperation.search_IME_hide_timer = NULL;
500 mf_debug("pNavi_s is NULL");
501 return ECORE_CALLBACK_CANCEL;
505 mf_genlist_create_search_itc();
508 const char *SearchRoot[3] = {0};
509 if (ap->mf_Status.more == MORE_SEARCH) {
510 text = g_strdup(elm_object_text_get(ap->mf_MainWindow.pSearchEntry));
513 if (ap->mf_Status.view_type == mf_view_root || ap->mf_Status.view_type == mf_view_root_category) {
514 SearchRoot[0] = PHONE_FOLDER;
516 if (ap->mf_Status.iStorageState & MYFILE_MMC) {
517 SearchRoot[root_num] = MEMORY_FOLDER;
520 if (ap->mf_Status.iStorageState & MYFILE_OTG) {
521 SearchRoot[root_num] = OTG_FOLDER;
525 if (ap->mf_Status.flagSearchAll == EINA_FALSE) {
526 SearchRoot[0] = ap->mf_Status.path->str;
529 int root = mf_fm_svc_wrapper_is_root_path(ap->mf_Status.path->str);
532 SearchRoot[0] = PHONE_FOLDER;
535 SearchRoot[0] = MEMORY_FOLDER;
538 SearchRoot[0] = OTG_FOLDER;
541 SearchRoot[0] = PHONE_FOLDER;
547 mf_debug("search root is %s text is [%s]", ap->mf_Status.path->str, text);
548 char *new_desc = NULL;
549 /*Start Search routine*/
550 if (!mf_search_start(ap->mf_Status.search_handler, SearchRoot, root_num, \
551 ((text) ? text : NULL), MF_SEARCH_OPTION_DEF, (void *)ap, NULL, mf_tray_item_category_none)) {
552 /*generate the popup used to show search path
553 **it's sure that new_desc is not NULL even if original path is NULL*/
554 new_desc = mf_fm_svc_wrapper_translate_path(ap->mf_Status.path->str, MF_TRANS_OPTION_POPUP);
555 ap->mf_MainWindow.pNormalPopup = mf_ug_popup_create_search(ap, __mf_search_bar_stop_cb, ap);
556 //mf_popup_create_popup(ap, POPMODE_TEXT_BTN_SEARCH, NULL, new_desc, NULL, NULL, NULL, __mf_search_bar_stop_cb, ap);
559 if (new_desc != NULL) {
569 ap->mf_FileOperation.search_IME_hide_timer = NULL;
570 return ECORE_CALLBACK_CANCEL;
573 void mf_search_bar_enter_search_routine(void *data, Evas_Object * obj, void *event_info)
576 struct appdata *ap = (struct appdata *)data;
579 SAFE_FREE_OBJ(ap->mf_MainWindow.pContextPopup);
581 if (ap->mf_Status.more == MORE_RENAME) {
582 mf_genlist_rename_done(ap, NULL, NULL);
586 if (ap->mf_Status.more != MORE_DEFAULT) {
589 if (ap->mf_Status.flagNaviPush) {
590 mf_debug("the transition of the naviframe is not finished");
594 if (ap->mf_FileOperation.search_IME_hide_timer != NULL) {
595 ecore_timer_del(ap->mf_FileOperation.search_IME_hide_timer);
596 ap->mf_FileOperation.search_IME_hide_timer = NULL;
599 ap->mf_Status.more = MORE_SEARCH;
600 ap->mf_Status.flagSearchAll = EINA_FALSE;
602 mf_navi_bar_create_search_view(ap);
606 void mf_search_bar_category_search(void *data, int category)
609 struct appdata *ap = (struct appdata *)data;
610 mf_retm_if(ap == NULL, "input data error");
611 SAFE_FREE_CHAR(ap->mf_Status.search_filter);
612 if (ap->mf_Status.search_handler > 0)
613 mf_search_finalize(&ap->mf_Status.search_handler);
614 int ret = mf_search_init(&ap->mf_Status.search_handler);
615 mf_retm_if(ret < 0, "Fail to mf_search_init()");
617 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
618 mf_retm_if(pNavi_s == NULL, "input data error");
620 evas_object_del(mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "content"));
621 Evas_Object *tray = mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "swallow.shortcut");
623 ap->mf_MainWindow.pNaviGengrid = NULL;
624 ap->mf_MainWindow.pNaviGenlist = NULL;
626 if (ap->mf_FileOperation.sync_pipe != NULL) {
627 ecore_pipe_del(ap->mf_FileOperation.sync_pipe);
628 ap->mf_FileOperation.sync_pipe = NULL;
630 ap->mf_FileOperation.sync_pipe = ecore_pipe_add(__mf_search_bar_pipe_cb, ap);
632 if (ap->mf_FileOperation.sync_pipe == NULL) {
633 mf_debug("add pipe failed");
635 /*this is to init global variable to ensure the first message can be transmitted correctly*/
636 /*flagSearchMsg is to indicate the condition wait to sync data of threads*/
637 pthread_mutex_lock(&gLockSearchMsg);
639 pthread_mutex_unlock(&gLockSearchMsg);
641 /*delete guide text label in the box*/
642 mf_search_bar_category_search_start(ap, category);
643 mf_debug("enter pressed %d", category);
647 void mf_search_bar_search_started_callback(void *data, Evas_Object * obj, void *event_info)
650 struct appdata *ap = (struct appdata *)data;
651 mf_retm_if(ap == NULL, "input data error");
653 char *text = g_strdup(elm_object_text_get(ap->mf_MainWindow.pSearchEntry));
654 if (text == NULL || strlen(text) == 0 || strlen(g_strstrip(text)) == 0) {
657 SAFE_FREE_CHAR(ap->mf_Status.search_filter);
664 SAFE_FREE_CHAR(ap->mf_Status.search_filter);
665 ap->mf_Status.search_filter = g_strdup(elm_object_text_get(ap->mf_MainWindow.pSearchEntry));
666 if (ap->mf_Status.more == MORE_RENAME) {
667 mf_genlist_rename_done(ap, NULL, NULL);
671 if (ap->mf_Status.search_handler > 0)
672 mf_search_finalize(&ap->mf_Status.search_handler);
673 int ret = mf_search_init(&ap->mf_Status.search_handler);
674 mf_retm_if(ret < 0, "Fail to mf_search_init()");
676 myfileNaviBar *pNavi_s = mf_navi_bar_get_in_use(ap);
677 mf_retm_if(pNavi_s == NULL, "input data error");
680 elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_FALSE);
682 /*delete guide text label in the box*/
683 evas_object_del(mf_widget_unset_part_content(ap->mf_MainWindow.pNaviLayout, "content"));
685 ap->mf_MainWindow.pNaviGengrid = NULL;
686 ap->mf_MainWindow.pNaviGenlist = NULL;
688 if (ap->mf_FileOperation.sync_pipe != NULL) {
689 ecore_pipe_del(ap->mf_FileOperation.sync_pipe);
690 ap->mf_FileOperation.sync_pipe = NULL;
692 ap->mf_FileOperation.sync_pipe = ecore_pipe_add(__mf_search_bar_pipe_cb, ap);
694 if (ap->mf_FileOperation.sync_pipe == NULL) {
695 mf_debug("add pipe failed");
697 /*this is to init global variable to ensure the first message can be transmitted correctly*/
698 /*flagSearchMsg is to indicate the condition wait to sync data of threads*/
699 pthread_mutex_lock(&gLockSearchMsg);
701 pthread_mutex_unlock(&gLockSearchMsg);
703 elm_object_focus_set(ap->mf_MainWindow.pSearchEntry, EINA_FALSE);
704 /*delete guide text label in the box*/
705 ap->mf_FileOperation.search_IME_hide_timer = ecore_timer_add(MF_SEARCH_TIMER_INTERVAL, (Ecore_Task_Cb)__mf_search_bar_idle_search_start, ap);
706 mf_debug("enter pressed");