[genlist] apply r71140 with local enhancement
[framework/uifw/elementary.git] / src / lib / elm_check.c
index d4567b8..efa3ccc 100644 (file)
@@ -98,6 +98,13 @@ _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
 static void
 _theme_hook(Evas_Object *obj)
 {
+   unsigned int counter = 0;
+   unsigned int i = 1;
+   unsigned int length = 0;
+   const char *str = NULL;
+   char labels[128] ;
+   char buffer[PATH_MAX]={'\0',};
+   char s1[PATH_MAX] = {'\0',};
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    _elm_widget_mirrored_reload(obj);
@@ -115,13 +122,30 @@ _theme_hook(Evas_Object *obj)
      edje_object_signal_emit(wd->chk, "elm,state,text,visible", "elm");
    else
      edje_object_signal_emit(wd->chk, "elm,state,text,hidden", "elm");
-   edje_object_part_text_set(wd->chk, "elm.text", wd->label);
-   edje_object_part_text_set(wd->chk, "elm.ontext", wd->ontext);
-   edje_object_part_text_set(wd->chk, "elm.offtext", wd->offtext);
+   edje_object_part_text_escaped_set(wd->chk, "elm.text", wd->label);
+   edje_object_part_text_escaped_set(wd->chk, "elm.ontext", wd->ontext);
+   edje_object_part_text_escaped_set(wd->chk, "elm.offtext", wd->offtext);
    if (elm_widget_disabled_get(obj))
      edje_object_signal_emit(wd->chk, "elm,state,disabled", "elm");
    edje_object_message_signal_process(wd->chk);
    edje_object_scale_set(wd->chk, elm_widget_scale_get(obj) * _elm_config->scale);
+   //introduced internationalization of additional text parts used in style
+   while (1)
+     {
+        // s1 is  used  to store part name while buffer is used to store the part's value string
+        snprintf(labels,sizeof(labels),"label_%d",i++);
+        str = edje_object_data_get(wd->chk,labels);
+        if (!str) break;
+        length = strlen(str);
+        while ((str[counter]!= ' ') && (counter < length))
+          counter++;
+        if (counter == length)
+          continue;
+        strncpy(s1, str, counter);
+        s1[counter] = '\0';
+        strncpy(buffer, str + counter, sizeof(buffer));
+        edje_object_part_text_set(wd->chk, s1, E_(buffer));
+     }
    _sizing_eval(obj);
 }
 
@@ -210,6 +234,31 @@ _activate_hook(Evas_Object *obj)
 }
 
 static void
+_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   edje_object_signal_emit(wd->chk, emission, source);
+}
+
+static void
+_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   edje_object_signal_callback_add(wd->chk, emission, source, func_cb, data);
+}
+
+static void
+_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   edje_object_signal_callback_del_full(wd->chk, emission, source, func_cb,
+                                        data);
+}
+
+static void
 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
@@ -258,11 +307,7 @@ _content_unset_hook(Evas_Object *obj, const char *part)
    if (!wd->icon) return NULL;
    Evas_Object *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->chk, wd->icon);
-   wd->icon = NULL;
+   edje_object_part_unswallow(wd->chk, icon);
    return icon;
 }
 
@@ -320,17 +365,17 @@ _elm_check_label_set(Evas_Object *obj, const char *item, const char *label)
         else
            edje_object_signal_emit(wd->chk, "elm,state,text,hidden", "elm");
         edje_object_message_signal_process(wd->chk);
-        edje_object_part_text_set(wd->chk, "elm.text", label);
+        edje_object_part_text_escaped_set(wd->chk, "elm.text", label);
      }
    else if ((item) && (!strcmp(item, "on")))
      {
         eina_stringshare_replace(&wd->ontext, label);
-        edje_object_part_text_set(wd->chk, "elm.ontext", wd->ontext);
+        edje_object_part_text_escaped_set(wd->chk, "elm.ontext", wd->ontext);
      }
    else if ((item) && (!strcmp(item, "off")))
      {
         eina_stringshare_replace(&wd->offtext, label);
-        edje_object_part_text_set(wd->chk, "elm.offtext", wd->offtext);
+        edje_object_part_text_escaped_set(wd->chk, "elm.offtext", wd->offtext);
      }
    _sizing_eval(obj);
 }
@@ -409,6 +454,9 @@ elm_check_add(Evas_Object *parent)
    elm_widget_can_focus_set(obj, EINA_TRUE);
    elm_widget_activate_hook_set(obj, _activate_hook);
    elm_widget_event_hook_set(obj, _event_hook);
+   elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
+   elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
+   elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
    elm_widget_text_set_hook_set(obj, _elm_check_label_set);
    elm_widget_text_get_hook_set(obj, _elm_check_label_get);
    elm_widget_content_set_hook_set(obj, _content_set_hook);
@@ -445,38 +493,6 @@ elm_check_add(Evas_Object *parent)
 }
 
 EAPI void
-elm_check_states_labels_set(Evas_Object *obj, const char *ontext, const char *offtext)
-{
-   _elm_check_label_set(obj, "on", ontext);
-   _elm_check_label_set(obj, "off", offtext);
-}
-
-EAPI void
-elm_check_states_labels_get(const Evas_Object *obj, const char **ontext, const char **offtext)
-{
-   if (ontext) *ontext = _elm_check_label_get(obj, "on");
-   if (offtext) *offtext = _elm_check_label_get(obj, "off");
-}
-
-EAPI void
-elm_check_icon_set(Evas_Object *obj, Evas_Object *icon)
-{
-   _content_set_hook(obj, "icon", icon);
-}
-
-EAPI Evas_Object *
-elm_check_icon_get(const Evas_Object *obj)
-{
-   return _content_get_hook(obj, "icon");
-}
-
-EAPI Evas_Object *
-elm_check_icon_unset(Evas_Object *obj)
-{
-   return _content_unset_hook(obj, "icon");
-}
-
-EAPI void
 elm_check_state_set(Evas_Object *obj, Eina_Bool state)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);