\hypertarget{index_example_01_8c-example}{}\doxysection{index\+\_\+example\+\_\+01.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Elementary.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <assert.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *dict[] = \(\backslash\)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include "dict.txt"}}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\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{           elm\_index\_item\_letter\_get(event\_info),}
\DoxyCodeLine{           data == \mbox{\hyperlink{group__Elm__General_ga4465a576c55d197878aeafc0bacf7bb4}{elm\_object\_item\_data\_get}}(event\_info) ? \textcolor{stringliteral}{"OK"} :}
\DoxyCodeLine{           \textcolor{stringliteral}{"FAIL, something went wrong"});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\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 = 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"}, elm\_index\_item\_letter\_get(it),}
\DoxyCodeLine{           \mbox{\hyperlink{group__Elm__General_ga4465a576c55d197878aeafc0bacf7bb4}{elm\_object\_item\_data\_get}}(it));}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(it);}
\DoxyCodeLine{   elm\_index\_level\_go(data, 0);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_item\_del\_all(\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{   elm\_index\_item\_clear(data);}
\DoxyCodeLine{   elm\_index\_level\_go(data, 0);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_active\_set(\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__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} disabled = elm\_index\_autohide\_disabled\_get(data);}
\DoxyCodeLine{   elm\_index\_autohide\_disabled\_set(data, !disabled);}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Toggling index programmatically to \%s.\(\backslash\)n"},}
\DoxyCodeLine{           !disabled ? \textcolor{stringliteral}{"On"} : \textcolor{stringliteral}{"Off"});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\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_ga4465a576c55d197878aeafc0bacf7bb4}{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 == elm\_index\_selected\_item\_get(obj, 0) ? \textcolor{stringliteral}{"OK"} :}
\DoxyCodeLine{           \textcolor{stringliteral}{"FAIL, something went wrong"});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{EAPI\_MAIN \textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \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, *hbox, *vbox, *bt, *sep, *list, *id;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}} *lit;}
\DoxyCodeLine{   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{   \textcolor{keywordtype}{char} curr = 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{}
\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{   vbox = \mbox{\hyperlink{group__Elm__Box_ga3d0998b60ada633bacfa8869a921cfd7}{elm\_box\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(vbox, \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, vbox);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(vbox);}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Elm__List_ga626e858fcd7c66bac06fa5a645e6a948}{elm\_list\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(list, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   evas\_object\_size\_hint\_align\_set(list, \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}}, \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(list);}
\DoxyCodeLine{   elm\_box\_pack\_end(vbox, list);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordtype}{id} = \mbox{\hyperlink{group__Elm__Index_gaf7fda3a54ca154cdc754326137f3737e}{elm\_index\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(\textcolor{keywordtype}{id}, \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, \textcolor{keywordtype}{id});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(\textcolor{keywordtype}{id});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{for} (i = 0; i < (\textcolor{keyword}{sizeof}(dict) / \textcolor{keyword}{sizeof}(dict[0])); i++)}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        lit = 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 = 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)elm\_index\_item\_find(\textcolor{keywordtype}{id}, lit);}
\DoxyCodeLine{             assert(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{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(\textcolor{keywordtype}{id}, \textcolor{stringliteral}{"delay,changed"}, \_index\_changed,}
\DoxyCodeLine{                                  NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(\textcolor{keywordtype}{id}, \textcolor{stringliteral}{"selected"}, \_index\_selected, NULL);}
\DoxyCodeLine{   elm\_index\_level\_go(\textcolor{keywordtype}{id}, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{comment}{/* attribute setting knobs */}}
\DoxyCodeLine{   sep = \mbox{\hyperlink{group__Elm__Separator_gabacf257db01e0b39987332c5a71096e0}{elm\_separator\_add}}(win);}
\DoxyCodeLine{   elm\_separator\_horizontal\_set(sep, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   elm\_box\_pack\_end(vbox, sep);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(sep);}
\DoxyCodeLine{}
\DoxyCodeLine{   hbox = \mbox{\hyperlink{group__Elm__Box_ga3d0998b60ada633bacfa8869a921cfd7}{elm\_box\_add}}(win);}
\DoxyCodeLine{   elm\_box\_horizontal\_set(hbox, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(hbox, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, 0);}
\DoxyCodeLine{   \mbox{\hyperlink{Evas__Common_8h_a1b148ef14ae2eb1fbde17179b66a0503}{evas\_object\_size\_hint\_fill\_set}}(hbox, \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}}, \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}});}
\DoxyCodeLine{   elm\_box\_pack\_end(vbox, hbox);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(hbox);}
\DoxyCodeLine{}
\DoxyCodeLine{   bt = \mbox{\hyperlink{group__Elm__Button_ga0021b9d86d822367035843ed18bc6ea9}{elm\_button\_add}}(win);}
\DoxyCodeLine{   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"bring in index"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(bt, \textcolor{stringliteral}{"clicked"}, \_active\_set, \textcolor{keywordtype}{id});}
\DoxyCodeLine{   elm\_box\_pack\_end(hbox, bt);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bt);}
\DoxyCodeLine{}
\DoxyCodeLine{   bt = \mbox{\hyperlink{group__Elm__Button_ga0021b9d86d822367035843ed18bc6ea9}{elm\_button\_add}}(win);}
\DoxyCodeLine{   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"delete last selected item"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(bt, \textcolor{stringliteral}{"clicked"}, \_item\_del, \textcolor{keywordtype}{id});}
\DoxyCodeLine{   elm\_box\_pack\_end(hbox, bt);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bt);}
\DoxyCodeLine{}
\DoxyCodeLine{   bt = \mbox{\hyperlink{group__Elm__Button_ga0021b9d86d822367035843ed18bc6ea9}{elm\_button\_add}}(win);}
\DoxyCodeLine{   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"delete all items"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(bt, \textcolor{stringliteral}{"clicked"}, \_item\_del\_all, \textcolor{keywordtype}{id});}
\DoxyCodeLine{   elm\_box\_pack\_end(hbox, bt);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bt);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_resize(win, 320, 600);}
\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}
 