This is probably the most complex example of elementary Elm\+\_\+\+Genlist.

We create a tree of items, using the subitems properties of the items, and keep it in memory to be able to expand/hide subitems of an item. The full source code can be found at \mbox{\hyperlink{genlist_example_05_c}{genlist\+\_\+example\+\_\+05.\+c}}

The main point is the way that Genlist manages subitems. Clicking on an item\textquotesingle{}s button to expand it won\textquotesingle{}t really show its children. It will only generate the \char`\"{}expand,request\char`\"{} signal, and the expansion must be done manually.

In this example we want to be able to add items as subitems of another item. If an item has any child, it must be displayed using a parent class, otherwise it will use the normal item class.

It will be possible to delete items too. Once a tree is constructed (with subitems of subitems), and the user clicks on the first parent (root of the tree), the entire subtree must be hidden. However, just calling elm\+\_\+genlist\+\_\+item\+\_\+expanded\+\_\+set(item, EINA\+\_\+\+FALSE) won\textquotesingle{}t hide them. The only thing that happens is that the parent item will change its appearance to represent that it\textquotesingle{}s contracted. And the signal \char`\"{}contracted\char`\"{} will be emitted from the genlist. Thus, we must call \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga36fe8144ee138375a9da2886e71da14b}{elm\+\_\+genlist\+\_\+item\+\_\+subitems\+\_\+clear()}} to delete all its subitems, but still keep a way to recreate them when expanding the parent again. That\textquotesingle{}s why we are going to keep a node struct for each item, that will be the data of the item, with the following information\+:

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\_Node\_Data\ \{}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ *children;}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordtype}{int}\ value;}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordtype}{int}\ level;}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ favorite;}
\DoxyCodeLine{\}\ Node\_Data;}

\end{DoxyCodeInclude}
 This {\ttfamily Node\+\_\+\+Data} contains the value for the item, a number indicating its level under the tree, a list of children (to be able to expand it later) and a boolean indicating if it\textquotesingle{}s a favorite item or not.

We use 3 different item classes in this example\+:

One for items that don\textquotesingle{}t have children\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ nitems\ =\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{char}\ *}
\DoxyCodeLine{\_item\_label\_get(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *part)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ buf[256]\ =\ \{0\};}
\DoxyCodeLine{\ \ \ Node\_Data\ *d\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(part,\ \textcolor{stringliteral}{"{}elm.text"{}}))}
\DoxyCodeLine{\ \ \ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}Item\ \#\ \%i\ (level\ \%i)"{}},\ d-\/>value,\ d-\/>level);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ strdup(buf);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 One for items that have children\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{char}\ *}
\DoxyCodeLine{\_parent\_label\_get(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *part\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ buf[256];}
\DoxyCodeLine{\ \ \ Node\_Data\ *d\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}Group\ \%d\ (\%d\ items)"{}},\ d-\/>value\ /\ 7,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ eina\_list\_count(d-\/>children));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ strdup(buf);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *}
\DoxyCodeLine{\_parent\_content\_get(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *part)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *ic\ =\ \mbox{\hyperlink{group__Elm__Icon_gac369f2d67be417e5cff81e8f001ff326}{elm\_icon\_add}}(obj);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(part,\ \textcolor{stringliteral}{"{}elm.swallow.icon"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic,\ \textcolor{stringliteral}{"{}folder"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gab09d6bf93b5435230b41ceca2abe783a}{evas\_object\_size\_hint\_aspect\_set}}(ic,\ \mbox{\hyperlink{Evas__Common_8h_ac68b577b7c0b79c356f01926e4a8099faeaf1e019f2dbfbbc2da9ab1fe1f175f6}{EVAS\_ASPECT\_CONTROL\_VERTICAL}},\ 1,\ 1);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ ic;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 And one for items that were favorited\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{char}\ *}
\DoxyCodeLine{\_favorite\_label\_get(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *part)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ buf[256]\ =\ \{0\};}
\DoxyCodeLine{\ \ \ Node\_Data\ *d\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(part,\ \textcolor{stringliteral}{"{}elm.text"{}}))}
\DoxyCodeLine{\ \ \ \ \ snprintf(buf,\ \textcolor{keyword}{sizeof}(buf),\ \textcolor{stringliteral}{"{}Favorite\ \#\ \%i"{}},\ d-\/>value);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ strdup(buf);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 The favorite item class is there just to demonstrate the \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gac16cbc443fcb23d89039bb7cde138add}{elm\+\_\+genlist\+\_\+item\+\_\+item\+\_\+class\+\_\+update()}} function in action. It would be much simpler to implement the favorite behavior by just changing the icon inside the icon\+\_\+get functions when the {\ttfamily favorite} boolean is activated.

Now we are going to declare the callbacks for the buttons that add, delete and change items.

First, a button for appending items to the list\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *}
\DoxyCodeLine{\_favorite\_content\_get(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *part)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *ic\ =\ \mbox{\hyperlink{group__Elm__Icon_gac369f2d67be417e5cff81e8f001ff326}{elm\_icon\_add}}(obj);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(part,\ \textcolor{stringliteral}{"{}elm.swallow.icon"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic,\ \textcolor{stringliteral}{"{}apps"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gab09d6bf93b5435230b41ceca2abe783a}{evas\_object\_size\_hint\_aspect\_set}}(ic,\ \mbox{\hyperlink{Evas__Common_8h_ac68b577b7c0b79c356f01926e4a8099faeaf1e019f2dbfbbc2da9ab1fe1f175f6}{EVAS\_ASPECT\_CONTROL\_VERTICAL}},\ 1,\ 1);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ ic;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_append\_cb(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \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__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit,\ *parent\ =\ NULL;}
\DoxyCodeLine{\ \ \ Node\_Data\ *pdata,\ *d\ =\ malloc(\textcolor{keyword}{sizeof}(*d));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ d-\/>children\ =\ NULL;}
\DoxyCodeLine{\ \ \ d-\/>value\ =\ nitems++;}
\DoxyCodeLine{\ \ \ d-\/>favorite\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga2dbee1d6bf7a36751d288cf95e1e6eb0}{elm\_genlist\_selected\_item\_get}}(list);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (glit)}
\DoxyCodeLine{\ \ \ \ \ parent\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga16ce85895d56fb4be950d564ef9f3597}{elm\_genlist\_item\_parent\_get}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (parent)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ d-\/>level\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gad33ad5178da567defeb1b170d535fe51}{elm\_genlist\_item\_expanded\_depth\_get}}(parent)\ +\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ pdata\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(parent);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ pdata-\/>children\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\_list\_append}}(pdata-\/>children,\ d);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ d-\/>level\ =\ 0;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Group_ga869214cf76896bc311c9464ad21126e0}{elm\_genlist\_item\_append}}(list,\ \_itc,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ d,\ parent,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fa1ffe76fc4e7fd2bb40e47290c01ac0df}{ELM\_GENLIST\_ITEM\_NONE}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 If an item is selected, a new item will be appended to the same level of that item, but using the selected item\textquotesingle{}s parent as its parent too. If no item is selected, the new item will be appended to the root of the tree.

Then the callback for marking an item as favorite\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_favorite\_cb(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \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__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga2dbee1d6bf7a36751d288cf95e1e6eb0}{elm\_genlist\_selected\_item\_get}}(list);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!glit)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ Node\_Data\ *d\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(glit);}
\DoxyCodeLine{\ \ \ d-\/>favorite\ =\ !d-\/>favorite;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (d-\/>favorite)}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gac16cbc443fcb23d89039bb7cde138add}{elm\_genlist\_item\_item\_class\_update}}(glit,\ \_itfav);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (d-\/>children)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gac16cbc443fcb23d89039bb7cde138add}{elm\_genlist\_item\_item\_class\_update}}(glit,\ \_itp);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gac16cbc443fcb23d89039bb7cde138add}{elm\_genlist\_item\_item\_class\_update}}(glit,\ \_itc);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gaa24da110b846b5f615b0e90b1f1e35f5}{elm\_genlist\_item\_update}}(glit);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 This callback is very simple, it just changes the item class of the selected item for the \char`\"{}favorite\char`\"{} one, or go back to the \char`\"{}item\char`\"{} or \char`\"{}parent\char`\"{} class depending on that item having children or not.

Now, the most complex operation (adding a child to an item)\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_add\_child\_cb(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \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__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga2dbee1d6bf7a36751d288cf95e1e6eb0}{elm\_genlist\_selected\_item\_get}}(list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\_prev,\ *glit\_parent;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!glit)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ Node\_Data\ *d\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(glit);}
\DoxyCodeLine{\ \ \ glit\_prev\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga6fbee602768cdc0d1d16e665aa2e8154}{elm\_genlist\_item\_prev\_get}}(glit);}
\DoxyCodeLine{\ \ \ glit\_parent\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga16ce85895d56fb4be950d564ef9f3597}{elm\_genlist\_item\_parent\_get}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ change\_item\ =\ !d-\/>children;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ creating\ new\ item\ data}}
\DoxyCodeLine{\ \ \ Node\_Data\ *ndata\ =\ malloc(\textcolor{keyword}{sizeof}(*ndata));}
\DoxyCodeLine{\ \ \ ndata-\/>value\ =\ nitems++;}
\DoxyCodeLine{\ \ \ ndata-\/>children\ =\ NULL;}
\DoxyCodeLine{\ \ \ ndata-\/>favorite\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ ndata-\/>level\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gad33ad5178da567defeb1b170d535fe51}{elm\_genlist\_item\_expanded\_depth\_get}}(glit)\ +\ 1;}
\DoxyCodeLine{\ \ \ d-\/>children\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\_list\_append}}(d-\/>children,\ ndata);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ Changing\ leaf\ item\ to\ parent\ item}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (change\_item)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (glit\_prev\ !=\ glit\_parent)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_gaeacc50b0856eece0534ce6f6094119e5}{elm\_genlist\_item\_insert\_after}}(list,\ \_itp,\ d,\ glit\_parent,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ glit\_prev,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fae3f8be87b286f57bcd0ebe8e93db665a}{ELM\_GENLIST\_ITEM\_TREE}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga868016658aa874d4805fec1371ddb4e4}{elm\_genlist\_item\_prepend}}(list,\ \_itp,\ d,\ glit\_parent,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fae3f8be87b286f57bcd0ebe8e93db665a}{ELM\_GENLIST\_ITEM\_TREE}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\_genlist\_item\_expanded\_set}}(glit,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gabf3f223c07862e2bb450d517b2658b94}{elm\_genlist\_item\_selected\_set}}(glit,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga48a8f862e4f2b96d33ab7181a266a96d}{elm\_genlist\_item\_expanded\_get}}(glit))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Group_ga869214cf76896bc311c9464ad21126e0}{elm\_genlist\_item\_append}}(list,\ \_itc,\ ndata,\ glit,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fa1ffe76fc4e7fd2bb40e47290c01ac0df}{ELM\_GENLIST\_ITEM\_NONE}},\ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gaa24da110b846b5f615b0e90b1f1e35f5}{elm\_genlist\_item\_update}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 This function gets the data of the selected item, create a new data (for the item being added), and appends it to the children list of the selected item.

Then we must check if the selected item (let\textquotesingle{}s call it {\ttfamily item1} now) to which the new item (called {\ttfamily item2} from now on) was already a parent item too (using the parent item class) or just a normal item (using the default item class). In the first case, we just have to append the item to the end of the {\ttfamily item1} children list.

However, if the {\ttfamily item1} didn\textquotesingle{}t have any child previously, we have to change it to a parent item now. It would be easy to just change its item class to the parent type, but there\textquotesingle{}s no way to change the item flags and make it be of the type \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fae3f8be87b286f57bcd0ebe8e93db665a}{ELM\+\_\+\+GENLIST\+\_\+\+ITEM\+\_\+\+TREE}}. Thus, we have to delete it and create a new item, and add this new item to the same position that the deleted one was. That\textquotesingle{}s the reason of the checks inside the bigger {\ttfamily if}.

After adding the item to the newly converted parent, we set it to not expanded (since we don\textquotesingle{}t want to show the added item immediately) and select it again, since the original item was deleted and no item is selected at the moment.

Finally, let\textquotesingle{}s show the callback for deleting items\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_clear\_list(Node\_Data\ *d)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Node\_Data\ *tmp;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}}(d-\/>children,\ tmp)}
\DoxyCodeLine{\ \ \ \ \ \ \_clear\_list(tmp);}
\DoxyCodeLine{\ \ \ free(d);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_del\_item\_cb(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \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__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list\ =\ data;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga2dbee1d6bf7a36751d288cf95e1e6eb0}{elm\_genlist\_selected\_item\_get}}(list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\_parent\ =\ NULL;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!glit)\ \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ Node\_Data\ *pdata,\ *d\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(glit);}
\DoxyCodeLine{\ \ \ glit\_parent\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga16ce85895d56fb4be950d564ef9f3597}{elm\_genlist\_item\_parent\_get}}(glit);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga36fe8144ee138375a9da2886e71da14b}{elm\_genlist\_item\_subitems\_clear}}(glit);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (glit\_parent)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ pdata\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(glit\_parent);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ pdata-\/>children\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga6e81c26272c54177d087b29c965af4d8}{eina\_list\_remove}}(pdata-\/>children,\ d);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \_clear\_list(d);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gaa24da110b846b5f615b0e90b1f1e35f5}{elm\_genlist\_item\_update}}(glit\_parent);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Since we have an iternal list representing each element of our tree, once we delete an item we have to go deleting each child of that item, in our internal list. That\textquotesingle{}s why we have the function {\ttfamily \+\_\+clear\+\_\+list}, which recursively goes freeing all the item data.

This is necessary because only when we really want to delete the item is when we need to delete the item data. When we are just contracting the item, we need to hide the children by deleting them, but keeping the item data.

Now there are two callbacks that will be called whenever the user clicks on the expand/contract icon of the item. They will just request to items to be contracted or expanded\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_expand\_request\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ event\_info;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}expand\ request\ on\ item:\ \%p\(\backslash\)n"{}},\ event\_info);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\_genlist\_item\_expanded\_set}}(glit,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_contract\_request\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ event\_info;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}contract\ request\ on\ item:\ \%p\(\backslash\)n"{}},\ event\_info);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\_genlist\_item\_expanded\_set}}(glit,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 When the \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\+\_\+genlist\+\_\+item\+\_\+expanded\+\_\+set()}} function is called with {\ttfamily EINA\+\_\+\+TRUE}, the {\ttfamily \+\_\+expanded\+\_\+cb} will be called. And when this happens, the subtree of that item must be recreated again. This is done using the internal list stored as item data for each item. The function code follows\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_expanded\_cb(\textcolor{keywordtype}{void}\ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ *l;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glit\ =\ event\_info;}
\DoxyCodeLine{\ \ \ Node\_Data\ *it\_data,\ *d\ =\ \mbox{\hyperlink{group__Elm__General_ga6593639f5568153bff4960224a7fadcb}{elm\_object\_item\_data\_get}}(glit);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list\ =\ \mbox{\hyperlink{group__Elm__General_ga613f9dff1e797ce1d3f41fefe2b22a9b}{elm\_object\_item\_widget\_get}}(glit);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Elm__Gen__Item__Class}{Elm\_Genlist\_Item\_Class}}\ *ic;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(d-\/>children,\ l,\ it\_data)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *nitem;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga9727d3b92987319ac981247bc196bd0f}{Elm\_Genlist\_Item\_Type}}\ type\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fa1ffe76fc4e7fd2bb40e47290c01ac0df}{ELM\_GENLIST\_ITEM\_NONE}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}expanding\ item:\ \#\%d\ from\ parent\ \#\%d\(\backslash\)n"{}},\ it\_data-\/>value,\ d-\/>value);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (it\_data-\/>favorite)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ ic\ =\ \_itfav;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (it\_data-\/>children)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ ic\ =\ \_itp;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ type\ =\ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fae3f8be87b286f57bcd0ebe8e93db665a}{ELM\_GENLIST\_ITEM\_TREE}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \}}

\end{DoxyCodeInclude}
 Each appended item is set to contracted, so we don\textquotesingle{}t have to deal with checking if the item was contracted or expanded before its parent being contracted. It could be easily implemented, though, by adding a flag expanded inside the item data.

Now, the {\ttfamily \+\_\+contracted\+\_\+cb}, which is much simpler\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ ic\ =\ \_itc;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ nitem\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga869214cf76896bc311c9464ad21126e0}{elm\_genlist\_item\_append}}(list,\ ic,\ it\_data,\ glit,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ type,\ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\_genlist\_item\_expanded\_set}}(nitem,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 We just have to call \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga36fe8144ee138375a9da2886e71da14b}{elm\+\_\+genlist\+\_\+item\+\_\+subitems\+\_\+clear()}}, that will take care of deleting every item, and keep the item data still stored (since we don\textquotesingle{}t have any del function set on any of our item classes).

Finally, the code inside {\ttfamily elm\+\_\+main} is very similar to the other examples\+:


\begin{DoxyCodeInclude}{0}
\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,\ *box,\ *fbox;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *list;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ i;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ win\ =\ \mbox{\hyperlink{group__Elm__Win__Group_ga23d9d1ffa0a65a1a1dd482d570db1ba0}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"{}genlist"{}},\ \textcolor{stringliteral}{"{}Genlist"{}});}
\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__Win__Group_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ box\ =\ \mbox{\hyperlink{group__Elm__Box__Group_ga49ec615c90bf8bead2158d5ffab2e445}{elm\_box\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(box,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win,\ box);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(box);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\_itc)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_gaddc052cd4804afe97c2c6a4ac68eb8a4}{elm\_genlist\_item\_class\_new}}();}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc-\/>item\_style\ =\ \textcolor{stringliteral}{"{}default"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc-\/>func.text\_get\ =\ \_item\_label\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc-\/>func.content\_get\ =\ \_item\_content\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc-\/>func.state\_get\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itc-\/>func.del\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\_itp)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_gaddc052cd4804afe97c2c6a4ac68eb8a4}{elm\_genlist\_item\_class\_new}}();}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp-\/>item\_style\ =\ \textcolor{stringliteral}{"{}default"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp-\/>func.text\_get\ =\ \_parent\_label\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp-\/>func.content\_get\ =\ \_parent\_content\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp-\/>func.state\_get\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itp-\/>func.del\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\_itfav)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_gaddc052cd4804afe97c2c6a4ac68eb8a4}{elm\_genlist\_item\_class\_new}}();}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav-\/>item\_style\ =\ \textcolor{stringliteral}{"{}default"{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav-\/>func.text\_get\ =\ \_favorite\_label\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav-\/>func.content\_get\ =\ \_favorite\_content\_get;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav-\/>func.state\_get\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \_itfav-\/>func.del\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ list\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga450dfb84aa3e9c092b9c003db1e1c47f}{elm\_genlist\_add}}(win);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{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{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{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__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(box,\ list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(list);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ fbox\ =\ \mbox{\hyperlink{group__Elm__Box__Group_ga49ec615c90bf8bead2158d5ffab2e445}{elm\_box\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga964ff6e51c328ed9e9a64c73f9e2a21f}{elm\_box\_layout\_set}}(fbox,\ \mbox{\hyperlink{group__Evas__Object__Box__Group_ga92c45845c149cc21fab4fcfd4e7839eb}{evas\_object\_box\_layout\_flow\_horizontal}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(fbox,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{evas\_object\_size\_hint\_align\_set}}(fbox,\ \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}}(box,\ fbox);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(fbox);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \_button\_add(list,\ fbox,\ \textcolor{stringliteral}{"{}append\ item"{}},\ \_append\_cb);}
\DoxyCodeLine{\ \ \ \_button\_add(list,\ fbox,\ \textcolor{stringliteral}{"{}favorite"{}},\ \_favorite\_cb);}
\DoxyCodeLine{\ \ \ \_button\_add(list,\ fbox,\ \textcolor{stringliteral}{"{}add\ child"{}},\ \_add\_child\_cb);}
\DoxyCodeLine{\ \ \ \_button\_add(list,\ fbox,\ \textcolor{stringliteral}{"{}del\ item"{}},\ \_del\_item\_cb);}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ Node\_Data\ *pdata\ =\ NULL;\ \textcolor{comment}{//\ data\ for\ the\ parent\ of\ the\ group}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *glg\ =\ NULL;}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ N\_ITEMS;\ i++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga13a0c231414b86e62f68afe3c6fb462b}{Elm\_Object\_Item}}\ *gli\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Node\_Data\ *data\ =\ malloc(\textcolor{keyword}{sizeof}(*data));\ \textcolor{comment}{//\ data\ for\ this\ item}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ data-\/>children\ =\ NULL;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ data-\/>value\ =\ i;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ data-\/>favorite\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ nitems++;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}creating\ item:\ \#\%d\(\backslash\)n"{}},\ data-\/>value);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (i\ \%\ 3\ ==\ 0)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ glg\ =\ gli\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga869214cf76896bc311c9464ad21126e0}{elm\_genlist\_item\_append}}(list,\ \_itp,\ data,\ NULL,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fae3f8be87b286f57bcd0ebe8e93db665a}{ELM\_GENLIST\_ITEM\_TREE}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_ga2ded3582b3c3ceb4f90ff6c1def80727}{elm\_genlist\_item\_expanded\_set}}(glg,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ pdata\ =\ data;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ data-\/>level\ =\ 0;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ gli\ =\ \mbox{\hyperlink{group__Elm__Genlist__Group_ga869214cf76896bc311c9464ad21126e0}{elm\_genlist\_item\_append}}(list,\ \_itc,\ data,\ glg,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__Genlist__Item__Group_gga9727d3b92987319ac981247bc196bd0fa1ffe76fc4e7fd2bb40e47290c01ac0df}{ELM\_GENLIST\_ITEM\_NONE}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_item\_sel\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (pdata)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ pdata-\/>children\ =\ \mbox{\hyperlink{group__Eina__List__Group_ga625698a383dda8fc0db245a1c7608c49}{eina\_list\_append}}(pdata-\/>children,\ data);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ data-\/>level\ =\ 1;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(list,\ \textcolor{stringliteral}{"{}expand,request"{}},\ \_expand\_request\_cb,\ list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(list,\ \textcolor{stringliteral}{"{}contract,request"{}},\ \_contract\_request\_cb,\ list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(list,\ \textcolor{stringliteral}{"{}expanded"{}},\ \_expanded\_cb,\ list);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(list,\ \textcolor{stringliteral}{"{}contracted"{}},\ \_contracted\_cb,\ list);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(win,\ 420,\ 600);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{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}
 The example will look like this when running\+:

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