2 //gcc -g `pkg-config --cflags --libs elementary` ctxpopup_example_01.c -o ctxpopup_example_01
4 #include <Elementary.h>
6 # include "elementary_config.h"
10 _ctxpopup_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
12 printf("ctxpopup item selected: %s\n", elm_object_item_text_get(event_info));
15 Elm_Object_Item *item_new(Evas_Object *ctxpopup, const char * label, const char *icon)
17 Evas_Object *ic = elm_icon_add(ctxpopup);
18 elm_icon_standard_set(ic, icon);
19 elm_icon_resizable_set(ic, EINA_FALSE, EINA_FALSE);
20 return elm_ctxpopup_item_append(ctxpopup, label, ic, _ctxpopup_item_cb, NULL);
24 _list_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
26 Evas_Object *ctxpopup;
30 ctxpopup = elm_ctxpopup_add(obj);
32 item_new(ctxpopup, "Go to home folder", "home");
33 item_new(ctxpopup, "Save file", "file");
34 item_new(ctxpopup, "Delete file", "delete");
35 it = item_new(ctxpopup, "Navigate to folder", "folder");
36 elm_object_item_disabled_set(it, EINA_TRUE);
37 item_new(ctxpopup, "Edit entry", "edit");
38 it = item_new(ctxpopup, "Set date and time", "clock");
39 elm_object_item_disabled_set(it, EINA_TRUE);
41 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
42 evas_object_size_hint_max_set(ctxpopup, 240, 240);
43 evas_object_move(ctxpopup, x, y);
44 evas_object_show(ctxpopup);
46 elm_list_item_selected_set(event_info, EINA_FALSE);
50 _list_item_cb2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
52 Evas_Object *ctxpopup;
56 ctxpopup = elm_ctxpopup_add(obj);
57 elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
59 item_new(ctxpopup, NULL, "home");
60 item_new(ctxpopup, NULL, "file");
61 item_new(ctxpopup, NULL, "delete");
62 item_new(ctxpopup, NULL, "folder");
63 it = item_new(ctxpopup, NULL, "edit");
64 elm_object_item_disabled_set(it, EINA_TRUE);
65 item_new(ctxpopup, NULL, "clock");
67 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
68 evas_object_size_hint_max_set(ctxpopup, 380, 40);
69 evas_object_move(ctxpopup, x, y);
70 evas_object_show(ctxpopup);
72 elm_list_item_selected_set(event_info, EINA_FALSE);
76 elm_main(int argc, char **argv)
78 Evas_Object *win, *bg, *list;
80 win = elm_win_add(NULL, "Contextual Popup", ELM_WIN_BASIC);
81 elm_win_title_set(win, "Contextual Popup");
82 elm_win_autodel_set(win, EINA_TRUE);
83 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
86 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87 elm_win_resize_object_add(win, bg);
90 list = elm_list_add(win);
91 elm_win_resize_object_add(win, list);
92 elm_list_mode_set(list, ELM_LIST_COMPRESS);
94 elm_list_item_append(list, "Ctxpopup with icons and labels", NULL, NULL,
96 elm_list_item_append(list, "Ctxpopup with icons only", NULL, NULL,
97 _list_item_cb2, NULL);
98 evas_object_show(list);
101 evas_object_resize(win, 400, 400);
102 evas_object_show(win);