summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-03-15 21:07:10 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-03-15 21:07:10 +0100
commitadd166fb62982b015abf79679ec3b25366cc27e4 (patch)
treef0bf71d6c4950f21cbc238b93de25b0474b5287c
parent7aec398ede219bfc25f7cfa8dd6b158139e85cd6 (diff)
New 1.19 API: elm.Calendar.date_{min,max}
with test
-rw-r--r--efl/elementary/calendar.pxi67
-rw-r--r--efl/elementary/calendar_cdef.pxi5
-rw-r--r--examples/elementary/test_calendar.py14
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):
216 time.tm_isdst = tmtup.tm_isdst 216 time.tm_isdst = tmtup.tm_isdst
217 elm_calendar_selected_time_set(self.obj, &time) 217 elm_calendar_selected_time_set(self.obj, &time)
218 218
219 property date_min:
220 """ Minimum date on calendar.
221
222 :type: datetime.date
223
224 .. versionadded:: 1.19
225
226 """
227 def __get__(self):
228 cdef const tm *time
229 time = elm_calendar_date_min_get(self.obj)
230 if time == NULL:
231 return None
232 return date(time.tm_year + 1900,
233 time.tm_mon + 1,
234 time.tm_mday)
235
236 def __set__(self, min_date):
237 cdef tm time
238 tmtup = min_date.timetuple()
239 time.tm_mday = tmtup.tm_mday
240 time.tm_mon = tmtup.tm_mon - 1
241 time.tm_year = tmtup.tm_year - 1900
242 time.tm_wday = tmtup.tm_wday
243 time.tm_yday = tmtup.tm_yday
244 time.tm_isdst = tmtup.tm_isdst
245 elm_calendar_date_min_set(self.obj, &time)
246
247 def date_min_get(self):
248 return self.date_min
249 def date_min_set(self, min_date):
250 self.date_min = min_date
251
252 property date_max:
253 """ Maximum date on calendar.
254
255 :type: datetime.date
256
257 .. versionadded:: 1.19
258
259 """
260 def __get__(self):
261 cdef const tm *time
262 time = elm_calendar_date_max_get(self.obj)
263 if time == NULL:
264 return None
265 return date(time.tm_year + 1900,
266 time.tm_mon + 1,
267 time.tm_mday)
268
269 def __set__(self, max_date):
270 cdef tm time
271 tmtup = max_date.timetuple()
272 time.tm_mday = tmtup.tm_mday
273 time.tm_mon = tmtup.tm_mon - 1
274 time.tm_year = tmtup.tm_year - 1900
275 time.tm_wday = tmtup.tm_wday
276 time.tm_yday = tmtup.tm_yday
277 time.tm_isdst = tmtup.tm_isdst
278 elm_calendar_date_max_set(self.obj, &time)
279
280 def date_max_get(self):
281 return self.date_max
282 def date_max_set(self, max_date):
283 self.date_max = max_date
284
285
219 # TODO: 286 # TODO:
220 # property format_function: 287 # property format_function:
221 # """Set a function to format the string that will be used to display 288 # """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":
46 void elm_calendar_selectable_set(Evas_Object *obj, Elm_Calendar_Selectable selectable) 46 void elm_calendar_selectable_set(Evas_Object *obj, Elm_Calendar_Selectable selectable)
47 Elm_Calendar_Selectable elm_calendar_selectable_get(const Evas_Object *obj) 47 Elm_Calendar_Selectable elm_calendar_selectable_get(const Evas_Object *obj)
48 Eina_Bool elm_calendar_displayed_time_get(const Evas_Object *obj, tm *displayed_time) 48 Eina_Bool elm_calendar_displayed_time_get(const Evas_Object *obj, tm *displayed_time)
49 49 const tm * elm_calendar_date_min_get(const Evas_Object *obj)
50 void elm_calendar_date_min_set(Evas_Object *obj, const tm *min)
51 const tm * elm_calendar_date_max_get(const Evas_Object *obj)
52 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):
106 if not stm: 106 if not stm:
107 return 107 return
108 108
109 interval = cal.interval
110 year_min, year_max = cal.min_max_year
111 sel_enabled = True if cal.select_mode != ELM_CALENDAR_SELECT_MODE_NONE else False 109 sel_enabled = True if cal.select_mode != ELM_CALENDAR_SELECT_MODE_NONE else False
112 wds = cal.weekdays_names 110 wds = cal.weekdays_names
113 111
114 info = ( 112 info = (
115 " Day: %i, Mon: %i, Year %i, WeekDay: %i<br/>" 113 " Day: %i, Mon: %i, Year %i, WeekDay: %i<br>"
116 " Interval: %0.2f, Year_Min: %i, Year_Max %i, Sel Enabled : %s<br/>" 114 " Interval: %0.2f, Sel Enabled : %s<br>"
117 " Weekdays: %s, %s, %s, %s, %s, %s, %s<br/>" % ( 115 " Date Min: %s, Date Max: %s <br>"
116 " Weekdays: %s, %s, %s, %s, %s, %s, %s<br>" % (
118 stm.day, stm.month, stm.year, stm.weekday(), 117 stm.day, stm.month, stm.year, stm.weekday(),
119 interval, year_min, year_max, sel_enabled, 118 cal.interval, sel_enabled,
119 cal.date_min, cal.date_max,
120 wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6] 120 wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]
121 ) 121 )
122 ) 122 )
@@ -151,7 +151,7 @@ def calendar2_clicked(obj, item=None):
151 cal = Calendar(bx, size_hint_weight=EXPAND_BOTH, 151 cal = Calendar(bx, size_hint_weight=EXPAND_BOTH,
152 size_hint_align=FILL_BOTH, weekdays_names=weekdays, 152 size_hint_align=FILL_BOTH, weekdays_names=weekdays,
153 first_day_of_week=ELM_DAY_SATURDAY, interval=0.4, 153 first_day_of_week=ELM_DAY_SATURDAY, interval=0.4,
154 min_max_year=(2010, 2020)) 154 date_min=datetime(2012, 12, 7), date_max=datetime(2020, 1, 3))
155 cal.show() 155 cal.show()
156 bx.pack_end(cal) 156 bx.pack_end(cal)
157 157