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