edje_object_signal_emit(wd->radio, "elm,state,text,visible", "elm");
else
edje_object_signal_emit(wd->radio, "elm,state,text,hidden", "elm");
- edje_object_part_text_set(wd->radio, "elm.text", wd->label);
+ edje_object_part_text_escaped_set(wd->radio, "elm.text", wd->label);
if (elm_widget_disabled_get(obj))
{
edje_object_signal_emit(wd->radio, "elm,state,disabled", "elm");
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->group->value == wd->value) return;
- wd->group->value = wd->value;
- if (wd->group->valuep) *(wd->group->valuep) = wd->group->value;
- _state_set_all(wd);
- evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
+ if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
+ (_elm_access_2nd_click_timeout(obj)))
+ {
+ wd->group->value = wd->value;
+ if (wd->group->valuep) *(wd->group->valuep) = wd->group->value;
+ _state_set_all(wd);
+ if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
+ _elm_access_say(E_("State: On"));
+ evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
+ }
}
static void
edje_object_signal_emit(wd->radio, "elm,state,text,hidden", "elm");
edje_object_message_signal_process(wd->radio);
}
- edje_object_part_text_set(wd->radio, "elm.text", label);
+ edje_object_part_text_escaped_set(wd->radio, "elm.text", label);
_sizing_eval(obj);
}
return wd->label;
}
+static char *
+_access_info_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Widget_Item *item __UNUSED__)
+{
+ const char *txt = elm_widget_access_info_get(obj);
+ if (!txt) txt = _elm_radio_label_get(obj, NULL);
+ if (txt) return strdup(txt);
+ return NULL;
+}
+
+static char *
+_access_state_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Widget_Item *item __UNUSED__)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (elm_widget_disabled_get(obj))
+ return strdup(E_("State: Disabled"));
+ if (wd->state)
+ return strdup(E_("State: On"));
+ return strdup(E_("State: Off"));
+}
+
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd;
+
+ if (part && strcmp(part, "icon")) return;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->icon == content) return;
+ if (wd->icon) evas_object_del(wd->icon);
+ wd->icon = content;
+ if (content)
+ {
+ elm_widget_sub_object_add(obj, content);
+ evas_object_event_callback_add(content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_swallow(wd->radio, "elm.swallow.content", content);
+ edje_object_signal_emit(wd->radio, "elm,state,icon,visible", "elm");
+ edje_object_message_signal_process(wd->radio);
+ }
+ _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+
+ if (part && strcmp(part, "icon")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->icon;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+ Evas_Object *icon;
+ if (part && strcmp(part, "icon")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (!wd->icon) return NULL;
+ icon = wd->icon;
+ elm_widget_sub_object_del(obj, wd->icon);
+ evas_object_event_callback_del_full(wd->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_unswallow(wd->radio, wd->icon);
+ wd->icon = NULL;
+ return icon;
+}
+
EAPI Evas_Object *
elm_radio_add(Evas_Object *parent)
{
elm_widget_event_hook_set(obj, _event_hook);
elm_widget_text_set_hook_set(obj, _elm_radio_label_set);
elm_widget_text_get_hook_set(obj, _elm_radio_label_get);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->radio = edje_object_add(e);
_elm_theme_object_set(obj, wd->radio, "radio", "base", "default");
// TODO: convert Elementary to subclassing of Evas_Smart_Class
// TODO: and save some bytes, making descriptions per-class and not instance!
evas_object_smart_callbacks_descriptions_set(obj, _signals);
- return obj;
-}
-EAPI void
-elm_radio_label_set(Evas_Object *obj, const char *label)
-{
- _elm_radio_label_set(obj, NULL, label);
-}
-
-EAPI const char *
-elm_radio_label_get(const Evas_Object *obj)
-{
- return _elm_radio_label_get(obj, NULL);
-}
-
-EAPI void
-elm_radio_icon_set(Evas_Object *obj, Evas_Object *icon)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->icon == icon) return;
- if (wd->icon) evas_object_del(wd->icon);
- wd->icon = icon;
- if (icon)
- {
- elm_widget_sub_object_add(obj, icon);
- evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _changed_size_hints, obj);
- edje_object_part_swallow(wd->radio, "elm.swallow.content", icon);
- edje_object_signal_emit(wd->radio, "elm,state,icon,visible", "elm");
- edje_object_message_signal_process(wd->radio);
- }
- _sizing_eval(obj);
-}
-
-EAPI Evas_Object *
-elm_radio_icon_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return wd->icon;
-}
+ _elm_access_object_register(obj, wd->radio);
+ _elm_access_text_set(_elm_access_object_get(obj),
+ ELM_ACCESS_TYPE, E_("Radio"));
+ _elm_access_callback_set(_elm_access_object_get(obj),
+ ELM_ACCESS_INFO, _access_info_cb, obj);
+ _elm_access_callback_set(_elm_access_object_get(obj),
+ ELM_ACCESS_STATE, _access_state_cb, obj);
-EAPI Evas_Object *
-elm_radio_icon_unset(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- if (!wd->icon) return NULL;
- Evas_Object *icon = wd->icon;
- elm_widget_sub_object_del(obj, wd->icon);
- edje_object_part_unswallow(wd->radio, wd->icon);
- wd->icon = NULL;
- return icon;
+ return obj;
}
EAPI void
wd->group->valuep = NULL;
}
}
+
+EAPI Evas_Object *
+elm_radio_selected_object_get(Evas_Object *obj)
+{
+ Eina_List *l;
+ Evas_Object *child;
+ Widget_Data *wd2;
+
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+
+ EINA_LIST_FOREACH(wd->group->radios, l, child)
+ {
+ wd2 = elm_widget_data_get(child);
+ if (wd2->value == wd->group->value)
+ return child;
+ }
+ return NULL;
+}