1. add the ability to have a link AND image path in inline images and

thumbs (allows for different thumbnail compared to what it links to).
2. fix if media obj is deleted on its own (stop button).
This commit is contained in:
Carsten Haitzler 2013-03-11 16:56:07 +09:00
parent 01bf2409bd
commit 735d93fbc4
3 changed files with 40 additions and 4 deletions

View File

@ -548,6 +548,20 @@ _smart_media_clicked(void *data, Evas_Object *obj, void *info __UNUSED__)
evas_object_smart_callback_call(data, "popup", (void *)file);
}
static void
_smart_media_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *info __UNUSED__)
{
Termblock *blk = data;
if (blk->obj == obj)
{
evas_object_event_callback_del_full
(blk->obj, EVAS_CALLBACK_DEL,
_smart_media_del, blk);
blk->obj = NULL;
}
}
static void
_smart_apply(Evas_Object *obj)
{
@ -639,6 +653,9 @@ _smart_apply(Evas_Object *obj)
blk->obj = media_add(obj, blk->path,
sd->config,
media, &type);
evas_object_event_callback_add
(blk->obj, EVAS_CALLBACK_DEL,
_smart_media_del, blk);
blk->type = type;
evas_object_smart_member_add(blk->obj, obj);
evas_object_stack_above(blk->obj, sd->grid.obj);
@ -785,6 +802,9 @@ _smart_apply(Evas_Object *obj)
blk->was_active = EINA_FALSE;
if (blk->obj)
{
evas_object_event_callback_del_full
(blk->obj, EVAS_CALLBACK_DEL,
_smart_media_del, blk);
evas_object_del(blk->obj);
blk->obj = NULL;
}
@ -2889,9 +2909,13 @@ _smart_pty_command(void *data)
// HH (decimal) in CELLS.
//
// isCWW;HH;PATH
// OR
// isCWW;HH;LINK\nPATH
repch = sd->pty->cur_cmd[2];
if (repch)
{
char *link = NULL;
for (p0 = p = &(sd->pty->cur_cmd[3]); *p; p++)
{
if (*p == ';')
@ -2911,9 +2935,18 @@ _smart_pty_command(void *data)
}
}
path = p;
p = strchr(path, '\n');
if (p)
{
link = strdup(path);
link[p - path] = 0;
path = p + 1;
}
if ((ww < 512) && (hh < 512))
{
Termblock *blk = termpty_block_new(sd->pty, ww, hh, path);
Termblock *blk;
blk = termpty_block_new(sd->pty, ww, hh, path, link);
if (blk)
{
if (sd->pty->cur_cmd[1] == 's')
@ -2927,6 +2960,7 @@ _smart_pty_command(void *data)
termpty_block_insert(sd->pty, repch, blk);
}
}
if (link) free(link);
}
return;
}

View File

@ -563,12 +563,13 @@ void
termpty_block_free(Termblock *tb)
{
if (tb->path) eina_stringshare_del(tb->path);
if (tb->link) eina_stringshare_del(tb->link);
if (tb->obj) evas_object_del(tb->obj);
free(tb);
}
Termblock *
termpty_block_new(Termpty *ty, int w, int h, const char *path)
termpty_block_new(Termpty *ty, int w, int h, const char *path, const char *link)
{
Termblock *tb;
int id;
@ -590,6 +591,7 @@ termpty_block_new(Termpty *ty, int w, int h, const char *path)
tb->w = w;
tb->h = h;
tb->path = eina_stringshare_add(path);
if (link) tb->link = eina_stringshare_add(link);
eina_hash_add(ty->block.blocks, &id, tb);
ty->block.curid++;
if (ty->block.curid >= 8192) ty->block.curid = 0;

View File

@ -144,7 +144,7 @@ struct _Termblock
int refs;
short w, h;
short x, y;
const char *path;
const char *path, *link;
Evas_Object *obj;
Eina_Bool scale_stretch : 1;
Eina_Bool scale_center : 1;
@ -174,7 +174,7 @@ void termpty_backscroll_set(Termpty *ty, int size);
pid_t termpty_pid_get(const Termpty *ty);
void termpty_block_free(Termblock *tb);
Termblock *termpty_block_new(Termpty *ty, int w, int h, const char *path);
Termblock *termpty_block_new(Termpty *ty, int w, int h, const char *path, const char *link);
void termpty_block_insert(Termpty *ty, int ch, Termblock *blk);
int termpty_block_id_get(Termcell *cell, int *x, int *y);
Termblock *termpty_block_get(Termpty *ty, int id);