37c0ad8a8bbddbd412ab2a71eaea7956b0e02496
[framework/uifw/elementary.git] / src / lib / elm_getting_started.h
1 /**
2  * @defgroup Start Getting Started
3  *
4  * To write an Elementary app, you can get started with the following:
5  *
6  * @code
7  * #include <Elementary.h>
8  * EAPI_MAIN int
9  * elm_main(int argc, char **argv)
10  * {
11  *    // create window(s) here and do any application init
12  *    elm_run(); // run main loop
13  *    elm_shutdown(); // after mainloop finishes running, shutdown
14  *    return 0; // exit 0 for exit code
15  * }
16  * ELM_MAIN()
17  * @endcode
18  *
19  * To use autotools (which helps in many ways in the long run, like being able
20  * to immediately create releases of your software directly from your tree
21  * and ensure everything needed to build it is there) you will need a
22  * configure.ac, Makefile.am and autogen.sh file.
23  *
24  * configure.ac:
25  *
26  * @verbatim
27  * AC_INIT(myapp, 0.0.0, myname@mydomain.com)
28  * AC_PREREQ(2.52)
29  * AC_CONFIG_SRCDIR(configure.ac)
30  * AM_CONFIG_HEADER(config.h)
31  * AC_PROG_CC
32  * AM_INIT_AUTOMAKE(1.6 dist-bzip2)
33  * PKG_CHECK_MODULES([ELEMENTARY], elementary)
34  * AC_OUTPUT(Makefile)
35  * @endverbatim
36  *
37  * Makefile.am:
38  *
39  * @verbatim
40  * AUTOMAKE_OPTIONS = 1.4 foreign
41  * MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.h.in configure depcomp install-sh missing
42  * 
43  * INCLUDES = -I$(top_srcdir)
44  * 
45  * bin_PROGRAMS = myapp
46  * 
47  * myapp_SOURCES = main.c
48  * myapp_LDADD = @ELEMENTARY_LIBS@
49  * myapp_CFLAGS = @ELEMENTARY_CFLAGS@
50  * @endverbatim
51  *
52  * autogen.sh:
53  *
54  * @verbatim
55  *#!/bin/sh
56  * echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
57  * echo "Running autoheader..." ; autoheader || exit 1
58  * echo "Running autoconf..." ; autoconf || exit 1
59  * echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
60  * ./configure "$@"
61  * @endverbatim
62  *
63  * To generate all the things needed to bootstrap just run:
64  *
65  * @verbatim
66  * ./autogen.sh
67  * @endverbatim
68  *
69  * This will generate Makefile.in's, the confgure script and everything else.
70  * After this it works like all normal autotools projects:
71  * @verbatim
72  * ./configure
73  * make
74  * sudo make install
75  * @endverbatim
76  *
77  * Note sudo was assumed to get root permissions, as this would install in
78  * /usr/local which is system-owned. Use any way you like to gain root, or
79  * specify a different prefix with configure:
80  *
81  * @verbatim
82  * ./confiugre --prefix=$HOME/mysoftware
83  * @endverbatim
84  *
85  * Also remember that autotools buys you some useful commands like:
86  * @verbatim
87  * make uninstall
88  * @endverbatim
89  *
90  * This uninstalls the software after it was installed with "make install".
91  * It is very useful to clear up what you built if you wish to clean the
92  * system.
93  *
94  * @verbatim
95  * make distcheck
96  * @endverbatim
97  *
98  * This firstly checks if your build tree is "clean" and ready for
99  * distribution. It also builds a tarball (myapp-0.0.0.tar.gz) that is
100  * ready to upload and distribute to the world, that contains the generated
101  * Makefile.in's and configure script. The users do not need to run
102  * autogen.sh - just configure and on. They don't need autotools installed.
103  * This tarball also builds cleanly, has all the sources it needs to build
104  * included (that is sources for your application, not libraries it depends
105  * on like Elementary). It builds cleanly in a buildroot and does not
106  * contain any files that are temporarily generated like binaries and other
107  * build-generated files, so the tarball is clean, and no need to worry
108  * about cleaning up your tree before packaging.
109  *
110  * @verbatim
111  * make clean
112  * @endverbatim
113  *
114  * This cleans up all build files (binaries, objects etc.) from the tree.
115  *
116  * @verbatim
117  * make distclean
118  * @endverbatim
119  *
120  * This cleans out all files from the build and from configure's output too.
121  *
122  * @verbatim
123  * make maintainer-clean
124  * @endverbatim
125  *
126  * This deletes all the files autogen.sh will produce so the tree is clean
127  * to be put into a revision-control system (like CVS, SVN or GIT for example).
128  *
129  * There is a more advanced way of making use of the quicklaunch infrastructure
130  * in Elementary (which will not be covered here due to its more advanced
131  * nature).
132  *
133  * Now let's actually create an interactive "Hello World" gui that you can
134  * click the ok button to exit. It's more code because this now does something
135  * much more significant, but it's still very simple:
136  *
137  * @code
138  * #include <Elementary.h>
139  * 
140  * static void
141  * on_done(void *data, Evas_Object *obj, void *event_info)
142  * {
143  *    // quit the mainloop (elm_run function will return)
144  *    elm_exit();
145  * }
146  * 
147  * EAPI_MAIN int
148  * elm_main(int argc, char **argv)
149  * {
150  *    Evas_Object *win, *box, *lab, *btn;
151  * 
152  *    // new window - do the usual and give it a name (hello) and title (Hello)
153  *    win = elm_win_util_standard_add("hello", "Hello");
154  *    // when the user clicks "close" on a window there is a request to delete
155  *    evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
156  * 
157  *    // add a box object - default is vertical. a box holds children in a row,
158  *    // either horizontally or vertically. nothing more.
159  *    box = elm_box_add(win);
160  *    // make the box hotizontal
161  *    elm_box_horizontal_set(box, EINA_TRUE);
162  *    // add object as a resize object for the window (controls window minimum
163  *    // size as well as gets resized if window is resized)
164  *    elm_win_resize_object_add(win, box);
165  *    evas_object_show(box);
166  * 
167  *    // add a label widget, set the text and put it in the pad frame
168  *    lab = elm_label_add(win);
169  *    // set default text of the label
170  *    elm_object_text_set(lab, "Hello out there world!");
171  *    // pack the label at the end of the box
172  *    elm_box_pack_end(box, lab);
173  *    evas_object_show(lab);
174  * 
175  *    // add an ok button
176  *    btn = elm_button_add(win);
177  *    // set default text of button to "OK"
178  *    elm_object_text_set(btn, "OK");
179  *    // pack the button at the end of the box
180  *    elm_box_pack_end(box, btn);
181  *    evas_object_show(btn);
182  *    // call on_done when button is clicked
183  *    evas_object_smart_callback_add(btn, "clicked", on_done, NULL);
184  * 
185  *    // now we are done, show the window
186  *    evas_object_show(win);
187  * 
188  *    // run the mainloop and process events and callbacks
189  *    elm_run();
190  *    elm_shutdown();
191  *    return 0;
192  * }
193  * ELM_MAIN()
194  * @endcode
195  *
196  */