In this example, we illustrate how Edje signals and Edje messages work.

We place, in the canvas, an Edje object along with a {\bfseries red} border image to delimit its geometry. The object\textquotesingle{}s group definition is so that we have four parts\+:
\begin{DoxyItemize}
\item a blue rectangle, aligned to the right
\item a white rectangle, aligned to the left
\item a text part, aligned to the center
\item a clipper rectangle on the blue rectangle
\end{DoxyItemize}

The left rectangle is bound to a {\bfseries color class}, so that we can multiply its colors by chosen values on the go\+:  
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#define MSG\_COLOR 1}
\textcolor{preprocessor}{#define MSG\_TEXT 2}

collections \{
   group \{
      name: \textcolor{stringliteral}{"example\_group"};

      parts \{
         part \{
            name: \textcolor{stringliteral}{"part\_right"};
            type: RECT;
            clip\_to: \textcolor{stringliteral}{"part\_right\_clipper"};
            description \{
               min: 50 50;
               max: 50 50;
               state: \textcolor{stringliteral}{"default"} 0.0;
               color: 0 0 255 255; \textcolor{comment}{/* blue */}
               rel1.relative: 1.0 0.5;
               rel1.offset: -49 0;
               rel2.relative: 1.0 0.5;
            \}
         \}

         part \{
            name: \textcolor{stringliteral}{"part\_left"};
            type: RECT;
            description \{
               color\_class: \textcolor{stringliteral}{"cc"};
               min: 50 50;
               max: 50 50;
               state: \textcolor{stringliteral}{"default"} 0.0;
               rel1.relative: 0.0 0.5;
               rel2.relative: 0.0 0.5;
               rel2.offset: 50 -1;
            \}
         \}

         part \{
            name: \textcolor{stringliteral}{"text"};
            type: TEXT;
            description \{
               min: 150 50;
               max: 150 50;
               fixed: 1 1;
               color: 0 0 0 255;
               state: \textcolor{stringliteral}{"default"} 0.0;
               rel1.relative: 0.5 0.5;
               rel2.relative: 0.5 0.5;
               text \{
                  font:     \textcolor{stringliteral}{"Sans"};
                  size:     20;
                  min:      1 1;
                  align:    0.5 0.5;
               \}
            \}
         \}

         part \{
            name: \textcolor{stringliteral}{"part\_right\_clipper"};
            type: RECT;
            repeat\_events: 1;

            description \{
               min: 50 50;
               max: 50 50;

               state: \textcolor{stringliteral}{"default"} 0.0;
               rel1.relative: 1.0 0.5;
               rel1.offset: -49 0;
               rel2.relative: 1.0 0.5;
            \}

            description \{
               state: \textcolor{stringliteral}{"hidden"} 0.0;
               inherit: \textcolor{stringliteral}{"default"} 0.0;
               visible: 0;
            \}
         \}
      \}

\end{DoxyCodeInclude}


The {\ttfamily \#define\textquotesingle{}s} on the beginning will serve as message identifiers, for our accorded message interface between the code and the this theme file.

Let\textquotesingle{}s move to the code, then. After instantiating the Edje object, we register two {\bfseries signal callbacks} on it. The first one uses {\bfseries globbing}, making all of the wheel mouse actions over the left rectangle to trigger {\ttfamily \+\_\+mouse\+\_\+wheel}. Note that those kind of signals are generated {\bfseries internally} (and automatically) in Edje. The second is a direct signal match, to a (custom) signal we defined in the E\+DC, ourselves\+:  
\begin{DoxyCodeInclude}
   edje\_obj = edje\_object\_add(evas);

   \textcolor{keywordflow}{if} (!edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"example\_group"}))
     \{
        \textcolor{keywordtype}{int} err = edje\_object\_load\_error\_get(edje\_obj);
        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errmsg = \hyperlink{group__Edje__Object__File_ga034465c2de4ab495802da20f332c386e}{edje\_load\_error\_str}(err);
        fprintf(stderr, \textcolor{stringliteral}{"Could not load 'example\_group' from "}
                        \textcolor{stringliteral}{"signals-messages.edj: %s\(\backslash\)n"}, errmsg);

        \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(edje\_obj);
        \textcolor{keywordflow}{goto} shutdown\_edje;
     \}

   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,wheel,*"}, \textcolor{stringliteral}{"part\_left"},
                                   \_on\_mouse\_wheel, NULL);

   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,over"}, \textcolor{stringliteral}{"part\_right"},
                                   \_on\_mouse\_over, NULL);

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* print signals coming from theme */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_sig\_print(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission,
           \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Signal %s coming from part %s!\(\backslash\)n"}, emission, source);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_wheel(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
                  \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj EINA\_UNUSED,
                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *emission,
                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *source)
\{
   \_sig\_print(emission, source);
\}

\end{DoxyCodeInclude}


That second callback is on a signal we emit on the theme, where we just translate Edje {\ttfamily \char`\"{}mouse,move\char`\"{}} internal events to the custom {\ttfamily \char`\"{}mouse,over\char`\"{}} one. When that signals reaches the code, we are, besides printing the signals\textquotesingle{} strings, sending a {\bfseries message} back to the theme. We generate random values of color components and send them as an \hyperlink{group__Edje_ggad0763549d687c9cfc6df685ac077d967aa392f6e98640e16c6b71f3dd19e18d39}{E\+D\+J\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+I\+N\+T\+\_\+\+S\+ET} message type\+:  
\begin{DoxyCodeInclude}
         program \{ \textcolor{comment}{/* custom signal */}
            name: \textcolor{stringliteral}{"part\_right,hovered"};
            signal: \textcolor{stringliteral}{"mouse,move"};
            source: \textcolor{stringliteral}{"part\_right"};
            action: SIGNAL\_EMIT \textcolor{stringliteral}{"mouse,over"} \textcolor{stringliteral}{"part\_right"};
         \}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* mouse over signals */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_over(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
               \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj,
               \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *emission,
               \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *source)
\{
   \textcolor{keywordtype}{int} i;

   \_sig\_print(emission, source);

   \hyperlink{struct__Edje__Message__Int__Set}{Edje\_Message\_Int\_Set} *msg = malloc(\textcolor{keyword}{sizeof}(*msg) + 3 * \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}));
   msg->\hyperlink{struct__Edje__Message__Int__Set_a975ee039878b90538f2fb4471428c56e}{count} = 4;
   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
     msg->\hyperlink{struct__Edje__Message__Int__Set_a835187daa81c0007a58cbcf4eaa896ed}{val}[i] = rand() % 256;

   edje\_object\_message\_send(edje\_obj, \hyperlink{group__Edje_ggad0763549d687c9cfc6df685ac077d967aa392f6e98640e16c6b71f3dd19e18d39}{EDJE\_MESSAGE\_INT\_SET}, MSG\_COLOR, msg);

   free(msg);
\}

\end{DoxyCodeInclude}


In our theme we\textquotesingle{}ll be changing the {\ttfamily \char`\"{}cc\char`\"{}} color class\textquotesingle{} values with those integer values of the message, so that moving the mouse over the right rectangle will change the left one\textquotesingle{}s colors\+:  
\begin{DoxyCodeInclude}
        \textcolor{keyword}{public} message(Msg\_Type:type, \textcolor{keywordtype}{id}, ...) \{
           \textcolor{keywordflow}{if} ((type == MSG\_INT\_SET) && (\textcolor{keywordtype}{id} == MSG\_COLOR)) \{
               \textcolor{keyword}{new} r, g, b, a;

               r = getarg(2);
               g = getarg(3);
               b = getarg(4);
               a = getarg(5);

               set\_color\_class(\textcolor{stringliteral}{"cc"}, r, g, b, a);
           \}
        \}

\end{DoxyCodeInclude}


Now we\textquotesingle{}re also sending messages {\bfseries from the Edje object}, besides signals. We do so when one clicks with the left button over the left rectangle. With that, we change the text part\textquotesingle{}s text, cycling between 3 pre-\/set strings declared in the E\+DC. With each new text string attribution, we send a string message to our code, with the current string as argument\+:  
\begin{DoxyCodeInclude}
      programs \{
         program \{
            name: \textcolor{stringliteral}{"bootstrap"};
            signal: \textcolor{stringliteral}{"load"};
            source: \textcolor{stringliteral}{""};
            script \{
               set\_str(global\_str0, \textcolor{stringliteral}{"String one"});
               set\_str(global\_str1, \textcolor{stringliteral}{"String two"});
               set\_str(global\_str2, \textcolor{stringliteral}{"String three"});
               set\_int(str\_idx, 0);
               set\_text\_string();
            \}
         \}
         program \{ \textcolor{comment}{/* change text part's string value */}
            name: \textcolor{stringliteral}{"text,change"};
            signal: \textcolor{stringliteral}{"mouse,clicked,1"};
            source: \textcolor{stringliteral}{"part\_left"};
            script \{
               \textcolor{keyword}{new} idx;
               idx = get\_int(str\_idx);
               idx = idx + 1;

               \textcolor{keywordflow}{if} (idx > 2)
                  set\_int(str\_idx, 0);
               \textcolor{keywordflow}{else}
                  set\_int(str\_idx, idx);

               set\_text\_string();
            \}
         \}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
        \textcolor{keyword}{public} set\_text\_string() \{
           \textcolor{keyword}{new} tmp[1024];
           \textcolor{keyword}{new} idx;
           idx = get\_int(str\_idx);

           \textcolor{keywordflow}{if} (idx == 0)
              get\_str(global\_str0, tmp, 1024);
           \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (idx == 1)
              get\_str(global\_str1, tmp, 1024);
           \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (idx == 2)
              get\_str(global\_str2, tmp, 1024);
              \textcolor{keywordflow}{else} \textcolor{keywordflow}{return};

           set\_text(PART:\textcolor{stringliteral}{"text"}, tmp);
           send\_message(MSG\_STRING, MSG\_TEXT, tmp);
        \}

\end{DoxyCodeInclude}


To get the message in code, we have to register a message handler, as follows\+:  
\begin{DoxyCodeInclude}
   edje\_object\_message\_handler\_set(edje\_obj, \_message\_handle, NULL);

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* print out received message string */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_message\_handle(\textcolor{keywordtype}{void}             *data EINA\_UNUSED,
                \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}      *obj EINA\_UNUSED,
                \hyperlink{group__Edje_gad0763549d687c9cfc6df685ac077d967}{Edje\_Message\_Type} type,
                \textcolor{keywordtype}{int}               \textcolor{keywordtype}{id},
                \textcolor{keywordtype}{void}             *msg)
\{
   \hyperlink{struct__Edje__Message__String}{Edje\_Message\_String} *m;

   \textcolor{keywordflow}{if} (type != \hyperlink{group__Edje_ggad0763549d687c9cfc6df685ac077d967ad24747cc7c7ef0d5a61d29cf9d78dd77}{EDJE\_MESSAGE\_STRING}) \textcolor{keywordflow}{return};
   \textcolor{keywordflow}{if} (\textcolor{keywordtype}{id} != MSG\_TEXT) \textcolor{keywordflow}{return};

   m = msg;

   fprintf(stdout, \textcolor{stringliteral}{"String message received: %s\(\backslash\)n"}, m->\hyperlink{struct__Edje__Message__String_a26d7286d36a05fa3f148b426ed8267e9}{str});
\}

\end{DoxyCodeInclude}


To interact with the last missing feature -- emitting signals {\bfseries from code} -- there\textquotesingle{}s a command line interface to exercise it. A help string can be asked for with the \textquotesingle{}h\textquotesingle{} key\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} commands[] = \(\backslash\)
  \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tt - toggle right rectangle's visibility\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tEsc - exit\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"};

\end{DoxyCodeInclude}


The {\ttfamily \textquotesingle{}t\textquotesingle{}} command will send either {\ttfamily \char`\"{}part\+\_\+right,show\char`\"{}} or {\ttfamily \char`\"{}part\+\_\+right,hide\char`\"{}} signals to the Edje object (those being the emission part of the signal), which was set to react on them as the names indicate. We\textquotesingle{}ll set the right rectangle\textquotesingle{}s visibility on/off, respectively, for those two signals\+:  
\begin{DoxyCodeInclude}
         program \{ \textcolor{comment}{/* hide right rectangle */}
            name: \textcolor{stringliteral}{"part\_right,hide"};
            signal: \textcolor{stringliteral}{"part\_right,hide"};
            source: \textcolor{stringliteral}{""};
            action: STATE\_SET \textcolor{stringliteral}{"hidden"} 0.0;
            target: \textcolor{stringliteral}{"part\_right\_clipper"};
         \}

         program \{
            name: \textcolor{stringliteral}{"part\_right,show"};
            signal: \textcolor{stringliteral}{"part\_right,show"};
            source: \textcolor{stringliteral}{""};
            action: STATE\_SET \textcolor{stringliteral}{"default"} 0.0;
            target: \textcolor{stringliteral}{"part\_right\_clipper"};
         \}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"t"})) \textcolor{comment}{/* toggle right rectangle's visibility */}
     \{
        \textcolor{keywordtype}{char} buf[1024];

        right\_rect\_show = !right\_rect\_show;
        snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"part\_right,%s"},
                 right\_rect\_show ? \textcolor{stringliteral}{"show"} : \textcolor{stringliteral}{"hide"});

        printf(\textcolor{stringliteral}{"emitting %s\(\backslash\)n"}, buf);

        edje\_object\_signal\_emit(edje\_obj, buf, \textcolor{stringliteral}{""});

        \textcolor{keywordflow}{return};
     \}

\end{DoxyCodeInclude}


The example\textquotesingle{}s window should look like this picture\+:

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{edje-signals-messages-example}}
\end{DoxyImageNoCaption}


The full example follows, along with its E\+DC file.


\begin{DoxyCodeInclude}
#define MSG\_COLOR 1
#define MSG\_TEXT 2

collections \{
   group \{
      name: "example\_group";

      parts \{
         part \{
            name: "part\_right";
            type: RECT;
            clip\_to: "part\_right\_clipper";
            description \{
               min: 50 50;
               max: 50 50;
               state: "default" 0.0;
               color: 0 0 255 255; /* blue */
               rel1.relative: 1.0 0.5;
               rel1.offset: -49 0;
               rel2.relative: 1.0 0.5;
            \}
         \}

         part \{
            name: "part\_left";
            type: RECT;
            description \{
               color\_class: "cc";
               min: 50 50;
               max: 50 50;
               state: "default" 0.0;
               rel1.relative: 0.0 0.5;
               rel2.relative: 0.0 0.5;
               rel2.offset: 50 -1;
            \}
         \}

         part \{
            name: "text";
            type: TEXT;
            description \{
               min: 150 50;
               max: 150 50;
               fixed: 1 1;
               color: 0 0 0 255;
               state: "default" 0.0;
               rel1.relative: 0.5 0.5;
               rel2.relative: 0.5 0.5;
               text \{
                  font:     "Sans";
                  size:     20;
                  min:      1 1;
                  align:    0.5 0.5;
               \}
            \}
         \}

         part \{
            name: "part\_right\_clipper";
            type: RECT;
            repeat\_events: 1;

            description \{
               min: 50 50;
               max: 50 50;

               state: "default" 0.0;
               rel1.relative: 1.0 0.5;
               rel1.offset: -49 0;
               rel2.relative: 1.0 0.5;
            \}

            description \{
               state: "hidden" 0.0;
               inherit: "default" 0.0;
               visible: 0;
            \}
         \}
      \}

      script \{
        public global\_str0;
        public global\_str1;
        public global\_str2;
        public str\_idx;

        public set\_text\_string() \{
           new tmp[1024];
           new idx;
           idx = get\_int(str\_idx);

           if (idx == 0)
              get\_str(global\_str0, tmp, 1024);
           else if (idx == 1)
              get\_str(global\_str1, tmp, 1024);
           else if (idx == 2)
              get\_str(global\_str2, tmp, 1024);
              else return;

           set\_text(PART:"text", tmp);
           send\_message(MSG\_STRING, MSG\_TEXT, tmp);
        \}

        public message(Msg\_Type:type, id, ...) \{
           if ((type == MSG\_INT\_SET) && (id == MSG\_COLOR)) \{
               new r, g, b, a;

               r = getarg(2);
               g = getarg(3);
               b = getarg(4);
               a = getarg(5);

               set\_color\_class("cc", r, g, b, a);
           \}
        \}
      \}

      programs \{
         program \{
            name: "bootstrap";
            signal: "load";
            source: "";
            script \{
               set\_str(global\_str0, "String one");
               set\_str(global\_str1, "String two");
               set\_str(global\_str2, "String three");
               set\_int(str\_idx, 0);
               set\_text\_string();
            \}
         \}

         program \{ /* custom signal */
            name: "part\_right,hovered";
            signal: "mouse,move";
            source: "part\_right";
            action: SIGNAL\_EMIT "mouse,over" "part\_right";
         \}

         program \{ /* hide right rectangle */
            name: "part\_right,hide";
            signal: "part\_right,hide";
            source: "";
            action: STATE\_SET "hidden" 0.0;
            target: "part\_right\_clipper";
         \}

         program \{
            name: "part\_right,show";
            signal: "part\_right,show";
            source: "";
            action: STATE\_SET "default" 0.0;
            target: "part\_right\_clipper";
         \}

         program \{ /* change text part's string value */
            name: "text,change";
            signal: "mouse,clicked,1";
            source: "part\_left";
            script \{
               new idx;
               idx = get\_int(str\_idx);
               idx = idx + 1;

               if (idx > 2)
                  set\_int(str\_idx, 0);
               else
                  set\_int(str\_idx, idx);

               set\_text\_string();
            \}
         \}
      \}
   \}
\}
\end{DoxyCodeInclude}
 
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{#include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{#define PACKAGE\_EXAMPLES\_DIR "."}
\textcolor{preprocessor}{#define EINA\_UNUSED}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#ifndef PACKAGE\_DATA\_DIR}
\textcolor{preprocessor}{#define PACKAGE\_DATA\_DIR "."}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}
\textcolor{preprocessor}{#include <\hyperlink{Edje_8h}{Edje.h}>}
\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{preprocessor}{#define WIDTH     (300)}
\textcolor{preprocessor}{#define HEIGHT    (300)}

\textcolor{preprocessor}{#define MSG\_COLOR 1}
\textcolor{preprocessor}{#define MSG\_TEXT  2}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} commands[] = \(\backslash\)
  \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tt - toggle right rectangle's visibility\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tEsc - exit\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"};

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} right\_rect\_show = \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_keydown(\textcolor{keywordtype}{void}        *data,
            \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas EINA\_UNUSED,
            \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED,
            \textcolor{keywordtype}{void}        *einfo)
\{
   \hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down} *ev;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}         *edje\_obj;

   ev = (\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down} *)einfo;
   edje\_obj = (\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *)data;

   \textcolor{keywordflow}{if} (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"h"})) \textcolor{comment}{/* print help */}
     \{
        fprintf(stdout, commands);
        \textcolor{keywordflow}{return};
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"t"})) \textcolor{comment}{/* toggle right rectangle's visibility */}
     \{
        \textcolor{keywordtype}{char} buf[1024];

        right\_rect\_show = !right\_rect\_show;
        snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"part\_right,%s"},
                 right\_rect\_show ? \textcolor{stringliteral}{"show"} : \textcolor{stringliteral}{"hide"});

        printf(\textcolor{stringliteral}{"emitting %s\(\backslash\)n"}, buf);

        edje\_object\_signal\_emit(edje\_obj, buf, \textcolor{stringliteral}{""});

        \textcolor{keywordflow}{return};
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Escape"}))
     \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
   \textcolor{keywordflow}{else}
     \{
        printf(\textcolor{stringliteral}{"unhandled key: %s\(\backslash\)n"}, ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key});
        fprintf(stdout, commands);
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_delete(Ecore\_Evas *ee EINA\_UNUSED)
\{
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
\}

\textcolor{comment}{/* print signals coming from theme */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_sig\_print(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission,
           \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Signal %s coming from part %s!\(\backslash\)n"}, emission, source);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_wheel(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
                  \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj EINA\_UNUSED,
                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *emission,
                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *source)
\{
   \_sig\_print(emission, source);
\}

\textcolor{comment}{/* mouse over signals */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_over(\textcolor{keywordtype}{void}        *data EINA\_UNUSED,
               \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj,
               \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *emission,
               \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *source)
\{
   \textcolor{keywordtype}{int} i;

   \_sig\_print(emission, source);

   \hyperlink{struct__Edje__Message__Int__Set}{Edje\_Message\_Int\_Set} *msg = malloc(\textcolor{keyword}{sizeof}(*msg) + 3 * \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}));
   msg->\hyperlink{struct__Edje__Message__Int__Set_a975ee039878b90538f2fb4471428c56e}{count} = 4;
   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
     msg->\hyperlink{struct__Edje__Message__Int__Set_a835187daa81c0007a58cbcf4eaa896ed}{val}[i] = rand() % 256;

   edje\_object\_message\_send(edje\_obj, \hyperlink{group__Edje_ggad0763549d687c9cfc6df685ac077d967aa392f6e98640e16c6b71f3dd19e18d39}{EDJE\_MESSAGE\_INT\_SET}, MSG\_COLOR, msg);

   free(msg);
\}

\textcolor{comment}{/* print out received message string */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_message\_handle(\textcolor{keywordtype}{void}             *data EINA\_UNUSED,
                \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}      *obj EINA\_UNUSED,
                \hyperlink{group__Edje_gad0763549d687c9cfc6df685ac077d967}{Edje\_Message\_Type} type,
                \textcolor{keywordtype}{int}               \textcolor{keywordtype}{id},
                \textcolor{keywordtype}{void}             *msg)
\{
   \hyperlink{struct__Edje__Message__String}{Edje\_Message\_String} *m;

   \textcolor{keywordflow}{if} (type != \hyperlink{group__Edje_ggad0763549d687c9cfc6df685ac077d967ad24747cc7c7ef0d5a61d29cf9d78dd77}{EDJE\_MESSAGE\_STRING}) \textcolor{keywordflow}{return};
   \textcolor{keywordflow}{if} (\textcolor{keywordtype}{id} != MSG\_TEXT) \textcolor{keywordflow}{return};

   m = msg;

   fprintf(stdout, \textcolor{stringliteral}{"String message received: %s\(\backslash\)n"}, m->\hyperlink{struct__Edje__Message__String_a26d7286d36a05fa3f148b426ed8267e9}{str});
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc EINA\_UNUSED, \textcolor{keywordtype}{char} *argv[] EINA\_UNUSED)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *img\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/red.png"};
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/signals-messages.edj"};
   Ecore\_Evas  *ee;
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *border;

   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}())
     \textcolor{keywordflow}{return} EXIT\_FAILURE;

   \textcolor{keywordflow}{if} (!\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}())
     \textcolor{keywordflow}{goto} shutdown\_ecore\_evas;

   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee) \textcolor{keywordflow}{goto} shutdown\_edje;

   \hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}(ee, \_on\_delete);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee, \textcolor{stringliteral}{"Edje Basics Example"});

   evas = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee);

   bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   \hyperlink{group__Evas_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   \hyperlink{group__Evas_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);
   evas\_object\_focus\_set(bg, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);

   edje\_obj = edje\_object\_add(evas);

   \textcolor{keywordflow}{if} (!edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"example\_group"}))
     \{
        \textcolor{keywordtype}{int} err = edje\_object\_load\_error\_get(edje\_obj);
        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errmsg = \hyperlink{group__Edje__Object__File_ga034465c2de4ab495802da20f332c386e}{edje\_load\_error\_str}(err);
        fprintf(stderr, \textcolor{stringliteral}{"Could not load 'example\_group' from "}
                        \textcolor{stringliteral}{"signals-messages.edj: %s\(\backslash\)n"}, errmsg);

        \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(edje\_obj);
        \textcolor{keywordflow}{goto} shutdown\_edje;
     \}

   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,wheel,*"}, \textcolor{stringliteral}{"part\_left"},
                                   \_on\_mouse\_wheel, NULL);

   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,over"}, \textcolor{stringliteral}{"part\_right"},
                                   \_on\_mouse\_over, NULL);

   edje\_object\_message\_handler\_set(edje\_obj, \_message\_handle, NULL);

   \hyperlink{group__Evas_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, 20, 20);
   \hyperlink{group__Evas_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(edje\_obj, WIDTH - 40, HEIGHT - 40);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj);

   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(bg, 
      \hyperlink{group__Evas_ggad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}, \_on\_keydown, edje\_obj);

   \textcolor{comment}{/* this is a border around the Edje object above, here just to}
\textcolor{comment}{    * emphasize its geometry */}
   border = evas\_object\_image\_filled\_add(evas);
   evas\_object\_image\_file\_set(border, img\_file, NULL);
   evas\_object\_image\_border\_set(border, 2, 2, 2, 2);
   evas\_object\_image\_border\_center\_fill\_set(border, EVAS\_BORDER\_FILL\_NONE);

   \hyperlink{group__Evas_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(border, WIDTH - 40 + 4, HEIGHT - 40 + 4);
   \hyperlink{group__Evas_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(border, 20 - 2, 20 - 2);
   evas\_object\_repeat\_events\_set(border, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(border);

   fprintf(stdout, commands);

   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();

   \textcolor{keywordflow}{return} EXIT\_SUCCESS;

 shutdown\_edje:
   \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();
 shutdown\_ecore\_evas:
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();

   \textcolor{keywordflow}{return} EXIT\_FAILURE;
\}
\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-signals-messages edje-signals-messages.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\"
* -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\"
* -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\"
* `pkg-config --cflags --libs evas ecore ecore-evas edje`
*
* edje_cc signals-messages.edc
* \end{DoxyVerb}
 