\hypertarget{group__Elm__Start}{}\doxysection{Getting Started}
\label{group__Elm__Start}\index{Getting Started@{Getting Started}}


To write an Elementary app, you can get started with the following\+:  


To write an Elementary app, you can get started with the following\+: 


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Elementary.h>}}
\DoxyCodeLine{EAPI\_MAIN\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ **argv)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ create\ window(s)\ here\ and\ do\ any\ application\ init}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gadf2553f83e6b0b9c7fbe054019a664a1}{elm\_run}}();\ \textcolor{comment}{//\ run\ main\ loop}}
\DoxyCodeLine{\ \ \textcolor{keywordflow}{return}\ 0;\ \textcolor{comment}{//\ exit\ 0\ for\ exit\ code}}
\DoxyCodeLine{\}}
\DoxyCodeLine{\mbox{\hyperlink{group__Elm__General_ga50fe52d513f7e89c9c770afd76de7ad9}{ELM\_MAIN}}()}

\end{DoxyCode}


To use autotools (which helps in many ways in the long run, like being able to immediately create releases of your software directly from your tree and ensure everything needed to build it is there) you will need a configure.\+ac, Makefile.\+am and autogen.\+sh file.

configure.\+ac\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{AC\_INIT(myapp,\ 0.0.0,\ myname@mydomain.com)}
\DoxyCodeLine{AC\_PREREQ(2.52)}
\DoxyCodeLine{AC\_CONFIG\_SRCDIR(configure.ac)}
\DoxyCodeLine{AM\_CONFIG\_HEADER(config.h)}
\DoxyCodeLine{AC\_PROG\_CC}
\DoxyCodeLine{AM\_INIT\_AUTOMAKE(1.6\ dist-\/bzip2)}
\DoxyCodeLine{PKG\_CHECK\_MODULES([ELEMENTARY],\ elementary)}
\DoxyCodeLine{AC\_OUTPUT(Makefile)}

\end{DoxyCode}


Makefile.\+am\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{AUTOMAKE\_OPTIONS\ =\ 1.4\ foreign}
\DoxyCodeLine{MAINTAINERCLEANFILES\ =\ Makefile.in\ aclocal.m4\ config.h.in\ configure\ depcomp\ install-\/sh\ missing}
\DoxyCodeLine{}
\DoxyCodeLine{INCLUDES\ =\ -\/I\$(top\_srcdir)}
\DoxyCodeLine{}
\DoxyCodeLine{bin\_PROGRAMS\ =\ myapp}
\DoxyCodeLine{}
\DoxyCodeLine{myapp\_SOURCES\ =\ main.c}
\DoxyCodeLine{myapp\_LDADD\ =\ @ELEMENTARY\_LIBS@}
\DoxyCodeLine{myapp\_CFLAGS\ =\ @ELEMENTARY\_CFLAGS@}

\end{DoxyCode}


autogen.\+sh\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#!/bin/sh}}
\DoxyCodeLine{\ echo\ \textcolor{stringliteral}{"{}Running\ aclocal..."{}}\ ;\ aclocal\ \$ACLOCAL\_FLAGS\ ||\ exit\ 1}
\DoxyCodeLine{\ echo\ \textcolor{stringliteral}{"{}Running\ autoheader..."{}}\ ;\ autoheader\ ||\ exit\ 1}
\DoxyCodeLine{\ echo\ \textcolor{stringliteral}{"{}Running\ autoconf..."{}}\ ;\ autoconf\ ||\ exit\ 1}
\DoxyCodeLine{\ echo\ \textcolor{stringliteral}{"{}Running\ automake..."{}}\ ;\ automake\ -\/-\/add-\/missing\ -\/-\/copy\ -\/-\/gnu\ ||\ exit\ 1}
\DoxyCodeLine{\ ./configure\ \textcolor{stringliteral}{"{}\$@"{}}}

\end{DoxyCode}


To generate all the things needed to bootstrap just run\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{./autogen.sh}

\end{DoxyCode}


This will generate Makefile.\+in\textquotesingle{}s, the configure script and everything else. After this it works like all normal autotools projects\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{./configure}
\DoxyCodeLine{make}
\DoxyCodeLine{sudo\ make\ install}

\end{DoxyCode}


Note sudo was assumed to get root permissions, as this would install in /usr/local which is system-\/owned. Use any way you like to gain root, or specify a different prefix with configure\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{./configure\ -\/-\/prefix=\$HOME/mysoftware}

\end{DoxyCode}


Also remember that autotools buys you some useful commands like\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{make\ uninstall}

\end{DoxyCode}


This uninstalls the software after it was installed with \char`\"{}make install\char`\"{}. It is very useful to clear up what you built if you wish to clean the system.


\begin{DoxyCode}{0}
\DoxyCodeLine{make\ distcheck}

\end{DoxyCode}


This firstly checks if your build tree is \char`\"{}clean\char`\"{} and ready for distribution. It also builds a tarball (myapp-\/0.\+0.\+0.\+tar.\+gz) that is ready to upload and distribute to the world, that contains the generated Makefile.\+in\textquotesingle{}s and configure script. The users do not need to run autogen.\+sh -\/ just configure and on. They don\textquotesingle{}t need autotools installed. This tarball also builds cleanly, has all the sources it needs to build included (that is sources for your application, not libraries it depends on like Elementary). It builds cleanly in a buildroot and does not contain any files that are temporarily generated like binaries and other build-\/generated files, so the tarball is clean, and no need to worry about cleaning up your tree before packaging.


\begin{DoxyCode}{0}
\DoxyCodeLine{make\ clean}

\end{DoxyCode}


This cleans up all build files (binaries, objects etc.) from the tree.


\begin{DoxyCode}{0}
\DoxyCodeLine{make\ distclean}

\end{DoxyCode}


This cleans out all files from the build and from configure\textquotesingle{}s output too.


\begin{DoxyCode}{0}
\DoxyCodeLine{make\ maintainer-\/clean}

\end{DoxyCode}


This deletes all the files autogen.\+sh will produce so the tree is clean to be put into a revision-\/control system (like CVS, SVN or GIT for example).

There is a more advanced way of making use of the quicklaunch infrastructure in Elementary (which will not be covered here due to its more advanced nature).

Now let\textquotesingle{}s actually create an interactive \char`\"{}\+Hello World\char`\"{} gui that you can click the ok button to exit. It\textquotesingle{}s more code because this now does something much more significant, but it\textquotesingle{}s still very simple\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Elementary.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{on\_done(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ quit\ the\ mainloop\ (elm\_run\ function\ will\ return)}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gabada1ccecc6a712df48e90cbf9915c35}{elm\_exit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{EAPI\_MAIN\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ **argv)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *win,\ *box,\ *lab,\ *btn;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ new\ window\ -\/\ do\ the\ usual\ and\ give\ it\ a\ name\ (hello)\ and\ title\ (Hello)}}
\DoxyCodeLine{\ \ \ win\ =\ \mbox{\hyperlink{group__Elm__Win__Group_ga23d9d1ffa0a65a1a1dd482d570db1ba0}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"{}hello"{}},\ \textcolor{stringliteral}{"{}Hello"{}});}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ when\ the\ user\ clicks\ "{}close"{}\ on\ a\ window\ there\ is\ a\ request\ to\ delete}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(win,\ \textcolor{stringliteral}{"{}delete,request"{}},\ on\_done,\ NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ add\ a\ box\ object\ -\/\ default\ is\ vertical.\ a\ box\ holds\ children\ in\ a\ row,}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ either\ horizontally\ or\ vertically.\ nothing\ more.}}
\DoxyCodeLine{\ \ \ box\ =\ \mbox{\hyperlink{group__Elm__Box__Group_ga49ec615c90bf8bead2158d5ffab2e445}{elm\_box\_add}}(win);}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ make\ the\ box\ horizontal}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga447f790a64a49b477019938dc3d5c3ff}{elm\_box\_horizontal\_set}}(box,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ add\ object\ as\ a\ resize\ object\ for\ the\ window\ (controls\ window\ minimum}}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ size\ as\ well\ as\ gets\ resized\ if\ window\ is\ resized)}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win,\ box);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(box);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ add\ a\ label\ widget,\ set\ the\ text\ and\ put\ it\ in\ the\ pad\ frame}}
\DoxyCodeLine{\ \ \ lab\ =\ \mbox{\hyperlink{group__Elm__Label__Group_ga39a584d245f8a4b18d742e3ede702507}{elm\_label\_add}}(win);}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ set\ default\ text\ of\ the\ label}}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(lab,\ \textcolor{stringliteral}{"{}Hello\ out\ there\ world!"{}});}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ pack\ the\ label\ at\ the\ end\ of\ the\ box}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(box,\ lab);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(lab);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ add\ an\ ok\ button}}
\DoxyCodeLine{\ \ \ btn\ =\ \mbox{\hyperlink{group__Elm__Button_gaf5caf46d74c4e122a18da323935d25e4}{elm\_button\_add}}(win);}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ set\ default\ text\ of\ button\ to\ "{}OK"{}}}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(btn,\ \textcolor{stringliteral}{"{}OK"{}});}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ pack\ the\ button\ at\ the\ end\ of\ the\ box}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(box,\ btn);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(btn);}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ call\ on\_done\ when\ button\ is\ clicked}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(btn,\ \textcolor{stringliteral}{"{}clicked"{}},\ on\_done,\ NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ now\ we\ are\ done,\ show\ the\ window}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(win);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{//\ run\ the\ mainloop\ and\ process\ events\ and\ callbacks}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gadf2553f83e6b0b9c7fbe054019a664a1}{elm\_run}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{\mbox{\hyperlink{group__Elm__General_ga50fe52d513f7e89c9c770afd76de7ad9}{ELM\_MAIN}}()}

\end{DoxyCode}
 