\chapter{Toolbar Example -\/ Items with Menus}
\hypertarget{toolbar_example_03}{}\label{toolbar_example_03}\index{Toolbar Example -\/ Items with Menus@{Toolbar Example -\/ Items with Menus}}
Toolbar widgets have support to items with menus.

This kind of item will display a menu when selected by the user.

Let\textquotesingle{}s start populating a toolbar with some regular items, the same way we started \doxysectlink{toolbar_example_02}{Toolbar Example 2}{0}.  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ tb\ =\ \mbox{\hyperlink{group__Elm__Toolbar_ga5132198a651cc7a87bde22d5a707f9a5}{elm\_toolbar\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(tb,\ 0.0,\ 0.0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gaaf1d3e26e36b316977336066b6f56632}{evas\_object\_size\_hint\_align\_set}}(tb,\ \mbox{\hyperlink{Evas__Common_8h_aecbac710f36d52911fc34dcdaf8e729c}{EVAS\_HINT\_FILL}},\ 0.0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(tb);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Toolbar_ga0e6a56df529b9d7e8dbc3d17613b9b22}{elm\_toolbar\_item\_append}}(tb,\ \textcolor{stringliteral}{"{}document-\/print"{}},\ \textcolor{stringliteral}{"{}Print"{}},\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Toolbar_ga0e6a56df529b9d7e8dbc3d17613b9b22}{elm\_toolbar\_item\_append}}(tb,\ \textcolor{stringliteral}{"{}folder-\/new"{}},\ \textcolor{stringliteral}{"{}Folder"{}},\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Toolbar_ga0e6a56df529b9d7e8dbc3d17613b9b22}{elm\_toolbar\_item\_append}}(tb,\ \textcolor{stringliteral}{"{}clock"{}},\ \textcolor{stringliteral}{"{}Clock"{}},\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Toolbar_ga0e6a56df529b9d7e8dbc3d17613b9b22}{elm\_toolbar\_item\_append}}(tb,\ \textcolor{stringliteral}{"{}refresh"{}},\ \textcolor{stringliteral}{"{}Update"{}},\ NULL,\ NULL);}

\end{DoxyCodeInclude}
 The only difference is that we\textquotesingle{}ll keep the default shrink mode, that adds an item with a menu of hidden items.

So, a important thing to do is to set a parent for toolbar menus, or they will use the toolbar as parent, and its size will be restricted to that. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Toolbar_ga7521ff3cdc135c0dd7a0e6d325db7b1e}{elm\_toolbar\_menu\_parent\_set}}(tb,\ win);}

\end{DoxyCodeInclude}
 Not only items\textquotesingle{} menus will respect this parent, but also the own toolbar menu, used to show hidden items.

Next, let\textquotesingle{}s add an item set to display a menu\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ tb\_it\ =\ \mbox{\hyperlink{group__Elm__Toolbar_ga0e6a56df529b9d7e8dbc3d17613b9b22}{elm\_toolbar\_item\_append}}(tb,\ \textcolor{stringliteral}{"{}mail-\/send"{}},\ \textcolor{stringliteral}{"{}Send\ Mail"{}},\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ elm\_toolbar\_item\_menu\_set(tb\_it,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 Now, to add two options to this item, we can get the menu object and use it as a regular elm\+\_\+menu. See \doxysectlink{tutorial_menu}{Menu example}{0} for more about menu widget. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ menu\ =\ elm\_toolbar\_item\_menu\_get(tb\_it);}
\DoxyCodeLine{\ \ \ elm\_menu\_item\_add(menu,\ NULL,\ \textcolor{stringliteral}{"{}emptytrash"{}},\ \textcolor{stringliteral}{"{}Empty\ Trash"{}},\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ elm\_menu\_item\_add(menu,\ NULL,\ \textcolor{stringliteral}{"{}trashcan\_full"{}},\ \textcolor{stringliteral}{"{}Full\ Trash"{}},\ NULL,\ NULL);}

\end{DoxyCodeInclude}
 See \doxylink{toolbar_example_03_8c-example}{toolbar\+\_\+example\+\_\+03.c}, whose window should look like this picture\+:

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