summaryrefslogtreecommitdiff
path: root/src/edje_externals
diff options
context:
space:
mode:
authorGustavo Lima Chaves <glima@profusion.mobi>2012-11-06 19:54:16 +0000
committerGustavo Lima Chaves <glima@profusion.mobi>2012-11-06 19:54:16 +0000
commit3d47e941e7dfb904d4c2af5b57826bd152a5dd79 (patch)
treebdc4dcb9caa2f9ed417b228ad05fd5a763d21af0 /src/edje_externals
parent4d2b17ff386e36016fc39ebebf4629873447f42e (diff)
[elm] Account for elm_object_orient_set() deprecation
along elm files. Spankies to Hermet for not doing it/delegating it before :) SVN revision: 78948
Diffstat (limited to 'src/edje_externals')
-rw-r--r--src/edje_externals/elm_notify.c407
1 files changed, 250 insertions, 157 deletions
diff --git a/src/edje_externals/elm_notify.c b/src/edje_externals/elm_notify.c
index d44b3f3a3..1b1535f4f 100644
--- a/src/edje_externals/elm_notify.c
+++ b/src/edje_externals/elm_notify.c
@@ -1,40 +1,125 @@
1#include "private.h" 1#include "private.h"
2#include <assert.h> 2#include <assert.h>
3 3
4
5typedef struct _Elm_Params_Notify Elm_Params_Notify; 4typedef struct _Elm_Params_Notify Elm_Params_Notify;
6 5
7struct _Elm_Params_Notify { 6struct _Elm_Params_Notify
8 Elm_Params base; 7{
9 Evas_Object *content; /* part name whose obj is to be set as content */ 8 Elm_Params base;
10 Eina_Bool allow_events_exists; 9 Evas_Object *content; /* part name whose obj is to be set as content */
11 Eina_Bool allow_events; 10 Eina_Bool allow_events_exists;
12 Eina_Bool timeout_exists; 11 Eina_Bool allow_events;
13 double timeout; 12 Eina_Bool timeout_exists;
13 double timeout;
14 14
15 const char *orient; 15 const char *orient;
16}; 16};
17 17
18
19static const char *orients[] = { 18static const char *orients[] = {
20 "top", 19 "top",
21 "center", 20 "center",
22 "bottom", 21 "bottom",
23 "left", 22 "left",
24 "right", 23 "right",
25 "top_left", 24 "top_left",
26 "top_right", 25 "top_right",
27 "bottom_left", 26 "bottom_left",
28 "bottom_right", 27 "bottom_right",
29 NULL 28 NULL
30}; 29};
31 30
32static Elm_Notify_Orient _orient_get(const char *orient) 31/* keeping old externals orient api for notify, but taking away the
32 * introduced deprecation warning by copying the deprecated code
33 * here */
34static Elm_Notify_Orient
35_elm_notify_orient_get(const Evas_Object *obj)
36{
37 Elm_Notify_Orient orient;
38 double horizontal, vertical;
39
40 elm_notify_align_get(obj, &horizontal, &vertical);
41
42 if ((horizontal == 0.5) && (vertical == 0.0))
43 orient = ELM_NOTIFY_ORIENT_TOP;
44 else if ((horizontal == 0.5) && (vertical == 0.5))
45 orient = ELM_NOTIFY_ORIENT_CENTER;
46 else if ((horizontal == 0.5) && (vertical == 1.0))
47 orient = ELM_NOTIFY_ORIENT_BOTTOM;
48 else if ((horizontal == 0.0) && (vertical == 0.5))
49 orient = ELM_NOTIFY_ORIENT_LEFT;
50 else if ((horizontal == 1.0) && (vertical == 0.5))
51 orient = ELM_NOTIFY_ORIENT_RIGHT;
52 else if ((horizontal == 0.0) && (vertical == 0.0))
53 orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
54 else if ((horizontal == 1.0) && (vertical == 0.0))
55 orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
56 else if ((horizontal == 0.0) && (vertical == 1.0))
57 orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
58 else if ((horizontal == 1.0) && (vertical == 1.0))
59 orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
60 else
61 orient = ELM_NOTIFY_ORIENT_TOP;
62 return orient;
63}
64
65static void
66_elm_notify_orient_set(Evas_Object *obj,
67 Elm_Notify_Orient orient)
68{
69 double horizontal = 0, vertical = 0;
70
71 switch (orient)
72 {
73 case ELM_NOTIFY_ORIENT_TOP:
74 horizontal = 0.5; vertical = 0.0;
75 break;
76
77 case ELM_NOTIFY_ORIENT_CENTER:
78 horizontal = 0.5; vertical = 0.5;
79 break;
80
81 case ELM_NOTIFY_ORIENT_BOTTOM:
82 horizontal = 0.5; vertical = 1.0;
83 break;
84
85 case ELM_NOTIFY_ORIENT_LEFT:
86 horizontal = 0.0; vertical = 0.5;
87 break;
88
89 case ELM_NOTIFY_ORIENT_RIGHT:
90 horizontal = 1.0; vertical = 0.5;
91 break;
92
93 case ELM_NOTIFY_ORIENT_TOP_LEFT:
94 horizontal = 0.0; vertical = 0.0;
95 break;
96
97 case ELM_NOTIFY_ORIENT_TOP_RIGHT:
98 horizontal = 1.0; vertical = 0.0;
99 break;
100
101 case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
102 horizontal = 0.0; vertical = 1.0;
103 break;
104
105 case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
106 horizontal = 1.0; vertical = 1.0;
107 break;
108
109 case ELM_NOTIFY_ORIENT_LAST:
110 break;
111 }
112
113 elm_notify_align_set(obj, horizontal, vertical);
114}
115
116static Elm_Notify_Orient
117_orient_get(const char *orient)
33{ 118{
34 unsigned int i; 119 unsigned int i;
35 120
36 assert(sizeof(orients)/sizeof(orients[0]) == 121 assert(sizeof(orients) / sizeof(orients[0]) ==
37 ELM_NOTIFY_ORIENT_LAST + 1); 122 ELM_NOTIFY_ORIENT_LAST + 1);
38 123
39 for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++) 124 for (i = 0; i < ELM_NOTIFY_ORIENT_LAST; i++)
40 if (!strcmp(orient, orients[i])) return i; 125 if (!strcmp(orient, orients[i])) return i;
@@ -42,158 +127,166 @@ static Elm_Notify_Orient _orient_get(const char *orient)
42 return ELM_NOTIFY_ORIENT_LAST; 127 return ELM_NOTIFY_ORIENT_LAST;
43} 128}
44 129
45static void external_notify_state_set(void *data __UNUSED__, 130static void
46 Evas_Object *obj, const void *from_params, 131external_notify_state_set(void *data __UNUSED__,
47 const void *to_params, float pos __UNUSED__) 132 Evas_Object *obj, const void *from_params,
133 const void *to_params, float pos __UNUSED__)
48{ 134{
49 const Elm_Params_Notify *p; 135 const Elm_Params_Notify *p;
50 136
51 if (to_params) p = to_params; 137 if (to_params) p = to_params;
52 else if (from_params) p = from_params; 138 else if (from_params)
53 else return; 139 p = from_params;
54 140 else return;
55 if (p->content) { 141
56 elm_object_content_set(obj, p->content); 142 if (p->content)
57 } 143 {
58 if (p->allow_events_exists) 144 elm_object_content_set(obj, p->content);
59 elm_notify_allow_events_set(obj, p->allow_events); 145 }
60 if (p->timeout_exists) 146 if (p->allow_events_exists)
61 elm_notify_timeout_set(obj, p->timeout); 147 elm_notify_allow_events_set(obj, p->allow_events);
62 if (p->orient) 148 if (p->timeout_exists)
63 { 149 elm_notify_timeout_set(obj, p->timeout);
64 Elm_Notify_Orient set = _orient_get(p->orient); 150 if (p->orient)
65 if (set == ELM_NOTIFY_ORIENT_LAST) return; 151 {
66 elm_notify_orient_set(obj, set); 152 Elm_Notify_Orient set = _orient_get(p->orient);
67 } 153 if (set == ELM_NOTIFY_ORIENT_LAST) return;
154 _elm_notify_orient_set(obj, set);
155 }
68} 156}
69 157
70static Eina_Bool external_notify_param_set(void *data __UNUSED__, 158static Eina_Bool
71 Evas_Object *obj, const Edje_External_Param *param) 159external_notify_param_set(void *data __UNUSED__,
160 Evas_Object *obj, const Edje_External_Param *param)
72{ 161{
73 if ((!strcmp(param->name, "content")) 162 if ((!strcmp(param->name, "content"))
74 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)) 163 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
75 { 164 {
76 Evas_Object *content = external_common_param_edje_object_get(obj, param); 165 Evas_Object *content =
77 if ((strcmp(param->s, "")) && (!content)) 166 external_common_param_edje_object_get(obj, param);
78 return EINA_FALSE; 167 if ((strcmp(param->s, "")) && (!content))
79 elm_object_content_set(obj, content); 168 return EINA_FALSE;
80 return EINA_TRUE; 169 elm_object_content_set(obj, content);
81 } 170 return EINA_TRUE;
82 else if ((!strcmp(param->name, "allow_events")) 171 }
83 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) 172 else if ((!strcmp(param->name, "allow_events"))
84 { 173 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
85 elm_notify_allow_events_set(obj, param->i); 174 {
86 return EINA_TRUE; 175 elm_notify_allow_events_set(obj, param->i);
87 } 176 return EINA_TRUE;
88 else if ((!strcmp(param->name, "timeout")) 177 }
89 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)) 178 else if ((!strcmp(param->name, "timeout"))
90 { 179 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
91 elm_notify_timeout_set(obj, param->d); 180 {
92 return EINA_TRUE; 181 elm_notify_timeout_set(obj, param->d);
93 } 182 return EINA_TRUE;
94 else if ((!strcmp(param->name, "orient")) 183 }
95 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)) 184 else if ((!strcmp(param->name, "orient"))
96 { 185 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
97 Elm_Notify_Orient set = _orient_get(param->s); 186 {
98 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE; 187 Elm_Notify_Orient set = _orient_get(param->s);
99 elm_notify_orient_set(obj, set); 188 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
100 return EINA_TRUE; 189 _elm_notify_orient_set(obj, set);
101 } 190 return EINA_TRUE;
102 191 }
103 ERR("unknown parameter '%s' of type '%s'", 192
104 param->name, edje_external_param_type_str(param->type)); 193 ERR("unknown parameter '%s' of type '%s'",
105 194 param->name, edje_external_param_type_str(param->type));
106 return EINA_FALSE; 195
196 return EINA_FALSE;
107} 197}
108 198
109static Eina_Bool external_notify_param_get(void *data __UNUSED__, 199static Eina_Bool
110 const Evas_Object *obj, Edje_External_Param *param) 200external_notify_param_get(void *data __UNUSED__,
201 const Evas_Object *obj, Edje_External_Param *param)
111{ 202{
112 if (!strcmp(param->name, "content")) 203 if (!strcmp(param->name, "content"))
113 { 204 {
114 /* not easy to get content name back from live object */ 205 /* not easy to get content name back from live object */
115 return EINA_FALSE; 206 return EINA_FALSE;
116 } 207 }
117 else if ((!strcmp(param->name, "allow_events")) 208 else if ((!strcmp(param->name, "allow_events"))
118 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)) 209 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
119 { 210 {
120 param->i = elm_notify_allow_events_get(obj); 211 param->i = elm_notify_allow_events_get(obj);
121 return EINA_TRUE; 212 return EINA_TRUE;
122 } 213 }
123 else if ((!strcmp(param->name, "timeout")) 214 else if ((!strcmp(param->name, "timeout"))
124 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)) 215 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
125 { 216 {
126 param->d = elm_notify_timeout_get(obj); 217 param->d = elm_notify_timeout_get(obj);
127 return EINA_TRUE; 218 return EINA_TRUE;
128 } 219 }
129 else if ((!strcmp(param->name, "orient")) 220 else if ((!strcmp(param->name, "orient"))
130 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)) 221 && (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE))
131 { 222 {
132 Elm_Notify_Orient set = elm_notify_orient_get(obj); 223 Elm_Notify_Orient set = _elm_notify_orient_get(obj);
133 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE; 224 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
134 param->s = orients[set]; 225 param->s = orients[set];
135 return EINA_TRUE; 226 return EINA_TRUE;
136 } 227 }
137 228
138 ERR("unknown parameter '%s' of type '%s'", 229 ERR("unknown parameter '%s' of type '%s'",
139 param->name, edje_external_param_type_str(param->type)); 230 param->name, edje_external_param_type_str(param->type));
140 231
141 return EINA_FALSE; 232 return EINA_FALSE;
142} 233}
143 234
144static void * external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj, 235static void *
145 const Eina_List *params) { 236external_notify_params_parse(void *data __UNUSED__, Evas_Object *obj,
146 Elm_Params_Notify *mem; 237 const Eina_List *params) {
147 Edje_External_Param *param; 238 Elm_Params_Notify *mem;
148 const Eina_List *l; 239 Edje_External_Param *param;
149 240 const Eina_List *l;
150 mem = calloc(1, sizeof(Elm_Params_Notify)); 241
151 if (!mem) 242 mem = calloc(1, sizeof(Elm_Params_Notify));
152 return NULL; 243 if (!mem)
153 244 return NULL;
154 EINA_LIST_FOREACH(params, l, param) 245
155 { 246 EINA_LIST_FOREACH(params, l, param)
156 if (!strcmp(param->name, "content")) 247 {
157 mem->content = external_common_param_edje_object_get(obj, param); 248 if (!strcmp(param->name, "content"))
158 else if (!strcmp(param->name, "timeout")) 249 mem->content = external_common_param_edje_object_get(obj, param);
159 { 250 else if (!strcmp(param->name, "timeout"))
160 mem->timeout = param->d; 251 {
161 mem->timeout_exists = EINA_TRUE; 252 mem->timeout = param->d;
162 } 253 mem->timeout_exists = EINA_TRUE;
163 else if (!strcmp(param->name, "allow_events")) 254 }
164 { 255 else if (!strcmp(param->name, "allow_events"))
165 mem->allow_events = param->i; 256 {
166 mem->allow_events_exists = EINA_TRUE; 257 mem->allow_events = param->i;
167 } 258 mem->allow_events_exists = EINA_TRUE;
168 else if (!strcmp(param->name, "orient")) 259 }
169 mem->orient = eina_stringshare_add(param->s); 260 else if (!strcmp(param->name, "orient"))
170 } 261 mem->orient = eina_stringshare_add(param->s);
171 262 }
172 return mem; 263
264 return mem;
173} 265}
174 266
175static Evas_Object *external_notify_content_get(void *data __UNUSED__, 267static Evas_Object *
176 const Evas_Object *obj, const char *content) 268external_notify_content_get(void *data __UNUSED__,
269 const Evas_Object *obj, const char *content)
177{ 270{
178 if (!strcmp(content, "content")) 271 if (!strcmp(content, "content"))
179 return elm_object_content_get(obj); 272 return elm_object_content_get(obj);
180 273
181 ERR("unknown content '%s'", content); 274 ERR("unknown content '%s'", content);
182 return NULL; 275 return NULL;
183} 276}
184 277
185static void external_notify_params_free(void *params) { 278static void
186 free(params); 279external_notify_params_free(void *params) {
280 free(params);
187} 281}
188 282
189static Edje_External_Param_Info external_notify_params[] = { 283static Edje_External_Param_Info external_notify_params[] = {
190 DEFINE_EXTERNAL_COMMON_PARAMS, 284 DEFINE_EXTERNAL_COMMON_PARAMS,
191 EDJE_EXTERNAL_PARAM_INFO_STRING("content"), 285 EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
192 EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"), 286 EDJE_EXTERNAL_PARAM_INFO_BOOL("allow_events"),
193 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"), 287 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("timeout"),
194 EDJE_EXTERNAL_PARAM_INFO_SENTINEL 288 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
195}; 289};
196 290
197DEFINE_EXTERNAL_ICON_ADD(notify, "notify"); 291DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
198DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify") 292DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify");
199;