2 * Simple Evas example illustrating evas_load_error_str()'s usage.
4 * You'll need at least one engine built for it (excluding the buffer
5 * one) and the png image loader also built. See stdout/stderr for
9 * gcc -o evas-load-error-str evas-load-error-str.c `pkg-config --libs \
10 * --cflags ecore-evas`
21 #include <Ecore_Evas.h>
28 static const char *valid_path = PACKAGE_EXAMPLES_DIR "/enlightenment.png";
29 static const char *bogus_path = "/tmp/non-existent-220986.png";
36 Evas_Object *img1, *img2, *bg;
39 if (!ecore_evas_init())
42 /* this will give you a window with an Evas canvas under the first
44 ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
50 /* the canvas pointer, de facto */
51 evas = ecore_evas_get(ee);
53 bg = evas_object_rectangle_add(evas);
54 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
55 evas_object_move(bg, 0, 0); /* at canvas' origin */
56 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
59 img1 = evas_object_image_filled_add(evas);
60 evas_object_image_file_set(img1, valid_path, NULL);
61 err = evas_object_image_load_error_get(img1);
62 if (err != EVAS_LOAD_ERROR_NONE)
64 fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
65 valid_path, evas_load_error_str(err));
70 "loaded image '%s' with succes! error string is \"%s\"\n",
71 valid_path, evas_load_error_str(err));
73 evas_object_move(img1, 0, 0);
74 evas_object_resize(img1, WIDTH / 2, HEIGHT / 2);
75 evas_object_show(img1);
78 /* image loading will fail for this one -- unless one cheats and
79 * puts a valid image on that path */
80 img2 = evas_object_image_filled_add(evas);
81 evas_object_image_file_set(img2, bogus_path, NULL);
82 err = evas_object_image_load_error_get(img2);
83 if (err != EVAS_LOAD_ERROR_NONE)
85 fprintf(stderr, "could not load image '%s': error string is \"%s\"\n",
86 bogus_path, evas_load_error_str(err));
90 evas_object_move(img2, WIDTH / 2, HEIGHT / 2);
91 evas_object_resize(img2, WIDTH / 2, HEIGHT / 2);
92 evas_object_show(img2);
95 ecore_main_loop_begin();
98 ecore_evas_shutdown();
102 fprintf(stderr, "you got to have at least one evas engine built and linked"
103 " up to ecore-evas for this example to run properly.\n");
104 ecore_evas_shutdown();