diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-01-24 11:32:38 +0100 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-01-26 11:42:02 +0100 |
commit | 1c27529363faa90450685140b7fa552fb24ab546 (patch) | |
tree | 7f75ecd4c2fb58bb6b9eb7cb8dfc0e934a901c57 | |
parent | 67d9b49c1bc9dd5d505aa9c31da9fb26fb4da444 (diff) | |
download | efl-1c27529363faa90450685140b7fa552fb24ab546.tar.gz |
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
-rw-r--r-- | src/lib/elementary/elc_fileselector_button.c | 50 | ||||
-rw-r--r-- | src/lib/elementary/elm_fileselector_button.eo | 4 | ||||
-rw-r--r-- | src/lib/elementary/elm_widget_fileselector_button.h | 1 | ||||
-rw-r--r-- | src/tests/elementary/elm_test_fileselector_button.c | 14 |
4 files changed, 68 insertions, 1 deletions
diff --git a/src/lib/elementary/elc_fileselector_button.c b/src/lib/elementary/elc_fileselector_button.c index 86632611bc..16d76cbf51 100644 --- a/src/lib/elementary/elc_fileselector_button.c +++ b/src/lib/elementary/elc_fileselector_button.c @@ -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) { diff --git a/src/lib/elementary/elm_fileselector_button.eo b/src/lib/elementary/elm_fileselector_button.eo index 545409f229..be3de44d08 100644 --- a/src/lib/elementary/elm_fileselector_button.eo +++ b/src/lib/elementary/elm_fileselector_button.eo @@ -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 */ diff --git a/src/lib/elementary/elm_widget_fileselector_button.h b/src/lib/elementary/elm_widget_fileselector_button.h index e055ae10de..86c8b53810 100644 --- a/src/lib/elementary/elm_widget_fileselector_button.h +++ b/src/lib/elementary/elm_widget_fileselector_button.h @@ -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; diff --git a/src/tests/elementary/elm_test_fileselector_button.c b/src/tests/elementary/elm_test_fileselector_button.c index c5bba5ccfa..97db3dcd58 100644 --- a/src/tests/elementary/elm_test_fileselector_button.c +++ b/src/tests/elementary/elm_test_fileselector_button.c @@ -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); } |