2 //gcc -o hoversel_example_01 hoversel_example_01.c -g `pkg-config --cflags --libs elementary`
4 #include <Elementary.h>
6 static void _print_items(void *data, Evas_Object *obj, void *event_info);
7 static void _rm_items(void *data, Evas_Object *obj, void *event_info);
8 static void _sel(void *data, Evas_Object *obj, void *event_info);
9 static void _free(void *data, Evas_Object *obj, void *event_info);
10 static void _add_item(void *data, Evas_Object *obj, void *event_info);
13 elm_main(int argc, char **argv)
15 Evas_Object *win, *bg, *rect, *hoversel;
16 Elm_Object_Item *hoversel_it;
18 win = elm_win_add(NULL, "hoversel", ELM_WIN_BASIC);
19 elm_win_title_set(win, "Hoversel");
20 elm_win_autodel_set(win, EINA_TRUE);
21 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
22 evas_object_resize(win, 200, 300);
23 evas_object_show(win);
26 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27 elm_win_resize_object_add(win, bg);
30 rect = evas_object_rectangle_add(evas_object_evas_get(win));
31 evas_object_color_set(rect, 255, 0, 0, 255);
32 evas_object_show(rect);
34 hoversel = elm_hoversel_add(win);
35 elm_hoversel_hover_parent_set(hoversel, win);
36 elm_hoversel_horizontal_set(hoversel, EINA_FALSE);
37 elm_object_text_set(hoversel, "Hoversel");
38 elm_object_part_content_set(hoversel, "icon", rect);
39 elm_hoversel_item_add(hoversel, "Print items", NULL, ELM_ICON_NONE,
41 elm_hoversel_item_add(hoversel, "Option 2", "home", ELM_ICON_STANDARD, NULL,
43 hoversel_it = elm_hoversel_item_add(hoversel, "Clear all items", "close",
44 ELM_ICON_STANDARD, _rm_items, NULL);
45 evas_object_smart_callback_add(hoversel, "selected", _sel, hoversel_it);
46 evas_object_smart_callback_add(hoversel, "clicked", _add_item, NULL);
48 evas_object_resize(hoversel, 180, 30);
49 evas_object_move(hoversel, 10, 10);
50 evas_object_show(hoversel);
61 _print_items(void *data, Evas_Object *obj, void *event_info)
63 const Eina_List *items = elm_hoversel_items_get(obj);
65 Elm_Object_Item *hoversel_it;
67 EINA_LIST_FOREACH(items, l, hoversel_it)
68 printf("%s\n", elm_object_item_text_get(hoversel_it));
72 _rm_items(void *data, Evas_Object *obj, void *event_info)
74 if (!elm_hoversel_expanded_get(obj))
75 elm_hoversel_clear(obj);
79 _sel(void *data, Evas_Object *obj, void *event_info)
81 if (!elm_hoversel_expanded_get(obj) && event_info != data)
82 elm_object_item_del(event_info);
86 _add_item(void *data, Evas_Object *obj, void *event_info)
89 char *str = malloc(sizeof(char) * 10);
90 Elm_Object_Item *hoversel_it;
92 snprintf(str, 10, "item %d", ++num);
94 hoversel_it = elm_hoversel_item_add(obj, str, NULL, ELM_ICON_NONE, NULL,
96 elm_object_item_del_cb_set(hoversel_it, _free);
100 _free(void *data, Evas_Object *obj, void *event_info)