2 * Simple Elementary's <b>segment_control widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g `pkg-config --cflags --libs elementary` segment_control_example.c -o segment_control_example
12 #include <Elementary.h>
14 # include "elementary_config.h"
20 _on_done(void *data __UNUSED__,
21 Evas_Object *obj __UNUSED__,
22 void *event_info __UNUSED__)
28 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
30 Evas_Object *win, *bg, *sc, *ic;
31 Elm_Object_Item *seg_it;
34 win = elm_win_add(NULL, "segment_control", ELM_WIN_BASIC);
35 elm_win_title_set(win, "Segment Control Example");
36 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
39 elm_win_resize_object_add(win, bg);
40 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 sc = elm_segment_control_add(win);
44 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
45 elm_win_resize_object_add(win, sc);
48 elm_segment_control_item_add(sc, NULL, "only text");
50 ic = elm_icon_add(win);
51 elm_icon_standard_set(ic, "close");
52 elm_segment_control_item_add(sc, ic, NULL);
54 ic = elm_icon_add(win);
55 elm_icon_standard_set(ic, "home");
56 elm_segment_control_item_add(sc, ic, "Home");
58 ic = elm_icon_add(win);
59 elm_icon_standard_set(ic, "close");
60 elm_segment_control_item_add(sc, ic, "");
62 count = elm_segment_control_item_count_get(sc);
63 elm_segment_control_item_insert_at(sc, NULL, "Inserted at", count - 1);
65 seg_it = elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
66 elm_object_item_del(seg_it);
68 elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
69 elm_segment_control_item_del_at(sc, 2);
71 seg_it = elm_segment_control_item_get(sc, 0);
72 elm_object_item_text_set(seg_it, "Only Text");
74 count = elm_segment_control_item_count_get(sc);
75 seg_it = elm_segment_control_item_get(sc, count / 2);
76 elm_segment_control_item_selected_set(seg_it, EINA_TRUE);
77 seg_it = elm_segment_control_item_selected_get(sc);
78 index = elm_segment_control_item_index_get(seg_it);
79 printf("Item selected: %i\n", index);
81 evas_object_show(win);