summaryrefslogtreecommitdiff
path: root/src/lib/efl/interfaces
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-10-25 15:13:32 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-04-30 14:21:11 -0700
commit8f00bf568112fdc913099ce5fc67fb4b2324f5d8 (patch)
tree8181803c29a1cf7e761bd100204b0f1cd9a4ac9f /src/lib/efl/interfaces
parent04c63cb489b2dda2f738df2435ef183209d06ead (diff)
efl: make efl.model use of eina_value and eina_future instead of efl_future.
Diffstat (limited to 'src/lib/efl/interfaces')
-rw-r--r--src/lib/efl/interfaces/efl_model.eo94
-rw-r--r--src/lib/efl/interfaces/efl_model_common.c54
2 files changed, 62 insertions, 86 deletions
diff --git a/src/lib/efl/interfaces/efl_model.eo b/src/lib/efl/interfaces/efl_model.eo
index 06477f9fdf..2fae595baa 100644
--- a/src/lib/efl/interfaces/efl_model.eo
+++ b/src/lib/efl/interfaces/efl_model.eo
@@ -22,50 +22,50 @@ interface Efl.Model ()
22 22
23 @since 1.14 23 @since 1.14
24 ]] 24 ]]
25 } 25 }
26 values { 26 values {
27 properties: const(array<string>); [[Array of current properties]] 27 properties: array<string>; [[Array of current properties]]
28 } 28 }
29 } 29 }
30 property_set { 30 @property property {
31 [[Set a property value of a given property name. 31 set {
32 32 [[Set a property value of a given property name.
33 The caller must ensure to call at least efl_model_prop_list 33
34 before being able to see/set properties. This function sets 34 The caller must ensure to call at least efl_model_prop_list
35 a new property value into given property name. Once the 35 before being able to see/set properties. This function sets
36 operation is completed the concrete implementation should 36 a new property value into given property name. Once the
37 raise EFL_MODEL_EVENT_PROPERTIES_CHANGED event in order to 37 operation is completed the concrete implementation should
38 notify listeners of the new value of the property. 38 raise EFL_MODEL_EVENT_PROPERTIES_CHANGED event in order to
39 39 notify listeners of the new value of the property.
40 If the model doesn't have the property then there are two 40
41 possibilities, either raise an error or create the new 41 If the model doesn't have the property then there are two
42 property in model 42 possibilities, either raise an error or create the new
43 43 property in model
44 See @.property_get, \@ref EFL_MODEL_EVENT_PROPERTIES_CHANGED 44
45 45 See @.property.get, \@ref EFL_MODEL_EVENT_PROPERTIES_CHANGED
46 @since 1.14 46
47 ]] 47 @since 1.14
48 params { 48 ]]
49 @in property: string; [[Property name]] 49 return: ptr(Eina.Future); [[Return an error in case the property could not be set, the value that was set otherwise.]]
50 @in value: const(any_value_ptr); [[New value]]
51 } 50 }
52 return: future<any_value>; [[Future returning the recorded value or error]] 51 get {
53 } 52 [[Retrieve the value of a given property name.
54 property_get {
55 [[Retrieve the value of a given property name.
56 53
57 At this point the caller is free to get values from properties. 54 At this point the caller is free to get values from properties.
58 The event EFL_MODEL_EVENT_PROPERTIES_CHANGED may be raised to 55 The event EFL_MODEL_EVENT_PROPERTIES_CHANGED may be raised to
59 notify listeners of the property/value. 56 notify listeners of the property/value.
60 57
61 See @.properties.get, \@ref EFL_MODEL_EVENT_PROPERTIES_CHANGED 58 See @.properties.get, \@ref EFL_MODEL_EVENT_PROPERTIES_CHANGED
62 59
63 @since 1.14 60 @since 1.14
64 ]] 61 ]]
65 params { 62 }
66 @in property: string; [[Property name]] 63 keys {
64 property: string; [[Property name]]
65 }
66 values {
67 value: any_value_ptr; [[Property value]]
67 } 68 }
68 return: future<any_value>; [[Future of the value that was got]]
69 } 69 }
70 children_slice_get { 70 children_slice_get {
71 [[Get children slice OR full range. 71 [[Get children slice OR full range.
@@ -89,7 +89,7 @@ interface Efl.Model ()
89 Optionally the user can call children_count_get to know the 89 Optionally the user can call children_count_get to know the
90 number of children so a valid range can be known in advance. 90 number of children so a valid range can be known in advance.
91 91
92 See @.children_count_get 92 See @.children_count.get
93 93
94 @since 1.14 94 @since 1.14
95 ]] 95 ]]
@@ -98,10 +98,11 @@ interface Efl.Model ()
98 @in count: uint; [[Range size. If count is 0, start is 98 @in count: uint; [[Range size. If count is 0, start is
99 ignored.]] 99 ignored.]]
100 } 100 }
101 return: future<accessor<Efl.Object> >; [[Future of the children]] 101 return: ptr(Eina.Future); [[Array of childrens]]
102 } 102 }
103 children_count_get { 103 @property children_count {
104 [[Get children count. 104 get {
105 [[Get children count.
105 106
106 When efl_model_load is completed efl_model_coildren_count_get 107 When efl_model_load is completed efl_model_coildren_count_get
107 can be used to get the number of children. children_count_get 108 can be used to get the number of children. children_count_get
@@ -112,8 +113,11 @@ interface Efl.Model ()
112 See also @.children_slice_get. 113 See also @.children_slice_get.
113 114
114 @since 1.14 115 @since 1.14
115 ]] 116 ]]
116 return: future<uint>; [[Future of the children count]] 117 }
118 values {
119 count: uint; [[Current known children count]]
120 }
117 } 121 }
118 child_add { 122 child_add {
119 [[Add a new child. 123 [[Add a new child.
@@ -147,8 +151,8 @@ interface Efl.Model ()
147 properties,changed: Efl.Model_Property_Event; [[Event dispatched when 151 properties,changed: Efl.Model_Property_Event; [[Event dispatched when
148 properties list is 152 properties list is
149 available.]] 153 available.]]
150 child,added: Efl.Object; [[Event dispatched when new child is added.]] 154 child,added; [[Event dispatched when new child is added.]]
151 child,removed: Efl.Object; [[Event dispatched when child is removed.]] 155 child,removed; [[Event dispatched when child is removed.]]
152 children,count,changed; [[Event dispatched when children count is finished.]] 156 children,count,changed; [[Event dispatched when children count is finished.]]
153 } 157 }
154} 158}
diff --git a/src/lib/efl/interfaces/efl_model_common.c b/src/lib/efl/interfaces/efl_model_common.c
index 6bf825819f..dabc388338 100644
--- a/src/lib/efl/interfaces/efl_model_common.c
+++ b/src/lib/efl/interfaces/efl_model_common.c
@@ -54,56 +54,28 @@ efl_model_init(void)
54 return EINA_TRUE; 54 return EINA_TRUE;
55} 55}
56 56
57EAPI Eina_Accessor* 57EAPI void
58efl_model_list_slice(Eina_List *list, unsigned start, unsigned count) 58_efl_model_properties_changed_internal(const Efl_Model *model, ...)
59{ 59{
60 if (!list) return NULL; 60 Efl_Model_Property_Event ev = { 0 };
61 Eina_Array *properties = eina_array_new(1);
62 const char *property;
63 va_list args;
61 64
62 if ((start == 0) && (count == 0)) /* this is full data */ 65 va_start(args, model);
63 {
64 /*
65 * children_accessor will be set to NULL by
66 * eina_list_accessor_new if the later fails.
67 */
68 return eina_list_accessor_new(list);
69 }
70 66
71 Eo *child; 67 while ((property = (const char*) va_arg(args, const char*)))
72 Eina_List *l, *ln, *lr = NULL;
73 ln = eina_list_nth_list(list, (start));
74 if (!ln)
75 { 68 {
76 return NULL; 69 eina_array_push(properties, property);
77 } 70 }
78 71
79 EINA_LIST_FOREACH(ln, l, child) 72 va_end(args);
80 {
81 efl_ref(child);
82 lr = eina_list_append(lr, child);
83 if (eina_list_count(lr) == count)
84 break;
85 }
86
87 if (!lr) return NULL;
88
89 // This may leak the children Eina_List.
90 return eina_list_accessor_new(lr);
91}
92 73
93EAPI void 74 ev.changed_properties = properties;
94efl_model_property_changed_notify(Efl_Model *model, const char *property)
95{
96 Eina_Array *changed_properties = eina_array_new(1);
97 EINA_SAFETY_ON_NULL_RETURN(changed_properties);
98 75
99 Eina_Bool ret = eina_array_push(changed_properties, property); 76 efl_event_callback_call((Efl_Model *) model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &ev);
100 EINA_SAFETY_ON_FALSE_GOTO(ret, on_error);
101 77
102 Efl_Model_Property_Event evt = {.changed_properties = changed_properties}; 78 eina_array_free(properties);
103 efl_event_callback_call(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &evt);
104
105on_error:
106 eina_array_free(changed_properties);
107} 79}
108 80
109EAPI void 81EAPI void