\section{popup\+\_\+example\+\_\+03.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o popup\_example\_03 popup\_example\_03.c -g `pkg-config --cflags --libs elementary`}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_item\_selected\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info);
\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_response\_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, *popup, *btn1, *btn2, *icon1;
   Elm_Object_Item *popup\_it1;
   \textcolor{keywordtype}{char} buf[256];

   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/logo\_small.png"});
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"popup"}, \textcolor{stringliteral}{"Popup"});
   elm_win_autodel_set(win, EINA\_TRUE);

   popup = elm_popup_add(win);

   icon1 = elm_icon_add(popup);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/logo\_small.png"}, elm_app_data_dir_get());
   elm_image_file_set(icon1, buf, NULL);

   \textcolor{comment}{//Seting popup title-text}
   elm_object_part_text_set(popup, \textcolor{stringliteral}{"title,text"}, \textcolor{stringliteral}{"Title"});

   \textcolor{comment}{//Appending popup content-items}
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Message"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Email"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Contacts"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Video"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Music"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Memo"}, NULL, \_item\_selected\_cb, NULL);
   popup\_it1 = elm_popup_item_append(popup, \textcolor{stringliteral}{"Radio"}, NULL, \_item\_selected\_cb,
                                     NULL);

   \textcolor{comment}{//Changing the label of the item}
   elm_object_item_text_set(popup\_it1, \textcolor{stringliteral}{"FM"});
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Messenger"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Settings"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"App Installer"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Browser"}, NULL, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"Weather"}, icon1, \_item\_selected\_cb, NULL);
   elm_popup_item_append(popup, \textcolor{stringliteral}{"News Feeds"}, NULL, \_item\_selected\_cb, NULL);

   \textcolor{comment}{//Seting popup title-text}
   elm_object_part_text_set(popup, \textcolor{stringliteral}{"title,text"}, \textcolor{stringliteral}{"Title"});

   \textcolor{comment}{// Creating the first action button}
   btn1 = elm_button_add(popup);
   elm\_object\_text\_set(btn1, \textcolor{stringliteral}{"OK"});

   \textcolor{comment}{//Appending the fist action button}
   elm_object_part_content_set(popup, \textcolor{stringliteral}{"button1"}, btn1);
   evas\_object\_smart\_callback\_add(btn1, \textcolor{stringliteral}{"clicked"}, \_response\_cb, popup);

   \textcolor{comment}{//Creating the second action button}
   btn2 = elm_button_add(popup);
   elm\_object\_text\_set(btn2, \textcolor{stringliteral}{"Cancel"});
   evas\_object\_smart\_callback\_add(btn2, \textcolor{stringliteral}{"clicked"}, \_response\_cb, popup);

   \textcolor{comment}{//Appending the second action button}
   elm_object_part_content_set(popup, \textcolor{stringliteral}{"button2"}, btn2);

   \textcolor{comment}{//Display the popup object}
   evas\_object\_show(popup);

   evas\_object\_resize(win, 480, 800);
   evas\_object\_show(win);

   elm_run();

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

static \textcolor{keywordtype}{void}
\_item\_selected\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj,
                  \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"popup item selected: %s\(\backslash\)n"}, elm\_object\_item\_text\_get(event\_info));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_response\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj,
             \textcolor{keywordtype}{void} *event\_info)
\{
   evas\_object\_hide(data);
\}
\end{DoxyCodeInclude}
 