\hypertarget{prefs_example_01_8c-example}{}\doxysection{prefs\+\_\+example\+\_\+01.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{//gcc -\/o prefs\_example\_01 prefs\_example\_01.c -\/g `pkg-\/config -\/-\/cflags -\/-\/libs elementary`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Elementary.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//testing ui reflection on prefs data changes}}
\DoxyCodeLine{\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_elm\_prefs\_data\_change(\textcolor{keywordtype}{void} *data)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *notify = data;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Prefs_ga7e2cbea5a9696262669748533f578a53}{Elm\_Prefs\_Data}} *prefs\_data;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Prefs_ga7525bee64184478acad1e807c3e570ae}{Elm\_Prefs\_Item\_Type}} type;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__Value}{Eina\_Value}} value;}
\DoxyCodeLine{}
\DoxyCodeLine{   prefs\_data = \mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(notify, \textcolor{stringliteral}{"prefs\_data"});}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Elm__Prefs_ga2b692083e7d307512858f1adc2563519}{elm\_prefs\_data\_value\_get}}(prefs\_data, \textcolor{stringliteral}{"main:universe"}, \&type, \&value))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Value__Value__Group_ga9a1407c953694c3d6f40ab01ebe9a294}{eina\_value\_set}}(\&value, 42);}
\DoxyCodeLine{        \mbox{\hyperlink{group__Elm__Prefs_gaae2c2d085d8c0e9d6c24ff580807a54e}{elm\_prefs\_data\_value\_set}}(prefs\_data, \textcolor{stringliteral}{"main:universe"}, type, \&value);}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Elm__Prefs_ga2b692083e7d307512858f1adc2563519}{elm\_prefs\_data\_value\_get}}(prefs\_data, \textcolor{stringliteral}{"main:text"}, \&type, \&value))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \mbox{\hyperlink{group__Eina__Value__Value__Group_ga9a1407c953694c3d6f40ab01ebe9a294}{eina\_value\_set}}(\&value, \textcolor{stringliteral}{"This is a text field (:"});}
\DoxyCodeLine{        \mbox{\hyperlink{group__Elm__Prefs_gaae2c2d085d8c0e9d6c24ff580807a54e}{elm\_prefs\_data\_value\_set}}(prefs\_data, \textcolor{stringliteral}{"main:text"}, type, \&value);}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(notify);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_page\_saved\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *page = event\_info;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"page \%s was saved!\(\backslash\)n"}, page);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_page\_loaded\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *page = event\_info;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"page \%s was loaded!\(\backslash\)n"}, page);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_item\_changed\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *item = event\_info;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"item \%s was changed!\(\backslash\)n"}, item);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{EAPI\_MAIN \textcolor{keywordtype}{int}}
\DoxyCodeLine{elm\_main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *win, *prefs, *notify, *label;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Prefs_ga7e2cbea5a9696262669748533f578a53}{Elm\_Prefs\_Data}} *prefs\_data;}
\DoxyCodeLine{}
\DoxyCodeLine{   win = \mbox{\hyperlink{group__Elm__Win_gac75d7752662fab73d6420706ce5be996}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"prefs"}, \textcolor{stringliteral}{"Prefs Example 01"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga7a05f37fd3a019da5e26c5fc91fcd937}{elm\_policy\_set}}(\mbox{\hyperlink{group__Elm__General_ggaa16f3378ecdbf660fa378402e3c5a0a9a02fadb6faada04b19d0fa42c11a8d32a}{ELM\_POLICY\_QUIT}}, \mbox{\hyperlink{group__Elm__General_gga46af37e6ac2c406321060be827117196abbe0962d88ae12afe1a173da881f56cd}{ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{   prefs = \mbox{\hyperlink{group__Elm__Prefs_ga6736d5f9363dd7acbcb39938668b3e45}{elm\_prefs\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(prefs, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win, prefs);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(prefs);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(prefs, \textcolor{stringliteral}{"page,saved"}, \_page\_saved\_cb, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(prefs, \textcolor{stringliteral}{"page,loaded"}, \_page\_loaded\_cb, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(prefs, \textcolor{stringliteral}{"item,changed"}, \_item\_changed\_cb, win);}
\DoxyCodeLine{}
\DoxyCodeLine{   elm\_prefs\_autosave\_set(prefs, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{   prefs\_data = \mbox{\hyperlink{group__Elm__Prefs_ga58895cf0ae0fd70db018fbe8eb7ba5c2}{elm\_prefs\_data\_new}}(\textcolor{stringliteral}{"./prefs\_example\_01.cfg"}, NULL,}
\DoxyCodeLine{                                   \mbox{\hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a763d29c19960a4e0d4eb7bc7bb512481}{EET\_FILE\_MODE\_READ\_WRITE}});}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Prefs_gaec5a0c4ea7f8e54909c5cdbc05e9b064}{elm\_prefs\_file\_set}}(prefs, \textcolor{stringliteral}{"prefs\_example\_01.epb"}, NULL);}
\DoxyCodeLine{   elm\_prefs\_data\_set(prefs, prefs\_data);}
\DoxyCodeLine{}
\DoxyCodeLine{   label = \mbox{\hyperlink{group__Elm__Label_ga01e161a300e3ee6f7a13a44505724e03}{elm\_label\_add}}(win);}
\DoxyCodeLine{   elm\_object\_text\_set(label, \textcolor{stringliteral}{"Setting Values Programmatically"});}
\DoxyCodeLine{   evas\_object\_size\_hint\_align\_set(label, 0.5, 0.5);}
\DoxyCodeLine{}
\DoxyCodeLine{   notify = \mbox{\hyperlink{group__Elm__Notify_ga3b3eb10c622de79e55539aeb84e538a3}{elm\_notify\_add}}(win);}
\DoxyCodeLine{   elm\_notify\_align\_set(notify, 0.5, 1);}
\DoxyCodeLine{   elm\_notify\_timeout\_set(notify, 2);}
\DoxyCodeLine{   elm\_object\_content\_set(notify, label);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(notify, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(notify);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Extras_ga70134a7068c9bff4107a761abe0a2ad4}{evas\_object\_data\_set}}(notify, \textcolor{stringliteral}{"prefs\_data"}, prefs\_data);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_resize(win, 320, 320);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(win);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Timer__Group_ga7b9cb9d24ecebfdbb957436e2e669402}{ecore\_timer\_add}}(5.0, \_elm\_prefs\_data\_change, notify);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_gadf2553f83e6b0b9c7fbe054019a664a1}{elm\_run}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Prefs_ga6a6905e5914a263a4e0195bae6c0b37d}{elm\_prefs\_data\_unref}}(prefs\_data);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}
\DoxyCodeLine{\mbox{\hyperlink{group__Elm__General_ga50fe52d513f7e89c9c770afd76de7ad9}{ELM\_MAIN}}()}
\end{DoxyCodeInclude}
 