summaryrefslogtreecommitdiff
path: root/src/edje_externals
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-04-19 21:36:19 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-04-19 21:36:19 +0000
commite1c869f856395df79c1f57423e322b6deecc5140 (patch)
treefbcc522cd7e565c6404f52e0a71ffe75042fb186 /src/edje_externals
parent5d2393d682ce20e8792b4f36fb30664e0a164919 (diff)
elementary: edje_external calendar instead of sel_enable use select_mode now. But nobody care I think ... see my next commit :P
SVN revision: 70337
Diffstat (limited to 'src/edje_externals')
-rw-r--r--src/edje_externals/elm_calendar.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/edje_externals/elm_calendar.c b/src/edje_externals/elm_calendar.c
index fd5c3eeb9..d3a3ea2f3 100644
--- a/src/edje_externals/elm_calendar.c
+++ b/src/edje_externals/elm_calendar.c
@@ -1,3 +1,5 @@
1#include <assert.h>
2
1#include "private.h" 3#include "private.h"
2 4
3typedef struct _Elm_Params_Calendar 5typedef struct _Elm_Params_Calendar
@@ -5,16 +7,37 @@ typedef struct _Elm_Params_Calendar
5 Elm_Params base; 7 Elm_Params base;
6 int year_min; 8 int year_min;
7 int year_max; 9 int year_max;
8 Eina_Bool sel_enable; 10 const char *select_mode;
9 Eina_Bool sel_exists:1; 11
10} Elm_Params_Calendar; 12} Elm_Params_Calendar;
11 13
14#define SELECT_MODE_GET(CHOICES, STR) \
15 unsigned int i; \
16 for (i = 0; i < (sizeof(CHOICES) / sizeof(CHOICES[0])); ++i) \
17 if (!strcmp(STR, CHOICES[i])) \
18 return i;
19
20
21static const char *_calendar_select_modes[] = {"default", "always", "none",
22 "ondemand", NULL};
23
24static Elm_Calendar_Select_Mode
25_calendar_select_mode_get(const char *select_mode)
26{
27 assert(sizeof(_calendar_select_modes) /
28 sizeof(_calendar_select_modes[0])
29 == ELM_CALENDAR_SELECT_MODE_ONDEMAND + 2);
30 SELECT_MODE_GET(_calendar_select_modes, select_mode);
31 return -1;
32}
33
12static void 34static void
13external_calendar_state_set(void *data __UNUSED__, Evas_Object *obj, 35external_calendar_state_set(void *data __UNUSED__, Evas_Object *obj,
14 const void *from_params, const void *to_params, 36 const void *from_params, const void *to_params,
15 float pos __UNUSED__) 37 float pos __UNUSED__)
16{ 38{
17 const Elm_Params_Calendar *p; 39 const Elm_Params_Calendar *p;
40 Elm_Calendar_Select_Mode select_mode;
18 int min,max; 41 int min,max;
19 42
20 if (to_params) p = to_params; 43 if (to_params) p = to_params;
@@ -31,8 +54,11 @@ external_calendar_state_set(void *data __UNUSED__, Evas_Object *obj,
31 elm_calendar_min_max_year_get(obj, &min, NULL); 54 elm_calendar_min_max_year_get(obj, &min, NULL);
32 elm_calendar_min_max_year_set(obj, min, p->year_max); 55 elm_calendar_min_max_year_set(obj, min, p->year_max);
33 } 56 }
34 if (p->sel_exists) 57 if (p->select_mode)
35 elm_calendar_day_selection_disabled_set(obj, !p->sel_enable); 58 {
59 select_mode = _calendar_select_mode_get(p->select_mode);
60 elm_calendar_select_mode_set(obj, select_mode);
61 }
36} 62}
37 63
38static Eina_Bool 64static Eina_Bool
@@ -59,11 +85,13 @@ external_calendar_param_set(void *data __UNUSED__, Evas_Object *obj,
59 return EINA_TRUE; 85 return EINA_TRUE;
60 } 86 }
61 } 87 }
62 else if (!strcmp(param->name, "sel_enable")) 88 else if (!strcmp(param->name, "select_mode"))
63 { 89 {
64 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 90 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
65 { 91 {
66 elm_calendar_day_selection_disabled_set(obj,!param->i ); 92 Elm_Calendar_Select_Mode select_mode;
93 select_mode = _calendar_select_mode_get(param->s);
94 elm_calendar_select_mode_set(obj, select_mode);
67 return EINA_TRUE; 95 return EINA_TRUE;
68 } 96 }
69 } 97 }
@@ -96,15 +124,18 @@ external_calendar_param_get(void *data __UNUSED__, const Evas_Object *obj,
96 return EINA_TRUE; 124 return EINA_TRUE;
97 } 125 }
98 } 126 }
99 else if (!strcmp(param->name, "sel_enable")) 127 else if (!strcmp(param->name, "select_mode"))
100 { 128 {
101 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) 129 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
102 { 130 {
103 param->i = !elm_calendar_day_selection_disabled_get(obj); 131 Elm_Calendar_Select_Mode mode;
132 mode = elm_calendar_select_mode_get(obj);
133 param->s = _calendar_select_modes[mode];
104 return EINA_TRUE; 134 return EINA_TRUE;
105 } 135 }
106 } 136 }
107 137
138
108 ERR("unknown parameter '%s' of type '%s'", 139 ERR("unknown parameter '%s' of type '%s'",
109 param->name, edje_external_param_type_str(param->type)); 140 param->name, edje_external_param_type_str(param->type));
110 141
@@ -132,11 +163,8 @@ external_calendar_params_parse(void *data __UNUSED__,
132 else if (!strcmp(param->name, "year_max")) 163 else if (!strcmp(param->name, "year_max"))
133 mem->year_max = param->i; 164 mem->year_max = param->i;
134 165
135 else if (!strcmp(param->name, "sel_enable")) 166 else if (!strcmp(param->name, "select_mode"))
136 { 167 mem->select_mode = eina_stringshare_add(param->s);
137 mem->sel_enable = param->i;
138 mem->sel_exists = EINA_TRUE;
139 }
140 } 168 }
141 169
142 return mem; 170 return mem;
@@ -154,6 +182,9 @@ external_calendar_content_get(void *data __UNUSED__,
154static void 182static void
155external_calendar_params_free(void *params) 183external_calendar_params_free(void *params)
156{ 184{
185 Elm_Params_Calendar *mem = params;
186 if (mem->select_mode)
187 eina_stringshare_del(mem->select_mode);
157 free(params); 188 free(params);
158} 189}
159 190
@@ -161,7 +192,7 @@ static Edje_External_Param_Info external_calendar_params[] = {
161 DEFINE_EXTERNAL_COMMON_PARAMS, 192 DEFINE_EXTERNAL_COMMON_PARAMS,
162 EDJE_EXTERNAL_PARAM_INFO_INT("year_min"), 193 EDJE_EXTERNAL_PARAM_INFO_INT("year_min"),
163 EDJE_EXTERNAL_PARAM_INFO_INT("year_max"), 194 EDJE_EXTERNAL_PARAM_INFO_INT("year_max"),
164 EDJE_EXTERNAL_PARAM_INFO_BOOL("sel_enable"), 195 EDJE_EXTERNAL_PARAM_INFO_STRING("select_mode"),
165 EDJE_EXTERNAL_PARAM_INFO_SENTINEL 196 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
166}; 197};
167 198