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