395159f627b466587f8aab3d6bd40ae706e98dae
[framework/uifw/elementary.git] / src / lib / elm_button.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Widget_Data Widget_Data;
5
6 enum
7 {
8    DEFAULT = 0,
9    HIGHLIGHTED,
10    FOCUSED,
11    DISABLED,
12 };
13
14 struct _Widget_Data
15 {
16    Evas_Object *btn, *icon;
17    const char *label;
18    double ar_threshold;
19    double ar_interval;
20    Ecore_Timer *timer;
21    const char *statelabel[4];
22    int statetype[4];
23    Eina_Bool autorepeat : 1;
24    Eina_Bool repeating : 1;
25    Eina_Bool delete_me : 1;
26 };
27
28 static const char *widtype = NULL;
29 static void _del_hook(Evas_Object *obj);
30 static void _del_pre_hook(Evas_Object *obj);
31 static void _theme_hook(Evas_Object *obj);
32 static void _disable_hook(Evas_Object *obj);
33 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
34 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
35 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
36 static void _sizing_eval(Evas_Object *obj);
37 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
38 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
39 static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
40 static void _signal_pressed(void *data, Evas_Object *obj, const char *emission, const char *source);
41 static void _signal_unpressed(void *data, Evas_Object *obj, const char *emission, const char *source);
42 static void _on_focus_hook(void *data, Evas_Object *obj);
43 static void _activate(Evas_Object *obj);
44 static void _activate_hook(Evas_Object *obj);
45 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
46                              Evas_Callback_Type type, void *event_info);
47
48 static void _set_label(Evas_Object *obj, const char *label);
49 static void _signal_default_text_set(void *data, Evas_Object *obj, const char *emission, const char *source);
50
51 static const char SIG_CLICKED[] = "clicked";
52 static const char SIG_REPEATED[] = "repeated";
53 static const char SIG_PRESSED[] = "pressed";
54 static const char SIG_UNPRESSED[] = "unpressed";
55 static const Evas_Smart_Cb_Description _signals[] = {
56        {SIG_CLICKED, ""},
57        {SIG_REPEATED, ""},
58        {SIG_PRESSED, ""},
59        {SIG_UNPRESSED, ""},
60        {NULL, NULL}
61 };
62
63 static Eina_Bool
64 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
65 {
66    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
67    Evas_Event_Key_Down *ev = event_info;
68    Widget_Data *wd = elm_widget_data_get(obj);
69    if (!wd) return EINA_FALSE;
70    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
71    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
72    if ((strcmp(ev->keyname, "Return")) &&
73        (strcmp(ev->keyname, "KP_Enter")) &&
74        (strcmp(ev->keyname, "space")))
75      return EINA_FALSE;
76    _activate(obj);
77    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
78    edje_object_signal_emit(wd->btn, "elm,anim,activate", "elm");
79    return EINA_TRUE;
80 }
81
82 static void
83 _del_pre_hook(Evas_Object *obj)
84 {
85    Widget_Data *wd = elm_widget_data_get(obj);
86    if (!wd) return;
87    wd->delete_me = EINA_TRUE;
88 }
89
90 static void
91 _del_hook(Evas_Object *obj)
92 {
93    Widget_Data *wd = elm_widget_data_get(obj);
94    if (!wd) return;
95    if (wd->label) eina_stringshare_del(wd->label);
96    if (wd->statelabel[DEFAULT]) eina_stringshare_del(wd->statelabel[DEFAULT]);
97    if (wd->statelabel[HIGHLIGHTED]) eina_stringshare_del(wd->statelabel[HIGHLIGHTED]);
98    if (wd->statelabel[FOCUSED]) eina_stringshare_del(wd->statelabel[FOCUSED]);
99    if (wd->statelabel[DISABLED]) eina_stringshare_del(wd->statelabel[DISABLED]);
100    free(wd);
101 }
102
103 static void
104 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
105 {
106    Widget_Data *wd = elm_widget_data_get(obj);
107    if (!wd) return;
108    if (elm_widget_focus_get(obj))
109      {
110         if (wd->statelabel[FOCUSED])
111           {
112              _set_label(obj, wd->statelabel[FOCUSED]);
113           }
114         edje_object_signal_emit(wd->btn, "elm,action,focus", "elm");
115         evas_object_focus_set(wd->btn, EINA_TRUE);
116      }
117    else
118      {
119         if (wd->statelabel[DEFAULT])
120           _set_label(obj, wd->statelabel[DEFAULT]);
121         edje_object_signal_emit(wd->btn, "elm,action,unfocus", "elm");
122         evas_object_focus_set(wd->btn, EINA_FALSE);
123      }
124 }
125
126 static void
127 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
128 {
129    Widget_Data *wd = elm_widget_data_get(obj);
130    if (!wd) return;
131    edje_object_mirrored_set(wd->btn, rtl);
132 }
133
134 static void
135 _theme_hook(Evas_Object *obj)
136 {
137    Widget_Data *wd = elm_widget_data_get(obj);
138    const char *str;
139    if (!wd) return;
140    _elm_widget_mirrored_reload(obj);
141    _mirrored_set(obj, elm_widget_mirrored_get(obj));
142    _elm_theme_object_set(obj, wd->btn, "button", "base", elm_widget_style_get(obj));
143    if (elm_object_disabled_get(obj))
144      edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
145    if (wd->icon)
146      edje_object_part_swallow(wd->btn, "elm.swallow.content", wd->icon);
147    if (wd->label)
148      edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
149    else
150      edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
151    if (wd->icon)
152      edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
153    else
154      edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
155    edje_object_part_text_set(wd->btn, "elm.text", wd->label);
156    edje_object_message_signal_process(wd->btn);
157    edje_object_scale_set(wd->btn, elm_widget_scale_get(obj) * _elm_config->scale);
158    str = edje_object_data_get(wd->btn, "focus_highlight");
159    if ((str) && (!strcmp(str, "on")))
160      elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
161    else
162      elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
163    _sizing_eval(obj);
164 }
165
166 static void
167 _disable_hook(Evas_Object *obj)
168 {
169    Widget_Data *wd = elm_widget_data_get(obj);
170    if (!wd) return;
171    if (elm_widget_disabled_get(obj))
172      {
173         if (wd->statelabel[DISABLED] )
174           {
175              _set_label(obj, wd->statelabel[DISABLED]);
176           }
177         edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
178      }
179    else
180      {
181         if (wd->statelabel[DEFAULT])
182           _set_label(obj, wd->statelabel[DEFAULT]);
183         edje_object_signal_emit(wd->btn, "elm,state,enabled", "elm");
184      }
185 }
186
187 static void
188 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
189 {
190    Widget_Data *wd = elm_widget_data_get(obj);
191    if (!wd) return;
192    edje_object_signal_emit(wd->btn, emission, source);
193 }
194
195 static void
196 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
197 {
198    Widget_Data *wd = elm_widget_data_get(obj);
199    if (!wd) return;
200    edje_object_signal_callback_add(wd->btn, emission, source, func_cb, data);
201 }
202
203 static void
204 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
205 {
206    Widget_Data *wd = elm_widget_data_get(obj);
207    edje_object_signal_callback_del_full(wd->btn, emission, source, func_cb,
208                                         data);
209 }
210
211 static void
212 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
213 {
214    ELM_CHECK_WIDTYPE(obj, widtype);
215    Widget_Data *wd = elm_widget_data_get(obj);
216    if (!wd) return;
217    if (part && strcmp(part, "icon")) return;
218    if (wd->icon == content) return;
219    if (wd->icon) evas_object_del(wd->icon);
220    wd->icon = content;
221    if (content)
222      {
223         elm_widget_sub_object_add(obj, content);
224         evas_object_event_callback_add(content,
225                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
226                                        _changed_size_hints, obj);
227         edje_object_part_swallow(wd->btn, "elm.swallow.content", content);
228         edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
229         edje_object_message_signal_process(wd->btn);
230      }
231    _sizing_eval(obj);
232 }
233
234 static Evas_Object *
235 _content_get_hook(const Evas_Object *obj, const char *part)
236 {
237    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
238    Widget_Data *wd;
239
240    if (part && strcmp(part, "icon")) return NULL;
241    wd = elm_widget_data_get(obj);
242    if (!wd) return NULL;
243    return wd->icon;
244 }
245
246 static Evas_Object *
247 _content_unset_hook(Evas_Object *obj, const char *part)
248 {
249    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
250    Widget_Data *wd;
251
252    if (part && strcmp(part, "icon")) return NULL;
253    wd = elm_widget_data_get(obj);
254    if (!wd) return NULL;
255    if (!wd->icon) return NULL;
256    Evas_Object *icon = wd->icon;
257    elm_widget_sub_object_del(obj, wd->icon);
258    evas_object_event_callback_del_full(wd->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
259                                        _changed_size_hints, obj);
260    edje_object_part_unswallow(wd->btn, wd->icon);
261    wd->icon = NULL;
262    return icon;
263 }
264
265 static void
266 _sizing_eval(Evas_Object *obj)
267 {
268    Widget_Data *wd = elm_widget_data_get(obj);
269    Evas_Coord minw = -1, minh = -1;
270
271    if (!wd) return;
272    if (wd->delete_me) return;
273    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
274    edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
275    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
276    evas_object_size_hint_min_set(obj, minw, minh);
277 }
278
279 static void
280 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
281 {
282    Widget_Data *wd = elm_widget_data_get(data);
283    if (!wd) return;
284    if (obj != wd->icon) return;
285    _sizing_eval(data);
286 }
287
288 static void
289 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
290 {
291    Widget_Data *wd = elm_widget_data_get(obj);
292    Evas_Object *sub = event_info;
293    if (!wd) return;
294    if (sub == wd->icon)
295      {
296         edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
297         evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
298                                             _changed_size_hints, obj);
299         wd->icon = NULL;
300         edje_object_message_signal_process(wd->btn);
301         _sizing_eval(obj);
302      }
303 }
304
305 static void
306 _activate(Evas_Object *obj)
307 {
308    Widget_Data *wd = elm_widget_data_get(obj);
309    if (!wd) return;
310    if (wd->timer)
311      {
312         ecore_timer_del(wd->timer);
313         wd->timer = NULL;
314      }
315    wd->repeating = EINA_FALSE;
316    if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
317        (_elm_access_2nd_click_timeout(obj)))
318      {
319         if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
320            _elm_access_say(E_("Clicked"));
321         evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
322      }
323 }
324
325 static void
326 _activate_hook(Evas_Object *obj)
327 {
328    _activate(obj);
329 }
330
331 static void
332 _signal_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
333 {
334    _activate(data);
335 }
336
337 static Eina_Bool
338 _autorepeat_send(void *data)
339 {
340    Widget_Data *wd = elm_widget_data_get(data);
341    if (!wd) return ECORE_CALLBACK_CANCEL;
342
343    evas_object_smart_callback_call(data, SIG_REPEATED, NULL);
344    if (!wd->repeating)
345      {
346         wd->timer = NULL;
347         return ECORE_CALLBACK_CANCEL;
348      }
349
350    return ECORE_CALLBACK_RENEW;
351 }
352
353 static Eina_Bool
354 _autorepeat_initial_send(void *data)
355 {
356    Widget_Data *wd = elm_widget_data_get(data);
357    if (!wd) return ECORE_CALLBACK_CANCEL;
358
359    if (wd->timer) ecore_timer_del(wd->timer);
360    wd->repeating = EINA_TRUE;
361    _autorepeat_send(data);
362    wd->timer = ecore_timer_add(wd->ar_interval, _autorepeat_send, data);
363
364    return ECORE_CALLBACK_CANCEL;
365 }
366
367 static void
368 _signal_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
369 {
370    Widget_Data *wd = elm_widget_data_get(data);
371    if (!wd) return;
372
373    if (wd->statelabel[HIGHLIGHTED])
374      {
375         _set_label(data, wd->statelabel[HIGHLIGHTED]);
376      }
377    if ((wd->autorepeat) && (!wd->repeating))
378      {
379         if (wd->ar_threshold <= 0.0)
380           _autorepeat_initial_send(data); /* call immediately */
381         else
382           wd->timer = ecore_timer_add(wd->ar_threshold, _autorepeat_initial_send, data);
383      }
384
385    evas_object_smart_callback_call(data, SIG_PRESSED, NULL);
386 }
387
388 static void
389 _signal_unpressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
390 {
391    Widget_Data *wd = elm_widget_data_get(data);
392    if (!wd) return;
393    if (wd->statelabel[DEFAULT])
394      _set_label(data, wd->statelabel[DEFAULT]);
395
396    if (wd->timer)
397      {
398         ecore_timer_del(wd->timer);
399         wd->timer = NULL;
400      }
401    wd->repeating = EINA_FALSE;
402    evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
403 }
404
405 static void
406 _signal_default_text_set(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
407 {
408    Widget_Data *wd = elm_widget_data_get(data);
409    if (!wd) return;
410    if (wd->statelabel[DEFAULT])
411      _set_label(data, wd->statelabel[DEFAULT]);
412 }
413
414 static void
415 _elm_button_label_set(Evas_Object *obj, const char *item, const char *label)
416 {
417    ELM_CHECK_WIDTYPE(obj, widtype);
418    Widget_Data *wd = elm_widget_data_get(obj);
419    if (item && strcmp(item, "default")) return;
420    if (!wd) return;
421    eina_stringshare_replace(&wd->label, label);
422    if (label)
423      edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
424    else
425      edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
426    edje_object_message_signal_process(wd->btn);
427    edje_object_part_text_set(wd->btn, "elm.text", label);
428    _sizing_eval(obj);
429 }
430
431 static const char *
432 _elm_button_label_get(const Evas_Object *obj, const char *item)
433 {
434    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
435    Widget_Data *wd = elm_widget_data_get(obj);
436    if (item && strcmp(item, "default")) return NULL;
437    if (!wd) return NULL;
438    return wd->label;
439 }
440
441 static char *
442 _access_info_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Widget_Item *item __UNUSED__)
443 {
444    const char *txt = elm_widget_access_info_get(obj);
445    if (!txt) txt = _elm_button_label_get(obj, NULL);
446    if (txt) return strdup(txt);
447    return NULL;
448 }
449
450 static char *
451 _access_state_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Widget_Item *item __UNUSED__)
452 {
453    if (elm_widget_disabled_get(obj))
454      return strdup(E_("State: Disabled"));
455    return NULL;
456 }
457
458 EAPI Evas_Object *
459 elm_button_add(Evas_Object *parent)
460 {
461    Evas_Object *obj;
462    Evas *e;
463    Widget_Data *wd;
464
465    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
466
467    ELM_SET_WIDTYPE(widtype, "button");
468    elm_widget_type_set(obj, "button");
469    elm_widget_sub_object_add(parent, obj);
470    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
471    elm_widget_data_set(obj, wd);
472    elm_widget_del_hook_set(obj, _del_hook);
473    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
474    elm_widget_theme_hook_set(obj, _theme_hook);
475    elm_widget_disable_hook_set(obj, _disable_hook);
476    elm_widget_can_focus_set(obj, EINA_TRUE);
477    elm_widget_activate_hook_set(obj, _activate_hook);
478    elm_widget_event_hook_set(obj, _event_hook);
479    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
480    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
481    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
482    elm_widget_text_set_hook_set(obj, _elm_button_label_set);
483    elm_widget_text_get_hook_set(obj, _elm_button_label_get);
484    elm_widget_content_set_hook_set(obj, _content_set_hook);
485    elm_widget_content_get_hook_set(obj, _content_get_hook);
486    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
487
488    wd->btn = edje_object_add(e);
489    _elm_theme_object_set(obj, wd->btn, "button", "base", "default");
490    wd->statetype[DEFAULT] = 0;
491    wd->statetype[HIGHLIGHTED] = 0;
492    wd->statetype[FOCUSED] = 0;
493    wd->statetype[DISABLED] = 0;
494    wd->statelabel[DEFAULT] = 0;
495    wd->statelabel[HIGHLIGHTED] = 0;
496    wd->statelabel[FOCUSED] = 0;
497    wd->statelabel[DISABLED] = 0;
498    edje_object_signal_callback_add(wd->btn, "elm,action,click", "",
499                                    _signal_clicked, obj);
500    edje_object_signal_callback_add(wd->btn, "elm,action,press", "",
501                                    _signal_pressed, obj);
502    edje_object_signal_callback_add(wd->btn, "elm,action,unpress", "",
503                                    _signal_unpressed, obj);
504    edje_object_signal_callback_add(wd->btn, "elm,action,default,text,set", "",
505                                    _signal_default_text_set, obj);
506    elm_widget_resize_object_set(obj, wd->btn);
507
508    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
509
510    _theme_hook(obj);
511
512    // TODO: convert Elementary to subclassing of Evas_Smart_Class
513    // TODO: and save some bytes, making descriptions per-class and not instance!
514    evas_object_smart_callbacks_descriptions_set(obj, _signals);
515
516    _elm_access_object_register(obj, wd->btn);
517    _elm_access_text_set(_elm_access_object_get(obj),
518                         ELM_ACCESS_TYPE, E_("Button"));
519    _elm_access_callback_set(_elm_access_object_get(obj),
520                             ELM_ACCESS_INFO, _access_info_cb, obj);
521    _elm_access_callback_set(_elm_access_object_get(obj),
522                             ELM_ACCESS_STATE, _access_state_cb, obj);
523    return obj;
524 }
525
526 static void
527 _set_label(Evas_Object *obj, const char *label)
528 {
529    Widget_Data *wd = elm_widget_data_get(obj);
530
531    edje_object_part_text_set(wd->btn, "elm.text", label);
532    _sizing_eval(obj);
533 }
534
535 EAPI void
536 elm_button_label_set_for_state(Evas_Object *obj, const char *label, UIControlState state)
537 {
538    Widget_Data *wd = elm_widget_data_get(obj);
539
540    if (!wd) return;
541    if (label == NULL) return;
542
543    if (state == UIControlStateDefault)
544      {
545         wd->statetype[DEFAULT] = UIControlStateDefault;
546         eina_stringshare_replace(&wd->statelabel[DEFAULT], label);
547         return;
548      }
549    if (state == UIControlStateHighlighted)
550      {
551         wd->statetype[HIGHLIGHTED] = UIControlStateHighlighted;
552         eina_stringshare_replace(&wd->statelabel[HIGHLIGHTED], label);
553         return;
554      }
555    if (state == UIControlStateFocused)
556      {
557         wd->statetype[FOCUSED] = UIControlStateFocused;
558         eina_stringshare_replace(&wd->statelabel[FOCUSED], label);
559         return;
560      }
561    if (state == UIControlStateDisabled)
562      {
563         wd->statetype[DISABLED] = UIControlStateDisabled;
564         eina_stringshare_replace(&wd->statelabel[DISABLED], label);
565         return;
566      }
567 }
568
569 EAPI const char*
570 elm_button_label_get_for_state(const Evas_Object *obj, UIControlState state)
571 {
572    Widget_Data *wd = elm_widget_data_get(obj);
573    if (!wd) return NULL;
574
575    if (state == UIControlStateDefault)
576      return wd->statelabel[DEFAULT];
577    else if (state == UIControlStateHighlighted)
578      return wd->statelabel[HIGHLIGHTED];
579    else if (state == UIControlStateFocused)
580      return wd->statelabel[FOCUSED];
581    else if (state == UIControlStateDisabled)
582      return wd->statelabel[DISABLED];
583    else
584      return NULL;
585 }
586
587 EAPI void
588 elm_button_label_set(Evas_Object *obj, const char *label)
589 {
590    _elm_button_label_set(obj, NULL, label);
591 }
592
593 EAPI const char *
594 elm_button_label_get(const Evas_Object *obj)
595 {
596    return _elm_button_label_get(obj, NULL);
597 }
598
599
600 EAPI void
601 elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
602 {
603    _content_set_hook(obj, "icon", icon);
604 }
605
606 EAPI Evas_Object *
607 elm_button_icon_get(const Evas_Object *obj)
608 {
609    return _content_get_hook(obj, "icon");
610 }
611
612 EAPI Evas_Object *
613 elm_button_icon_unset(Evas_Object *obj)
614 {
615    return _content_unset_hook(obj, "icon");
616 }
617
618 EAPI void
619 elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
620 {
621    ELM_CHECK_WIDTYPE(obj, widtype);
622    Widget_Data *wd = elm_widget_data_get(obj);
623    if (!wd) return;
624    if (wd->timer)
625      {
626         ecore_timer_del(wd->timer);
627         wd->timer = NULL;
628      }
629    wd->autorepeat = on;
630    wd->repeating = EINA_FALSE;
631 }
632
633 EAPI Eina_Bool
634 elm_button_autorepeat_get(const Evas_Object *obj)
635 {
636    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
637    Widget_Data *wd = elm_widget_data_get(obj);
638    if (!wd) return EINA_FALSE;
639    return wd->autorepeat;
640 }
641
642 EAPI void
643 elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
644 {
645    ELM_CHECK_WIDTYPE(obj, widtype);
646    Widget_Data *wd = elm_widget_data_get(obj);
647    if (!wd) return;
648    if (wd->ar_threshold == t) return;
649    if (wd->timer)
650      {
651         ecore_timer_del(wd->timer);
652         wd->timer = NULL;
653      }
654    wd->ar_threshold = t;
655 }
656
657 EAPI double
658 elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
659 {
660    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
661    Widget_Data *wd = elm_widget_data_get(obj);
662    if (!wd) return 0.0;
663    return wd->ar_threshold;
664 }
665
666 EAPI void
667 elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
668 {
669    ELM_CHECK_WIDTYPE(obj, widtype);
670    Widget_Data *wd = elm_widget_data_get(obj);
671    if (!wd) return;
672    if (wd->ar_interval == t) return;
673
674    wd->ar_interval = t;
675    if ((wd->repeating) && (wd->timer)) ecore_timer_interval_set(wd->timer, t);
676 }
677
678 EAPI double
679 elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
680 {
681    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
682    Widget_Data *wd = elm_widget_data_get(obj);
683    if (!wd) return 0.0;
684    return wd->ar_interval;
685 }