summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Atton <jonathan.atton@gmail.com>2010-07-11 21:19:27 +0000
committerJonathan Atton <jonathan.atton@gmail.com>2010-07-11 21:19:27 +0000
commit0f4120738fcec4f1e459305aca15d65148061519 (patch)
tree635aef59ffe5958a14c7dc6b04481bb5199b55b0
parent14701103af296434e4c430eeb2e8c0d696f01555 (diff)
Add the elm notify external object
SVN revision: 50180
Diffstat (limited to '')
-rw-r--r--src/edje_externals/Makefile.am3
-rw-r--r--src/edje_externals/elm_notify.c206
-rw-r--r--src/edje_externals/modules.inc1
-rw-r--r--src/lib/Elementary.h.in6
-rw-r--r--src/lib/elm_notify.c39
5 files changed, 253 insertions, 2 deletions
diff --git a/src/edje_externals/Makefile.am b/src/edje_externals/Makefile.am
index 44b277a7f..6b94540c7 100644
--- a/src/edje_externals/Makefile.am
+++ b/src/edje_externals/Makefile.am
@@ -49,7 +49,8 @@ elm_slideshow.c \
49elm_spinner.c \ 49elm_spinner.c \
50elm_thumb.c \ 50elm_thumb.c \
51elm_toggle.c \ 51elm_toggle.c \
52elm_toolbar.c 52elm_toolbar.c \
53elm_notify.c
53 54
54elm_la_LIBADD = $(top_builddir)/src/lib/libelementary.la 55elm_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
55elm_la_LDFLAGS = $(all_libraries) -no-undefined @lt_enable_auto_import@ -module -avoid-version -shared -fPIC 56elm_la_LDFLAGS = $(all_libraries) -no-undefined @lt_enable_auto_import@ -module -avoid-version -shared -fPIC
diff --git a/src/edje_externals/elm_notify.c b/src/edje_externals/elm_notify.c
new file mode 100644
index 000000000..54db41591
--- /dev/null
+++ b/src/edje_externals/elm_notify.c
@@ -0,0 +1,206 @@
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 repeat_events_exists;
11 Eina_Bool repeat_events;
12 Eina_Bool timer_init;
13 Eina_Bool timeout_exists;
14 int timeout;
15
16 const char *orient;
17};
18
19
20static const char *orients[] = {
21 "top",
22 "center",
23 "bottom",
24 "left",
25 "right",
26 "top_left",
27 "top_right",
28 "bottom_left",
29 "bottom_right",
30 NULL
31};
32
33static Elm_Notify_Orient _orient_get(const char *orient)
34{
35 unsigned int i;
36
37 assert(sizeof(orients)/sizeof(orients[0]) ==
38 ELM_NOTIFY_ORIENT_LAST + 1);
39
40 for (i = 0; i < sizeof(orients); i++)
41 if (strcmp(orient, orients[i]) == 0) return i;
42
43 return ELM_NOTIFY_ORIENT_LAST;
44}
45
46static void external_notify_state_set(void *data __UNUSED__,
47 Evas_Object *obj, const void *from_params,
48 const void *to_params, float pos __UNUSED__)
49{
50 const Elm_Params_Notify *p;
51
52 if (to_params) p = to_params;
53 else if (from_params) p = from_params;
54 else return;
55
56 if (p->content) {
57 elm_notify_content_set(obj, p->content);
58 }
59 if(p->repeat_events_exists)
60 elm_notify_repeat_events_set(obj, p->repeat_events);
61 if(p->timeout_exists)
62 elm_notify_timeout_set(obj, p->timeout);
63 if(p->timer_init)
64 elm_notify_timer_init(obj);
65
66 if (p->orient)
67 {
68 Elm_Notify_Orient set = _orient_get(p->orient);
69 if (set == ELM_NOTIFY_ORIENT_LAST) return;
70 elm_notify_orient_set(obj, set);
71 }
72}
73
74static Eina_Bool external_notify_param_set(void *data __UNUSED__,
75 Evas_Object *obj, const Edje_External_Param *param)
76{
77 if (!strcmp(param->name, "content")
78 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
79 {
80 Evas_Object *content = external_common_param_edje_object_get(obj, param);
81 if ((strcmp(param->s, "")) && (!content))
82 return EINA_FALSE;
83 elm_notify_content_set(obj, content);
84 return EINA_TRUE;
85 }
86 else if (!strcmp(param->name, "repeat_events")
87 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
88 {
89 elm_notify_repeat_events_set(obj, param->i);
90 return EINA_TRUE;
91 }
92 else if (!strcmp(param->name, "timer_init")
93 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
94 {
95 elm_notify_timer_init(obj);
96 return EINA_TRUE;
97 }
98 else if (!strcmp(param->name, "timeout")
99 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
100 {
101 elm_notify_timeout_set(obj, param->i);
102 return EINA_TRUE;
103 }
104 else if (!strcmp(param->name, "orient")
105 && param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
106 {
107 Elm_Notify_Orient set = _orient_get(param->s);
108 if (set == ELM_NOTIFY_ORIENT_LAST) return;
109 elm_notify_orient_set(obj, set);
110 return EINA_TRUE;
111 }
112
113 ERR("unknown parameter '%s' of type '%s'",
114 param->name, edje_external_param_type_str(param->type));
115
116 return EINA_FALSE;
117}
118
119static Eina_Bool external_notify_param_get(void *data __UNUSED__,
120 const Evas_Object *obj, Edje_External_Param *param)
121{
122 if (!strcmp(param->name, "content"))
123 {
124 /* not easy to get content name back from live object */
125 return EINA_FALSE;
126 }
127 else if (!strcmp(param->name, "repeat_events")
128 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
129 {
130 param->i = elm_notify_repeat_events_get(obj);
131 return EINA_TRUE;
132 }
133 else if (!strcmp(param->name, "timeout")
134 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
135 {
136 param->i = elm_notify_timeout_get(obj);
137 return EINA_TRUE;
138 }
139 else if (!strcmp(param->name, "orient")
140 && param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
141 {
142 Elm_Notify_Orient set = elm_notify_orient_get(obj);
143 if (set == ELM_NOTIFY_ORIENT_LAST) return EINA_FALSE;
144 param->s = orients[set];
145 return EINA_TRUE;
146 }
147
148 ERR("unknown parameter '%s' of type '%s'",
149 param->name, edje_external_param_type_str(param->type));
150
151 return EINA_FALSE;
152}
153
154static void * external_notify_params_parse(void *data, Evas_Object *obj,
155 const Eina_List *params) {
156 Elm_Params_Notify *mem;
157 Edje_External_Param *param;
158 const Eina_List *l;
159
160 mem = external_common_params_parse(Elm_Params_Notify, data, obj, params);
161 if (!mem)
162 return NULL;
163
164 EINA_LIST_FOREACH(params, l, param)
165 {
166 if (!strcmp(param->name, "content"))
167 mem->content = external_common_param_edje_object_get(obj, param);
168 else if (!strcmp(param->name, "timeout"))
169 {
170 mem->timeout = param->i;
171 mem->timeout_exists = EINA_TRUE;
172 }
173 else if (!strcmp(param->name, "timer_init") && param->i > 0)
174 {
175 mem->timer_init = EINA_TRUE;
176 }
177 else if (!strcmp(param->name, "repeat_events"))
178 {
179 mem->repeat_events = param->i;
180 mem->repeat_events_exists = EINA_TRUE;
181 }
182 else if (!strcmp(param->name, "orient"))
183 mem->orient = eina_stringshare_add(param->s);
184 }
185
186 return mem;
187}
188
189static void external_notify_params_free(void *params) {
190 Elm_Params_Notify *mem = params;
191
192 external_common_params_free(params);
193}
194
195static Edje_External_Param_Info external_notify_params[] = {
196 DEFINE_EXTERNAL_COMMON_PARAMS,
197 EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
198 EDJE_EXTERNAL_PARAM_INFO_BOOL("repeat_events"),
199 EDJE_EXTERNAL_PARAM_INFO_INT("timeout"),
200 EDJE_EXTERNAL_PARAM_INFO_BOOL("timer_init"),
201 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
202};
203
204DEFINE_EXTERNAL_ICON_ADD(notify, "notify");
205DEFINE_EXTERNAL_TYPE_SIMPLE(notify, "Notify")
206;
diff --git a/src/edje_externals/modules.inc b/src/edje_externals/modules.inc
index ec2950839..3dfa71dae 100644
--- a/src/edje_externals/modules.inc
+++ b/src/edje_externals/modules.inc
@@ -21,3 +21,4 @@ DEFINE_TYPE(spinner)
21DEFINE_TYPE(thumb) 21DEFINE_TYPE(thumb)
22DEFINE_TYPE(toggle) 22DEFINE_TYPE(toggle)
23DEFINE_TYPE(toolbar) 23DEFINE_TYPE(toolbar)
24DEFINE_TYPE(notify)
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index b3c8791f5..bfe21d34c 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -672,16 +672,20 @@ extern "C" {
672 ELM_NOTIFY_ORIENT_TOP_LEFT, 672 ELM_NOTIFY_ORIENT_TOP_LEFT,
673 ELM_NOTIFY_ORIENT_TOP_RIGHT, 673 ELM_NOTIFY_ORIENT_TOP_RIGHT,
674 ELM_NOTIFY_ORIENT_BOTTOM_LEFT, 674 ELM_NOTIFY_ORIENT_BOTTOM_LEFT,
675 ELM_NOTIFY_ORIENT_BOTTOM_RIGHT 675 ELM_NOTIFY_ORIENT_BOTTOM_RIGHT,
676 ELM_NOTIFY_ORIENT_LAST
676 } Elm_Notify_Orient; 677 } Elm_Notify_Orient;
677 EAPI Evas_Object *elm_notify_add(Evas_Object *parent); 678 EAPI Evas_Object *elm_notify_add(Evas_Object *parent);
678 EAPI void elm_notify_content_set(Evas_Object *obj, Evas_Object *content); 679 EAPI void elm_notify_content_set(Evas_Object *obj, Evas_Object *content);
679 EAPI Evas_Object *elm_notify_content_unset(Evas_Object *obj); 680 EAPI Evas_Object *elm_notify_content_unset(Evas_Object *obj);
680 EAPI void elm_notify_parent_set(Evas_Object *obj, Evas_Object *parent); 681 EAPI void elm_notify_parent_set(Evas_Object *obj, Evas_Object *parent);
681 EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient); 682 EAPI void elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient);
683 EAPI Elm_Notify_Orient elm_notify_orient_get(const Evas_Object *obj);
682 EAPI void elm_notify_timeout_set(Evas_Object *obj, int timeout); 684 EAPI void elm_notify_timeout_set(Evas_Object *obj, int timeout);
685 EAPI int elm_notify_timeout_get(const Evas_Object *obj);
683 EAPI void elm_notify_timer_init(Evas_Object *obj); 686 EAPI void elm_notify_timer_init(Evas_Object *obj);
684 EAPI void elm_notify_repeat_events_set(Evas_Object *obj, Eina_Bool repeat); 687 EAPI void elm_notify_repeat_events_set(Evas_Object *obj, Eina_Bool repeat);
688 EAPI Eina_Bool elm_notify_repeat_events_get(const Evas_Object *obj);
685 /* smart callbacks called: 689 /* smart callbacks called:
686 */ 690 */
687 691
diff --git a/src/lib/elm_notify.c b/src/lib/elm_notify.c
index 385c41099..5351d29a4 100644
--- a/src/lib/elm_notify.c
+++ b/src/lib/elm_notify.c
@@ -443,6 +443,19 @@ elm_notify_orient_set(Evas_Object *obj, Elm_Notify_Orient orient)
443} 443}
444 444
445/** 445/**
446 * Return the orientation
447 * @param obj the notify objects
448 */
449EAPI Elm_Notify_Orient
450elm_notify_orient_get(const Evas_Object *obj)
451{
452 ELM_CHECK_WIDTYPE(obj, widtype);
453 Widget_Data *wd = elm_widget_data_get(obj);
454 if (!wd) return;
455 return wd->orient;
456}
457
458/**
446 * Set the time before the notify window is hidden. <br> 459 * Set the time before the notify window is hidden. <br>
447 * Set a value < 0 to disable the timer 460 * Set a value < 0 to disable the timer
448 * 461 *
@@ -460,6 +473,19 @@ elm_notify_timeout_set(Evas_Object *obj, int timeout)
460} 473}
461 474
462/** 475/**
476 * Return the timeout value (in seconds)
477 * @param obj the notify object
478 */
479EAPI int
480elm_notify_timeout_get(const Evas_Object *obj)
481{
482 ELM_CHECK_WIDTYPE(obj, widtype);
483 Widget_Data *wd = elm_widget_data_get(obj);
484 if (!wd) return;
485 return wd->timeout;
486}
487
488/**
463 * Re-init the timer 489 * Re-init the timer
464 * @param obj The notify object 490 * @param obj The notify object
465 */ 491 */
@@ -504,3 +530,16 @@ elm_notify_repeat_events_set(Evas_Object *obj, Eina_Bool repeat)
504 evas_object_del(wd->block_events); 530 evas_object_del(wd->block_events);
505} 531}
506 532
533/**
534 * Return true if events are repeat below the notify object
535 * @param obj the notify object
536 */
537EAPI Eina_Bool
538elm_notify_repeat_events_get(const Evas_Object *obj)
539{
540 ELM_CHECK_WIDTYPE(obj, widtype);
541 Widget_Data *wd = elm_widget_data_get(obj);
542 if (!wd) return;
543 return wd->repeat_events;
544}
545