2 //gcc -o popup_example_03 popup_example_03.c -g `pkg-config --cflags --libs elementary`
4 #include <Elementary.h>
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);
10 elm_main(int argc, char **argv)
12 Evas_Object *win, *bg, *popup, *btn1, *btn2, *icon1;
13 Elm_Object_Item *popup_it1;
16 elm_app_info_set(elm_main, "elementary", "images/logo_small.png");
17 win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
18 elm_win_title_set(win, "Popup");
19 elm_win_autodel_set(win, EINA_TRUE);
20 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
23 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
24 elm_win_resize_object_add(win, bg);
27 popup = elm_popup_add(win);
29 icon1 = elm_icon_add(popup);
30 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
31 elm_image_file_set(icon1, buf, NULL);
33 //Seting popup title-text
34 elm_object_part_text_set(popup, "title,text", "Title");
36 //Appending popup content-items
37 elm_popup_item_append(popup, "Message", NULL, _item_selected_cb, NULL);
38 elm_popup_item_append(popup, "Email", NULL, _item_selected_cb, NULL);
39 elm_popup_item_append(popup, "Contacts", NULL, _item_selected_cb, NULL);
40 elm_popup_item_append(popup, "Video", NULL, _item_selected_cb, NULL);
41 elm_popup_item_append(popup, "Music", NULL, _item_selected_cb, NULL);
42 elm_popup_item_append(popup, "Memo", NULL, _item_selected_cb, NULL);
43 popup_it1 = elm_popup_item_append(popup, "Radio", NULL, _item_selected_cb,
46 //Changing the label of the item
47 elm_object_item_text_set(popup_it1, "FM");
48 elm_popup_item_append(popup, "Messenger", NULL, _item_selected_cb, NULL);
49 elm_popup_item_append(popup, "Settings", NULL, _item_selected_cb, NULL);
50 elm_popup_item_append(popup, "App Installer", NULL, _item_selected_cb, NULL);
51 elm_popup_item_append(popup, "Browser", NULL, _item_selected_cb, NULL);
52 elm_popup_item_append(popup, "Weather", icon1, _item_selected_cb, NULL);
53 elm_popup_item_append(popup, "News Feeds", NULL, _item_selected_cb, NULL);
55 //Seting popup title-text
56 elm_object_part_text_set(popup, "title,text", "Title");
58 // Creating the first action button
59 btn1 = elm_button_add(popup);
60 elm_object_text_set(btn1, "OK");
62 //Appending the fist action button
63 elm_object_part_content_set(popup, "button1", btn1);
64 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
66 //Creating the second action button
67 btn2 = elm_button_add(popup);
68 elm_object_text_set(btn2, "Cancel");
69 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
71 //Appending the second action button
72 elm_object_part_content_set(popup, "button2", btn2);
74 //Display the popup object
75 evas_object_show(popup);
77 evas_object_resize(win, 480, 800);
78 evas_object_show(win);
88 _item_selected_cb(void *data, Evas_Object *obj,
91 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
95 _response_cb(void *data, Evas_Object *obj,
98 evas_object_hide(data);