rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=574dba860d395bae5de140e5e8b3dfa9cfd893ee

commit 574dba860d395bae5de140e5e8b3dfa9cfd893ee
Author: Vitalii Vorobiov <vi.vorob...@samsung.com>
Date:   Wed Dec 16 13:28:56 2015 +0200

    demo_group: load list of swallow and text parts
---
 src/bin/ui/demo_group.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 152 insertions(+), 5 deletions(-)

diff --git a/src/bin/ui/demo_group.c b/src/bin/ui/demo_group.c
index 6d0305f..399dd2f 100644
--- a/src/bin/ui/demo_group.c
+++ b/src/bin/ui/demo_group.c
@@ -32,17 +32,84 @@ typedef struct
    Evas_Object *layout;
    Evas_Object *genlist;
 
-   Elm_Genlist_Item_Class *itc_group;
-   Elm_Genlist_Item_Class *itc_text;
-   Elm_Genlist_Item_Class *itc_swallow;
-   Elm_Genlist_Item_Class *itc_signals;
-
    Elm_Object_Item *selected_part_item;
 } Part_Demo_List;
 
+static Elm_Genlist_Item_Class *itc_group;
+static Elm_Genlist_Item_Class *itc_part;
+static Elm_Genlist_Item_Class *itc_part_selected;
+static Elm_Genlist_Item_Class *itc_signals;
+
+static char *
+_group_label_get(void *data,
+                Evas_Object *obj __UNUSED__,
+                const char *pr __UNUSED__)
+{
+   assert(data);
+
+   return strdup(data);
+}
+static char *
+_part_label_get(void *data,
+                Evas_Object *obj __UNUSED__,
+                const char *pr __UNUSED__)
+{
+   Part_ *part = data;
+
+   assert(part != NULL);
+   assert(part->name != NULL);
+
+   return strdup(part->name);
+}
+
+static void
+_on_clicked_double(void *data __UNUSED__,
+                   Evas_Object *obj __UNUSED__,
+                   void *event_info)
+{
+   Elm_Object_Item *glit = (Elm_Object_Item *)event_info;
+
+   if (elm_genlist_item_type_get(glit) == ELM_GENLIST_ITEM_TREE)
+     elm_genlist_item_expanded_set(glit, !elm_genlist_item_expanded_get(glit));
+}
+static void
+_expand_request_cb(void *data __UNUSED__,
+                   Evas_Object *o __UNUSED__,
+                   void *event_info)
+{
+   Elm_Object_Item *glit = event_info;
+   elm_genlist_item_expanded_set(glit, EINA_TRUE);
+}
+static void
+_contract_request_cb(void *data __UNUSED__,
+                     Evas_Object *o __UNUSED__,
+                     void *event_info)
+{
+   Elm_Object_Item *glit = event_info;
+   elm_genlist_item_expanded_set(glit, EINA_FALSE);
+}
+static void
+_contracted_cb(void *data __UNUSED__,
+               Evas_Object *o __UNUSED__,
+               void *event_info)
+{
+   Elm_Object_Item *glit = event_info;
+   elm_genlist_item_subitems_clear(glit);
+}
+static void
+_selected_cb(void *data __UNUSED__,
+             Evas_Object *o __UNUSED__,
+             void *event_info __UNUSED__)
+{
+}
+
 Evas_Object *
 demo_group_add(Group *group)
 {
+   Elm_Object_Item *it_swallow, *it_text;
+   Eina_List *l;
+   Part_ *part;
+
    assert(group != NULL);
    assert(ap.win != NULL);
 
@@ -53,6 +120,86 @@ demo_group_add(Group *group)
 
    evas_object_data_set(pl->layout, DEMO_GROUP_DATA, pl);
 
+   /* add some genlists */
+   if (!itc_group)
+     {
+        itc_group = elm_genlist_item_class_new();
+        itc_group->item_style = "part";
+        itc_group->func.text_get = _group_label_get;
+     }
+
+   if (!itc_part)
+     {
+        itc_part = elm_genlist_item_class_new();
+        itc_part->item_style = "state";
+        itc_part->func.text_get = _part_label_get;
+        itc_part_selected = elm_genlist_item_class_new();
+        itc_part_selected->item_style = "state_selected";
+        itc_part_selected->func.text_get = _part_label_get;
+     }
+   if (!itc_signals)
+     {
+        itc_signals = elm_genlist_item_class_new();
+        itc_signals->item_style = "item";
+        itc_signals->func.text_get = _group_label_get;
+     }
+   /* filling genlist */
+   pl->genlist = elm_genlist_add(pl->layout);
+   elm_genlist_homogeneous_set(pl->layout, true);
+   elm_scroller_policy_set(pl->genlist, ELM_SCROLLER_POLICY_OFF, 
ELM_SCROLLER_POLICY_AUTO);
+   evas_object_show(pl->genlist);
+   elm_object_content_set(pl->layout, pl->genlist);
+   evas_object_smart_callback_add(pl->genlist, "clicked,double", 
_on_clicked_double, pl);
+   evas_object_smart_callback_add(pl->genlist, "expand,request", 
_expand_request_cb, pl);
+   evas_object_smart_callback_add(pl->genlist, "contract,request", 
_contract_request_cb, pl);
+   evas_object_smart_callback_add(pl->genlist, "contracted", _contracted_cb, 
pl);
+   evas_object_smart_callback_add(pl->genlist, "selected", _selected_cb, pl);
+   evas_object_data_set(pl->genlist, DEMO_GROUP_DATA, pl);
+
+   it_swallow = elm_genlist_item_append(pl->genlist,
+                                        itc_group,
+                                        eina_stringshare_add("Swallows"),
+                                        NULL,
+                                        ELM_GENLIST_ITEM_TREE,
+                                        NULL,
+                                        NULL);
+   it_text = elm_genlist_item_append(pl->genlist,
+                                     itc_group,
+                                     eina_stringshare_add("Text"),
+                                     NULL,
+                                     ELM_GENLIST_ITEM_TREE,
+                                     NULL,
+                                     NULL);
+   elm_genlist_item_append(pl->genlist,
+                           itc_group,
+                           eina_stringshare_add("Signals"),
+                           NULL,
+                           ELM_GENLIST_ITEM_TREE,
+                           NULL,
+                           NULL);
+
+   EINA_LIST_FOREACH(group->parts, l, part)
+     {
+        if ((part->type == EDJE_PART_TYPE_TEXT) || (part->type == 
EDJE_PART_TYPE_TEXTBLOCK))
+          elm_genlist_item_append(pl->genlist,
+                                  itc_part,
+                                  part,
+                                  it_text,
+                                  ELM_GENLIST_ITEM_NONE,
+                                  NULL,
+                                  NULL);
+        else if (part->type == EDJE_PART_TYPE_SWALLOW)
+          elm_genlist_item_append(pl->genlist,
+                                  itc_part,
+                                  part,
+                                  it_swallow,
+                                  ELM_GENLIST_ITEM_NONE,
+                                  NULL,
+                                  NULL);
+     }
+
+   elm_object_text_set(pl->layout, pl->group->name);
+
    pl->group = group;
 
    return pl->layout;

-- 


Reply via email to