summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2014-09-28 22:14:09 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-09-28 23:50:16 +0900
commit3307725ab8795fafb86e0b8e7325821382e42d0e (patch)
tree1b2aa6b3264c80083e6e6adfd5df4500ff0bf7b5
parent94a51a5d295e1c0db15c53a9747f17195aecbe67 (diff)
elementary: Adding example to demonstrate radio "changed" functionality.
Summary: Added this example which demonstrate the exact behavior or "changed" in radio button. After changing the documentation of "changed" as in https://phab.enlightenment.org/D1445, thought the example might be useful, so added this. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: devilhorns, stefan_schmidt, seoz Differential Revision: https://phab.enlightenment.org/D1490
-rw-r--r--src/examples/.gitignore1
-rw-r--r--src/examples/Makefile.am3
-rw-r--r--src/examples/radio_example_02.c95
3 files changed, 99 insertions, 0 deletions
diff --git a/src/examples/.gitignore b/src/examples/.gitignore
index 4148ea266..4c1683bfa 100644
--- a/src/examples/.gitignore
+++ b/src/examples/.gitignore
@@ -71,6 +71,7 @@
71/popup_example_03 71/popup_example_03
72/progressbar_example 72/progressbar_example
73/radio_example_01 73/radio_example_01
74/radio_example_02
74/scroller_example_01 75/scroller_example_01
75/segment_control_example 76/segment_control_example
76/separator_example_01 77/separator_example_01
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index 3edf636cd..b8b6e0db8 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -110,6 +110,7 @@ popup_example_02.c \
110popup_example_03.c \ 110popup_example_03.c \
111progressbar_example.c \ 111progressbar_example.c \
112radio_example_01.c \ 112radio_example_01.c \
113radio_example_02.c \
113segment_control_example.c \ 114segment_control_example.c \
114separator_example_01.c \ 115separator_example_01.c \
115slider_example.c \ 116slider_example.c \
@@ -260,6 +261,7 @@ popup_example_02 \
260popup_example_03 \ 261popup_example_03 \
261progressbar_example \ 262progressbar_example \
262radio_example_01 \ 263radio_example_01 \
264radio_example_02 \
263segment_control_example \ 265segment_control_example \
264separator_example_01 \ 266separator_example_01 \
265slider_example \ 267slider_example \
@@ -369,6 +371,7 @@ panes_example:panes_example.png:0.0 \
369ctxpopup_example_01:ctxpopup_example_01.png:0.0 \ 371ctxpopup_example_01:ctxpopup_example_01.png:0.0 \
370separator_example_01:separator_example_01.png:0.0 \ 372separator_example_01:separator_example_01.png:0.0 \
371radio_example_01:radio_example_01.png:0.0 \ 373radio_example_01:radio_example_01.png:0.0 \
374radio_example_02:radio_example_02.png:0.0 \
372panel_example_01:panel_example_01.png:0.0 \ 375panel_example_01:panel_example_01.png:0.0 \
373gengrid_example:gengrid_example.png:0.0 \ 376gengrid_example:gengrid_example.png:0.0 \
374genlist_example_01:genlist_example_01.png:0.1 \ 377genlist_example_01:genlist_example_01.png:0.1 \
diff --git a/src/examples/radio_example_02.c b/src/examples/radio_example_02.c
new file mode 100644
index 000000000..a59d0a090
--- /dev/null
+++ b/src/examples/radio_example_02.c
@@ -0,0 +1,95 @@
1//Compile with:
2//gcc -g radio_example_02.c -o radio_example_02 `pkg-config --cflags --libs elementary`
3
4#include <Elementary.h>
5
6static int val = 0;
7
8static void _cb1(void *data, Evas_Object *obj, void *event_info);
9static void _cb2(void *data, Evas_Object *obj, void *event_info);
10static void _cb3(void *data, Evas_Object *obj, void *event_info);
11
12EAPI_MAIN int
13elm_main(int argc, char **argv)
14{
15 Evas_Object *win, *bx, *radio, *group, *ic;
16
17 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
18
19 win = elm_win_util_standard_add("radio", "Radio");
20 elm_win_autodel_set(win, EINA_TRUE);
21
22 bx = elm_box_add(win);
23 elm_box_horizontal_set(bx, EINA_TRUE);
24 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
25 elm_win_resize_object_add(win, bx);
26 evas_object_show(bx);
27
28 group = radio = elm_radio_add(win);
29 elm_object_text_set(radio, "Radio 1");
30 elm_radio_state_value_set(radio, 1);
31 elm_radio_value_pointer_set(radio, &val);
32 ic = elm_icon_add(win);
33 elm_icon_standard_set(ic, "home");
34 elm_object_part_content_set(radio, "icon", ic);
35 elm_box_pack_end(bx, radio);
36 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
38 evas_object_show(radio);
39 evas_object_smart_callback_add(radio, "changed", _cb1, NULL);
40
41 radio = elm_radio_add(win);
42 elm_object_text_set(radio, "Radio 2");
43 elm_radio_state_value_set(radio, 2);
44 elm_radio_value_pointer_set(radio, &val);
45 elm_radio_group_add(radio, group);
46 ic = elm_icon_add(win);
47 elm_icon_standard_set(ic, "file");
48 elm_object_part_content_set(radio, "icon", ic);
49 elm_box_pack_end(bx, radio);
50 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
51 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
52 evas_object_show(radio);
53 evas_object_smart_callback_add(radio, "changed", _cb2, NULL);
54
55 radio = elm_radio_add(win);
56 elm_object_text_set(radio, "Radio 3");
57 elm_radio_state_value_set(radio, 3);
58 elm_radio_value_pointer_set(radio, &val);
59 elm_radio_group_add(radio, group);
60 ic = elm_icon_add(win);
61 elm_icon_standard_set(ic, "folder");
62 elm_object_part_content_set(radio, "icon", ic);
63 elm_box_pack_end(bx, radio);
64 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
65 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
66 evas_object_show(radio);
67 evas_object_smart_callback_add(radio, "changed", _cb3, NULL);
68
69 evas_object_show(win);
70
71 elm_run();
72 elm_shutdown();
73
74 return 0;
75}
76ELM_MAIN()
77
78static void
79_cb1(void *data, Evas_Object *obj, void *event_info)
80{
81 printf("Radio 1 Clicked: val is now: %d\n", val);
82}
83
84static void
85_cb2(void *data, Evas_Object *obj, void *event_info)
86{
87 printf("Radio 2 Clicked: val is now: %d\n", val);
88}
89
90static void
91_cb3(void *data, Evas_Object *obj, void *event_info)
92{
93 printf("Radio 3 Clicked: val is now: %d\n", val);
94}
95