

As told in their documentation blocks, the elm\+\_\+app\+\_\+compile\+\_\+$\ast$\+\_\+dir\+\_\+set() family of functions have to be called before \mbox{\hyperlink{group__Elm__App_ga0cefb59efb95841232561d67e34d9909}{elm\+\_\+app\+\_\+info\+\_\+set()}}\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{comment}{/* tell elm about our app so it can figure out where to get files */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__App_gaedf0adf5c965a79a28f43b9c4cb49762}{elm\_app\_compile\_bin\_dir\_set}}(BIN\_DIR);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__App_ga4e875d27efb02b4c425619957c0ae7c7}{elm\_app\_compile\_data\_dir\_set}}(DATA\_DIR);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__App_ga9e553b1adb80795b58e101c28fc0adef}{elm\_app\_compile\_lib\_dir\_set}}(LIB\_DIR);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__App_ga0cefb59efb95841232561d67e34d9909}{elm\_app\_info\_set}}(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/logo.png"});}

\end{DoxyCodeInclude}


We are here setting the fallback paths to the compiling time target paths, naturally. If you\textquotesingle{}re building the example out of the project\textquotesingle{}s build system, we\textquotesingle{}re assuming they are the canonical ones.

After the program starts, \mbox{\hyperlink{group__Elm__App_ga0cefb59efb95841232561d67e34d9909}{elm\+\_\+app\+\_\+info\+\_\+set()}} will actually run and then you\textquotesingle{}ll see a problem\+: Elementary does the prefix lookup {\bfseries{twice}}. This is so because of the quicklaunch infrastructure in Elementary (Start), which will register a predefined prefix for possible users of the launch schema. We\textquotesingle{}re not hooking into a quick launch, so this first call can\textquotesingle{}t be avoided.

If you ran this example from your \char`\"{}bindir\char`\"{} installation directory, no output will emerge from these both attempts -- it will find the \char`\"{}magic\char`\"{} file there registered and set the prefixes silently. Otherwise, you could get something like\+: \begin{DoxyVerb}WARNING: Could not determine its installed prefix for 'ELM'
      so am falling back on the compiled in default:
        usr
      implied by the following:
        bindir    = usr/lib
        libdir    = usr/lib
        datadir   = usr/share/elementary
        localedir = usr/share/locale
      Try setting the following environment variables:
        ELM_PREFIX     - points to the base prefix of install
      or the next 4 variables
        ELM_BIN_DIR    - provide a specific binary directory
        ELM_LIB_DIR    - provide a specific library directory
        ELM_DATA_DIR   - provide a specific data directory
        ELM_LOCALE_DIR - provide a specific locale directory
\end{DoxyVerb}
 if you also didn\textquotesingle{}t change those environment variables (remember they are also a valid way of communicating your prefix to the binary) -\/ this is the scenario where it fallbacks to the paths set for compile time.

Then, you can check the prefixes set on the standard output\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"prefix was set to: \%s\(\backslash\)n"}, \mbox{\hyperlink{group__Elm__App_gaff335edd418543d7fba447757c1da585}{elm\_app\_prefix\_dir\_get}}());}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"data directory is: \%s\(\backslash\)n"}, \mbox{\hyperlink{group__Elm__App_ga92a09dbf88cc1ca3eab51c51dea589d0}{elm\_app\_data\_dir\_get}}());}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"library directory is: \%s\(\backslash\)n"}, \mbox{\hyperlink{group__Elm__App_gaebb58baebbfa5cc79ec0668293ee3623}{elm\_app\_lib\_dir\_get}}());}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"locale directory is: \%s\(\backslash\)n"}, \mbox{\hyperlink{group__Elm__App_ga387d986f89742ea5d5ee6453ba60996e}{elm\_app\_locale\_dir\_get}}());}

\end{DoxyCodeInclude}


In the fragment 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{comment}{/* by using this policy value, we avoid having to}}
\DoxyCodeLine{\textcolor{comment}{    * evas\_object\_smart\_callback\_add(win, "delete,request", \_on\_exit, NULL),}}
\DoxyCodeLine{\textcolor{comment}{    * calling elm\_exit() on that callback ourselves.}}
\DoxyCodeLine{\textcolor{comment}{    */}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga7a05f37fd3a019da5e26c5fc91fcd937}{elm\_policy\_set}}(\mbox{\hyperlink{group__Elm__General_ggaa16f3378ecdbf660fa378402e3c5a0a9a02fadb6faada04b19d0fa42c11a8d32a}{ELM\_POLICY\_QUIT}}, \mbox{\hyperlink{group__Elm__General_gga46af37e6ac2c406321060be827117196abbe0962d88ae12afe1a173da881f56cd}{ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 we demonstrate the use of Elementary policies. The policy defining under which circumstances our application should quit automatically is set to when its last window is closed (this one has just one window, though). This will save us from having to set a callback ourselves on the window, like done in \mbox{\hyperlink{bg_example_01_c}{this}} example. Note that we need to tell the window to delete itself\textquotesingle{}s object on a request to destroy the canvas coming, with \mbox{\hyperlink{group__Elm__Win_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\+\_\+win\+\_\+autodel\+\_\+set()}}.

What follows is some boilerplate code, creating a frame with a {\bfseries{button}}, our object of interest, and, below, widgets to change the button\textquotesingle{}s behavior and exemplify the group of functions in question.

 We enabled the focus highlight object for this window, so that you can keep track of the current focused object better\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_gaac351764768c41d7c5faa76932a919cd}{elm\_win\_focus\_highlight\_enabled\_set}}(win, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(win);}

\end{DoxyCodeInclude}
 Use the tab key to navigate through the focus chain.

 While creating the button, we exemplify how to use Elementary\textquotesingle{}s finger size information to scale our UI\+: 
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}


 The first checkbox\textquotesingle{}s callback is\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_btn\_enabled\_cb(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                \textcolor{keywordtype}{void}        *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga6849a57df3316eabad5bec443bf87597}{elm\_object\_disabled\_set}}(d.btn, !d.btn\_enabled);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 When unsetting the checkbox, we disable the button, which will get a new decoration (greyed out) and stop receiving events. The focus chain will also ignore it.

Following, there are 2 more buttons whose actions are focus/unfocus the top button, respectively\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/* focus callback */}}
\DoxyCodeLine{\_btn\_focus\_cb(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{              \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{              \textcolor{keywordtype}{void}        *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Focus_ga05e39b5e60ad861c63100c811855ef55}{elm\_object\_focus\_set}}(d.btn, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 and 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/* unfocus callback */}}
\DoxyCodeLine{\_btn\_unfocus\_cb(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                \textcolor{keywordtype}{void}        *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Focus_ga05e39b5e60ad861c63100c811855ef55}{elm\_object\_focus\_set}}(d.btn, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Note the situations in which they won\textquotesingle{}t take effect\+:
\begin{DoxyItemize}
\item the button is not allowed to get focus or
\item the button is disabled
\end{DoxyItemize}

The first restriction above you\textquotesingle{}ll get by a second checkbox, whose callback is\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{/* focus allow callback */}}
\DoxyCodeLine{\_btn\_focus\_allow\_cb(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                    \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{                    \textcolor{keywordtype}{void}        *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Focus_gaab06e876ce12b5f52c8e88615850c6f9}{elm\_object\_focus\_allow\_set}}(d.btn, d.btn\_gets\_focus);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Note that the button will still get mouse events, though.

Next, there\textquotesingle{}s a slider controlling the button\textquotesingle{}s scale\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void} \textcolor{comment}{/* scaling callback */}}
\DoxyCodeLine{\_btn\_scale\_cb(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{              \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj,}
\DoxyCodeLine{              \textcolor{keywordtype}{void}        *event \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Scaling_ga1606f51f88c4d0b58544d36225420a37}{elm\_object\_scale\_set}}(d.btn, \mbox{\hyperlink{group__Elm__Slider_ga2dd3f70cdbcb4a81b5d7a08a18afaa1d}{elm\_slider\_value\_get}}(obj));}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


Experiment with it, so you understand the effect better. If you change its value, it will mess with the button\textquotesingle{}s original size, naturally.

The full code for this example can be found \mbox{\hyperlink{general_functions_example_c}{here}}. 