aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/edje_externals/elm_button.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/elementary/src/edje_externals/elm_button.c200
1 files changed, 200 insertions, 0 deletions
diff --git a/libraries/elementary/src/edje_externals/elm_button.c b/libraries/elementary/src/edje_externals/elm_button.c
new file mode 100644
index 0000000..9d056df
--- /dev/null
+++ b/libraries/elementary/src/edje_externals/elm_button.c
@@ -0,0 +1,200 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Button
4{
5 Elm_Params base;
6 const char *label;
7 Evas_Object *icon;
8 double autorepeat_initial;
9 double autorepeat_gap;
10 Eina_Bool autorepeat:1;
11 Eina_Bool autorepeat_exists:1;
12 Eina_Bool autorepeat_gap_exists:1;
13 Eina_Bool autorepeat_initial_exists:1;
14} Elm_Params_Button;
15
16static void
17external_button_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
18{
19 const Elm_Params_Button *p;
20
21 if (to_params) p = to_params;
22 else if (from_params) p = from_params;
23 else return;
24
25 if (p->label)
26 elm_object_text_set(obj, p->label);
27 if (p->icon)
28 elm_object_part_content_set(obj, "icon", p->icon);
29 if (p->autorepeat_gap_exists)
30 elm_button_autorepeat_gap_timeout_set(obj, p->autorepeat_gap);
31 if (p->autorepeat_initial_exists)
32 elm_button_autorepeat_initial_timeout_set(obj, p->autorepeat_initial);
33 if (p->autorepeat_exists)
34 elm_button_autorepeat_set(obj, p->autorepeat);
35}
36
37static Eina_Bool
38external_button_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
39{
40 if (!strcmp(param->name, "label"))
41 {
42 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
43 {
44 elm_object_text_set(obj, param->s);
45 return EINA_TRUE;
46 }
47 }
48 else if (!strcmp(param->name, "icon"))
49 {
50 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
51 {
52 Evas_Object *icon = external_common_param_icon_get(obj, param);
53 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
54 elm_object_part_content_set(obj, "icon", icon);
55 return EINA_TRUE;
56 }
57 }
58 else if (!strcmp(param->name, "autorepeat_initial"))
59 {
60 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
61 {
62 elm_button_autorepeat_initial_timeout_set(obj, param->d);
63 return EINA_TRUE;
64 }
65 }
66 else if (!strcmp(param->name, "autorepeat_gap"))
67 {
68 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
69 {
70 elm_button_autorepeat_gap_timeout_set(obj, param->d);
71 return EINA_TRUE;
72 }
73 }
74 else if (!strcmp(param->name, "autorepeat"))
75 {
76 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
77 {
78 elm_button_autorepeat_set(obj, param->i);
79 return EINA_TRUE;
80 }
81 }
82
83 ERR("unknown parameter '%s' of type '%s'",
84 param->name, edje_external_param_type_str(param->type));
85
86 return EINA_FALSE;
87}
88
89static Eina_Bool
90external_button_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
91{
92 if (!strcmp(param->name, "label"))
93 {
94 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
95 {
96 param->s = elm_object_text_get(obj);
97 return EINA_TRUE;
98 }
99 }
100 else if (!strcmp(param->name, "icon"))
101 {
102 /* not easy to get icon name back from live object */
103 return EINA_FALSE;
104 }
105 else if (!strcmp(param->name, "autorepeat_initial"))
106 {
107 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
108 {
109 param->d = elm_button_autorepeat_initial_timeout_get(obj);
110 return EINA_TRUE;
111 }
112 }
113 else if (!strcmp(param->name, "autorepeat_gap"))
114 {
115 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
116 {
117 param->d = elm_button_autorepeat_gap_timeout_get(obj);
118 return EINA_TRUE;
119 }
120 }
121 else if (!strcmp(param->name, "autorepeat"))
122 {
123 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
124 {
125 param->i = elm_button_autorepeat_get(obj);
126 return EINA_TRUE;
127 }
128 }
129
130 ERR("unknown parameter '%s' of type '%s'",
131 param->name, edje_external_param_type_str(param->type));
132
133 return EINA_FALSE;
134}
135
136static void *
137external_button_params_parse(void *data __UNUSED__, Evas_Object *obj, const Eina_List *params)
138{
139 Elm_Params_Button *mem;
140 Edje_External_Param *param;
141 const Eina_List *l;
142
143 mem = ELM_NEW(Elm_Params_Button);
144 if (!mem)
145 return NULL;
146
147 external_common_icon_param_parse(&mem->icon, obj, params);
148
149 EINA_LIST_FOREACH(params, l, param)
150 {
151 if (!strcmp(param->name, "autorepeat_initial"))
152 {
153 mem->autorepeat_initial = param->d;
154 mem->autorepeat_initial_exists = EINA_TRUE;
155 }
156 else if (!strcmp(param->name, "autorepeat_gap"))
157 {
158 mem->autorepeat_gap = param->d;
159 mem->autorepeat_gap_exists = EINA_TRUE;
160 }
161 else if (!strcmp(param->name, "autorepeat"))
162 {
163 mem->autorepeat = !!param->i;
164 mem->autorepeat_exists = EINA_TRUE;
165 }
166 else if (!strcmp(param->name, "label"))
167 mem->label = eina_stringshare_add(param->s);
168 }
169
170 return mem;
171}
172
173static Evas_Object *external_button_content_get(void *data __UNUSED__,
174 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
175{
176 ERR("No content.");
177 return NULL;
178}
179
180static void
181external_button_params_free(void *params)
182{
183 Elm_Params_Button *mem = params;
184 if (mem->label)
185 eina_stringshare_del(mem->label);
186 free(params);
187}
188
189static Edje_External_Param_Info external_button_params[] = {
190 DEFINE_EXTERNAL_COMMON_PARAMS,
191 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
192 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
193 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("autorepeat_initial"),
194 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("autorepeat_gap"),
195 EDJE_EXTERNAL_PARAM_INFO_BOOL("autorepeat"),
196 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
197};
198
199DEFINE_EXTERNAL_ICON_ADD(button, "button");
200DEFINE_EXTERNAL_TYPE_SIMPLE(button, "Button");