aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/examples/menu_example_01.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:20:32 +1000
committerDavid Walter Seikel2012-04-22 09:20:32 +1000
commit3ad3455551be0d7859ecb02290376206d5e66498 (patch)
tree497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/examples/menu_example_01.c
parentUpdate EFL to latest beta. (diff)
downloadSledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz
And actually include new files, plus elementary libraries.
Diffstat (limited to 'libraries/elementary/src/examples/menu_example_01.c')
-rw-r--r--libraries/elementary/src/examples/menu_example_01.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/menu_example_01.c b/libraries/elementary/src/examples/menu_example_01.c
new file mode 100644
index 0000000..bb64f29
--- /dev/null
+++ b/libraries/elementary/src/examples/menu_example_01.c
@@ -0,0 +1,73 @@
1//Compile with:
2//gcc -g menu_example_01.c -o menu_example_01 `pkg-config --cflags --libs elementary`
3
4#include <Elementary.h>
5
6static void
7_del_it(void *data, Evas_Object *obj, void *event_info)
8{
9 const Eina_List *l;
10 Elm_Object_Item *menu_it = elm_menu_first_item_get(data);
11 menu_it = elm_menu_item_next_get(menu_it);
12 l = elm_menu_item_subitems_get(menu_it);
13 elm_object_item_del(eina_list_data_get(l));
14}
15
16static void
17_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
18{
19 Evas_Event_Mouse_Down *ev = event_info;
20 elm_menu_move(data, ev->canvas.x, ev->canvas.y);
21 evas_object_show(data);
22}
23
24EAPI_MAIN int
25elm_main(int argc, char **argv)
26{
27 Evas_Object *win, *bg, *menu, *button, *rect;
28 Elm_Object_Item *menu_it, *menu_it1;
29
30 win = elm_win_add(NULL, "menu", ELM_WIN_BASIC);
31 elm_win_title_set(win, "Menu");
32 elm_win_autodel_set(win, EINA_TRUE);
33 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
34
35 bg = elm_bg_add(win);
36 elm_win_resize_object_add(win, bg);
37 evas_object_show(bg);
38
39 rect = evas_object_rectangle_add(evas_object_evas_get(win));
40 elm_win_resize_object_add(win, rect);
41 evas_object_color_set(rect, 0, 0, 0, 0);
42 evas_object_show(rect);
43
44 menu = elm_menu_add(win);
45 elm_menu_item_add(menu, NULL, NULL, "first item", NULL, NULL);
46 menu_it = elm_menu_item_add(menu, NULL, "mail-reply-all", "second item", NULL, NULL);
47
48 elm_menu_item_add(menu, menu_it, "object-rotate-left", "menu 1", NULL, NULL);
49 button = elm_button_add(win);
50 elm_object_text_set(button, "button - delete items");
51 menu_it1 = elm_menu_item_add(menu, menu_it, NULL, NULL, NULL, NULL);
52 elm_object_item_content_set(menu_it1, button);
53 evas_object_smart_callback_add(button, "clicked", _del_it, menu);
54 elm_menu_item_separator_add(menu, menu_it);
55 elm_menu_item_add(menu, menu_it, NULL, "third item", NULL, NULL);
56 elm_menu_item_add(menu, menu_it, NULL, "fourth item", NULL, NULL);
57 elm_menu_item_add(menu, menu_it, "window-new", "sub menu", NULL, NULL);
58
59 menu_it = elm_menu_item_add(menu, NULL, NULL, "third item", NULL, NULL);
60 elm_object_item_disabled_set(menu_it, EINA_TRUE);
61
62 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _show, menu);
63 evas_object_show(menu);
64
65 evas_object_resize(win, 250, 350);
66 evas_object_show(win);
67
68 elm_run();
69 elm_shutdown();
70
71 return 0;
72}
73ELM_MAIN()