summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>2009-12-06 01:22:54 +0000
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>2009-12-06 01:22:54 +0000
commitabebd98c52c4bdba993f2d61559a202696c8b732 (patch)
tree480ab91ab764073bee3ea447257e0c55af64ef3d /src
parent4f2d186d2af5b82646032f79a752c51319687c71 (diff)
Elementary edje external modules
Widgets: Button, Check, Radio, Slider, Toggle SVN revision: 44207
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/edje_externals/Makefile.am37
-rw-r--r--src/edje_externals/elm.c87
-rw-r--r--src/edje_externals/elm_button.c59
-rw-r--r--src/edje_externals/elm_check.c61
-rw-r--r--src/edje_externals/elm_radio.c80
-rw-r--r--src/edje_externals/elm_slider.c111
-rw-r--r--src/edje_externals/elm_toggle.c77
-rw-r--r--src/edje_externals/modules.inc5
-rw-r--r--src/edje_externals/private.h76
10 files changed, 594 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6345966f7..be7ccd90f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
1AUTOMAKE_OPTIONS = 1.4 foreign 1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = lib bin modules 4SUBDIRS = lib bin modules edje_externals
diff --git a/src/edje_externals/Makefile.am b/src/edje_externals/Makefile.am
new file mode 100644
index 000000000..8c97bc73a
--- /dev/null
+++ b/src/edje_externals/Makefile.am
@@ -0,0 +1,37 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_builddir) \
7-I$(top_srcdir) \
8-I$(top_srcdir)/src/lib \
9-I$(top_builddir)/src/lib \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11-DPACKAGE_LIB_DIR=\"$(libdir)\" \
12@ELEMENTARY_CFLAGS@ \
13@ELEMENTARY_X_CFLAGS@ \
14@ELEMENTARY_FB_CFLAGS@ \
15@ELEMENTARY_WIN32_CFLAGS@ \
16@ELEMENTARY_WINCE_CFLAGS@ \
17@ELEMENTARY_EDBUS_CFLAGS@ \
18@ELEMENTARY_EFREET_CFLAGS@
19
20if ELEMENTARY_WINDOWS_BUILD
21AM_CPPFLAGS += -DELEMENTARY_BUILD
22endif
23
24pkgdir = $(libdir)/edje
25pkg_LTLIBRARIES = elm.la
26
27elm_la_SOURCES = private.h \
28 modules.inc \
29 elm.c \
30 elm_button.c \
31 elm_check.c \
32 elm_radio.c \
33 elm_slider.c \
34 elm_toggle.c
35
36elm_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
37elm_la_LDFLAGS = $(all_libraries) -no-undefined @lt_enable_auto_import@ -module -avoid-version -shared -fPIC
diff --git a/src/edje_externals/elm.c b/src/edje_externals/elm.c
new file mode 100644
index 000000000..2f39675b3
--- /dev/null
+++ b/src/edje_externals/elm.c
@@ -0,0 +1,87 @@
1#include <Elementary.h>
2#include "private.h"
3
4void
5external_signal(void *data, Evas_Object *obj, const char *signal, const char *source)
6{
7 printf("External Signal received: '%s' '%s'\n", signal, source);
8}
9
10void *
11external_common_params_parse_internal(size_t params_size, void *data, Evas_Object *obj, const Eina_List *params)
12{
13 Elm_Params *p;
14 const Eina_List *l;
15 Edje_External_Param *param;
16
17 if (params_size < sizeof(Elm_Params))
18 return NULL;
19
20 p = calloc(1, params_size);
21 if (!p)
22 return NULL;
23
24 EINA_LIST_FOREACH(params, l, param)
25 {
26 if (!strcmp(param->name, "label"))
27 p->label = param->s;
28 if(!strcmp(param->name, "state"))
29 p->state = param->i;
30 }
31 return p;
32}
33
34void
35external_common_icon_param_parse(Evas_Object **icon, Evas_Object *obj, const Eina_List *params)
36{
37 Edje_External_Param *p;
38
39 p = edje_external_param_find(params, "icon");
40 if (p)
41 {
42 Evas_Object *parent = evas_object_smart_parent_get(obj);
43 const char *file;
44 edje_object_file_get(parent, &file, NULL);
45 *icon = elm_icon_add(parent);
46
47 if (!elm_icon_file_set(*icon, file, p->s))
48 elm_icon_standard_set(*icon, p->s);
49 }
50}
51
52void
53external_common_params_free(void *params)
54{
55 Elm_Params *p = params;
56 free(p);
57};
58
59#define DEFINE_TYPE(type_name) \
60 extern const Edje_External_Type external_##type_name##_type;
61#include "modules.inc"
62#undef DEFINE_TYPE
63
64static Edje_External_Type_Info elm_external_types[] =
65{
66#define DEFINE_TYPE(type_name) \
67 {"elm/"#type_name, &external_##type_name##_type},
68#include "modules.inc"
69#undef DEFINE_TYPE
70 {NULL, NULL}
71};
72
73static Eina_Bool
74elm_mod_init(void)
75{
76 edje_external_type_array_register(elm_external_types);
77 return EINA_TRUE;
78}
79
80static void
81elm_mod_shutdown(void)
82{
83 edje_external_type_array_unregister(elm_external_types);
84}
85
86EINA_MODULE_INIT(elm_mod_init);
87EINA_MODULE_SHUTDOWN(elm_mod_shutdown);
diff --git a/src/edje_externals/elm_button.c b/src/edje_externals/elm_button.c
new file mode 100644
index 000000000..0f0b65118
--- /dev/null
+++ b/src/edje_externals/elm_button.c
@@ -0,0 +1,59 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Button
4{
5 Elm_Params base;
6 Evas_Object *icon;
7} Elm_Params_Button;
8
9static void
10external_button_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos)
11{
12 const Elm_Params_Button *p1 = from_params, *p2 = to_params;
13
14 p1 = from_params;
15 p2 = to_params;
16
17 if (!p2)
18 {
19 elm_button_label_set(obj, p1->base.label);
20 elm_button_icon_set(obj, p1->icon);
21 return;
22 }
23
24 elm_button_label_set(obj, p2->base.label);
25 elm_button_icon_set(obj, p2->icon);
26}
27
28static void *
29external_button_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
30{
31 Elm_Params_Button *mem;
32 Edje_External_Param *param;
33
34 mem = external_common_params_parse(Elm_Params_Button, data, obj, params);
35 if (!mem)
36 return NULL;
37
38 external_common_icon_param_parse(&mem->icon, obj, params);
39
40 return mem;
41}
42
43static void
44external_button_params_free(void *params)
45{
46 Elm_Params_Button *mem = params;
47
48 if (mem->icon)
49 evas_object_del(mem->icon);
50 external_common_params_free(params);
51}
52
53static Edje_External_Param_Info external_button_params[] = {
54 DEFINE_EXTERNAL_COMMON_PARAMS,
55 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
56 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
57};
58
59DEFINE_EXTERNAL_TYPE_SIMPLE(button, "Button");
diff --git a/src/edje_externals/elm_check.c b/src/edje_externals/elm_check.c
new file mode 100644
index 000000000..6449b3b84
--- /dev/null
+++ b/src/edje_externals/elm_check.c
@@ -0,0 +1,61 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Check
4{
5 Elm_Params base;
6 Evas_Object *icon;
7} Elm_Params_Check;
8
9static void
10external_check_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos)
11{
12 const Elm_Params_Check *p1 = from_params, *p2 = to_params;
13
14 p1 = from_params;
15 p2 = to_params;
16
17 if (!p2)
18 {
19 elm_check_label_set(obj, p1->base.label);
20 elm_check_icon_set(obj, p1->icon);
21 elm_check_state_set(obj, p1->base.state);
22 return;
23 }
24
25 elm_check_label_set(obj, p2->base.label);
26 elm_check_icon_set(obj, p2->icon);
27 elm_check_state_set(obj, p2->base.state);
28}
29
30static void *
31external_check_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
32{
33 Elm_Params_Check *mem;
34 Edje_External_Param *param;
35
36 mem = external_common_params_parse(Elm_Params_Check, data, obj, params);
37 if (!mem)
38 return NULL;
39
40 external_common_icon_param_parse(&mem->icon, obj, params);
41
42 return mem;
43}
44
45static void
46external_check_params_free(void *params)
47{
48 Elm_Params_Check *mem = params;
49
50 if (mem->icon)
51 evas_object_del(mem->icon);
52 external_common_params_free(params);
53}
54
55static Edje_External_Param_Info external_check_params[] = {
56 DEFINE_EXTERNAL_COMMON_PARAMS,
57 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
58 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
59};
60
61DEFINE_EXTERNAL_TYPE_SIMPLE(check, "Check")
diff --git a/src/edje_externals/elm_radio.c b/src/edje_externals/elm_radio.c
new file mode 100644
index 000000000..db954a9d3
--- /dev/null
+++ b/src/edje_externals/elm_radio.c
@@ -0,0 +1,80 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Radio
4{
5 Elm_Params base;
6 Evas_Object *icon;
7 const char* group_name;
8} Elm_Params_Radio;
9
10static void
11external_radio_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos)
12{
13 const Elm_Params_Radio *p1 = from_params, *p2 = to_params;
14
15 p1 = from_params;
16 p2 = to_params;
17
18 if (!p2)
19 {
20 elm_radio_label_set(obj, p1->base.label);
21 elm_radio_icon_set(obj, p1->icon);
22 elm_radio_state_value_set(obj, p1->base.state);
23 if (p1->group_name)
24 {
25 Evas_Object *ed = evas_object_smart_parent_get(obj);
26 Evas_Object *group = edje_object_part_swallow_get(ed, p1->group_name);
27 elm_radio_group_add(obj, group);
28 }
29 return;
30 }
31
32 elm_radio_label_set(obj, p2->base.label);
33 elm_radio_icon_set(obj, p2->icon);
34 elm_radio_state_value_set(obj, p2->base.state);
35 if (p2->group_name)
36 {
37 Evas_Object *ed = evas_object_smart_parent_get(obj);
38 Evas_Object *group = edje_object_part_swallow_get(ed, p2->group_name);
39 elm_radio_group_add(obj, group);
40 }
41}
42
43static void *
44external_radio_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
45{
46 Elm_Params_Radio *mem;
47 Edje_External_Param *param;
48
49 mem = external_common_params_parse(Elm_Params_Radio, data, obj, params);
50 if (!mem)
51 return NULL;
52
53 external_common_icon_param_parse(&mem->icon, obj, params);
54
55 param = edje_external_param_find(params, "param group");
56 if (param)
57 mem->group_name = eina_stringshare_add(param->s);
58
59 return mem;
60}
61
62static void
63external_radio_params_free(void *params)
64{
65 Elm_Params_Radio *mem = params;
66
67 if (mem->icon)
68 evas_object_del(mem->icon);
69 if (mem->group_name)
70 eina_stringshare_del(mem->group_name);
71 external_common_params_free(params);
72}
73
74static Edje_External_Param_Info external_radio_params[] = {
75 DEFINE_EXTERNAL_COMMON_PARAMS,
76 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
77 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
78};
79
80DEFINE_EXTERNAL_TYPE_SIMPLE(radio, "Radio")
diff --git a/src/edje_externals/elm_slider.c b/src/edje_externals/elm_slider.c
new file mode 100644
index 000000000..f3736226a
--- /dev/null
+++ b/src/edje_externals/elm_slider.c
@@ -0,0 +1,111 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Slider
4{
5 Elm_Params base;
6 Evas_Object *icon;
7 const char *indicator, *unit;
8 int inverted, max, min, span, value, horizontal;
9} Elm_Params_Slider;
10
11static void
12external_slider_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos)
13{
14 const Elm_Params_Slider *p1 = from_params, *p2 = to_params;
15
16 p1 = from_params;
17 p2 = to_params;
18
19 if (!p2)
20 {
21 elm_slider_label_set(obj, p1->base.label);
22 elm_slider_icon_set(obj, p1->icon);
23 elm_slider_span_size_set(obj, p1->span);
24 elm_slider_min_max_set(obj, p1->min, p1->max);
25 elm_slider_value_set(obj, p1->value);
26 elm_slider_inverted_set(obj, p1->inverted);;
27 elm_slider_horizontal_set(obj, p1->horizontal);
28 elm_slider_indicator_format_set(obj, p1->indicator);
29 elm_slider_unit_format_set(obj, p1->unit);
30 return;
31 }
32
33 elm_slider_label_set(obj, p2->base.label);
34 elm_slider_icon_set(obj, p2->icon);
35 elm_slider_span_size_set(obj, p2->span);
36 elm_slider_min_max_set(obj, p2->min, p2->max);
37 elm_slider_value_set(obj, p2->value);
38 elm_slider_inverted_set(obj, p2->inverted);
39 elm_slider_horizontal_set(obj, p2->horizontal);
40 elm_slider_indicator_format_set(obj, p2->indicator);
41 elm_slider_unit_format_set(obj, p2->unit);
42}
43
44static void *
45external_slider_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
46{
47 Elm_Params_Slider *mem;
48 Edje_External_Param *param;
49
50 mem = external_common_params_parse(Elm_Params_Slider, data, obj, params);
51 if (!mem)
52 return NULL;
53
54 external_common_icon_param_parse(&mem->icon, obj, params);
55
56 param = edje_external_param_find(params, "span");
57 if (param)
58 mem->span = param->i;
59
60 param = edje_external_param_find(params, "min");
61 if (param)
62 mem->min = param->i;
63
64 param = edje_external_param_find(params, "max");
65 if (param)
66 mem->max = param->i;
67
68 param = edje_external_param_find(params, "value");
69 if (param)
70 mem->value = param->i;
71
72 param = edje_external_param_find(params, "inverted");
73 if (param)
74 mem->inverted = param->i;
75
76 param = edje_external_param_find(params, "horizontal");
77 if (param)
78 mem->horizontal = param->i;
79
80 param = edje_external_param_find(params, "unit");
81 if (param)
82 mem->unit = eina_stringshare_add(param->s);
83
84 param = edje_external_param_find(params, "indicator");
85 if (param)
86 mem->indicator = eina_stringshare_add(param->s);
87
88 return mem;
89}
90
91static void
92external_slider_params_free(void *params)
93{
94 Elm_Params_Slider *mem = params;
95
96 if (mem->icon)
97 evas_object_del(mem->icon);
98 if (mem->unit)
99 eina_stringshare_del(mem->unit);
100 if (mem->indicator)
101 eina_stringshare_del(mem->indicator);
102 external_common_params_free(params);
103}
104
105static Edje_External_Param_Info external_slider_params[] = {
106 DEFINE_EXTERNAL_COMMON_PARAMS,
107 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
108 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
109};
110
111DEFINE_EXTERNAL_TYPE_SIMPLE(slider, "Slider")
diff --git a/src/edje_externals/elm_toggle.c b/src/edje_externals/elm_toggle.c
new file mode 100644
index 000000000..3cc4b71ae
--- /dev/null
+++ b/src/edje_externals/elm_toggle.c
@@ -0,0 +1,77 @@
1#include "private.h"
2#include <string.h>
3
4typedef struct _Elm_Params_Toggle
5{
6 Elm_Params base;
7 Evas_Object *icon;
8 const char *st_label_from, *st_label_to;
9} Elm_Params_Toggle;
10
11static void
12external_toggle_state_set(void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos)
13{
14 const Elm_Params_Toggle *p1 = from_params, *p2 = to_params;
15
16 p1 = from_params;
17 p2 = to_params;
18
19 if (!p2)
20 {
21 elm_toggle_label_set(obj, p1->base.label);
22 elm_toggle_icon_set(obj, p1->icon);
23 elm_toggle_states_labels_set(obj, p1->st_label_from, p1->st_label_to);
24 elm_toggle_state_set(obj, p1->base.state);
25 return;
26 }
27
28 elm_toggle_label_set(obj, p2->base.label);
29 elm_toggle_icon_set(obj, p2->icon);
30 elm_toggle_states_labels_set(obj, p2->st_label_from, p2->st_label_to);
31 elm_toggle_state_set(obj, p2->base.state);
32}
33
34static void *
35external_toggle_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
36{
37 Elm_Params_Toggle *mem;
38 Edje_External_Param *param;
39
40 mem = external_common_params_parse(Elm_Params_Toggle, data, obj, params);
41 if (!mem)
42 return NULL;
43
44 external_common_icon_param_parse(&mem->icon, obj, params);
45
46 param = edje_external_param_find(params, "state label from");
47 if (param)
48 mem->st_label_from = eina_stringshare_add(param->s);
49
50 param = edje_external_param_find(params, "state label to");
51 if (param)
52 mem->st_label_to = eina_stringshare_add(param->s);
53
54 return mem;
55}
56
57static void
58external_toggle_params_free(void *params)
59{
60 Elm_Params_Toggle *mem = params;
61
62 if (mem->icon)
63 evas_object_del(mem->icon);
64 if (mem->st_label_from)
65 eina_stringshare_del(mem->st_label_from);
66 if (mem->st_label_to)
67 eina_stringshare_del(mem->st_label_to);
68 external_common_params_free(params);
69}
70
71static Edje_External_Param_Info external_toggle_params[] = {
72 DEFINE_EXTERNAL_COMMON_PARAMS,
73 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
74 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
75};
76
77DEFINE_EXTERNAL_TYPE_SIMPLE(toggle, "Toggle")
diff --git a/src/edje_externals/modules.inc b/src/edje_externals/modules.inc
new file mode 100644
index 000000000..c8a4f201d
--- /dev/null
+++ b/src/edje_externals/modules.inc
@@ -0,0 +1,5 @@
1DEFINE_TYPE(button)
2DEFINE_TYPE(check)
3DEFINE_TYPE(radio)
4DEFINE_TYPE(slider)
5DEFINE_TYPE(toggle)
diff --git a/src/edje_externals/private.h b/src/edje_externals/private.h
new file mode 100644
index 000000000..0f9fbdba7
--- /dev/null
+++ b/src/edje_externals/private.h
@@ -0,0 +1,76 @@
1#include <Elementary.h>
2
3#ifdef EAPI
4# undef EAPI
5#endif
6
7#define EAPI __attribute__ ((visibility("default")))
8
9/* #ifdef _WIN32 */
10/* # ifdef EFL_EDJE_BUILD */
11/* # ifdef DLL_EXPORT */
12/* # define EAPI __declspec(dllexport) */
13/* # else */
14/* # define EAPI */
15/* # endif /\* ! DLL_EXPORT *\/ */
16/* # else */
17/* # define EAPI __declspec(dllimport) */
18/* # endif /\* ! EFL_EDJE_BUILD *\/ */
19/* #else */
20/* # ifdef __GNUC__ */
21/* # if __GNUC__ >= 4 */
22/* # define EAPI __attribute__ ((visibility("default"))) */
23/* # else */
24/* # define EAPI */
25/* # endif */
26/* # else */
27/* # define EAPI */
28/* # endif */
29/* #endif */
30
31typedef struct {
32 const char *label;
33 int state;
34} Elm_Params;
35
36void external_signal(void *data, Evas_Object *obj, const char *signal, const char *source);
37void external_common_params_free(void *params);
38void *external_common_params_parse_internal(size_t params_size, void *data, Evas_Object *obj, const Eina_List *params);
39void external_commom_icon_param_parse(Evas_Object *icon, Evas_Object *obj, const Eina_List *params);
40#define external_common_params_parse(type, data, obj, params) \
41 external_common_params_parse_internal(sizeof(type), data, obj, params)
42
43
44#define DEFINE_EXTERNAL_TYPE(type_name, name) \
45static const char * \
46external_##type_name##_label_get(void *data) { \
47 return name; \
48} \
49 \
50const Edje_External_Type external_##type_name##_type = {\
51 .abi_version = EDJE_EXTERNAL_TYPE_ABI_VERSION, \
52 .module = name, \
53 .add = external_##type_name##_add, \
54 .signal_emit = external_signal, \
55 .state_set = external_##type_name##_state_set, \
56 .params_parse = external_##type_name##_params_parse,\
57 .params_free = external_##type_name##_params_free, \
58 .icon_add = NULL, \
59 .label_get = external_##type_name##_label_get, \
60 .parameters_info = external_##type_name##_params, \
61 .data = NULL \
62};
63
64#define DEFINE_EXTERNAL_TYPE_SIMPLE(type_name, name) \
65static Evas_Object * \
66external_##type_name##_add(void *data, Evas *evas, Evas_Object *parent, const Eina_List *params) \
67{\
68 return elm_##type_name##_add(parent); \
69}\
70\
71DEFINE_EXTERNAL_TYPE(type_name, name)
72
73
74#define DEFINE_EXTERNAL_COMMON_PARAMS \
75 EDJE_EXTERNAL_PARAM_INFO_STRING("label"), \
76 EDJE_EXTERNAL_PARAM_INFO_INT("state")