summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_widget_factory.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/elementary/efl_ui_widget_factory.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c
index 1ae33b2..3e325e1 100644
--- a/src/lib/elementary/efl_ui_widget_factory.c
+++ b/src/lib/elementary/efl_ui_widget_factory.c
@@ -39,6 +39,7 @@ struct _Efl_Ui_Widget_Factory_Data
39struct _Efl_Ui_Widget_Factory_Request 39struct _Efl_Ui_Widget_Factory_Request
40{ 40{
41 Efl_Ui_Widget_Factory_Data *pd; 41 Efl_Ui_Widget_Factory_Data *pd;
42 Efl_Ui_Factory *factory;
42 Eo *parent; 43 Eo *parent;
43}; 44};
44 45
@@ -66,9 +67,31 @@ _efl_ui_widget_factory_item_class_get(const Eo *obj EINA_UNUSED,
66 return pd->klass; 67 return pd->klass;
67} 68}
68 69
70static void
71_efl_ui_widget_factory_efl_ui_factory_building(const Eo *obj EINA_UNUSED, Efl_Ui_Widget_Factory_Data *pd EINA_UNUSED, Efl_Gfx_Entity *ui_view)
72{
73 const Efl_Model *model;
74 Eina_Value *property;
75 char *style;
76
77 if (!pd->style) return ;
78
79 model = efl_ui_view_model_get(ui_view);
80 // As we have already waited for the property to be ready, we should get the right style now
81 property = efl_model_property_get(model, pd->style);
82 if (!property) return ;
83
84 style = eina_value_to_string(property);
85 if (style) efl_ui_widget_style_set(ui_view, style);
86 free(style);
87
88 eina_value_free(property);
89}
90
69static Efl_Ui_Widget * 91static Efl_Ui_Widget *
70_efl_ui_widget_create(const Efl_Class *klass, Eo *parent, 92_efl_ui_widget_create(const Efl_Ui_Factory *factory,
71 const char *style, Efl_Model *model, 93 const Efl_Class *klass, Eo *parent,
94 Efl_Model *model,
72 const Eina_Hash *parts) 95 const Eina_Hash *parts)
73{ 96{
74 Efl_Ui_Bind_Part_Data *bpd; 97 Efl_Ui_Bind_Part_Data *bpd;
@@ -76,8 +99,8 @@ _efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
76 Efl_Ui_Widget *w; 99 Efl_Ui_Widget *w;
77 100
78 w = efl_add(klass, parent, 101 w = efl_add(klass, parent,
79 style ? efl_ui_widget_style_set(efl_added, style) : (void) 0, 102 efl_ui_view_model_set(efl_added, model),
80 efl_ui_view_model_set(efl_added, model)); 103 efl_ui_factory_building(factory, efl_added));
81 if (!parts) return w; 104 if (!parts) return w;
82 105
83 it = eina_hash_iterator_data_new(parts); 106 it = eina_hash_iterator_data_new(parts);
@@ -97,16 +120,12 @@ _efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
97} 120}
98 121
99static Eina_Value 122static Eina_Value
100_efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v) 123_efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v EINA_UNUSED)
101{ 124{
102 Efl_Ui_Widget_Factory_Request *r = data; 125 Efl_Ui_Widget_Factory_Request *r = data;
103 Efl_Ui_Widget *w; 126 Efl_Ui_Widget *w;
104 const char *string = NULL;
105
106 if (!eina_value_string_get(&v, &string))
107 return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED);
108 127
109 w = _efl_ui_widget_create(r->pd->klass, r->parent, string, model, r->pd->parts); 128 w = _efl_ui_widget_create(r->factory, r->pd->klass, r->parent, model, r->pd->parts);
110 if (!w) return eina_value_error_init(ENOMEM); 129 if (!w) return eina_value_error_init(ENOMEM);
111 return eina_value_object_init(w); 130 return eina_value_object_init(w);
112} 131}
@@ -122,6 +141,7 @@ _efl_ui_widget_factory_create_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_
122{ 141{
123 Efl_Ui_Widget_Factory_Request *r = data; 142 Efl_Ui_Widget_Factory_Request *r = data;
124 143
144 efl_unref(r->factory);
125 efl_unref(r->parent); 145 efl_unref(r->parent);
126 free(r); 146 free(r);
127} 147}
@@ -147,7 +167,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
147 167
148 EINA_ITERATOR_FOREACH(models, model) 168 EINA_ITERATOR_FOREACH(models, model)
149 { 169 {
150 w = _efl_ui_widget_create(pd->klass, parent, NULL, model, pd->parts); 170 w = _efl_ui_widget_create(obj, pd->klass, parent, model, pd->parts);
151 171
152 if (!w) return efl_loop_future_rejected(obj, ENOMEM); 172 if (!w) return efl_loop_future_rejected(obj, ENOMEM);
153 eina_value_array_append(&r, w); 173 eina_value_array_append(&r, w);
@@ -162,6 +182,7 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
162 182
163 r->pd = pd; 183 r->pd = pd;
164 r->parent = efl_ref(parent); 184 r->parent = efl_ref(parent);
185 r->factory = efl_ref(obj);
165 186
166 f = calloc(count + 1, sizeof (Eina_Future *)); 187 f = calloc(count + 1, sizeof (Eina_Future *));
167 if (!f) return efl_loop_future_rejected(obj, ENOMEM); 188 if (!f) return efl_loop_future_rejected(obj, ENOMEM);