Elementary Toggle: Don't use deprecated functions
authorbdilly <bdilly@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 24 Oct 2011 23:41:11 +0000 (23:41 +0000)
committerMike McCormack <mj.mccormack@samsung.com>
Tue, 15 Nov 2011 06:26:40 +0000 (15:26 +0900)
If we need to add functions born deprecated because it will
make other developers life easier, ok. But using these
deprecated functions inside our project isn't nice.

git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@64363 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/test_toggle.c
src/edje_externals/elm_toggle.c
src/lib/elm_toggle.c

index a31ea81..92c0ba0 100644 (file)
@@ -67,8 +67,8 @@ test_toggle(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
 
    tg = elm_toggle_add(win);
    elm_object_text_set(tg, "Label Only");
-   elm_toggle_states_labels_set(tg, "Big long fun times label",
-                                "Small long happy fun label");
+   elm_object_text_part_set(tg, "on", "Big long fun times label");
+   elm_object_text_part_set(tg, "off", "Small long happy fun label");
    elm_box_pack_end(bx, tg);
    evas_object_show(tg);
 
index 9646e19..4d0a29d 100644 (file)
@@ -26,17 +26,10 @@ external_toggle_state_set(void *data __UNUSED__, Evas_Object *obj, const void *f
    if (p->icon)
      elm_object_content_set(obj, p->icon);
 
-   if ((p->on) && (p->off))
-     elm_toggle_states_labels_set(obj, p->on, p->off);
-   else if ((p->on) || (p->off))
-     {
-       const char *on, *off;
-       elm_toggle_states_labels_get(obj, &on, &off);
-       if (p->on)
-         elm_toggle_states_labels_set(obj, p->on, off);
-       else
-         elm_toggle_states_labels_set(obj, on, p->off);
-     }
+   if (p->on)
+     elm_object_text_part_set(obj, "on", p->on);
+   if (p->off)
+     elm_object_text_part_set(obj, "off", p->off);
 
    if (p->state_exists)
      elm_toggle_state_set(obj, p->state);
@@ -67,9 +60,7 @@ external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ex
      {
        if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
          {
-            const char *on, *off;
-            elm_toggle_states_labels_get(obj, &on, &off);
-            elm_toggle_states_labels_set(obj, param->s, off);
+            elm_object_text_part_set(obj, "on", param->s);
             return EINA_TRUE;
          }
      }
@@ -77,9 +68,7 @@ external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ex
      {
        if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
          {
-            const char *on, *off;
-            elm_toggle_states_labels_get(obj, &on, &off);
-            elm_toggle_states_labels_set(obj, on, param->s);
+            elm_object_text_part_set(obj, "off", param->s);
             return EINA_TRUE;
          }
      }
@@ -118,9 +107,7 @@ external_toggle_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_Ex
      {
        if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
          {
-            const char *on, *off;
-            elm_toggle_states_labels_get(obj, &on, &off);
-            param->s = on;
+            param->s = elm_object_text_part_get(obj, "on");
             return EINA_TRUE;
          }
      }
@@ -128,9 +115,7 @@ external_toggle_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_Ex
      {
        if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
          {
-            const char *on, *off;
-            elm_toggle_states_labels_get(obj, &on, &off);
-            param->s = off;
+            param->s = elm_object_text_part_get(obj, "off");
             return EINA_TRUE;
          }
      }
index 1e3c48c..82c25bd 100644 (file)
@@ -8,7 +8,8 @@ elm_toggle_add(Evas_Object *parent)
 
    obj = elm_check_add(parent);
    elm_object_style_set(obj, "toggle");
-   elm_check_states_labels_set(obj, E_("ON"), E_("OFF"));
+   elm_object_text_part_set(obj, "on", E_("ON"));
+   elm_object_text_part_set(obj, "off", E_("OFF"));
    return obj;
 }
 
@@ -45,14 +46,16 @@ elm_toggle_icon_unset(Evas_Object *obj)
 EAPI void
 elm_toggle_states_labels_set(Evas_Object *obj, const char *onlabel, const char *offlabel)
 {
-   elm_check_states_labels_set(obj, onlabel, offlabel);
+   elm_object_text_part_set(obj, "on", onlabel);
+   elm_object_text_part_set(obj, "off", offlabel);
 }
 
 
 EAPI void
 elm_toggle_states_labels_get(const Evas_Object *obj, const char **onlabel, const char **offlabel)
 {
-   elm_check_states_labels_get(obj, onlabel, offlabel);
+   if (onlabel) *onlabel = elm_object_text_part_get(obj, "on");
+   if (offlabel) *offlabel = elm_object_text_part_get(obj, "off");
 }
 
 EAPI void