tizen 2.4 release
[framework/uifw/elementary.git] / src / examples / popup_example_03.c
1 //Compile with:
2 //gcc -o popup_example_03 popup_example_03.c -g `pkg-config --cflags --libs elementary`
3
4 #include <Elementary.h>
5
6 static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info);
7 static void _response_cb(void *data, Evas_Object *obj, void *event_info);
8
9 EAPI_MAIN int
10 elm_main(int argc, char **argv)
11 {
12    Evas_Object *win, *popup, *btn1, *btn2, *icon1;
13    Elm_Object_Item *popup_it1;
14    char buf[256];
15
16    elm_app_info_set(elm_main, "elementary", "images/logo_small.png");
17    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
18
19    win = elm_win_util_standard_add("popup", "Popup");
20    elm_win_autodel_set(win, EINA_TRUE);
21
22    popup = elm_popup_add(win);
23
24    icon1 = elm_icon_add(popup);
25    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
26    elm_image_file_set(icon1, buf, NULL);
27
28    //Seting popup title-text
29    elm_object_part_text_set(popup, "title,text", "Title");
30
31    //Appending popup content-items
32    elm_popup_item_append(popup, "Message", NULL, _item_selected_cb, NULL);
33    elm_popup_item_append(popup, "Email", NULL, _item_selected_cb, NULL);
34    elm_popup_item_append(popup, "Contacts", NULL, _item_selected_cb, NULL);
35    elm_popup_item_append(popup, "Video", NULL, _item_selected_cb, NULL);
36    elm_popup_item_append(popup, "Music", NULL, _item_selected_cb, NULL);
37    elm_popup_item_append(popup, "Memo", NULL, _item_selected_cb, NULL);
38    popup_it1 = elm_popup_item_append(popup, "Radio", NULL, _item_selected_cb,
39                                      NULL);
40
41    //Changing the label of the item
42    elm_object_item_text_set(popup_it1, "FM");
43    elm_popup_item_append(popup, "Messenger", NULL, _item_selected_cb, NULL);
44    elm_popup_item_append(popup, "Settings", NULL, _item_selected_cb, NULL);
45    elm_popup_item_append(popup, "App Installer", NULL, _item_selected_cb, NULL);
46    elm_popup_item_append(popup, "Browser", NULL, _item_selected_cb, NULL);
47    elm_popup_item_append(popup, "Weather", icon1, _item_selected_cb, NULL);
48    elm_popup_item_append(popup, "News Feeds", NULL, _item_selected_cb, NULL);
49
50    //Seting popup title-text
51    elm_object_part_text_set(popup, "title,text", "Title");
52
53    // Creating the first action button
54    btn1 = elm_button_add(popup);
55    elm_object_text_set(btn1, "OK");
56
57    //Appending the fist action button
58    elm_object_part_content_set(popup, "button1", btn1);
59    evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
60
61    //Creating the second action button
62    btn2 = elm_button_add(popup);
63    elm_object_text_set(btn2, "Cancel");
64    evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
65
66    //Appending the second action button
67    elm_object_part_content_set(popup, "button2", btn2);
68
69    //Display the popup object
70    evas_object_show(popup);
71
72    evas_object_resize(win, 480, 800);
73    evas_object_show(win);
74
75    elm_run();
76
77    return 0;
78 }
79 ELM_MAIN()
80
81 static void
82 _item_selected_cb(void *data, Evas_Object *obj,
83                   void *event_info)
84 {
85    printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
86 }
87
88 static void
89 _response_cb(void *data, Evas_Object *obj,
90              void *event_info)
91 {
92    evas_object_hide(data);
93 }