summaryrefslogtreecommitdiff
path: root/src/examples/evas/evas-init-shutdown.c
blob: 197891b354222dc85b11d43ea08249e600ff957d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * Example of initializing and shutting down Evas.
 *
 * For this introduction to Evas, we'll simply turn it on and off and
 * explain everything we're doing from the absolute basics, to provide
 * a starting point for understanding the other examples in this set,
 * which won't be explaining things quite so verbosely.
 *
 * See the @ref Example_Evas_Buffer_Simple as the next step in the tutorial.
 *
 * Evas examples can be built using the regular `make examples`, but each
 * example includes the compiler line for building that specific example if
 * you wish to build it in isolation:
 *
 * @verbatim
 * gcc -o evas-init-shutdown evas-init-shutdown.c `pkg-config --libs --cflags evas`
 * @endverbatim
 *
 * For this compilation to function properly, you'll need to have built and
 * installed the evas library and include files in a location that the pkg-config
 * tool will be able to find.  The example executable will be 'evas-init-shutdown'.
 */

#include <Evas.h>
#include <stdio.h>
#include <errno.h>

int
main(void)
{
   Eina_List *engine_list, *l;
   char *engine_name;

   /* Initialize Evas.  This will startup other dependencies such as
    * eina, eet, ecore, etc. and initializes various internal things
    * (threads, filters, etc.) */
   evas_init();

   /* When building Evas you can configure a variety of engines to be
    * built with it.  Get a list of what engines are available using the
    * evas_render_method_list routine.
    */
   engine_list = evas_render_method_list();
   if (!engine_list)
     {
        fprintf(stderr, "ERROR: Evas supports no engines! Exit.\n");
        exit(-1);
     }

   /* 'engine_list' is a linked list (@see Eina_List.)  The
    * EINA_LIST_FOREACH macro permits navigating through the items using
    * the iterator 'l', making the node data available as 'engine_name'.
    */
   printf("Available Evas Engines:\n");
   EINA_LIST_FOREACH(engine_list, l, engine_name)
     printf("%s\n", engine_name);

   /* To free the list, we use evas_render_method_list's corresponding
    * destructor routine.
    */
   evas_render_method_list_free(engine_list);

   /* Shuts down all dependencies if nothing else is using them, and
    * clears allocated data held internally.
    */
   evas_shutdown();
   return 0;
}