
\begin{DoxyCodeInclude}

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

\textcolor{comment}{/* 'done' cb */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_fs\_done(\textcolor{keywordtype}{void}        *data,
         Evas\_Object *obj,
         \textcolor{keywordtype}{void}        *event\_info)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *selected = event\_info;
   \textcolor{comment}{/* event\_info contains the full path of the selected file or NULL}
\textcolor{comment}{    * if none is selected (or cancel is pressed) */}

   printf(\textcolor{stringliteral}{"We're done! Selected file is: %s\(\backslash\)n"},
          selected ? selected : \textcolor{stringliteral}{"*none!*"});

   elm_exit();
\}

\textcolor{comment}{/* 'selected' cb */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_fs\_selected(\textcolor{keywordtype}{void}        *data,
             Evas\_Object *obj,
             \textcolor{keywordtype}{void}        *event\_info)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *selected = event\_info;
   \textcolor{comment}{/* event\_info contains the full path of the selected file */}

   printf(\textcolor{stringliteral}{"There's been a selection: %s\(\backslash\)n"}, selected);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_is\_save\_clicked(\textcolor{keywordtype}{void}        *data,
                 Evas\_Object *obj,
                 \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *fs = data;
   Eina\_Bool old\_val = elm_fileselector_is_save_get(fs);

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

   elm_fileselector_is_save_set(fs, !old\_val);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_folder\_only\_clicked(\textcolor{keywordtype}{void}        *data,
                     Evas\_Object *obj,
                     \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *fs = data;
   Eina\_Bool old\_val = elm_fileselector_folder_only_get(fs);

   printf(\textcolor{stringliteral}{"%s folder-only mode\(\backslash\)n"},
          old\_val ? \textcolor{stringliteral}{"Disabling"} : \textcolor{stringliteral}{"Enabling"});

   elm_fileselector_folder_only_set(fs, !old\_val);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_expandable\_clicked(\textcolor{keywordtype}{void}        *data,
                    Evas\_Object *obj,
                    \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *fs = data;
   Eina\_Bool old\_val = elm_fileselector_expandable_get(fs);

   printf(\textcolor{stringliteral}{"%s tree-view mode\(\backslash\)n"},
          old\_val ? \textcolor{stringliteral}{"Disabling"} : \textcolor{stringliteral}{"Enabling"});

   elm_fileselector_expandable_set(fs, !old\_val);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_sel\_get\_clicked(\textcolor{keywordtype}{void}        *data,
                 Evas\_Object *obj,
                 \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *fs = data;
   printf(\textcolor{stringliteral}{"Current selection is: %s\(\backslash\)n"}, elm_fileselector_selected_get(fs));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_path\_get\_clicked(\textcolor{keywordtype}{void}        *data,
                  Evas\_Object *obj,
                  \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *fs = data;
   printf(\textcolor{stringliteral}{"Current selection's directory path is: %s\(\backslash\)n"},
          elm_fileselector_path_get(fs));
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int}    argc,
         \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *fs, *vbox, *buttons\_bx, *bt, *sep, *bx;

   \textcolor{comment}{/* Set the locale according to the system pref. If you dont do so}
\textcolor{comment}{    * the file selector will order the files list in a case sensitive}
\textcolor{comment}{    * manner}
\textcolor{comment}{    */}
   setlocale(LC\_ALL, \textcolor{stringliteral}{""});

   elm_need_ethumb(); \textcolor{comment}{/* let's have thumbnails of images on grid view */}
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

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

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

   vbox = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(vbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(vbox, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_show(vbox);
   elm_box_pack_end(bx, vbox);

   \textcolor{comment}{/* first file selector, in list mode */}
   fs = elm_fileselector_add(win);
   \textcolor{comment}{/* enable the fs file name entry */}
   elm_fileselector_is_save_set(fs, EINA\_TRUE);
   \textcolor{comment}{/* custom list view */}
   elm_fileselector_expandable_set(fs, EINA\_FALSE);
   \textcolor{comment}{/* start the fileselector in the /tmp/ dir */}
   elm_fileselector_path_set(fs, \textcolor{stringliteral}{"/tmp"});

   evas\_object\_size\_hint\_weight\_set(fs, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(fs, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(vbox, fs);
   evas\_object\_show(fs);

   \textcolor{comment}{/* the 'done' cb is called when the user presses ok/cancel */}
   evas\_object\_smart\_callback\_add(fs, \textcolor{stringliteral}{"done"}, \_fs\_done, win);
   \textcolor{comment}{/* the 'selected' cb is called when the user clicks on a file/dir */}
   evas\_object\_smart\_callback\_add(fs, \textcolor{stringliteral}{"selected"}, \_fs\_selected, win);

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

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

   bt = elm_check_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"editable selection"});
   elm_check_state_set(bt, elm_fileselector_is_save_get(fs));
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"changed"}, \_is\_save\_clicked, fs);
   elm_box_pack_end(buttons\_bx, bt);
   evas\_object\_show(bt);

   bt = elm_check_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"folders only"});
   elm_check_state_set(bt, elm_fileselector_folder_only_get(fs));
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"changed"}, \_folder\_only\_clicked, fs);
   elm_box_pack_end(buttons\_bx, bt);
   evas\_object\_show(bt);

   bt = elm_check_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"expandable"});
   elm_check_state_set(bt, elm_fileselector_expandable_get(fs));
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"changed"}, \_expandable\_clicked, fs);
   elm_box_pack_end(buttons\_bx, bt);
   evas\_object\_show(bt);

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

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Print selection"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_sel\_get\_clicked, fs);
   elm_box_pack_end(buttons\_bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Print path"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_path\_get\_clicked, fs);
   elm_box_pack_end(buttons\_bx, bt);
   evas\_object\_show(bt);

   sep = elm_separator_add(win);
   elm_separator_horizontal_set(sep, EINA\_FALSE);
   elm_box_pack_end(bx, sep);
   evas\_object\_show(sep);

   \textcolor{comment}{/* second file selector, now with grid view */}
   fs = elm_fileselector_add(win);
   elm_fileselector_is_save_set(fs, EINA\_TRUE);
   elm_fileselector_mode_set(fs, ELM\_FILESELECTOR\_GRID);
   elm_fileselector_buttons_ok_cancel_set(fs, EINA\_FALSE);
   elm_fileselector_path_set(fs, \textcolor{stringliteral}{"/tmp"});

   evas\_object\_size\_hint\_weight\_set(fs, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(fs, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(bx, fs);
   evas\_object\_show(fs);

   evas\_object\_resize(win, 800, 600);
   evas\_object\_show(win);

   elm_run();

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