summaryrefslogtreecommitdiff
path: root/tutorial/c/eo-intro/src/eo_intro_main.c
blob: f87a3501dbc2a8dcc18bbf1b45286d60c5d6fcf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#define EFL_BETA_API_SUPPORT 1

#include <Eina.h>
#include <Efl_Core.h>

#include <stdlib.h>

Eo *_root, *_child1, *_child2;

// Create our test hierarchy
static void
_obj_create()
{
   // First create a root element
   _root = efl_new(EFL_GENERIC_MODEL_CLASS,
                   efl_name_set(efl_added, "Root"));

   // Create the first child element
   _child1 = efl_add(EFL_GENERIC_MODEL_CLASS, _root,
                     efl_name_set(efl_added, "Child1"));

   // Create the second child element, this time, with an extra reference
   _child2 = efl_add_ref(EFL_GENERIC_MODEL_CLASS, _root,
                         efl_name_set(efl_added, "Child2"));
}

// Destroy the test hierarchy
static void
_obj_destroy()
{
   // Destroy the root element
   printf ("Deleting Root...\n");
   efl_unref(_root);

   // Destroy the child2 element, for which we were keeping an extra reference
   printf ("Deleting Child2...\n");
   efl_unref(_child2);
}

EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   // Create all objects
   _obj_create();

   // Destroy all objects
   _obj_destroy();

   // Exit
   efl_exit(0);
}
EFL_MAIN()