3 * - child elements focusing support
4 * - user defined icon/label cb
5 * - show/hide/add buttons ???
6 * - show/hide hidden files
7 * - double click to choose a file
9 * - make variable/function names that are sensible
14 # include "elementary_config.h"
21 #include <Elementary.h>
24 typedef struct _Widget_Data Widget_Data;
31 Evas_Object *filename_entry;
32 Evas_Object *path_entry;
33 Evas_Object *files_list;
34 Evas_Object *files_grid;
35 Evas_Object *up_button;
36 Evas_Object *home_button;
38 Evas_Object *ok_button;
39 Evas_Object *cancel_button;
42 const char *selection;
43 Ecore_Idler *sel_idler;
45 const char *path_separator;
51 Elm_Fileselector_Mode mode;
53 Eina_Bool only_folder : 1;
63 typedef struct _Widget_Request Widget_Request;
64 struct _Widget_Request
67 Elm_Object_Item *parent;
79 } Elm_Fileselector_Type;
82 static Elm_Genlist_Item_Class list_itc[ELM_FILE_LAST] = {
83 { "default", { NULL, NULL, NULL, NULL } },
84 { "default", { NULL, NULL, NULL, NULL } },
85 { "default", { NULL, NULL, NULL, NULL } }
87 static Elm_Gengrid_Item_Class grid_itc[ELM_FILE_LAST] = {
88 { "default", { NULL, NULL, NULL, NULL } },
89 { "default", { NULL, NULL, NULL, NULL } },
90 { "default", { NULL, NULL, NULL, NULL } }
93 static Elm_Genlist_Item_Class *list_itc[ELM_FILE_LAST];
94 static Elm_Gengrid_Item_Class *grid_itc[ELM_FILE_LAST];
95 >>>>>>> remotes/origin/upstream
97 static const char *widtype = NULL;
99 static const char SIG_DIRECTORY_OPEN[] = "directory,open";
100 static const char SIG_DONE[] = "done";
101 static const char SIG_SELECTED[] = "selected";
102 static const Evas_Smart_Cb_Description _signals[] = {
103 {SIG_DIRECTORY_OPEN, "s"},
109 static void _populate(Evas_Object *obj,
111 Elm_Object_Item *parent);
112 static void _do_anchors(Evas_Object *obj,
115 /*** ELEMENTARY WIDGET ***/
117 _widget_data_free(Widget_Data *wd)
119 if (wd->path) eina_stringshare_del(wd->path);
120 if (wd->selection) eina_stringshare_del(wd->selection);
125 sd = ecore_idler_del(wd->sel_idler);
132 _del_hook(Evas_Object *obj)
138 >>>>>>> remotes/origin/upstream
140 wd = elm_widget_data_get(obj);
145 for (i = 0; i < ELM_FILE_LAST; ++i)
147 elm_genlist_item_class_free(list_itc[i]);
148 elm_gengrid_item_class_free(grid_itc[i]);
151 >>>>>>> remotes/origin/upstream
154 eio_file_cancel(wd->current);
157 wd->files_list = NULL;
158 wd->files_grid = NULL;
160 EINA_REFCOUNT_UNREF(wd)
161 _widget_data_free(wd);
165 _sizing_eval(Evas_Object *obj)
167 Widget_Data *wd = elm_widget_data_get(obj);
168 Evas_Coord minw = -1, minh = -1;
170 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
171 edje_object_size_min_restricted_calc(wd->edje, &minw, &minh, minw, minh);
172 evas_object_size_hint_min_set(obj, minw, minh);
176 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
178 Widget_Data *wd = elm_widget_data_get(obj);
180 elm_widget_mirrored_set(wd->cancel_button, rtl);
181 elm_widget_mirrored_set(wd->ok_button, rtl);
182 elm_widget_mirrored_set(wd->files_list, rtl);
183 elm_widget_mirrored_set(wd->up_button, rtl);
184 elm_widget_mirrored_set(wd->home_button, rtl);
185 edje_object_mirrored_set(wd->edje, rtl);
189 _theme_hook(Evas_Object *obj)
191 Widget_Data *wd = elm_widget_data_get(obj);
192 const char *style = elm_widget_style_get(obj);
197 _elm_widget_mirrored_reload(obj);
199 _elm_theme_object_set(obj, wd->edje, "fileselector", "base", style);
201 if (elm_object_disabled_get(obj))
202 edje_object_signal_emit(wd->edje, "elm,state,disabled", "elm");
204 data = edje_object_data_get(wd->edje, "path_separator");
206 wd->path_separator = data;
208 wd->path_separator = "/";
210 if (!style) style = "default";
211 snprintf(buf, sizeof(buf), "fileselector/%s", style);
213 #define SWALLOW(part_name, object_ptn) \
216 elm_widget_style_set(object_ptn, buf); \
217 if (edje_object_part_swallow(wd->edje, part_name, object_ptn)) \
218 evas_object_show(object_ptn); \
220 evas_object_hide(object_ptn); \
222 SWALLOW("elm.swallow.up", wd->up_button);
223 SWALLOW("elm.swallow.home", wd->home_button);
225 if (wd->mode == ELM_FILESELECTOR_LIST)
227 if (edje_object_part_swallow(wd->edje, "elm.swallow.files",
230 evas_object_show(wd->files_list);
231 evas_object_hide(wd->files_grid);
234 evas_object_hide(wd->files_list);
238 if (edje_object_part_swallow(wd->edje, "elm.swallow.files",
241 evas_object_show(wd->files_grid);
242 evas_object_hide(wd->files_list);
245 evas_object_hide(wd->files_grid);
248 SWALLOW("elm.swallow.filename", wd->filename_entry);
249 SWALLOW("elm.swallow.path", wd->path_entry);
251 snprintf(buf, sizeof(buf), "fileselector/actions/%s", style);
252 SWALLOW("elm.swallow.cancel", wd->cancel_button);
253 SWALLOW("elm.swallow.ok", wd->ok_button);
256 edje_object_message_signal_process(wd->edje);
257 _mirrored_set(obj, elm_widget_mirrored_get(obj));
258 edje_object_scale_set
259 (wd->edje, elm_widget_scale_get(obj) * _elm_config->scale);
263 /*** GENLIST "MODEL" ***/
265 _itc_text_get(void *data,
266 Evas_Object *obj __UNUSED__,
267 const char *source __UNUSED__)
269 return strdup(ecore_file_file_get(data)); /* NOTE this will be
275 _itc_icon_folder_get(void *data __UNUSED__,
281 if (strcmp(source, "elm.swallow.icon")) return NULL;
283 ic = elm_icon_add(obj);
284 elm_icon_standard_set(ic, "folder");
286 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
292 _itc_icon_image_get(void *data,
296 const char *filename = data;
299 if (strcmp(source, "elm.swallow.icon")) return NULL;
301 ic = elm_icon_add(obj);
302 elm_icon_standard_set(ic, "image");
303 elm_icon_thumb_set(ic, filename, NULL);
305 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
311 _itc_icon_file_get(void *data __UNUSED__,
317 if (strcmp(source, "elm.swallow.icon")) return NULL;
319 ic = elm_icon_add(obj);
320 elm_icon_standard_set(ic, "file");
322 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
328 _itc_state_get(void *data __UNUSED__,
329 Evas_Object *obj __UNUSED__,
330 const char *source __UNUSED__)
337 Evas_Object *obj __UNUSED__)
339 eina_stringshare_del(data);
343 _expand_done(void *data,
344 Evas_Object *obj __UNUSED__,
347 Elm_Object_Item *it = event_info;
348 const char *path = elm_object_item_data_get(it);
349 _populate(data, path, it);
353 _contract_done(void *data __UNUSED__,
354 Evas_Object *obj __UNUSED__,
357 Elm_Object_Item *it = event_info;
358 elm_genlist_item_subitems_clear(it);
362 _expand_req(void *data __UNUSED__,
363 Evas_Object *obj __UNUSED__,
366 Elm_Object_Item *it = event_info;
367 elm_genlist_item_expanded_set(it, EINA_TRUE);
371 _contract_req(void *data __UNUSED__,
372 Evas_Object *obj __UNUSED__,
375 Elm_Object_Item *it = event_info;
376 elm_genlist_item_expanded_set(it, EINA_FALSE);
389 wd = elm_widget_data_get(sd->fs);
392 if ((!wd->only_folder) && ecore_file_is_dir(path))
394 if (wd->expand && wd->mode == ELM_FILESELECTOR_LIST)
396 _do_anchors(sd->fs, path);
397 elm_object_text_set(wd->filename_entry, "");
401 /* keep a ref to path 'couse it will be destroyed by _populate */
402 p = eina_stringshare_add(path);
403 _populate(sd->fs, p, NULL);
404 eina_stringshare_del(p);
408 else /* navigating through folders only or file is not a dir. */
410 if (wd->expand && wd->mode == ELM_FILESELECTOR_LIST)
411 _do_anchors(sd->fs, path);
412 else if (wd->only_folder)
414 /* keep a ref to path 'couse it will be destroyed by _populate */
415 p = eina_stringshare_add(path);
416 _populate(sd->fs, p, NULL);
417 eina_stringshare_del(p);
419 elm_object_text_set(wd->filename_entry,
420 ecore_file_file_get(path));
423 evas_object_smart_callback_call(sd->fs, SIG_SELECTED, (void *)path);
426 wd->sel_idler = NULL;
428 return ECORE_CALLBACK_CANCEL;
433 Evas_Object *obj __UNUSED__,
442 //This event_info could be a list or gengrid item
443 Elm_Object_Item *it = event_info;
444 >>>>>>> remotes/origin/upstream
446 wd = elm_widget_data_get(data);
449 sd = malloc(sizeof(*sd));
452 sd->path = wd->mode == ELM_FILESELECTOR_LIST ?
453 elm_object_item_data_get(event_info) :
454 elm_gengrid_item_data_get(event_info);
456 sd->path = elm_object_item_data_get(it);
457 >>>>>>> remotes/origin/upstream
461 eina_stringshare_replace(&wd->path, "");
465 dir = wd->only_folder ? strdup(sd->path) : ecore_file_dir_get(sd->path);
468 eina_stringshare_replace(&wd->path, dir);
473 eina_stringshare_replace(&wd->path, "");
479 old_sd = ecore_idler_del(wd->sel_idler);
482 wd->sel_idler = ecore_idler_add(_sel_do, sd);
487 Evas_Object *obj __UNUSED__,
488 void *event_info __UNUSED__)
490 Evas_Object *fs = data;
493 Widget_Data *wd = elm_widget_data_get(fs);
495 parent = ecore_file_dir_get(wd->path);
496 _populate(fs, parent, NULL);
502 Evas_Object *obj __UNUSED__,
503 void *event_info __UNUSED__)
505 Evas_Object *fs = data;
506 _populate(fs, getenv("HOME"), NULL);
511 Evas_Object *obj __UNUSED__,
512 void *event_info __UNUSED__)
514 Evas_Object *fs = data;
515 evas_object_smart_callback_call(fs, SIG_DONE,
516 (void *)elm_fileselector_selected_get(fs));
521 Evas_Object *obj __UNUSED__,
522 void *event_info __UNUSED__)
524 Evas_Object *fs = data;
525 evas_object_smart_callback_call(fs, SIG_DONE, NULL);
529 _anchor_clicked(void *data,
530 Evas_Object *obj __UNUSED__,
533 Evas_Object *fs = data;
534 Widget_Data *wd = elm_widget_data_get(fs);
535 Elm_Entry_Anchor_Info *info = event_info;
538 // keep a ref to path 'couse it will be destroyed by _populate
539 p = eina_stringshare_add(info->name);
540 _populate(fs, p, NULL);
541 evas_object_smart_callback_call(data, SIG_SELECTED, (void *)p);
542 eina_stringshare_del(p);
546 _do_anchors(Evas_Object *obj,
549 Widget_Data *wd = elm_widget_data_get(obj);
550 char **tok, buf[PATH_MAX * 3];
554 tok = eina_str_split(path, "/", 0);
555 eina_strlcat(buf, "<a href=/>root</a>", sizeof(buf));
556 for (i = 0; tok[i]; i++)
558 if ((!tok[i]) || (!tok[i][0])) continue;
559 eina_strlcat(buf, wd->path_separator, sizeof(buf));
560 eina_strlcat(buf, "<a href=", sizeof(buf));
561 for (j = 0; j <= i; j++)
563 if (strlen(tok[j]) < 1) continue;
564 eina_strlcat(buf, "/", sizeof(buf));
565 eina_strlcat(buf, tok[j], sizeof(buf));
567 eina_strlcat(buf, ">", sizeof(buf));
568 eina_strlcat(buf, tok[i], sizeof(buf));
569 eina_strlcat(buf, "</a>", sizeof(buf));
574 elm_object_text_set(wd->path_entry, buf);
579 _filter_cb(void *data __UNUSED__, Eio_File *handler, const Eina_File_Direct_Info *info)
581 const char *filename;
583 if (info->path[info->name_start] == '.')
586 filename = eina_stringshare_add(info->path);
587 eio_file_associate_direct_add(handler, "filename", filename, EINA_FREE_CB(eina_stringshare_del));
589 if (info->type == EINA_FILE_DIR)
592 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_DIRECTORY], NULL);
593 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_DIRECTORY], NULL);
595 eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_DIRECTORY], NULL);
596 eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_DIRECTORY], NULL);
597 >>>>>>> remotes/origin/upstream
601 if (evas_object_image_extension_can_load_get(info->path + info->name_start))
604 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_IMAGE], NULL);
605 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_IMAGE], NULL);
609 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_UNKNOW], NULL);
610 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_UNKNOW], NULL);
612 eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_FILE_IMAGE], NULL);
613 eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_FILE_IMAGE], NULL);
617 eio_file_associate_direct_add(handler, "type/grid", grid_itc[ELM_FILE_UNKNOW], NULL);
618 eio_file_associate_direct_add(handler, "type/list", list_itc[ELM_FILE_UNKNOW], NULL);
619 >>>>>>> remotes/origin/upstream
627 _file_grid_cmp(const void *a, const void *b)
630 const Elm_Gengrid_Item *ga = a;
631 const Elm_Gengrid_Item *gb = b;
632 const Elm_Gengrid_Item_Class *ca = elm_gengrid_item_item_class_get(ga);
633 const Elm_Gengrid_Item_Class *cb = elm_gengrid_item_item_class_get(gb);
635 if (ca == &grid_itc[ELM_DIRECTORY])
637 if (cb != &grid_itc[ELM_DIRECTORY])
640 else if (cb == &grid_itc[ELM_DIRECTORY])
642 const Elm_Object_Item *ga = a;
643 const Elm_Object_Item *gb = b;
644 const Elm_Gengrid_Item_Class *ca = elm_gengrid_item_item_class_get(ga);
645 const Elm_Gengrid_Item_Class *cb = elm_gengrid_item_item_class_get(gb);
647 if (ca == grid_itc[ELM_DIRECTORY])
649 if (cb != grid_itc[ELM_DIRECTORY])
652 else if (cb == grid_itc[ELM_DIRECTORY])
653 >>>>>>> remotes/origin/upstream
659 return strcoll(elm_gengrid_item_data_get(ga), elm_gengrid_item_data_get(gb));
661 return strcoll(elm_object_item_data_get(ga), elm_object_item_data_get(gb));
662 >>>>>>> remotes/origin/upstream
666 _file_list_cmp(const void *a, const void *b)
668 const Elm_Object_Item *la = a;
669 const Elm_Object_Item *lb = b;
670 const Elm_Genlist_Item_Class *ca = elm_genlist_item_item_class_get(la);
671 const Elm_Genlist_Item_Class *cb = elm_genlist_item_item_class_get(lb);
674 if (ca == &list_itc[ELM_DIRECTORY])
676 if (cb != &list_itc[ELM_DIRECTORY])
679 else if (cb == &list_itc[ELM_DIRECTORY])
681 if (ca == list_itc[ELM_DIRECTORY])
683 if (cb != list_itc[ELM_DIRECTORY])
686 else if (cb == list_itc[ELM_DIRECTORY])
687 >>>>>>> remotes/origin/upstream
692 return strcoll(elm_object_item_data_get(la), elm_object_item_data_get(lb));
696 _signal_first(Widget_Request *wr)
698 if (!wr->first) return ;
699 evas_object_smart_callback_call(wr->obj, SIG_DIRECTORY_OPEN, (void *)wr->path);
702 elm_genlist_clear(wr->wd->files_list);
703 elm_gengrid_clear(wr->wd->files_grid);
704 eina_stringshare_replace(&wr->wd->path, wr->path);
705 _do_anchors(wr->obj, wr->path);
708 if (wr->wd->filename_entry) elm_object_text_set(wr->wd->filename_entry, "");
710 wr->first = EINA_FALSE;
714 _main_cb(void *data, Eio_File *handler, const Eina_File_Direct_Info *info __UNUSED__)
716 Widget_Request *wr = data;
718 if (eio_file_check(handler))
720 if (!wr->wd->files_list || !wr->wd->files_grid || wr->wd->current != handler)
722 eio_file_cancel(handler);
728 if (wr->wd->mode == ELM_FILESELECTOR_LIST)
731 Eina_Bool is_dir = (eio_file_associate_find(handler, "type/list") == &list_itc[ELM_DIRECTORY]);
733 elm_genlist_item_direct_sorted_insert(wr->wd->files_list, eio_file_associate_find(handler, "type/list"),
734 eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
735 wr->parent, wr->wd->expand && is_dir ? ELM_GENLIST_ITEM_SUBITEMS : ELM_GENLIST_ITEM_NONE,
736 _file_list_cmp, NULL, NULL);
738 else if (wr->wd->mode == ELM_FILESELECTOR_GRID)
739 elm_gengrid_item_direct_sorted_insert(wr->wd->files_grid, eio_file_associate_find(handler, "type/grid"),
741 Eina_Bool is_dir = (eio_file_associate_find(handler, "type/list") == list_itc[ELM_DIRECTORY]);
743 elm_genlist_item_sorted_insert(wr->wd->files_list, eio_file_associate_find(handler, "type/list"),
744 eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
745 wr->parent, wr->wd->expand && is_dir ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
746 _file_list_cmp, NULL, NULL);
748 else if (wr->wd->mode == ELM_FILESELECTOR_GRID)
749 elm_gengrid_item_sorted_insert(wr->wd->files_grid, eio_file_associate_find(handler, "type/grid"),
750 >>>>>>> remotes/origin/upstream
751 eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
752 _file_grid_cmp, NULL, NULL);
756 _widget_request_cleanup(Widget_Request *wr)
758 EINA_REFCOUNT_UNREF(wr->wd)
759 _widget_data_free(wr->wd);
761 eina_stringshare_del(wr->path);
766 _done_cb(void *data, Eio_File *handler __UNUSED__)
768 Widget_Request *wr = data;
772 wr->wd->current = NULL;
773 _widget_request_cleanup(wr);
777 _error_cb(void *data, Eio_File *handler, int error __UNUSED__)
779 Widget_Request *wr = data;
781 if (wr->wd->current == handler)
782 wr->wd->current = NULL;
783 _widget_request_cleanup(wr);
789 _populate(Evas_Object *obj,
791 Elm_Object_Item *parent)
793 Widget_Data *wd = elm_widget_data_get(obj);
797 Eina_File_Direct_Info *file;
800 Eina_List *files = NULL, *dirs = NULL;
805 if (!ecore_file_is_dir(path)) return ;
806 it = eina_file_stat_ls(path);
808 evas_object_smart_callback_call(obj, SIG_DIRECTORY_OPEN, (void *)path);
811 elm_genlist_clear(wd->files_list);
812 elm_gengrid_clear(wd->files_grid);
813 eina_stringshare_replace(&wd->path, path);
814 _do_anchors(obj, path);
817 if (wd->filename_entry) elm_object_text_set(wd->filename_entry, "");
818 EINA_ITERATOR_FOREACH(it, file)
820 const char *filename;
822 if (file->path[file->name_start] == '.')
825 filename = eina_stringshare_add(file->path);
826 if (file->type == EINA_FILE_DIR)
827 dirs = eina_list_append(dirs, filename);
828 else if (!wd->only_folder)
829 files = eina_list_append(files, filename);
831 eina_iterator_free(it);
833 files = eina_list_sort(files, eina_list_count(files),
834 EINA_COMPARE_CB(strcoll));
835 dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll));
836 EINA_LIST_FREE(dirs, real)
838 if (wd->mode == ELM_FILESELECTOR_LIST)
840 elm_genlist_item_append(wd->files_list, &list_itc[ELM_DIRECTORY],
841 real, /* item data */
843 wd->expand ? ELM_GENLIST_ITEM_SUBITEMS :
844 ELM_GENLIST_ITEM_NONE,
846 else if (wd->mode == ELM_FILESELECTOR_GRID)
847 elm_gengrid_item_append(wd->files_grid, &grid_itc[ELM_DIRECTORY],
849 elm_genlist_item_append(wd->files_list, list_itc[ELM_DIRECTORY],
850 real, /* item data */
852 wd->expand ? ELM_GENLIST_ITEM_TREE :
853 ELM_GENLIST_ITEM_NONE,
855 else if (wd->mode == ELM_FILESELECTOR_GRID)
856 elm_gengrid_item_append(wd->files_grid, grid_itc[ELM_DIRECTORY],
857 >>>>>>> remotes/origin/upstream
858 real, /* item data */
862 EINA_LIST_FREE(files, real)
864 Elm_Fileselector_Type type = evas_object_image_extension_can_load_fast_get(real) ?
865 ELM_FILE_IMAGE : ELM_FILE_UNKNOW;
867 if (wd->mode == ELM_FILESELECTOR_LIST)
869 elm_genlist_item_append(wd->files_list, &list_itc[type],
871 elm_genlist_item_append(wd->files_list, list_itc[type],
872 >>>>>>> remotes/origin/upstream
873 real, /* item data */
874 parent, ELM_GENLIST_ITEM_NONE,
876 else if (wd->mode == ELM_FILESELECTOR_GRID)
878 elm_gengrid_item_append(wd->files_grid, &grid_itc[type],
880 elm_gengrid_item_append(wd->files_grid, grid_itc[type],
881 >>>>>>> remotes/origin/upstream
882 real, /* item data */
888 if (wd->expand && wd->current) return ;
889 >>>>>>> remotes/origin/upstream
891 eio_file_cancel(wd->current);
892 wr = malloc(sizeof (Widget_Request));
895 EINA_REFCOUNT_REF(wr->wd);
896 wr->parent = parent; /* FIXME: should we refcount the parent ? */
898 wr->path = eina_stringshare_add(path);
899 wr->first = EINA_TRUE;
901 wd->current = eio_file_stat_ls(path,
913 elm_fileselector_add(Evas_Object *parent)
916 Evas_Object *obj, *ic, *bt, *li, *en, *grid;
921 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
923 EINA_REFCOUNT_INIT(wd);
925 ELM_SET_WIDTYPE(widtype, "fileselector");
926 elm_widget_type_set(obj, "fileselector");
927 elm_widget_sub_object_add(parent, obj);
928 elm_widget_data_set(obj, wd);
929 elm_widget_del_hook_set(obj, _del_hook);
930 elm_widget_theme_hook_set(obj, _theme_hook);
931 elm_widget_can_focus_set(obj, EINA_FALSE);
933 wd->expand = !!_elm_config->fileselector_expand_enable;
935 wd->edje = edje_object_add(e);
936 _elm_theme_object_set(obj, wd->edje, "fileselector", "base", "default");
937 elm_widget_resize_object_set(obj, wd->edje);
940 ic = elm_icon_add(parent);
941 elm_icon_standard_set(ic, "arrow_up");
942 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
943 bt = elm_button_add(parent);
944 elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
945 elm_object_part_content_set(bt, "icon", ic);
946 elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Up"));
947 evas_object_size_hint_align_set(bt, 0.0, 0.0);
949 evas_object_smart_callback_add(bt, "clicked", _up, obj);
951 elm_widget_sub_object_add(obj, bt);
955 ic = elm_icon_add(parent);
956 elm_icon_standard_set(ic, "home");
957 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
958 bt = elm_button_add(parent);
959 elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
960 elm_object_part_content_set(bt, "icon", ic);
961 elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Home"));
962 evas_object_size_hint_align_set(bt, 0.0, 0.0);
964 evas_object_smart_callback_add(bt, "clicked", _home, obj);
966 elm_widget_sub_object_add(obj, bt);
967 wd->home_button = bt;
970 list_itc[ELM_DIRECTORY].func.content_get = grid_itc[ELM_DIRECTORY].func.content_get = _itc_icon_folder_get;
971 list_itc[ELM_FILE_IMAGE].func.content_get = grid_itc[ELM_FILE_IMAGE].func.content_get = _itc_icon_image_get;
972 list_itc[ELM_FILE_UNKNOW].func.content_get = grid_itc[ELM_FILE_UNKNOW].func.content_get = _itc_icon_file_get;
974 for (i = 0; i < ELM_FILE_LAST; ++i)
976 list_itc[i].func.text_get = grid_itc[i].func.text_get = _itc_text_get;
977 list_itc[i].func.state_get = grid_itc[i].func.state_get = _itc_state_get;
978 list_itc[i].func.del = grid_itc[i].func.del = _itc_del;
982 for (i = 0; i < ELM_FILE_LAST; ++i)
984 list_itc[i] = elm_genlist_item_class_new();
985 grid_itc[i] = elm_gengrid_item_class_new();
987 list_itc[i]->item_style = "default";
988 list_itc[i]->func.text_get = grid_itc[i]->func.text_get = _itc_text_get;
989 list_itc[i]->func.state_get = grid_itc[i]->func.state_get = _itc_state_get;
990 list_itc[i]->func.del = grid_itc[i]->func.del = _itc_del;
993 list_itc[ELM_DIRECTORY]->func.content_get =
994 grid_itc[ELM_DIRECTORY]->func.content_get = _itc_icon_folder_get;
995 list_itc[ELM_FILE_IMAGE]->func.content_get =
996 grid_itc[ELM_FILE_IMAGE]->func.content_get = _itc_icon_image_get;
997 list_itc[ELM_FILE_UNKNOW]->func.content_get =
998 grid_itc[ELM_FILE_UNKNOW]->func.content_get = _itc_icon_file_get;
1000 >>>>>>> remotes/origin/upstream
1001 li = elm_genlist_add(parent);
1002 elm_widget_mirrored_automatic_set(li, EINA_FALSE);
1003 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
1004 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1005 evas_object_size_hint_min_set(li, 100, 100);
1007 grid = elm_gengrid_add(parent);
1008 elm_widget_mirrored_automatic_set(grid, EINA_FALSE);
1009 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
1010 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1013 s = elm_finger_size_get() * 2;
1015 // XXX: will fail for dynamic finger size changing
1016 s = _elm_config->finger_size * 2;
1017 >>>>>>> remotes/origin/upstream
1018 elm_gengrid_item_size_set(grid, s, s);
1019 elm_gengrid_align_set(grid, 0.0, 0.0);
1021 evas_object_smart_callback_add(li, "selected", _sel, obj);
1022 evas_object_smart_callback_add(li, "expand,request", _expand_req, obj);
1023 evas_object_smart_callback_add(li, "contract,request", _contract_req, obj);
1024 evas_object_smart_callback_add(li, "expanded", _expand_done, obj);
1025 evas_object_smart_callback_add(li, "contracted", _contract_done, obj);
1027 evas_object_smart_callback_add(grid, "selected", _sel, obj);
1029 elm_widget_sub_object_add(obj, li);
1030 elm_widget_sub_object_add(obj, grid);
1031 wd->files_list = li;
1032 wd->files_grid = grid;
1035 en = elm_entry_add(parent);
1036 elm_entry_scrollable_set(en, EINA_TRUE);
1037 elm_widget_mirrored_automatic_set(en, EINA_FALSE);
1038 elm_entry_editable_set(en, EINA_FALSE);
1039 elm_entry_single_line_set(en, EINA_TRUE);
1040 elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
1041 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1042 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1044 evas_object_smart_callback_add(en, "anchor,clicked", _anchor_clicked, obj);
1046 elm_widget_sub_object_add(obj, en);
1047 wd->path_entry = en;
1050 en = elm_entry_add(parent);
1051 elm_entry_scrollable_set(en, EINA_TRUE);
1052 elm_widget_mirrored_automatic_set(en, EINA_FALSE);
1053 elm_entry_editable_set(en, EINA_TRUE);
1054 elm_entry_single_line_set(en, EINA_TRUE);
1055 elm_entry_line_wrap_set(en, ELM_WRAP_CHAR);
1056 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1057 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1059 elm_widget_sub_object_add(obj, en);
1060 wd->filename_entry = en;
1062 elm_fileselector_buttons_ok_cancel_set(obj, EINA_TRUE);
1063 elm_fileselector_is_save_set(obj, EINA_FALSE);
1067 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1072 elm_fileselector_is_save_set(Evas_Object *obj,
1075 ELM_CHECK_WIDTYPE(obj, widtype);
1076 Widget_Data *wd = elm_widget_data_get(obj);
1079 elm_object_disabled_set(wd->filename_entry, !is_save);
1082 edje_object_signal_emit(wd->edje, "elm,state,save,on", "elm");
1084 edje_object_signal_emit(wd->edje, "elm,state,save,off", "elm");
1088 elm_fileselector_is_save_get(const Evas_Object *obj)
1090 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1091 Widget_Data *wd = elm_widget_data_get(obj);
1092 if (!wd) return EINA_FALSE;
1094 return elm_object_disabled_get(wd->filename_entry);
1096 return !elm_object_disabled_get(wd->filename_entry);
1097 >>>>>>> remotes/origin/upstream
1101 elm_fileselector_folder_only_set(Evas_Object *obj,
1104 ELM_CHECK_WIDTYPE(obj, widtype);
1105 Widget_Data *wd = elm_widget_data_get(obj);
1107 if (wd->only_folder == only) return;
1108 wd->only_folder = !!only;
1109 if (wd->path) _populate(obj, wd->path, NULL);
1113 elm_fileselector_folder_only_get(const Evas_Object *obj)
1115 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1116 Widget_Data *wd = elm_widget_data_get(obj);
1117 if (!wd) return EINA_FALSE;
1118 return wd->only_folder;
1122 elm_fileselector_buttons_ok_cancel_set(Evas_Object *obj,
1125 ELM_CHECK_WIDTYPE(obj, widtype);
1126 Widget_Data *wd = elm_widget_data_get(obj);
1133 bt = elm_button_add(obj);
1134 elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
1135 elm_object_domain_translatable_text_set(bt, PACKAGE, N_("Cancel"));
1137 evas_object_smart_callback_add(bt, "clicked", _canc, obj);
1139 elm_widget_sub_object_add(obj, bt);
1140 wd->cancel_button = bt;
1143 bt = elm_button_add(obj);
1144 elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
1145 elm_object_domain_translatable_text_set(bt, PACKAGE, N_("OK"));
1147 evas_object_smart_callback_add(bt, "clicked", _ok, obj);
1149 elm_widget_sub_object_add(obj, bt);
1156 evas_object_del(wd->cancel_button);
1157 wd->cancel_button = NULL;
1158 evas_object_del(wd->ok_button);
1159 wd->ok_button = NULL;
1164 elm_fileselector_buttons_ok_cancel_get(const Evas_Object *obj)
1166 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1167 Widget_Data *wd = elm_widget_data_get(obj);
1168 if (!wd) return EINA_FALSE;
1169 return wd->ok_button ? EINA_TRUE : EINA_FALSE;
1173 elm_fileselector_expandable_set(Evas_Object *obj,
1176 ELM_CHECK_WIDTYPE(obj, widtype);
1179 wd = elm_widget_data_get(obj);
1182 wd->expand = !!expand;
1184 if (wd->path) _populate(obj, wd->path, NULL);
1188 elm_fileselector_expandable_get(const Evas_Object *obj)
1190 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1191 Widget_Data *wd = elm_widget_data_get(obj);
1192 if (!wd) return EINA_FALSE;
1197 elm_fileselector_path_set(Evas_Object *obj,
1201 ELM_CHECK_WIDTYPE(obj, widtype);
1202 _populate(obj, path, NULL);
1206 ELM_CHECK_WIDTYPE(obj, widtype);
1208 path = ecore_file_realpath(_path);
1209 _populate(obj, path, NULL);
1211 >>>>>>> remotes/origin/upstream
1215 elm_fileselector_path_get(const Evas_Object *obj)
1217 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1218 Widget_Data *wd = elm_widget_data_get(obj);
1219 if (!wd) return NULL;
1224 elm_fileselector_mode_set(Evas_Object *obj,
1225 Elm_Fileselector_Mode mode)
1227 ELM_CHECK_WIDTYPE(obj, widtype);
1229 Widget_Data *wd = elm_widget_data_get(obj);
1232 if (mode == wd->mode) return;
1234 if (mode == ELM_FILESELECTOR_LIST)
1236 if (edje_object_part_swallow(wd->edje, "elm.swallow.files",
1239 evas_object_show(wd->files_list);
1240 evas_object_hide(wd->files_grid);
1243 evas_object_hide(wd->files_list);
1247 if (edje_object_part_swallow(wd->edje, "elm.swallow.files",
1250 evas_object_show(wd->files_grid);
1251 evas_object_hide(wd->files_list);
1254 evas_object_hide(wd->files_grid);
1259 _populate(obj, wd->path, NULL);
1262 EAPI Elm_Fileselector_Mode
1263 elm_fileselector_mode_get(const Evas_Object *obj)
1265 ELM_CHECK_WIDTYPE(obj, widtype) ELM_FILESELECTOR_LAST;
1267 Widget_Data *wd = elm_widget_data_get(obj);
1268 if (!wd) return ELM_FILESELECTOR_LAST;
1274 elm_fileselector_selected_get(const Evas_Object *obj)
1276 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1277 Widget_Data *wd = elm_widget_data_get(obj);
1278 if (!wd) return NULL;
1280 if (wd->filename_entry)
1286 dir = wd->only_folder ? ecore_file_dir_get(wd->path) : strdup(wd->path);
1287 name = elm_object_text_get(wd->filename_entry);
1288 snprintf(buf, sizeof(buf), "%s/%s",
1290 if (wd->only_folder && !ecore_file_is_dir(buf))
1291 eina_stringshare_replace(&wd->selection, ecore_file_dir_get(buf));
1293 eina_stringshare_replace(&wd->selection, buf);
1295 return wd->selection;
1298 if (wd->mode == ELM_FILESELECTOR_LIST)
1301 Elm_Object_Item *it;
1302 it = elm_genlist_selected_item_get(wd->files_list);
1303 if (it) return elm_genlist_item_data_get(it);
1307 Elm_Object_Item *it;
1308 it = elm_gengrid_selected_item_get(wd->files_grid);
1309 if (it) return elm_object_item_data_get(it);
1311 Elm_Object_Item *gl_it = elm_genlist_selected_item_get(wd->files_list);
1312 if (gl_it) return elm_object_item_data_get(gl_it);
1316 Elm_Object_Item *gg_it = elm_gengrid_selected_item_get(wd->files_grid);
1317 if (gg_it) return elm_object_item_data_get(gg_it);
1318 >>>>>>> remotes/origin/upstream
1325 elm_fileselector_selected_set(Evas_Object *obj,
1330 >>>>>>> remotes/origin/upstream
1332 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1333 Widget_Data *wd = elm_widget_data_get(obj);
1334 if (!wd) return EINA_FALSE;
1338 Eina_Bool ret = EINA_TRUE;
1340 path = ecore_file_realpath(_path);
1342 >>>>>>> remotes/origin/upstream
1343 if (ecore_file_is_dir(path))
1344 _populate(obj, path, NULL);
1347 if (!ecore_file_exists(path))
1355 >>>>>>> remotes/origin/upstream
1357 _populate(obj, ecore_file_dir_get(path), NULL);
1358 if (wd->filename_entry)
1360 elm_object_text_set(wd->filename_entry,
1361 ecore_file_file_get(path));
1362 eina_stringshare_replace(&wd->selection, path);
1372 >>>>>>> remotes/origin/upstream