Tizen 2.1 base
[framework/uifw/elementary.git] / src / edje_externals / elm_index.c
1 #include "private.h"
2
3 typedef struct _Elm_Params_Index
4 {
5    Elm_Params base;
6    Eina_Bool active:1;
7    Eina_Bool active_exists:1;
8
9 } Elm_Params_Index;
10
11 static void
12 external_index_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
13 {
14    const Elm_Params_Index *p;
15
16    if (to_params) p = to_params;
17    else if (from_params) p = from_params;
18    else return;
19
20    if (p->active_exists)
21      elm_index_autohide_disabled_set(obj, p->active_exists);
22 }
23
24 static Eina_Bool
25 external_index_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
26 {
27    if (!strcmp(param->name, "active"))
28      {
29         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
30           {
31              elm_index_autohide_disabled_set(obj, param->i);
32              return EINA_TRUE;
33           }
34      }
35    ERR("unknown parameter '%s' of type '%s'",
36        param->name, edje_external_param_type_str(param->type));
37
38    return EINA_FALSE;
39 }
40
41 static Eina_Bool
42 external_index_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
43 {
44    if (!strcmp(param->name, "active"))
45      {
46         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
47           {
48              param->i = elm_index_autohide_disabled_get(obj);
49              return EINA_TRUE;
50           }
51      }
52
53    ERR("unknown parameter '%s' of type '%s'",
54        param->name, edje_external_param_type_str(param->type));
55
56    return EINA_FALSE;
57 }
58
59 static void *
60 external_index_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
61 {
62    Elm_Params_Index *mem;
63    Edje_External_Param *param;
64    const Eina_List *l;
65
66    mem = calloc(1, sizeof(Elm_Params_Index));
67    if (!mem)
68      return NULL;
69
70    EINA_LIST_FOREACH(params, l, param)
71      {
72         if (!strcmp(param->name, "active"))
73           {
74              mem->active = !!param->i;
75              mem->active_exists = EINA_TRUE;
76           }
77      }
78
79    return mem;
80 }
81
82 static Evas_Object *external_index_content_get(void *data __UNUSED__,
83                 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
84 {
85    ERR("No content.");
86    return NULL;
87 }
88
89 static void
90 external_index_params_free(void *params)
91 {
92    Elm_Params_Index *mem = params;
93    free(mem);
94 }
95
96 static Edje_External_Param_Info external_index_params[] = {
97    DEFINE_EXTERNAL_COMMON_PARAMS,
98     EDJE_EXTERNAL_PARAM_INFO_BOOL("active"),
99    EDJE_EXTERNAL_PARAM_INFO_SENTINEL
100 };
101
102 DEFINE_EXTERNAL_ICON_ADD(index, "index");
103 DEFINE_EXTERNAL_TYPE_SIMPLE(index, "index");