+elm_icon_memfile_set

SVN revision: 61603
This commit is contained in:
Mike Blumenkrantz 2011-07-22 23:03:46 +00:00
parent 1a992059fd
commit ad1d676d1c
4 changed files with 71 additions and 3 deletions

View File

@ -1955,6 +1955,23 @@ extern "C" {
* @ingroup Icon
*/
EAPI Eina_Bool elm_icon_file_set(Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1, 2);
/**
* Set a location in memory to be used as an icon
*
* @param obj The icon object
* @param img The binary data that will be used as an image
* @param size The size of binary data @p img
* @param format Optional format of @p img to pass to the image loader
* @param key Optional key of @p img to pass to the image loader (eg. if @p img is an edje file)
*
* @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
*
* @note The icon image set by this function can be changed by
* elm_icon_standard_set().
*
* @ingroup Icon
*/
EAPI Eina_Bool elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key); EINA_ARG_NONNULL(1, 2);
/**
* Get the file that will be used as icon.
*

View File

@ -471,6 +471,23 @@ elm_icon_add(Evas_Object *parent)
return obj;
}
EAPI Eina_Bool
elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
Eina_Bool ret;
if (!wd) return EINA_FALSE;
EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL(!size, EINA_FALSE);
eina_stringshare_del(wd->stdicon);
wd->stdicon = NULL;
ret = _els_smart_icon_memfile_set(wd->img, img, size, format, key);
_sizing_eval(obj);
return ret;
}
EAPI Eina_Bool
elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
{

View File

@ -65,14 +65,13 @@ _preloaded(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSE
sd->prev = NULL;
}
Eina_Bool
_els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
static void
_els_smart_icon_file_helper(Evas_Object *obj)
{
Smart_Data *sd;
Evas_Object *pclip;
sd = evas_object_smart_data_get(obj);
if (!sd) return EINA_FALSE;
/* smart code here */
if (sd->prev) evas_object_del(sd->prev);
pclip = evas_object_clip_get(sd->obj);
@ -89,6 +88,40 @@ _els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key
if (!sd->size)
evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
}
Eina_Bool
_els_smart_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return EINA_FALSE;
_els_smart_icon_file_helper(obj);
evas_object_image_memfile_set(sd->obj, (void*)img, size, (char*)format, (char*)key);
sd->preloading = EINA_TRUE;
sd->show = EINA_TRUE;
evas_object_hide(sd->obj);
evas_object_image_preload(sd->obj, EINA_FALSE);
if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
{
ERR("Things are going bad for some random %zu byte chunk of memory (%p)", size, sd->obj);
return EINA_FALSE;
}
_smart_reconfigure(sd);
return EINA_TRUE;
}
Eina_Bool
_els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return EINA_FALSE;
_els_smart_icon_file_helper(obj);
evas_object_image_file_set(sd->obj, file, key);
sd->preloading = EINA_TRUE;
sd->show = EINA_TRUE;

View File

@ -1,4 +1,5 @@
Evas_Object *_els_smart_icon_add (Evas *evas);
Eina_Bool _els_smart_icon_memfile_set (Evas_Object *obj, const void *file, size_t size, const char *format, const char *key);
Eina_Bool _els_smart_icon_file_key_set (Evas_Object *obj, const char *file, const char *key);
Eina_Bool _els_smart_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part);
void _els_smart_icon_file_get (const Evas_Object *obj, const char **file, const char **key);