summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-02-12 10:52:43 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-03-08 14:31:01 -0800
commite7afae9a8b7ca3fc3c65b1e4d541eb6f1788bfe5 (patch)
tree2426a257e6686c8b85d108780a8cb265634fbc5b
parentd1d30f442bb376817535838a8747764941a2329c (diff)
elementary: Efl.Ui.Image now rely on Efl.Ui.Widget infrastructure for View and Property_Bind.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D7942
-rw-r--r--src/lib/elementary/efl_ui_image.c42
-rw-r--r--src/lib/elementary/efl_ui_image.eo4
-rw-r--r--src/lib/elementary/efl_ui_widget_image.h1
3 files changed, 25 insertions, 22 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index a29ce753a7..4e75b29f9b 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -595,6 +595,8 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
595EOLIAN static void 595EOLIAN static void
596_efl_ui_image_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Data *sd) 596_efl_ui_image_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Data *sd)
597{ 597{
598 Efl_Model *model;
599
598 if (elm_widget_is_legacy(obj)) 600 if (elm_widget_is_legacy(obj))
599 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, 601 efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
600 _on_size_hints_changed, sd); 602 _on_size_hints_changed, sd);
@@ -607,12 +609,11 @@ _efl_ui_image_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Data *sd)
607 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free); 609 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
608 ELM_SAFE_FREE(sd->remote.key, eina_stringshare_del); 610 ELM_SAFE_FREE(sd->remote.key, eina_stringshare_del);
609 611
610 if (sd->property.model) 612 model = efl_ui_view_model_get(obj);
613 if (model)
611 { 614 {
612 efl_event_callback_del(sd->property.model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, 615 efl_event_callback_del(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
613 _efl_ui_image_model_properties_changed_cb, obj); 616 _efl_ui_image_model_properties_changed_cb, obj);
614 efl_unref(sd->property.model);
615 sd->property.model = NULL;
616 } 617 }
617 618
618 efl_canvas_group_del(efl_super(obj, MY_CLASS)); 619 efl_canvas_group_del(efl_super(obj, MY_CLASS));
@@ -1849,12 +1850,14 @@ _update_viewmodel(Eo *obj, Efl_Ui_Image_Data *pd)
1849 Eina_File *f = NULL; 1850 Eina_File *f = NULL;
1850 char *file = NULL; 1851 char *file = NULL;
1851 char *key = NULL; 1852 char *key = NULL;
1853 Efl_Model *model;
1852 1854
1853 if (!pd->property.model) return ; 1855 model = efl_ui_view_model_get(obj);
1856 if (!model) return ;
1854 1857
1855 vfile = efl_model_property_get(pd->property.model, pd->property.file); 1858 vfile = efl_model_property_get(model, pd->property.file);
1856 if (!vfile) return; 1859 if (!vfile) return;
1857 vkey = efl_model_property_get(pd->property.model, pd->property.key); 1860 vkey = efl_model_property_get(model, pd->property.key);
1858 1861
1859 if (eina_value_type_get(vfile) == EINA_VALUE_TYPE_ERROR) 1862 if (eina_value_type_get(vfile) == EINA_VALUE_TYPE_ERROR)
1860 goto err; 1863 goto err;
@@ -1926,29 +1929,27 @@ _efl_ui_image_model_properties_changed_cb(void *data, const Efl_Event *event)
1926EOLIAN static void 1929EOLIAN static void
1927_efl_ui_image_efl_ui_view_model_set(Eo *obj, Efl_Ui_Image_Data *pd, Efl_Model *model) 1930_efl_ui_image_efl_ui_view_model_set(Eo *obj, Efl_Ui_Image_Data *pd, Efl_Model *model)
1928{ 1931{
1929 if (pd->property.model) 1932 Efl_Model *setted;
1933
1934 setted = efl_ui_view_model_get(obj);
1935 if (setted)
1930 { 1936 {
1931 efl_event_callback_del(pd->property.model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, 1937 efl_event_callback_del(setted, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
1932 _efl_ui_image_model_properties_changed_cb, obj); 1938 _efl_ui_image_model_properties_changed_cb, obj);
1933 } 1939 }
1934 1940
1935 efl_replace(&pd->property.model, model); 1941 efl_ui_view_model_set(efl_super(obj, EFL_UI_IMAGE_CLASS), model);
1936 1942
1937 if (model) 1943 setted = efl_ui_view_model_get(obj);
1944 if (setted)
1938 { 1945 {
1939 efl_event_callback_add(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, 1946 efl_event_callback_add(setted, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
1940 _efl_ui_image_model_properties_changed_cb, obj); 1947 _efl_ui_image_model_properties_changed_cb, obj);
1941 } 1948 }
1942 1949
1943 _update_viewmodel(obj, pd); 1950 _update_viewmodel(obj, pd);
1944} 1951}
1945 1952
1946EOLIAN static Efl_Model *
1947_efl_ui_image_efl_ui_view_model_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
1948{
1949 return pd->property.model;
1950}
1951
1952EOLIAN static Eina_Error 1953EOLIAN static Eina_Error
1953_efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd, const char *key, const char *property) 1954_efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd, const char *key, const char *property)
1954{ 1955{
@@ -1967,7 +1968,10 @@ _efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd,
1967 { 1968 {
1968 eina_stringshare_replace(&pd->property.key, property); 1969 eina_stringshare_replace(&pd->property.key, property);
1969 } 1970 }
1970 else return EINA_FALSE; 1971 else
1972 {
1973 return efl_ui_property_bind(efl_super(obj, EFL_UI_IMAGE_CLASS), key, property);
1974 }
1971 1975
1972 _update_viewmodel(obj, pd); 1976 _update_viewmodel(obj, pd);
1973 return 0; 1977 return 0;
diff --git a/src/lib/elementary/efl_ui_image.eo b/src/lib/elementary/efl_ui_image.eo
index 7da1f4c771..3e876e02be 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -22,7 +22,7 @@ class @beta Efl.Ui.Image extends Efl.Ui.Widget implements Efl.Ui.Clickable, Efl.
22 Efl.File, Efl.Gfx.Image, Efl.Gfx.Image_Load_Controller, Efl.Player, Efl.Gfx.View, 22 Efl.File, Efl.Gfx.Image, Efl.Gfx.Image_Load_Controller, Efl.Player, Efl.Gfx.View,
23 Efl.Access.Component, Efl.Access.Widget.Action, Efl.Gfx.Color, 23 Efl.Access.Component, Efl.Access.Widget.Action, Efl.Gfx.Color,
24 Efl.Orientation, 24 Efl.Orientation,
25 Efl.Ui.View, Efl.Ui.Property_Bind, Efl.Layout.Calc, 25 Efl.Layout.Calc,
26 Efl.Layout.Group, Efl.Layout.Signal 26 Efl.Layout.Group, Efl.Layout.Signal
27{ 27{
28 [[ Efl UI image class]] 28 [[ Efl UI image class]]
@@ -119,7 +119,7 @@ class @beta Efl.Ui.Image extends Efl.Ui.Widget implements Efl.Ui.Clickable, Efl.
119 Efl.Canvas.Group.group_member_add; 119 Efl.Canvas.Group.group_member_add;
120 Efl.Ui.Draggable.drag_target { get; set; } 120 Efl.Ui.Draggable.drag_target { get; set; }
121 Efl.Ui.Property_Bind.property_bind; 121 Efl.Ui.Property_Bind.property_bind;
122 Efl.Ui.View.model { get; set; } 122 Efl.Ui.View.model { set; }
123 Efl.Ui.Widget.theme_apply; 123 Efl.Ui.Widget.theme_apply;
124 Efl.Ui.Widget.widget_input_event_handler; 124 Efl.Ui.Widget.widget_input_event_handler;
125 Efl.Access.Component.extents { get; } 125 Efl.Access.Component.extents { get; }
diff --git a/src/lib/elementary/efl_ui_widget_image.h b/src/lib/elementary/efl_ui_widget_image.h
index 8fae00f950..5bdb566add 100644
--- a/src/lib/elementary/efl_ui_widget_image.h
+++ b/src/lib/elementary/efl_ui_widget_image.h
@@ -80,7 +80,6 @@ struct _Efl_Ui_Image_Data
80 const char *stdicon; 80 const char *stdicon;
81 81
82 struct { 82 struct {
83 Efl_Model *model;
84 Eina_Stringshare *file; 83 Eina_Stringshare *file;
85 Eina_Stringshare *key; 84 Eina_Stringshare *key;
86 85