elm examples: Adjust directory names.
[framework/uifw/elementary.git] / src / examples / bg_example_02.c
1 //Compile with:
2 //gcc -o bg_example_02 bg_example_02.c -g `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\""
3 //where directory is the a path where images/plant_01.jpg can be found.
4
5 #include <Elementary.h>
6 #ifndef DATA_DIR
7 # define DATA_DIR "/usr/share/elementary"
8 #endif
9
10 static void
11 on_done(void *data, Evas_Object *obj, void *event_info)
12 {
13    /* quit the mainloop (elm_run) */
14    elm_exit();
15 }
16
17 EAPI_MAIN int
18 elm_main(int argc, char **argv)
19 {
20    Evas_Object *win, *bg;
21    char buf[PATH_MAX];
22
23    win = elm_win_add(NULL, "bg-image", ELM_WIN_BASIC);
24    elm_win_title_set(win, "Bg Image");
25    evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
26    elm_win_autodel_set(win, EINA_TRUE);
27
28    bg = elm_bg_add(win);
29    elm_bg_load_size_set(bg, 20, 20);
30    elm_bg_option_set(bg, ELM_BG_OPTION_CENTER);
31    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", DATA_DIR);
32    elm_bg_file_set(bg, buf, NULL);
33    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
34    elm_win_resize_object_add(win, bg);
35    evas_object_show(bg);
36
37    evas_object_size_hint_min_set(bg, 160, 160);
38    evas_object_size_hint_max_set(bg, 640, 640);
39    evas_object_resize(win, 320, 320);
40    evas_object_show(win);
41
42    elm_run();
43    elm_shutdown();
44
45    return 0;
46 }
47 ELM_MAIN()