Changeset View
Changeset View
Standalone View
Standalone View
src/lib/elementary/efl_ui_radio.c
Show All 37 Lines | |||||
38 | static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); | 38 | static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); | ||
39 | 39 | | |||
40 | static const Elm_Action key_actions[] = { | 40 | static const Elm_Action key_actions[] = { | ||
41 | {"activate", _key_action_activate}, | 41 | {"activate", _key_action_activate}, | ||
42 | {NULL, NULL} | 42 | {NULL, NULL} | ||
43 | }; | 43 | }; | ||
44 | 44 | | |||
45 | static void | 45 | static void | ||
46 | _state_set(Evas_Object *obj, Eina_Bool state, Eina_Bool activate) | 46 | _radio_widget_signal_emit(Evas_Object *obj, const char *middle_term) | ||
47 | { | 47 | { | ||
48 | ELM_RADIO_DATA_GET(obj, sd); | 48 | const char *source, *state; | ||
49 | char path[PATH_MAX]; | ||||
50 | | ||||
51 | if (elm_widget_is_legacy(obj)) | ||||
52 | source = "elm"; | ||||
53 | else | ||||
54 | source = "efl"; | ||||
55 | | ||||
56 | if (efl_ui_check_selected_get(obj)) | ||||
57 | state = "on"; | ||||
58 | else | ||||
59 | state = "off"; | ||||
60 | | ||||
61 | snprintf(path, sizeof(path), "%s,%s,%s", source, middle_term, state); | ||||
62 | elm_layout_signal_emit(obj, path, source); | ||||
63 | } | ||||
49 | 64 | | |||
50 | if (state != sd->state) | 65 | static void | ||
66 | _efl_ui_radio_efl_ui_check_selected_set(Eo *obj, Efl_Ui_Radio_Data *pd EINA_UNUSED, Eina_Bool value) | ||||
67 | { | ||||
68 | if (value == efl_ui_check_selected_get(obj)) return; | ||||
69 | efl_ui_check_selected_set(efl_super(obj, MY_CLASS), value); | ||||
70 | | ||||
71 | _radio_widget_signal_emit(obj, "state,radio"); | ||||
72 | | ||||
73 | if (_elm_config->atspi_mode) | ||||
51 | { | 74 | { | ||
52 | sd->state = state; | 75 | if (efl_ui_check_selected_get(obj)) | ||
53 | if (sd->state) | | |||
54 | { | | |||
55 | // FIXME: to do animation during state change , we need different signal | | |||
56 | // so that we can distinguish between state change by user or state change | | |||
57 | // by calling state_change() api. Keep both the signal for backward compatibility | | |||
58 | // and only emit "elm,state,radio,on" when activate is false when we can break ABI. | | |||
59 | if (elm_widget_is_legacy(obj)) | | |||
60 | { | | |||
61 | if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,on", "elm"); | | |||
62 | elm_layout_signal_emit(obj, "elm,state,radio,on", "elm"); | | |||
63 | } | | |||
64 | else | | |||
65 | { | | |||
66 | if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,on", "efl"); | | |||
67 | elm_layout_signal_emit(obj, "efl,state,radio,on", "efl"); | | |||
68 | } | | |||
69 | } | | |||
70 | else | | |||
71 | { | 76 | { | ||
72 | // FIXME: to do animation during state change , we need different signal | 77 | efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE); | ||
73 | // so that we can distinguish between state change by user or state change | | |||
74 | // by calling state_change() api. Keep both the signal for backward compatibility | | |||
75 | // and only emit "elm,state,radio,off"when activate is false when we can break ABI. | | |||
76 | if (elm_widget_is_legacy(obj)) | | |||
77 | { | | |||
78 | if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,off", "elm"); | | |||
79 | elm_layout_signal_emit(obj, "elm,state,radio,off", "elm"); | | |||
80 | } | | |||
81 | else | | |||
82 | { | | |||
83 | if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,off", "efl"); | | |||
84 | elm_layout_signal_emit(obj, "efl,state,radio,off", "efl"); | | |||
85 | } | | |||
86 | } | | |||
87 | if (_elm_config->atspi_mode) | | |||
88 | { | | |||
89 | if (sd->state) | | |||
90 | { | | |||
91 | efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE); | | |||
92 | } | | |||
93 | } | 78 | } | ||
94 | } | 79 | } | ||
95 | } | 80 | } | ||
96 | 81 | | |||
82 | | ||||
83 | static void | ||||
84 | _activate_state_emit(Evas_Object *obj) | ||||
85 | { | ||||
86 | _radio_widget_signal_emit(obj, "activate,radio"); | ||||
87 | } | ||||
88 | | ||||
97 | static void | 89 | static void | ||
98 | _state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate) | 90 | _state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate) | ||
99 | { | 91 | { | ||
100 | const Eina_List *l; | 92 | const Eina_List *l; | ||
101 | Eina_Bool disabled = EINA_FALSE; | 93 | Eina_Bool disabled = EINA_FALSE; | ||
102 | Evas_Object *child, *selected = NULL; | 94 | Evas_Object *child, *selected = NULL; | ||
103 | 95 | | |||
104 | EINA_LIST_FOREACH(sd->group->radios, l, child) | 96 | EINA_LIST_FOREACH(sd->group->radios, l, child) | ||
105 | { | 97 | { | ||
106 | ELM_RADIO_DATA_GET(child, sdc); | 98 | ELM_RADIO_DATA_GET(child, sdc); | ||
107 | 99 | | |||
108 | if (sdc->state) selected = child; | 100 | if (efl_ui_check_selected_get(child)) selected = child; | ||
109 | if (sdc->value == sd->group->value) | 101 | if (sdc->value == sd->group->value) | ||
110 | { | 102 | { | ||
111 | _state_set(child, EINA_TRUE, activate); | 103 | if (activate) _activate_state_emit(child); | ||
112 | if (!sdc->state) disabled = EINA_TRUE; | 104 | efl_ui_check_selected_set(child, EINA_TRUE); | ||
105 | if (!efl_ui_check_selected_get(child)) disabled = EINA_TRUE; | ||||
106 | } | ||||
107 | else | ||||
108 | { | ||||
109 | if (activate) _activate_state_emit(child); | ||||
110 | efl_ui_check_selected_set(child, EINA_FALSE); | ||||
113 | } | 111 | } | ||
114 | else _state_set(child, EINA_FALSE, activate); | | |||
115 | } | 112 | } | ||
116 | 113 | | |||
117 | if ((disabled) && (selected)) _state_set(selected, 1, activate); | 114 | if ((disabled) && (selected)) | ||
115 | { | ||||
116 | if (activate) _activate_state_emit(selected); | ||||
117 | efl_ui_check_selected_set(selected, EINA_TRUE); | ||||
118 | } | ||||
118 | } | 119 | } | ||
119 | 120 | | |||
120 | static void | 121 | static void | ||
121 | _activate(Evas_Object *obj) | 122 | _activate(Evas_Object *obj) | ||
122 | { | 123 | { | ||
123 | ELM_RADIO_DATA_GET(obj, sd); | 124 | ELM_RADIO_DATA_GET(obj, sd); | ||
124 | 125 | | |||
125 | if (sd->group->value == sd->value) return; | 126 | if (sd->group->value == sd->value) return; | ||
Show All 17 Lines | |||||
143 | static Eina_Bool | 144 | static Eina_Bool | ||
144 | _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) | 145 | _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) | ||
145 | { | 146 | { | ||
146 | _activate(obj); | 147 | _activate(obj); | ||
147 | return EINA_TRUE; | 148 | return EINA_TRUE; | ||
148 | } | 149 | } | ||
149 | 150 | | |||
150 | EOLIAN static Eina_Error | 151 | EOLIAN static Eina_Error | ||
151 | _efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd) | 152 | _efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd EINA_UNUSED) | ||
152 | { | 153 | { | ||
153 | ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC); | 154 | ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC); | ||
154 | Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; | 155 | Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; | ||
155 | int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_CHECK_CLASS)); | 156 | int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_CHECK_CLASS)); | ||
156 | if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; | 157 | if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret; | ||
157 | 158 | | |||
158 | if (elm_widget_is_legacy(obj)) | 159 | if (elm_widget_is_legacy(obj)) | ||
159 | { | 160 | { | ||
160 | if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm"); | 161 | if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm"); | ||
161 | else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm"); | 162 | else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm"); | ||
162 | } | 163 | } | ||
163 | else | 164 | else | ||
164 | { | 165 | { | ||
165 | if (sd->state) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl"); | 166 | if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl"); | ||
166 | else elm_layout_signal_emit(obj, "efl,state,radio,off", "efl"); | 167 | else elm_layout_signal_emit(obj, "efl,state,radio,off", "efl"); | ||
167 | } | 168 | } | ||
168 | 169 | | |||
169 | edje_object_message_signal_process(wd->resize_obj); | 170 | edje_object_message_signal_process(wd->resize_obj); | ||
170 | 171 | | |||
171 | elm_layout_sizing_eval(obj); | 172 | elm_layout_sizing_eval(obj); | ||
172 | 173 | | |||
173 | return int_ret; | 174 | return int_ret; | ||
Show All 17 Lines | 188 | { | |||
191 | if (txt) return strdup(txt); | 192 | if (txt) return strdup(txt); | ||
192 | 193 | | |||
193 | return NULL; | 194 | return NULL; | ||
194 | } | 195 | } | ||
195 | 196 | | |||
196 | static char * | 197 | static char * | ||
197 | _access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) | 198 | _access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) | ||
198 | { | 199 | { | ||
199 | ELM_RADIO_DATA_GET(obj, sd); | | |||
200 | | ||||
201 | if (elm_widget_disabled_get(obj)) return strdup(E_("State: Disabled")); | 200 | if (elm_widget_disabled_get(obj)) return strdup(E_("State: Disabled")); | ||
202 | if (sd->state) return strdup(E_("State: On")); | 201 | if (efl_ui_check_selected_get(obj)) return strdup(E_("State: On")); | ||
203 | 202 | | |||
204 | return strdup(E_("State: Off")); | 203 | return strdup(E_("State: Off")); | ||
205 | } | 204 | } | ||
206 | 205 | | |||
207 | EOLIAN static Eo * | 206 | EOLIAN static Eo * | ||
208 | _efl_ui_radio_efl_object_constructor(Eo *obj, Efl_Ui_Radio_Data *pd) | 207 | _efl_ui_radio_efl_object_constructor(Eo *obj, Efl_Ui_Radio_Data *pd) | ||
209 | { | 208 | { | ||
210 | if (!elm_widget_theme_klass_get(obj)) | 209 | if (!elm_widget_theme_klass_get(obj)) | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 260 | else if (sd->group == sdg->group) | |||
262 | return; | 261 | return; | ||
263 | else | 262 | else | ||
264 | { | 263 | { | ||
265 | sd->group->radios = eina_list_remove(sd->group->radios, obj); | 264 | sd->group->radios = eina_list_remove(sd->group->radios, obj); | ||
266 | if (!sd->group->radios) free(sd->group); | 265 | if (!sd->group->radios) free(sd->group); | ||
267 | sd->group = sdg->group; | 266 | sd->group = sdg->group; | ||
268 | sd->group->radios = eina_list_append(sd->group->radios, obj); | 267 | sd->group->radios = eina_list_append(sd->group->radios, obj); | ||
269 | } | 268 | } | ||
270 | if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE); | 269 | if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE); | ||
271 | else _state_set(obj, EINA_FALSE, EINA_FALSE); | 270 | else efl_ui_check_selected_set(obj, EINA_FALSE); | ||
272 | } | 271 | } | ||
273 | 272 | | |||
274 | EOLIAN static void | 273 | EOLIAN static void | ||
275 | _efl_ui_radio_state_value_set(Eo *obj, Efl_Ui_Radio_Data *sd, int value) | 274 | _efl_ui_radio_state_value_set(Eo *obj, Efl_Ui_Radio_Data *sd, int value) | ||
276 | { | 275 | { | ||
277 | sd->value = value; | 276 | sd->value = value; | ||
278 | if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE); | 277 | if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE); | ||
279 | else _state_set(obj, EINA_FALSE, EINA_FALSE); | 278 | else efl_ui_check_selected_set(obj, EINA_FALSE); | ||
280 | } | 279 | } | ||
281 | 280 | | |||
282 | EOLIAN static int | 281 | EOLIAN static int | ||
283 | _efl_ui_radio_state_value_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd) | 282 | _efl_ui_radio_state_value_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd) | ||
284 | { | 283 | { | ||
285 | return sd->value; | 284 | return sd->value; | ||
286 | } | 285 | } | ||
287 | 286 | | |||
▲ Show 20 Lines • Show All 212 Lines • Show Last 20 Lines |