summaryrefslogtreecommitdiff
path: root/src/lib/ecore/efl_model_composite.c
blob: 90cd8adc845b14223aafe6c45c824f92403ecc8b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Eina.h>
#include <Efl.h>
#include <Ecore.h>

#include "ecore_private.h"

#include "efl_model_composite.eo.h"

typedef struct _Efl_Model_Composite_Data Efl_Model_Composite_Data;

struct _Efl_Model_Composite_Data
{
   Efl_Model *source;
};

static void
_efl_model_composite_efl_object_destructor(Eo *obj, Efl_Model_Composite_Data *pd)
{
   efl_unref(pd->source);
   pd->source = NULL;

   efl_destructor(efl_super(obj, EFL_MODEL_COMPOSITE_CLASS));
}

static Efl_Object *
_efl_model_composite_efl_object_finalize(Eo *obj, Efl_Model_Composite_Data *pd)
{
   if (pd->source == NULL)
     {
        ERR("Source of the composite model wasn't defined at construction time.");
        return NULL;
     }

   return obj;
}

static void
_efl_model_composite_efl_ui_view_model_set(Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd, Efl_Model *model)
{
   if (pd->source != NULL)
     {
        ERR("Source already set for composite model. It can only be set once.");
        return ;
     }
   pd->source = efl_ref(model);
}

static Efl_Model *
_efl_model_composite_efl_ui_view_model_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd)
{
   return pd->source;
}

static Eina_Future *
_efl_model_composite_efl_model_property_set(Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd,
                                            const char *property, Eina_Value *value)
{
   return efl_model_property_set(pd->source, property, value);
}

static Eina_Value *
_efl_model_composite_efl_model_property_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd,
                                            const char *property)
{
   return efl_model_property_get(pd->source, property);
}

static Eina_Array *
_efl_model_composite_efl_model_properties_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd)
{
   return efl_model_properties_get(pd->source);
}

static unsigned int
_efl_model_composite_efl_model_children_count_get(const Eo *obj EINA_UNUSED, Efl_Model_Composite_Data *pd)
{
   return efl_model_children_count_get(pd->source);
}

static Eina_Future *
_efl_model_composite_efl_model_children_slice_get(Eo *obj EINA_UNUSED,
                                                  Efl_Model_Composite_Data *pd,
                                                  unsigned int start,
                                                  unsigned int count)
{
   return efl_model_children_slice_get(pd->source, start, count);
}

static Efl_Object *
_efl_model_composite_efl_model_child_add(Eo *obj EINA_UNUSED,
                                         Efl_Model_Composite_Data *pd)
{
   return efl_model_child_add(pd->source);
}

static void
_efl_model_composite_efl_model_child_del(Eo *obj EINA_UNUSED,
                                         Efl_Model_Composite_Data *pd,
                                         Efl_Object *child)
{
   efl_model_child_del(pd->source, child);
}

#include "efl_model_composite.eo.c"