summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyuan Choi <ryuan.choi@gmail.com>2013-09-10 18:47:30 +0900
committerRyuan Choi <ryuan.choi@gmail.com>2013-09-10 19:11:43 +0900
commit87f58fb5c398445ccb14d9cf6210b4fdaa8301af (patch)
treeef3ee7c1a5e601ee869743b60854924754e7dab3
parent81f15c10865d7c7192a128cf431d31517b6cfacb (diff)
elc_fileselector : Select path which user typed on path_entry.
Summary: In fileselector, user can write directory path or file path which they want. If then, fileselector navigates path when directory path is given, but just send a "selected" signal without real selection when file path or wrong path is given. With this path, - fileselector will navigate (if needed) and select file with signal when file path is given. - no action when wrong path is given.
-rw-r--r--legacy/elementary/ChangeLog5
-rw-r--r--legacy/elementary/NEWS1
-rw-r--r--legacy/elementary/src/lib/elc_fileselector.c149
-rw-r--r--legacy/elementary/src/lib/elm_widget_fileselector.h1
4 files changed, 118 insertions, 38 deletions
diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog
index d957f29482..9b701ef348 100644
--- a/legacy/elementary/ChangeLog
+++ b/legacy/elementary/ChangeLog
@@ -1598,3 +1598,8 @@
1598 1598
1599 * ProgressBar: Added support for more than one progress status in a 1599 * ProgressBar: Added support for more than one progress status in a
1600 single progress bar 1600 single progress bar
1601
16022013-09-10 Ryuan Choi (ryuan)
1603
1604 * elc_fileselector : Navigate (if needed) and select file with "selected"
1605 signal when user typed file path on path_entry.
diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS
index 2a3ed46f56..b14ad6c852 100644
--- a/legacy/elementary/NEWS
+++ b/legacy/elementary/NEWS
@@ -277,6 +277,7 @@ Fixes:
277 This prevents the asynchronous states between ime and conformant. 277 This prevents the asynchronous states between ime and conformant.
278 * Flip : Fix the flip page to not flip on a direction if the direction is disabled. 278 * Flip : Fix the flip page to not flip on a direction if the direction is disabled.
279 * Spinner : change part name to access.text from access_text on default style. 279 * Spinner : change part name to access.text from access_text on default style.
280 * Fix fileselector only send "selected" signal without selection when file path is typed on the path entry.
280 281
281Removals: 282Removals:
282 283
diff --git a/legacy/elementary/src/lib/elc_fileselector.c b/legacy/elementary/src/lib/elc_fileselector.c
index ef73b6a807..742ac30365 100644
--- a/legacy/elementary/src/lib/elc_fileselector.c
+++ b/legacy/elementary/src/lib/elc_fileselector.c
@@ -393,6 +393,7 @@ _ls_main_cb(void *data,
393 const Eina_File_Direct_Info *info) 393 const Eina_File_Direct_Info *info)
394{ 394{
395 Listing_Request *lreq = data; 395 Listing_Request *lreq = data;
396 Elm_Object_Item *item;
396 int itcn = ELM_FILE_UNKNOW; 397 int itcn = ELM_FILE_UNKNOW;
397 398
398 if (eio_file_check(handler)) return; 399 if (eio_file_check(handler)) return;
@@ -416,16 +417,26 @@ _ls_main_cb(void *data,
416 } 417 }
417 418
418 if (lreq->sd->mode == ELM_FILESELECTOR_LIST) 419 if (lreq->sd->mode == ELM_FILESELECTOR_LIST)
419 elm_genlist_item_sorted_insert(lreq->sd->files_list, list_itc[itcn], 420 {
420 eina_stringshare_add(info->path), 421 item = elm_genlist_item_sorted_insert(lreq->sd->files_list, list_itc[itcn],
421 lreq->parent_it, 422 eina_stringshare_add(info->path),
422 ((lreq->sd->expand) && (itcn == ELM_DIRECTORY)) 423 lreq->parent_it,
423 ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE, 424 ((lreq->sd->expand) && (itcn == ELM_DIRECTORY))
424 _file_list_cmp, NULL, NULL); 425 ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
426 _file_list_cmp, NULL, NULL);
427
428 if (lreq->selected && !strcmp(info->path, lreq->selected))
429 elm_genlist_item_selected_set(item, EINA_TRUE);
430 }
425 else if (lreq->sd->mode == ELM_FILESELECTOR_GRID) 431 else if (lreq->sd->mode == ELM_FILESELECTOR_GRID)
426 elm_gengrid_item_sorted_insert(lreq->sd->files_grid, grid_itc[itcn], 432 {
427 eina_stringshare_add(info->path), 433 item = elm_gengrid_item_sorted_insert(lreq->sd->files_grid, grid_itc[itcn],
428 _file_grid_cmp, NULL, NULL); 434 eina_stringshare_add(info->path),
435 _file_grid_cmp, NULL, NULL);
436
437 if (lreq->selected && !strcmp(info->path, lreq->selected))
438 elm_gengrid_item_selected_set(item, EINA_TRUE);
439 }
429} 440}
430 441
431static void 442static void
@@ -434,6 +445,7 @@ _listing_request_cleanup(Listing_Request *lreq)
434 EINA_REFCOUNT_UNREF(lreq->sd) _elm_fileselector_smart_del_do(lreq->sd); 445 EINA_REFCOUNT_UNREF(lreq->sd) _elm_fileselector_smart_del_do(lreq->sd);
435 446
436 eina_stringshare_del(lreq->path); 447 eina_stringshare_del(lreq->path);
448 eina_stringshare_del(lreq->selected);
437 free(lreq); 449 free(lreq);
438} 450}
439 451
@@ -468,7 +480,8 @@ _ls_error_cb(void *data, Eio_File *handler, int error __UNUSED__)
468static void 480static void
469_populate(Evas_Object *obj, 481_populate(Evas_Object *obj,
470 const char *path, 482 const char *path,
471 Elm_Object_Item *parent_it) 483 Elm_Object_Item *parent_it,
484 const char *selected)
472{ 485{
473 ELM_FILESELECTOR_DATA_GET(obj, sd); 486 ELM_FILESELECTOR_DATA_GET(obj, sd);
474 if (!path) return; 487 if (!path) return;
@@ -538,14 +551,24 @@ _populate(Evas_Object *obj,
538 ELM_FILE_IMAGE : ELM_FILE_UNKNOW; 551 ELM_FILE_IMAGE : ELM_FILE_UNKNOW;
539 552
540 if (sd->mode == ELM_FILESELECTOR_LIST) 553 if (sd->mode == ELM_FILESELECTOR_LIST)
541 elm_genlist_item_append(sd->files_list, list_itc[type], 554 {
542 entry, /* item data */ 555 Elm_Object_Item *item;
543 parent_it, ELM_GENLIST_ITEM_NONE, 556 item = elm_genlist_item_append(sd->files_list, list_itc[type],
544 NULL, NULL); 557 entry, /* item data */
558 parent_it, ELM_GENLIST_ITEM_NONE,
559 NULL, NULL);
560 if (selected && !strcmp(entry, selected))
561 elm_genlist_item_selected_set(item, EINA_TRUE);
562 }
545 else if (sd->mode == ELM_FILESELECTOR_GRID) 563 else if (sd->mode == ELM_FILESELECTOR_GRID)
546 elm_gengrid_item_append(sd->files_grid, grid_itc[type], 564 {
547 entry, /* item data */ 565 Elm_Object_Item *item;
548 NULL, NULL); 566 item = elm_gengrid_item_append(sd->files_grid, grid_itc[type],
567 entry, /* item data */
568 NULL, NULL);
569 if (selected && !strcmp(entry, selected))
570 elm_gengrid_item_selected_set(item, EINA_TRUE);
571 }
549 } 572 }
550 573
551#else /* asynchronous listing path */ 574#else /* asynchronous listing path */
@@ -564,6 +587,11 @@ _populate(Evas_Object *obj,
564 lreq->path = eina_stringshare_add(path); 587 lreq->path = eina_stringshare_add(path);
565 lreq->first = EINA_TRUE; 588 lreq->first = EINA_TRUE;
566 589
590 if (selected)
591 lreq->selected = eina_stringshare_add(selected);
592 else
593 lreq->selected = NULL;
594
567 sd->current = eio_file_stat_ls(path, _ls_filter_cb, _ls_main_cb, 595 sd->current = eio_file_stat_ls(path, _ls_filter_cb, _ls_main_cb,
568 _ls_done_cb, _ls_error_cb, lreq); 596 _ls_done_cb, _ls_error_cb, lreq);
569 elm_progressbar_pulse(sd->spinner, EINA_TRUE); 597 elm_progressbar_pulse(sd->spinner, EINA_TRUE);
@@ -579,7 +607,7 @@ _on_list_expanded(void *data,
579 Elm_Object_Item *it = event_info; 607 Elm_Object_Item *it = event_info;
580 const char *path = elm_object_item_data_get(it); 608 const char *path = elm_object_item_data_get(it);
581 609
582 _populate(data, path, it); 610 _populate(data, path, it, NULL);
583} 611}
584 612
585static void 613static void
@@ -632,7 +660,7 @@ _sel_do(void *data)
632 { 660 {
633 /* keep a ref to path 'couse it will be destroyed by _populate */ 661 /* keep a ref to path 'couse it will be destroyed by _populate */
634 p = eina_stringshare_add(path); 662 p = eina_stringshare_add(path);
635 _populate(sdata->fs, p, NULL); 663 _populate(sdata->fs, p, NULL, NULL);
636 eina_stringshare_del(p); 664 eina_stringshare_del(p);
637 } 665 }
638 else 666 else
@@ -703,7 +731,7 @@ _on_dir_up(void *data,
703 ELM_FILESELECTOR_DATA_GET(fs, sd); 731 ELM_FILESELECTOR_DATA_GET(fs, sd);
704 732
705 parent = ecore_file_dir_get(sd->path); 733 parent = ecore_file_dir_get(sd->path);
706 _populate(fs, parent, NULL); 734 _populate(fs, parent, NULL, NULL);
707 free(parent); 735 free(parent);
708} 736}
709 737
@@ -714,7 +742,7 @@ _home(void *data,
714{ 742{
715 Evas_Object *fs = data; 743 Evas_Object *fs = data;
716 744
717 _populate(fs, getenv("HOME"), NULL); 745 _populate(fs, getenv("HOME"), NULL, NULL);
718} 746}
719 747
720static void 748static void
@@ -729,7 +757,7 @@ _current_filer_changed(void *data,
729 elm_object_text_set(obj, filter->filter_name); 757 elm_object_text_set(obj, filter->filter_name);
730 filter->sd->current_filter = filter; 758 filter->sd->current_filter = filter;
731 759
732 _populate(filter->sd->obj, filter->sd->path, NULL); 760 _populate(filter->sd->obj, filter->sd->path, NULL, NULL);
733} 761}
734 762
735static void 763static void
@@ -778,16 +806,61 @@ _on_text_activated(void *data,
778 void *event_info __UNUSED__) 806 void *event_info __UNUSED__)
779{ 807{
780 Evas_Object *fs = data; 808 Evas_Object *fs = data;
781 const char *p; 809 const char *p, *path;
810 char *dir;
782 811
783 // keep a ref to path 'couse it will be destroyed by _populate 812 ELM_FILESELECTOR_DATA_GET(fs, sd);
784 p = eina_stringshare_add(elm_object_text_get(obj)); 813
785 if (ecore_file_is_dir(p)) 814 path = elm_object_text_get(obj);
786 _populate(fs, p, NULL); 815
816 // FIXME: Needs some feedback to user like alert.
817 if (!ecore_file_exists(path)) goto end;
818
819 if (ecore_file_is_dir(path))
820 {
821 // keep a ref to path 'couse it will be destroyed by _populate
822 p = eina_stringshare_add(path);
823 _populate(fs, p, NULL, NULL);
824 eina_stringshare_del(p);
825 goto end;
826 }
827
828 dir = ecore_file_dir_get(path);
829 if (!dir) goto end;
830
831 if (strcmp(dir, sd->path))
832 _populate(fs, dir, NULL, path);
787 else 833 else
788 evas_object_smart_callback_call(data, SIG_SELECTED, (void *)p); 834 {
835 if (sd->mode == ELM_FILESELECTOR_LIST)
836 {
837 Elm_Object_Item *item = elm_genlist_first_item_get(sd->files_list);
838 while (item)
839 {
840 const char *item_path = elm_object_item_data_get(item);
841 if (!strcmp(item_path, path))
842 elm_genlist_item_selected_set(item, EINA_TRUE);
843 item = elm_genlist_item_next_get(item);
844 }
845 }
846 else
847 {
848 Elm_Object_Item *item = elm_gengrid_first_item_get(sd->files_list);
849 while (item)
850 {
851 const char *item_path = elm_object_item_data_get(item);
852 if (!strcmp(item_path, path))
853 {
854 elm_gengrid_item_selected_set(item, EINA_TRUE);
855 break;
856 }
857 item = elm_gengrid_item_next_get(item);
858 }
859 }
860 }
861 free(dir);
789 862
790 eina_stringshare_del(p); 863end:
791 elm_object_focus_set(obj, EINA_FALSE); 864 elm_object_focus_set(obj, EINA_FALSE);
792} 865}
793 866
@@ -811,7 +884,7 @@ _anchor_clicked(void *data,
811 884
812 // keep a ref to path 'couse it will be destroyed by _populate 885 // keep a ref to path 'couse it will be destroyed by _populate
813 p = eina_stringshare_add(info->name); 886 p = eina_stringshare_add(info->name);
814 _populate(fs, p, NULL); 887 _populate(fs, p, NULL, NULL);
815 evas_object_smart_callback_call(data, SIG_SELECTED, (void *)p); 888 evas_object_smart_callback_call(data, SIG_SELECTED, (void *)p);
816 eina_stringshare_del(p); 889 eina_stringshare_del(p);
817 /* After anchor was clicked, entry will be focused, and will be editable. 890 /* After anchor was clicked, entry will be focused, and will be editable.
@@ -1035,7 +1108,7 @@ _folder_only_set(Eo *obj, void *_pd, va_list *list)
1035 if (sd->only_folder == only) return; 1108 if (sd->only_folder == only) return;
1036 1109
1037 sd->only_folder = !!only; 1110 sd->only_folder = !!only;
1038 if (sd->path) _populate(obj, sd->path, NULL); 1111 if (sd->path) _populate(obj, sd->path, NULL, NULL);
1039} 1112}
1040 1113
1041EAPI Eina_Bool 1114EAPI Eina_Bool
@@ -1136,7 +1209,7 @@ _expandable_set(Eo *obj, void *_pd, va_list *list)
1136 1209
1137 sd->expand = !!expand; 1210 sd->expand = !!expand;
1138 1211
1139 if (sd->path) _populate(obj, sd->path, NULL); 1212 if (sd->path) _populate(obj, sd->path, NULL, NULL);
1140} 1213}
1141 1214
1142EAPI Eina_Bool 1215EAPI Eina_Bool
@@ -1171,7 +1244,7 @@ _path_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
1171 char *path; 1244 char *path;
1172 1245
1173 path = ecore_file_realpath(_path); 1246 path = ecore_file_realpath(_path);
1174 _populate(obj, path, NULL); 1247 _populate(obj, path, NULL, NULL);
1175 free(path); 1248 free(path);
1176} 1249}
1177 1250
@@ -1217,7 +1290,7 @@ _mode_set(Eo *obj, void *_pd, va_list *list)
1217 1290
1218 sd->mode = mode; 1291 sd->mode = mode;
1219 1292
1220 _populate(obj, sd->path, NULL); 1293 _populate(obj, sd->path, NULL, NULL);
1221} 1294}
1222 1295
1223EAPI Elm_Fileselector_Mode 1296EAPI Elm_Fileselector_Mode
@@ -1306,7 +1379,7 @@ _selected_set(Eo *obj, void *_pd, va_list *list)
1306 1379
1307 path = ecore_file_realpath(_path); 1380 path = ecore_file_realpath(_path);
1308 1381
1309 if (ecore_file_is_dir(path)) _populate(obj, path, NULL); 1382 if (ecore_file_is_dir(path)) _populate(obj, path, NULL, NULL);
1310 else 1383 else
1311 { 1384 {
1312 if (!ecore_file_exists(path)) 1385 if (!ecore_file_exists(path))
@@ -1316,7 +1389,7 @@ _selected_set(Eo *obj, void *_pd, va_list *list)
1316 } 1389 }
1317 1390
1318 selected = ecore_file_dir_get(path); 1391 selected = ecore_file_dir_get(path);
1319 _populate(obj, selected, NULL); 1392 _populate(obj, selected, NULL, NULL);
1320 eina_stringshare_replace(&sd->selection, path); 1393 eina_stringshare_replace(&sd->selection, path);
1321 free(selected); 1394 free(selected);
1322 } 1395 }
@@ -1373,7 +1446,7 @@ _mime_types_filter_append(Eo *obj, void *_pd, va_list *list)
1373 1446
1374 sd->filter_list = eina_list_append(sd->filter_list, ff); 1447 sd->filter_list = eina_list_append(sd->filter_list, ff);
1375 1448
1376 _populate(obj, sd->path, NULL); 1449 _populate(obj, sd->path, NULL, NULL);
1377 1450
1378 if (need_theme) 1451 if (need_theme)
1379 eo_do(obj, elm_wdg_theme(NULL)); 1452 eo_do(obj, elm_wdg_theme(NULL));
@@ -1409,7 +1482,7 @@ _filters_clear(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1409 1482
1410 ELM_SAFE_FREE(sd->filter_hoversel, evas_object_del); 1483 ELM_SAFE_FREE(sd->filter_hoversel, evas_object_del);
1411 1484
1412 _populate(obj, sd->path, NULL); 1485 _populate(obj, sd->path, NULL, NULL);
1413} 1486}
1414 1487
1415static void 1488static void
diff --git a/legacy/elementary/src/lib/elm_widget_fileselector.h b/legacy/elementary/src/lib/elm_widget_fileselector.h
index ad8c35ae68..353a4fb8aa 100644
--- a/legacy/elementary/src/lib/elm_widget_fileselector.h
+++ b/legacy/elementary/src/lib/elm_widget_fileselector.h
@@ -68,6 +68,7 @@ struct _Listing_Request
68 68
69 Evas_Object *obj; 69 Evas_Object *obj;
70 const char *path; 70 const char *path;
71 const char *selected;
71 Eina_Bool first : 1; 72 Eina_Bool first : 1;
72}; 73};
73 74