express: Fix support for gravatar showing 'busy' image while downloading
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
2578ce12d9
commit
cc02bfdd79
|
@ -1,7 +1,7 @@
|
|||
#include "private.h"
|
||||
#include "gravatar.h"
|
||||
#include "theme.h"
|
||||
//#include "config.h"
|
||||
#include "media.h"
|
||||
#include "md5/md5.h"
|
||||
|
||||
/* specific log domain to help debug the gravatar module */
|
||||
|
@ -22,104 +22,32 @@ int _gravatar_log_dom = -1;
|
|||
#define GRAVATAR_URL_START "http://www.gravatar.com/avatar/"
|
||||
#define GRAVATAR_URL_END ""
|
||||
|
||||
static Evas_Object *_img_obj;
|
||||
static const char *_img_file;
|
||||
static Evas_Object *o;
|
||||
|
||||
typedef struct _Gravatar
|
||||
{
|
||||
const char *url;
|
||||
int tmpfd;
|
||||
} Gravatar;
|
||||
|
||||
static Eina_Bool
|
||||
_url_compl_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Ecore_Con_Event_Url_Complete *ev = event_info;
|
||||
// Evas_Object *o = evas_object_smart_member_get(ev->url_con);
|
||||
|
||||
edje_object_signal_emit(o, "done", "express");
|
||||
evas_object_smart_member_del(o);
|
||||
elm_image_file_set(_img_obj, _img_file, NULL);
|
||||
evas_object_show(_img_obj);
|
||||
ecore_con_url_free(ev->url_con);
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
media_add(Evas_Object *obj, Gravatar *g)
|
||||
{
|
||||
int tmpfd;
|
||||
Ecore_Con_Url *url;
|
||||
|
||||
tmpfd = eina_file_mkstemp("expressXXXXXX.png", &_img_file);
|
||||
|
||||
g->tmpfd = tmpfd;
|
||||
|
||||
if (tmpfd >= 0)
|
||||
{
|
||||
if (!(url = ecore_con_url_new(g->url)))
|
||||
{
|
||||
unlink(_img_file);
|
||||
eina_tmpstr_del(_img_file);
|
||||
close(tmpfd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecore_con_url_fd_set(url, tmpfd);
|
||||
if (!ecore_con_url_get(url))
|
||||
{
|
||||
unlink(_img_file);
|
||||
eina_tmpstr_del(_img_file);
|
||||
close(tmpfd);
|
||||
ecore_con_url_free(url);
|
||||
url = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
o = edje_object_add(evas_object_evas_get(obj));
|
||||
evas_object_smart_member_add(o, obj);
|
||||
_theme_apply(o, PACKAGE_NAME"/mediabusy");
|
||||
evas_object_show(o);
|
||||
edje_object_signal_emit(o, "busy", "express");
|
||||
ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE,
|
||||
_url_compl_cb, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _img_obj;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_tooltip_content(void *data, Evas_Object *obj EINA_UNUSED, Evas_Object *tt)
|
||||
_tooltip_content(void *data, Evas_Object *obj, Evas_Object *tt EINA_UNUSED)
|
||||
{
|
||||
Gravatar *g = data;
|
||||
Gravatar *g;
|
||||
Evas_Object *o;
|
||||
|
||||
if (!(_img_obj = elm_image_add(tt)))
|
||||
{
|
||||
ERR("Could not add a image object.\n");
|
||||
return NULL;
|
||||
}
|
||||
_img_obj = media_add(tt , g);
|
||||
evas_object_size_hint_min_set(_img_obj, 80, 80);
|
||||
g = data;
|
||||
o = _media_add(obj, g->url, MEDIA_STRETCH, MEDIA_TYPE_IMG);
|
||||
evas_object_size_hint_min_set(o, 80, 80);
|
||||
|
||||
return _img_obj;
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_tooltip_del(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Gravatar *g = data;
|
||||
Gravatar *g;
|
||||
|
||||
close(g->tmpfd);
|
||||
g = data;
|
||||
eina_stringshare_del(g->url);
|
||||
free(g);
|
||||
|
||||
unlink(_img_file);
|
||||
eina_tmpstr_del(_img_file);
|
||||
evas_object_del(_img_obj);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -130,7 +58,6 @@ gravatar_tooltip(Evas_Object *obj, char *email)
|
|||
char md5out[(2 * MD5_HASHBYTES) + 1];
|
||||
unsigned char hash[MD5_HASHBYTES];
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
const char *url;
|
||||
Gravatar *g;
|
||||
|
||||
g = calloc(sizeof(Gravatar), 1);
|
||||
|
@ -149,10 +76,8 @@ gravatar_tooltip(Evas_Object *obj, char *email)
|
|||
}
|
||||
md5out[2 * MD5_HASHBYTES] = '\0';
|
||||
|
||||
url = eina_stringshare_printf(GRAVATAR_URL_START"%s"GRAVATAR_URL_END,
|
||||
md5out);
|
||||
|
||||
g->url = url;
|
||||
g->url =
|
||||
eina_stringshare_printf(GRAVATAR_URL_START"%s"GRAVATAR_URL_END, md5out);
|
||||
|
||||
elm_object_tooltip_content_cb_set(obj, _tooltip_content, g, _tooltip_del);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue