
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Elementary.h>}

\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 */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_inwin\_mode\_toggle(\textcolor{keywordtype}{void}            *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *fs\_bt = data;
   Eina\_Bool old\_val = elm_fileselector_button_inwin_mode_get(fs\_bt);

   elm_fileselector_button_inwin_mode_set(fs\_bt, !old\_val);
   printf(\textcolor{stringliteral}{"Inwin mode set to: %s\(\backslash\)n"}, old\_val ? \textcolor{stringliteral}{"false"} : \textcolor{stringliteral}{"true"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_current\_sel\_toggle(\textcolor{keywordtype}{void}            *data,
                    Evas\_Object *obj,
                    \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *fs\_bt = data;
   Eina\_Bool old\_val = elm_fileselector_button_is_save_get(fs\_bt);
   elm_fileselector_button_is_save_set(fs\_bt, !old\_val);

   printf(\textcolor{stringliteral}{"%s text entry with selected item's name\(\backslash\)n"},
          old\_val ? \textcolor{stringliteral}{"Disabling"} : \textcolor{stringliteral}{"Enabling"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_folder\_only\_toggle(\textcolor{keywordtype}{void}            *data,
                    Evas\_Object *obj,
                    \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *fs\_bt = data;
   Eina\_Bool old\_val = elm_fileselector_button_folder_only_get(fs\_bt);
   elm_fileselector_button_folder_only_set(fs\_bt, !old\_val);

   printf(\textcolor{stringliteral}{"Folder only mode set to: %s\(\backslash\)n"}, old\_val ? \textcolor{stringliteral}{"false"} : \textcolor{stringliteral}{"true"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_expandable\_toggle(\textcolor{keywordtype}{void}            *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *fs\_bt = data;
   Eina\_Bool old\_val = elm_fileselector_button_expandable_get(fs\_bt);
   elm_fileselector_button_expandable_set(fs\_bt, !old\_val);

   printf(\textcolor{stringliteral}{"Expandable folders mode set to: %s\(\backslash\)n"}, old\_val ? \textcolor{stringliteral}{"false"} : \textcolor{stringliteral}{"true"});
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int}    argc,
         \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *vbox, *hbox, *ic, *ck, *fs\_bt, *en, *lb, *sep;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"fileselector-button"}, \textcolor{stringliteral}{"File Selector Button Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

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

   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);
   evas\_object\_show(ic);

   \textcolor{comment}{/* attribute setting knobs */}
   sep = elm_separator_add(win);
   elm_separator_horizontal_set(sep, EINA\_TRUE);
   elm_box_pack_end(vbox, sep);
   evas\_object\_show(sep);

   hbox = elm_box_add(win);
   elm_box_horizontal_set(hbox, EINA\_TRUE);
   elm_box_pack_end(vbox, hbox);
   evas\_object\_show(hbox);

   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);

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

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 