elm external: fix elm_label
[framework/uifw/elementary.git] / src / edje_externals / elm_label.c
1 #include "private.h"
2
3 typedef struct _Elm_Params_Label
4 {
5    const char* label;
6 } Elm_Params_Label;
7
8 static void
9 external_label_state_set(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const void *from_params, const void *to_params, float pos __UNUSED__)
10 {
11    const Elm_Params_Label *p;
12
13    if (to_params) p = to_params;
14    else if (from_params) p = from_params;
15    else return;
16
17    if (p->label) elm_label_label_set(obj, p->label);
18 }
19
20 static Eina_Bool
21 external_label_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
22 {
23    if (!strcmp(param->name, "label"))
24      {
25         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
26           {
27              elm_label_label_set(obj, param->s);
28              return EINA_TRUE;
29           }
30      }
31
32    ERR("unknown parameter '%s' of type '%s'",
33        param->name, edje_external_param_type_str(param->type));
34
35    return EINA_FALSE;
36 }
37
38 static Eina_Bool
39 external_label_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
40 {
41    if (!strcmp(param->name, "label"))
42      {
43         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
44           {
45              param->s = elm_label_label_get(obj);
46              return EINA_TRUE;
47           }
48      }
49
50    ERR("unknown parameter '%s' of type '%s'",
51        param->name, edje_external_param_type_str(param->type));
52
53    return EINA_FALSE;
54 }
55
56 static void *
57 external_label_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params __UNUSED__)
58 {
59    Elm_Params_Label *mem;
60    Edje_External_Param *param;
61    const Eina_List *l;
62
63    mem = ELM_NEW(Elm_Params_Label);
64    if (!mem)
65      return NULL;
66
67    EINA_LIST_FOREACH(params, l, param)
68      {
69         if (!strcmp(param->name, "label"))
70            mem->label = eina_stringshare_add(param->s);
71      }
72
73    return mem;
74 }
75
76 static Evas_Object *external_label_content_get(void *data __UNUSED__,
77                 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
78 {
79         ERR("no content");
80         return NULL;
81 }
82
83 static void
84 external_label_params_free(void *params)
85 {
86    external_common_params_free(params);
87 }
88
89 static Edje_External_Param_Info external_label_params[] = {
90    DEFINE_EXTERNAL_COMMON_PARAMS,
91    EDJE_EXTERNAL_PARAM_INFO_SENTINEL
92 };
93
94 DEFINE_EXTERNAL_ICON_ADD(label, "label");
95 DEFINE_EXTERNAL_TYPE_SIMPLE(label, "label");