aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/examples/eina_model_02.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/examples/eina_model_02.c')
-rw-r--r--libraries/eina/src/examples/eina_model_02.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/libraries/eina/src/examples/eina_model_02.c b/libraries/eina/src/examples/eina_model_02.c
deleted file mode 100644
index a2cb693..0000000
--- a/libraries/eina/src/examples/eina_model_02.c
+++ /dev/null
@@ -1,61 +0,0 @@
1//Compile with:
2//gcc -g eina_model_02.c -o eina_model_02 `pkg-config --cflags --libs eina`
3
4#include <Eina.h>
5
6static void _cb_on_deleted(void *data, Eina_Model *model, const Eina_Model_Event_Description *desc, void *event_info);
7
8int main(void)
9{
10 Eina_Model *m;
11 char *s;
12 int i;
13
14 eina_init();
15
16 m = eina_model_new(EINA_MODEL_TYPE_GENERIC);
17
18 eina_model_event_callback_add(m, "deleted", _cb_on_deleted, NULL);
19
20 //Adding properties to model
21 for (i = 0; i < 5; i++)
22 {
23 Eina_Value val;
24 char name[2] = {'a'+ i, 0};
25 eina_value_setup(&val, EINA_VALUE_TYPE_INT);
26 eina_value_set(&val, i);
27 eina_model_property_set(m, name, &val);
28 eina_value_flush(&val);
29 }
30
31 //Adding children to model
32 for (i = 0; i < 5; i++)
33 {
34 Eina_Value val;
35 Eina_Model *c = eina_model_new(EINA_MODEL_TYPE_GENERIC);
36 eina_value_setup(&val, EINA_VALUE_TYPE_INT);
37 eina_value_set(&val, i);
38 eina_model_property_set(c, "x", &val);
39
40 eina_model_event_callback_add(c, "deleted", _cb_on_deleted, NULL);
41
42 eina_model_child_append(m, c);
43 //Now that the child has been appended to a model, it's parent will manage it's lifecycle
44 eina_model_unref(c);
45 eina_value_flush(&val);
46 }
47
48 s = eina_model_to_string(m);
49 printf("model as string:\n%s\n", s);
50
51 free(s);
52 eina_model_unref(m);
53 eina_shutdown();
54
55 return 0;
56}
57
58static void _cb_on_deleted(void *data, Eina_Model *model, const Eina_Model_Event_Description *desc, void *event_info)
59{
60 printf("deleted %p\n", model);
61}