svn update: 51469 (latest:51480)
[framework/uifw/elementary.git] / src / edje_externals / elm_bubble.c
1 #include "private.h"
2
3 typedef struct _Elm_Params_Bubble
4 {
5    Elm_Params base;
6    Evas_Object *icon;
7    const char *info;
8    Evas_Object *content; /* part name whose obj is to be set as content */
9 } Elm_Params_Bubble;
10
11 static void
12 external_bubble_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
13 {
14    const Elm_Params_Bubble *p;
15
16    if (to_params) p = to_params;
17    else if (from_params) p = from_params;
18    else return;
19
20    if (p->base.label) elm_bubble_label_set(obj, p->base.label);
21    if (p->icon) elm_bubble_icon_set(obj, p->icon);
22    if (p->info) elm_bubble_info_set(obj, p->info);
23    if (p->content) elm_bubble_content_set(obj, p->content);
24 }
25
26 static Eina_Bool
27 external_bubble_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
28 {
29    if (!strcmp(param->name, "label"))
30      {
31         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
32           {
33              elm_bubble_label_set(obj, param->s);
34              return EINA_TRUE;
35           }
36      }
37    else if (!strcmp(param->name, "icon"))
38      {
39         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
40           {
41              Evas_Object *icon = external_common_param_icon_get(obj, param);
42              if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
43              elm_bubble_icon_set(obj, icon);
44              return EINA_TRUE;
45           }
46      }
47    else if (!strcmp(param->name, "info"))
48      {
49         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
50           {
51              elm_bubble_info_set(obj, param->s);
52              return EINA_TRUE;
53           }
54      }
55    else if (!strcmp(param->name, "content"))
56      {
57         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
58           {
59              Evas_Object *content = \
60                     external_common_param_edje_object_get(obj, param);
61              if ((strcmp(param->s, "")) && (!content)) return EINA_FALSE;
62              elm_bubble_content_set(obj, content);
63              return EINA_TRUE;
64           }
65      }
66
67    ERR("unknown parameter '%s' of type '%s'",
68        param->name, edje_external_param_type_str(param->type));
69
70    return EINA_FALSE;
71 }
72
73 static Eina_Bool
74 external_bubble_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
75 {
76    if (!strcmp(param->name, "label"))
77      {
78         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
79           {
80              param->s = elm_bubble_label_get(obj);
81              return EINA_TRUE;
82           }
83      }
84    else if (!strcmp(param->name, "icon"))
85      {
86         /* not easy to get icon name back from live object */
87         return EINA_FALSE;
88      }
89    else if (!strcmp(param->name, "info"))
90      {
91         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
92           {
93              param->s = elm_bubble_info_get(obj);
94              return EINA_TRUE;
95           }
96      }
97    else if (!strcmp(param->name, "content"))
98      {
99         /* not easy to get content name back from live object */
100         return EINA_FALSE;
101      }
102
103    ERR("unknown parameter '%s' of type '%s'",
104        param->name, edje_external_param_type_str(param->type));
105
106    return EINA_FALSE;
107 }
108
109 static void *
110 external_bubble_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
111 {
112    Elm_Params_Bubble *mem;
113    Edje_External_Param *param;
114    const Eina_List *l;
115
116    mem = external_common_params_parse(Elm_Params_Bubble, data, obj, params);
117    if (!mem)
118      return NULL;
119
120    external_common_icon_param_parse(&mem->icon, obj, params);
121
122    EINA_LIST_FOREACH(params, l, param)
123      {
124         if (!strcmp(param->name, "info"))
125           mem->info = eina_stringshare_add(param->s);
126         else if (!strcmp(param->name, "content"))
127           mem->content = external_common_param_edje_object_get(obj, param);
128      }
129
130    return mem;
131 }
132
133 static Evas_Object *external_bubble_content_get(void *data __UNUSED__,
134                 const Evas_Object *obj, const char *content)
135 {
136         ERR("so content");
137         return NULL;
138 }
139
140 static void
141 external_bubble_params_free(void *params)
142 {
143    Elm_Params_Bubble *mem = params;
144
145    if (mem->info)
146      eina_stringshare_del(mem->info);
147    external_common_params_free(params);
148 }
149
150 static Edje_External_Param_Info external_bubble_params[] = {
151    DEFINE_EXTERNAL_COMMON_PARAMS,
152    EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
153    EDJE_EXTERNAL_PARAM_INFO_STRING("info"),
154    EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
155    EDJE_EXTERNAL_PARAM_INFO_SENTINEL
156 };
157
158 DEFINE_EXTERNAL_ICON_ADD(bubble, "bubble");
159 DEFINE_EXTERNAL_TYPE_SIMPLE(bubble, "Bubble");