2 //gcc -g `pkg-config --cflags --libs elementary` popup_example_03.c -o popup_example_03
4 #include <Elementary.h>
6 # include "elementary_config.h"
8 # define __UNUSED__ __attribute__((unused))
9 # define PACKAGE_DATA_DIR "../../data"
12 static void _item_selected_cb(void *data, Evas_Object *obj, void *event_info);
13 static void _response_cb(void *data, Evas_Object *obj, void *event_info);
16 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
18 Evas_Object *win, *bg, *popup, *btn1, *btn2, *icon1;
19 Elm_Object_Item *popup_it1;
22 win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
23 elm_win_title_set(win, "Popup");
24 elm_win_autodel_set(win, EINA_TRUE);
25 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
28 elm_win_resize_object_add(win, bg);
31 popup = elm_popup_add(win);
33 icon1 = elm_icon_add(popup);
34 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
35 elm_icon_file_set(icon1, buf, NULL);
37 //Seting popup title-text
38 elm_object_part_text_set(popup, "title,text", "Title");
40 //Appending popup content-items
41 elm_popup_item_append(popup, "Message", NULL, _item_selected_cb, NULL);
42 elm_popup_item_append(popup, "Email", NULL, _item_selected_cb, NULL);
43 elm_popup_item_append(popup, "Contacts", NULL, _item_selected_cb, NULL);
44 elm_popup_item_append(popup, "Video", NULL, _item_selected_cb, NULL);
45 elm_popup_item_append(popup, "Music", NULL, _item_selected_cb, NULL);
46 elm_popup_item_append(popup, "Memo", NULL, _item_selected_cb, NULL);
47 popup_it1 = elm_popup_item_append(popup, "Radio", NULL, _item_selected_cb,
50 //Changing the label of the item
51 elm_object_item_text_set(popup_it1, "FM");
52 elm_popup_item_append(popup, "Messenger", NULL, _item_selected_cb, NULL);
53 elm_popup_item_append(popup, "Settings", NULL, _item_selected_cb, NULL);
54 elm_popup_item_append(popup, "App Installer", NULL, _item_selected_cb, NULL);
55 elm_popup_item_append(popup, "Browser", NULL, _item_selected_cb, NULL);
56 elm_popup_item_append(popup, "Weather", icon1, _item_selected_cb, NULL);
57 elm_popup_item_append(popup, "News Feeds", NULL, _item_selected_cb, NULL);
59 //Seting popup title-text
60 elm_object_part_text_set(popup, "title,text", "Title");
62 // Creating the first action button
63 btn1 = elm_button_add(popup);
64 elm_object_text_set(btn1, "OK");
66 //Appending the fist action button
67 elm_object_part_content_set(popup, "button1", btn1);
68 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
70 //Creating the second action button
71 btn2 = elm_button_add(popup);
72 elm_object_text_set(btn2, "Cancel");
73 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
75 //Appending the second action button
76 elm_object_part_content_set(popup, "button1", btn2);
78 //Display the popup object
79 evas_object_show(popup);
81 evas_object_resize(win, 480, 800);
82 evas_object_show(win);
91 _item_selected_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
94 printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
98 _response_cb(void *data, Evas_Object *obj __UNUSED__,
99 void *event_info __UNUSED__)
101 evas_object_hide(data);