summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 11:28:29 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 11:28:29 -0300
commit3a5339436f2670aaddf38652babe6e7d25f753d3 (patch)
tree92d21d909d8ecb4f87bb7bb9606da915ecd0f57f
parent479fba816cbafa1ba8144aca15f59cb06d246cbc (diff)
csharp: Add Efl.Model implementations to internal modeldevs/lauromoura/cv-finalize-csharp
These methods are needed by widgets like Collection.View
-rw-r--r--src/lib/efl_mono/efl_mono_model_internal.c55
-rw-r--r--src/lib/efl_mono/efl_mono_model_internal.eo1
2 files changed, 55 insertions, 1 deletions
diff --git a/src/lib/efl_mono/efl_mono_model_internal.c b/src/lib/efl_mono/efl_mono_model_internal.c
index cda6d66e14..cdb0976dd9 100644
--- a/src/lib/efl_mono/efl_mono_model_internal.c
+++ b/src/lib/efl_mono/efl_mono_model_internal.c
@@ -44,6 +44,9 @@ typedef struct _Efl_Mono_Model_Internal_Data
44 Eina_Array *properties_info; 44 Eina_Array *properties_info;
45 Eina_Array *properties_names; 45 Eina_Array *properties_names;
46 Eina_Array *items; 46 Eina_Array *items;
47 // These two are needed by CollectionView currently
48 int item_height;
49 int item_width;
47} _Efl_Mono_Model_Internal_Data; 50} _Efl_Mono_Model_Internal_Data;
48 51
49 52
@@ -101,11 +104,12 @@ _efl_mono_model_internal_add_property(Eo *obj EINA_UNUSED, Efl_Mono_Model_Intern
101 eina_array_push (pd->properties_names, eina_stringshare_add(info->name)); 104 eina_array_push (pd->properties_names, eina_stringshare_add(info->name));
102} 105}
103 106
107static const char* _efl_mono_model_properties_names[] = { "item.width", "item.height" };
104 108
105static Eina_Iterator * 109static Eina_Iterator *
106_efl_mono_model_internal_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Mono_Model_Internal_Data *pd EINA_UNUSED) 110_efl_mono_model_internal_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Mono_Model_Internal_Data *pd EINA_UNUSED)
107{ 111{
108 return eina_array_iterator_new (NULL); 112 return EINA_C_ARRAY_ITERATOR_NEW(_efl_mono_model_properties_names);
109} 113}
110 114
111static Efl_Object* 115static Efl_Object*
@@ -130,6 +134,55 @@ _efl_mono_model_internal_efl_model_children_count_get(const Eo *obj EINA_UNUSED,
130} 134}
131 135
132static Eina_Future * 136static Eina_Future *
137_efl_mono_model_internal_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Data *pd, const char *property, Eina_Value *value)
138{
139 if (strcmp(property, "item.width"))
140 {
141 int width;
142 eina_value_get(value, &width);
143 pd->item_width = width;
144 }
145 else if (strcmp(property, "item.height"))
146 {
147 int height;
148 eina_value_get(value, &height);
149 pd->item_height = height;
150 }
151 else
152 {
153 return efl_loop_future_rejected(obj, EINVAL);
154 }
155
156 Eina_Value tmp_value;
157 eina_value_copy(value, &tmp_value);
158
159 return efl_loop_future_resolved(obj, tmp_value);
160}
161
162static Eina_Value *
163_efl_mono_model_internal_efl_model_property_get(const Eo *obj EINA_UNUSED, Efl_Mono_Model_Internal_Data *pd EINA_UNUSED, const char *property EINA_UNUSED)
164{
165 if (strcmp(property, "item.width"))
166 {
167 Eina_Value *value = malloc(sizeof(Eina_Value));
168 eina_value_setup(value, EINA_VALUE_TYPE_INT);
169 eina_value_set(value, pd->item_width);
170 return value;
171 }
172 else if (strcmp(property, "item.height"))
173 {
174 Eina_Value *value = malloc(sizeof(Eina_Value));
175 eina_value_setup(value, EINA_VALUE_TYPE_INT);
176 eina_value_set(value, pd->item_height);
177 return value;
178 }
179
180 return eina_value_error_new(EINVAL);
181}
182
183/// Model_Internal_Child implementations
184
185static Eina_Future *
133_efl_mono_model_internal_child_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd, const char *property, Eina_Value *value) 186_efl_mono_model_internal_child_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd, const char *property, Eina_Value *value)
134{ 187{
135 int i = _find_property_index (property, pd->model_pd->properties_names); 188 int i = _find_property_index (property, pd->model_pd->properties_names);
diff --git a/src/lib/efl_mono/efl_mono_model_internal.eo b/src/lib/efl_mono/efl_mono_model_internal.eo
index 3a639defe7..0efbd45198 100644
--- a/src/lib/efl_mono/efl_mono_model_internal.eo
+++ b/src/lib/efl_mono/efl_mono_model_internal.eo
@@ -15,5 +15,6 @@ class @beta Efl.Mono_Model_Internal extends Efl.Loop_Consumer implements Efl.Mod
15 Efl.Model.child_add; 15 Efl.Model.child_add;
16 Efl.Model.children_count { get; } 16 Efl.Model.children_count { get; }
17 Efl.Model.children_slice_get; 17 Efl.Model.children_slice_get;
18 Efl.Model.property { get; set; }
18 } 19 }
19} 20}