summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-23 23:07:54 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-23 23:07:54 +0900
commit53e27458f6d71a26291f896fbddc70f41d30478d (patch)
tree925f393986b4b2349922ddd91852d1f4655094ae /src/examples
parent9c1466e19315852352886078d988579a80162c41 (diff)
evas - examples - fix broken evas stacking example
this fixes a broken example that assumes getting name always succeeds. this fixes T559
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/evas-stacking.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/examples/evas/evas-stacking.c b/src/examples/evas/evas-stacking.c
index 67e85c1ca7..9763227f51 100644
--- a/src/examples/evas/evas-stacking.c
+++ b/src/examples/evas/evas-stacking.c
@@ -52,13 +52,21 @@ static const char *commands = \
52 "\tl - change background rectangle's layer\n" 52 "\tl - change background rectangle's layer\n"
53 "\th - print help\n"; 53 "\th - print help\n";
54 54
55static const char *
56_name_get(Evas_Object *o)
57{
58 const char *s = evas_object_name_get(o);
59 if (!s) s = "(null)";
60 return s;
61}
62
55static void 63static void
56_on_mouse_down(void *data EINA_UNUSED, 64_on_mouse_down(void *data EINA_UNUSED,
57 Evas *evas EINA_UNUSED, 65 Evas *evas EINA_UNUSED,
58 Evas_Object *o, 66 Evas_Object *o,
59 void *einfo EINA_UNUSED) 67 void *einfo EINA_UNUSED)
60{ 68{
61 fprintf(stdout, "Mouse down on rectangle %s!\n", evas_object_name_get(o)); 69 fprintf(stdout, "Mouse down on rectangle %s!\n", _name_get(o));
62} 70}
63 71
64/* here just to keep our example's window size and background image's 72/* here just to keep our example's window size and background image's
@@ -81,7 +89,7 @@ _on_keydown(void *data EINA_UNUSED,
81 void *einfo) 89 void *einfo)
82{ 90{
83 Evas_Event_Key_Down *ev = einfo; 91 Evas_Event_Key_Down *ev = einfo;
84 const char *name = evas_object_name_get(d.rects[d.cur_rect]); 92 const char *name = _name_get(d.rects[d.cur_rect]);
85 93
86 if (strcmp(ev->keyname, "h") == 0) /* print help */ 94 if (strcmp(ev->keyname, "h") == 0) /* print help */
87 { 95 {
@@ -98,19 +106,19 @@ _on_keydown(void *data EINA_UNUSED,
98 fprintf(stdout, "Order of stacking, from top to bottom, is: "); 106 fprintf(stdout, "Order of stacking, from top to bottom, is: ");
99 107
100 rect = evas_object_top_get(evas); 108 rect = evas_object_top_get(evas);
101 fprintf(stdout, "%s", evas_object_name_get(rect)); 109 fprintf(stdout, "%s", _name_get(rect));
102 110
103 rect = evas_object_below_get(rect); 111 rect = evas_object_below_get(rect);
104 while (rect) 112 while (rect)
105 { 113 {
106 fprintf(stdout, ", %s", evas_object_name_get(rect)); 114 fprintf(stdout, ", %s", _name_get(rect));
107 rect = evas_object_below_get(rect); 115 rect = evas_object_below_get(rect);
108 } 116 }
109 117
110 fprintf(stdout, ".\n"); 118 fprintf(stdout, ".\n");
111 119
112 fprintf(stdout, "Current target rectangle is %s\n", 120 fprintf(stdout, "Current target rectangle is %s\n",
113 evas_object_name_get(d.rects[d.cur_rect])); 121 _name_get(d.rects[d.cur_rect]));
114 122
115 fprintf(stdout, "Background rectangle's layer is %d\n", 123 fprintf(stdout, "Background rectangle's layer is %d\n",
116 evas_object_layer_get(d.bg)); 124 evas_object_layer_get(d.bg));
@@ -133,7 +141,7 @@ _on_keydown(void *data EINA_UNUSED,
133 d.cur_rect = (d.cur_rect + 1) % 3; 141 d.cur_rect = (d.cur_rect + 1) % 3;
134 142
135 fprintf(stdout, "Changing target rectangle to the %s one\n", 143 fprintf(stdout, "Changing target rectangle to the %s one\n",
136 evas_object_name_get(d.rects[d.cur_rect])); 144 _name_get(d.rects[d.cur_rect]));
137 return; 145 return;
138 } 146 }
139 147
@@ -148,7 +156,7 @@ _on_keydown(void *data EINA_UNUSED,
148 156
149 neighbour = evas_object_below_get(d.rects[d.cur_rect]); 157 neighbour = evas_object_below_get(d.rects[d.cur_rect]);
150 fprintf(stdout, "Below of %s rect is %s\n", name, 158 fprintf(stdout, "Below of %s rect is %s\n", name,
151 neighbour ? evas_object_name_get(neighbour) : "no object"); 159 neighbour ? _name_get(neighbour) : "no object");
152 return; 160 return;
153 } 161 }
154 162
@@ -164,7 +172,7 @@ _on_keydown(void *data EINA_UNUSED,
164 172
165 neighbour = evas_object_below_get(d.rects[d.cur_rect]); 173 neighbour = evas_object_below_get(d.rects[d.cur_rect]);
166 fprintf(stdout, "Below of %s rect is %s\n", name, 174 fprintf(stdout, "Below of %s rect is %s\n", name,
167 neighbour ? evas_object_name_get(neighbour) : "no object"); 175 neighbour ? _name_get(neighbour) : "no object");
168 return; 176 return;
169 } 177 }
170 178
@@ -206,11 +214,11 @@ _on_keydown(void *data EINA_UNUSED,
206 214
207 neighbour = evas_object_above_get(d.rects[d.cur_rect]); 215 neighbour = evas_object_above_get(d.rects[d.cur_rect]);
208 fprintf(stdout, "Above of %s rect is %s\n", name, 216 fprintf(stdout, "Above of %s rect is %s\n", name,
209 neighbour ? evas_object_name_get(neighbour) : "no object"); 217 neighbour ? _name_get(neighbour) : "no object");
210 218
211 neighbour = evas_object_below_get(d.rects[d.cur_rect]); 219 neighbour = evas_object_below_get(d.rects[d.cur_rect]);
212 fprintf(stdout, "Below of %s rect is %s\n", name, 220 fprintf(stdout, "Below of %s rect is %s\n", name,
213 neighbour ? evas_object_name_get(neighbour) : "no object"); 221 neighbour ? _name_get(neighbour) : "no object");
214 return; 222 return;
215 } 223 }
216 224
@@ -228,12 +236,12 @@ _on_keydown(void *data EINA_UNUSED,
228 236
229 neighbour = evas_object_above_get(d.rects[d.cur_rect]); 237 neighbour = evas_object_above_get(d.rects[d.cur_rect]);
230 fprintf(stdout, "Above of %s rect is %s\n", name, 238 fprintf(stdout, "Above of %s rect is %s\n", name,
231 neighbour ? evas_object_name_get(neighbour) : "no object"); 239 neighbour ? _name_get(neighbour) : "no object");
232 240
233 neighbour = evas_object_below_get(d.rects[d.cur_rect]); 241 neighbour = evas_object_below_get(d.rects[d.cur_rect]);
234 242
235 fprintf(stdout, "Below of %s rect is %s\n", name, 243 fprintf(stdout, "Below of %s rect is %s\n", name,
236 neighbour ? evas_object_name_get(neighbour) : "no object"); 244 neighbour ? _name_get(neighbour) : "no object");
237 return; 245 return;
238 } 246 }
239} 247}