From 821ad977785e3ccc6d75a91b225770efdf9bab71 Mon Sep 17 00:00:00 2001 From: Daniel Juyung Seo Date: Sun, 11 Sep 2011 12:24:40 +0000 Subject: [PATCH] elm gengrid: Gengrid longpress documentation. Patch by Benjamin Drucker On Fri, Sep 9, 2011 at 4:18 PM, Benjamin Drucker wrote: > gengrid already emits "longpressed" signals, but it is not currently > documented nor demonstrated in the examples. See the attached patch, > please. SVN revision: 63323 --- legacy/elementary/src/examples/gengrid_example.c | 11 +++++++++++ legacy/elementary/src/lib/Elementary.h.in | 2 ++ legacy/elementary/src/lib/elm_gengrid.c | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/legacy/elementary/src/examples/gengrid_example.c b/legacy/elementary/src/examples/gengrid_example.c index bba0f70660..b3c145eabf 100644 --- a/legacy/elementary/src/examples/gengrid_example.c +++ b/legacy/elementary/src/examples/gengrid_example.c @@ -288,6 +288,16 @@ _double_click(void *data __UNUSED__, fprintf(stdout, "Double click on item with handle %p\n", event_info); } +/* item long press callback */ +static void +_long_pressed(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info) +{ + fprintf(stdout, "Long press on item with handle %p\n", event_info); +} + + /* label fetching callback */ static char * _grid_label_get(void *data, @@ -428,6 +438,7 @@ elm_main(int argc __UNUSED__, evas_object_size_hint_min_set(grid, 600, 500); elm_box_pack_end(bx, grid); evas_object_smart_callback_add(grid, "clicked,double", _double_click, NULL); + evas_object_smart_callback_add(grid, "longpressed", _long_pressed, NULL); evas_object_show(grid); hbx_1 = elm_box_add(win); diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index e1ee82f476..ed97b3019b 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -7835,6 +7835,8 @@ extern "C" { * is the gengrid item that was activated. * - @c "clicked,double" - The user has double-clicked an item. * The @c event_info parameter is the gengrid item that was double-clicked. + * - @c "longpressed" - This is called when the item is pressed for a certain + * amount of time. By default it's 1 second. * - @c "selected" - The user has made an item selected. The * @c event_info parameter is the gengrid item that was selected. * - @c "unselected" - The user has made an item unselected. The diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index f422c53e7f..dc7ebb9ef9 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -135,6 +135,7 @@ static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl); static const char SIG_ACTIVATED[] = "activated"; static const char SIG_CLICKED_DOUBLE[] = "clicked,double"; +static const char SIG_LONGPRESSED[] = "longpressed"; static const char SIG_SELECTED[] = "selected"; static const char SIG_UNSELECTED[] = "unselected"; static const char SIG_REALIZED[] = "realized"; @@ -156,6 +157,7 @@ static const char SIG_MOVED[] = "moved"; static const Evas_Smart_Cb_Description _signals[] = { {SIG_ACTIVATED, ""}, {SIG_CLICKED_DOUBLE, ""}, + {SIG_LONGPRESSED, ""}, {SIG_SELECTED, ""}, {SIG_UNSELECTED, ""}, {SIG_REALIZED, ""}, @@ -762,7 +764,7 @@ _long_press(void *data) item->long_timer = NULL; if ((item->disabled) || (item->dragging)) return ECORE_CALLBACK_CANCEL; item->wd->longpressed = EINA_TRUE; - evas_object_smart_callback_call(item->wd->self, "longpressed", item); + evas_object_smart_callback_call(item->wd->self, SIG_LONGPRESSED, item); if (item->wd->reorder_mode) { item->wd->reorder_item = item;