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