summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-11-23 01:09:13 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-12-04 12:21:23 -0800
commit003ce06e85ba0f1597a26405ead92f2e01607177 (patch)
tree9c57112dfb1cddd13aeb20112b286ed321ff76b6 /src/examples
parentb04a7ed4f4d031ef92d028b5fe84ec9150da2e15 (diff)
elementary: small improvement on example migrating them to newer unified API.
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/elementary/layout_property_bind.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/examples/elementary/layout_property_bind.c b/src/examples/elementary/layout_property_bind.c
index f9c5cf979e..8dc68a564a 100644
--- a/src/examples/elementary/layout_property_bind.c
+++ b/src/examples/elementary/layout_property_bind.c
@@ -27,6 +27,8 @@ struct _Layout_Model_Data
27}; 27};
28typedef struct _Layout_Model_Data Layout_Model_Data; 28typedef struct _Layout_Model_Data Layout_Model_Data;
29 29
30static Evas_Object *win = NULL;
31
30static Eina_Value 32static Eina_Value
31_wait_for_image(Eo *o EINA_UNUSED, void *data, const Eina_Value v) 33_wait_for_image(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
32{ 34{
@@ -50,22 +52,32 @@ _cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
50} 52}
51 53
52static void 54static void
53_list_selected_cb(void *data EINA_UNUSED, const Efl_Event *event) 55_list_pressed_item_cb(void *data EINA_UNUSED, const Efl_Event *event)
54{ 56{
55 Layout_Model_Data *priv = data; 57 Layout_Model_Data *priv = data;
56 Eo *child = event->info; 58 Efl_Ui_Item_Clickable_Pressed *pressed = event->info;
57 59 Efl_Ui_Item *item = pressed->item;
58 printf("LIST selected model\n"); 60 Efl_Model *model = efl_ui_view_model_get(item);
59 efl_ui_view_model_set(priv->provider, child); 61
62 printf("LIST pressed model `%s` from item `%s`.\n",
63 efl_debug_name_get(model),
64 efl_debug_name_get(item));
65 efl_ui_view_model_set(priv->provider, model);
60} 66}
61 67
62static void 68static void
63_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 69_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
64{ 70{
65 Layout_Model_Data *priv = data; 71 Layout_Model_Data *priv = data;
72 Efl_Model *newone;
66 73
67 const char *text = elm_object_text_get(priv->entry); 74 const char *text = elm_object_text_get(priv->entry);
68 elm_layout_text_set(priv->label, "default", text); 75 newone = efl_add(EFL_IO_MODEL_CLASS, win,
76 efl_io_model_path_set(efl_added, text));
77 efl_ui_view_model_set(priv->fileview, newone);
78 efl_del(priv->model);
79 priv->model = newone;
80
69} 81}
70 82
71static void 83static void
@@ -103,7 +115,8 @@ EAPI_MAIN int
103elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) 115elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
104{ 116{
105 Layout_Model_Data *priv; 117 Layout_Model_Data *priv;
106 Evas_Object *win, *panes, *bxr, *genlist; 118 Evas_Object *panes, *bxr;
119 Efl_Ui_Factory *factory;
107 Eo *img_factory; 120 Eo *img_factory;
108 char *dirname; 121 char *dirname;
109 122
@@ -122,16 +135,19 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
122 if (argv[1] != NULL) dirname = argv[1]; 135 if (argv[1] != NULL) dirname = argv[1];
123 else dirname = EFL_MODEL_TEST_FILENAME_PATH; 136 else dirname = EFL_MODEL_TEST_FILENAME_PATH;
124 137
125 priv->model = efl_add_ref(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname)); 138 priv->model = efl_add(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname));
139
140 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
141 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS);
142 efl_ui_property_bind(factory, "efl.text", "filename");
126 143
127 genlist = elm_genlist_add(win); 144 priv->fileview = efl_add(EFL_UI_LIST_VIEW_CLASS, panes,
128 priv->fileview = efl_add_ref(ELM_VIEW_LIST_CLASS, win, elm_view_list_genlist_set(efl_added, genlist, ELM_GENLIST_ITEM_NONE, NULL)); 145 efl_ui_collection_view_factory_set(efl_added, factory),
129 elm_view_list_property_connect(priv->fileview, "filename", "elm.text"); 146 efl_ui_view_model_set(efl_added, priv->model));
130 elm_view_list_model_set(priv->fileview, priv->model); 147 _widget_init(priv->fileview);
131 _widget_init(genlist); 148 elm_object_part_content_set(panes, "left", priv->fileview);
132 elm_object_part_content_set(panes, "left", genlist);
133 elm_panes_content_left_size_set(panes, 0.3); 149 elm_panes_content_left_size_set(panes, 0.3);
134 efl_event_callback_add(priv->fileview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _list_selected_cb, priv); 150 efl_event_callback_add(priv->fileview, EFL_UI_EVENT_ITEM_PRESSED, _list_pressed_item_cb, priv);
135 151
136 bxr = elm_box_add(win); 152 bxr = elm_box_add(win);
137 priv->bxr = bxr; 153 priv->bxr = bxr;