2011-07-14 08:45:44 -07:00
|
|
|
/**
|
|
|
|
* Elementary's <b>calendar widget</b> example, demonstrates how to modify
|
|
|
|
* layout strings, using functions to set weekdays names and to format
|
|
|
|
* month and year label.
|
|
|
|
*
|
|
|
|
* See stdout/stderr for output. Compile with:
|
|
|
|
*
|
|
|
|
* @verbatim
|
2012-03-19 05:58:07 -07:00
|
|
|
* gcc -o calendar_example_02 calendar_example_02.c -g `pkg-config --cflags --libs elementary`
|
2011-07-14 08:45:44 -07:00
|
|
|
* @endverbatim
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Elementary.h>
|
|
|
|
|
|
|
|
static char *
|
2012-03-26 16:46:53 -07:00
|
|
|
_format_month_year(struct tm *format_time)
|
2011-07-14 08:45:44 -07:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
/* abbreviates month and year */
|
2012-03-26 16:46:53 -07:00
|
|
|
if (!strftime(buf, sizeof(buf), "%b %y", format_time)) return NULL;
|
2011-07-14 08:45:44 -07:00
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
2011-08-28 21:16:18 -07:00
|
|
|
EAPI_MAIN int
|
2017-04-19 23:33:59 -07:00
|
|
|
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
2011-07-14 08:45:44 -07:00
|
|
|
{
|
2013-06-25 20:06:34 -07:00
|
|
|
Evas_Object *win, *cal;
|
2011-07-14 08:45:44 -07:00
|
|
|
const char *weekdays[] =
|
|
|
|
{
|
|
|
|
"S", "M", "T", "W", "T", "F", "S"
|
|
|
|
};
|
|
|
|
|
2012-03-19 05:58:07 -07:00
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
2011-07-14 08:45:44 -07:00
|
|
|
|
2013-06-25 20:06:34 -07:00
|
|
|
win = elm_win_util_standard_add("calendar", "Calendar Layout Formatting Example");
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2011-07-14 08:45:44 -07:00
|
|
|
|
|
|
|
cal = elm_calendar_add(win);
|
|
|
|
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2013-06-26 16:26:42 -07:00
|
|
|
elm_win_resize_object_add(win, cal);
|
2011-07-14 08:45:44 -07:00
|
|
|
|
|
|
|
elm_calendar_format_function_set(cal, _format_month_year);
|
|
|
|
elm_calendar_weekdays_names_set(cal, weekdays);
|
|
|
|
|
|
|
|
evas_object_show(cal);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
|
|
|
|
elm_run();
|
2012-03-27 23:04:36 -07:00
|
|
|
|
2011-07-14 08:45:44 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ELM_MAIN()
|