This code places an Elementary toolbar widget on a window, to exemplify part of the widget\textquotesingle{}s A\+PI.

Let\textquotesingle{}s start adding a button to our window, that will have its text modified depending on which item is selected. It\textquotesingle{}s used just to exemplify how to change a window content from the toolbar.  
\begin{DoxyCodeInclude}
   bt = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(bt, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(bt, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Button"});
   evas\_object\_show(bt);

\end{DoxyCodeInclude}


Also, we\textquotesingle{}ll need a toolbar widget, obviously\+: 
\begin{DoxyCodeInclude}
   tb = elm_toolbar_add(win);
   elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
   evas\_object\_size\_hint\_weight\_set(tb, 0.0, 0.0);
   evas\_object\_size\_hint\_align\_set(tb, EVAS\_HINT\_FILL, 0.0);
   evas\_object\_show(tb);

\end{DoxyCodeInclude}


When appending an item is possible to set an icon, label, and a callback function that will receive passed data. 
\begin{DoxyCodeInclude}
   elm_toolbar_item_append(tb, \textcolor{stringliteral}{"document-print"}, \textcolor{stringliteral}{"Print"}, \_item\_1\_pressed, bt);
   elm_toolbar_item_append(tb, \textcolor{stringliteral}{"folder-new"}, \textcolor{stringliteral}{"New Folder"}, \_item\_2\_pressed, bt);

\end{DoxyCodeInclude}


It\textquotesingle{}s possible to disable items, so the user can\textquotesingle{}t select then. We will disable the third item\+: 
\begin{DoxyCodeInclude}
   tb\_it = elm_toolbar_item_append(tb, \textcolor{stringliteral}{"mail-send"}, \textcolor{stringliteral}{"Create and send email"},
                                   \_item\_3\_pressed, bt);
   elm\_object\_item\_disabled\_set(tb\_it, EINA\_TRUE);

\end{DoxyCodeInclude}


Our callbacks will just set button\textquotesingle{}s label\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_item\_2\_pressed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *bt = data;
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Create new folder"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_item\_3\_pressed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{comment}{/* This function won't be called because we disabled item that call it */}
   Evas\_Object *bt = data;
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Create and send email"});
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bx, *tb, *bt;
   Elm_Object_Item *tb\_it;

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"toolbar"}, \textcolor{stringliteral}{"Toolbar Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   bx = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(bx, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, bx);
   evas\_object\_show(bx);

   bt = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(bt, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(bt, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Button"});
   evas\_object\_show(bt);

   tb = elm_toolbar_add(win);
   elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
   evas\_object\_size\_hint\_weight\_set(tb, 0.0, 0.0);
   evas\_object\_size\_hint\_align\_set(tb, EVAS\_HINT\_FILL, 0.0);
   evas\_object\_show(tb);

   elm_toolbar_item_append(tb, \textcolor{stringliteral}{"document-print"}, \textcolor{stringliteral}{"Print"}, \_item\_1\_pressed, bt);
   elm_toolbar_item_append(tb, \textcolor{stringliteral}{"folder-new"}, \textcolor{stringliteral}{"New Folder"}, \_item\_2\_pressed, bt);

   tb\_it = elm_toolbar_item_append(tb, \textcolor{stringliteral}{"mail-send"}, \textcolor{stringliteral}{"Create and send email"},
                                   \_item\_3\_pressed, bt);
   elm\_object\_item\_disabled\_set(tb\_it, EINA\_TRUE);

   elm_toolbar_homogeneous_set(tb, EINA\_FALSE);

   elm_box_pack_end(bx, tb);
   elm_box_pack_end(bx, bt);

   evas\_object\_resize(win, 200, 200);
   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}


By default, toolbars would display items homogeneously, so item with long labels, like the third, will make all of them occupy a lot of space. To avoid that, we can disable it\+:  
\begin{DoxyCodeInclude}
   elm_toolbar_homogeneous_set(tb, EINA\_FALSE);

\end{DoxyCodeInclude}


Another default behavior, is to add an menu item if we have more items that would fit on toolbar size. To simply enable scroll, without menus, it\textquotesingle{}s required to change toolbar\textquotesingle{}s shrink mode\+:  
\begin{DoxyCodeInclude}
   elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);

\end{DoxyCodeInclude}


See \hyperlink{toolbar_example_01_8c-example}{toolbar\+\_\+example\+\_\+01.c}, whose window should look like this picture\+:

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