summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-09-13 20:11:19 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-09-13 20:38:52 +0900
commit3984148b8e540c788ac1538704f8f6c44365100d (patch)
tree9b6df4fdb41e309f4e3e642e893fb30ca5cf55e3 /src
parentcca312d42ccfbb89779cd307b1cee9371225ba4f (diff)
efl.ui.clock: correct value_set/get & value_min/max APIs signature.
We could just pass Efl_Time value as copy by value to set time in setter APIs and return Efl_Time value in getter APIs. Thanks to @JackDanielZ for the report. Fixes T6008
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_ui_clock.c2
-rw-r--r--src/lib/elementary/efl_ui_clock.c64
-rw-r--r--src/lib/elementary/efl_ui_clock.eo32
-rw-r--r--src/lib/elementary/elm_datetime.c21
-rw-r--r--src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c12
5 files changed, 48 insertions, 83 deletions
diff --git a/src/bin/elementary/test_ui_clock.c b/src/bin/elementary/test_ui_clock.c
index 616143c733..a7bcc2ab84 100644
--- a/src/bin/elementary/test_ui_clock.c
+++ b/src/bin/elementary/test_ui_clock.c
@@ -33,7 +33,7 @@ _bt_clicked(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUS
33 efl_ui_clock_field_visible_set(dt1, EFL_UI_CLOCK_TYPE_SECOND, EINA_TRUE); 33 efl_ui_clock_field_visible_set(dt1, EFL_UI_CLOCK_TYPE_SECOND, EINA_TRUE);
34 efl_ui_clock_field_visible_set(dt1, EFL_UI_CLOCK_TYPE_DAY, EINA_TRUE); 34 efl_ui_clock_field_visible_set(dt1, EFL_UI_CLOCK_TYPE_DAY, EINA_TRUE);
35 35
36 efl_ui_clock_value_set(dt1, &new_time); 36 efl_ui_clock_value_set(dt1, new_time);
37 elm_object_disabled_set(dt1, EINA_TRUE); 37 elm_object_disabled_set(dt1, EINA_TRUE);
38 38
39 elm_object_disabled_set(obj, EINA_TRUE); 39 elm_object_disabled_set(obj, EINA_TRUE);
diff --git a/src/lib/elementary/efl_ui_clock.c b/src/lib/elementary/efl_ui_clock.c
index ce975739ce..6f579549dc 100644
--- a/src/lib/elementary/efl_ui_clock.c
+++ b/src/lib/elementary/efl_ui_clock.c
@@ -1105,25 +1105,19 @@ _efl_ui_clock_field_limit_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Ui_Clock_Type
1105 1105
1106 if (!_field_cmp(fieldtype, &old_time, &sd->curr_time)) 1106 if (!_field_cmp(fieldtype, &old_time, &sd->curr_time))
1107 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL); 1107 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL);
1108
1109} 1108}
1110 1109
1111EOLIAN static Eina_Bool 1110EOLIAN static Efl_Time
1112_efl_ui_clock_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd, struct tm *currtime) 1111_efl_ui_clock_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd)
1113{ 1112{
1114 EINA_SAFETY_ON_NULL_RETURN_VAL(currtime, EINA_FALSE); 1113 return sd->curr_time;
1115
1116 *currtime = sd->curr_time;
1117 return EINA_TRUE;
1118} 1114}
1119 1115
1120EOLIAN static Eina_Bool 1116EOLIAN static void
1121_efl_ui_clock_value_set(Eo *obj, Efl_Ui_Clock_Data *sd, struct tm *newtime) 1117_efl_ui_clock_value_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Time newtime)
1122{ 1118{
1123 EINA_SAFETY_ON_NULL_RETURN_VAL(newtime, EINA_FALSE); 1119 if (_date_cmp(&sd->curr_time, &newtime)) return;
1124 1120 sd->curr_time = newtime;
1125 if (_date_cmp(&sd->curr_time, newtime)) return EINA_TRUE;
1126 sd->curr_time = *newtime;
1127 // apply default field restrictions for curr_time 1121 // apply default field restrictions for curr_time
1128 _apply_range_restrictions(&sd->curr_time); 1122 _apply_range_restrictions(&sd->curr_time);
1129 // validate the curr_time according to the min_limt and max_limt 1123 // validate the curr_time according to the min_limt and max_limt
@@ -1132,28 +1126,21 @@ _efl_ui_clock_value_set(Eo *obj, Efl_Ui_Clock_Data *sd, struct tm *newtime)
1132 _apply_field_limits(obj); 1126 _apply_field_limits(obj);
1133 1127
1134 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL); 1128 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL);
1135
1136 return EINA_TRUE;
1137} 1129}
1138 1130
1139EOLIAN static Eina_Bool 1131EOLIAN static Efl_Time
1140_efl_ui_clock_value_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd, Efl_Time *mintime) 1132_efl_ui_clock_value_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd)
1141{ 1133{
1142 EINA_SAFETY_ON_NULL_RETURN_VAL(mintime, EINA_FALSE); 1134 return sd->min_limit;
1143
1144 *mintime = sd->min_limit;
1145 return EINA_TRUE;
1146} 1135}
1147 1136
1148EOLIAN static Eina_Bool 1137EOLIAN static void
1149_efl_ui_clock_value_min_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Time *mintime) 1138_efl_ui_clock_value_min_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Time mintime)
1150{ 1139{
1151 struct tm old_time; 1140 struct tm old_time;
1152 1141
1153 EINA_SAFETY_ON_NULL_RETURN_VAL(mintime, EINA_FALSE); 1142 if (_date_cmp(&sd->min_limit, &mintime)) return;
1154 1143 sd->min_limit = mintime;
1155 if (_date_cmp(&sd->min_limit, mintime)) return EINA_TRUE;
1156 sd->min_limit = *mintime;
1157 old_time = sd->curr_time; 1144 old_time = sd->curr_time;
1158 // apply default field restrictions for min_limit 1145 // apply default field restrictions for min_limit
1159 _apply_range_restrictions(&sd->min_limit); 1146 _apply_range_restrictions(&sd->min_limit);
@@ -1164,28 +1151,21 @@ _efl_ui_clock_value_min_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Time *mintime)
1164 1151
1165 if (!_date_cmp(&old_time, &sd->curr_time)) 1152 if (!_date_cmp(&old_time, &sd->curr_time))
1166 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL); 1153 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL);
1167
1168 return EINA_TRUE;
1169} 1154}
1170 1155
1171EOLIAN static Eina_Bool 1156EOLIAN static Efl_Time
1172_efl_ui_clock_value_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd, struct tm *maxtime) 1157_efl_ui_clock_value_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Clock_Data *sd)
1173{ 1158{
1174 EINA_SAFETY_ON_NULL_RETURN_VAL(maxtime, EINA_FALSE); 1159 return sd->max_limit;
1175
1176 *maxtime = sd->max_limit;
1177 return EINA_TRUE;
1178} 1160}
1179 1161
1180EOLIAN static Eina_Bool 1162EOLIAN static void
1181_efl_ui_clock_value_max_set(Eo *obj, Efl_Ui_Clock_Data *sd, struct tm *maxtime) 1163_efl_ui_clock_value_max_set(Eo *obj, Efl_Ui_Clock_Data *sd, Efl_Time maxtime)
1182{ 1164{
1183 struct tm old_time; 1165 struct tm old_time;
1184 1166
1185 EINA_SAFETY_ON_NULL_RETURN_VAL(maxtime, EINA_FALSE); 1167 if (_date_cmp(&sd->max_limit, &maxtime)) return;
1186 1168 sd->max_limit = maxtime;
1187 if (_date_cmp(&sd->max_limit, maxtime)) return EINA_TRUE;
1188 sd->max_limit = *maxtime;
1189 old_time = sd->curr_time; 1169 old_time = sd->curr_time;
1190 // apply default field restrictions for max_limit 1170 // apply default field restrictions for max_limit
1191 _apply_range_restrictions(&sd->max_limit); 1171 _apply_range_restrictions(&sd->max_limit);
@@ -1196,8 +1176,6 @@ _efl_ui_clock_value_max_set(Eo *obj, Efl_Ui_Clock_Data *sd, struct tm *maxtime)
1196 1176
1197 if (!_date_cmp(&old_time, &sd->curr_time)) 1177 if (!_date_cmp(&old_time, &sd->curr_time))
1198 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL); 1178 efl_event_callback_legacy_call(obj, EFL_UI_CLOCK_EVENT_CHANGED, NULL);
1199
1200 return EINA_TRUE;
1201} 1179}
1202 1180
1203EOLIAN static void 1181EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_clock.eo b/src/lib/elementary/efl_ui_clock.eo
index 2bcf804d01..81ed89c717 100644
--- a/src/lib/elementary/efl_ui_clock.eo
+++ b/src/lib/elementary/efl_ui_clock.eo
@@ -131,15 +131,8 @@ class Efl.Ui.Clock (Efl.Ui.Layout)
131 131
132 Minute: default value range is from 0 to 59. 132 Minute: default value range is from 0 to 59.
133 ]] 133 ]]
134 set { 134 values {
135 return: bool; [[$true on success, $false otherwise]] 135 mintime: Efl.Time; [[Time structure containing the minimum time value.]]
136 }
137 get {
138 return: bool; [[$true on success, $false otherwise]]
139 }
140
141 keys {
142 mintime: ptr(Efl.Time); [[Time structure containing the minimum time value.]]
143 } 136 }
144 } 137 }
145 @property value_max { 138 @property value_max {
@@ -158,15 +151,8 @@ class Efl.Ui.Clock (Efl.Ui.Layout)
158 151
159 Minute: default value range is from 0 to 59. 152 Minute: default value range is from 0 to 59.
160 ]] 153 ]]
161 set { 154 values {
162 return: bool; [[$true on success, $false otherwise]] 155 maxtime: Efl.Time; [[Time structure containing the maximum time value.]]
163 }
164 get {
165 return: bool; [[$true on success, $false otherwise]]
166 }
167
168 keys {
169 maxtime: ptr(Efl.Time); [[Time structure containing the minimum time value.]]
170 } 156 }
171 } 157 }
172 @property value { 158 @property value {
@@ -185,14 +171,8 @@ class Efl.Ui.Clock (Efl.Ui.Layout)
185 171
186 Minute: default value range is from 0 to 59. 172 Minute: default value range is from 0 to 59.
187 ]] 173 ]]
188 set { 174 values {
189 return: bool; [[$true on success, $false otherwise]] 175 curtime: Efl.Time; [[Time structure containing the time value.]]
190 }
191 get {
192 return: bool; [[$true on success, $false otherwise]]
193 }
194 keys {
195 curtime: ptr(Efl.Time); [[Time structure containing the minimum time value.]]
196 } 176 }
197 } 177 }
198 @property field_visible { 178 @property field_visible {
diff --git a/src/lib/elementary/elm_datetime.c b/src/lib/elementary/elm_datetime.c
index 572cc9c183..aeaa1a906d 100644
--- a/src/lib/elementary/elm_datetime.c
+++ b/src/lib/elementary/elm_datetime.c
@@ -82,24 +82,29 @@ elm_datetime_field_limit_get(const Evas_Object *obj, Elm_Datetime_Field_Type fie
82EAPI Eina_Bool 82EAPI Eina_Bool
83elm_datetime_value_min_set(Evas_Object *obj, const Efl_Time *mintime) 83elm_datetime_value_min_set(Evas_Object *obj, const Efl_Time *mintime)
84{ 84{
85 return efl_ui_clock_value_min_set(obj, (Efl_Time *)mintime); 85 if (mintime) efl_ui_clock_value_min_set(obj, *mintime);
86 return EINA_TRUE;
86} 87}
87 88
88EAPI Eina_Bool 89EAPI Eina_Bool
89elm_datetime_value_min_get(const Evas_Object *obj, Efl_Time *mintime) 90elm_datetime_value_min_get(const Evas_Object *obj, Efl_Time *mintime)
90{ 91{
91 return efl_ui_clock_value_min_get(obj, mintime); 92 if (mintime) *mintime = efl_ui_clock_value_min_get(obj);
93 return EINA_TRUE;
92} 94}
93 95
94EAPI Eina_Bool 96EAPI Eina_Bool
95elm_datetime_value_set(Evas_Object *obj, const Efl_Time *newtime) 97elm_datetime_value_set(Evas_Object *obj, const Efl_Time *newtime)
96{ 98{
97 return efl_ui_clock_value_set(obj, (Efl_Time *)newtime); 99 if (newtime) efl_ui_clock_value_set(obj, *newtime);
100 return EINA_TRUE;
98} 101}
99 102
100EAPI Eina_Bool elm_datetime_value_get(const Evas_Object *obj, Efl_Time *currtime) 103EAPI Eina_Bool
104elm_datetime_value_get(const Evas_Object *obj, Efl_Time *currtime)
101{ 105{
102 return efl_ui_clock_value_get(obj, currtime); 106 if (currtime) *currtime = efl_ui_clock_value_get(obj);
107 return EINA_TRUE;
103} 108}
104 109
105EAPI void 110EAPI void
@@ -116,11 +121,13 @@ EAPI Eina_Bool elm_datetime_field_visible_get(const Evas_Object *obj, Elm_Dateti
116EAPI Eina_Bool 121EAPI Eina_Bool
117elm_datetime_value_max_set(Evas_Object *obj, const Efl_Time *maxtime) 122elm_datetime_value_max_set(Evas_Object *obj, const Efl_Time *maxtime)
118{ 123{
119 return efl_ui_clock_value_max_set(obj, (Efl_Time *)maxtime); 124 if (maxtime) efl_ui_clock_value_max_set(obj, *maxtime);
125 return EINA_TRUE;
120} 126}
121 127
122EAPI Eina_Bool 128EAPI Eina_Bool
123elm_datetime_value_max_get(const Evas_Object *obj, Efl_Time *maxtime) 129elm_datetime_value_max_get(const Evas_Object *obj, Efl_Time *maxtime)
124{ 130{
125 return efl_ui_clock_value_max_get(obj, maxtime); 131 if (maxtime) *maxtime = efl_ui_clock_value_max_get(obj);
132 return EINA_TRUE;
126} 133}
diff --git a/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c b/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
index b3b90b6f20..d94a8867a1 100644
--- a/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
+++ b/src/modules/elementary/clock_input_ctxpopup/clock_input_ctxpopup.c
@@ -97,13 +97,13 @@ _diskselector_cb(void *data EINA_UNUSED, const Efl_Event *event)
97 disk_data = (DiskItem_Data *)elm_object_item_data_get(event->info); 97 disk_data = (DiskItem_Data *)elm_object_item_data_get(event->info);
98 if (!disk_data || !(disk_data->ctx_mod)) return; 98 if (!disk_data || !(disk_data->ctx_mod)) return;
99 99
100 efl_ui_clock_value_get(disk_data->ctx_mod->mod_data.base, &curr_time); 100 curr_time = efl_ui_clock_value_get(disk_data->ctx_mod->mod_data.base);
101 fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type); 101 fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type);
102 if ((disk_data->sel_field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) || 102 if ((disk_data->sel_field_type == EFL_UI_CLOCK_TYPE_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) ||
103 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12)) 103 (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12))
104 disk_data->sel_field_value += 12; 104 disk_data->sel_field_value += 12;
105 _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value); 105 _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value);
106 efl_ui_clock_value_set(disk_data->ctx_mod->mod_data.base, &curr_time); 106 efl_ui_clock_value_set(disk_data->ctx_mod->mod_data.base, curr_time);
107 evas_object_hide(disk_data->ctx_mod->ctxpopup); 107 evas_object_hide(disk_data->ctx_mod->ctxpopup);
108} 108}
109 109
@@ -116,10 +116,10 @@ _ampm_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
116 ctx_mod = (Ctxpopup_Module_Data *)data; 116 ctx_mod = (Ctxpopup_Module_Data *)data;
117 if (!ctx_mod) return; 117 if (!ctx_mod) return;
118 118
119 efl_ui_clock_value_get(ctx_mod->mod_data.base, &curr_time); 119 curr_time = efl_ui_clock_value_get(ctx_mod->mod_data.base);
120 if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12; 120 if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12;
121 else curr_time.tm_hour += 12; 121 else curr_time.tm_hour += 12;
122 efl_ui_clock_value_set(ctx_mod->mod_data.base, &curr_time); 122 efl_ui_clock_value_set(ctx_mod->mod_data.base, curr_time);
123} 123}
124 124
125static void 125static void
@@ -169,7 +169,7 @@ _field_clicked_cb(void *data, const Efl_Event *event)
169 169
170 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(event->object, "_field_type"); 170 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(event->object, "_field_type");
171 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); 171 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
172 efl_ui_clock_value_get(ctx_mod->mod_data.base, &time1); 172 time1 = efl_ui_clock_value_get(ctx_mod->mod_data.base);
173 val = _field_value_get(&time1, field_type); 173 val = _field_value_get(&time1, field_type);
174 ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max); 174 ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max);
175 175
@@ -283,7 +283,7 @@ field_value_display(Efl_Ui_Clock_Module_Data *module_data, Evas_Object *obj)
283 ctx_mod = (Ctxpopup_Module_Data *)module_data; 283 ctx_mod = (Ctxpopup_Module_Data *)module_data;
284 if (!ctx_mod || !obj) return; 284 if (!ctx_mod || !obj) return;
285 285
286 efl_ui_clock_value_get(ctx_mod->mod_data.base, &tim); 286 tim = efl_ui_clock_value_get(ctx_mod->mod_data.base);
287 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(obj, "_field_type"); 287 field_type = (Efl_Ui_Clock_Type )evas_object_data_get(obj, "_field_type");
288 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); 288 fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type);
289 buf[0] = 0; 289 buf[0] = 0;