141317e5ff703a194a50a38707c0dcacce23e4d6
[framework/uifw/elementary.git] / src / examples / popup_example_01.c
1 //Compile with:
2 //gcc -o popup_example_01 popup_example_01.c -g `pkg-config --cflags --libs elementary`
3
4 #include <Elementary.h>
5 #define PACKAGE_DATA_DIR "../../data"
6
7 static void _block_clicked(void *data, Evas_Object *obj, void *event_info);
8 static void _timeout(void *data, Evas_Object *obj, void *event_info);
9
10 EAPI_MAIN int
11 elm_main(int argc, char **argv)
12 {
13    Evas_Object *win, *bg, *popup, *content;
14
15    win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
16    elm_win_title_set(win, "Popup");
17    elm_win_autodel_set(win, EINA_TRUE);
18    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
19
20    bg = elm_bg_add(win);
21    elm_bg_color_set(bg, 128, 128, 128);
22    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
23    elm_win_resize_object_add(win, bg);
24    evas_object_show(bg);
25
26    content = elm_label_add(win);
27    elm_object_text_set(content, "<align=center>Content</align>");
28
29    popup = elm_popup_add(win);
30    elm_popup_timeout_set(popup, 3.0);
31    evas_object_smart_callback_add(popup, "timeout", _timeout, NULL);
32
33    //Setting popup content
34    elm_object_content_set(popup, content);
35    //Seting popup title-text
36    elm_object_part_text_set(popup, "title,text", "Title");
37    evas_object_show(popup);
38    evas_object_smart_callback_add(popup, "block,clicked", _block_clicked, NULL);
39
40    evas_object_show(win);
41    evas_object_resize(win, 480, 800);
42
43    elm_run();
44    elm_shutdown();
45
46    return 0;
47 }
48 ELM_MAIN()
49
50 static void
51 _block_clicked(void *data, Evas_Object *obj,
52                void *event_info)
53 {
54    evas_object_hide(obj);
55 }
56
57 static void
58 _timeout(void *data, Evas_Object *obj, void *event_info)
59 {
60    evas_object_hide(obj);
61 }