diff options
author | Jyotiprakash Sahoo <jp.sahoo@samsung.com> | 2014-07-23 11:35:20 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2014-07-23 11:35:20 +0900 |
commit | cb10e929f20cfa2f971e2bee80e8b82b9989ad65 (patch) | |
tree | ec11dce7cd11a9dba93a4ad2367e941b7a5a165c /src/lib | |
parent | 1ad8575e8fd2abb274725f9b24898623c757b3bd (diff) |
gengrid: Add function to search item by string.
Summary: This function allows user to search for item in Gengrid.
Test Plan: elementary_test -to "Gengrid Item Search By Text"
Reviewers: seoz, singh.amitesh, Hermet, raster
Differential Revision: https://phab.enlightenment.org/D1178
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/elm_gengrid.c | 25 | ||||
-rw-r--r-- | src/lib/elm_gengrid.eo | 10 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c index 607d400fd..9d06c64e6 100644 --- a/src/lib/elm_gengrid.c +++ b/src/lib/elm_gengrid.c | |||
@@ -102,6 +102,31 @@ static const Elm_Action key_actions[] = { | |||
102 | {NULL, NULL} | 102 | {NULL, NULL} |
103 | }; | 103 | }; |
104 | 104 | ||
105 | EOLIAN static Elm_Object_Item * | ||
106 | _elm_gengrid_search_by_text_item_get(Eo *obj EINA_UNUSED, | ||
107 | Elm_Gengrid_Data *sd, | ||
108 | Elm_Object_Item * item_to_search_from, | ||
109 | Elm_Gen_Item_Text_Get_Cb _text_get, | ||
110 | const char * part_name, | ||
111 | const char * pattern, | ||
112 | int flags) | ||
113 | { | ||
114 | Elm_Gen_Item *it = NULL; | ||
115 | const char * str = NULL; | ||
116 | Eina_Inlist * start = NULL; | ||
117 | |||
118 | if (!_text_get || !pattern) return NULL; | ||
119 | if (!sd->items) return NULL; | ||
120 | |||
121 | start = (item_to_search_from) ? EINA_INLIST_GET((Elm_Gen_Item *)item_to_search_from) : sd->items; | ||
122 | EINA_INLIST_FOREACH(start, it) | ||
123 | { | ||
124 | str = _text_get((void *)it->base.data, VIEW(it), part_name); | ||
125 | if (!fnmatch(pattern, str, flags)) return (Elm_Object_Item *)it; | ||
126 | } | ||
127 | return NULL; | ||
128 | } | ||
129 | |||
105 | static void | 130 | static void |
106 | _item_show_region(void *data) | 131 | _item_show_region(void *data) |
107 | { | 132 | { |
diff --git a/src/lib/elm_gengrid.eo b/src/lib/elm_gengrid.eo index a7c5f7037..6b125f97a 100644 --- a/src/lib/elm_gengrid.eo +++ b/src/lib/elm_gengrid.eo | |||
@@ -656,6 +656,16 @@ class Elm_Gengrid (Elm_Layout, Elm_Interface_Scrollable, Evas.Clickable_Interfac | |||
656 | @in const(void)* func_data; /*@ Data to be passed to @p func. */ | 656 | @in const(void)* func_data; /*@ Data to be passed to @p func. */ |
657 | } | 657 | } |
658 | } | 658 | } |
659 | search_by_text_item_get { | ||
660 | return Elm_Object_Item *; | ||
661 | params { | ||
662 | @in Elm_Object_Item * item_to_search_from; /*@ Pointer to item to start search from. If NULL search will be started from the first item of the genlist. */ | ||
663 | @in Elm_Gen_Item_Text_Get_Cb _text_get; /*@ Pointer to Elm_Gen_Item_Text_Get_Cb function to get text for comparison. */ | ||
664 | @in const(char)* part_name; /*@ Name of the TEXT part of genlist item to search string in. */ | ||
665 | @in const(char)* pattern; /*@ The search pattern. */ | ||
666 | @in int flags; /*@ fnmatch search flags */ | ||
667 | } | ||
668 | } | ||
659 | } | 669 | } |
660 | implements { | 670 | implements { |
661 | class.constructor; | 671 | class.constructor; |