Merge branch 'master' into svn_merge
[framework/uifw/elementary.git] / src / lib / elm_clock.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Widget_Data Widget_Data;
5
6 struct _Widget_Data
7 {
8    Evas_Object *clk;
9    double interval, first_interval;
10    Eina_Bool seconds : 1;
11    Eina_Bool am_pm : 1;
12    Eina_Bool edit : 1;
13    Elm_Clock_Digedit digedit;
14    int hrs, min, sec, timediff;
15    Evas_Object *digit[6];
16    Evas_Object *ampm;
17    Evas_Object *sel_obj;
18    Ecore_Timer *ticker, *spin;
19    struct
20    {
21       int hrs, min, sec;
22       char ampm;
23       Eina_Bool seconds : 1;
24       Eina_Bool am_pm : 1;
25       Eina_Bool edit : 1;
26       Elm_Clock_Digedit digedit;
27    } cur;
28 };
29
30 static const char *widtype = NULL;
31 static void _del_hook(Evas_Object *obj);
32 static void _theme_hook(Evas_Object *obj);
33 static void _on_focus_hook(void *data, Evas_Object *obj);
34 static Eina_Bool _ticker(void *data);
35 static Eina_Bool _signal_clock_val_up(void *data);
36 static Eina_Bool _signal_clock_val_down(void *data);
37 static void _time_update(Evas_Object *obj);
38
39 static const char SIG_CHANGED[] = "changed";
40
41 static const Evas_Smart_Cb_Description _signals[] = {
42    {SIG_CHANGED, ""},
43    {NULL, NULL}
44 };
45
46
47 static void
48 _del_hook(Evas_Object *obj)
49 {
50    Widget_Data *wd = elm_widget_data_get(obj);
51    if (!wd) return;
52    int i;
53    for (i = 0; i < 6; i++)
54      {
55         if (wd->digit[i]) evas_object_del(wd->digit[i]);
56      }
57    if (wd->ampm) evas_object_del(wd->ampm);
58    if (wd->ticker) ecore_timer_del(wd->ticker);
59    if (wd->spin) ecore_timer_del(wd->spin);
60    free(wd);
61 }
62
63 static void
64 _theme_hook(Evas_Object *obj)
65 {
66    Widget_Data *wd = elm_widget_data_get(obj);
67    if (!wd) return;
68    if (elm_widget_focus_get(obj))
69      edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
70    else
71      edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
72    wd->cur.am_pm = !wd->cur.am_pm; /* hack - force update */
73    _time_update(obj);
74 }
75
76 static void
77 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
78 {
79    Widget_Data *wd = elm_widget_data_get(obj);
80    if (!wd) return;
81    if (elm_widget_focus_get(obj))
82      {
83         edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
84         evas_object_focus_set(wd->clk, EINA_TRUE);
85      }
86    else
87      {
88         edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
89         evas_object_focus_set(wd->clk, EINA_FALSE);
90      }
91 }
92
93 static void
94 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
95 {
96    Widget_Data *wd = elm_widget_data_get(obj);
97    int i;
98    if (!wd) return;
99    edje_object_signal_emit(wd->clk, emission, source);
100    for (i = 0; i < 6; i++)
101      {
102         if (wd->digit[i])
103           edje_object_signal_emit(wd->digit[i], emission, source);
104      }
105 }
106
107 static void
108 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
109 {
110    Widget_Data *wd = elm_widget_data_get(obj);
111    int i;
112    if (!wd) return;
113    edje_object_signal_callback_add(wd->clk, emission, source, func_cb, data);
114    for (i = 0; i < 6; i++)
115      {
116         if (wd->digit[i])
117           edje_object_signal_callback_add(wd->digit[i], emission, source,
118                                           func_cb, data);
119      }
120 }
121
122 static void
123 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
124 {
125    Widget_Data *wd = elm_widget_data_get(obj);
126    int i;
127    for (i = 0; i < 6; i++)
128      {
129         edje_object_signal_callback_del_full(wd->digit[i], emission, source,
130                                              func_cb, data);
131      }
132    edje_object_signal_callback_del_full(wd->clk, emission, source, func_cb,
133                                         data);
134 }
135
136 static void
137 _timediff_set(Widget_Data *wd)
138 {
139    struct timeval timev;
140    struct tm *tm;
141    time_t tt;
142    gettimeofday(&timev, NULL);
143    tt = (time_t)(timev.tv_sec);
144    tzset();
145    tm = localtime(&tt);
146    wd->timediff = (((wd->hrs - tm->tm_hour) * 60 +
147                     wd->min - tm->tm_min) * 60) + wd->sec - tm->tm_sec;
148 }
149
150 static Eina_Bool
151 _ticker(void *data)
152 {
153    Widget_Data *wd = elm_widget_data_get(data);
154    double t;
155    struct timeval timev;
156    struct tm *tm;
157    time_t tt;
158    if (!wd) return ECORE_CALLBACK_CANCEL;
159    gettimeofday(&timev, NULL);
160    t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
161    wd->ticker = ecore_timer_add(t, _ticker, data);
162    if (!wd->edit)
163      {
164         tt = (time_t)(timev.tv_sec) + wd->timediff;
165         tzset();
166         tm = localtime(&tt);
167         if (tm)
168           {
169              wd->hrs = tm->tm_hour;
170              wd->min = tm->tm_min;
171              wd->sec = tm->tm_sec;
172              _time_update(data);
173           }
174      }
175    return ECORE_CALLBACK_CANCEL;
176 }
177
178 static Eina_Bool
179 _signal_clock_val_up(void *data)
180 {
181    Widget_Data *wd = elm_widget_data_get(data);
182    if (!wd) goto clock_val_up_exit_on_error;
183    if (!wd->edit) goto clock_val_up_cancel;
184    if (!wd->sel_obj) goto clock_val_up_cancel;
185    if (wd->sel_obj == wd->digit[0])
186      {
187         wd->hrs = wd->hrs + 10;
188         if (wd->hrs >= 24) wd->hrs -= 24;
189      }
190    if (wd->sel_obj == wd->digit[1])
191      {
192         wd->hrs = wd->hrs + 1;
193         if (wd->hrs >= 24) wd->hrs -= 24;
194      }
195    if (wd->sel_obj == wd->digit[2])
196      {
197         wd->min = wd->min + 10;
198         if (wd->min >= 60) wd->min -= 60;
199      }
200    if (wd->sel_obj == wd->digit[3])
201      {
202         wd->min = wd->min + 1;
203         if (wd->min >= 60) wd->min -= 60;
204      }
205    if (wd->sel_obj == wd->digit[4])
206      {
207         wd->sec = wd->sec + 10;
208         if (wd->sec >= 60) wd->sec -= 60;
209      }
210    if (wd->sel_obj == wd->digit[5])
211      {
212         wd->sec = wd->sec + 1;
213         if (wd->sec >= 60) wd->sec -= 60;
214      }
215    if (wd->sel_obj == wd->ampm)
216      {
217         wd->hrs = wd->hrs + 12;
218         if (wd->hrs > 23) wd->hrs -= 24;
219      }
220    wd->interval = wd->interval / 1.05;
221    ecore_timer_interval_set(wd->spin, wd->interval);
222    _time_update(data);
223    evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
224    return ECORE_CALLBACK_RENEW;
225 clock_val_up_cancel:
226    wd->spin = NULL;
227 clock_val_up_exit_on_error:
228    return ECORE_CALLBACK_CANCEL;
229 }
230
231 static Eina_Bool
232 _signal_clock_val_down(void *data)
233 {
234    Widget_Data *wd = elm_widget_data_get(data);
235    if (!wd) goto clock_val_down_exit_on_error;
236    if (!wd->edit) goto clock_val_down_cancel;
237    if (!wd->sel_obj) goto clock_val_down_cancel;
238    if (wd->sel_obj == wd->digit[0])
239      {
240         wd->hrs = wd->hrs - 10;
241         if (wd->hrs < 0) wd->hrs += 24;
242      }
243    if (wd->sel_obj == wd->digit[1])
244      {
245         wd->hrs = wd->hrs - 1;
246         if (wd->hrs < 0) wd->hrs += 24;
247      }
248    if (wd->sel_obj == wd->digit[2])
249      {
250         wd->min = wd->min - 10;
251         if (wd->min < 0) wd->min += 60;
252      }
253    if (wd->sel_obj == wd->digit[3])
254      {
255         wd->min = wd->min - 1;
256         if (wd->min < 0) wd->min += 60;
257      }
258    if (wd->sel_obj == wd->digit[4])
259      {
260         wd->sec = wd->sec - 10;
261         if (wd->sec < 0) wd->sec += 60;
262      }
263    if (wd->sel_obj == wd->digit[5])
264      {
265         wd->sec = wd->sec - 1;
266         if (wd->sec < 0) wd->sec += 60;
267      }
268    if (wd->sel_obj == wd->ampm)
269      {
270         wd->hrs = wd->hrs - 12;
271         if (wd->hrs < 0) wd->hrs += 24;
272      }
273    wd->interval = wd->interval / 1.05;
274    ecore_timer_interval_set(wd->spin, wd->interval);
275    _time_update(data);
276    evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
277    return ECORE_CALLBACK_RENEW;
278 clock_val_down_cancel:
279    wd->spin = NULL;
280 clock_val_down_exit_on_error:
281    return ECORE_CALLBACK_CANCEL;
282 }
283
284 static void
285 _signal_clock_val_up_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
286 {
287    Widget_Data *wd = elm_widget_data_get(data);
288    if (!wd) return;
289    wd->interval = wd->first_interval;
290    wd->sel_obj = obj;
291    if (wd->spin) ecore_timer_del(wd->spin);
292    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_up, data);
293    _signal_clock_val_up(data);
294 }
295
296 static void
297 _signal_clock_val_down_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
298 {
299    Widget_Data *wd = elm_widget_data_get(data);
300    if (!wd) return;
301    wd->interval = wd->first_interval;
302    wd->sel_obj = obj;
303    if (wd->spin) ecore_timer_del(wd->spin);
304    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_down, data);
305    _signal_clock_val_down(data);
306 }
307
308 static void
309 _signal_clock_val_change_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
310 {
311    Widget_Data *wd = elm_widget_data_get(data);
312    if (!wd) return;
313    if (wd->spin) ecore_timer_del(wd->spin);
314    wd->spin = NULL;
315    wd->sel_obj = NULL;
316 }
317
318 static void
319 _time_update(Evas_Object *obj)
320 {
321    Widget_Data *wd = elm_widget_data_get(obj);
322    Edje_Message_Int msg;
323    int ampm = 0;
324    const char *style = elm_widget_style_get(obj);
325    if (!wd) return;
326    if ((wd->cur.seconds != wd->seconds) || (wd->cur.am_pm != wd->am_pm) ||
327        (wd->cur.edit != wd->edit) || (wd->cur.digedit != wd->digedit))
328      {
329         int i;
330         Evas_Coord mw, mh;
331
332         for (i = 0; i < 6; i++)
333           {
334              if (wd->digit[i])
335                {
336                   evas_object_del(wd->digit[i]);
337                   wd->digit[i] = NULL;
338                }
339           }
340         if (wd->ampm)
341           {
342              evas_object_del(wd->ampm);
343              wd->ampm = NULL;
344           }
345
346         if ((wd->seconds) && (wd->am_pm))
347           _elm_theme_object_set(obj, wd->clk, "clock", "base-all", style);
348         else if (wd->seconds)
349           _elm_theme_object_set(obj, wd->clk, "clock", "base-seconds", style);
350         else if (wd->am_pm)
351           _elm_theme_object_set(obj, wd->clk, "clock", "base-am_pm", style);
352         else
353           _elm_theme_object_set(obj, wd->clk, "clock", "base", style);
354         edje_object_scale_set(wd->clk, elm_widget_scale_get(obj) *
355                               _elm_config->scale);
356
357         for (i = 0; i < 6; i++)
358           {
359              char buf[16];
360
361              if ((!wd->seconds) && (i >= 4)) break;
362              wd->digit[i] = edje_object_add(evas_object_evas_get(wd->clk));
363              _elm_theme_object_set(obj, wd->digit[i], "clock", "flipdigit", style);
364              edje_object_scale_set(wd->digit[i], elm_widget_scale_get(obj) *
365                                    _elm_config->scale);
366              if ((wd->edit) && (wd->digedit & (1 << i)))
367                edje_object_signal_emit(wd->digit[i], "elm,state,edit,on", "elm");
368              edje_object_signal_callback_add(wd->digit[i], "elm,action,up,start",
369                                              "", _signal_clock_val_up_start, obj);
370              edje_object_signal_callback_add(wd->digit[i], "elm,action,up,stop",
371                                              "", _signal_clock_val_change_stop, obj);
372              edje_object_signal_callback_add(wd->digit[i], "elm,action,down,start",
373                                              "", _signal_clock_val_down_start, obj);
374              edje_object_signal_callback_add(wd->digit[i], "elm,action,down,stop",
375                                              "", _signal_clock_val_change_stop, obj);
376              mw = mh = -1;
377              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
378              edje_object_size_min_restricted_calc(wd->digit[i], &mw, &mh, mw, mh);
379              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
380              edje_extern_object_min_size_set(wd->digit[i], mw, mh);
381              snprintf(buf, sizeof(buf), "d%i", i);
382              edje_object_part_swallow(wd->clk , buf, wd->digit[i]);
383              evas_object_show(wd->digit[i]);
384           }
385         if (wd->am_pm)
386           {
387              wd->ampm = edje_object_add(evas_object_evas_get(wd->clk));
388              _elm_theme_object_set(obj, wd->ampm, "clock", "flipampm", style);
389              edje_object_scale_set(wd->ampm, elm_widget_scale_get(obj) *
390                                    _elm_config->scale);
391              if (wd->edit)
392                edje_object_signal_emit(wd->ampm, "elm,state,edit,on", "elm");
393              edje_object_signal_callback_add(wd->ampm, "elm,action,up,start",
394                                              "", _signal_clock_val_up_start, obj);
395              edje_object_signal_callback_add(wd->ampm, "elm,action,up,stop",
396                                              "", _signal_clock_val_change_stop, obj);
397              edje_object_signal_callback_add(wd->ampm, "elm,action,down,start",
398                                              "", _signal_clock_val_down_start, obj);
399              edje_object_signal_callback_add(wd->ampm, "elm,action,down,stop",
400                                              "", _signal_clock_val_change_stop, obj);
401              mw = mh = -1;
402              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
403              edje_object_size_min_restricted_calc(wd->ampm, &mw, &mh, mw, mh);
404              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
405              edje_extern_object_min_size_set(wd->ampm, mw, mh);
406              edje_object_part_swallow(wd->clk , "ampm", wd->ampm);
407              evas_object_show(wd->ampm);
408           }
409
410         edje_object_size_min_calc(wd->clk, &mw, &mh);
411         evas_object_size_hint_min_set(obj, mw, mh);
412
413         wd->cur.hrs = 0;
414         wd->cur.min = 0;
415         wd->cur.sec = 0;
416         wd->cur.ampm = -1;
417         wd->cur.seconds = wd->seconds;
418         wd->cur.am_pm = wd->am_pm;
419         wd->cur.edit = wd->edit;
420         wd->cur.digedit = wd->digedit;
421      }
422    if (wd->hrs != wd->cur.hrs)
423      {
424         int hrs;
425         int d1, d2, dc1, dc2;
426
427         hrs = wd->hrs;
428         if (wd->am_pm)
429           {
430              if (hrs >= 12)
431                {
432                   if (hrs > 12) hrs -= 12;
433                   ampm = 1;
434                }
435              else if (!hrs) hrs = 12;
436           }
437         d1 = hrs / 10;
438         d2 = hrs % 10;
439         dc1 = wd->cur.hrs / 10;
440         dc2 = wd->cur.hrs % 10;
441         if (d1 != dc1)
442           {
443              msg.val = d1;
444              edje_object_message_send(wd->digit[0], EDJE_MESSAGE_INT, 1, &msg);
445           }
446         if (d2 != dc2)
447           {
448              msg.val = d2;
449              edje_object_message_send(wd->digit[1], EDJE_MESSAGE_INT, 1, &msg);
450           }
451         wd->cur.hrs = hrs;
452      }
453    if (wd->min != wd->cur.min)
454      {
455         int d1, d2, dc1, dc2;
456
457         d1 = wd->min / 10;
458         d2 = wd->min % 10;
459         dc1 = wd->cur.min / 10;
460         dc2 = wd->cur.min % 10;
461         if (d1 != dc1)
462           {
463              msg.val = d1;
464              edje_object_message_send(wd->digit[2], EDJE_MESSAGE_INT, 1, &msg);
465           }
466         if (d2 != dc2)
467           {
468              msg.val = d2;
469              edje_object_message_send(wd->digit[3], EDJE_MESSAGE_INT, 1, &msg);
470           }
471         wd->cur.min = wd->min;
472      }
473    if (wd->seconds)
474      {
475         if (wd->sec != wd->cur.sec)
476           {
477              int d1, d2, dc1, dc2;
478
479              d1 = wd->sec / 10;
480              d2 = wd->sec % 10;
481              dc1 = wd->cur.sec / 10;
482              dc2 = wd->cur.sec % 10;
483              if (d1 != dc1)
484                {
485                   msg.val = d1;
486                   edje_object_message_send(wd->digit[4], EDJE_MESSAGE_INT, 1, &msg);
487                }
488              if (d2 != dc2)
489                {
490                   msg.val = d2;
491                   edje_object_message_send(wd->digit[5], EDJE_MESSAGE_INT, 1, &msg);
492                }
493              wd->cur.sec = wd->sec;
494           }
495      }
496    else
497      wd->cur.sec = -1;
498
499    if (wd->am_pm)
500      {
501         if (wd->hrs >= 12) ampm = 1;
502         if (ampm != wd->cur.ampm)
503           {
504              if (wd->cur.ampm != ampm)
505                {
506                   msg.val = ampm;
507                   edje_object_message_send(wd->ampm, EDJE_MESSAGE_INT, 1, &msg);
508                }
509              wd->cur.ampm = ampm;
510           }
511      }
512    else
513      wd->cur.ampm = -1;
514 }
515
516 EAPI Evas_Object *
517 elm_clock_add(Evas_Object *parent)
518 {
519    Evas_Object *obj;
520    Evas *e;
521    Widget_Data *wd;
522
523    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
524
525    ELM_SET_WIDTYPE(widtype, "clock");
526    elm_widget_type_set(obj, "clock");
527    elm_widget_sub_object_add(parent, obj);
528    elm_widget_data_set(obj, wd);
529    elm_widget_del_hook_set(obj, _del_hook);
530    elm_widget_theme_hook_set(obj, _theme_hook);
531    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
532    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
533    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
534    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
535    elm_widget_can_focus_set(obj, EINA_TRUE);
536
537    wd->clk = edje_object_add(e);
538    elm_widget_resize_object_set(obj, wd->clk);
539
540    wd->cur.ampm = -1;
541    wd->cur.seconds = EINA_TRUE;
542    wd->cur.am_pm = EINA_TRUE;
543    wd->cur.edit = EINA_TRUE;
544    wd->cur.digedit = ELM_CLOCK_NONE;
545    wd->first_interval = 0.85;
546    wd->timediff = 0;
547
548    _time_update(obj);
549    _ticker(obj);
550
551    evas_object_smart_callbacks_descriptions_set(obj, _signals);
552
553    return obj;
554 }
555
556 EAPI void
557 elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
558 {
559    ELM_CHECK_WIDTYPE(obj, widtype);
560    Widget_Data *wd = elm_widget_data_get(obj);
561    if (!wd) return;
562    wd->hrs = hrs;
563    wd->min = min;
564    wd->sec = sec;
565    _timediff_set(wd);
566    _time_update(obj);
567 }
568
569 EAPI void
570 elm_clock_time_get(const Evas_Object *obj, int *hrs, int *min, int *sec)
571 {
572    ELM_CHECK_WIDTYPE(obj, widtype);
573    Widget_Data *wd = elm_widget_data_get(obj);
574    if (!wd) return;
575    if (hrs) *hrs = wd->hrs;
576    if (min) *min = wd->min;
577    if (sec) *sec = wd->sec;
578 }
579
580 EAPI void
581 elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
582 {
583    ELM_CHECK_WIDTYPE(obj, widtype);
584    Widget_Data *wd = elm_widget_data_get(obj);
585    if (!wd) return;
586    wd->edit = edit;
587    if (!edit)
588      _timediff_set(wd);
589    if ((edit) && (wd->digedit == ELM_CLOCK_NONE))
590      elm_clock_digit_edit_set(obj, ELM_CLOCK_ALL);
591    else
592      _time_update(obj);
593 }
594
595 EAPI Eina_Bool
596 elm_clock_edit_get(const Evas_Object *obj)
597 {
598    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
599    Widget_Data *wd = elm_widget_data_get(obj);
600    if (!wd) return EINA_FALSE;
601    return wd->edit;
602 }
603
604 EAPI void
605 elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit)
606 {
607    ELM_CHECK_WIDTYPE(obj, widtype);
608    Widget_Data *wd = elm_widget_data_get(obj);
609    if (!wd) return;
610    wd->digedit = digedit;
611    if (digedit == ELM_CLOCK_NONE)
612      elm_clock_edit_set(obj, EINA_FALSE);
613    else
614      _time_update(obj);
615 }
616
617 EAPI Elm_Clock_Digedit
618 elm_clock_digit_edit_get(const Evas_Object *obj)
619 {
620    ELM_CHECK_WIDTYPE(obj, widtype) 0;
621    Widget_Data *wd = elm_widget_data_get(obj);
622    if (!wd) return 0;
623    return wd->digedit;
624 }
625
626 EAPI void
627 elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
628 {
629    ELM_CHECK_WIDTYPE(obj, widtype);
630    Widget_Data *wd = elm_widget_data_get(obj);
631    if (!wd) return;
632    wd->am_pm = am_pm;
633    _time_update(obj);
634 }
635
636 EAPI Eina_Bool
637 elm_clock_show_am_pm_get(const Evas_Object *obj)
638 {
639    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
640    Widget_Data *wd = elm_widget_data_get(obj);
641    if (!wd) return EINA_FALSE;
642    return wd->am_pm;
643 }
644
645 EAPI void
646 elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
647 {
648    ELM_CHECK_WIDTYPE(obj, widtype);
649    Widget_Data *wd = elm_widget_data_get(obj);
650    if (!wd) return;
651    wd->seconds = seconds;
652    _time_update(obj);
653 }
654
655 EAPI Eina_Bool
656 elm_clock_show_seconds_get(const Evas_Object *obj)
657 {
658    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
659    Widget_Data *wd = elm_widget_data_get(obj);
660    if (!wd) return EINA_FALSE;
661    return wd->seconds;
662 }
663
664 EAPI void
665 elm_clock_interval_set(Evas_Object *obj, double interval)
666 {
667    ELM_CHECK_WIDTYPE(obj, widtype);
668    Widget_Data *wd = elm_widget_data_get(obj);
669    if (!wd) return;
670    wd->first_interval = interval;
671 }
672
673 EAPI double
674 elm_clock_interval_get(const Evas_Object *obj)
675 {
676    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
677    Widget_Data *wd = elm_widget_data_get(obj);
678    if (!wd) return 0.0;
679    return wd->first_interval;
680 }