raster pushed a commit to branch master.

commit 735d93fbc4f60375794846bb21e0fef3d39fc3ff
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Mon Mar 11 16:56:07 2013 +0900

    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).
---
 src/bin/termio.c  | 36 +++++++++++++++++++++++++++++++++++-
 src/bin/termpty.c |  4 +++-
 src/bin/termpty.h |  4 ++--
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index dbc6ef2..9457abd 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -549,6 +549,20 @@ _smart_media_clicked(void *data, Evas_Object *obj, void 
*info __UNUSED__)
 }
 
 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)
 {
    Termio *sd = evas_object_smart_data_get(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;
           }
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 802a841..af4c436 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -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;
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 6c73fa1..9510d61 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -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);

-- 

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev

Reply via email to