9ecd03aa49a5bb02a07cb0f9975f513c8d6d28f3
[framework/uifw/elementary.git] / src / examples / popup_example_02.c
1 //Compile with:
2 //gcc -g `pkg-config --cflags --libs elementary` popup_example_02.c -o popup_example_02
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 _response_cb(void *data, Evas_Object *obj, void *event_info);
13
14 EAPI_MAIN int
15 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
16 {
17    Evas_Object *win, *bg, *popup, *btn1, *btn2, *btn3, *icon1;
18    char buf[256];
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_win_resize_object_add(win, bg);
27    evas_object_show(bg);
28
29    popup = elm_popup_add(win);
30
31    // Setting popup content-text
32    elm_object_text_set(popup, "This is the Content-Text for popup. The wrap"
33             "for the content-text is character wrapping");
34    // Setting the wrapping type to character wrapping
35    elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
36
37    // Seting popup title-text
38    elm_object_part_text_set(popup, "title,text", "Title");
39
40    icon1 = elm_icon_add(popup);
41    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
42    elm_icon_file_set(icon1, buf, NULL);
43    //Setting popup title-icon
44    elm_object_part_content_set(popup, "title,icon", icon1);
45
46    // Creating the first action button
47    btn1 = elm_button_add(popup);
48    elm_object_text_set(btn1, "OK");
49
50    // Setting the fist action button
51    elm_object_part_content_set(popup, "button1", btn1);
52    evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
53
54    // Creating the second action button
55    btn2 = elm_button_add(popup);
56    elm_object_text_set(btn2, "Cancel");
57
58    // Setting the second action button
59    elm_object_part_content_set(popup, "button2", btn2);
60    evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
61
62    btn3 = elm_button_add(popup);
63    elm_object_text_set(btn3, "Close");
64    // Setting this action button
65    elm_object_part_content_set(popup, "button3", btn3);
66    // Setting the orientation of popup to Top
67    elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
68    // Display the popup object
69    evas_object_show(popup);
70
71    evas_object_resize(win, 480, 800);
72    evas_object_show(win);
73
74    elm_run();
75
76    return 0;
77 }
78 ELM_MAIN()
79 static void
80 _response_cb(void *data, Evas_Object *obj __UNUSED__,
81              void *event_info __UNUSED__)
82 {
83    evas_object_del(data);
84 }
85