#include <Elementary.h>
#include "elm_priv.h"
+#define DEFAULT_FIRST_INTERVAL 0.85
typedef struct _Widget_Data Widget_Data;
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;
Eina_Bool seconds : 1;
Eina_Bool am_pm : 1;
Eina_Bool edit : 1;
- Elm_Clock_Digedit digedit;
+ Elm_Clock_Edit_Mode digedit;
} cur;
};
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
{
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;
}
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);
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);
}
}
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);
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);
}
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);
}
}
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);