\chapter{List -\/ Items management}
\hypertarget{list_example_03}{}\label{list_example_03}\index{List -\/ Items management@{List -\/ Items management}}
This code places an Elementary list widgets on a window, along with some buttons trigerring actions on it (though its API). It covers most of elm\+\_\+list\+\_\+item functions.

On our {\ttfamily main} function, we are adding a default list with 3 items. We are only setting their labels (second parameter of function elm\+\_\+list\+\_\+item\+\_\+append)\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ li\ =\ \mbox{\hyperlink{group__Elm__List__Group_gaf6389bff5604ff879bc572ab12494dd2}{elm\_list\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(li,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{evas\_object\_size\_hint\_align\_set}}(li,\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}},\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(bx,\ li);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ \textcolor{stringliteral}{"{}Item\ 0"{}},\ NULL,\ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ \textcolor{stringliteral}{"{}Item\ 1"{}},\ NULL,\ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ \textcolor{stringliteral}{"{}Item\ 2"{}},\ NULL,\ NULL,\ NULL,\ NULL);}

\end{DoxyCodeInclude}
 Next we are adding lots of buttons, each one for a callback function that will realize a task covering part of list items API. Lets check the first one\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ bt\ =\ \mbox{\hyperlink{group__Elm__Button_gaf5caf46d74c4e122a18da323935d25e4}{elm\_button\_add}}(win);}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(bt,\ \textcolor{stringliteral}{"{}Prepend\ item"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(bt,\ \textcolor{stringliteral}{"{}clicked"{}},\ \_prepend\_cb,\ li);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(hbx,\ bt);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(bt,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{evas\_object\_size\_hint\_align\_set}}(bt,\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}},\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bt);}

\end{DoxyCodeInclude}
 We are labeling the button with a task description with elm\+\_\+object\+\_\+text\+\_\+set() and setting a callback function \doxylink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\+\_\+object\+\_\+smart\+\_\+callback\+\_\+add()}. Each callback function will have the signature\+: {\ttfamily  static void \+\_\+task\+\_\+cb(void \texorpdfstring{$\ast$}{*}data, Evas\+\_\+\+Object \texorpdfstring{$\ast$}{*}obj, void \texorpdfstring{$\ast$}{*}event\+\_\+info)} with the function name varying for each task.

Now let\textquotesingle{}s cover all of them.

{\bfseries{ Prepending an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_prepend\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_gaf79a07ace606b48e315aad393cfe546b}{elm\_list\_item\_prepend}}(li,\ label,\ NULL,\ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 The item will be placed on the beginning of the list, i.\+e. it will be the first one.

The first parameter of \doxylink{group__Elm__List__Group_gaf79a07ace606b48e315aad393cfe546b}{elm\+\_\+list\+\_\+item\+\_\+prepend()} is the list object, that we are receiving as data on our callback function. The second one is a label, the string that will be placed in the center of our item. As we don\textquotesingle{}t want icons or callback functions, we can send NULL as third, fourth, fifth and sixth parameters.

{\bfseries{ Appending an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_add\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ label,\ NULL,\ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Items included with append will be inserted inserted after the last one.

{\bfseries{ Appending an item with icon\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_add\_ic\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *ic,\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ ic\ =\ \mbox{\hyperlink{group__Elm__Icon_gac369f2d67be417e5cff81e8f001ff326}{elm\_icon\_add}}(li);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic,\ \textcolor{stringliteral}{"{}home"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Image_ga6a389436a18e590fff5b6f6b81c72722}{elm\_image\_resizable\_set}}(ic,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}},\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ label,\ ic,\ \ NULL,\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\ with\ icon\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 If an icon is required, you can pass it as third parameter on our \doxylink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\+\_\+list\+\_\+item\+\_\+append()} function. It will be place on the left side of item\textquotesingle{}s label. If an icon is wanted on the right side, it should be passed as fourth parameter.

For more details about how to create icons, look for elm\+\_\+icon examples \doxysectlink{tutorial_icon}{Icon example}{0}.

{\bfseries{ Appending an item with callback function for selected\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_sel\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Elm\_Object\_Item\ *list\_it\ =\ event\_info;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Selected\ label:\ \%s\(\backslash\)n"{}},\ elm\_object\_item\_text\_get(list\_it));}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_add\_func\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ label,\ NULL,\ NULL,\ \_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 To set a callback function that will be called every time an item is selected, i.\+e., everytime the list stops with this item in center position, just pass the function as fifth parameter.

{\bfseries{ Appending an item with callback function for selected with data\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_sel\_data\_cb(\textcolor{keywordtype}{void}\ *data,\ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ *content\ =\ data;}
\DoxyCodeLine{\ \ \ Elm\_Object\_Item\ *list\_it\ =\ event\_info;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Selected\ label:\ \%s\ with\ data:\ \%s\(\backslash\)n"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ elm\_object\_item\_text\_get(list\_it),\ content);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_free\_data(\textcolor{keywordtype}{void}\ *data,\ 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{\ \ \ free(data);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_add\_data\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ *content\ =\ malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char})\ *\ 32);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(content,\ 32,\ \textcolor{stringliteral}{"{}Item\ content\ \%i"{}},\ counter);}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga5f2fecdca079df9522ac4f8e64b2d98e}{elm\_list\_item\_append}}(li,\ label,\ NULL,\ NULL,\ \_sel\_data\_cb,\ content);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga2e17c3f1030712f3175f5b7812ada9a0}{elm\_object\_item\_del\_cb\_set}}(list\_it,\ \_free\_data);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 If the callback function request an extra data, it can be attached to our item passing a pointer for data as sixth parameter. Our function \+\_\+sel\+\_\+data\+\_\+cb will receive it as {\ttfamily  void \texorpdfstring{$\ast$}{*}data }.

If you want to free this data, or handle that the way you need when the item is deleted, set a callback function for that, with \doxylink{group__Elm__General_ga2e17c3f1030712f3175f5b7812ada9a0}{elm\+\_\+object\+\_\+item\+\_\+del\+\_\+cb\+\_\+set()}.

As you can see we check if {\ttfamily it} is not {\ttfamily NULL} after appending it. If an error happens, we won\textquotesingle{}t try to set a function for it.

{\bfseries{ Deleting an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_del\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(selected\_item);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 To delete an item we simple need to call \doxylink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\+\_\+object\+\_\+item\+\_\+del()} with a pointer for such item.

If you need, you can get selected item with \doxylink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\+\_\+list\+\_\+selected\+\_\+item\+\_\+get()}, that will return a pointer for it.

{\bfseries{ Unselecting an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_unselect\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ elm\_list\_item\_selected\_set(selected\_item,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 To select an item, you should call elm\+\_\+list\+\_\+item\+\_\+selected\+\_\+set() passing {\ttfamily EINA\+\_\+\+TRUE}, and to unselect it, {\ttfamily EINA\+\_\+\+FALSE}.

{\bfseries{ Printing all items\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_print\_cb(\textcolor{keywordtype}{void}\ *data,\ 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{\ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ *l,\ *items;}
\DoxyCodeLine{\ \ \ Elm\_Object\_Item\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ items\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga6da431471216dd2e77ffd9734e23a8c5}{elm\_list\_items\_get}}(li);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(items,\ l,\ list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n"{}},\ elm\_object\_item\_text\_get(list\_it));}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 {\bfseries{ Clearing the list\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_clear\_cb(\textcolor{keywordtype}{void}\ *data,\ 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{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_gabe4b2c3e5419575144f880042b337eca}{elm\_list\_clear}}(li);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 {\bfseries{ Selecting the next item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_select\_next\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item,\ *next\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ next\_item\ =\ elm\_list\_item\_next(selected\_item);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (next\_item)}
\DoxyCodeLine{\ \ \ \ \ elm\_list\_item\_selected\_set(next\_item,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 {\bfseries{ Inserting after an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_insert\_after\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item,\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga8880eb99d6b50a9a6e1098b91a6b4d9e}{elm\_list\_item\_insert\_after}}(li,\ selected\_item,\ label,\ NULL,\ NULL,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 {\bfseries{ Selecting the previous item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_select\_prev\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item,\ *prev\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ prev\_item\ =\ elm\_list\_item\_prev(selected\_item);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (prev\_item)}
\DoxyCodeLine{\ \ \ \ \ elm\_list\_item\_selected\_set(prev\_item,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 {\bfseries{ Inserting before an item\+: }}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_insert\_before\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item,\ *list\_it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ label[32];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(label,\ \textcolor{keyword}{sizeof}(label),\ \textcolor{stringliteral}{"{}Item\ \%i"{}},\ counter++);}
\DoxyCodeLine{\ \ \ list\_it\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga7f6d007721027b8fd0402bd49829038c}{elm\_list\_item\_insert\_before}}(li,\ selected\_item,\ label,\ NULL,\ NULL,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!list\_it)}
\DoxyCodeLine{\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Error\ adding\ item\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 If a separator is required, just set an item as such\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_set\_separator\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ elm\_list\_item\_separator\_set(selected\_item,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__List__Group_ga016361621126444b003a71dc8ff75627}{elm\_list\_go}}(li);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Also an item can be disabled, and the user won\textquotesingle{}t be allowed to (un)select it\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_disable\_cb(\textcolor{keywordtype}{void}\ *data,\ 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\_Object\_Item\ *selected\_item;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *li\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ selected\_item\ =\ \mbox{\hyperlink{group__Elm__List__Group_ga30a9c03f1ae67140cb8350ba7fd2851e}{elm\_list\_selected\_item\_get}}(li);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!selected\_item)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga1d4c8d3c83ed9408eaa35d605adbd7d2}{elm\_object\_item\_disabled\_set}}(selected\_item,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 See the full \doxylink{list_example_03_8c-example}{list\+\_\+example\+\_\+03.c} code, whose window should look like this picture\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/list_example_03}}
\end{DoxyImageNoCaption}
 