5 typedef struct _Elm_Params_Notify Elm_Params_Notify;
7 struct _Elm_Params_Notify {
9 Evas_Object *content; /* part name whose obj is to be set as content */
10 Eina_Bool allow_events_exists;
11 Eina_Bool allow_events;
12 Eina_Bool timeout_exists;
19 static const char *orients[] = {
32 /* keeping old externals orient api for notify, but taking away the
33 * introduced deprecation warning by copying the deprecated code
35 static Elm_Notify_Orient
36 _elm_notify_orient_get(const Evas_Object *obj)
38 Elm_Notify_Orient orient;
39 double horizontal, vertical;
41 elm_notify_align_get(obj, &horizontal, &vertical);
43 if ((horizontal == 0.5) && (vertical == 0.0))
44 orient = ELM_NOTIFY_ORIENT_TOP;
45 else if ((horizontal == 0.5) && (vertical == 0.5))
46 orient = ELM_NOTIFY_ORIENT_CENTER;
47 else if ((horizontal == 0.5) && (vertical == 1.0))
48 orient = ELM_NOTIFY_ORIENT_BOTTOM;
49 else if ((horizontal == 0.0) && (vertical == 0.5))
50 orient = ELM_NOTIFY_ORIENT_LEFT;
51 else if ((horizontal == 1.0) && (vertical == 0.5))
52 orient = ELM_NOTIFY_ORIENT_RIGHT;
53 else if ((horizontal == 0.0) && (vertical == 0.0))
54 orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
55 else if ((horizontal == 1.0) && (vertical == 0.0))
56 orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
57 else if ((horizontal == 0.0) && (vertical == 1.0))
58 orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
59 else if ((horizontal == 1.0) && (vertical == 1.0))
60 orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
62 orient = ELM_NOTIFY_ORIENT_TOP;
67 _elm_notify_orient_set(Evas_Object *obj,
68 Elm_Notify_Orient orient)
70 double horizontal = 0, vertical = 0;
74 case ELM_NOTIFY_ORIENT_TOP:
75 horizontal = 0.5; vertical = 0.0;
78 case ELM_NOTIFY_ORIENT_CENTER:
79 horizontal = 0.5; vertical = 0.5;
82 case ELM_NOTIFY_ORIENT_BOTTOM:
83 horizontal = 0.5; vertical = 1.0;
86 case ELM_NOTIFY_ORIENT_LEFT:
87 horizontal = 0.0; vertical = 0.5;
90 case ELM_NOTIFY_ORIENT_RIGHT:
91 horizontal = 1.0; vertical = 0.5;
94 case ELM_NOTIFY_ORIENT_TOP_LEFT:
95 horizontal = 0.0; vertical = 0.0;
98 case ELM_NOTIFY_ORIENT_TOP_RIGHT:
99 horizontal = 1.0; vertical = 0.0;
102 case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
103 horizontal = 0.0; vertical = 1.0;
106 case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
107 horizontal = 1.0; vertical = 1.0;
110 case ELM_NOTIFY_ORIENT_LAST:
114 elm_notify_align_set(obj, horizontal, vertical);
117 static Elm_Notify_Orient _orient_get(const char *orient)
121 assert(sizeof(orients)/sizeof(orients[0]) ==
122 ELM_NOTIFY_ORIENT_LAST + 1);
124 for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++)
125 if (!strcmp(orient, orients[i])) return i;
127 return ELM_NOTIFY_ORIENT_LAST;
130 static void external_notify_state_set(void *data __UNUSED__,
131 Evas_Object *obj, const void *from_params,
132 const void *to_params, float pos __UNUSED__)
134 const Elm_Params_Notify *p;
136 if (to_params) p = to_params;
137 else if (from_params) p = from_params;
141 elm_object_content_set(obj, p->content);
143 if (p->allow_events_exists)
144 elm_notify_allow_events_set(obj, p->allow_events);
145 if (p->timeout_exists)
146 elm_notify_timeout_set(obj, p->timeout);
149 Elm_Notify_Orient set = _orient_get(p->orient);
150 if (set == ELM_NOTIFY_ORIENT_LAST) return;
151 _elm_notify_orient_set(obj, set);
155 static Eina_Bool external_notify_param_set(void *data __UNUSED__,
156 Evas_Object *obj, const Edje_External_Param *param)
158 if ((!strcmp(param->name, "content"))
159 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
161 Evas_Object *content = external_common_param_edje_object_get(obj, param);
162 if ((strcmp(param->s, "")) && (!content))
164 elm_object_content_set(obj, content);
167 else if ((!strcmp(param->name, "allow_events"))
168 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
170 elm_notify_allow_events_set(obj, param->i);
173 else if ((!strcmp(param->name, "timeout"))
174 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
176 elm_notify_timeout_set(obj, param->d);
179 else if ((!strcmp(param->name, "orient"))
180 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
182 Elm_Notify_Orient set = _orient_get(param->s);
183 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
184 _elm_notify_orient_set(obj, set);
188 ERR("unknown parameter '%s' of type '%s'",
189 param->name, edje_external_param_type_str(param->type));
194 static Eina_Bool external_notify_param_get(void *data __UNUSED__,
195 const Evas_Object *obj, Edje_External_Param *param)
197 if (!strcmp(param->name, "content"))
199 /* not easy to get content name back from live object */
202 else if ((!strcmp(param->name, "allow_events"))
203 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
205 param->i = elm_notify_allow_events_get(obj);
208 else if ((!strcmp(param->name, "timeout"))
209 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
211 param->d = elm_notify_timeout_get(obj);
214 else if ((!strcmp(param->name, "orient"))
215 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
217 Elm_Notify_Orient set = _elm_notify_orient_get(obj);
218 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
219 param->s = orients[set];
223 ERR("unknown parameter '%s' of type '%s'",
224 param->name, edje_external_param_type_str(param->type));
229 static void * external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj,
230 const Eina_List *params) {
231 Elm_Params_Notify *mem;
232 Edje_External_Param *param;
235 mem = calloc(1, sizeof(Elm_Params_Notify));
239 EINA_LIST_FOREACH(params, l, param)
241 if (!strcmp(param->name, "content"))
242 mem->content = external_common_param_edje_object_get(obj, param);
243 else if (!strcmp(param->name, "timeout"))
245 mem->timeout = param->d;
246 mem->timeout_exists = EINA_TRUE;
248 else if (!strcmp(param->name, "allow_events"))
250 mem->allow_events = param->i;
251 mem->allow_events_exists = EINA_TRUE;
253 else if (!strcmp(param->name, "orient"))
254 mem->orient = eina_stringshare_add(param->s);
260 static Evas_Object *external_notify_content_get(void *data __UNUSED__,
261 const Evas_Object *obj, const char *content)
263 if (!strcmp(content, "content"))
264 return elm_object_content_get(obj);
266 ERR("unknown content '%s'", content);
270 static void external_notify_params_free(void *params) {
274 static Edje_External_Param_Info external_notify_params[] = {
275 DEFINE_EXTERNAL_COMMON_PARAMS,
276 EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
277 EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
278 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
279 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
282 DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
283 DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify")