This code places an Elementary index widget on a window, which also has a very long list of arbitrary strings on it.

The list is sorted alphabetically and the index will be used to index the first items of each set of strings beginning with an alphabet letter.

Below the list are some buttons, which are there just to exercise some index widget\textquotesingle{}s API.

Here\textquotesingle{}s how we instantiate it\+:  
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
where we\textquotesingle{}re showing also the list being created. Note that we issue \mbox{\hyperlink{group__Elm__Win__Group_ga505d6bd217e5ee01e82b548ec35986eb}{elm\+\_\+win\+\_\+resize\+\_\+object\+\_\+add()}} on the index, so that it\textquotesingle{}s set to have the whole window as its container. Then, we have to populate both list and index widgets\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ (\textcolor{keyword}{sizeof}(dict)\ /\ \textcolor{keyword}{sizeof}(dict[0]));\ i++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ lit\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(list,\ dict[i],\ NULL,\ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (curr\ !=\ dict[i][0])}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *index\_it;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ buf[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ curr\ =\ dict[i][0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ indexing\ by\ first\ letters\ */}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}\%c"{}},\ curr);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ index\_it\ =\ \mbox{\hyperlink{group__Elm__Index__Group_ga4ba5c5901f940b935144c357ef8cac9d}{elm\_index\_item\_append}}(\textcolor{keywordtype}{id},\ buf,\ NULL,\ lit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ this\ is\ here\ just\ to\ demostrate\ the\ API\ call\ */}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ (void)\mbox{\hyperlink{group__Elm__Index__Group_ga0a0ec1967a198fe963276bb2d80697a7}{elm\_index\_item\_find}}(\textcolor{keywordtype}{id},\ lit);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ assert(\mbox{\hyperlink{group__Elm__Index__Group_ga0a0ec1967a198fe963276bb2d80697a7}{elm\_index\_item\_find}}(\textcolor{keywordtype}{id},\ lit)\ ==\ index\_it);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga2e17c3f1030712f3175f5b7812ada9a0}{elm\_object\_item\_del\_cb\_set}}(index\_it,\ \_index\_item\_del);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 The strings populating the list come from a file  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *dict[]\ =\ \(\backslash\)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ "{}dict.txt"{}}}
\DoxyCodeLine{\};}

\end{DoxyCodeInclude}
 We use the {\ttfamily curr} char variable to hold the last initial letter seen on that ordered list of strings, so that we\textquotesingle{}re able to have an index item pointing to each list item starting a new letter \char`\"{}section\char`\"{}. Note that our index item data pointers will be the list item handles. We are also setting a callback function to index items deletion events\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_index\_item\_del(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Deleting\ index\ node\ (\%s).\ Comparing\ index\ "{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}item\ data\ reported\ via\ callback\ with\ the\ one\ returned\ by\ "{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}index's\ API\ on\ items:\ \%s.\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Index__Item__Group_ga63b3be17a2bb05531ba1f31d2da82d7d}{elm\_index\_item\_letter\_get}}(event\_info),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ data\ ==\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(event\_info)\ ?\ \textcolor{stringliteral}{"{}OK"{}}\ :}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}FAIL,\ something\ went\ wrong"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 There, we show you that the {\ttfamily event\+\_\+info} pointer will contain the item in question\textquotesingle{}s data, i.\+e., a given list item\textquotesingle{}s pointer. Because item data is also returned in the {\ttfamily data} argument on {\ttfamily Evas\+\_\+\+Smart\+\_\+\+Cb} functions, those two pointers must have the same values. On this deletion callback, we\textquotesingle{}re deleting the referred list item too, just to exemplify that anything could be done there.

Next, we hook to two smart events of the index object\+:  
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/*\ "{}delay,changed"{}\ hook\ */}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_index\_changed(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ elm\_list\_item\_bring\_in(\mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(event\_info));}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_index\_selected(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *lit\ =\ event\_info;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}New\ index\ item\ selected.\ Comparing\ item\ reported"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\ via\ callback\ with\ the\ selection\ returned\ by\ the\ API:\ "{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\%s.\(\backslash\)n"{}},\ lit\ ==\ \mbox{\hyperlink{group__Elm__Index__Group_ga6d1c50017e16771ef3af76d915cc4d82}{elm\_index\_selected\_item\_get}}(obj,\ 0)\ ?\ \textcolor{stringliteral}{"{}OK"{}}\ :}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}FAIL,\ something\ went\ wrong"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Check that, whenever one holds the mouse pressed over a given index letter for some time, the list beneath it will roll down to the item pointed to by that index item. When one releases the mouse button, the second callback takes place. There, we check that the reported item data, on {\ttfamily event\+\_\+info}, is the same reported by \mbox{\hyperlink{group__Elm__Index__Group_ga6d1c50017e16771ef3af76d915cc4d82}{elm\+\_\+index\+\_\+selected\+\_\+item\+\_\+get()}}, which gives the last selection\textquotesingle{}s data on the index widget.

The first of the three buttons that follow will call \mbox{\hyperlink{group__Elm__Index__Group_ga6569179b38d11fb5fb1286815cf846fb}{elm\+\_\+index\+\_\+autohide\+\_\+disabled\+\_\+set()}}, thus showing the index automatically for you, if it\textquotesingle{}s not already visible, what is checked with \mbox{\hyperlink{group__Elm__Index__Group_ga4b1a080a5ddba56e53d16f97cdcfb3a1}{elm\+\_\+index\+\_\+autohide\+\_\+disabled\+\_\+get()}}. The second button will exercise {\bfseries{deletion}} of index item objects, by the following code\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/*\ delete\ an\ index\ item\ */}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_item\_del(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *it\ =\ \mbox{\hyperlink{group__Elm__Index__Group_ga6d1c50017e16771ef3af76d915cc4d82}{elm\_index\_selected\_item\_get}}(data,\ 0);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!it)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Deleting\ last\ selected\ index\ item,\ which\ had\ letter"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\ \%s\ (pointing\ to\ \%p)\(\backslash\)n"{}},\ \mbox{\hyperlink{group__Elm__Index__Item__Group_ga63b3be17a2bb05531ba1f31d2da82d7d}{elm\_index\_item\_letter\_get}}(it),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(it));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(it);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Index__Group_ga3bb92a868f63463403668a4bbcda21d1}{elm\_index\_level\_go}}(data,\ 0);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 It will get the last index item selected\textquotesingle{}s data and find the respective index item handle(\mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\+\_\+\+Object\+\_\+\+Item}}) with \mbox{\hyperlink{group__Elm__Index__Group_ga0a0ec1967a198fe963276bb2d80697a7}{elm\+\_\+index\+\_\+item\+\_\+find()}}. We need the latter to query the indexing letter string from, with \mbox{\hyperlink{group__Elm__Index__Item__Group_ga63b3be17a2bb05531ba1f31d2da82d7d}{elm\+\_\+index\+\_\+item\+\_\+letter\+\_\+get()}}. Next, comes the deletion itself, which will also trigger the {\ttfamily \+\_\+index\+\_\+item\+\_\+del} callback function, as said above.

The third button, finally, will exercise \mbox{\hyperlink{group__Elm__Index__Group_ga9c0c1ff500522b62a674b36beafe7a19}{elm\+\_\+index\+\_\+item\+\_\+clear()}}, which will delete {\bfseries{all}} of the index\textquotesingle{}s items.

This is how the example program\textquotesingle{}s window looks like with the index widget hidden\+:  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth,height=\textheight/2,keepaspectratio=true]{index_example_00}}
\end{DoxyImageNoCaption}


When it\textquotesingle{}s shown, it\textquotesingle{}s like the following figure\+:  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth,height=\textheight/2,keepaspectratio=true]{index_example_01}}
\end{DoxyImageNoCaption}


See the full \mbox{\hyperlink{index_example_01_c}{source code}} for this example. 