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);
20 elm_icon_scale_set(ic, EINA_FALSE, EINA_FALSE);
22 elm_icon_resizable_set(ic, EINA_FALSE, EINA_FALSE);
23 >>>>>>> remotes/origin/upstream
24 return elm_ctxpopup_item_append(ctxpopup, label, ic, _ctxpopup_item_cb, NULL);
28 _list_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
30 Evas_Object *ctxpopup;
34 ctxpopup = elm_ctxpopup_add(obj);
36 item_new(ctxpopup, "Go to home folder", "home");
37 item_new(ctxpopup, "Save file", "file");
38 item_new(ctxpopup, "Delete file", "delete");
39 it = item_new(ctxpopup, "Navigate to folder", "folder");
40 elm_object_item_disabled_set(it, EINA_TRUE);
41 item_new(ctxpopup, "Edit entry", "edit");
42 it = item_new(ctxpopup, "Set date and time", "clock");
43 elm_object_item_disabled_set(it, EINA_TRUE);
45 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
46 evas_object_size_hint_max_set(ctxpopup, 240, 240);
47 evas_object_move(ctxpopup, x, y);
48 evas_object_show(ctxpopup);
50 elm_list_item_selected_set(event_info, EINA_FALSE);
54 _list_item_cb2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
56 Evas_Object *ctxpopup;
60 ctxpopup = elm_ctxpopup_add(obj);
61 elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
63 item_new(ctxpopup, NULL, "home");
64 item_new(ctxpopup, NULL, "file");
65 item_new(ctxpopup, NULL, "delete");
66 item_new(ctxpopup, NULL, "folder");
67 it = item_new(ctxpopup, NULL, "edit");
68 elm_object_item_disabled_set(it, EINA_TRUE);
69 item_new(ctxpopup, NULL, "clock");
71 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
72 evas_object_size_hint_max_set(ctxpopup, 380, 40);
73 evas_object_move(ctxpopup, x, y);
74 evas_object_show(ctxpopup);
76 elm_list_item_selected_set(event_info, EINA_FALSE);
80 elm_main(int argc, char **argv)
82 Evas_Object *win, *bg, *list;
84 win = elm_win_add(NULL, "Contextual Popup", ELM_WIN_BASIC);
85 elm_win_title_set(win, "Contextual Popup");
86 elm_win_autodel_set(win, EINA_TRUE);
87 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
90 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
91 elm_win_resize_object_add(win, bg);
94 list = elm_list_add(win);
95 elm_win_resize_object_add(win, list);
96 elm_list_mode_set(list, ELM_LIST_COMPRESS);
98 elm_list_item_append(list, "Ctxpopup with icons and labels", NULL, NULL,
100 elm_list_item_append(list, "Ctxpopup with icons only", NULL, NULL,
101 _list_item_cb2, NULL);
102 evas_object_show(list);
105 evas_object_resize(win, 400, 400);
106 evas_object_show(win);