aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/edje_externals/elm_notify.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/elementary/src/edje_externals/elm_notify.c')
-rw-r--r--libraries/elementary/src/edje_externals/elm_notify.c199
1 files changed, 199 insertions, 0 deletions
diff --git a/libraries/elementary/src/edje_externals/elm_notify.c b/libraries/elementary/src/edje_externals/elm_notify.c
new file mode 100644
index 0000000..d44b3f3
--- /dev/null
+++ b/libraries/elementary/src/edje_externals/elm_notify.c
@@ -0,0 +1,199 @@
1#include "private.h"
2#include <assert.h>
3
4
5typedef struct _Elm_Params_Notify Elm_Params_Notify;
6
7struct _Elm_Params_Notify {
8 Elm_Params base;
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;
13 double timeout;
14
15 const char *orient;
16};
17
18
19static const char *orients[] = {
20 "top",
21 "center",
22 "bottom",
23 "left",
24 "right",
25 "top_left",
26 "top_right",
27 "bottom_left",
28 "bottom_right",
29 NULL
30};
31
32static Elm_Notify_Orient _orient_get(const char *orient)
33{
34 unsigned int i;
35
36 assert(sizeof(orients)/sizeof(orients[0]) ==
37 ELM_NOTIFY_ORIENT_LAST + 1);
38
39 for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++)
40 if (!strcmp(orient, orients[i])) return i;
41
42 return ELM_NOTIFY_ORIENT_LAST;
43}
44
45static void external_notify_state_set(void *data __UNUSED__,
46 Evas_Object *obj, const void *from_params,
47 const void *to_params, float pos __UNUSED__)
48{
49 const Elm_Params_Notify *p;
50
51 if (to_params) p = to_params;
52 else if (from_params) p = from_params;
53 else return;
54
55 if (p->content) {
56 elm_object_content_set(obj, p->content);
57 }
58 if (p->allow_events_exists)
59 elm_notify_allow_events_set(obj, p->allow_events);
60 if (p->timeout_exists)
61 elm_notify_timeout_set(obj, p->timeout);
62 if (p->orient)
63 {
64 Elm_Notify_Orient set = _orient_get(p->orient);
65 if (set == ELM_NOTIFY_ORIENT_LAST) return;
66 elm_notify_orient_set(obj, set);
67 }
68}
69
70static Eina_Bool external_notify_param_set(void *data __UNUSED__,
71 Evas_Object *obj, const Edje_External_Param *param)
72{
73 if ((!strcmp(param->name, "content"))
74 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
75 {
76 Evas_Object *content = external_common_param_edje_object_get(obj, param);
77 if ((strcmp(param->s, "")) && (!content))
78 return EINA_FALSE;
79 elm_object_content_set(obj, content);
80 return EINA_TRUE;
81 }
82 else if ((!strcmp(param->name, "allow_events"))
83 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
84 {
85 elm_notify_allow_events_set(obj, param->i);
86 return EINA_TRUE;
87 }
88 else if ((!strcmp(param->name, "timeout"))
89 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
90 {
91 elm_notify_timeout_set(obj, param->d);
92 return EINA_TRUE;
93 }
94 else if ((!strcmp(param->name, "orient"))
95 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
96 {
97 Elm_Notify_Orient set = _orient_get(param->s);
98 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
99 elm_notify_orient_set(obj, set);
100 return EINA_TRUE;
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
109static Eina_Bool external_notify_param_get(void *data __UNUSED__,
110 const Evas_Object *obj, Edje_External_Param *param)
111{
112 if (!strcmp(param->name, "content"))
113 {
114 /* not easy to get content name back from live object */
115 return EINA_FALSE;
116 }
117 else if ((!strcmp(param->name, "allow_events"))
118 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
119 {
120 param->i = elm_notify_allow_events_get(obj);
121 return EINA_TRUE;
122 }
123 else if ((!strcmp(param->name, "timeout"))
124 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
125 {
126 param->d = elm_notify_timeout_get(obj);
127 return EINA_TRUE;
128 }
129 else if ((!strcmp(param->name, "orient"))
130 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
131 {
132 Elm_Notify_Orient set = elm_notify_orient_get(obj);
133 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
134 param->s = orients[set];
135 return EINA_TRUE;
136 }
137
138 ERR("unknown parameter '%s' of type '%s'",
139 param->name, edje_external_param_type_str(param->type));
140
141 return EINA_FALSE;
142}
143
144static void * external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj,
145 const Eina_List *params) {
146 Elm_Params_Notify *mem;
147 Edje_External_Param *param;
148 const Eina_List *l;
149
150 mem = calloc(1, sizeof(Elm_Params_Notify));
151 if (!mem)
152 return NULL;
153
154 EINA_LIST_FOREACH(params, l, param)
155 {
156 if (!strcmp(param->name, "content"))
157 mem->content = external_common_param_edje_object_get(obj, param);
158 else if (!strcmp(param->name, "timeout"))
159 {
160 mem->timeout = param->d;
161 mem->timeout_exists = EINA_TRUE;
162 }
163 else if (!strcmp(param->name, "allow_events"))
164 {
165 mem->allow_events = param->i;
166 mem->allow_events_exists = EINA_TRUE;
167 }
168 else if (!strcmp(param->name, "orient"))
169 mem->orient = eina_stringshare_add(param->s);
170 }
171
172 return mem;
173}
174
175static Evas_Object *external_notify_content_get(void *data __UNUSED__,
176 const Evas_Object *obj, const char *content)
177{
178 if (!strcmp(content, "content"))
179 return elm_object_content_get(obj);
180
181 ERR("unknown content '%s'", content);
182 return NULL;
183}
184
185static void external_notify_params_free(void *params) {
186 free(params);
187}
188
189static Edje_External_Param_Info external_notify_params[] = {
190 DEFINE_EXTERNAL_COMMON_PARAMS,
191 EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
192 EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
193 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
194 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
195};
196
197DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
198DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify")
199;