The elm_toolbar_iteams_count have to return only the number of manually added items.
[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, *bg, *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    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);
21
22    bg = elm_bg_add(win);
23    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
24    elm_win_resize_object_add(win, bg);
25    evas_object_show(bg);
26
27    popup = elm_popup_add(win);
28
29    icon1 = elm_icon_add(popup);
30    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
31    elm_icon_file_set(icon1, buf, NULL);
32
33    //Seting popup title-text
34    elm_object_part_text_set(popup, "title,text", "Title");
35
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,
44                                      NULL);
45
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);
54
55    //Seting popup title-text
56    elm_object_part_text_set(popup, "title,text", "Title");
57
58    // Creating the first action button
59    btn1 = elm_button_add(popup);
60    elm_object_text_set(btn1, "OK");
61
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);
65
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);
70
71    //Appending the second action button
72    elm_object_part_content_set(popup, "button1", btn2);
73
74    //Display the popup object
75    evas_object_show(popup);
76
77    evas_object_resize(win, 480, 800);
78    evas_object_show(win);
79
80    elm_run();
81    elm_shutdown();
82
83    return 0;
84 }
85 ELM_MAIN()
86
87 static void
88 _item_selected_cb(void *data, Evas_Object *obj,
89                   void *event_info)
90 {
91    printf("popup item selected: %s\n", elm_object_item_text_get(event_info));
92 }
93
94 static void
95 _response_cb(void *data, Evas_Object *obj,
96              void *event_info)
97 {
98    evas_object_hide(data);
99 }