From: raster Date: Tue, 6 Mar 2012 06:30:43 +0000 (+0000) Subject: lets update genlist/grid examples to use the new class thing. X-Git-Tag: REL_F_I9500_20120323_1~17^2~357 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b5726ce61015a9c93436a4072cc45f3c2fabe16;p=framework%2Fuifw%2Felementary.git lets update genlist/grid examples to use the new class thing. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68774 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/examples/gengrid_example.c b/src/examples/gengrid_example.c index 37ee232..b75734c 100644 --- a/src/examples/gengrid_example.c +++ b/src/examples/gengrid_example.c @@ -35,8 +35,8 @@ static const char *imgs[9] = "wood_01.jpg", }; -static Elm_Gengrid_Item_Class gic; -Evas_Object *before_bt, *after_bt; +static Elm_Gengrid_Item_Class *gic = NULL; +static Evas_Object *before_bt, *after_bt; static void _on_done(void *data __UNUSED__, @@ -170,7 +170,7 @@ _before_bt_clicked(void *data, return; it = _item_new(); - elm_gengrid_item_insert_before(grid, &gic, it, sel, _grid_sel, NULL); + elm_gengrid_item_insert_before(grid, gic, it, sel, _grid_sel, NULL); } /* "insert after" callback */ @@ -188,7 +188,7 @@ _after_bt_clicked(void *data, return; it = _item_new(); - elm_gengrid_item_insert_after(grid, &gic, it, sel, _grid_sel, NULL); + elm_gengrid_item_insert_after(grid, gic, it, sel, _grid_sel, NULL); } /* prepend an item */ @@ -201,7 +201,7 @@ _prepend_bt_clicked(void *data, Evas_Object *grid = data; it = _item_new(); - elm_gengrid_item_prepend(grid, &gic, it, _grid_sel, NULL); + elm_gengrid_item_prepend(grid, gic, it, _grid_sel, NULL); } /* append an item */ @@ -213,7 +213,7 @@ _append_bt_clicked(void *data, Evas_Object *grid = data; Example_Item *it = _item_new(); - elm_gengrid_item_append(grid, &gic, it, _grid_sel, NULL); + elm_gengrid_item_append(grid, gic, it, _grid_sel, NULL); } /* delete items */ @@ -604,11 +604,15 @@ elm_main(int argc __UNUSED__, _page_change_cb(grid, sl, NULL); evas_object_smart_callback_add(sl, "changed", _page_change_cb, grid); - gic.item_style = "default"; - gic.func.text_get = _grid_label_get; - gic.func.content_get = _grid_content_get; - gic.func.state_get = _grid_state_get; - gic.func.del = _grid_del; + if (!gic) + { + gic = elm_gengrid_item_class_new(); + gic->item_style = "default"; + gic->func.text_get = _grid_label_get; + gic->func.content_get = _grid_content_get; + gic->func.state_get = _grid_state_get; + gic->func.del = _grid_del; + } // we only create the first time its needed. we dont unref/free _append_bt_clicked(grid, NULL, NULL); _append_bt_clicked(grid, NULL, NULL); diff --git a/src/examples/genlist_example_01.c b/src/examples/genlist_example_01.c index e916735..da5d9ad 100644 --- a/src/examples/genlist_example_01.c +++ b/src/examples/genlist_example_01.c @@ -10,7 +10,7 @@ #define N_ITEMS 30 -static Elm_Genlist_Item_Class _itc; +static Elm_Genlist_Item_Class *_itc = NULL; static char * _item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) @@ -57,17 +57,21 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_win_resize_object_add(win, bg); evas_object_show(bg); - _itc.item_style = "default"; - _itc.func.text_get = _item_label_get; - _itc.func.content_get = _item_content_get; - _itc.func.state_get = NULL; - _itc.func.del = NULL; + if (!_itc) + { + _itc = elm_genlist_item_class_new(); + _itc->item_style = "default"; + _itc->func.text_get = _item_label_get; + _itc->func.content_get = _item_content_get; + _itc->func.state_get = NULL; + _itc->func.del = NULL; + } list = elm_genlist_add(win); for (i = 0; i < N_ITEMS; i++) { - elm_genlist_item_append(list, &_itc, + elm_genlist_item_append(list, _itc, (void *)(long)i, NULL, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); diff --git a/src/examples/genlist_example_02.c b/src/examples/genlist_example_02.c index 0148fc5..7be04a7 100644 --- a/src/examples/genlist_example_02.c +++ b/src/examples/genlist_example_02.c @@ -11,7 +11,7 @@ #define N_ITEMS 300 -static Elm_Genlist_Item_Class _itc; +static Elm_Genlist_Item_Class *_itc = NULL; static char * _item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) @@ -114,11 +114,15 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) list = elm_genlist_add(win); - _itc.item_style = "default"; - _itc.func.text_get = _item_label_get; - _itc.func.content_get = _item_content_get; - _itc.func.state_get = NULL; - _itc.func.del = NULL; + if (!_itc) + { + _itc = elm_genlist_item_class_new(); + _itc->item_style = "default"; + _itc->func.text_get = _item_label_get; + _itc->func.content_get = _item_content_get; + _itc->func.state_get = NULL; + _itc->func.del = NULL; + } Eina_Bool hbounce, vbounce; Elm_Scroller_Policy hp, vp; @@ -155,7 +159,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) for (i = 0; i < N_ITEMS; i++) { - elm_genlist_item_append(list, &_itc, + elm_genlist_item_append(list, _itc, (void *)(long)i, NULL, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); diff --git a/src/examples/genlist_example_03.c b/src/examples/genlist_example_03.c index 946fa84..1f67c8c 100644 --- a/src/examples/genlist_example_03.c +++ b/src/examples/genlist_example_03.c @@ -10,7 +10,7 @@ #define N_ITEMS 30 -static Elm_Genlist_Item_Class _itc; +static Elm_Genlist_Item_Class *_itc = NULL; static char * _item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part) @@ -71,7 +71,7 @@ _genlist_fill(Evas_Object *list) for (i = 0; i < N_ITEMS; i++) { - elm_genlist_item_append(list, &_itc, + elm_genlist_item_append(list, _itc, (void *)(long)i, NULL, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -102,12 +102,16 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_win_resize_object_add(win, box); evas_object_show(box); - _itc.item_style = "double_label"; - _itc.func.text_get = _item_label_get; - _itc.func.content_get = _item_content_get; - _itc.func.state_get = NULL; - _itc.func.del = NULL; - + if (!_itc) + { + _itc = elm_genlist_item_class_new(); + _itc->item_style = "double_label"; + _itc->func.text_get = _item_label_get; + _itc->func.content_get = _item_content_get; + _itc->func.state_get = NULL; + _itc->func.del = NULL; + } + list = _genlist_add(box); _genlist_fill(list); diff --git a/src/examples/genlist_example_04.c b/src/examples/genlist_example_04.c index df4a96e..7104d3d 100644 --- a/src/examples/genlist_example_04.c +++ b/src/examples/genlist_example_04.c @@ -10,8 +10,8 @@ #define N_ITEMS 300 -static Elm_Genlist_Item_Class _itc; -static Elm_Genlist_Item_Class _itc_group; +static Elm_Genlist_Item_Class *_itc = NULL; +static Elm_Genlist_Item_Class *_itc_group = NULL; static int nitems = 0; static char * @@ -81,7 +81,7 @@ _append_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) { Evas_Object *list = data; - elm_genlist_item_append(list, &_itc, + elm_genlist_item_append(list, _itc, (void *)(long)nitems++, NULL, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -93,7 +93,7 @@ _prepend_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) { Evas_Object *list = data; - elm_genlist_item_prepend(list, &_itc, + elm_genlist_item_prepend(list, _itc, (void *)(long)nitems++, NULL, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -108,7 +108,7 @@ _insert_before_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUS if (!glit) return; - elm_genlist_item_insert_before(list, &_itc, + elm_genlist_item_insert_before(list, _itc, (void *)(long)nitems++, NULL, glit, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -123,7 +123,7 @@ _insert_after_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSE if (!glit) return; - elm_genlist_item_insert_after(list, &_itc, + elm_genlist_item_insert_after(list, _itc, (void *)(long)nitems++, NULL, glit, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -263,18 +263,26 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_win_resize_object_add(win, box); evas_object_show(box); - _itc.item_style = "double_label"; - _itc.func.text_get = _item_label_get; - _itc.func.content_get = _item_content_get; - _itc.func.state_get = NULL; - _itc.func.del = NULL; - - _itc_group.item_style = "group_index"; - _itc_group.func.text_get = _group_label_get; - _itc_group.func.content_get = _group_content_get; - _itc_group.func.state_get = NULL; - _itc_group.func.del = NULL; + if (!_itc) + { + _itc = elm_genlist_item_class_new(); + _itc->item_style = "default"; + _itc->func.text_get = _item_label_get; + _itc->func.content_get = _item_content_get; + _itc->func.state_get = NULL; + _itc->func.del = NULL; + } + if (!_itc_group) + { + _itc_group = elm_genlist_item_class_new(); + _itc_group->item_style = "default"; + _itc_group->func.text_get = _item_label_get; + _itc_group->func.content_get = _item_content_get; + _itc_group->func.state_get = NULL; + _itc_group->func.del = NULL; + } + list = elm_genlist_add(win); evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -310,7 +318,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) if (i % 7 == 0) { - glg = gli = elm_genlist_item_append(list, &_itc_group, + glg = gli = elm_genlist_item_append(list, _itc_group, (void *)(long)nitems++, NULL, ELM_GENLIST_ITEM_GROUP, _item_sel_cb, NULL); @@ -318,7 +326,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) } else { - gli = elm_genlist_item_append(list, &_itc, + gli = elm_genlist_item_append(list, _itc, (void *)(long)nitems++, glg, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); diff --git a/src/examples/genlist_example_05.c b/src/examples/genlist_example_05.c index 144fe63..236242a 100644 --- a/src/examples/genlist_example_05.c +++ b/src/examples/genlist_example_05.c @@ -17,9 +17,9 @@ typedef struct _Node_Data { Eina_Bool favorite; } Node_Data; -static Elm_Genlist_Item_Class _itc; -static Elm_Genlist_Item_Class _itp; -static Elm_Genlist_Item_Class _itfav; +static Elm_Genlist_Item_Class *_itc = NULL; +static Elm_Genlist_Item_Class *_itp = NULL; +static Elm_Genlist_Item_Class *_itfav = NULL; static int nitems = 0; static char * @@ -125,7 +125,7 @@ _append_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) else d->level = 0; - elm_genlist_item_append(list, &_itc, + elm_genlist_item_append(list, _itc, d, parent, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); @@ -142,13 +142,13 @@ _favorite_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__) Node_Data *d = elm_object_item_data_get(glit); d->favorite = !d->favorite; if (d->favorite) - elm_genlist_item_item_class_update(glit, &_itfav); + elm_genlist_item_item_class_update(glit, _itfav); else { if (d->children) - elm_genlist_item_item_class_update(glit, &_itp); + elm_genlist_item_item_class_update(glit, _itp); else - elm_genlist_item_item_class_update(glit, &_itc); + elm_genlist_item_item_class_update(glit, _itc); } elm_genlist_item_update(glit); @@ -183,12 +183,12 @@ _add_child_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__ elm_object_item_del(glit); if (glit_prev != glit_parent) - glit = elm_genlist_item_insert_after(list, &_itp, d, glit_parent, + glit = elm_genlist_item_insert_after(list, _itp, d, glit_parent, glit_prev, ELM_GENLIST_ITEM_SUBITEMS, _item_sel_cb, NULL); else - glit = elm_genlist_item_prepend(list, &_itp, d, glit_parent, + glit = elm_genlist_item_prepend(list, _itp, d, glit_parent, ELM_GENLIST_ITEM_SUBITEMS, _item_sel_cb, NULL); elm_genlist_item_expanded_set(glit, EINA_FALSE); @@ -196,7 +196,7 @@ _add_child_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__ } else if (elm_genlist_item_expanded_get(glit)) { - elm_genlist_item_append(list, &_itc, ndata, glit, + elm_genlist_item_append(list, _itc, ndata, glit, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); } @@ -269,14 +269,14 @@ _expanded_cb(void *data __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE; printf("expanding item: #%d from parent #%d\n", it_data->value, d->value); if (it_data->favorite) - ic = &_itfav; + ic = _itfav; else if (it_data->children) { - ic = &_itp; + ic = _itp; type = ELM_GENLIST_ITEM_SUBITEMS; } else - ic = &_itc; + ic = _itc; nitem = elm_genlist_item_append(list, ic, it_data, glit, type, _item_sel_cb, NULL); @@ -331,23 +331,35 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_win_resize_object_add(win, box); evas_object_show(box); - _itc.item_style = "default"; - _itc.func.text_get = _item_label_get; - _itc.func.content_get = _item_content_get; - _itc.func.state_get = NULL; - _itc.func.del = NULL; - - _itp.item_style = "default"; - _itp.func.text_get = _parent_label_get; - _itp.func.content_get = _parent_content_get; - _itp.func.state_get = NULL; - _itp.func.del = NULL; - - _itfav.item_style = "default"; - _itfav.func.text_get = _favorite_label_get; - _itfav.func.content_get = _favorite_content_get; - _itfav.func.state_get = NULL; - _itfav.func.del = NULL; + if (!_itc) + { + _itc = elm_genlist_item_class_new(); + _itc->item_style = "default"; + _itc->func.text_get = _item_label_get; + _itc->func.content_get = _item_content_get; + _itc->func.state_get = NULL; + _itc->func.del = NULL; + } + + if (!_itp) + { + _itp = elm_genlist_item_class_new(); + _itp->item_style = "default"; + _itp->func.text_get = _parent_label_get; + _itp->func.content_get = _parent_content_get; + _itp->func.state_get = NULL; + _itp->func.del = NULL; + } + + if (!_itfav) + { + _itfav = elm_genlist_item_class_new(); + _itfav->item_style = "default"; + _itfav->func.text_get = _favorite_label_get; + _itfav->func.content_get = _favorite_content_get; + _itfav->func.state_get = NULL; + _itfav->func.del = NULL; + } list = elm_genlist_add(win); @@ -383,7 +395,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) printf("creating item: #%d\n", data->value); if (i % 3 == 0) { - glg = gli = elm_genlist_item_append(list, &_itp, data, NULL, + glg = gli = elm_genlist_item_append(list, _itp, data, NULL, ELM_GENLIST_ITEM_SUBITEMS, _item_sel_cb, NULL); elm_genlist_item_expanded_set(glg, EINA_TRUE); @@ -392,7 +404,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) } else { - gli = elm_genlist_item_append(list, &_itc, data, glg, + gli = elm_genlist_item_append(list, _itc, data, glg, ELM_GENLIST_ITEM_NONE, _item_sel_cb, NULL); pdata->children = eina_list_append(pdata->children, data);