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'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's} on the beginning will serve as message identifiers, for our accorded message interface between the code and the this theme file.

Let'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\+D\+C, 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' strings, sending a {\bfseries message} back to the theme. We generate random values of color components and send them as an \hyperlink{group__Edje__Object__Communication__Interface__Message_gga0d3b39bbf2f2f0c070d45edd5d0b0cfaaa392f6e98640e16c6b71f3dd19e18d39}{E\+D\+J\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+I\+N\+T\+\_\+\+S\+E\+T} 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__Object__Communication__Interface__Message_gga0d3b39bbf2f2f0c070d45edd5d0b0cfaaa392f6e98640e16c6b71f3dd19e18d39}{EDJE\_MESSAGE\_INT\_SET}, MSG\_COLOR, msg);

   free(msg);
\}

\end{DoxyCodeInclude}


In our theme we'll be changing the {\ttfamily \char`\"{}cc\char`\"{}} color class' values with those integer values of the message, so that moving the mouse over the right rectangle will change the left one'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'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's text, cycling between 3 pre-\/set strings declared in the E\+D\+C. 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__Object__Communication__Interface__Message_ga986c03fa5abf90ef03b6dbbd93cf8dcc}{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__Object__Communication__Interface__Message_gga0d3b39bbf2f2f0c070d45edd5d0b0cfaad24747cc7c7ef0d5a61d29cf9d78dd77}{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's a command line interface to exercise it. A help string can be asked for with the 'h' 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 't'} 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'll set the right rectangle'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's window should look like this picture\+:

  
\begin{DoxyImage}
\includegraphics{edje-signals-messages-example}
\caption{width=}
\end{DoxyImage}


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


\begin{DoxyCodeInclude}
1 #define MSG\_COLOR 1
2 #define MSG\_TEXT 2
3 
4 collections \{
5    group \{
6       name: "example\_group";
7 
8       parts \{
9          part \{
10             name: "part\_right";
11             type: RECT;
12             clip\_to: "part\_right\_clipper";
13             description \{
14                min: 50 50;
15                max: 50 50;
16                state: "default" 0.0;
17                color: 0 0 255 255; /* blue */
18                rel1.relative: 1.0 0.5;
19                rel1.offset: -49 0;
20                rel2.relative: 1.0 0.5;
21             \}
22          \}
23 
24          part \{
25             name: "part\_left";
26             type: RECT;
27             description \{
28                color\_class: "cc";
29                min: 50 50;
30                max: 50 50;
31                state: "default" 0.0;
32                rel1.relative: 0.0 0.5;
33                rel2.relative: 0.0 0.5;
34                rel2.offset: 50 -1;
35             \}
36          \}
37 
38          part \{
39             name: "text";
40             type: TEXT;
41             description \{
42                min: 150 50;
43                max: 150 50;
44                fixed: 1 1;
45                color: 0 0 0 255;
46                state: "default" 0.0;
47                rel1.relative: 0.5 0.5;
48                rel2.relative: 0.5 0.5;
49                text \{
50                   font:     "Sans";
51                   size:     20;
52                   min:      1 1;
53                   align:    0.5 0.5;
54                \}
55             \}
56          \}
57 
58          part \{
59             name: "part\_right\_clipper";
60             type: RECT;
61             repeat\_events: 1;
62 
63             description \{
64                min: 50 50;
65                max: 50 50;
66 
67                state: "default" 0.0;
68                rel1.relative: 1.0 0.5;
69                rel1.offset: -49 0;
70                rel2.relative: 1.0 0.5;
71             \}
72 
73             description \{
74                state: "hidden" 0.0;
75                inherit: "default" 0.0;
76                visible: 0;
77             \}
78          \}
79       \}
80 
81       script \{
82         public global\_str0;
83         public global\_str1;
84         public global\_str2;
85         public str\_idx;
86 
87         public set\_text\_string() \{
88            new tmp[1024];
89            new idx;
90            idx = get\_int(str\_idx);
91 
92            if (idx == 0)
93               get\_str(global\_str0, tmp, 1024);
94            else if (idx == 1)
95               get\_str(global\_str1, tmp, 1024);
96            else if (idx == 2)
97               get\_str(global\_str2, tmp, 1024);
98               else return;
99 
100            set\_text(PART:"text", tmp);
101            send\_message(MSG\_STRING, MSG\_TEXT, tmp);
102         \}
103 
104         public message(Msg\_Type:type, id, ...) \{
105            if ((type == MSG\_INT\_SET) && (id == MSG\_COLOR)) \{
106                new r, g, b, a;
107 
108                r = getarg(2);
109                g = getarg(3);
110                b = getarg(4);
111                a = getarg(5);
112 
113                set\_color\_class("cc", r, g, b, a);
114            \}
115         \}
116       \}
117 
118       programs \{
119          program \{
120             name: "bootstrap";
121             signal: "load";
122             source: "";
123             script \{
124                set\_str(global\_str0, "String one");
125                set\_str(global\_str1, "String two");
126                set\_str(global\_str2, "String three");
127                set\_int(str\_idx, 0);
128                set\_text\_string();
129             \}
130          \}
131 
132          program \{ /* custom signal */
133             name: "part\_right,hovered";
134             signal: "mouse,move";
135             source: "part\_right";
136             action: SIGNAL\_EMIT "mouse,over" "part\_right";
137          \}
138 
139          program \{ /* hide right rectangle */
140             name: "part\_right,hide";
141             signal: "part\_right,hide";
142             source: "";
143             action: STATE\_SET "hidden" 0.0;
144             target: "part\_right\_clipper";
145          \}
146 
147          program \{
148             name: "part\_right,show";
149             signal: "part\_right,show";
150             source: "";
151             action: STATE\_SET "default" 0.0;
152             target: "part\_right\_clipper";
153          \}
154 
155          program \{ /* change text part's string value */
156             name: "text,change";
157             signal: "mouse,clicked,1";
158             source: "part\_left";
159             script \{
160                new idx;
161                idx = get\_int(str\_idx);
162                idx = idx + 1;
163 
164                if (idx > 2)
165                   set\_int(str\_idx, 0);
166                else
167                   set\_int(str\_idx, idx);
168 
169                set\_text\_string();
170             \}
171          \}
172       \}
173    \}
174 \}
\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__Object__Communication__Interface__Message_gga0d3b39bbf2f2f0c070d45edd5d0b0cfaaa392f6e98640e16c6b71f3dd19e18d39}{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__Object__Communication__Interface__Message_ga986c03fa5abf90ef03b6dbbd93cf8dcc}{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__Object__Communication__Interface__Message_gga0d3b39bbf2f2f0c070d45edd5d0b0cfaad24747cc7c7ef0d5a61d29cf9d78dd77}{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 */}
   evas\_object\_move(bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   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);

   evas\_object\_move(edje\_obj, 20, 20);
   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{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa336b86bad4f145f84c155e4922335584}{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 = \hyperlink{group__Evas__Object__Image_ga0e8cb83d31d02bf583c75925b7cd14d7}{evas\_object\_image\_filled\_add}(evas);
   \hyperlink{group__Evas__Object__Image_gac27fd0ceabe5f56607b7a86d71577df1}{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, \hyperlink{Evas__Common_8h_a4a05f0fd82f51c6b330e349457cdc7e2a2ad856ac6aab5e2659c3a584a37aec70}{EVAS\_BORDER\_FILL\_NONE});

   evas\_object\_resize(border, WIDTH - 40 + 4, HEIGHT - 40 + 4);
   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}
 