aboutsummaryrefslogtreecommitdiffstats
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
parentecore: remove exit_signal_received conditional from windows build (diff)
downloadefl-devs/larrylira/factory.tar.gz
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 @@
#define EFL_MODEL_TEST_FILENAME_PATH "/tmp"
-static void
-_realized_cb(void *data, const Efl_Event *event)
-{
- Efl_Ui_View_List_Item_Event *ie = event->info;
- Eo *imf = data;
- printf("realize %d\n", ie->index);
-
- evas_object_size_hint_weight_set(ie->layout, EVAS_HINT_EXPAND, 0);
- evas_object_size_hint_align_set(ie->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- efl_ui_factory_model_connect(ie->layout, "efl.icon", imf);
-}
-
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Efl_Ui_Layout_Factory *factory;
+ Efl_Ui_Image_Factory *imgf;
Evas_Object *win;
- Eo *imf, *model, *li;
+ Eo *model, *li;
char *dirname;
win = elm_win_util_standard_add("viewlist", "Viewlist");
@@ -56,9 +44,9 @@ elm_main(int argc, char **argv)
evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
- imf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
- efl_ui_model_connect(imf, "", "path"); //connect to "path" property
- efl_event_callback_add(li, EFL_UI_VIEW_LIST_EVENT_ITEM_REALIZED, _realized_cb, imf);
+ imgf = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
+ efl_ui_model_connect(imgf, "", "path"); //connect to "path" property
+ efl_ui_factory_model_connect(factory, "efl.icon", imgf);
elm_win_resize_object_add(win, li);
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
{
Eina_Array *layouts;
Eina_Hash *connects;
+ Eina_Hash *factory_connects;
Eina_Stringshare *klass;
Eina_Stringshare *group;
Eina_Stringshare *style;
@@ -29,6 +30,17 @@ _model_connect(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, v
return EINA_TRUE;
}
+Eina_Bool
+_factory_model_connect(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata)
+{
+ Eo *layout = fdata;
+ Eina_Stringshare *name = key;
+ Efl_Ui_Factory *factory = data;
+
+ efl_ui_factory_model_connect(layout, name, factory);
+ return EINA_TRUE;
+}
+
EOLIAN static Eo *
_efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd)
{
@@ -39,6 +51,7 @@ _efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Dat
pd->style = NULL;
pd->layouts = eina_array_new(8);
pd->connects = eina_hash_stringshared_new(EINA_FREE_CB(eina_stringshare_del));
+ pd->factory_connects = eina_hash_stringshared_new(EINA_FREE_CB(efl_del));
return obj;
}
@@ -59,6 +72,7 @@ _efl_ui_layout_factory_efl_object_destructor(Eo *obj, Efl_Ui_Layout_Factory_Data
eina_array_free(pd->layouts);
eina_hash_free(pd->connects);
+ eina_hash_free(pd->factory_connects);
efl_destructor(efl_super(obj, MY_CLASS));
}
@@ -83,6 +97,7 @@ _efl_ui_layout_factory_efl_ui_factory_create(Eo *obj EINA_UNUSED, Efl_Ui_Layout_
efl_ui_layout_object_theme_set(efl_added, pd->klass, pd->group, pd->style));
eina_hash_foreach(pd->connects, _model_connect, layout);
+ eina_hash_foreach(pd->factory_connects, _factory_model_connect, layout);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0);
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
}
EOLIAN static void
+_efl_ui_layout_factory_efl_ui_factory_model_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
+ , const char *name, Efl_Ui_Factory *factory)
+{
+ Eina_Stringshare *ss_name;
+ ss_name = eina_stringshare_add(name);
+
+ if (factory == NULL)
+ {
+ eina_hash_del(pd->factory_connects, ss_name, NULL);
+ return;
+ }
+
+ eina_stringshare_del(eina_hash_set(pd->factory_connects, ss_name, factory));
+}
+
+EOLIAN static void
_efl_ui_layout_factory_efl_ui_model_connect_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
, const char *name, const char *property)
{
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)
Efl.Object.destructor;
Efl.Ui.Factory.create;
Efl.Ui.Factory.release;
+ Efl.Ui.Factory.model_connect;
Efl.Ui.Model.Connect.connect;
}
}