elm_fileselector_button: support the whole interface

this adds full support of the full elm_fileselector interface to
elm_fileselector_button.

ref T5719

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7753
This commit is contained in:
Marcel Hollerbach 2019-01-24 11:32:38 +01:00
parent 67d9b49c1b
commit 1c27529363
4 changed files with 68 additions and 1 deletions

View File

@ -98,7 +98,7 @@ _selection_done(void *data, const Efl_Event *event EINA_UNUSED)
_model_event_call
(sd->obj, ELM_FILESELECTOR_BUTTON_EVENT_FILE_CHOSEN, NULL, NULL);
}
eina_stringshare_replace(&sd->fsd.current_name, elm_interface_fileselector_current_name_get(sd->fs));
del = sd->fsw;
sd->fs = NULL;
sd->fsw = NULL;
@ -629,6 +629,54 @@ _elm_fileselector_button_elm_interface_fileselector_hidden_visible_set(Eo *obj E
if (sd->fs) elm_fileselector_hidden_visible_set(sd->fs, visible);
}
EOLIAN static void
_elm_fileselector_button_elm_interface_fileselector_current_name_set(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd, const char *name)
{
eina_stringshare_replace(&sd->fsd.current_name, name);
if (sd->fs) elm_fileselector_current_name_set(sd->fs, sd->fsd.current_name);
}
EOLIAN static const char*
_elm_fileselector_button_elm_interface_fileselector_current_name_get(const Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
{
if (sd->fs)
return elm_fileselector_current_name_get(sd->fs);
return sd->fsd.current_name;
}
#define FS_USAGE_API(ret)\
if (!pd->fs) \
{ \
ERR("This function is only supported when there is a fileselector"); \
return ret; \
} \
EOLIAN static Eina_Bool
_elm_fileselector_button_elm_interface_fileselector_custom_filter_append(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *pd, Elm_Fileselector_Filter_Func func, void *data, const char *filter_name)
{
FS_USAGE_API(EINA_FALSE)
return elm_interface_fileselector_custom_filter_append(pd->fs, func, data, filter_name);
}
EOLIAN static Eina_Bool
_elm_fileselector_button_elm_interface_fileselector_mime_types_filter_append(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *pd, const char *mime_types, const char *filter_name)
{
FS_USAGE_API(EINA_FALSE)
return elm_interface_fileselector_mime_types_filter_append(pd->fs, mime_types, filter_name);
}
EOLIAN static void
_elm_fileselector_button_elm_interface_fileselector_filters_clear(Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *pd)
{
FS_USAGE_API()
elm_interface_fileselector_filters_clear(pd->fs);
}
EOLIAN static Eina_Bool
_elm_fileselector_button_elm_interface_fileselector_hidden_visible_get(const Eo *obj EINA_UNUSED, Elm_Fileselector_Button_Data *sd)
{

View File

@ -18,6 +18,10 @@ class Elm.Fileselector_Button extends Efl.Ui.Button implements Elm.Interface.Fil
Elm.Interface.Fileselector.multi_select { get; set; }
Elm.Interface.Fileselector.folder_only { get; set; }
Elm.Interface.Fileselector.mode { get; set; }
Elm.Interface.Fileselector.current_name { get; set; }
Elm.Interface.Fileselector.custom_filter_append;
Elm.Interface.Fileselector.mime_types_filter_append;
Elm.Interface.Fileselector.filters_clear;
}
events {
/* FIXME: Can be Efl.Model, string and NULL */

View File

@ -41,6 +41,7 @@ struct _Elm_Fileselector_Button_Data
const char *path;
Efl_Model *selection;
const char *selection_path;
const char *current_name;
Evas_Coord_Size thumbnail_size;
Elm_Fileselector_Mode mode;
Elm_Fileselector_Sort sort_type;

View File

@ -26,6 +26,19 @@ EFL_START_TEST (elm_fileselector_button_legacy_type_check)
}
EFL_END_TEST
EFL_START_TEST (elm_fileselector_button_current_name)
{
Evas_Object *win, *fs_button;
win = win_add(NULL, "fileselector_button", ELM_WIN_BASIC);
fs_button = elm_fileselector_button_add(win);
elm_fileselector_current_name_set(fs_button, "test.txt");
ck_assert_str_eq(elm_fileselector_current_name_get(fs_button), "test.txt");
}
EFL_END_TEST
EFL_START_TEST (elm_atspi_role_get)
{
Evas_Object *win, *fs_button;
@ -44,5 +57,6 @@ EFL_END_TEST
void elm_test_fileselector_button(TCase *tc)
{
tcase_add_test(tc, elm_fileselector_button_legacy_type_check);
tcase_add_test(tc, elm_fileselector_button_current_name);
tcase_add_test(tc, elm_atspi_role_get);
}