2 * Simple Elementary's <b>segment_control widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g segment_control_example.c -o segment_control_example `pkg-config --cflags --libs elementary`
12 #include <Elementary.h>
23 elm_main(int argc, char **argv)
25 Evas_Object *win, *bg, *sc, *ic;
26 Elm_Object_Item *seg_it;
29 win = elm_win_add(NULL, "segment_control", ELM_WIN_BASIC);
30 elm_win_title_set(win, "Segment Control Example");
31 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
34 elm_win_resize_object_add(win, bg);
35 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38 sc = elm_segment_control_add(win);
39 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
40 elm_win_resize_object_add(win, sc);
43 elm_segment_control_item_add(sc, NULL, "only text");
45 ic = elm_icon_add(win);
46 elm_icon_standard_set(ic, "close");
47 elm_segment_control_item_add(sc, ic, NULL);
49 ic = elm_icon_add(win);
50 elm_icon_standard_set(ic, "home");
51 elm_segment_control_item_add(sc, ic, "Home");
53 ic = elm_icon_add(win);
54 elm_icon_standard_set(ic, "close");
55 elm_segment_control_item_add(sc, ic, "");
57 count = elm_segment_control_item_count_get(sc);
58 elm_segment_control_item_insert_at(sc, NULL, "Inserted at", count - 1);
60 seg_it = elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
61 elm_object_item_del(seg_it);
63 elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
64 elm_segment_control_item_del_at(sc, 2);
66 seg_it = elm_segment_control_item_get(sc, 0);
67 elm_object_item_text_set(seg_it, "Only Text");
69 count = elm_segment_control_item_count_get(sc);
70 seg_it = elm_segment_control_item_get(sc, count / 2);
71 elm_segment_control_item_selected_set(seg_it, EINA_TRUE);
72 seg_it = elm_segment_control_item_selected_get(sc);
73 idx = elm_segment_control_item_index_get(seg_it);
74 printf("Item selected: %i\n", idx);
76 evas_object_show(win);