summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/dummy_part_holder.c
blob: aaeee6cec867c65fc526ff24da02ed90187e4fd6 (plain) (blame)
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
54
55
56
57
58
#include "libefl_mono_native_test.h"

typedef struct Dummy_Part_Holder_Data
{
  Eo *one;
  Eo *two;
} Dummy_Part_Holder_Data;

void part_deleted_cb(void *data, const Efl_Event *evt)
{
   Dummy_Part_Holder_Data *pd = data;

   if (evt->object == pd->one)
     pd->one = NULL;
   else if (evt->object == pd->two)
     pd->two = NULL;
}

// Part holder
static Efl_Object*
_dummy_part_holder_efl_object_constructor(Eo *obj, Dummy_Part_Holder_Data *pd)
{
   efl_constructor(efl_super(obj, DUMMY_PART_HOLDER_CLASS));

   // To avoid an infinite loop calling the same constructor
   if (!efl_parent_get(obj))
     {
        pd->one = efl_add(DUMMY_TEST_OBJECT_CLASS, obj, efl_name_set(efl_added, "part_one"));
        efl_event_callback_add(pd->one, EFL_EVENT_DEL, part_deleted_cb, pd);
        pd->two = efl_add(DUMMY_TEST_OBJECT_CLASS, obj, efl_name_set(efl_added, "part_two"));
        efl_event_callback_add(pd->two, EFL_EVENT_DEL, part_deleted_cb, pd);


     }

   return obj;
}

static void
_dummy_part_holder_efl_object_destructor(EINA_UNUSED Eo* obj, Dummy_Part_Holder_Data *pd)
{
   if (pd->one)
     efl_parent_set(pd->one, NULL);
   if (pd->two)
     efl_parent_set(pd->two, NULL);
}

Efl_Object *_dummy_part_holder_efl_part_part_get(EINA_UNUSED const Eo *obj, Dummy_Part_Holder_Data *pd, const char *name)
{
    if (!strcmp(name, "one"))
      return pd->one;
    else if (!strcmp(name, "two"))
      return pd->two;
    else
      return NULL;
}

#include "dummy_part_holder.eo.c"