summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Lira <larry@expertisesolutions.com.br>2018-07-20 19:41:08 -0300
committerLarry Lira <larry@expertisesolutions.com.br>2018-07-20 19:52:21 -0300
commite8ce6e02e223933b5255f4ad5c291bc1129ca0be (patch)
tree3257eac0bf282b2d92107e6079bdd8b71a2d79ff
parent44bce025fa478cc52bc23b8f3fed799f8e1b8806 (diff)
Efl.Ui.Layout.Factory: added factory_model_connectdevs/larrylira/factory
Summary: when create a new layout connect a factory to it change example to use the factory_model_connect
-rw-r--r--src/examples/elementary/efl_ui_view_list_example_2.c22
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.c31
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.eo1
3 files changed, 37 insertions, 17 deletions
diff --git a/src/examples/elementary/efl_ui_view_list_example_2.c b/src/examples/elementary/efl_ui_view_list_example_2.c
index de4d259962..310aa26976 100644
--- a/src/examples/elementary/efl_ui_view_list_example_2.c
+++ b/src/examples/elementary/efl_ui_view_list_example_2.c
@@ -14,25 +14,13 @@
14 14
15#define EFL_MODEL_TEST_FILENAME_PATH "/tmp" 15#define EFL_MODEL_TEST_FILENAME_PATH "/tmp"
16 16
17static void
18_realized_cb(void *data, const Efl_Event *event)
19{
20 Efl_Ui_View_List_Item_Event *ie = event->info;
21 Eo *imf = data;
22 printf("realize %d\n", ie->index);
23
24 evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
25 evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
26
27 efl_ui_factory_model_connect(ie->layout, "efl.icon", imf);
28}
29
30EAPI_MAIN int 17EAPI_MAIN int
31elm_main(int argc, char **argv) 18elm_main(int argc, char **argv)
32{ 19{
33 Efl_Ui_Layout_Factory *factory; 20 Efl_Ui_Layout_Factory *factory;
21 Efl_Ui_Image_Factory *imgf;
34 Evas_Object *win; 22 Evas_Object *win;
35 Eo *imf, *model, *li; 23 Eo *model, *li;
36 char *dirname; 24 char *dirname;
37 25
38 win = elm_win_util_standard_add("viewlist", "Viewlist"); 26 win = elm_win_util_standard_add("viewlist", "Viewlist");
@@ -56,9 +44,9 @@ elm_main(int argc, char **argv)
56 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); 44 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
57 45
58 46
59 imf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win); 47 imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
60 efl_ui_model_connect(imf, "", "path"); //connect to "path" property 48 efl_ui_model_connect(imgf, "", "path"); //connect to "path" property
61 efl_event_callback_add(li, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_cb, imf); 49 efl_ui_factory_model_connect(factory, "efl.icon", imgf);
62 50
63 elm_win_resize_object_add(win, li); 51 elm_win_resize_object_add(win, li);
64 52
diff --git a/src/lib/elementary/efl_ui_layout_factory.c b/src/lib/elementary/efl_ui_layout_factory.c
index 16621c53a0..73d18091f4 100644
--- a/src/lib/elementary/efl_ui_layout_factory.c
+++ b/src/lib/elementary/efl_ui_layout_factory.c
@@ -12,6 +12,7 @@ typedef struct _Efl_Ui_Layout_Factory_Data
12{ 12{
13 Eina_Array *layouts; 13 Eina_Array *layouts;
14 Eina_Hash *connects; 14 Eina_Hash *connects;
15 Eina_Hash *factory_connects;
15 Eina_Stringshare *klass; 16 Eina_Stringshare *klass;
16 Eina_Stringshare *group; 17 Eina_Stringshare *group;
17 Eina_Stringshare *style; 18 Eina_Stringshare *style;
@@ -29,6 +30,17 @@ _model_connect(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, v
29 return EINA_TRUE; 30 return EINA_TRUE;
30} 31}
31 32
33Eina_Bool
34_factory_model_connect(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata)
35{
36 Eo *layout = fdata;
37 Eina_Stringshare *name = key;
38 Efl_Ui_Factory *factory = data;
39
40 efl_ui_factory_model_connect(layout, name, factory);
41 return EINA_TRUE;
42}
43
32EOLIAN static Eo * 44EOLIAN static Eo *
33_efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd) 45_efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd)
34{ 46{
@@ -39,6 +51,7 @@ _efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Dat
39 pd->style = NULL; 51 pd->style = NULL;
40 pd->layouts = eina_array_new(8); 52 pd->layouts = eina_array_new(8);
41 pd->connects = eina_hash_stringshared_new(EINA_FREE_CB(eina_stringshare_del)); 53 pd->connects = eina_hash_stringshared_new(EINA_FREE_CB(eina_stringshare_del));
54 pd->factory_connects = eina_hash_stringshared_new(EINA_FREE_CB(efl_del));
42 55
43 return obj; 56 return obj;
44} 57}
@@ -59,6 +72,7 @@ _efl_ui_layout_factory_efl_object_destructor(Eo *obj, Efl_Ui_Layout_Factory_Data
59 72
60 eina_array_free(pd->layouts); 73 eina_array_free(pd->layouts);
61 eina_hash_free(pd->connects); 74 eina_hash_free(pd->connects);
75 eina_hash_free(pd->factory_connects);
62 76
63 efl_destructor(efl_super(obj, MY_CLASS)); 77 efl_destructor(efl_super(obj, MY_CLASS));
64} 78}
@@ -83,6 +97,7 @@ _efl_ui_layout_factory_efl_ui_factory_create(Eo *obj EINA_UNUSED, Efl_Ui_Layout_
83 efl_ui_layout_object_theme_set(efl_added, pd->klass, pd->group, pd->style)); 97 efl_ui_layout_object_theme_set(efl_added, pd->klass, pd->group, pd->style));
84 98
85 eina_hash_foreach(pd->connects, _model_connect, layout); 99 eina_hash_foreach(pd->connects, _model_connect, layout);
100 eina_hash_foreach(pd->factory_connects, _factory_model_connect, layout);
86 101
87 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0); 102 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0);
88 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); 103 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -99,6 +114,22 @@ _efl_ui_layout_factory_efl_ui_factory_release(Eo *obj EINA_UNUSED, Efl_Ui_Layout
99} 114}
100 115
101EOLIAN static void 116EOLIAN static void
117_efl_ui_layout_factory_efl_ui_factory_model_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
118 , const char *name, Efl_Ui_Factory *factory)
119{
120 Eina_Stringshare *ss_name;
121 ss_name = eina_stringshare_add(name);
122
123 if (factory == NULL)
124 {
125 eina_hash_del(pd->factory_connects, ss_name, NULL);
126 return;
127 }
128
129 eina_stringshare_del(eina_hash_set(pd->factory_connects, ss_name, factory));
130}
131
132EOLIAN static void
102_efl_ui_layout_factory_efl_ui_model_connect_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd 133_efl_ui_layout_factory_efl_ui_model_connect_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
103 , const char *name, const char *property) 134 , const char *name, const char *property)
104{ 135{
diff --git a/src/lib/elementary/efl_ui_layout_factory.eo b/src/lib/elementary/efl_ui_layout_factory.eo
index e712900d1c..334a4c4478 100644
--- a/src/lib/elementary/efl_ui_layout_factory.eo
+++ b/src/lib/elementary/efl_ui_layout_factory.eo
@@ -17,6 +17,7 @@ class Efl.Ui.Layout_Factory (Efl.Object, Efl.Ui.Factory)
17 Efl.Object.destructor; 17 Efl.Object.destructor;
18 Efl.Ui.Factory.create; 18 Efl.Ui.Factory.create;
19 Efl.Ui.Factory.release; 19 Efl.Ui.Factory.release;
20 Efl.Ui.Factory.model_connect;
20 Efl.Ui.Model.Connect.connect; 21 Efl.Ui.Model.Connect.connect;
21 } 22 }
22} 23}