

In this example we will create 4 radio buttons, three of them in a group and another one not in the group. We will also have the radios in the group change the value of a variable directly and have then print it when the value changes. The fourth button is in the example just to make clear that radios outside the group don't affect the group.

We'll start with the usual includes\-: 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <Elementary.h>}

\end{DoxyCodeInclude}


And move right to declaring a static variable(the one whose value the radios will change)\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{int} val = 1;

\end{DoxyCodeInclude}


We now need to have a window and all that good stuff to be able to place our radios in\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{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(\textcolor{stringliteral}{"radio"}, \textcolor{stringliteral}{"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);

\end{DoxyCodeInclude}


And now we create a radio button, since this is the first button in our group we set the group to be the radio(so we can set the other radios in the same group). We also set the state value of this radio to 1 and the value pointer to {\ttfamily val}, since val is {\ttfamily 1} this has the additional effect of setting the radio value to {\ttfamily 1}. For this radio we choose the default home icon\-: 
\begin{DoxyCodeInclude}

   group = radio = elm_radio_add(win);
   elm\_object\_text\_set(radio, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"home"});
   elm_object_part_content_set(radio, \textcolor{stringliteral}{"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);

\end{DoxyCodeInclude}


To check that our radio buttons are working we'll add a callback to the \char`\"{}changed\char`\"{} signal of the radio\-: 
\begin{DoxyCodeInclude}
   evas\_object\_smart\_callback\_add(radio, \textcolor{stringliteral}{"changed"}, \_cb, NULL);

\end{DoxyCodeInclude}


The creation of our second radio button is almost identical, the 2 differences worth noting are, the value of this radio 2 and that we add this radio to the group of the first radio\-: 
\begin{DoxyCodeInclude}

   radio = elm_radio_add(win);
   elm\_object\_text\_set(radio, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"file"});
   elm_object_part_content_set(radio, \textcolor{stringliteral}{"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, \textcolor{stringliteral}{"changed"}, \_cb, NULL);

\end{DoxyCodeInclude}


For our third callback we'll omit the icon and set the value to 3, we'll also add it to the group of the first radio\-: 
\begin{DoxyCodeInclude}

   radio = elm_radio_add(win);
   elm\_object\_text\_set(radio, \textcolor{stringliteral}{"Radio 3"});
   elm_radio_state_value_set(radio, 3);
   elm_radio_value_pointer_set(radio, &val);
   elm_radio_group_add(radio, group);
   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, \textcolor{stringliteral}{"changed"}, \_cb, NULL);

\end{DoxyCodeInclude}


Our fourth callback has a value of 4, no icon and most relevantly is not a member of the same group as the other radios\-: 
\begin{DoxyCodeInclude}

   radio = elm_radio_add(win);
   elm\_object\_text\_set(radio, \textcolor{stringliteral}{"Radio 4"});
   elm_radio_state_value_set(radio, 4);
   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);

\end{DoxyCodeInclude}


We finally run the main loop\-: 
\begin{DoxyCodeInclude}

   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()

\end{DoxyCodeInclude}


And the last detail in our example is the callback that prints {\ttfamily val} so that we can see that the radios are indeed changing its value\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"val is now: %d\(\backslash\)n"}, val);
\}

\end{DoxyCodeInclude}


The example will look like this\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/radio_example_01}
\caption{width=}
\end{DoxyImage}
 