Merge "[Copy&Paste] remove "Paste" button when CBHM has no item"
[framework/uifw/elementary.git] / src / edje_externals / elm_toolbar.c
1 #include "private.h"
2
3 typedef struct _Elm_Params_Toolbar
4 {
5    Elm_Params base;
6    int icon_size;
7    Eina_Bool icon_size_exists:1;
8    double align;
9    Eina_Bool align_exists:1;
10 } Elm_Params_Toolbar;
11
12 static void
13 external_toolbar_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
14 {
15    const Elm_Params_Toolbar *p;
16
17    if (to_params) p = to_params;
18    else if (from_params) p = from_params;
19    else return;
20
21    if (p->icon_size_exists)
22      elm_toolbar_icon_size_set(obj, p->icon_size);
23    if (p->align_exists)
24      elm_toolbar_align_set(obj, p->align);
25 }
26
27 static Eina_Bool
28 external_toolbar_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
29 {
30    if (!strcmp(param->name, "icon_size"))
31      {
32         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
33           {
34              elm_toolbar_icon_size_set(obj, param->i);
35              return EINA_TRUE;
36           }
37      }
38    else if (!strcmp(param->name, "align"))
39      {
40         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
41           {
42              elm_toolbar_align_set(obj, param->d);
43              return EINA_TRUE;
44           }
45      }
46
47    ERR("unknown parameter '%s' of type '%s'",
48        param->name, edje_external_param_type_str(param->type));
49
50    return EINA_FALSE;
51 }
52
53 static Eina_Bool
54 external_toolbar_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
55 {
56    if (!strcmp(param->name, "icon_size"))
57      {
58         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
59           {
60              param->i = elm_toolbar_icon_size_get(obj);
61              return EINA_TRUE;
62           }
63      }
64    else if (!strcmp(param->name, "align"))
65      {
66         if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
67           {
68              param->d = elm_toolbar_align_get(obj);
69              return EINA_TRUE;
70           }
71      }
72
73    ERR("unknown parameter '%s' of type '%s'",
74        param->name, edje_external_param_type_str(param->type));
75
76    return EINA_FALSE;
77 }
78
79 static void *
80 external_toolbar_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
81 {
82    Elm_Params_Toolbar *mem;
83    Edje_External_Param *param;
84    const Eina_List *l;
85
86    mem = calloc(1, sizeof(Elm_Params_Toolbar));
87    if (!mem)
88      return NULL;
89
90    EINA_LIST_FOREACH(params, l, param)
91      {
92         if (!strcmp(param->name, "icon_size"))
93           {
94              mem->icon_size = param->i;
95              mem->icon_size_exists = EINA_TRUE;
96           }
97         else if (!strcmp(param->name, "align"))
98           {
99              mem->align = param->d;
100              mem->align_exists = EINA_TRUE;
101           }
102      }
103
104    return mem;
105 }
106
107 static Evas_Object *external_toolbar_content_get(void *data __UNUSED__,
108                 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
109 {
110         ERR("No content.");
111         return NULL;
112 }
113
114 static void
115 external_toolbar_params_free(void *params)
116 {
117    Elm_Params_Toolbar *mem = params;
118    free(mem);
119 }
120
121 static Edje_External_Param_Info external_toolbar_params[] = {
122    DEFINE_EXTERNAL_COMMON_PARAMS,
123    EDJE_EXTERNAL_PARAM_INFO_INT("icon_size"),
124    EDJE_EXTERNAL_PARAM_INFO_DOUBLE("align"),
125    EDJE_EXTERNAL_PARAM_INFO_SENTINEL
126 };
127
128 DEFINE_EXTERNAL_ICON_ADD(toolbar, "toolbar");
129 DEFINE_EXTERNAL_TYPE_SIMPLE(toolbar, "Toolbar");