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's A\-P\-I.

Here's how we instantiate it\-:  
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
 where we're showing also the list being created. Note that we issue \hyperlink{group__Win_ga505d6bd217e5ee01e82b548ec35986eb}{elm\-\_\-win\-\_\-resize\-\_\-object\-\_\-add()} on the index, so that it's set to have the whole window as its container. Then, we have to populate both list and index widgets\-:  
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{for} (i = 0; i < (\textcolor{keyword}{sizeof}(dict) / \textcolor{keyword}{sizeof}(dict[0])); i++)
     \{
        lit = elm_list_item_append(list, dict[i], NULL, NULL, NULL, NULL);

        \textcolor{keywordflow}{if} (curr != dict[i][0])
          \{
             Elm_Object_Item *index\_it, *it;
             \textcolor{keywordtype}{char} buf[32];

             curr = dict[i][0];
             \textcolor{comment}{/* indexing by first letters */}

             snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%c"}, curr);
             index\_it = elm_index_item_append(\textcolor{keywordtype}{id}, buf, NULL, lit);

             \textcolor{comment}{/* this is here just to demostrate the API call */}
             it = elm_index_item_find(\textcolor{keywordtype}{id}, lit);
             assert(it == index\_it);

             elm_object_item_del_cb_set(index\_it, \_index\_item\_del);
          \}
     \}

\end{DoxyCodeInclude}


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

\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'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}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_index\_item\_del(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Deleting index node (%s). Comparing index "}
           \textcolor{stringliteral}{"item data reported via callback with the one returned by "}
           \textcolor{stringliteral}{"index's API on items: %s.\(\backslash\)n"},
           elm_index_item_letter_get(event\_info),
           data == elm_object_item_data_get(event\_info) ? \textcolor{stringliteral}{"OK"} :
           \textcolor{stringliteral}{"FAIL, something went wrong"});
\}

\end{DoxyCodeInclude}


There, we show you that the {\ttfamily event\-\_\-info} pointer will contain the item in question's data, i.\-e., a given list item'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'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}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* "delay,changed" hook */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_index\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   elm_list_item_bring_in(elm_object_item_data_get(event\_info));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_index\_selected(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Elm_Object_Item *lit = event\_info;

   fprintf(stdout, \textcolor{stringliteral}{"New index item selected. Comparing item reported"}
           \textcolor{stringliteral}{" via callback with the selection returned by the API: "}
           \textcolor{stringliteral}{"%s.\(\backslash\)n"}, lit == elm_index_selected_item_get(obj, 0) ? \textcolor{stringliteral}{"OK"} :
           \textcolor{stringliteral}{"FAIL, something went wrong"});
\}

\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 \hyperlink{group__Index_ga93ba050910c0f8081a72c87f9c2edec9}{elm\-\_\-index\-\_\-selected\-\_\-item\-\_\-get()}, which gives the last selection's data on the index widget.

The first of the three buttons that follow will call \hyperlink{group__Index_gad472ab052daf2639bdf3c84ef6efd35d}{elm\-\_\-index\-\_\-autohide\-\_\-disabled\-\_\-set()}, thus showing the index automatically for you, if it's not already visible, what is checked with \hyperlink{group__Index_ga57c74965645dedf30560b004b19a2c4c}{elm\-\_\-index\-\_\-autohide\-\_\-disabled\-\_\-get()}. The second button will exercise {\bfseries deletion} of index item objects, by the following code\-:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* delete an index item */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_item\_del(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Elm_Object_Item *it = elm_index_selected_item_get(data, 0);

   \textcolor{keywordflow}{if} (!it) \textcolor{keywordflow}{return};

   fprintf(stdout, \textcolor{stringliteral}{"Deleting last selected index item, which had letter"}
           \textcolor{stringliteral}{" %s (pointing to %p)\(\backslash\)n"}, elm_index_item_letter_get(it),
           elm_object_item_data_get(it));

   elm_object_item_del(it);
   elm_index_level_go(data, 0);
\}

\end{DoxyCodeInclude}


It will get the last index item selected's data and find the respective index item handle(\hyperlink{group__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\-\_\-\-Object\-\_\-\-Item}) with \hyperlink{group__Index_gaf93e336cdd25771d797b797999884591}{elm\-\_\-index\-\_\-item\-\_\-find()}. We need the latter to query the indexing letter string from, with \hyperlink{group__Index_ga58eaaa07a66228564c36995d083d2b92}{elm\-\_\-index\-\_\-item\-\_\-letter\-\_\-get()}. Next, comes the delition, itself, which will also trigger the {\ttfamily \-\_\-index\-\_\-item\-\_\-del} callback function, as said above.

The third button, finally, will exercise \hyperlink{group__Index_ga176b7d23252f80163e4ac04bc36e1980}{elm\-\_\-index\-\_\-item\-\_\-clear()}, which will delete {\bfseries all} of the index's items.

This is how the example program's window looks like with the index widget hidden\-:  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics{screenshots/index_example_00}}
\end{DoxyImageNoCaption}


When it's shown, it's like the following figure\-:  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics{screenshots/index_example_01}}
\end{DoxyImageNoCaption}


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