seoz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=3307725ab8795fafb86e0b8e7325821382e42d0e

commit 3307725ab8795fafb86e0b8e7325821382e42d0e
Author: Srivardhan Hebbar <sri.heb...@samsung.com>
Date:   Sun Sep 28 22:14:09 2014 +0900

    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.heb...@samsung.com>
    
    Reviewers: devilhorns, stefan_schmidt, seoz
    
    Differential Revision: https://phab.enlightenment.org/D1490
---
 src/examples/.gitignore         |  1 +
 src/examples/Makefile.am        |  3 ++
 src/examples/radio_example_02.c | 95 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/src/examples/.gitignore b/src/examples/.gitignore
index 4148ea2..4c1683b 100644
--- a/src/examples/.gitignore
+++ b/src/examples/.gitignore
@@ -71,6 +71,7 @@
 /popup_example_03
 /progressbar_example
 /radio_example_01
+/radio_example_02
 /scroller_example_01
 /segment_control_example
 /separator_example_01
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index 3edf636..b8b6e0d 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -110,6 +110,7 @@ popup_example_02.c \
 popup_example_03.c \
 progressbar_example.c \
 radio_example_01.c \
+radio_example_02.c \
 segment_control_example.c \
 separator_example_01.c \
 slider_example.c \
@@ -260,6 +261,7 @@ popup_example_02 \
 popup_example_03 \
 progressbar_example \
 radio_example_01 \
+radio_example_02 \
 segment_control_example \
 separator_example_01 \
 slider_example \
@@ -369,6 +371,7 @@ panes_example:panes_example.png:0.0 \
 ctxpopup_example_01:ctxpopup_example_01.png:0.0 \
 separator_example_01:separator_example_01.png:0.0 \
 radio_example_01:radio_example_01.png:0.0 \
+radio_example_02:radio_example_02.png:0.0 \
 panel_example_01:panel_example_01.png:0.0 \
 gengrid_example:gengrid_example.png:0.0 \
 genlist_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 0000000..a59d0a0
--- /dev/null
+++ b/src/examples/radio_example_02.c
@@ -0,0 +1,95 @@
+//Compile with:
+//gcc -g radio_example_02.c -o radio_example_02 `pkg-config --cflags --libs 
elementary`
+
+#include <Elementary.h>
+
+static int val = 0;
+
+static void _cb1(void *data, Evas_Object *obj, void *event_info);
+static void _cb2(void *data, Evas_Object *obj, void *event_info);
+static void _cb3(void *data, Evas_Object *obj, void *event_info);
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+   Evas_Object *win, *bx, *radio, *group, *ic;
+
+   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+   win = elm_win_util_standard_add("radio", "Radio");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   bx = elm_box_add(win);
+   elm_box_horizontal_set(bx, EINA_TRUE);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bx);
+   evas_object_show(bx);
+
+   group = radio = elm_radio_add(win);
+   elm_object_text_set(radio, "Radio 1");
+   elm_radio_state_value_set(radio, 1);
+   elm_radio_value_pointer_set(radio, &val);
+   ic = elm_icon_add(win);
+   elm_icon_standard_set(ic, "home");
+   elm_object_part_content_set(radio, "icon", ic);
+   elm_box_pack_end(bx, radio);
+   evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(radio);
+   evas_object_smart_callback_add(radio, "changed", _cb1, NULL);
+
+   radio = elm_radio_add(win);
+   elm_object_text_set(radio, "Radio 2");
+   elm_radio_state_value_set(radio, 2);
+   elm_radio_value_pointer_set(radio, &val);
+   elm_radio_group_add(radio, group);
+   ic = elm_icon_add(win);
+   elm_icon_standard_set(ic, "file");
+   elm_object_part_content_set(radio, "icon", ic);
+   elm_box_pack_end(bx, radio);
+   evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(radio);
+   evas_object_smart_callback_add(radio, "changed", _cb2, NULL);
+
+   radio = elm_radio_add(win);
+   elm_object_text_set(radio, "Radio 3");
+   elm_radio_state_value_set(radio, 3);
+   elm_radio_value_pointer_set(radio, &val);
+   elm_radio_group_add(radio, group);
+   ic = elm_icon_add(win);
+   elm_icon_standard_set(ic, "folder");
+   elm_object_part_content_set(radio, "icon", ic);
+   elm_box_pack_end(bx, radio);
+   evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(radio);
+   evas_object_smart_callback_add(radio, "changed", _cb3, NULL);
+
+   evas_object_show(win);
+
+   elm_run();
+   elm_shutdown();
+
+   return 0;
+}
+ELM_MAIN()
+
+static void
+_cb1(void *data, Evas_Object *obj, void *event_info)
+{
+   printf("Radio 1 Clicked: val is now: %d\n", val);
+}
+
+static void
+_cb2(void *data, Evas_Object *obj, void *event_info)
+{
+   printf("Radio 2 Clicked: val is now: %d\n", val);
+}
+
+static void
+_cb3(void *data, Evas_Object *obj, void *event_info)
+{
+   printf("Radio 3 Clicked: val is now: %d\n", val);
+}
+

-- 


Reply via email to