Elementary calendar: fix min_max_year_set function
authorbdilly <bdilly@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 14 May 2011 19:47:54 +0000 (19:47 +0000)
committerbdilly <bdilly@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 14 May 2011 19:47:54 +0000 (19:47 +0000)
Properly support negative value for max year.
In this case, it shouldn't try to set the selected time
to year -1.

git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@59390 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/test_calendar.c
src/lib/elm_calendar.c

index a086daf..fdbe0e9 100644 (file)
@@ -145,6 +145,8 @@ test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
    elm_entry_editable_set(en, EINA_FALSE);
    evas_object_show(win);
 
+   elm_calendar_min_max_year_set(cal3, -1, -1);
+
    elm_calendar_weekdays_names_set(cal, weekdays);
    elm_calendar_interval_set(cal, 0.4);
    elm_calendar_format_function_set(cal, _format_month_year);
index 294e1b3..4e8c3f5 100644 (file)
@@ -940,7 +940,7 @@ elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max)
    if ((wd->year_min == min) && (wd->year_max == max)) return;
    wd->year_min = min > 2 ? min : 2;
    wd->year_max = max;
-   if (wd->selected_time.tm_year > wd->year_max)
+   if ((max >= wd->year_min) && (wd->selected_time.tm_year > wd->year_max))
      wd->selected_time.tm_year = wd->year_max;
    if (wd->selected_time.tm_year < wd->year_min)
      wd->selected_time.tm_year = wd->year_min;