davemds pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=add166fb62982b015abf79679ec3b25366cc27e4

commit add166fb62982b015abf79679ec3b25366cc27e4
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Wed Mar 15 21:07:10 2017 +0100

    New 1.19 API: elm.Calendar.date_{min,max}
    
    with test
---
 efl/elementary/calendar.pxi          | 67 ++++++++++++++++++++++++++++++++++++
 efl/elementary/calendar_cdef.pxi     |  5 ++-
 examples/elementary/test_calendar.py | 14 ++++----
 3 files changed, 78 insertions(+), 8 deletions(-)

diff --git a/efl/elementary/calendar.pxi b/efl/elementary/calendar.pxi
index 2d5ac1f..0bfae5d 100644
--- a/efl/elementary/calendar.pxi
+++ b/efl/elementary/calendar.pxi
@@ -216,6 +216,73 @@ cdef class Calendar(LayoutClass):
             time.tm_isdst = tmtup.tm_isdst
             elm_calendar_selected_time_set(self.obj, &time)
 
+    property date_min:
+        """ Minimum date on calendar.
+
+        :type: datetime.date
+
+        .. versionadded:: 1.19
+
+        """
+        def __get__(self):
+            cdef const tm *time
+            time = elm_calendar_date_min_get(self.obj)
+            if time == NULL:
+                return None
+            return date(time.tm_year + 1900,
+                        time.tm_mon + 1,
+                        time.tm_mday)
+    
+        def __set__(self, min_date):
+            cdef tm time
+            tmtup = min_date.timetuple()
+            time.tm_mday = tmtup.tm_mday
+            time.tm_mon = tmtup.tm_mon - 1
+            time.tm_year = tmtup.tm_year - 1900
+            time.tm_wday = tmtup.tm_wday
+            time.tm_yday = tmtup.tm_yday
+            time.tm_isdst = tmtup.tm_isdst
+            elm_calendar_date_min_set(self.obj, &time)
+
+    def date_min_get(self):
+        return self.date_min
+    def date_min_set(self, min_date):
+        self.date_min = min_date
+
+    property date_max:
+        """ Maximum date on calendar.
+
+        :type: datetime.date
+
+        .. versionadded:: 1.19
+
+        """
+        def __get__(self):
+            cdef const tm *time
+            time = elm_calendar_date_max_get(self.obj)
+            if time == NULL:
+                return None
+            return date(time.tm_year + 1900,
+                        time.tm_mon + 1,
+                        time.tm_mday)
+    
+        def __set__(self, max_date):
+            cdef tm time
+            tmtup = max_date.timetuple()
+            time.tm_mday = tmtup.tm_mday
+            time.tm_mon = tmtup.tm_mon - 1
+            time.tm_year = tmtup.tm_year - 1900
+            time.tm_wday = tmtup.tm_wday
+            time.tm_yday = tmtup.tm_yday
+            time.tm_isdst = tmtup.tm_isdst
+            elm_calendar_date_max_set(self.obj, &time)
+
+    def date_max_get(self):
+        return self.date_max
+    def date_max_set(self, max_date):
+        self.date_max = max_date
+    
+
     # TODO:
     # property format_function:
     #     """Set a function to format the string that will be used to display
diff --git a/efl/elementary/calendar_cdef.pxi b/efl/elementary/calendar_cdef.pxi
index b73d49f..9dcb01f 100644
--- a/efl/elementary/calendar_cdef.pxi
+++ b/efl/elementary/calendar_cdef.pxi
@@ -46,4 +46,7 @@ cdef extern from "Elementary.h":
     void                        elm_calendar_selectable_set(Evas_Object *obj, 
Elm_Calendar_Selectable selectable)
     Elm_Calendar_Selectable     elm_calendar_selectable_get(const Evas_Object 
*obj)
     Eina_Bool                   elm_calendar_displayed_time_get(const 
Evas_Object *obj, tm *displayed_time)
-
+    const tm *                  elm_calendar_date_min_get(const Evas_Object 
*obj)
+    void                        elm_calendar_date_min_set(Evas_Object *obj, 
const tm *min)
+    const tm *                  elm_calendar_date_max_get(const Evas_Object 
*obj)
+    void                        elm_calendar_date_max_set(Evas_Object *obj, 
const tm *max)
diff --git a/examples/elementary/test_calendar.py 
b/examples/elementary/test_calendar.py
index 089fbbe..2c4482f 100644
--- a/examples/elementary/test_calendar.py
+++ b/examples/elementary/test_calendar.py
@@ -106,17 +106,17 @@ def print_cal_info(cal, en):
     if not stm:
         return
 
-    interval = cal.interval
-    year_min, year_max = cal.min_max_year
     sel_enabled = True if cal.select_mode != ELM_CALENDAR_SELECT_MODE_NONE 
else False
     wds = cal.weekdays_names
 
     info = (
-        "  Day: %i, Mon: %i, Year %i, WeekDay: %i<br/>"
-        "  Interval: %0.2f, Year_Min: %i, Year_Max %i, Sel Enabled : %s<br/>"
-        "  Weekdays: %s, %s, %s, %s, %s, %s, %s<br/>" % (
+        "  Day: %i, Mon: %i, Year %i, WeekDay: %i<br>"
+        "  Interval: %0.2f, Sel Enabled : %s<br>"
+        "  Date Min: %s, Date Max: %s <br>"
+        "  Weekdays: %s, %s, %s, %s, %s, %s, %s<br>" % (
             stm.day, stm.month, stm.year, stm.weekday(),
-            interval, year_min, year_max, sel_enabled,
+            cal.interval, sel_enabled,
+            cal.date_min, cal.date_max,
             wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]
             )
         )
@@ -151,7 +151,7 @@ def calendar2_clicked(obj, item=None):
     cal = Calendar(bx, size_hint_weight=EXPAND_BOTH,
         size_hint_align=FILL_BOTH, weekdays_names=weekdays,
         first_day_of_week=ELM_DAY_SATURDAY, interval=0.4,
-        min_max_year=(2010, 2020))
+        date_min=datetime(2012, 12, 7), date_max=datetime(2020, 1, 3))
     cal.show()
     bx.pack_end(cal)
 

-- 


Reply via email to