Hi, everybody. We are near to release elementary. But I want to push one
patch in
more, who add 2 API. The first one is to set the first day of week in
elm_calendar
widget and second one to get the info. Please review it, but don't commit
it.
I will push it, if you agreed.

-- 
Michaël Bouchaud
Index: src/lib/elm_calendar.c
===================================================================
--- src/lib/elm_calendar.c      (révision 69630)
+++ src/lib/elm_calendar.c      (copie de travail)
@@ -24,7 +24,7 @@
    Eina_List *marks;
    double interval, first_interval;
    int year_min, year_max, spin_speed;
-   int today_it, selected_it, first_day_it;
+   int today_it, selected_it, first_day_it, first_week_day;
    Ecore_Timer *spin, *update_timer;
    Elm_Calendar_Format_Cb format_func;
    const char *weekdays[7];
@@ -173,6 +173,35 @@
    return (day + first_week_day - 1) % 7;
 }
 
+static void
+_fill_weekdays(Evas_Object *obj)
+{
+   time_t weekday = 259200;
+   int i;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   weekday += (86400 * wd->first_week_day);
+   for (i = 0; i < 7; i++)
+     {
+        /* FIXME: I'm not aware of a known max, so if it fails,
+         * just make it larger. :| */
+        char buf[20];
+        /* I don't know of a better way of doing it */
+        if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
+          {
+             wd->weekdays[i] = eina_stringshare_add(buf);
+          }
+        else
+          {
+             /* If we failed getting day, get a default value */
+             wd->weekdays[i] = _days_abbrev[i];
+             WRN("Failed getting weekday name for '%s' from locale.",
+                 _days_abbrev[i]);
+          }
+        weekday += 86400; /* Advance by a day */
+     }
+}
+
 // EINA_DEPRECATED
 static void
 _text_day_color_update(Widget_Data *wd, int pos)
@@ -241,7 +270,10 @@
    mktime(&first_day);
 
    // Layout of the calendar is changed for removing the unfilled last row.
-   wd->first_day_it = first_day.tm_wday;
+   if (first_day.tm_wday < wd->first_week_day)
+     wd->first_day_it = first_day.tm_wday + 7 - wd->first_week_day;
+   else
+     wd->first_day_it = first_day.tm_wday - wd->first_week_day;
 
    if ((35 - wd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
 
@@ -286,7 +318,7 @@
    for (i = 0; i < 42; i++)
      {
         _text_day_color_update(wd, i); // EINA_DEPRECATED
-        if ((!day) && (i == first_day.tm_wday)) day = 1;
+        if ((!day) && (i == wd->first_day_it)) day = 1;
 
         if ((day == wd->current_time.tm_mday)
             && (mon == wd->current_time.tm_mon)
@@ -706,7 +738,7 @@
    time_t weekday = 259200; /* Just the first sunday since epoch */
    Evas_Object *obj;
    Widget_Data *wd;
-   int i, t;
+   int t;
    Evas *e;
 
    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
@@ -749,25 +781,7 @@
 
    evas_object_smart_callbacks_descriptions_set(obj, _signals);
 
-   for (i = 0; i < 7; i++)
-     {
-        /* FIXME: I'm not aware of a known max, so if it fails,
-         * just make it larger. :| */
-        char buf[20];
-        /* I don't know of a better way of doing it */
-        if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
-          {
-             wd->weekdays[i] = eina_stringshare_add(buf);
-          }
-        else
-          {
-             /* If we failed getting day, get a default value */
-             wd->weekdays[i] = _days_abbrev[i];
-             WRN("Failed getting weekday name for '%s' from locale.",
-                 _days_abbrev[i]);
-          }
-        weekday += 86400; /* Advance by a day */
-     }
+   _fill_weekdays(obj);
 
    current_time = time(NULL);
    localtime_r(&current_time, &wd->selected_time);
@@ -973,3 +987,28 @@
    if (!wd) return;
    _populate(obj);
 }
+
+EAPI void
+elm_calendar_first_day_of_week_set(Evas_Object *obj, int day)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if ((day > 6) || (day < 0)) return;
+   if (wd->first_week_day != day)
+     {
+        wd->first_week_day = day;
+        _fill_weekdays(obj);
+        _set_headers(obj);
+        _populate(obj);
+     }
+}
+
+EAPI int
+elm_calendar_first_day_of_week_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) -1;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return -1;
+   return wd->first_week_day;
+}
Index: src/lib/elm_calendar.h
===================================================================
--- src/lib/elm_calendar.h      (révision 69630)
+++ src/lib/elm_calendar.h      (copie de travail)
@@ -443,6 +455,31 @@
  */
 EAPI double               elm_calendar_interval_get(const Evas_Object *obj);
 
+
 /**
+ * Set the first day of week to use on calendar widgets'.
+ *
+ * @param obj The calendar object
+ * @param day An int which correspond to the first day of the week (Sunday = 
0, monday = 1,
+ * ..., saturday = 6)
+ *
+ * @ingroup Calendar
+ */
+EAPI void                 elm_calendar_first_day_of_week_set(Evas_Object *obj, 
int day);
+
+/**
+ * Get the first day of week, who are used on calendar widgets'.
+ *
+ * @param obj The calendar object
+ * @return An int which correspond to the first day of the week (Sunday = 0, 
monday = 1,
+ * ..., saturday = 6)
+ *
+ * @see elm_calendar_first_day_of_week_set() for more details
+ *
+ * @ingroup Calendar
+ */
+EAPI int                  elm_calendar_first_day_of_week_get(const Evas_Object 
*obj);
+
+/**
  * @}
  */
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to