diff --git a/src/lib/elementary/efl_ui_bg_widget.c b/src/lib/elementary/efl_ui_bg_widget.c index 3cc8fb1c58..7f18b8a8c4 100644 --- a/src/lib/elementary/efl_ui_bg_widget.c +++ b/src/lib/elementary/efl_ui_bg_widget.c @@ -45,6 +45,8 @@ _efl_ui_bg_widget_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Widget_Data *pd) pd->img = efl_add(EFL_UI_IMAGE_CLASS, obj, efl_image_scale_type_set(efl_added, EFL_IMAGE_SCALE_TYPE_FIT_OUTSIDE), efl_content_set(efl_part(obj, "elm.swallow.background"), efl_added)); + pd->file = NULL; + pd->key = NULL; efl_access_type_set(obj, EFL_ACCESS_TYPE_DISABLED); @@ -53,6 +55,15 @@ _efl_ui_bg_widget_efl_object_constructor(Eo *obj, Efl_Ui_Bg_Widget_Data *pd) return obj; } +EOLIAN static void +_efl_ui_bg_widget_efl_object_destructor(Eo *obj, Efl_Ui_Bg_Widget_Data *sd) +{ + ELM_SAFE_FREE(sd->file, eina_stringshare_del); + ELM_SAFE_FREE(sd->key, eina_stringshare_del); + + efl_destructor(efl_super(obj, MY_CLASS)); +} + EAPI void elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option) { @@ -191,6 +202,9 @@ elm_bg_file_set(Eo *obj, const char *file, const char *group) EOLIAN static Eina_Bool _efl_ui_bg_widget_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, const char *file, const char *key) { + eina_stringshare_replace(&sd->file, file); + eina_stringshare_replace(&sd->key, key); + return efl_file_set(sd->img, file, key); } EAPI void @@ -200,8 +214,15 @@ elm_bg_file_get(const Eo *obj, const char **file, const char **group) } EOLIAN static void -_efl_ui_bg_widget_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Bg_Widget_Data *sd, const char **file, const char **key) +_efl_ui_bg_widget_efl_file_file_get(Eo *obj, Efl_Ui_Bg_Widget_Data *sd, const char **file, const char **key) { + if (elm_widget_is_legacy(obj)) + { + *file = sd->file; + *key = sd->key; + return; + } + efl_file_get(sd->img, file, key); } diff --git a/src/lib/elementary/efl_ui_bg_widget.eo b/src/lib/elementary/efl_ui_bg_widget.eo index ef8882d7ac..105108c750 100644 --- a/src/lib/elementary/efl_ui_bg_widget.eo +++ b/src/lib/elementary/efl_ui_bg_widget.eo @@ -9,6 +9,7 @@ class Efl.Ui.Bg_Widget (Efl.Ui.Layout, Efl.Ui.Bg, Efl.Image.Load) legacy_prefix: elm_bg; implements { Efl.Object.constructor; + Efl.Object.destructor; Efl.File.file { get; set; } Efl.File.mmap { get; set; } Efl.Gfx.Color.color { get; set; } diff --git a/src/lib/elementary/efl_ui_bg_widget_private.h b/src/lib/elementary/efl_ui_bg_widget_private.h index 0ef56c113b..e886db50ba 100644 --- a/src/lib/elementary/efl_ui_bg_widget_private.h +++ b/src/lib/elementary/efl_ui_bg_widget_private.h @@ -28,6 +28,8 @@ struct _Efl_Ui_Bg_Widget_Data { Evas_Object *rect; /*<< Used for elm_bg_color_set(): elm.swallow.rectangle */ Evas_Object *img; /*<< Used for elm_bg_file_set(): elm.swallow.content */ + const char *file; /*<< Used for elm_bg_file_set() with legacy widget */ + const char *key; /*<< Used for elm_bg_file_set() with legacy widget */ }; /** diff --git a/src/tests/elementary/elm_test_bg.c b/src/tests/elementary/elm_test_bg.c index 7a7fbd9c47..9ce43bcb5b 100644 --- a/src/tests/elementary/elm_test_bg.c +++ b/src/tests/elementary/elm_test_bg.c @@ -28,7 +28,35 @@ START_TEST (elm_bg_legacy_type_check) } END_TEST +START_TEST (elm_bg_legacy_file_set_get_check) +{ + Evas_Object *win, *bg; + const char *file = NULL, *key = NULL; + + elm_init(1, NULL); + win = elm_win_add(NULL, "bg", ELM_WIN_BASIC); + + bg = elm_bg_add(win); + + /* This test case will check the following things for legacy widget. + * It is all about backward compatibility. + * 1. Set and Get file path, key even if there is no proper image file for the given file path. + * 2. Even if there is a proper image file and the given file path is interpreted to full file path, + * the Get function should give original file path. NOT interpreted. */ + elm_bg_file_set(bg, "~/test.png", "test_key"); + elm_bg_file_get(bg, &file, &key); + + ck_assert(file != NULL); + ck_assert(!strcmp(file, "~/test.png")); + ck_assert(key != NULL); + ck_assert(!strcmp(key, "test_key")); + + elm_shutdown(); +} +END_TEST + void elm_test_bg(TCase *tc EINA_UNUSED) { tcase_add_test(tc, elm_bg_legacy_type_check); + tcase_add_test(tc, elm_bg_legacy_file_set_get_check); }