Adding selection API to E_Icon
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>
Fri, 18 Jun 2010 22:39:00 +0000 (22:39 +0000)
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>
Fri, 18 Jun 2010 22:39:00 +0000 (22:39 +0000)
SVN revision: 49755

src/bin/e_icon.c
src/bin/e_icon.h
src/bin/e_ilist.c
src/bin/e_menu.c
src/bin/e_widget_toolbar.c

index 2e7420a..20e508b 100644 (file)
@@ -308,6 +308,20 @@ e_icon_scale_size_get(const Evas_Object *obj)
    return sd->size;
 }
 
+EAPI void
+e_icon_selected_set(const Evas_Object *obj, Eina_Bool selected)
+{
+   E_Smart_Data *sd = evas_object_smart_data_get(obj);
+   if (!sd) return;
+   if (strcmp(evas_object_type_get(sd->obj), "edje"))
+     return;
+
+   if (selected)
+     edje_object_signal_emit(sd->obj, "e,state,selected", "e");
+   else
+     edje_object_signal_emit(sd->obj, "e,state,unselected", "e");
+}
+
 /* local subsystem globals */
 static void
 _e_icon_smart_reconfigure(E_Smart_Data *sd)
index 6c9d9dc..070eabb 100644 (file)
@@ -27,6 +27,7 @@ EAPI void         e_icon_data_set         (Evas_Object *obj, void *data, int w,
 EAPI void        *e_icon_data_get         (const Evas_Object *obj, int *w, int *h);
 EAPI void         e_icon_scale_size_set   (Evas_Object *obj, int size);
 EAPI int          e_icon_scale_size_get   (const Evas_Object *obj);
+EAPI void         e_icon_selected_set    (const Evas_Object *obj, Eina_Bool selected);
 
 #endif
 #endif
index c626c1c..b9933b4 100644 (file)
@@ -49,6 +49,9 @@ static void _e_typebuf_timer_update (Evas_Object *obj);
 static void _e_typebuf_timer_delete (Evas_Object *obj);
 static void _e_typebuf_clean        (Evas_Object *obj);
 
+static void _item_select           (E_Ilist_Item *si);
+static void _item_unselect         (E_Ilist_Item *si);
+
 static Evas_Smart *_e_smart = NULL;
 
 EAPI Evas_Object *
@@ -479,7 +482,6 @@ e_ilist_unselect(Evas_Object *obj)
 {
    Eina_List *l = NULL;
    E_Ilist_Item *si = NULL;
-   const char *stacking, *selectraise;
 
    API_ENTRY return;
 
@@ -489,15 +491,7 @@ e_ilist_unselect(Evas_Object *obj)
      {
        if (!si) continue;
        if (!si->selected) continue;
-       edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
-       si->selected = 0;
-       stacking = edje_object_data_get(si->o_base, "stacking");
-       selectraise = edje_object_data_get(si->o_base, "selectraise");
-       if ((selectraise) && (!strcmp(selectraise, "on")))
-         {
-            if ((stacking) && (!strcmp(stacking, "below")))
-              evas_object_lower(si->o_base);
-         }
+       _item_unselect(si);
      }
    sd->selected = -1;
 }
@@ -508,7 +502,6 @@ e_ilist_selected_set(Evas_Object *obj, int n)
    E_Ilist_Item *si = NULL;
    Eina_List *l = NULL;
    int i;
-   const char *stacking, *selectraise;
 
    API_ENTRY return;
    if (!sd->items) return;
@@ -521,15 +514,7 @@ e_ilist_selected_set(Evas_Object *obj, int n)
      {
        if (!si) continue;
        if ((!si->selected) || (si->header)) continue;
-       edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
-       si->selected = 0;
-       stacking = edje_object_data_get(si->o_base, "stacking");
-       selectraise = edje_object_data_get(si->o_base, "selectraise");
-       if ((selectraise) && (!strcmp(selectraise, "on")))
-         {
-            if ((stacking) && (!strcmp(stacking, "below")))
-              evas_object_lower(si->o_base);
-         }
+       _item_unselect(si);
      }
    sd->selected = -1;
    if (!(si = eina_list_nth(sd->items, n))) return;
@@ -541,11 +526,7 @@ e_ilist_selected_set(Evas_Object *obj, int n)
      if (!(si = eina_list_nth(sd->items, n))) return;
    if (si->header) return;
 
-   si->selected = 1;
-   selectraise = edje_object_data_get(si->o_base, "selectraise");
-   if ((selectraise) && (!strcmp(selectraise, "on")))
-     evas_object_raise(si->o_base);
-   edje_object_signal_emit(si->o_base, "e,state,selected", "e");
+   _item_select(si);
    sd->selected = n;
    if (si->func_hilight) si->func_hilight(si->data, si->data2);
    if (sd->selector) return;
@@ -893,7 +874,6 @@ e_ilist_multi_select(Evas_Object *obj, int n)
 {
    E_Ilist_Item *si = NULL;
    int i;
-   const char *stacking, *selectraise;
 
    API_ENTRY return;
    if ((!sd->items) || (!sd->multi_select)) return;
@@ -905,17 +885,9 @@ e_ilist_multi_select(Evas_Object *obj, int n)
    if (!(si = eina_list_nth(sd->items, n))) return;
    if (si->header) return;
    sd->selected = n;
-   selectraise = edje_object_data_get(si->o_base, "selectraise");
    if (si->selected) 
      {
-       edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
-       si->selected = 0;
-       stacking = edje_object_data_get(si->o_base, "stacking");
-       if ((selectraise) && (!strcmp(selectraise, "on")))
-         {
-            if ((stacking) && (!strcmp(stacking, "below")))
-              evas_object_lower(si->o_base);
-         }
+       _item_unselect(si);
        if (si->func_hilight) si->func_hilight(si->data, si->data2);
        if (sd->selector) return;
        if (!sd->on_hold)
@@ -924,10 +896,7 @@ e_ilist_multi_select(Evas_Object *obj, int n)
          }
        return;
      }
-   si->selected = 1;
-   if ((selectraise) && (!strcmp(selectraise, "on")))
-     evas_object_raise(si->o_base);
-   edje_object_signal_emit(si->o_base, "e,state,selected", "e");
+   _item_select(si);
    if (si->func_hilight) si->func_hilight(si->data, si->data2);
    if (sd->selector) return;
    if (!sd->on_hold)
@@ -1426,3 +1395,43 @@ _e_typebuf_clean(Evas_Object *obj)
    sd->typebuf.size = 0;
    _e_typebuf_timer_delete(obj);
 }
+
+static void
+_item_select(E_Ilist_Item *si)
+{
+   const char *selectraise;
+   si->selected = EINA_TRUE;
+   selectraise = edje_object_data_get(si->o_base, "selectraise");
+   if ((selectraise) && (!strcmp(selectraise, "on")))
+     evas_object_raise(si->o_base);
+   edje_object_signal_emit(si->o_base, "e,state,selected", "e");
+   if (si->o_icon)
+     {
+       if (strcmp(evas_object_type_get(si->o_icon), "e_icon"))
+         edje_object_signal_emit(si->o_icon, "e,state,selected", "e");
+       else
+         e_icon_selected_set(si->o_icon, EINA_TRUE);
+     }
+}
+
+static void
+_item_unselect(E_Ilist_Item *si)
+{
+   const char *stacking, *selectraise;
+   si->selected = EINA_FALSE;
+   edje_object_signal_emit(si->o_base, "e,state,unselected", "e");
+   if (si->o_icon)
+     {
+        if (strcmp(evas_object_type_get(si->o_icon), "e_icon"))
+          edje_object_signal_emit(si->o_icon, "e,state,unselected", "e");
+        else
+          e_icon_selected_set(si->o_icon, EINA_FALSE);
+     }
+   stacking = edje_object_data_get(si->o_base, "stacking");
+   selectraise = edje_object_data_get(si->o_base, "selectraise");
+   if ((selectraise) && (!strcmp(selectraise, "on")))
+     {
+        if ((stacking) && (!strcmp(stacking, "below")))
+          evas_object_lower(si->o_base);
+     }
+}
index ebaa1dc..9920df3 100644 (file)
@@ -852,7 +852,12 @@ e_menu_item_active_set(E_Menu_Item *mi, int active)
        if (mi->toggle_object)
          edje_object_signal_emit(mi->toggle_object, "e,state,selected", "e");
        if (mi->icon_key)
-         edje_object_signal_emit(mi->icon_object, "e,state,selected", "e");
+         {
+            if (strcmp(evas_object_type_get(mi->icon_object), "e_icon"))
+              edje_object_signal_emit(mi->icon_object, "e,state,selected", "e");
+            else
+              e_icon_selected_set(mi->icon_object, EINA_TRUE);
+         }
        edje_object_signal_emit(mi->menu->bg_object, "e,state,selected", "e");
        _e_menu_submenu_activate(mi);
      }
@@ -871,7 +876,12 @@ e_menu_item_active_set(E_Menu_Item *mi, int active)
        if (mi->toggle_object)
          edje_object_signal_emit(mi->toggle_object, "e,state,unselected", "e");
        if (mi->icon_key)
-         edje_object_signal_emit(mi->icon_object, "e,state,unselected", "e");
+         {
+            if (strcmp(evas_object_type_get(mi->icon_object), "e_icon"))
+              edje_object_signal_emit(mi->icon_object, "e,state,unselected", "e");
+            else
+              e_icon_selected_set(mi->icon_object, EINA_FALSE);
+         }
        edje_object_signal_emit(mi->menu->bg_object, "e,state,unselected", "e");
        _e_menu_submenu_deactivate(mi);
      }
index 9fee6a5..d28e2ab 100644 (file)
@@ -525,7 +525,10 @@ _item_select(Item *it)
 {
    it->selected = EINA_TRUE;
    edje_object_signal_emit(it->o_base, "e,state,selected", "e");
-   edje_object_signal_emit(it->o_icon, "e,state,selected", "e");
+   if (strcmp(evas_object_type_get(it->o_icon), "e_icon"))
+     edje_object_signal_emit(it->o_icon, "e,state,selected", "e");
+   else
+     e_icon_selected_set(it->o_icon, EINA_TRUE);
    _item_show(it);
    if (it->func) it->func((void *)it->data1, (void *)it->data2);
 }
@@ -535,5 +538,8 @@ _item_unselect(Item *it)
 {
    it->selected = EINA_FALSE;
    edje_object_signal_emit(it->o_base, "e,state,unselected", "e");
-   edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
+   if (strcmp(evas_object_type_get(it->o_icon), "e_icon"))
+     edje_object_signal_emit(it->o_icon, "e,state,unselected", "e");
+   else
+     e_icon_selected_set(it->o_icon, EINA_FALSE);
 }