From: Ryuan Choi Date: Fri, 18 Oct 2013 03:16:54 +0000 (+0900) Subject: elc_fileselector: Added support to show/hide hidden files/directories. X-Git-Tag: upstream/1.20.0~7116^2~14^2~3928 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5c6eaa50e59131becea426f83cb62f3079c63c6;p=platform%2Fupstream%2Fefl.git elc_fileselector: Added support to show/hide hidden files/directories. Added elm_fileselector_hidden_visible_set/get to show or hide hidden resources. --- diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index 285dc57..2358d2b 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1708,3 +1708,6 @@ * Default theme is now dark. +2013-10-18 Ryuan Choi (ryuan) + + * fileselector : Add support visibility control of hidden files/directories. diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index fc17a2e..7489b41 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -98,6 +98,7 @@ Additions: * Add "activated" smart callback for fileselector. * Add elm_object_item_signal_emit support in hoversel. This works only when the item is created. * Add elm_fileselector_multi_select_set/get() and elm_fileselector_selected_paths_get to support multi-selection. + * Add elm_fileselector_hidden_visible_set/get() to show or hide hidden files/directories. Improvements: diff --git a/legacy/elementary/src/bin/test_fileselector.c b/legacy/elementary/src/bin/test_fileselector.c index f6ee2bc..c1f5044 100644 --- a/legacy/elementary/src/bin/test_fileselector.c +++ b/legacy/elementary/src/bin/test_fileselector.c @@ -144,8 +144,8 @@ _multi_clicked(void *data, static void _buttons_clicked(void *data, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) { Evas_Object *fs = data; printf("Toggle Buttons\n"); @@ -156,6 +156,19 @@ _buttons_clicked(void *data, } static void +_hidden_clicked(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Evas_Object *fs = data; + printf("Toggle visibility of hidden files/directories\n"); + if (elm_fileselector_hidden_visible_get(fs)) + elm_fileselector_hidden_visible_set(fs, EINA_FALSE); + else + elm_fileselector_hidden_visible_set(fs, EINA_TRUE); +} + +static void _sel_get_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) @@ -224,6 +237,13 @@ _option_create(Evas_Object *parent, Evas_Object *fs) elm_box_pack_end(hbox, bt); evas_object_show(bt); + bt = elm_check_add(hbox); + elm_object_text_set(bt, "hidden"); + elm_check_state_set(bt, elm_fileselector_hidden_visible_get(fs)); + evas_object_smart_callback_add(bt, "changed", _hidden_clicked, fs); + elm_box_pack_end(hbox, bt); + evas_object_show(bt); + return frame; } diff --git a/legacy/elementary/src/lib/elc_fileselector.c b/legacy/elementary/src/lib/elc_fileselector.c index 84a391d..6ffe33e 100644 --- a/legacy/elementary/src/lib/elc_fileselector.c +++ b/legacy/elementary/src/lib/elc_fileselector.c @@ -3,7 +3,6 @@ * - child elements focusing support * - user defined icon/label cb * - show/hide/add buttons ??? - * - show/hide hidden files * - make variable/function names that are sensible * - Pattern Filter support * - Custom Filter support @@ -314,7 +313,7 @@ _ls_filter_cb(void *data, { Listing_Request *lreq = data; - if (info->path[info->name_start] == '.') + if (!lreq->sd->hidden_visible && info->path[info->name_start] == '.') return EINA_FALSE; if (lreq->sd->only_folder && info->type != EINA_FILE_DIR) @@ -538,7 +537,7 @@ _populate(Evas_Object *obj, { const char *filename; - if (file->path[file->name_start] == '.') continue; + if (!sd->hidden_visible && file->path[file->name_start] == '.') continue; filename = eina_stringshare_add(file->path); if (file->type == EINA_FILE_DIR) @@ -1818,6 +1817,45 @@ _filters_clear(Eo *obj, void *_pd, va_list *list EINA_UNUSED) _populate(obj, sd->path, NULL, NULL); } +EAPI void +elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible) +{ + ELM_FILESELECTOR_CHECK(obj); + eo_do(obj, elm_obj_fileselector_hidden_visible_set(visible)); +} + +static void +_hidden_visible_set(Eo *obj __UNUSED__, void *_pd, va_list *list EINA_UNUSED) +{ + Eina_Bool visible = va_arg(*list, int); + Elm_Fileselector_Smart_Data *sd = _pd; + + visible = !!visible; + if (sd->hidden_visible == visible) return; + sd->hidden_visible = visible; + + _clear_selections(sd, NULL); + _populate(obj, sd->path, NULL, NULL); +} + +EAPI Eina_Bool +elm_fileselector_hidden_visible_get(const Evas_Object *obj) +{ + ELM_FILESELECTOR_CHECK(obj) EINA_FALSE; + Eina_Bool ret = EINA_FALSE; + eo_do((Eo *) obj, elm_obj_fileselector_hidden_visible_get(&ret)); + return ret; +} + +static void +_hidden_visible_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED) +{ + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + Elm_Fileselector_Smart_Data *sd = _pd; + + *ret = sd->hidden_visible; +} + static void _elm_fileselector_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) { @@ -1898,6 +1936,8 @@ _class_constructor(Eo_Class *klass) EO_OP_FUNC(ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_SELECTED_PATHS_GET), _selected_paths_get), EO_OP_FUNC(ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_MIME_TYPES_FILTER_APPEND), _mime_types_filter_append), EO_OP_FUNC(ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_FILTERS_CLEAR), _filters_clear), + EO_OP_FUNC(ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_SET), _hidden_visible_set), + EO_OP_FUNC(ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_GET), _hidden_visible_get), EO_OP_FUNC_SENTINEL }; eo_class_funcs_set(klass, func_desc); @@ -1958,6 +1998,8 @@ static const Eo_Op_Description op_desc[] = { EO_OP_DESCRIPTION(ELM_OBJ_FILESELECTOR_SUB_ID_SELECTED_PATHS_GET, "Get the currently selected item's (full) path, in the given file selector widget."), EO_OP_DESCRIPTION(ELM_OBJ_FILESELECTOR_SUB_ID_MIME_TYPES_FILTER_APPEND, "Append mime type filter"), EO_OP_DESCRIPTION(ELM_OBJ_FILESELECTOR_SUB_ID_FILTERS_CLEAR, "Clear filters"), + EO_OP_DESCRIPTION(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_SET, "Enable or disable visibility of hidden files/directories in the file selector widget."), + EO_OP_DESCRIPTION(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_GET, "Get if visibility of hidden files/directories in the file selector widget is enabled or disabled."), EO_OP_DESCRIPTION_SENTINEL }; static const Eo_Class_Description class_desc = { diff --git a/legacy/elementary/src/lib/elc_fileselector_eo.h b/legacy/elementary/src/lib/elc_fileselector_eo.h index 351c9b7..e50fa9c 100644 --- a/legacy/elementary/src/lib/elc_fileselector_eo.h +++ b/legacy/elementary/src/lib/elc_fileselector_eo.h @@ -30,6 +30,8 @@ enum ELM_OBJ_FILESELECTOR_SUB_ID_SELECTED_PATHS_GET, ELM_OBJ_FILESELECTOR_SUB_ID_MIME_TYPES_FILTER_APPEND, ELM_OBJ_FILESELECTOR_SUB_ID_FILTERS_CLEAR, + ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_SET, + ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_GET, ELM_OBJ_FILESELECTOR_SUB_ID_LAST }; @@ -274,5 +276,30 @@ enum #define elm_obj_fileselector_filters_clear() ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_FILTERS_CLEAR) /** + * @def elm_obj_fileselector_hidden_visible_set + * @since 1.8 + * + * Enable or disable visibility of hidden files/directories + * in the file selector widget. + * + * @param[in] visible + * + * @see elm_fileselector_hidden_visible_get + */ +#define elm_obj_fileselector_hidden_visible_set(multi) ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_SET), EO_TYPECHECK(Eina_Bool, multi) + +/** + * @def elm_obj_fileselector_hidden_visible_get + * @since 1.8 + * + * Get if hiden files/directories in the file selector are visible or not. + * + * @param[out] visible + * + * @see elm_fileselector_hidden_visible_set + */ +#define elm_obj_fileselector_hidden_visible_get(ret) ELM_OBJ_FILESELECTOR_ID(ELM_OBJ_FILESELECTOR_SUB_ID_HIDDEN_VISIBLE_GET), EO_TYPECHECK(Eina_Bool *, ret) + +/** * @} */ diff --git a/legacy/elementary/src/lib/elc_fileselector_legacy.h b/legacy/elementary/src/lib/elc_fileselector_legacy.h index c94a724..4b5ab8a 100644 --- a/legacy/elementary/src/lib/elc_fileselector_legacy.h +++ b/legacy/elementary/src/lib/elc_fileselector_legacy.h @@ -333,3 +333,32 @@ EAPI Eina_Bool elm_fileselector_mime_types_filter_append(Evas_Object * @ingroup Fileselector */ EAPI void elm_fileselector_filters_clear(Evas_Object *obj); + +/** + * Enable or disable visibility of hidden files/directories + * in the file selector widget. + * + * @param obj The file selector object + * @param visible Visibility of hidden files/directories. Default is disabled. + * + * This enables (@c EINA_TRUE) or disables (@c EINA_FALSE) visibility of hidden + * files/directories in the list/grid of the file selector widget. + * + * @since 1.8 + * @ingroup Fileselector + */ +EAPI void elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible); + +/** + * Get if hiden files/directories in the file selector widget are visible or not. + * + * @param obj The file selector object + * @return Visibility of hidden files/directories + * (@c EINA_TRUE = enabled/@c EINA_FALSE = disabled). Default is @c EINA_FALSE. + * + * @see elm_fileselector_hidden_visible_set() + * + * @since 1.8 + * @ingroup Fileselector + */ +EAPI Eina_Bool elm_fileselector_hidden_visible_get(const Evas_Object *obj); diff --git a/legacy/elementary/src/lib/elm_widget_fileselector.h b/legacy/elementary/src/lib/elm_widget_fileselector.h index 889e11b..dec0f06 100644 --- a/legacy/elementary/src/lib/elm_widget_fileselector.h +++ b/legacy/elementary/src/lib/elm_widget_fileselector.h @@ -64,6 +64,8 @@ struct _Elm_Fileselector_Smart_Data * so that fileselector will clear current selection when user clicked * another item. */ Eina_Bool dir_selected : 1; + + Eina_Bool hidden_visible : 1; }; struct sel_data