summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-23 16:40:19 +0200
committerBoris Faure <billiob@gmail.com>2015-08-23 16:41:15 +0200
commit5c9d98cf22cf728f0f7dd759efc5c2f7e15460ce (patch)
treea6422d6234430c4d41b472c1f70c95e8436f37b9 /src
parent72123799c6a0a5d66738273922c100376b51ab66 (diff)
add error handlers on textblocks. Should fix T2672
Diffstat (limited to 'src')
-rw-r--r--src/bin/media.c104
-rw-r--r--src/bin/termio.c60
2 files changed, 114 insertions, 50 deletions
diff --git a/src/bin/media.c b/src/bin/media.c
index dc04450..7cb4d6c 100644
--- a/src/bin/media.c
+++ b/src/bin/media.c
@@ -72,7 +72,7 @@ static Eina_Bool et_connected = EINA_FALSE;
72static Eina_List *et_queue = NULL; 72static Eina_List *et_queue = NULL;
73 73
74static void _et_init(void); 74static void _et_init(void);
75static void _type_thumb_init2(Evas_Object *obj); 75static int _type_thumb_init2(Evas_Object *obj);
76 76
77static void 77static void
78_et_disconnect(void *data EINA_UNUSED, Ethumb_Client *c) 78_et_disconnect(void *data EINA_UNUSED, Ethumb_Client *c)
@@ -187,11 +187,13 @@ _et_error(Ethumb_Client *c EINA_UNUSED, void *data)
187 sd->et_req = NULL; 187 sd->et_req = NULL;
188} 188}
189 189
190static void 190static int
191_type_thumb_init2(Evas_Object *obj) 191_type_thumb_init2(Evas_Object *obj)
192{ 192{
193 Media *sd = evas_object_smart_data_get(obj); 193 Media *sd = evas_object_smart_data_get(obj);
194 if (!sd) return; 194 Eina_Bool ok;
195
196 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
195 197
196 if ((sd->realf) && (sd->realf[0] != '/')) 198 if ((sd->realf) && (sd->realf[0] != '/'))
197 { 199 {
@@ -220,21 +222,31 @@ _type_thumb_init2(Evas_Object *obj)
220 icon_theme = eina_stringshare_add(theme->name.internal); 222 icon_theme = eina_stringshare_add(theme->name.internal);
221 } 223 }
222 fl = efreet_icon_path_find(icon_theme, sd->realf, sd->iw); 224 fl = efreet_icon_path_find(icon_theme, sd->realf, sd->iw);
223 ethumb_client_file_set(et_client, fl, NULL); 225 ok = ethumb_client_file_set(et_client, fl, NULL);
226 if (!ok)
227 return -1;
224 } 228 }
225 else 229 else
226 ethumb_client_file_set(et_client, sd->realf, NULL); 230 {
231 ok = ethumb_client_file_set(et_client, sd->realf, NULL);
232 if (!ok)
233 return -1;
234 }
235
227 sd->et_req = ethumb_client_thumb_async_get(et_client, _et_done, 236 sd->et_req = ethumb_client_thumb_async_get(et_client, _et_done,
228 _et_error, obj); 237 _et_error, obj);
229 sd->queued = EINA_FALSE; 238 sd->queued = EINA_FALSE;
239 return 0;
230} 240}
231 241
232static void 242static int
233_type_thumb_init(Evas_Object *obj) 243_type_thumb_init(Evas_Object *obj)
234{ 244{
235 Evas_Object *o; 245 Evas_Object *o;
236 Media *sd = evas_object_smart_data_get(obj); 246 Media *sd = evas_object_smart_data_get(obj);
237 if (!sd) return; 247
248 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
249
238 sd->type = MEDIA_TYPE_THUMB; 250 sd->type = MEDIA_TYPE_THUMB;
239 _et_init(); 251 _et_init();
240 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj)); 252 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
@@ -248,9 +260,9 @@ _type_thumb_init(Evas_Object *obj)
248 { 260 {
249 et_queue = eina_list_append(et_queue, obj); 261 et_queue = eina_list_append(et_queue, obj);
250 sd->queued = EINA_TRUE; 262 sd->queued = EINA_TRUE;
251 return; 263 return 0;
252 } 264 }
253 _type_thumb_init2(obj); 265 return _type_thumb_init2(obj);
254} 266}
255 267
256//////////////////////// img 268//////////////////////// img
@@ -299,26 +311,35 @@ _cb_img_frame(void *data)
299 return EINA_TRUE; 311 return EINA_TRUE;
300} 312}
301 313
302static void 314static int
303_type_img_anim_handle(Evas_Object *obj) 315_type_img_anim_handle(Evas_Object *obj)
304{ 316{
305 double t; 317 double t;
306 Media *sd = evas_object_smart_data_get(obj); 318 Media *sd = evas_object_smart_data_get(obj);
307 if (!sd) return; 319
308 if (!evas_object_image_animated_get(sd->o_img)) return; 320 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
321
322 if (!evas_object_image_animated_get(sd->o_img))
323 return -1;
324
309 sd->fr = 1; 325 sd->fr = 1;
310 sd->frnum = evas_object_image_animated_frame_count_get(sd->o_img); 326 sd->frnum = evas_object_image_animated_frame_count_get(sd->o_img);
311 if (sd->frnum < 2) return; 327 if (sd->frnum < 2)
328 return 0;
329
312 t = evas_object_image_animated_frame_duration_get(sd->o_img, sd->fr, 0); 330 t = evas_object_image_animated_frame_duration_get(sd->o_img, sd->fr, 0);
313 sd->anim = ecore_timer_add(t, _cb_img_frame, obj); 331 sd->anim = ecore_timer_add(t, _cb_img_frame, obj);
332 return 0;
314} 333}
315 334
316static void 335static int
317_type_img_init(Evas_Object *obj) 336_type_img_init(Evas_Object *obj)
318{ 337{
319 Evas_Object *o; 338 Evas_Object *o;
320 Media *sd = evas_object_smart_data_get(obj); 339 Media *sd = evas_object_smart_data_get(obj);
321 if (!sd) return; 340
341 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
342
322 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj)); 343 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
323 evas_object_smart_member_add(o, obj); 344 evas_object_smart_member_add(o, obj);
324 evas_object_clip_set(o, sd->clip); 345 evas_object_clip_set(o, sd->clip);
@@ -329,7 +350,7 @@ _type_img_init(Evas_Object *obj)
329 evas_object_image_file_set(o, sd->realf, NULL); 350 evas_object_image_file_set(o, sd->realf, NULL);
330 evas_object_image_size_get(o, &(sd->iw), &(sd->ih)); 351 evas_object_image_size_get(o, &(sd->iw), &(sd->ih));
331 evas_object_image_preload(o, EINA_FALSE); 352 evas_object_image_preload(o, EINA_FALSE);
332 _type_img_anim_handle(obj); 353 return _type_img_anim_handle(obj);
333} 354}
334 355
335static void 356static void
@@ -408,12 +429,14 @@ _cb_scale_preloaded(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSE
408 } 429 }
409} 430}
410 431
411static void 432static int
412_type_scale_init(Evas_Object *obj) 433_type_scale_init(Evas_Object *obj)
413{ 434{
414 Evas_Object *o; 435 Evas_Object *o;
415 Media *sd = evas_object_smart_data_get(obj); 436 Media *sd = evas_object_smart_data_get(obj);
416 if (!sd) return; 437
438 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
439
417 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj)); 440 o = sd->o_img = evas_object_image_filled_add(evas_object_evas_get(obj));
418 evas_object_smart_member_add(o, obj); 441 evas_object_smart_member_add(o, obj);
419 evas_object_clip_set(o, sd->clip); 442 evas_object_clip_set(o, sd->clip);
@@ -424,6 +447,8 @@ _type_scale_init(Evas_Object *obj)
424 evas_object_image_file_set(o, sd->realf, NULL); 447 evas_object_image_file_set(o, sd->realf, NULL);
425 evas_object_image_size_get(o, &(sd->iw), &(sd->ih)); 448 evas_object_image_size_get(o, &(sd->iw), &(sd->ih));
426 evas_object_image_preload(o, EINA_FALSE); 449 evas_object_image_preload(o, EINA_FALSE);
450
451 return 0;
427} 452}
428 453
429static void 454static void
@@ -516,7 +541,7 @@ _cb_edje_preloaded(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EIN
516 evas_object_show(sd->clip); 541 evas_object_show(sd->clip);
517} 542}
518 543
519static void 544static int
520_type_edje_init(Evas_Object *obj) 545_type_edje_init(Evas_Object *obj)
521{ 546{
522 Evas_Object *o; 547 Evas_Object *o;
@@ -528,7 +553,9 @@ _type_edje_init(Evas_Object *obj)
528 NULL 553 NULL
529 }; 554 };
530 Media *sd = evas_object_smart_data_get(obj); 555 Media *sd = evas_object_smart_data_get(obj);
531 if (!sd) return; 556
557 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
558
532 o = sd->o_img = edje_object_add(evas_object_evas_get(obj)); 559 o = sd->o_img = edje_object_add(evas_object_evas_get(obj));
533 evas_object_smart_member_add(o, obj); 560 evas_object_smart_member_add(o, obj);
534 evas_object_clip_set(o, sd->clip); 561 evas_object_clip_set(o, sd->clip);
@@ -541,9 +568,10 @@ _type_edje_init(Evas_Object *obj)
541 _cb_edje_preloaded, obj); 568 _cb_edje_preloaded, obj);
542 edje_object_preload(o, EINA_FALSE); 569 edje_object_preload(o, EINA_FALSE);
543 theme_auto_reload_enable(o); 570 theme_auto_reload_enable(o);
544 return; 571 return 0;
545 } 572 }
546 } 573 }
574 return 0;
547} 575}
548 576
549static void 577static void
@@ -696,7 +724,7 @@ _cb_media_pos(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EIN
696 media_position_set(data, vx + vy); 724 media_position_set(data, vx + vy);
697} 725}
698 726
699static void 727static int
700_type_mov_init(Evas_Object *obj) 728_type_mov_init(Evas_Object *obj)
701{ 729{
702 Evas_Object *o; 730 Evas_Object *o;
@@ -710,9 +738,10 @@ _type_mov_init(Evas_Object *obj)
710 "gstreamer1" 738 "gstreamer1"
711 }; 739 };
712 char *mod = NULL; 740 char *mod = NULL;
713
714 Media *sd = evas_object_smart_data_get(obj); 741 Media *sd = evas_object_smart_data_get(obj);
715 if (!sd) return; 742
743 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
744
716 emotion_init(); 745 emotion_init();
717 o = sd->o_img = emotion_object_add(evas_object_evas_get(obj)); 746 o = sd->o_img = emotion_object_add(evas_object_evas_get(obj));
718 if ((sd->config->vidmod >= 0) && 747 if ((sd->config->vidmod >= 0) &&
@@ -723,7 +752,7 @@ _type_mov_init(Evas_Object *obj)
723 ERR(_("Could not Initialize the emotion module '%s'"), mod); 752 ERR(_("Could not Initialize the emotion module '%s'"), mod);
724 evas_object_del(sd->o_img); 753 evas_object_del(sd->o_img);
725 sd->o_img = NULL; 754 sd->o_img = NULL;
726 return; 755 return -1;
727 } 756 }
728 evas_object_smart_callback_add(o, "frame_decode", 757 evas_object_smart_callback_add(o, "frame_decode",
729 _cb_mov_frame_decode, obj); 758 _cb_mov_frame_decode, obj);
@@ -769,8 +798,12 @@ _type_mov_init(Evas_Object *obj)
769 evas_object_show(o); 798 evas_object_show(o);
770 799
771 media_play_set(obj, EINA_TRUE); 800 media_play_set(obj, EINA_TRUE);
772 if (sd->config->mute) media_mute_set(obj, EINA_TRUE); 801 if (sd->config->mute)
773 if (sd->config->visualize) media_visualize_set(obj, EINA_TRUE); 802 media_mute_set(obj, EINA_TRUE);
803 if (sd->config->visualize)
804 media_visualize_set(obj, EINA_TRUE);
805
806 return 0;
774} 807}
775 808
776static void 809static void
@@ -1270,23 +1303,28 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
1270 if ((mode & MEDIA_SIZE_MASK) == MEDIA_THUMB) 1303 if ((mode & MEDIA_SIZE_MASK) == MEDIA_THUMB)
1271 { 1304 {
1272 // XXX: handle sd->url being true? 1305 // XXX: handle sd->url being true?
1273 _type_thumb_init(obj); 1306 if (_type_thumb_init(obj) < 0)
1307 goto err;
1274 } 1308 }
1275 else 1309 else
1276 { 1310 {
1277 switch (type) 1311 switch (type)
1278 { 1312 {
1279 case MEDIA_TYPE_IMG: 1313 case MEDIA_TYPE_IMG:
1280 if (!sd->url) _type_img_init(obj); 1314 if (!sd->url && (_type_img_init(obj) < 0))
1315 goto err;
1281 break; 1316 break;
1282 case MEDIA_TYPE_SCALE: 1317 case MEDIA_TYPE_SCALE:
1283 if (!sd->url) _type_scale_init(obj); 1318 if (!sd->url && (_type_scale_init(obj) < 0))
1319 goto err;
1284 break; 1320 break;
1285 case MEDIA_TYPE_EDJE: 1321 case MEDIA_TYPE_EDJE:
1286 if (!sd->url) _type_edje_init(obj); 1322 if (!sd->url && (_type_edje_init(obj) < 0))
1323 goto err;
1287 break; 1324 break;
1288 case MEDIA_TYPE_MOV: 1325 case MEDIA_TYPE_MOV:
1289 if (!sd->url) _type_mov_init(obj); 1326 if (!sd->url && (_type_mov_init(obj) < 0))
1327 goto err;
1290 break; 1328 break;
1291 default: 1329 default:
1292 break; 1330 break;
@@ -1306,12 +1344,10 @@ media_add(Evas_Object *parent, const char *src, const Config *config, int mode,
1306 1344
1307 return obj; 1345 return obj;
1308 1346
1309#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 13)
1310err: 1347err:
1311 if (obj) 1348 if (obj)
1312 evas_object_del(obj); 1349 evas_object_del(obj);
1313 return NULL; 1350 return NULL;
1314#endif
1315} 1351}
1316 1352
1317void 1353void
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 786cf3c..b879432 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -1774,12 +1774,16 @@ _block_edje_activate(Evas_Object *obj, Termblock *blk)
1774 if ((!blk->path) || (!blk->link)) return; 1774 if ((!blk->path) || (!blk->link)) return;
1775 blk->obj = edje_object_add(evas_object_evas_get(obj)); 1775 blk->obj = edje_object_add(evas_object_evas_get(obj));
1776 if (blk->path[0] == '/') 1776 if (blk->path[0] == '/')
1777 ok = edje_object_file_set(blk->obj, blk->path, blk->link); 1777 {
1778 ok = edje_object_file_set(blk->obj, blk->path, blk->link);
1779 }
1778 else if (!strcmp(blk->path, "THEME")) 1780 else if (!strcmp(blk->path, "THEME"))
1779 ok = edje_object_file_set(blk->obj, 1781 {
1780 config_theme_path_default_get 1782 ok = edje_object_file_set(blk->obj,
1781 (sd->config), 1783 config_theme_path_default_get
1782 blk->link); 1784 (sd->config),
1785 blk->link);
1786 }
1783 else 1787 else
1784 { 1788 {
1785 char path[PATH_MAX], home[PATH_MAX]; 1789 char path[PATH_MAX], home[PATH_MAX];
@@ -1806,6 +1810,10 @@ _block_edje_activate(Evas_Object *obj, Termblock *blk)
1806 { 1810 {
1807 _block_edje_cmds(sd->pty, blk, blk->cmds, EINA_TRUE); 1811 _block_edje_cmds(sd->pty, blk, blk->cmds, EINA_TRUE);
1808 } 1812 }
1813 else
1814 {
1815 ERR("failed to activate textblock of id %d", blk->id);
1816 }
1809} 1817}
1810 1818
1811static void 1819static void
@@ -1817,38 +1825,52 @@ _block_media_activate(Evas_Object *obj, Termblock *blk)
1817 Evas_Object *mctrl; 1825 Evas_Object *mctrl;
1818 1826
1819 EINA_SAFETY_ON_NULL_RETURN(sd); 1827 EINA_SAFETY_ON_NULL_RETURN(sd);
1820 if (blk->scale_stretch) media = MEDIA_STRETCH; 1828
1821 else if (blk->scale_center) media = MEDIA_POP; 1829 if (blk->scale_stretch)
1822 else if (blk->scale_fill) media = MEDIA_BG; 1830 media = MEDIA_STRETCH;
1823 else if (blk->thumb) media = MEDIA_THUMB; 1831 else if (blk->scale_center)
1824// media = MEDIA_POP; 1832 media = MEDIA_POP;
1833 else if (blk->scale_fill)
1834 media = MEDIA_BG;
1835 else if (blk->thumb)
1836 media = MEDIA_THUMB;
1837
1825 if (!blk->was_active_before || blk->mov_state == MOVIE_STATE_STOP) 1838 if (!blk->was_active_before || blk->mov_state == MOVIE_STATE_STOP)
1826 media |= MEDIA_SAVE; 1839 media |= MEDIA_SAVE;
1827 else 1840 else
1828 media |= MEDIA_RECOVER | MEDIA_SAVE; 1841 media |= MEDIA_RECOVER | MEDIA_SAVE;
1842
1829 type = media_src_type_get(blk->path); 1843 type = media_src_type_get(blk->path);
1830 blk->obj = media_add(obj, blk->path, sd->config, media, type); 1844 blk->obj = media_add(obj, blk->path, sd->config, media, type);
1845
1831 if (type == MEDIA_TYPE_MOV) 1846 if (type == MEDIA_TYPE_MOV)
1832 media_play_set(blk->obj, blk->mov_state == MOVIE_STATE_PLAY); 1847 media_play_set(blk->obj, blk->mov_state == MOVIE_STATE_PLAY);
1848
1833 evas_object_event_callback_add 1849 evas_object_event_callback_add
1834 (blk->obj, EVAS_CALLBACK_DEL, _smart_media_del, blk); 1850 (blk->obj, EVAS_CALLBACK_DEL, _smart_media_del, blk);
1835 evas_object_smart_callback_add(blk->obj, "play", _smart_media_play, blk); 1851 evas_object_smart_callback_add(blk->obj, "play", _smart_media_play, blk);
1836 evas_object_smart_callback_add(blk->obj, "pause", _smart_media_pause, blk); 1852 evas_object_smart_callback_add(blk->obj, "pause", _smart_media_pause, blk);
1837 evas_object_smart_callback_add(blk->obj, "stop", _smart_media_stop, blk); 1853 evas_object_smart_callback_add(blk->obj, "stop", _smart_media_stop, blk);
1854
1838 blk->type = type; 1855 blk->type = type;
1839 evas_object_smart_member_add(blk->obj, obj); 1856 evas_object_smart_member_add(blk->obj, obj);
1857
1840 mctrl = media_control_get(blk->obj); 1858 mctrl = media_control_get(blk->obj);
1841 if (mctrl) 1859 if (mctrl)
1842 { 1860 {
1843 evas_object_smart_member_add(mctrl, obj); 1861 evas_object_smart_member_add(mctrl, obj);
1844 evas_object_stack_above(mctrl, sd->event); 1862 evas_object_stack_above(mctrl, sd->event);
1845 } 1863 }
1864
1846 evas_object_stack_above(blk->obj, sd->grid.obj); 1865 evas_object_stack_above(blk->obj, sd->grid.obj);
1847 evas_object_show(blk->obj); 1866 evas_object_show(blk->obj);
1848 evas_object_data_set(blk->obj, "blk", blk); 1867 evas_object_data_set(blk->obj, "blk", blk);
1868
1849 if (blk->thumb) 1869 if (blk->thumb)
1850 evas_object_smart_callback_add 1870 {
1851 (blk->obj, "clicked", _smart_media_clicked, obj); 1871 evas_object_smart_callback_add(blk->obj, "clicked",
1872 _smart_media_clicked, obj);
1873 }
1852} 1874}
1853 1875
1854static void 1876static void
@@ -1857,11 +1879,17 @@ _block_activate(Evas_Object *obj, Termblock *blk)
1857 Termio *sd = evas_object_smart_data_get(obj); 1879 Termio *sd = evas_object_smart_data_get(obj);
1858 1880
1859 EINA_SAFETY_ON_NULL_RETURN(sd); 1881 EINA_SAFETY_ON_NULL_RETURN(sd);
1860 if (blk->active) return; 1882
1883 if (blk->active)
1884 return;
1861 blk->active = EINA_TRUE; 1885 blk->active = EINA_TRUE;
1862 if (blk->obj) return; 1886 if (blk->obj)
1863 if (blk->edje) _block_edje_activate(obj, blk); 1887 return;
1864 else _block_media_activate(obj, blk); 1888 if (blk->edje)
1889 _block_edje_activate(obj, blk);
1890 else
1891 _block_media_activate(obj, blk);
1892
1865 blk->was_active_before = EINA_TRUE; 1893 blk->was_active_before = EINA_TRUE;
1866 if (!blk->was_active) 1894 if (!blk->was_active)
1867 sd->pty->block.active = eina_list_append(sd->pty->block.active, blk); 1895 sd->pty->block.active = eina_list_append(sd->pty->block.active, blk);