summaryrefslogtreecommitdiff
path: root/src/edje_external/elementary/elm_radio.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/edje_external/elementary/elm_radio.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/edje_external/elementary/elm_radio.c')
-rw-r--r--src/edje_external/elementary/elm_radio.c181
1 files changed, 181 insertions, 0 deletions
diff --git a/src/edje_external/elementary/elm_radio.c b/src/edje_external/elementary/elm_radio.c
new file mode 100644
index 0000000..576e67f
--- /dev/null
+++ b/src/edje_external/elementary/elm_radio.c
@@ -0,0 +1,181 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Radio
4{
5 Elm_Params base;
6 const char *label;
7 Evas_Object *icon;
8 const char* group_name;
9 int value;
10 Eina_Bool value_exists:1;
11} Elm_Params_Radio;
12
13static void
14external_radio_state_set(void *data EINA_UNUSED, Evas_Object *obj,
15 const void *from_params, const void *to_params,
16 float pos EINA_UNUSED)
17{
18 const Elm_Params_Radio *p;
19
20 if (to_params) p = to_params;
21 else if (from_params) p = from_params;
22 else return;
23
24 if (p->label)
25 elm_object_text_set(obj, p->label);
26 if (p->icon)
27 elm_object_part_content_set(obj, "icon", p->icon);
28 if (p->value_exists)
29 elm_radio_state_value_set(obj, p->value);
30 if (p->group_name)
31 {
32 Evas_Object *ed = evas_object_smart_parent_get(obj);
33 Evas_Object *group = edje_object_part_swallow_get(ed, p->group_name);
34 elm_radio_group_add(obj, group);
35 }
36}
37
38static Eina_Bool
39external_radio_param_set(void *data EINA_UNUSED, Evas_Object *obj,
40 const Edje_External_Param *param)
41{
42 if (!strcmp(param->name, "label"))
43 {
44 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
45 {
46 elm_object_text_set(obj, param->s);
47 return EINA_TRUE;
48 }
49 }
50 else if (!strcmp(param->name, "icon"))
51 {
52 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
53 {
54 Evas_Object *icon = external_common_param_icon_get(obj, param);
55 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
56 elm_object_part_content_set(obj, "icon", icon);
57 return EINA_TRUE;
58 }
59 }
60 else if (!strcmp(param->name, "value"))
61 {
62 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
63 {
64 elm_radio_value_set(obj, param->i);
65 return EINA_TRUE;
66 }
67 }
68 else if (!strcmp(param->name, "group"))
69 {
70 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
71 {
72 Evas_Object *ed = evas_object_smart_parent_get(obj);
73 Evas_Object *group = edje_object_part_swallow_get(ed, param->s);
74 elm_radio_group_add(obj, group);
75 return EINA_TRUE;
76 }
77 }
78
79 ERR("unknown parameter '%s' of type '%s'",
80 param->name, edje_external_param_type_str(param->type));
81
82 return EINA_FALSE;
83}
84
85static Eina_Bool
86external_radio_param_get(void *data EINA_UNUSED, const Evas_Object *obj,
87 Edje_External_Param *param)
88{
89 if (!strcmp(param->name, "label"))
90 {
91 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
92 {
93 param->s = elm_object_text_get(obj);
94 return EINA_TRUE;
95 }
96 }
97 else if (!strcmp(param->name, "icon"))
98 {
99 /* not easy to get icon name back from live object */
100 return EINA_FALSE;
101 }
102 else if (!strcmp(param->name, "value"))
103 {
104 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
105 {
106 param->i = elm_radio_value_get(obj);
107 return EINA_TRUE;
108 }
109 }
110 else if (!strcmp(param->name, "group"))
111 {
112 /* not easy to get group name back from live object */
113 return EINA_FALSE;
114 }
115
116 ERR("unknown parameter '%s' of type '%s'",
117 param->name, edje_external_param_type_str(param->type));
118
119 return EINA_FALSE;
120}
121
122static void *
123external_radio_params_parse(void *data EINA_UNUSED, Evas_Object *obj, const Eina_List *params)
124{
125 Elm_Params_Radio *mem;
126 Edje_External_Param *param;
127 const Eina_List *l;
128
129 mem = calloc(1, sizeof(Elm_Params_Radio));
130 if (!mem)
131 return NULL;
132
133 external_common_icon_param_parse(&mem->icon, obj, params);
134
135 EINA_LIST_FOREACH(params, l, param)
136 {
137 if (!strcmp(param->name, "group"))
138 mem->group_name = eina_stringshare_add(param->s);
139 else if (!strcmp(param->name, "value"))
140 {
141 mem->value = param->i;
142 mem->value_exists = EINA_TRUE;
143 }
144 else if (!strcmp(param->name, "label"))
145 mem->label = eina_stringshare_add(param->s);
146 }
147
148 return mem;
149}
150
151static Evas_Object *external_radio_content_get(void *data EINA_UNUSED,
152 const Evas_Object *obj EINA_UNUSED,
153 const char *content EINA_UNUSED)
154{
155 ERR("No content.");
156 return NULL;
157}
158
159static void
160external_radio_params_free(void *params)
161{
162 Elm_Params_Radio *mem = params;
163
164 if (mem->group_name)
165 eina_stringshare_del(mem->group_name);
166 if (mem->label)
167 eina_stringshare_del(mem->label);
168 free(params);
169}
170
171static Edje_External_Param_Info external_radio_params[] = {
172 DEFINE_EXTERNAL_COMMON_PARAMS,
173 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
174 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
175 EDJE_EXTERNAL_PARAM_INFO_STRING("group"),
176 EDJE_EXTERNAL_PARAM_INFO_INT("value"),
177 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
178};
179
180DEFINE_EXTERNAL_ICON_ADD(radio, "radio");
181DEFINE_EXTERNAL_TYPE_SIMPLE(radio, "Radio");