\hypertarget{index_example_02_8c-example}{}\doxysection{index\+\_\+example\+\_\+02.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Elementary.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *items[] =}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{stringliteral}{"Judith"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Paulina"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Cathy"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Vendella"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Naomi"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Ashley"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Stacey"},}
\DoxyCodeLine{   \textcolor{stringliteral}{"Gail"}}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_index\_changed(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{               \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{               \textcolor{keywordtype}{void}        *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}} *item = \mbox{\hyperlink{group__Elm__General_ga4465a576c55d197878aeafc0bacf7bb4}{elm\_object\_item\_data\_get}}(event\_info);}
\DoxyCodeLine{   elm\_gengrid\_item\_bring\_in(item, \mbox{\hyperlink{group__Elm__General_gga40161f81baa7e0c89b14f84b80c71735a2752198ebed6ede5edf236c45307679e}{ELM\_GENGRID\_ITEM\_SCROLLTO\_IN}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{char} *}
\DoxyCodeLine{\_grid\_label\_get(\textcolor{keywordtype}{void}        *data,}
\DoxyCodeLine{                \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *part \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{int} idx = (int)(uintptr\_t)data;}
\DoxyCodeLine{   \textcolor{keywordflow}{return} strdup(items[idx]);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *}
\DoxyCodeLine{\_grid\_content\_get(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                  \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj,}
\DoxyCodeLine{                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *part)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!strcmp(part, \textcolor{stringliteral}{"elm.swallow.icon"}))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \textcolor{keywordtype}{char} buf[PATH\_MAX];}
\DoxyCodeLine{        snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"\%s/images/\%s"}, \mbox{\hyperlink{group__Elm__App_ga92a09dbf88cc1ca3eab51c51dea589d0}{elm\_app\_data\_dir\_get}}(),}
\DoxyCodeLine{                 \textcolor{stringliteral}{"sky\_01.jpg"});}
\DoxyCodeLine{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *icon = \mbox{\hyperlink{group__Elm__Bg_gaeec8f79ac62ce0cf607cfe330008a63f}{elm\_bg\_add}}(obj);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Elm__Bg_ga0b11c11879de61126414adfbfe3e431c}{elm\_bg\_file\_set}}(icon, buf, NULL);}
\DoxyCodeLine{        evas\_object\_size\_hint\_aspect\_set(icon, \mbox{\hyperlink{Evas__Common_8h_ac68b577b7c0b79c356f01926e4a8099faeaf1e019f2dbfbbc2da9ab1fe1f175f6}{EVAS\_ASPECT\_CONTROL\_VERTICAL}}, 1,}
\DoxyCodeLine{                                         1);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(icon);}
\DoxyCodeLine{        \textcolor{keywordflow}{return} icon;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* ordering alphabetically */}}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\_index\_icmp(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *data1,}
\DoxyCodeLine{            \textcolor{keyword}{const} \textcolor{keywordtype}{void} *data2)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *label1, *label2;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keyword}{const} \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}} *index\_it1 = data1;}
\DoxyCodeLine{   \textcolor{keyword}{const} \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}} *index\_it2 = data2;}
\DoxyCodeLine{}
\DoxyCodeLine{   label1 = elm\_index\_item\_letter\_get(index\_it1);}
\DoxyCodeLine{   label2 = elm\_index\_item\_letter\_get(index\_it2);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} strcasecmp(label1, label2);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{EAPI\_MAIN \textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int}    argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{         \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *win, *grid, *idx;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}} *gg\_it;}
\DoxyCodeLine{   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Elm__Gen__Item__Class}{Elm\_Gengrid\_Item\_Class}} gic = \{ 0 \};}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga7a05f37fd3a019da5e26c5fc91fcd937}{elm\_policy\_set}}(\mbox{\hyperlink{group__Elm__General_ggaa16f3378ecdbf660fa378402e3c5a0a9a02fadb6faada04b19d0fa42c11a8d32a}{ELM\_POLICY\_QUIT}}, \mbox{\hyperlink{group__Elm__General_gga46af37e6ac2c406321060be827117196abbe0962d88ae12afe1a173da881f56cd}{ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__App_ga0cefb59efb95841232561d67e34d9909}{elm\_app\_info\_set}}(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images"});}
\DoxyCodeLine{}
\DoxyCodeLine{   win = \mbox{\hyperlink{group__Elm__Win_gac75d7752662fab73d6420706ce5be996}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"index"}, \textcolor{stringliteral}{"Index Example"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{   grid = \mbox{\hyperlink{group__Elm__Gengrid_ga9ab2e5b38433f1021c01d0f71397266c}{elm\_gengrid\_add}}(win);}
\DoxyCodeLine{   elm\_gengrid\_item\_size\_set(grid, 150, 150);}
\DoxyCodeLine{}
\DoxyCodeLine{   gic.\mbox{\hyperlink{struct__Elm__Gen__Item__Class_aa611ea90d00c3e0f9abe25ff56fc420f}{item\_style}} = \textcolor{stringliteral}{"default"};}
\DoxyCodeLine{   gic.\mbox{\hyperlink{struct__Elm__Gen__Item__Class_a457622de444f6539822387321996418d}{func}}.\mbox{\hyperlink{struct__Elm__Gen__Item__Class__Functions_ae7a3a244fab9e126b3ac264615535c41}{text\_get}} = \_grid\_label\_get;}
\DoxyCodeLine{   gic.\mbox{\hyperlink{struct__Elm__Gen__Item__Class_a457622de444f6539822387321996418d}{func}}.\mbox{\hyperlink{struct__Elm__Gen__Item__Class__Functions_a796220b356374cd6395bcd2c3668f8d8}{content\_get}} = \_grid\_content\_get;}
\DoxyCodeLine{   gic.\mbox{\hyperlink{struct__Elm__Gen__Item__Class_a457622de444f6539822387321996418d}{func}}.\mbox{\hyperlink{struct__Elm__Gen__Item__Class__Functions_a23a335ae22003578adc536313f21e6e5}{state\_get}} = NULL;}
\DoxyCodeLine{   gic.\mbox{\hyperlink{struct__Elm__Gen__Item__Class_a457622de444f6539822387321996418d}{func}}.\mbox{\hyperlink{struct__Elm__Gen__Item__Class__Functions_a29069fe3b82c13e822a3ce515e12dac0}{del}} = NULL;}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(grid, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win, grid);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(grid);}
\DoxyCodeLine{}
\DoxyCodeLine{   idx = \mbox{\hyperlink{group__Elm__Index_gaf7fda3a54ca154cdc754326137f3737e}{elm\_index\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(idx, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win, idx);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(idx);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{for} (i = 0; i < (\textcolor{keyword}{sizeof}(items) / \textcolor{keyword}{sizeof}(items[0])); i++)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \textcolor{keywordtype}{char} buf[32];}
\DoxyCodeLine{}
\DoxyCodeLine{        gg\_it = elm\_gengrid\_item\_append(grid, \&gic, (\textcolor{keywordtype}{void} *)(uintptr\_t)i, NULL, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{comment}{/* indexing by first letters */}}
\DoxyCodeLine{        snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"\%c"}, items[i][0]);}
\DoxyCodeLine{        elm\_index\_item\_sorted\_insert(idx, buf, NULL, gg\_it, \_index\_icmp, NULL);}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(idx, \textcolor{stringliteral}{"delay,changed"}, \_index\_changed, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   elm\_index\_autohide\_disabled\_set(idx, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{   elm\_index\_level\_go(idx, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_resize(win, 320, 300);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(win);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_gadf2553f83e6b0b9c7fbe054019a664a1}{elm\_run}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{\mbox{\hyperlink{group__Elm__General_ga50fe52d513f7e89c9c770afd76de7ad9}{ELM\_MAIN}}()}
\end{DoxyCodeInclude}
 