Merge "[copy&paste] add interface for OSP"
[framework/uifw/elementary.git] / src / lib / elm_clock.c
index 8594134..3bd0b2d 100644 (file)
@@ -1,6 +1,7 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
+#define DEFAULT_FIRST_INTERVAL 0.85
 typedef struct _Widget_Data Widget_Data;
 
 struct _Widget_Data
@@ -10,7 +11,7 @@ struct _Widget_Data
    Eina_Bool seconds : 1;
    Eina_Bool am_pm : 1;
    Eina_Bool edit : 1;
-   Elm_Clock_Digedit digedit;
+   Elm_Clock_Edit_Mode digedit;
    int hrs, min, sec, timediff;
    Evas_Object *digit[6];
    Evas_Object *ampm;
@@ -23,7 +24,7 @@ struct _Widget_Data
       Eina_Bool seconds : 1;
       Eina_Bool am_pm : 1;
       Eina_Bool edit : 1;
-      Elm_Clock_Digedit digedit;
+      Elm_Clock_Edit_Mode digedit;
    } cur;
 };
 
@@ -142,12 +143,9 @@ _timediff_set(Widget_Data *wd)
    gettimeofday(&timev, NULL);
    tt = (time_t)(timev.tv_sec);
    tzset();
-   tm = calloc(1, sizeof(struct tm));
-   if (!tm) return;
-   localtime_r(&tt, tm);
+   tm = localtime(&tt);
    wd->timediff = (((wd->hrs - tm->tm_hour) * 60 +
                     wd->min - tm->tm_min) * 60) + wd->sec - tm->tm_sec;
-   free(tm);
 }
 
 static Eina_Bool
@@ -166,15 +164,14 @@ _ticker(void *data)
      {
         tt = (time_t)(timev.tv_sec) + wd->timediff;
         tzset();
-        tm = calloc(1, sizeof(struct tm));
-        if (!tm) return ECORE_CALLBACK_CANCEL;
-        localtime_r(&tt, tm);
-        wd->hrs = tm->tm_hour;
-        wd->min = tm->tm_min;
-        wd->sec = tm->tm_sec;
-        _time_update(data);
-
-        free(tm);
+        tm = localtime(&tt);
+        if (tm)
+          {
+             wd->hrs = tm->tm_hour;
+             wd->min = tm->tm_min;
+             wd->sec = tm->tm_sec;
+             _time_update(data);
+          }
      }
    return ECORE_CALLBACK_CANCEL;
 }
@@ -545,8 +542,8 @@ elm_clock_add(Evas_Object *parent)
    wd->cur.seconds = EINA_TRUE;
    wd->cur.am_pm = EINA_TRUE;
    wd->cur.edit = EINA_TRUE;
-   wd->cur.digedit = ELM_CLOCK_NONE;
-   wd->first_interval = 0.85;
+   wd->cur.digedit = ELM_CLOCK_EDIT_DEFAULT;
+   wd->first_interval = DEFAULT_FIRST_INTERVAL;
    wd->timediff = 0;
 
    _time_update(obj);
@@ -590,8 +587,8 @@ elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
    wd->edit = edit;
    if (!edit)
      _timediff_set(wd);
-   if ((edit) && (wd->digedit == ELM_CLOCK_NONE))
-     elm_clock_digit_edit_set(obj, ELM_CLOCK_ALL);
+   if ((edit) && (wd->digedit == ELM_CLOCK_EDIT_DEFAULT))
+     elm_clock_edit_mode_set(obj, ELM_CLOCK_EDIT_ALL);
    else
      _time_update(obj);
 }
@@ -606,20 +603,20 @@ elm_clock_edit_get(const Evas_Object *obj)
 }
 
 EAPI void
-elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit)
+elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    wd->digedit = digedit;
-   if (digedit == ELM_CLOCK_NONE)
+   if (digedit == ELM_CLOCK_EDIT_DEFAULT)
      elm_clock_edit_set(obj, EINA_FALSE);
    else
      _time_update(obj);
 }
 
-EAPI Elm_Clock_Digedit
-elm_clock_digit_edit_get(const Evas_Object *obj)
+EAPI Elm_Clock_Edit_Mode
+elm_clock_edit_mode_get(const Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) 0;
    Widget_Data *wd = elm_widget_data_get(obj);
@@ -633,7 +630,7 @@ elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->am_pm = am_pm;
+   wd->am_pm = !!am_pm;
    _time_update(obj);
 }
 
@@ -652,7 +649,7 @@ elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->seconds = seconds;
+   wd->seconds = !!seconds;
    _time_update(obj);
 }
 
@@ -666,16 +663,16 @@ elm_clock_show_seconds_get(const Evas_Object *obj)
 }
 
 EAPI void
-elm_clock_interval_set(Evas_Object *obj, double interval)
+elm_clock_first_interval_set(Evas_Object *obj, double interval)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->first_interval = interval;
+   wd->first_interval = !!interval;
 }
 
 EAPI double
-elm_clock_interval_get(const Evas_Object *obj)
+elm_clock_first_interval_get(const Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
    Widget_Data *wd = elm_widget_data_get(obj);