+#include <assert.h>
+
#include "private.h"
typedef struct _Elm_Params_Calendar
Elm_Params base;
int year_min;
int year_max;
- Eina_Bool sel_enable;
- Eina_Bool sel_exists:1;
+ const char *select_mode;
+
} Elm_Params_Calendar;
+#define SELECT_MODE_GET(CHOICES, STR) \
+ unsigned int i; \
+ for (i = 0; i < (sizeof(CHOICES) / sizeof(CHOICES[0])); ++i) \
+ if (!strcmp(STR, CHOICES[i])) \
+ return i;
+
+
+static const char *_calendar_select_modes[] = {"default", "always", "none",
+ "ondemand", NULL};
+
+static Elm_Calendar_Select_Mode
+_calendar_select_mode_get(const char *select_mode)
+{
+ assert(sizeof(_calendar_select_modes) /
+ sizeof(_calendar_select_modes[0])
+ == ELM_CALENDAR_SELECT_MODE_ONDEMAND + 2);
+ SELECT_MODE_GET(_calendar_select_modes, select_mode);
+ return -1;
+}
+
static void
external_calendar_state_set(void *data __UNUSED__, Evas_Object *obj,
const void *from_params, const void *to_params,
float pos __UNUSED__)
{
const Elm_Params_Calendar *p;
+ Elm_Calendar_Select_Mode select_mode;
int min,max;
if (to_params) p = to_params;
elm_calendar_min_max_year_get(obj, &min, NULL);
elm_calendar_min_max_year_set(obj, min, p->year_max);
}
- if (p->sel_exists)
- elm_calendar_day_selection_disabled_set(obj, !p->sel_enable);
+ if (p->select_mode)
+ {
+ select_mode = _calendar_select_mode_get(p->select_mode);
+ elm_calendar_select_mode_set(obj, select_mode);
+ }
}
static Eina_Bool
return EINA_TRUE;
}
}
- else if (!strcmp(param->name, "sel_enable"))
+ else if (!strcmp(param->name, "select_mode"))
{
- if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
+ if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
- elm_calendar_day_selection_disabled_set(obj,!param->i );
+ Elm_Calendar_Select_Mode select_mode;
+ select_mode = _calendar_select_mode_get(param->s);
+ elm_calendar_select_mode_set(obj, select_mode);
return EINA_TRUE;
}
}
return EINA_TRUE;
}
}
- else if (!strcmp(param->name, "sel_enable"))
+ else if (!strcmp(param->name, "select_mode"))
{
- if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
+ if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
{
- param->i = !elm_calendar_day_selection_disabled_get(obj);
+ Elm_Calendar_Select_Mode mode;
+ mode = elm_calendar_select_mode_get(obj);
+ param->s = _calendar_select_modes[mode];
return EINA_TRUE;
}
}
+
ERR("unknown parameter '%s' of type '%s'",
param->name, edje_external_param_type_str(param->type));
else if (!strcmp(param->name, "year_max"))
mem->year_max = param->i;
- else if (!strcmp(param->name, "sel_enable"))
- {
- mem->sel_enable = param->i;
- mem->sel_exists = EINA_TRUE;
- }
+ else if (!strcmp(param->name, "select_mode"))
+ mem->select_mode = eina_stringshare_add(param->s);
}
return mem;
static void
external_calendar_params_free(void *params)
{
+ Elm_Params_Calendar *mem = params;
+ if (mem->select_mode)
+ eina_stringshare_del(mem->select_mode);
free(params);
}
DEFINE_EXTERNAL_COMMON_PARAMS,
EDJE_EXTERNAL_PARAM_INFO_INT("year_min"),
EDJE_EXTERNAL_PARAM_INFO_INT("year_max"),
- EDJE_EXTERNAL_PARAM_INFO_BOOL("sel_enable"),
+ EDJE_EXTERNAL_PARAM_INFO_STRING("select_mode"),
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
};