Fixing bugs in examples.
[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` -DPACKAGE_DATA_DIR="\"<directory>\""
3 //where directory is the a path where images/plant_01.jpg can be found.
4
5 #include <Elementary.h>
6 #ifdef HAVE_CONFIG_H
7 # include "elementary_config.h"
8 #else
9 # define __UNUSED__
10 #endif
11
12 static void
13 on_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
14 {
15    /* quit the mainloop (elm_run) */
16    elm_exit();
17 }
18
19 int
20 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
21 {
22    Evas_Object *win, *bg;
23    char buf[PATH_MAX];
24
25    win = elm_win_add(NULL, "bg-image", ELM_WIN_BASIC);
26    elm_win_title_set(win, "Bg Image");
27    evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
28    elm_win_autodel_set(win, EINA_TRUE);
29
30    bg = elm_bg_add(win);
31    elm_bg_load_size_set(bg, 20, 20);
32    elm_bg_option_set(bg, ELM_BG_OPTION_CENTER);
33    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
34    elm_bg_file_set(bg, buf, NULL);
35    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
36    elm_win_resize_object_add(win, bg);
37    evas_object_show(bg);
38
39    evas_object_size_hint_min_set(bg, 160, 160);
40    evas_object_size_hint_max_set(bg, 640, 640);
41    evas_object_resize(win, 320, 320);
42    evas_object_show(win);
43
44    elm_run();
45
46    return 0;
47 }
48
49 ELM_MAIN()