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