summaryrefslogtreecommitdiff
path: root/src/edje_external
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-07-03 11:29:35 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-07-03 21:35:07 +0200
commitfd5f07300feafa347ec29a9ea9c164b88a245294 (patch)
treea8c0c2cd519e0dc17228bd2fab1a7eadfce5592c /src/edje_external
parentbc8f87c3ac595a05bab2fe7902d79dc572da9322 (diff)
edje_external: add combobox external
The combobox widget can now be used from edje externals. It accepts the "guide" parameter, which is of type string.
Diffstat (limited to 'src/edje_external')
-rw-r--r--src/edje_external/elementary/elm_combobox.c113
-rw-r--r--src/edje_external/elementary/modules.inc1
2 files changed, 114 insertions, 0 deletions
diff --git a/src/edje_external/elementary/elm_combobox.c b/src/edje_external/elementary/elm_combobox.c
new file mode 100644
index 0000000..518fcad
--- /dev/null
+++ b/src/edje_external/elementary/elm_combobox.c
@@ -0,0 +1,113 @@
1#include "private.h"
2
3typedef struct
4{
5 Elm_Params base;
6 Eina_Stringshare *guide;
7} Elm_Params_Combobox;
8
9
10static void
11external_combobox_state_set(void *data EINA_UNUSED,
12 Evas_Object *obj,
13 const void *from_params,
14 const void *to_params,
15 float pos EINA_UNUSED)
16{
17 const Elm_Params_Combobox *p;
18
19 if (to_params) p = to_params;
20 else if (from_params) p = from_params;
21 else return;
22
23 if (p->guide) elm_object_part_text_set(obj, "guide", p->guide);
24}
25
26static Eina_Bool
27external_combobox_param_set(void *data EINA_UNUSED,
28 Evas_Object *obj,
29 const Edje_External_Param *param)
30{
31 if (!strcmp(param->name, "guide"))
32 {
33 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
34 {
35 elm_object_part_text_set(obj, "guide", param->s);
36 return EINA_TRUE;
37 }
38 }
39
40 ERR("unknown parameter '%s' of type '%s'", param->name,
41 edje_external_param_type_str(param->type));
42 return EINA_FALSE;
43}
44
45static Eina_Bool
46external_combobox_param_get(void *data EINA_UNUSED,
47 const Evas_Object *obj,
48 Edje_External_Param *param)
49{
50 if (!strcmp(param->name, "guide"))
51 {
52 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
53 {
54 param->s = elm_object_part_text_get(obj, "guide");
55 return EINA_TRUE;
56 }
57 }
58
59 ERR("Unknown parameter '%s' f type %s", param->name,
60 edje_external_param_type_str(param->type));
61 return EINA_FALSE;
62}
63
64static void *
65external_combobox_params_parse(void *data EINA_UNUSED,
66 Evas_Object *obj EINA_UNUSED,
67 const Eina_List *params)
68{
69 Elm_Params_Combobox *mem;
70 Edje_External_Param *param;
71 const Eina_List *l;
72
73 mem = calloc(1, sizeof(*mem));
74 if (EINA_UNLIKELY(!mem))
75 return NULL;
76
77 EINA_LIST_FOREACH(params, l, param)
78 {
79 if (!strcmp(param->name, "guide"))
80 {
81 mem->guide = eina_stringshare_add(param->s);
82 }
83 }
84
85 return mem;
86}
87
88static Evas_Object *
89external_combobox_content_get(void *data EINA_UNUSED,
90 const Evas_Object *obj EINA_UNUSED,
91 const char *content EINA_UNUSED)
92{
93 ERR("No content for combobox");
94 return NULL;
95}
96
97static void
98external_combobox_params_free(void *params)
99{
100 Elm_Params_Combobox *const mem = params;
101
102 if (mem->guide) eina_stringshare_del(mem->guide);
103 free(mem);
104}
105
106static Edje_External_Param_Info external_combobox_params[] = {
107 DEFINE_EXTERNAL_COMMON_PARAMS,
108 EDJE_EXTERNAL_PARAM_INFO_STRING("guide"),
109 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
110};
111
112DEFINE_EXTERNAL_ICON_ADD(combobox, "combobox");
113DEFINE_EXTERNAL_TYPE_SIMPLE(combobox, "Combobox");
diff --git a/src/edje_external/elementary/modules.inc b/src/edje_external/elementary/modules.inc
index 221817b..dbfead5 100644
--- a/src/edje_external/elementary/modules.inc
+++ b/src/edje_external/elementary/modules.inc
@@ -5,6 +5,7 @@ DEFINE_TYPE(button)
5DEFINE_TYPE(calendar) 5DEFINE_TYPE(calendar)
6DEFINE_TYPE(check) 6DEFINE_TYPE(check)
7DEFINE_TYPE(clock) 7DEFINE_TYPE(clock)
8DEFINE_TYPE(combobox)
8DEFINE_TYPE(entry) 9DEFINE_TYPE(entry)
9DEFINE_TYPE(fileselector) 10DEFINE_TYPE(fileselector)
10DEFINE_TYPE(fileselector_button) 11DEFINE_TYPE(fileselector_button)