2009-12-05 17:22:54 -08:00
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_Check
|
|
|
|
{
|
|
|
|
Elm_Params base;
|
2010-10-21 15:03:43 -07:00
|
|
|
const char *label;
|
2009-12-05 17:22:54 -08:00
|
|
|
Evas_Object *icon;
|
2010-03-25 13:17:34 -07:00
|
|
|
Eina_Bool state:1;
|
|
|
|
Eina_Bool state_exists:1;
|
2009-12-05 17:22:54 -08:00
|
|
|
} Elm_Params_Check;
|
|
|
|
|
|
|
|
static void
|
2014-01-23 03:08:10 -08:00
|
|
|
external_check_state_set(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
const void *from_params, const void *to_params,
|
|
|
|
float pos EINA_UNUSED)
|
2009-12-05 17:22:54 -08:00
|
|
|
{
|
2010-03-25 13:17:34 -07:00
|
|
|
const Elm_Params_Check *p;
|
|
|
|
|
|
|
|
if (to_params) p = to_params;
|
|
|
|
else if (from_params) p = from_params;
|
|
|
|
else return;
|
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
if (p->label)
|
2011-07-04 03:13:50 -07:00
|
|
|
elm_object_text_set(obj, p->label);
|
2010-03-25 13:17:34 -07:00
|
|
|
if (p->icon)
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(obj, "icon", p->icon);
|
2010-03-25 13:17:34 -07:00
|
|
|
if (p->state_exists)
|
|
|
|
elm_check_state_set(obj, p->state);
|
2009-12-05 17:22:54 -08:00
|
|
|
}
|
|
|
|
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
static Eina_Bool
|
2014-01-23 03:08:10 -08:00
|
|
|
external_check_param_set(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
const Edje_External_Param *param)
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "label"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
elm_object_text_set(obj, param->s);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
Evas_Object *icon = external_common_param_icon_get(obj, param);
|
|
|
|
if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
|
|
|
|
elm_object_part_content_set(obj, "icon", icon);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "state"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_check_state_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07: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-23 03:08:10 -08:00
|
|
|
external_check_param_get(void *data EINA_UNUSED, const Evas_Object *obj,
|
|
|
|
Edje_External_Param *param)
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "label"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
param->s = elm_object_text_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
/* not easy to get icon name back from live object */
|
|
|
|
return EINA_FALSE;
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "state"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_check_state_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
static void *
|
2014-01-23 03:08:10 -08:00
|
|
|
external_check_params_parse(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
const Eina_List *params)
|
2009-12-05 17:22:54 -08:00
|
|
|
{
|
|
|
|
Elm_Params_Check *mem;
|
|
|
|
Edje_External_Param *param;
|
2010-10-21 15:03:43 -07:00
|
|
|
const Eina_List *l;
|
2009-12-05 17:22:54 -08:00
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
mem = calloc(1, sizeof(Elm_Params_Check));
|
2009-12-05 17:22:54 -08:00
|
|
|
if (!mem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
external_common_icon_param_parse(&mem->icon, obj, params);
|
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
2010-03-25 13:17:34 -07:00
|
|
|
{
|
2010-10-21 15:03:43 -07:00
|
|
|
if (!strcmp(param->name, "state"))
|
|
|
|
{
|
|
|
|
mem->state = !!param->i;
|
|
|
|
mem->state_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "label"))
|
2014-01-23 03:08:10 -08:00
|
|
|
mem->label = eina_stringshare_add(param->s);
|
2010-03-25 13:17:34 -07:00
|
|
|
}
|
2009-12-07 20:57:39 -08:00
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2014-01-06 06:30:02 -08:00
|
|
|
static Evas_Object *external_check_content_get(void *data EINA_UNUSED,
|
2014-01-23 03:08:10 -08:00
|
|
|
const Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *content EINA_UNUSED)
|
2010-08-01 10:29:20 -07:00
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
ERR("No content.");
|
|
|
|
return NULL;
|
2010-08-01 10:29:20 -07:00
|
|
|
}
|
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
static void
|
|
|
|
external_check_params_free(void *params)
|
|
|
|
{
|
2010-10-21 15:03:43 -07:00
|
|
|
Elm_Params_Check *mem = params;
|
|
|
|
if (mem->label)
|
2014-01-23 03:08:10 -08:00
|
|
|
eina_stringshare_del(mem->label);
|
2010-10-21 15:03:43 -07:00
|
|
|
free(params);
|
2009-12-05 17:22:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Edje_External_Param_Info external_check_params[] = {
|
2014-01-23 03:08:10 -08:00
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL("state", 0, "unchecked", "checked"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
2009-12-05 17:22:54 -08:00
|
|
|
};
|
|
|
|
|
2014-01-23 03:08:10 -08:00
|
|
|
DEFINE_EXTERNAL_ICON_ADD(check, "check");
|
|
|
|
DEFINE_EXTERNAL_TYPE_SIMPLE(check, "Check");
|