\section{location\+\_\+example\+\_\+01.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o location\_example\_01 location\_example\_01.c -g `pkg-config --cflags --libs elementary elocation`}

\textcolor{preprocessor}{#include <Elementary.h>}
\textcolor{preprocessor}{#ifdef ELM\_ELOCATION}
\textcolor{preprocessor}{#include <Elocation.h>}
\textcolor{preprocessor}{#endif}

\textcolor{keyword}{static} Evas\_Object *label, *win;

\textcolor{preprocessor}{#ifdef ELM\_ELOCATION}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_print\_position(Elocation\_Position *position)
\{
   \textcolor{keywordtype}{char} buffer[1024];

   \textcolor{keywordflow}{if} (!position) \textcolor{keywordflow}{return};
   snprintf(buffer, \textcolor{keyword}{sizeof}(buffer),
            \textcolor{stringliteral}{"<b>GeoClue position reply with data from timestamp</b> %i<br/>"}
            \textcolor{stringliteral}{"<b>Latitude:</b> %f<br/>"}
            \textcolor{stringliteral}{"<b>Longitude:</b> %f<br/>"}
            \textcolor{stringliteral}{"<b>Altitude:</b> %f<br/>"}
            \textcolor{stringliteral}{"<b>Accuracy level:</b> %i<br/>"}
            \textcolor{stringliteral}{"<b>Accuracy horizontal:</b> %f<br/>"}
            \textcolor{stringliteral}{"<b>Accuracy vertical:</b> %f"},
            position->timestamp, position->latitude, position->longitude,
            position->altitude, position->accur->level,
            position->accur->horizontal, position->accur->vertical);
   elm\_object\_text\_set(label, buffer);
\}

\textcolor{keyword}{static} Eina\_Bool
\_position\_changed(\textcolor{keywordtype}{void} *data, \textcolor{keywordtype}{int} ev\_type, \textcolor{keywordtype}{void} *event)
\{
   Elocation\_Position *position;

   position = event;
   \_print\_position(position);
   \textcolor{keywordflow}{return} ECORE\_CALLBACK\_DONE;
\}
\textcolor{preprocessor}{#endif}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
\textcolor{preprocessor}{#ifdef ELM\_ELOCATION}
   Elocation\_Address *address;
   Elocation\_Position *position;
\textcolor{preprocessor}{#endif}

   \textcolor{comment}{/* The program will proceed only if Ewebkit library is available. */}
   \textcolor{keywordflow}{if} (elm\_need\_elocation() == EINA\_FALSE)
     \textcolor{keywordflow}{return} -1;

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

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"elocation"}, \textcolor{stringliteral}{"Elocation example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   label = elm_label_add(win);
   elm_label_line_wrap_set(label, ELM\_WRAP\_CHAR);
   elm\_object\_text\_set(label, \textcolor{stringliteral}{"Getting location ..."});
   evas\_object\_size\_hint\_weight\_set(label, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(label, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_ALWAYS);
   evas\_object\_resize(label, 600, 480);
   evas\_object\_show(label);

\textcolor{preprocessor}{#ifdef ELM\_ELOCATION}
   address = elocation\_address\_new();
   position = elocation\_position\_new();

   ecore\_event\_handler\_add(ELOCATION\_EVENT\_POSITION, \_position\_changed, NULL);

   elocation\_position\_get(position);
   \_print\_position(position);
\textcolor{preprocessor}{#endif}

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

   elm_run();

\textcolor{preprocessor}{#ifdef ELM\_ELOCATION}
   elocation\_position\_free(position);
   elocation\_address\_free(address);
\textcolor{preprocessor}{#endif}

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