summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorGareth Halfacree <freelance@halfacree.co.uk>2017-12-13 05:37:26 -0800
committerapache <apache@e5-web1.enlightenment.org>2017-12-13 05:37:26 -0800
commit4fde6bcdc1865b5a8d897fa6df2438e7a71d0f84 (patch)
tree10026cf53b5724dd55e8236065b778fb33351270 /pages
parent2b105f7e97fe8a6367b838effc39bbced12a7a7c (diff)
Wiki page lifecycle.md changed with summary [] by Gareth Halfacree
Diffstat (limited to 'pages')
-rw-r--r--pages/develop/tutorials/c/lifecycle.md.txt43
1 files changed, 21 insertions, 22 deletions
diff --git a/pages/develop/tutorials/c/lifecycle.md.txt b/pages/develop/tutorials/c/lifecycle.md.txt
index 4438594c3..d8d40f5cb 100644
--- a/pages/develop/tutorials/c/lifecycle.md.txt
+++ b/pages/develop/tutorials/c/lifecycle.md.txt
@@ -4,19 +4,19 @@
4 4
5# Lifecycle Management # 5# Lifecycle Management #
6 6
7The [Hello World](/develop/tutorials/c/hello-world) tutorial explained how to create a desktop-like application using the ``EFL_MAIN()`` macro. Applications targeted at mobile or embedded devices, though, often have additional lifecycle constrains, which are explained in this tutorial. 7The [Hello World](/develop/tutorials/c/hello-world) tutorial explained how to create a desktop-like application using the ``EFL_MAIN()`` macro. Applications targeted at mobile or embedded devices often have additional lifecycle constrains which are explored in this tutorial.
8 8
9## Prerequisites ## 9## Prerequisites ##
10 10
11* Finish the [Hello World](/develop/tutorials/c/hello-world) tutorial to know the basics of EFL application creation. 11You should have completed the [Hello World](/develop/tutorials/c/hello-world) tutorial in order to understand the basics of EFL application creation before proceeding with this tutorial.
12 12
13## Application Management Events ## 13## Application Management Events ##
14 14
15EFL will call some special methods in your application to inform you of events related to the application lifecycle, like it being paused, resumed or about to be closed. 15EFL will call some special methods in your application to inform you of events related to the application lifecycle such as being paused, resumed or when it is about to be closed.
16 16
17If you use the ``EFL_MAIN()`` macro as explained in the [Hello World](/develop/tutorials/c/hello-world) tutorial, though, these methods are hidden from you. While this is usually convenient for desktop applications, you will probably need to use them in mobile or embedded applications. To do this, use the ``EFL_MAIN_EX()`` macro instead. 17If you use the ``EFL_MAIN()`` macro, as in the [Hello World](/develop/tutorials/c/hello-world) tutorial, these methods are hidden from you. While this is usually convenient for desktop applications, you will likely need to use them when developing mobile or embedded applications. To do this you should use the ``EFL_MAIN_EX()`` macro instead.
18 18
19Create a ``lifecycle_main.c`` file and write this: 19Begin by creating a ``lifecycle_main.c`` file:
20 20
21```c 21```c
22#define EFL_EO_API_SUPPORT 1 22#define EFL_EO_API_SUPPORT 1
@@ -33,7 +33,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
33EFL_MAIN_EX() 33EFL_MAIN_EX()
34``` 34```
35 35
36This looks like the Hello World tutorial, but using ``EFL_MAIN_EX()`` instead. If you try to compile it, though, it will complain (admittedly in a rather convoluted way) about missing symbols. 36This is based on the Hello World tutorial but rewritten to use ``EFL_MAIN_EX()``. If you try to compile it, however, it will complain - admittedly in a rather convoluted way - about missing symbols.
37 37
38These are the new methods that you need to add. All of them have the same signature as ``efl_main()``: 38These are the new methods that you need to add. All of them have the same signature as ``efl_main()``:
39 39
@@ -43,7 +43,7 @@ These are the new methods that you need to add. All of them have the same signat
43| ``efl_resume()`` | Application is leaving the paused state | 43| ``efl_resume()`` | Application is leaving the paused state |
44| ``efl_terminate()`` | Application is about to be terminated | 44| ``efl_terminate()`` | Application is about to be terminated |
45 45
46Add them with a simple ``printf()`` so we can keep track of the application state changes: 46Add them with a simple ``printf()`` so you can more easily keep track of the application state changes:
47 47
48```c 48```c
49EAPI_MAIN void 49EAPI_MAIN void
@@ -65,17 +65,17 @@ efl_terminate(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
65} 65}
66``` 66```
67 67
68The system will typically put your application in the paused state when it leaves the foreground, therefore, you should free as many resources as you can in ``efl_pause()`` so they are available to other applications. In ``efl_resume()`` you can then reload them. 68The system will typically put your application in the paused state when it leaves the foreground. You should free as many resources as you can in ``efl_pause()`` so they are available to other applications. You may then reload them in ``efl_resume()``.
69 69
70In ``efl_terminate()`` you normally will commit to permanent storage (like a disk file) the application state, so it can be retrieved next time the application is started. 70In ``efl_terminate()`` you will usually commit the application state to permanent storage, such as a file on disk, so it can be retrieved next time the application is started.
71 71
72## Simulating Application Management Events ## 72## Simulating Application Management Events ##
73 73
74The above section explains everything you need to know about application lifecycle management in EFL. However, the code provided so far will not demonstrate much when tested on a desktop environment. 74The above section explains everything you need to know about application lifecycle management in EFL. The code provided so far, however, will not demonstrate much when tested on a desktop environment.
75 75
76This sections adds a bit of *simulation code* which will artificially trigger the application management events studied before, for the sake of this tutorial only. 76This sections adds a bit of *simulation code* which will artificially trigger the application management events, for the sake of this tutorial.
77 77
78Define this method in your code: 78Begin by defining this method in your existing code:
79 79
80```c 80```c
81static void 81static void
@@ -103,9 +103,9 @@ _lifecycle_simulation(void *data, const Efl_Event *ev EINA_UNUSED)
103} 103}
104``` 104```
105 105
106If you have read the [Events Programming Guide](/develop/guides/c/core/events.md) you will know that ``efl_event_callback_call()`` is manually emitting an event. This is what EFL uses internally to inform your application of these events on systems that support them (i.e. *not* on desktops). 106If you have read the [Events Programming Guide](/develop/guides/c/core/events.md) you will know that the ``efl_event_callback_call()`` function is manually emitting an event. This used internally by EFL to inform your application of these events on systems that support them - i.e. *not* on desktops.
107 107
108And now create a timer at the end of ``efl_main()`` that will periodically call the above defined ``_lifecycle_simulation()`` method: 108Now create a timer at the end of ``efl_main()`` that will periodically call the above defined ``_lifecycle_simulation()`` method:
109 109
110```c 110```c
111 [...] 111 [...]
@@ -114,13 +114,13 @@ And now create a timer at the end of ``efl_main()`` that will periodically call
114 efl_loop_timer_interval_set(efl_added, 1.0)); 114 efl_loop_timer_interval_set(efl_added, 1.0));
115``` 115```
116 116
117Read the [Main Loop Programming Guide](/develop/guides/c/core/main-loop.md) to learn about timers. Suffice to say that this call creates one, registers a callback to it, and configures it to trigger every second. 117This call creates a timer, registers a callback to it and configures it to trigger every second. Read the [Main Loop Programming Guide](/develop/guides/c/core/main-loop.md) for more information on timers.
118 118
119With this, the program is complete, including simulation code. 119With this, the program is complete including the simulation code.
120 120
121## Complete Application ## 121## Complete Application ##
122 122
123The whole program, with some additional comments for clarity, should look like this: 123The whole program, with some additional comments for clarity, is reproduced below:
124 124
125```c 125```c
126#define EFL_EO_API_SUPPORT 1 126#define EFL_EO_API_SUPPORT 1
@@ -192,9 +192,9 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
192EFL_MAIN_EX() 192EFL_MAIN_EX()
193``` 193```
194 194
195You can find it in the EFL repository: [tutorial/c/lifecycle/src/lifecycle_main.c](https://git.enlightenment.org/tools/examples.git/tree/tutorial/c/lifecycle/src/lifecycle_main.c). 195A copy of this program is available in the EFL git repository: [tutorial/c/lifecycle/src/lifecycle_main.c](https://git.enlightenment.org/tools/examples.git/tree/tutorial/c/lifecycle/src/lifecycle_main.c).
196 196
197If you execute it, you should see how your application receives events for Launching, Pause, Resume and Termination, spaced every second. 197Execute the program and you will see how it receives events for Launch, Pause, Resume and Termination, spaced every second.
198 198
199## Summary ## 199## Summary ##
200 200
@@ -202,7 +202,7 @@ At the end of this tutorial you have learned:
202 202
203* To use ``EFL_MAIN_EX()`` instead of ``EFL_MAIN()`` if you are interested in application management events. 203* To use ``EFL_MAIN_EX()`` instead of ``EFL_MAIN()`` if you are interested in application management events.
204 204
205* The methods to implement in that case are ``efl_pause()``, ``efl_resume()`` and ``efl_terminate()``. 205* The methods to implement in that case: ``efl_pause()``, ``efl_resume()`` and ``efl_terminate()``.
206 206
207## Further Reading ## 207## Further Reading ##
208 208
@@ -216,5 +216,4 @@ At the end of this tutorial you have learned:
216: Guide explaining how EFL timers work. 216: Guide explaining how EFL timers work.
217 217
218[tutorial/c/lifecycle/src/lifecycle_main.c](https://git.enlightenment.org/tools/examples.git/tree/tutorial/c/lifecycle/src/lifecycle_main.c) 218[tutorial/c/lifecycle/src/lifecycle_main.c](https://git.enlightenment.org/tools/examples.git/tree/tutorial/c/lifecycle/src/lifecycle_main.c)
219: Application management from the EFL git examples repository. 219: Application management from the EFL git examples repository. \ No newline at end of file
220