2011-10-10 19:06:21 -07:00
|
|
|
#include <assert.h>
|
2010-11-10 14:48:36 -08:00
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_Icon
|
|
|
|
{
|
2011-10-10 19:06:21 -07:00
|
|
|
const char *file;
|
|
|
|
Eina_Bool scale_up_exists;
|
|
|
|
Eina_Bool scale_up : 1;
|
|
|
|
Eina_Bool scale_down_exists;
|
|
|
|
Eina_Bool scale_down : 1;
|
|
|
|
Eina_Bool smooth_exists;
|
|
|
|
Eina_Bool smooth : 1;
|
|
|
|
Eina_Bool fill_outside_exists;
|
|
|
|
Eina_Bool fill_outside : 1;
|
|
|
|
Eina_Bool no_scale_exists;
|
|
|
|
Eina_Bool no_scale : 1;
|
|
|
|
Eina_Bool prescale_size_exists;
|
|
|
|
int prescale_size;
|
2010-11-10 14:48:36 -08:00
|
|
|
Elm_Params base;
|
|
|
|
const char *icon;
|
|
|
|
} Elm_Params_Icon;
|
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
|
2010-11-10 14:48:36 -08:00
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
external_icon_state_set(void *data EINA_UNUSED, Evas_Object *obj,
|
2011-10-10 19:06:21 -07:00
|
|
|
const void *from_params, const void *to_params,
|
2014-01-06 06:30:02 -08:00
|
|
|
float pos EINA_UNUSED)
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
|
|
|
const Elm_Params_Icon *p;
|
|
|
|
Evas_Object *edje;
|
|
|
|
const char *file;
|
2016-06-26 10:42:21 -07:00
|
|
|
Eina_Bool param;
|
2010-11-10 14:48:36 -08:00
|
|
|
|
|
|
|
if (to_params) p = to_params;
|
|
|
|
else if (from_params) p = from_params;
|
|
|
|
else return;
|
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
if (p->file)
|
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_file_set(obj, p->file, NULL);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
if (p->smooth_exists)
|
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_smooth_set(obj, p->smooth);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
if (p->no_scale_exists)
|
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_no_scale_set(obj, p->no_scale);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
if (p->scale_up_exists && p->scale_down_exists)
|
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_resizable_set(obj, p->scale_up, p->scale_down);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (p->scale_up_exists || p->scale_down_exists)
|
|
|
|
{
|
2012-03-02 01:00:52 -08:00
|
|
|
if (p->scale_up_exists)
|
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, NULL, ¶m);
|
|
|
|
elm_image_resizable_set(obj, p->scale_up, param);
|
2012-03-02 01:00:52 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, ¶m, NULL);
|
|
|
|
elm_image_resizable_set(obj, param, p->scale_down);
|
2012-03-02 01:00:52 -08:00
|
|
|
}
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
if (p->fill_outside_exists)
|
|
|
|
{
|
2012-06-28 11:40:35 -07:00
|
|
|
elm_image_fill_outside_set(obj, p->fill_outside);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
if (p->prescale_size_exists)
|
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_prescale_set(obj, p->prescale_size);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
2010-11-10 14:48:36 -08:00
|
|
|
if (p->icon)
|
2011-07-06 06:24:35 -07:00
|
|
|
{
|
|
|
|
edje = evas_object_smart_parent_get(obj);
|
|
|
|
edje_object_file_get(edje, &file, NULL);
|
2010-11-10 14:48:36 -08:00
|
|
|
|
2015-06-17 05:53:37 -07:00
|
|
|
if (!edje_file_group_exists(file, p->icon))
|
|
|
|
{
|
|
|
|
if (!elm_icon_standard_set(obj, p->icon))
|
|
|
|
ERR("Failed to set standard icon! (%s)", p->icon);
|
|
|
|
}
|
|
|
|
else if (!elm_image_file_set(obj, file, p->icon))
|
|
|
|
{
|
|
|
|
if (!elm_icon_standard_set(obj, p->icon))
|
|
|
|
ERR("Failed to set standard icon! (%s)", p->icon);
|
|
|
|
}
|
2011-07-06 06:24:35 -07:00
|
|
|
}
|
2010-11-10 14:48:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_icon_param_set(void *data EINA_UNUSED, Evas_Object *obj,
|
2011-10-10 19:06:21 -07:00
|
|
|
const Edje_External_Param *param)
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
|
|
|
Evas_Object *edje;
|
|
|
|
const char *file;
|
2016-06-26 10:42:21 -07:00
|
|
|
Eina_Bool p;
|
2010-11-10 14:48:36 -08:00
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
if (!strcmp(param->name, "file")
|
2014-01-23 03:08:10 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
return elm_image_file_set(obj, param->s, NULL);
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "smooth")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_smooth_set(obj, param->i);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "no scale")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_no_scale_set(obj, param->i);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale up")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, NULL, &p);
|
|
|
|
elm_image_resizable_set(obj, param->i, p);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale down")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, &p, NULL);
|
|
|
|
elm_image_resizable_set(obj, p, param->i);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "fill outside")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2012-06-28 11:40:35 -07:00
|
|
|
elm_image_fill_outside_set(obj, param->i);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "prescale")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_prescale_set(obj, param->i);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
2011-07-06 06:24:35 -07:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
edje = evas_object_smart_parent_get(obj);
|
|
|
|
edje_object_file_get(edje, &file, NULL);
|
|
|
|
|
2015-06-17 05:53:37 -07:00
|
|
|
if (!edje_file_group_exists(file, param->s))
|
|
|
|
{
|
|
|
|
if (!elm_icon_standard_set(obj, param->s))
|
|
|
|
ERR("Failed to set standard icon! (%s)", param->s);
|
|
|
|
}
|
|
|
|
else if (!elm_image_file_set(obj, file, param->s))
|
|
|
|
{
|
|
|
|
if (!elm_icon_standard_set(obj, param->s))
|
|
|
|
ERR("Failed to set standard icon as fallback! (%s)", param->s);
|
|
|
|
}
|
2011-07-06 06:24:35 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-11-10 14:48:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_icon_param_get(void *data EINA_UNUSED,
|
2016-06-26 10:42:21 -07:00
|
|
|
const Evas_Object *obj,
|
2011-10-10 19:06:21 -07:00
|
|
|
Edje_External_Param *param)
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
if (!strcmp(param->name, "file")
|
2014-01-23 03:08:10 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_file_get(obj, ¶m->s, NULL);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "smooth")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
param->i = elm_image_smooth_get(obj);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "no scale")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
param->i = elm_image_no_scale_get(obj);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale up")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, NULL, (Eina_Bool *)(¶m->i));
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale down")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
elm_image_resizable_get(obj, (Eina_Bool *)(¶m->i), NULL);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "fill outside")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
param->i = elm_image_fill_outside_get(obj);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "prescale")
|
2012-03-02 01:00:52 -08:00
|
|
|
&& param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
|
2011-10-10 19:06:21 -07:00
|
|
|
{
|
2016-06-26 10:42:21 -07:00
|
|
|
param->i = elm_image_prescale_get(obj);
|
2012-03-02 01:00:52 -08:00
|
|
|
return EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
2011-07-06 06:24:35 -07:00
|
|
|
/* not easy to get icon name back from live object */
|
|
|
|
return EINA_FALSE;
|
2010-11-10 14:48:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2014-01-06 06:30:02 -08:00
|
|
|
external_icon_params_parse(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
2011-10-10 19:06:21 -07:00
|
|
|
const Eina_List *params)
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
|
|
|
Elm_Params_Icon *mem;
|
|
|
|
Edje_External_Param *param;
|
|
|
|
const Eina_List *l;
|
2010-11-22 04:46:58 -08:00
|
|
|
mem = ELM_NEW(Elm_Params_Icon);
|
2016-06-26 10:42:21 -07:00
|
|
|
if (EINA_UNLIKELY(!mem))
|
2010-11-10 14:48:36 -08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
2011-07-06 06:24:35 -07:00
|
|
|
{
|
2011-10-10 19:06:21 -07:00
|
|
|
if (!strcmp(param->name, "file"))
|
2012-03-02 01:00:52 -08:00
|
|
|
mem->file = eina_stringshare_add(param->s);
|
|
|
|
else if (!strcmp(param->name, "smooth"))
|
|
|
|
{
|
|
|
|
mem->smooth = param->i;
|
|
|
|
mem->smooth_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "no scale"))
|
|
|
|
{
|
|
|
|
mem->no_scale = param->i;
|
|
|
|
mem->no_scale_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale up"))
|
|
|
|
{
|
|
|
|
mem->scale_up = param->i;
|
|
|
|
mem->scale_up_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "scale down"))
|
|
|
|
{
|
|
|
|
mem->scale_down = param->i;
|
|
|
|
mem->scale_down_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "fill outside"))
|
|
|
|
{
|
|
|
|
mem->fill_outside = param->i;
|
|
|
|
mem->fill_outside_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "prescale"))
|
|
|
|
{
|
|
|
|
mem->prescale_size = param->i;
|
|
|
|
mem->prescale_size_exists = EINA_TRUE;
|
2011-10-10 19:06:21 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
2011-07-06 06:24:35 -07:00
|
|
|
{
|
|
|
|
mem->icon = eina_stringshare_add(param->s);
|
|
|
|
}
|
|
|
|
}
|
2010-11-10 14:48:36 -08:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
static Evas_Object *
|
2014-01-06 06:30:02 -08:00
|
|
|
external_icon_content_get(void *data EINA_UNUSED,
|
|
|
|
const Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *content EINA_UNUSED)
|
2010-11-10 14:48:36 -08:00
|
|
|
{
|
2011-07-06 06:24:35 -07:00
|
|
|
ERR("no content");
|
|
|
|
return NULL;
|
2010-11-10 14:48:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
external_icon_params_free(void *params)
|
|
|
|
{
|
|
|
|
Elm_Params_Icon *mem = params;
|
|
|
|
|
2011-10-10 19:06:21 -07:00
|
|
|
if (mem->file)
|
|
|
|
eina_stringshare_del(mem->file);
|
|
|
|
|
2010-11-10 14:48:36 -08:00
|
|
|
if (mem->icon)
|
2011-07-06 06:24:35 -07:00
|
|
|
eina_stringshare_del(mem->icon);
|
2011-10-10 19:06:21 -07:00
|
|
|
free(mem);
|
2010-11-10 14:48:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Edje_External_Param_Info external_icon_params[] = {
|
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
|
2011-10-10 19:06:21 -07:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("smooth"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("no scale"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("scale up"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("scale down"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("fill outside"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_INT("prescale"),
|
2010-11-10 14:48:36 -08:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_EXTERNAL_ICON_ADD(icon, "icon");
|
|
|
|
DEFINE_EXTERNAL_TYPE_SIMPLE(icon, "Icon");
|