This code places an Elementary file selector button widget on a window, along with some other checkboxes and a text entry.

Those are there just as knobs on the file selector button's state and to display information from it.

Here's how we instantiate it\-:  
\begin{DoxyCodeInclude}
   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"file"});
   evas\_object\_size\_hint\_aspect\_set(ic, EVAS\_ASPECT\_CONTROL\_VERTICAL, 1, 1);

   \textcolor{comment}{/* file selector button */}
   fs\_bt = elm_fileselector_button_add(win);
   elm_fileselector_button_path_set(fs\_bt, \textcolor{stringliteral}{"/tmp"});
   elm\_object\_text\_set(fs\_bt, \textcolor{stringliteral}{"Select a file"});
   elm_object_part_content_set(fs\_bt, \textcolor{stringliteral}{"icon"}, ic);

   elm_box_pack_end(vbox, fs\_bt);
   evas\_object\_show(fs\_bt);

\end{DoxyCodeInclude}


Note that we set on it both icon and label decorations. It's set to list the contents of the {\ttfamily \char`\"{}/tmp\char`\"{}} directory, too, with \hyperlink{group__File__Selector__Button_ga1a052144f4e779d15e5928b2a39e79f9}{elm\-\_\-fileselector\-\_\-button\-\_\-path\-\_\-set()}. What follows are checkboxes to exercise some of its A\-P\-I funtions\-:  
\begin{DoxyCodeInclude}
   ck = elm_check_add(win);
   elm\_object\_text\_set(ck, \textcolor{stringliteral}{"editable selection"});
   elm_check_state_set(ck, elm_fileselector_button_is_save_get(fs\_bt));
   evas\_object\_smart\_callback\_add(ck, \textcolor{stringliteral}{"changed"}, \_current\_sel\_toggle, fs\_bt);
   elm_box_pack_end(hbox, ck);
   evas\_object\_show(ck);

   ck = elm_check_add(win);
   elm\_object\_text\_set(ck, \textcolor{stringliteral}{"\(\backslash\)"inwin\(\backslash\)" mode"});
   elm_check_state_set(ck, elm_fileselector_button_inwin_mode_get(fs\_bt));
   evas\_object\_smart\_callback\_add(ck, \textcolor{stringliteral}{"changed"}, \_inwin\_mode\_toggle, fs\_bt);
   elm_box_pack_end(hbox, ck);
   evas\_object\_show(ck);

   ck = elm_check_add(win);
   elm\_object\_text\_set(ck, \textcolor{stringliteral}{"folders only"});
   elm_check_state_set(ck, elm_fileselector_button_folder_only_get(fs\_bt));
   evas\_object\_smart\_callback\_add(ck, \textcolor{stringliteral}{"changed"}, \_folder\_only\_toggle, fs\_bt);
   elm_box_pack_end(hbox, ck);
   evas\_object\_show(ck);

   ck = elm_check_add(win);
   elm\_object\_text\_set(ck, \textcolor{stringliteral}{"expandable"});
   elm_check_state_set(ck, elm_fileselector_button_expandable_get(fs\_bt));
   evas\_object\_smart\_callback\_add(ck, \textcolor{stringliteral}{"changed"}, \_expandable\_toggle, fs\_bt);
   elm_box_pack_end(hbox, ck);
   evas\_object\_show(ck);

   lb = elm_label_add(win);
   elm\_object\_text\_set(lb, \textcolor{stringliteral}{"Last selection:"});
   elm_box_pack_end(vbox, lb);
   evas\_object\_show(lb);

   en = elm_entry_add(win);
   elm\_entry\_line\_wrap\_set(en, EINA\_FALSE);
   elm_entry_editable_set(en, EINA\_FALSE);
   evas\_object\_smart\_callback\_add(fs\_bt, \textcolor{stringliteral}{"file,chosen"}, \_file\_chosen, en);
   elm_box_pack_end(vbox, en);
   evas\_object\_show(en);

\end{DoxyCodeInclude}


The checkboxes will toggle whether the file selector button's internal file selector\-:
\begin{DoxyItemize}
\item must have an editable text entry for file names (thus, be in \char`\"{}save dialog mode\char`\"{})
\item is to be raised as an \char`\"{}inner window\char`\"{} (note it's the default behavior) or as a dedicated window
\item is to populate its view with folders only
\item is to expand its folders, in its view, {\bfseries in place}, and not repainting it entirely just with the contents of a sole directory.
\end{DoxyItemize}

The entry labeled {\ttfamily \char`\"{}\-Last selection\char`\"{}} will exercise the {\ttfamily \char`\"{}file,chosen\char`\"{}} smart event coming from the file selector button\-:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void} \textcolor{comment}{/* hook on the sole smart callback */}
\_file\_chosen(\textcolor{keywordtype}{void}            *data,
             Evas\_Object *obj,
             \textcolor{keywordtype}{void}            *event\_info)
\{
   Evas\_Object *entry = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file = event\_info;
   \textcolor{keywordflow}{if} (file)
     \{
        elm\_object\_text\_set(entry, file);
        printf(\textcolor{stringliteral}{"File chosen: %s\(\backslash\)n"}, file);
     \}
   \textcolor{keywordflow}{else}
     printf(\textcolor{stringliteral}{"File selection canceled.\(\backslash\)n"});
\}

\textcolor{comment}{/* toggle inwin mode */}

\end{DoxyCodeInclude}


Whenever you dismiss or acknowledges the file selector, after it's raised, the {\ttfamily event\-\_\-info} string will contain the last selection on it (if any was made).

This is how the example, just after called, should look like\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/fileselector_button_example_00}
\caption{width=}
\end{DoxyImage}


Click on the file selector button to raise its internal file selector, which will be contained on an {\bfseries \char`\"{}inner window\char`\"{}}\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/fileselector_button_example_01}
\caption{width=}
\end{DoxyImage}


Toggle the \char`\"{}inwin mode\char`\"{} switch off and, if you click on the file selector button again, you'll get {\bfseries two} windows, the original one (note the last selection there!)

 
\begin{DoxyImage}
\includegraphics{screenshots/fileselector_button_example_02}
\caption{width=}
\end{DoxyImage}


and the file selector's new one

 
\begin{DoxyImage}
\includegraphics{screenshots/fileselector_button_example_03}
\caption{width=}
\end{DoxyImage}


Play with the checkboxes to get the behavior changes on the file selector button. The respective A\-P\-I calls on the widget coming from those knobs where shown in the code already.

See the full \hyperlink{fileselector_button_example_c}{source code} for this example. 