summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGustavo Lima Chaves <glima@profusion.mobi>2012-11-30 14:41:39 +0000
committerGustavo Lima Chaves <glima@profusion.mobi>2012-11-30 14:41:39 +0000
commite966637e9fe77e3d52187726859a8de42eae6a22 (patch)
treea7a4f2417187c09ef3ffdf6720d5273d4daa2529 /src/modules
parentf3aa3078161e4f5fe846bb4338e7e5c49bda94ea (diff)
[elm] Introducing a new widget, along with its infrastructure -- prefs.
The prefs widgets aims to aid with the implementation of preference/configuration windows/UI elements in Elementary-based applications (think of Enlightenment configuration dialogs, elementary_config, etc). Prefs is a widget that populates its view with widgets bound to data types (following the instructions of a ".epb" file that describes a set of items) and handles the storage/restoration of such data on a configuration file automatically. There's also the prefs_data handle, which is the one dealing with user saved data for a given epb defaults set. The documentation on the new widget is rich (we have examples and even an EPC reference) and there's a new test entry for it. I'm blogging about it soon, with screeshots and more details. Enjoy. ps.: This is a team work by Murilo Belluzzo, Ricardo de Almeida and me. SVN revision: 79909
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/Makefile.am1
-rw-r--r--src/modules/prefs/Makefile.am78
-rw-r--r--src/modules/prefs/elm_button.c72
-rw-r--r--src/modules/prefs/elm_check.c100
-rw-r--r--src/modules/prefs/elm_datetime.c95
-rw-r--r--src/modules/prefs/elm_entry.c280
-rw-r--r--src/modules/prefs/elm_horizontal_box.c99
-rw-r--r--src/modules/prefs/elm_horizontal_frame.c118
-rw-r--r--src/modules/prefs/elm_label.c37
-rw-r--r--src/modules/prefs/elm_prefs_swallow.edc15
-rw-r--r--src/modules/prefs/elm_separator.c59
-rw-r--r--src/modules/prefs/elm_slider.c125
-rw-r--r--src/modules/prefs/elm_spinner.c124
-rw-r--r--src/modules/prefs/elm_swallow.c65
-rw-r--r--src/modules/prefs/elm_vertical_box.c99
-rw-r--r--src/modules/prefs/elm_vertical_frame.c117
-rw-r--r--src/modules/prefs/item_widgets.inc9
-rw-r--r--src/modules/prefs/page_widgets.inc4
-rw-r--r--src/modules/prefs/prefs_iface.c283
-rw-r--r--src/modules/prefs/private.h127
20 files changed, 1907 insertions, 0 deletions
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index e435e37ff..00fbcc05c 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -2,6 +2,7 @@ AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = \ 4SUBDIRS = \
5prefs \
5test_entry \ 6test_entry \
6test_map \ 7test_map \
7access_output \ 8access_output \
diff --git a/src/modules/prefs/Makefile.am b/src/modules/prefs/Makefile.am
new file mode 100644
index 000000000..b05ad87f8
--- /dev/null
+++ b/src/modules/prefs/Makefile.am
@@ -0,0 +1,78 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3EDJE_CC = @edje_cc@
4EDJE_FLAGS_VERBOSE_ =
5EDJE_FLAGS_VERBOSE_0 =
6EDJE_FLAGS_VERBOSE_1 = -v
7EDJE_FLAGS = $(EDJE_FLAGS_$(V))
8
9EXTRA_DIST = \
10elm_prefs_swallow.edc
11
12filesdir = $(libdir)/elementary/modules/prefs/$(MODULE_ARCH)
13files_DATA = elm_prefs_swallow.edj
14
15elm_prefs_swallow.edj: Makefile elm_prefs_swallow.edc
16 $(EDJE_CC) $(EDJE_FLAGS) \
17 $(top_srcdir)/src/modules/prefs/elm_prefs_swallow.edc \
18 $(top_builddir)/src/modules/prefs/elm_prefs_swallow.edj
19
20AM_CPPFLAGS = \
21-I. \
22-I$(top_builddir) \
23-I$(top_srcdir) \
24-I$(top_srcdir)/src/lib \
25-I$(top_builddir)/src/lib \
26-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
27-DLOCALE_DIR=\"@LOCALE_DIR@\" \
28-DPACKAGE_LIB_DIR=\"$(libdir)\" \
29@ELEMENTARY_CFLAGS@ \
30@ELEMENTARY_X_CFLAGS@ \
31@ELEMENTARY_FB_CFLAGS@ \
32@ELEMENTARY_SDL_CFLAGS@ \
33@ELEMENTARY_WIN32_CFLAGS@ \
34@ELEMENTARY_WINCE_CFLAGS@ \
35@ELEMENTARY_EDBUS_CFLAGS@ \
36@ELEMENTARY_EFREET_CFLAGS@ \
37@ELEMENTARY_ETHUMB_CFLAGS@ \
38@ELEMENTARY_WEB_CFLAGS@ \
39@ELEMENTARY_EMAP_CFLAGS@ \
40@ELEMENTARY_ECORE_CON_CFLAGS@ \
41@ELEMENTARY_ECORE_IMF_CFLAGS@ \
42@ELEMENTARY_WAYLAND_CFLAGS@ \
43@EVIL_CFLAGS@ \
44@EIO_CFLAGS@ \
45@EMOTION_CFLAGS@
46
47if ELEMENTARY_WINDOWS_BUILD
48AM_CPPFLAGS += -DELEMENTARY_BUILD
49endif
50
51pkgdir = $(libdir)/elementary/modules/prefs/$(MODULE_ARCH)
52pkg_LTLIBRARIES = module.la
53
54module_la_SOURCES = \
55private.h \
56item_widgets.inc \
57page_widgets.inc \
58prefs_iface.c \
59elm_button.c \
60elm_check.c \
61elm_datetime.c \
62elm_entry.c \
63elm_label.c \
64elm_separator.c \
65elm_slider.c \
66elm_spinner.c \
67elm_swallow.c \
68elm_vertical_box.c \
69elm_horizontal_box.c \
70elm_vertical_frame.c \
71elm_horizontal_frame.c
72
73module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la
74module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
75module_la_LIBTOOLFLAGS = --tag=disable-static
76
77clean-local:
78 rm -f *.edj
diff --git a/src/modules/prefs/elm_button.c b/src/modules/prefs/elm_button.c
new file mode 100644
index 000000000..6e05ab644
--- /dev/null
+++ b/src/modules/prefs/elm_button.c
@@ -0,0 +1,72 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_ACTION,
6 ELM_PREFS_TYPE_RESET,
7 ELM_PREFS_TYPE_SAVE,
8 ELM_PREFS_TYPE_UNKNOWN
9};
10
11static void
12_item_changed_cb(void *data,
13 Evas_Object *obj,
14 void *event_info __UNUSED__)
15{
16 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
17
18 prefs_it_changed_cb(obj);
19}
20
21static Evas_Object *
22elm_prefs_button_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
23 Evas_Object *prefs,
24 const Elm_Prefs_Item_Type type __UNUSED__,
25 const Elm_Prefs_Item_Spec spec __UNUSED__,
26 Elm_Prefs_Item_Changed_Cb cb)
27{
28 Evas_Object *obj = elm_button_add(prefs);
29
30 evas_object_smart_callback_add(obj, "clicked", _item_changed_cb, cb);
31
32 return obj;
33}
34
35static Eina_Bool
36elm_prefs_button_label_set(Evas_Object *obj,
37 const char *label)
38{
39 return elm_layout_text_set(obj, NULL, label);
40}
41
42static Eina_Bool
43elm_prefs_button_icon_set(Evas_Object *obj,
44 const char *icon)
45{
46 Evas_Object *ic = elm_icon_add(obj);
47 Eina_Bool ret;
48
49 if (!elm_icon_standard_set(ic, icon)) goto err;
50
51 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
52
53 ret = elm_layout_content_set(obj, "icon", ic);
54 if (!ret) goto err;
55
56 return ret;
57
58err:
59 evas_object_del(ic);
60 return EINA_FALSE;
61}
62
63PREFS_ITEM_WIDGET_ADD(button,
64 supported_types,
65 NULL,
66 NULL,
67 NULL,
68 elm_prefs_button_label_set,
69 elm_prefs_button_icon_set,
70 NULL,
71 NULL,
72 NULL);
diff --git a/src/modules/prefs/elm_check.c b/src/modules/prefs/elm_check.c
new file mode 100644
index 000000000..a7f040f31
--- /dev/null
+++ b/src/modules/prefs/elm_check.c
@@ -0,0 +1,100 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_BOOL,
6 ELM_PREFS_TYPE_UNKNOWN
7};
8
9static void
10_item_changed_cb(void *data,
11 Evas_Object *obj,
12 void *event_info __UNUSED__)
13{
14 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
15
16 prefs_it_changed_cb(obj);
17}
18
19static Evas_Object *
20elm_prefs_check_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
21 Evas_Object *prefs,
22 const Elm_Prefs_Item_Type type __UNUSED__,
23 const Elm_Prefs_Item_Spec spec,
24 Elm_Prefs_Item_Changed_Cb cb)
25{
26 Evas_Object *obj = elm_check_add(prefs);
27
28 evas_object_smart_callback_add(obj, "changed", _item_changed_cb, cb);
29
30 elm_check_state_set(obj, spec.b.def);
31
32 return obj;
33}
34
35static Eina_Bool
36elm_prefs_check_value_set(Evas_Object *obj,
37 Eina_Value *value)
38{
39 Eina_Bool val;
40
41 if (eina_value_type_get(value) != EINA_VALUE_TYPE_UCHAR) return EINA_FALSE;
42
43 eina_value_get(value, &val);
44 elm_check_state_set(obj, val);
45
46 return EINA_TRUE;
47}
48
49static Eina_Bool
50elm_prefs_check_value_get(Evas_Object *obj,
51 Eina_Value *value)
52{
53 Eina_Bool val;
54
55 val = elm_check_state_get(obj);
56
57 if (!eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)) return EINA_FALSE;
58 if (!eina_value_set(value, val)) return EINA_FALSE;
59
60 return EINA_TRUE;
61}
62
63static Eina_Bool
64elm_prefs_check_label_set(Evas_Object *obj,
65 const char *label)
66{
67 return elm_layout_text_set(obj, NULL, label);
68}
69
70static Eina_Bool
71elm_prefs_check_icon_set(Evas_Object *obj,
72 const char *icon)
73{
74 Evas_Object *ic = elm_icon_add(obj);
75 Eina_Bool ret;
76
77 if (!elm_icon_standard_set(ic, icon)) goto err;
78
79 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
80
81 ret = elm_layout_content_set(obj, "icon", ic);
82 if (!ret) goto err;
83
84 return ret;
85
86err:
87 evas_object_del(ic);
88 return EINA_FALSE;
89}
90
91PREFS_ITEM_WIDGET_ADD(check,
92 supported_types,
93 elm_prefs_check_value_set,
94 elm_prefs_check_value_get,
95 NULL,
96 elm_prefs_check_label_set,
97 elm_prefs_check_icon_set,
98 NULL,
99 NULL,
100 NULL);
diff --git a/src/modules/prefs/elm_datetime.c b/src/modules/prefs/elm_datetime.c
new file mode 100644
index 000000000..f9681ec2d
--- /dev/null
+++ b/src/modules/prefs/elm_datetime.c
@@ -0,0 +1,95 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_DATE,
6 ELM_PREFS_TYPE_UNKNOWN
7};
8
9static void
10_item_changed_cb(void *data,
11 Evas_Object *obj,
12 void *event_info __UNUSED__)
13{
14 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
15
16 prefs_it_changed_cb(obj);
17}
18
19static Evas_Object *
20elm_prefs_datetime_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
21 Evas_Object *prefs,
22 const Elm_Prefs_Item_Type type __UNUSED__,
23 const Elm_Prefs_Item_Spec spec,
24 Elm_Prefs_Item_Changed_Cb cb)
25{
26 Evas_Object *obj = elm_datetime_add(prefs);
27 struct tm time = {0};
28
29 elm_datetime_field_visible_set(obj, ELM_DATETIME_HOUR, EINA_FALSE);
30 elm_datetime_field_visible_set(obj, ELM_DATETIME_MINUTE, EINA_FALSE);
31 elm_datetime_field_visible_set(obj, ELM_DATETIME_AMPM, EINA_FALSE);
32
33 evas_object_smart_callback_add(obj, "changed", _item_changed_cb, cb);
34
35 time.tm_year = spec.d.min.y - 1900;
36 time.tm_mon = spec.d.min.m - 1;
37 time.tm_mday = spec.d.min.d;
38
39 elm_datetime_value_min_set(obj, &time);
40
41 time.tm_year = spec.d.max.y - 1900;
42 time.tm_mon = spec.d.max.m - 1;
43 time.tm_mday = spec.d.max.d;
44
45 elm_datetime_value_max_set(obj, &time);
46
47 return obj;
48}
49
50static Eina_Bool
51elm_prefs_datetime_value_set(Evas_Object *obj,
52 Eina_Value *value)
53{
54 struct timeval val;
55 struct tm *time;
56
57 if (eina_value_type_get(value) != EINA_VALUE_TYPE_TIMEVAL)
58 return EINA_FALSE;
59
60 eina_value_get(value, &val);
61
62 time = gmtime(&(val.tv_sec));
63
64 if (elm_datetime_value_set(obj, time)) return EINA_TRUE;
65
66 return EINA_FALSE;
67}
68
69static Eina_Bool
70elm_prefs_datetime_value_get(Evas_Object *obj,
71 Eina_Value *value)
72{
73 struct timeval val = {0};
74 struct tm time;
75
76 if (!elm_datetime_value_get(obj, &time)) return EINA_FALSE;
77
78 val.tv_sec = mktime(&time);
79
80 if (!eina_value_setup(value, EINA_VALUE_TYPE_TIMEVAL)) return EINA_FALSE;
81 if (!eina_value_set(value, val)) return EINA_FALSE;
82
83 return EINA_TRUE;
84}
85
86PREFS_ITEM_WIDGET_ADD(datetime,
87 supported_types,
88 elm_prefs_datetime_value_set,
89 elm_prefs_datetime_value_get,
90 NULL,
91 NULL,
92 NULL,
93 NULL,
94 NULL,
95 NULL);
diff --git a/src/modules/prefs/elm_entry.c b/src/modules/prefs/elm_entry.c
new file mode 100644
index 000000000..8138bf826
--- /dev/null
+++ b/src/modules/prefs/elm_entry.c
@@ -0,0 +1,280 @@
1#include "private.h"
2#include <sys/types.h>
3#include <regex.h>
4
5#define BLINK_INTERVAL 0.1
6
7static Elm_Prefs_Item_Type supported_types[] =
8{
9 ELM_PREFS_TYPE_TEXT,
10 ELM_PREFS_TYPE_TEXTAREA,
11 ELM_PREFS_TYPE_UNKNOWN
12};
13
14static Eina_Bool
15_color_change_do(void *data)
16{
17 Evas_Object *obj = data;
18 int color;
19
20 color = (int)(long)evas_object_data_get(obj, "current_color");
21 switch (color)
22 {
23 case 0:
24 evas_object_data_set(obj, "current_color", (void *)1);
25 evas_object_color_set(obj, 255, 0, 0, 255); /* 1st red */
26 goto renew;
27
28 case 1:
29 evas_object_data_set(obj, "current_color", (void *)2);
30 evas_object_color_set(obj, 255, 255, 255, 255); /* 2nd white */
31 goto renew;
32
33 case 2:
34 evas_object_data_set(obj, "current_color", (void *)3);
35 evas_object_color_set(obj, 255, 0, 0, 255); /* 2nd red */
36 goto renew;
37
38 case 3:
39 default:
40 evas_object_data_set(obj, "current_color", (void *)0);
41 evas_object_color_set(obj, 255, 255, 255, 255); /* back to white */
42 goto end;
43 }
44
45renew:
46 return ECORE_CALLBACK_RENEW;
47
48end:
49 evas_object_data_del(obj, "timer");
50 return ECORE_CALLBACK_CANCEL;
51}
52
53static Eina_Bool
54elm_prefs_entry_value_validate(Evas_Object *obj)
55{
56 Ecore_Timer *timer;
57 const char *val;
58 regex_t *regex;
59 size_t min;
60
61 val = elm_entry_entry_get(obj);
62
63 regex = evas_object_data_get(obj, "accept_regex");
64 if (regex)
65 {
66 if (regexec(regex, val, 0, NULL, 0)) goto mismatch;
67 }
68
69 regex = evas_object_data_get(obj, "deny_regex");
70 if (regex)
71 {
72 /* we want tokens *out* of the deny language */
73 if (!regexec(regex, val, 0, NULL, 0)) goto mismatch;
74 }
75
76 min = (size_t) evas_object_data_get(obj, "min_size");
77 if (min)
78 {
79 if (strlen(val) < min) goto mismatch;
80 }
81
82 return EINA_TRUE;
83
84mismatch:
85 evas_object_color_set(obj, 255, 0, 0, 255);
86
87 timer = evas_object_data_get(obj, "timer");
88 if (timer) ecore_timer_del(timer);
89
90 evas_object_data_set
91 (obj, "timer", ecore_timer_add(BLINK_INTERVAL, _color_change_do, obj));
92
93 return EINA_FALSE;
94}
95
96static void
97_item_changed_cb(void *data,
98 Evas_Object *obj,
99 void *event_info __UNUSED__)
100{
101 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
102
103 prefs_it_changed_cb(obj);
104}
105
106static void
107_entry_del_cb(void *data __UNUSED__,
108 Evas *evas __UNUSED__,
109 Evas_Object *obj,
110 void *event_info __UNUSED__)
111{
112 regex_t *regex;
113 Ecore_Timer *timer;
114
115 regex = evas_object_data_del(obj, "accept_regex");
116 if (regex) regfree(regex);
117
118 regex = evas_object_data_del(obj, "deny_regex");
119 if (regex) regfree(regex);
120
121 timer = evas_object_data_del(obj, "timer");
122 if (timer) ecore_timer_del(timer);
123
124 evas_object_data_del(obj, "min_size");
125}
126
127static Evas_Object *
128elm_prefs_entry_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
129 Evas_Object *prefs,
130 const Elm_Prefs_Item_Type type,
131 const Elm_Prefs_Item_Spec spec,
132 Elm_Prefs_Item_Changed_Cb cb)
133{
134 Evas_Object *obj = elm_entry_add(prefs);
135 regex_t *regex = NULL;
136 char buf[256];
137
138 Elm_Entry_Filter_Limit_Size limit = {
139 .max_char_count = spec.s.length.max
140 };
141
142 evas_object_data_set(obj, "prefs_type", (void *)type);
143
144 /* FIXME: have this warning animation on the theme, later */
145
146 /* 0: orig. white; 1: 1st red; 2: 2nd white; 3: 2o red */
147 evas_object_data_set(obj, "current_color", 0);
148
149 /* FIXME: is it worth to ERR with the item's name, too, here? */
150
151 evas_object_smart_callback_add(obj, "activated", _item_changed_cb, cb);
152 evas_object_smart_callback_add(obj, "unfocused", _item_changed_cb, cb);
153
154 if (spec.s.accept)
155 {
156 int ret;
157
158 regex = calloc(1, sizeof(regex_t));
159 ret = regcomp(regex, spec.s.accept, REG_EXTENDED | REG_NOSUB);
160
161 if (ret)
162 {
163 regerror(ret, regex, buf, sizeof(buf));
164 regfree(regex);
165 ERR("bad regular expression (%s) on item's 'accept' tag (%s)."
166 " Because of that, the 'accept' tag will be dropped for the "
167 "item.", spec.s.accept, buf);
168 }
169 else
170 evas_object_data_set(obj, "accept_regex", regex);
171 }
172
173 if (spec.s.deny)
174 {
175 int ret;
176
177 regex = calloc(1, sizeof(regex_t));
178 ret = regcomp(regex, spec.s.deny, REG_EXTENDED | REG_NOSUB);
179
180 if (ret)
181 {
182 regerror(ret, regex, buf, sizeof(buf));
183 regfree(regex);
184 ERR("bad regular expression (%s) on item's 'deny' tag (%s)."
185 " Because of that, the 'deny' tag will be dropped for the "
186 "item.", spec.s.deny, buf);
187 }
188 else
189 evas_object_data_set(obj, "deny_regex", regex);
190 }
191
192 if (spec.s.length.min) /* zero makes no sense */
193 {
194 size_t min = (size_t) spec.s.length.min;
195 evas_object_data_set(obj, "min_size", (void *) min);
196 }
197
198 evas_object_event_callback_add
199 (obj, EVAS_CALLBACK_DEL, _entry_del_cb, NULL);
200
201 elm_entry_scrollable_set(obj, EINA_TRUE);
202
203 if (type == ELM_PREFS_TYPE_TEXT)
204 elm_entry_single_line_set(obj, EINA_TRUE);
205
206 elm_entry_markup_filter_append(obj, elm_entry_filter_limit_size, &limit);
207 elm_layout_text_set(obj, NULL, spec.s.placeholder);
208
209 return obj;
210}
211
212/* already expects an EINA_VALUE_TYPE_STRINGSHARE one */
213static Eina_Bool
214elm_prefs_entry_value_set(Evas_Object *obj,
215 Eina_Value *value)
216{
217 const char *val;
218
219 eina_value_get(value, &val);
220
221 return elm_layout_text_set(obj, NULL, val);
222}
223
224static Eina_Bool
225elm_prefs_entry_value_get(Evas_Object *obj,
226 Eina_Value *value)
227{
228 const char *val;
229
230 val = elm_layout_text_get(obj, NULL);
231
232 if (!eina_value_setup(value, EINA_VALUE_TYPE_STRINGSHARE))
233 return EINA_FALSE;
234 if (!eina_value_set(value, val)) return EINA_FALSE;
235
236 return EINA_TRUE;
237}
238
239static Eina_Bool
240elm_prefs_entry_icon_set(Evas_Object *obj,
241 const char *icon)
242{
243 Evas_Object *ic = elm_icon_add(obj);
244
245 elm_icon_standard_set(ic, icon);
246
247 return elm_layout_content_set(obj, "icon", ic);
248}
249
250static Eina_Bool
251elm_prefs_entry_editable_set(Evas_Object *obj,
252 Eina_Bool editable)
253{
254 elm_entry_editable_set(obj, editable);
255
256 return EINA_TRUE;
257}
258
259static Eina_Bool
260elm_prefs_entry_editable_get(Evas_Object *obj)
261{
262 return elm_entry_editable_get(obj);
263}
264
265static Eina_Bool
266elm_prefs_entry_expand_want(Evas_Object *obj __UNUSED__)
267{
268 return EINA_TRUE;
269}
270
271PREFS_ITEM_WIDGET_ADD(entry,
272 supported_types,
273 elm_prefs_entry_value_set,
274 elm_prefs_entry_value_get,
275 elm_prefs_entry_value_validate,
276 NULL,
277 elm_prefs_entry_icon_set,
278 elm_prefs_entry_editable_set,
279 elm_prefs_entry_editable_get,
280 elm_prefs_entry_expand_want);
diff --git a/src/modules/prefs/elm_horizontal_box.c b/src/modules/prefs/elm_horizontal_box.c
new file mode 100644
index 000000000..368490ded
--- /dev/null
+++ b/src/modules/prefs/elm_horizontal_box.c
@@ -0,0 +1,99 @@
1#include "private.h"
2
3static Evas_Object *
4elm_prefs_horizontal_box_add(const Elm_Prefs_Page_Iface *iface __UNUSED__,
5 Evas_Object *prefs)
6{
7 Evas_Object *obj = elm_box_add(prefs);
8
9 elm_box_horizontal_set(obj, EINA_TRUE);
10
11 return obj;
12}
13
14static Eina_Bool
15elm_prefs_horizontal_box_item_pack(Evas_Object *obj,
16 Evas_Object *it,
17 const Elm_Prefs_Item_Type type,
18 const Elm_Prefs_Item_Iface *iface)
19{
20 Evas_Object *l;
21
22 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
23 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
24 return EINA_FALSE;
25
26 l = evas_object_data_get(it, "label_widget");
27 if (l)
28 evas_object_size_hint_align_set(l, 1.0, 0.5);
29
30 elm_prefs_horizontal_page_common_pack(it, obj, iface);
31
32 return EINA_TRUE;
33}
34
35static Eina_Bool
36elm_prefs_horizontal_box_item_unpack(Evas_Object *obj,
37 Evas_Object *it)
38{
39 /* back to defaults */
40 evas_object_size_hint_align_set(it, 0.5, 0.5);
41 evas_object_size_hint_weight_set(it, 0.0, 0.0);
42
43 elm_prefs_page_common_unpack(it, obj);
44
45 return EINA_TRUE;
46}
47
48static Eina_Bool
49elm_prefs_horizontal_box_item_pack_before(Evas_Object *obj,
50 Evas_Object *it,
51 Evas_Object *it_before,
52 const Elm_Prefs_Item_Type type,
53 const Elm_Prefs_Item_Iface *iface)
54{
55 Evas_Object *l;
56
57 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
58 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
59 return EINA_FALSE;
60
61 l = evas_object_data_get(it, "label_widget");
62 if (l)
63 evas_object_size_hint_align_set(l, 1.0, 0.5);
64
65 elm_prefs_horizontal_page_common_pack_before(it, it_before, obj, iface);
66
67 return EINA_TRUE;
68}
69
70static Eina_Bool
71elm_prefs_horizontal_box_item_pack_after(Evas_Object *obj,
72 Evas_Object *it,
73 Evas_Object *it_after,
74 const Elm_Prefs_Item_Type type,
75 const Elm_Prefs_Item_Iface *iface)
76{
77 Evas_Object *l;
78
79 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
80 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
81 return EINA_FALSE;
82
83 l = evas_object_data_get(it, "label_widget");
84 if (l)
85 evas_object_size_hint_align_set(l, 1.0, 0.5);
86
87 elm_prefs_horizontal_page_common_pack_after(it, it_after, obj, iface);
88
89 return EINA_TRUE;
90}
91
92PREFS_PAGE_WIDGET_ADD(horizontal_box,
93 NULL,
94 NULL,
95 NULL,
96 elm_prefs_horizontal_box_item_pack,
97 elm_prefs_horizontal_box_item_unpack,
98 elm_prefs_horizontal_box_item_pack_before,
99 elm_prefs_horizontal_box_item_pack_after);
diff --git a/src/modules/prefs/elm_horizontal_frame.c b/src/modules/prefs/elm_horizontal_frame.c
new file mode 100644
index 000000000..9fe153ca4
--- /dev/null
+++ b/src/modules/prefs/elm_horizontal_frame.c
@@ -0,0 +1,118 @@
1#include "private.h"
2
3static Evas_Object *
4elm_prefs_horizontal_frame_add(const Elm_Prefs_Page_Iface *iface __UNUSED__,
5 Evas_Object *prefs)
6{
7 Evas_Object *bx, *obj = elm_frame_add(prefs);
8
9 bx = elm_box_add(obj);
10 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
11 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
12
13 elm_box_horizontal_set(bx, EINA_TRUE);
14
15 elm_layout_content_set(obj, NULL, bx);
16
17 evas_object_data_set(obj, "bx_container", bx);
18
19 return obj;
20}
21
22static Eina_Bool
23elm_prefs_horizontal_frame_title_set(Evas_Object *obj,
24 const char *title)
25{
26 elm_layout_text_set(obj, NULL, title);
27
28 return EINA_TRUE;
29}
30
31static Eina_Bool
32elm_prefs_horizontal_frame_item_pack(Evas_Object *obj,
33 Evas_Object *it,
34 const Elm_Prefs_Item_Type type,
35 const Elm_Prefs_Item_Iface *iface)
36{
37 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
38
39 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
40 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
41 return EINA_FALSE;
42
43 l = evas_object_data_get(it, "label_widget");
44 if (l)
45 evas_object_size_hint_align_set(l, 1.0, 0.5);
46
47 elm_prefs_horizontal_page_common_pack(it, bx, iface);
48
49 return EINA_TRUE;
50}
51
52static Eina_Bool
53elm_prefs_horizontal_frame_item_unpack(Evas_Object *obj,
54 Evas_Object *it)
55{
56 Evas_Object *bx = evas_object_data_get(obj, "bx_container");
57
58 /* back to defaults */
59 evas_object_size_hint_align_set(it, 0.5, 0.5);
60 evas_object_size_hint_weight_set(it, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61
62 elm_prefs_page_common_unpack(it, bx);
63
64 return EINA_TRUE;
65}
66
67static Eina_Bool
68elm_prefs_horizontal_frame_item_pack_before(Evas_Object *obj,
69 Evas_Object *it,
70 Evas_Object *it_before,
71 const Elm_Prefs_Item_Type type,
72 const Elm_Prefs_Item_Iface *iface)
73{
74 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
75
76 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
77 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
78 return EINA_FALSE;
79
80 l = evas_object_data_get(it, "label_widget");
81 if (l)
82 evas_object_size_hint_align_set(l, 1.0, 0.5);
83
84 elm_prefs_horizontal_page_common_pack_before(it, it_before, bx, iface);
85
86 return EINA_TRUE;
87}
88
89static Eina_Bool
90elm_prefs_horizontal_frame_item_pack_after(Evas_Object *obj,
91 Evas_Object *it,
92 Evas_Object *it_after,
93 const Elm_Prefs_Item_Type type,
94 const Elm_Prefs_Item_Iface *iface)
95{
96 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
97
98 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
99 (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE)))
100 return EINA_FALSE;
101
102 l = evas_object_data_get(it, "label_widget");
103 if (l)
104 evas_object_size_hint_align_set(l, 1.0, 0.5);
105
106 elm_prefs_horizontal_page_common_pack_after(it, it_after, bx, iface);
107
108 return EINA_TRUE;
109}
110
111PREFS_PAGE_WIDGET_ADD(horizontal_frame,
112 elm_prefs_horizontal_frame_title_set,
113 NULL,
114 NULL,
115 elm_prefs_horizontal_frame_item_pack,
116 elm_prefs_horizontal_frame_item_unpack,
117 elm_prefs_horizontal_frame_item_pack_before,
118 elm_prefs_horizontal_frame_item_pack_after);
diff --git a/src/modules/prefs/elm_label.c b/src/modules/prefs/elm_label.c
new file mode 100644
index 000000000..1e321a342
--- /dev/null
+++ b/src/modules/prefs/elm_label.c
@@ -0,0 +1,37 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_LABEL,
6 ELM_PREFS_TYPE_UNKNOWN
7};
8
9static Evas_Object *
10elm_prefs_label_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
11 Evas_Object *prefs,
12 const Elm_Prefs_Item_Type type __UNUSED__,
13 const Elm_Prefs_Item_Spec spec __UNUSED__,
14 Elm_Prefs_Item_Changed_Cb it_changed_cb __UNUSED__)
15{
16 Evas_Object *obj = elm_label_add(prefs);
17
18 return obj;
19}
20
21static Eina_Bool
22elm_prefs_label_label_set(Evas_Object *obj,
23 const char *label)
24{
25 return elm_layout_text_set(obj, NULL, label);
26}
27
28PREFS_ITEM_WIDGET_ADD(label,
29 supported_types,
30 NULL,
31 NULL,
32 NULL,
33 elm_prefs_label_label_set,
34 NULL,
35 NULL,
36 NULL,
37 NULL);
diff --git a/src/modules/prefs/elm_prefs_swallow.edc b/src/modules/prefs/elm_prefs_swallow.edc
new file mode 100644
index 000000000..730d0c177
--- /dev/null
+++ b/src/modules/prefs/elm_prefs_swallow.edc
@@ -0,0 +1,15 @@
1collections {
2 group {
3 name: "elm_prefs_swallow";
4
5 parts {
6 part {
7 name: "content";
8 type: SWALLOW;
9
10 description {
11 }
12 }
13 }
14 }
15}
diff --git a/src/modules/prefs/elm_separator.c b/src/modules/prefs/elm_separator.c
new file mode 100644
index 000000000..ed5aa5bad
--- /dev/null
+++ b/src/modules/prefs/elm_separator.c
@@ -0,0 +1,59 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_SEPARATOR,
6 ELM_PREFS_TYPE_UNKNOWN
7};
8
9static Evas_Object *
10elm_prefs_separator_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
11 Evas_Object *prefs,
12 const Elm_Prefs_Item_Type type __UNUSED__,
13 const Elm_Prefs_Item_Spec spec __UNUSED__,
14 Elm_Prefs_Item_Changed_Cb cb __UNUSED__)
15{
16 Evas_Object *obj = elm_separator_add(prefs);
17
18 return obj;
19}
20
21static Eina_Bool
22elm_prefs_separator_value_set(Evas_Object *obj,
23 Eina_Value *value)
24{
25 Eina_Bool val;
26
27 if (eina_value_type_get(value) != EINA_VALUE_TYPE_UCHAR)
28 return EINA_FALSE;
29
30 eina_value_get(value, &val);
31 elm_separator_horizontal_set(obj, val);
32
33 return EINA_TRUE;
34}
35
36static Eina_Bool
37elm_prefs_separator_value_get(Evas_Object *obj,
38 Eina_Value *value)
39{
40 Eina_Bool val = elm_separator_horizontal_get(obj);
41
42 if (!eina_value_setup(value, EINA_VALUE_TYPE_UCHAR))
43 return EINA_FALSE;
44
45 if (!eina_value_set(value, val)) return EINA_FALSE;
46
47 return EINA_TRUE;
48}
49
50PREFS_ITEM_WIDGET_ADD(separator,
51 supported_types,
52 elm_prefs_separator_value_set,
53 elm_prefs_separator_value_get,
54 NULL,
55 NULL,
56 NULL,
57 NULL,
58 NULL,
59 NULL);
diff --git a/src/modules/prefs/elm_slider.c b/src/modules/prefs/elm_slider.c
new file mode 100644
index 000000000..06157f492
--- /dev/null
+++ b/src/modules/prefs/elm_slider.c
@@ -0,0 +1,125 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_INT,
6 ELM_PREFS_TYPE_FLOAT,
7 ELM_PREFS_TYPE_UNKNOWN
8};
9
10static void
11_item_changed_cb(void *data,
12 Evas_Object *obj,
13 void *event_info __UNUSED__)
14{
15 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
16
17 prefs_it_changed_cb(obj);
18}
19
20static Evas_Object *
21elm_prefs_slider_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
22 Evas_Object *prefs,
23 const Elm_Prefs_Item_Type type,
24 const Elm_Prefs_Item_Spec spec,
25 Elm_Prefs_Item_Changed_Cb cb)
26{
27 Evas_Object *obj = elm_slider_add(prefs);
28
29 evas_object_data_set(obj, "prefs_type", (void *)type);
30
31 evas_object_smart_callback_add(obj, "changed", _item_changed_cb, cb);
32
33 if (type == ELM_PREFS_TYPE_INT)
34 {
35 elm_slider_unit_format_set(obj, "%1.0f");
36 elm_slider_indicator_format_set(obj, "%1.0f");
37 elm_slider_min_max_set(obj, spec.i.min, spec.i.max);
38 elm_slider_value_set(obj, spec.i.def);
39 }
40 else if (type == ELM_PREFS_TYPE_FLOAT)
41 {
42 elm_slider_unit_format_set(obj, "%1.2f");
43 elm_slider_indicator_format_set(obj, "%1.2f");
44 elm_slider_min_max_set(obj, spec.f.min, spec.f.max);
45 elm_slider_value_set(obj, spec.f.def);
46 }
47
48 return obj;
49}
50
51static Eina_Bool
52elm_prefs_slider_value_set(Evas_Object *obj,
53 Eina_Value *value)
54{
55 union
56 {
57 int i;
58 float f;
59 } val;
60
61 Elm_Prefs_Item_Type pt =
62 (Elm_Prefs_Item_Type)evas_object_data_get(obj, "prefs_type");
63
64 const Eina_Value_Type *vt = eina_value_type_get(value);
65 if (!vt) return EINA_FALSE;
66
67 if ((pt == ELM_PREFS_TYPE_INT) && (vt == EINA_VALUE_TYPE_INT))
68 {
69 eina_value_get(value, &(val.i));
70 elm_slider_value_set(obj, val.i);
71 }
72 else if ((pt == ELM_PREFS_TYPE_FLOAT) && (vt == EINA_VALUE_TYPE_FLOAT))
73 {
74 eina_value_get(value, &(val.f));
75 elm_slider_value_set(obj, val.f);
76 }
77 else
78 return EINA_FALSE;
79
80 return EINA_TRUE;
81}
82
83static Eina_Bool
84elm_prefs_slider_value_get(Evas_Object *obj,
85 Eina_Value *value)
86{
87 union
88 {
89 int i;
90 float f;
91 } val;
92
93 Elm_Prefs_Item_Type pt =
94 (Elm_Prefs_Item_Type)evas_object_data_get(obj, "prefs_type");
95
96 if (pt == ELM_PREFS_TYPE_INT)
97 {
98 val.i = elm_slider_value_get(obj);
99
100 if (!eina_value_setup(value, EINA_VALUE_TYPE_INT)) return EINA_FALSE;
101 if (!eina_value_set(value, val.i)) return EINA_FALSE;
102 }
103 else if (pt == ELM_PREFS_TYPE_FLOAT)
104 {
105 val.f = elm_slider_value_get(obj);
106
107 if (!eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)) return EINA_FALSE;
108 if (!eina_value_set(value, val.f)) return EINA_FALSE;
109 }
110 else
111 return EINA_FALSE;
112
113 return EINA_TRUE;
114}
115
116PREFS_ITEM_WIDGET_ADD(slider,
117 supported_types,
118 elm_prefs_slider_value_set,
119 elm_prefs_slider_value_get,
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL,
125 NULL);
diff --git a/src/modules/prefs/elm_spinner.c b/src/modules/prefs/elm_spinner.c
new file mode 100644
index 000000000..2317f9e0d
--- /dev/null
+++ b/src/modules/prefs/elm_spinner.c
@@ -0,0 +1,124 @@
1#include "private.h"
2
3static Elm_Prefs_Item_Type supported_types[] =
4{
5 ELM_PREFS_TYPE_INT,
6 ELM_PREFS_TYPE_FLOAT,
7 ELM_PREFS_TYPE_UNKNOWN
8};
9
10static void
11_item_changed_cb(void *data,
12 Evas_Object *obj,
13 void *event_info __UNUSED__)
14{
15 Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data;
16
17 prefs_it_changed_cb(obj);
18}
19
20static Evas_Object *
21elm_prefs_spinner_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
22 Evas_Object *prefs,
23 const Elm_Prefs_Item_Type type,
24 const Elm_Prefs_Item_Spec spec,
25 Elm_Prefs_Item_Changed_Cb cb)
26{
27 Evas_Object *obj = elm_spinner_add(prefs);
28
29 evas_object_data_set(obj, "prefs_type", (void *)type);
30
31 evas_object_smart_callback_add(obj, "changed", _item_changed_cb, cb);
32
33 if (type == ELM_PREFS_TYPE_INT)
34 {
35 elm_spinner_step_set(obj, 1.0);
36 elm_spinner_min_max_set(obj, spec.i.min, spec.i.max);
37 elm_spinner_value_set(obj, spec.i.def);
38 }
39 else if (type == ELM_PREFS_TYPE_FLOAT)
40 {
41 elm_spinner_label_format_set(obj, "%1.2f");
42 elm_spinner_step_set(obj, 0.1);
43 elm_spinner_min_max_set(obj, spec.f.min, spec.f.max);
44 elm_spinner_value_set(obj, spec.f.def);
45 }
46
47 return obj;
48}
49
50static Eina_Bool
51elm_prefs_spinner_value_set(Evas_Object *obj,
52 Eina_Value *value)
53{
54 union
55 {
56 int i;
57 float f;
58 } val;
59
60 Elm_Prefs_Item_Type pt =
61 (Elm_Prefs_Item_Type) evas_object_data_get(obj, "prefs_type");
62
63 const Eina_Value_Type *vt = eina_value_type_get(value);
64 if (!vt) return EINA_FALSE;
65
66 if ((pt == ELM_PREFS_TYPE_INT) && (vt == EINA_VALUE_TYPE_INT))
67 {
68 eina_value_get(value, &(val.i));
69 elm_spinner_value_set(obj, val.i);
70 }
71 else if ((pt == ELM_PREFS_TYPE_FLOAT) && (vt == EINA_VALUE_TYPE_FLOAT))
72 {
73 eina_value_get(value, &(val.f));
74 elm_spinner_value_set(obj, val.f);
75 }
76 else
77 return EINA_FALSE;
78
79 return EINA_TRUE;
80}
81
82static Eina_Bool
83elm_prefs_spinner_value_get(Evas_Object *obj,
84 Eina_Value *value)
85{
86 union
87 {
88 int i;
89 float f;
90 } val;
91
92 Elm_Prefs_Item_Type pt =
93 (Elm_Prefs_Item_Type) evas_object_data_get(obj, "prefs_type");
94
95 if (pt == ELM_PREFS_TYPE_INT)
96 {
97 val.i = elm_spinner_value_get(obj);
98
99 if (!eina_value_setup(value, EINA_VALUE_TYPE_INT)) return EINA_FALSE;
100 if (!eina_value_set(value, val.i)) return EINA_FALSE;
101 }
102 else if (pt == ELM_PREFS_TYPE_FLOAT)
103 {
104 val.f = elm_spinner_value_get(obj);
105
106 if (!eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)) return EINA_FALSE;
107 if (!eina_value_set(value, val.f)) return EINA_FALSE;
108 }
109 else
110 return EINA_FALSE;
111
112 return EINA_TRUE;
113}
114
115PREFS_ITEM_WIDGET_ADD(spinner,
116 supported_types,
117 elm_prefs_spinner_value_set,
118 elm_prefs_spinner_value_get,
119 NULL,
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL);
diff --git a/src/modules/prefs/elm_swallow.c b/src/modules/prefs/elm_swallow.c
new file mode 100644
index 000000000..b8bc8b59a
--- /dev/null
+++ b/src/modules/prefs/elm_swallow.c
@@ -0,0 +1,65 @@
1#include "private.h"
2
3static const char LAYOUT_EDJ[] = PACKAGE_LIB_DIR\
4 "/elementary/modules/prefs/"\
5 MODULE_ARCH\
6 "/elm_prefs_swallow.edj";
7
8static Elm_Prefs_Item_Type supported_types[] =
9{
10 ELM_PREFS_TYPE_SWALLOW,
11 ELM_PREFS_TYPE_UNKNOWN
12};
13
14static Evas_Object *
15elm_prefs_swallow_add(const Elm_Prefs_Item_Iface *iface __UNUSED__,
16 Evas_Object *prefs,
17 const Elm_Prefs_Item_Type type __UNUSED__,
18 const Elm_Prefs_Item_Spec spec __UNUSED__,
19 Elm_Prefs_Item_Changed_Cb cb __UNUSED__)
20{
21 Evas_Object *obj = elm_layout_add(prefs);
22
23 elm_layout_file_set(obj, LAYOUT_EDJ, "elm_prefs_swallow");
24
25 return obj;
26}
27
28static Eina_Bool
29elm_prefs_swallow_swallow(Evas_Object *obj,
30 Eina_Value *value)
31{
32 Evas_Object *subobj;
33
34 if (eina_value_type_get(value) != EINA_VALUE_TYPE_UINT64 ||
35 !eina_value_get(value, &subobj))
36 return EINA_FALSE;
37
38 elm_layout_content_set(obj, "content", subobj);
39
40 return EINA_TRUE;
41}
42
43static Eina_Bool
44elm_prefs_swallow_unswallow(Evas_Object *obj,
45 Eina_Value *value)
46{
47 Evas_Object *subobj = elm_layout_content_unset(obj, "content");
48
49 if (!eina_value_setup(value, EINA_VALUE_TYPE_UINT64) ||
50 !eina_value_set(value, subobj))
51 return EINA_FALSE;
52
53 return EINA_TRUE;
54}
55
56PREFS_ITEM_WIDGET_ADD(swallow,
57 supported_types,
58 elm_prefs_swallow_swallow,
59 elm_prefs_swallow_unswallow,
60 NULL,
61 NULL,
62 NULL,
63 NULL,
64 NULL,
65 NULL);
diff --git a/src/modules/prefs/elm_vertical_box.c b/src/modules/prefs/elm_vertical_box.c
new file mode 100644
index 000000000..2b23a45c9
--- /dev/null
+++ b/src/modules/prefs/elm_vertical_box.c
@@ -0,0 +1,99 @@
1#include "private.h"
2
3static Evas_Object *
4elm_prefs_vertical_box_add(const Elm_Prefs_Page_Iface *iface __UNUSED__,
5 Evas_Object *prefs)
6{
7 Evas_Object *obj = elm_box_add(prefs);
8
9 elm_box_horizontal_set(obj, EINA_FALSE);
10
11 return obj;
12}
13
14static Eina_Bool
15elm_prefs_vertical_box_item_pack(Evas_Object *obj,
16 Evas_Object *it,
17 const Elm_Prefs_Item_Type type,
18 const Elm_Prefs_Item_Iface *iface)
19{
20 Evas_Object *l;
21
22 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
23 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
24 return EINA_FALSE;
25
26 l = evas_object_data_get(it, "label_widget");
27 if (l)
28 evas_object_size_hint_align_set(l, 0.0, 1.0);
29
30 elm_prefs_vertical_page_common_pack(it, obj, iface);
31
32 return EINA_TRUE;
33}
34
35static Eina_Bool
36elm_prefs_vertical_box_item_unpack(Evas_Object *obj,
37 Evas_Object *it)
38{
39 /* back to defaults */
40 evas_object_size_hint_align_set(it, 0.5, 0.5);
41 evas_object_size_hint_weight_set(it, 0.0, 0.0);
42
43 elm_prefs_page_common_unpack(it, obj);
44
45 return EINA_TRUE;
46}
47
48static Eina_Bool
49elm_prefs_vertical_box_item_pack_before(Evas_Object *obj,
50 Evas_Object *it,
51 Evas_Object *it_before,
52 const Elm_Prefs_Item_Type type,
53 const Elm_Prefs_Item_Iface *iface)
54{
55 Evas_Object *l;
56
57 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
58 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
59 return EINA_FALSE;
60
61 l = evas_object_data_get(it, "label_widget");
62 if (l)
63 evas_object_size_hint_align_set(l, 0.0, 1.0);
64
65 elm_prefs_vertical_page_common_pack_before(it, it_before, obj, iface);
66
67 return EINA_TRUE;
68}
69
70static Eina_Bool
71elm_prefs_vertical_box_item_pack_after(Evas_Object *obj,
72 Evas_Object *it,
73 Evas_Object *it_after,
74 const Elm_Prefs_Item_Type type,
75 const Elm_Prefs_Item_Iface *iface)
76{
77 Evas_Object *l;
78
79 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
80 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
81 return EINA_FALSE;
82
83 l = evas_object_data_get(it, "label_widget");
84 if (l)
85 evas_object_size_hint_align_set(l, 0.0, 1.0);
86
87 elm_prefs_vertical_page_common_pack_after(it, it_after, obj, iface);
88
89 return EINA_TRUE;
90}
91
92PREFS_PAGE_WIDGET_ADD(vertical_box,
93 NULL,
94 NULL,
95 NULL,
96 elm_prefs_vertical_box_item_pack,
97 elm_prefs_vertical_box_item_unpack,
98 elm_prefs_vertical_box_item_pack_before,
99 elm_prefs_vertical_box_item_pack_after);
diff --git a/src/modules/prefs/elm_vertical_frame.c b/src/modules/prefs/elm_vertical_frame.c
new file mode 100644
index 000000000..06bb5c5fe
--- /dev/null
+++ b/src/modules/prefs/elm_vertical_frame.c
@@ -0,0 +1,117 @@
1#include "private.h"
2
3static Evas_Object *
4elm_prefs_vertical_frame_add(const Elm_Prefs_Page_Iface *iface __UNUSED__,
5 Evas_Object *prefs)
6{
7 Evas_Object *bx, *obj = elm_frame_add(prefs);
8
9 bx = elm_box_add(obj);
10 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
11 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
12
13 elm_layout_content_set(obj, NULL, bx);
14
15 evas_object_data_set(obj, "bx_container", bx);
16
17 return obj;
18}
19
20static Eina_Bool
21elm_prefs_vertical_frame_title_set(Evas_Object *obj,
22 const char *title)
23{
24 elm_layout_text_set(obj, NULL, title);
25
26 return EINA_TRUE;
27}
28
29static Eina_Bool
30elm_prefs_vertical_frame_item_pack(Evas_Object *obj,
31 Evas_Object *it,
32 const Elm_Prefs_Item_Type type,
33 const Elm_Prefs_Item_Iface *iface)
34{
35 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
36
37 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
38 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
39 return EINA_FALSE;
40
41 l = evas_object_data_get(it, "label_widget");
42 if (l)
43 evas_object_size_hint_align_set(l, 0.0, 1.0);
44
45 elm_prefs_vertical_page_common_pack(it, bx, iface);
46
47 return EINA_TRUE;
48}
49
50static Eina_Bool
51elm_prefs_vertical_frame_item_unpack(Evas_Object *obj,
52 Evas_Object *it)
53{
54 Evas_Object *bx = evas_object_data_get(obj, "bx_container");
55
56 /* back to defaults */
57 evas_object_size_hint_align_set(it, 0.5, 0.5);
58 evas_object_size_hint_weight_set(it, 0.0, 0.0);
59
60 elm_prefs_page_common_unpack(it, bx);
61
62 return EINA_TRUE;
63}
64
65
66static Eina_Bool
67elm_prefs_vertical_frame_item_pack_before(Evas_Object *obj,
68 Evas_Object *it,
69 Evas_Object *it_before,
70 const Elm_Prefs_Item_Type type,
71 const Elm_Prefs_Item_Iface *iface)
72{
73 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
74
75 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
76 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
77 return EINA_FALSE;
78
79 l = evas_object_data_get(it, "label_widget");
80 if (l)
81 evas_object_size_hint_align_set(l, 0.0, 1.0);
82
83 elm_prefs_vertical_page_common_pack_before(it, it_before, bx, iface);
84
85 return EINA_TRUE;
86}
87
88static Eina_Bool
89elm_prefs_vertical_frame_item_pack_after(Evas_Object *obj,
90 Evas_Object *it,
91 Evas_Object *it_after,
92 const Elm_Prefs_Item_Type type,
93 const Elm_Prefs_Item_Iface *iface)
94{
95 Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
96
97 if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
98 (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
99 return EINA_FALSE;
100
101 l = evas_object_data_get(it, "label_widget");
102 if (l)
103 evas_object_size_hint_align_set(l, 0.0, 1.0);
104
105 elm_prefs_vertical_page_common_pack_after(it, it_after, bx, iface);
106
107 return EINA_TRUE;
108}
109
110PREFS_PAGE_WIDGET_ADD(vertical_frame,
111 elm_prefs_vertical_frame_title_set,
112 NULL,
113 NULL,
114 elm_prefs_vertical_frame_item_pack,
115 elm_prefs_vertical_frame_item_unpack,
116 elm_prefs_vertical_frame_item_pack_before,
117 elm_prefs_vertical_frame_item_pack_after);
diff --git a/src/modules/prefs/item_widgets.inc b/src/modules/prefs/item_widgets.inc
new file mode 100644
index 000000000..1c0ce6623
--- /dev/null
+++ b/src/modules/prefs/item_widgets.inc
@@ -0,0 +1,9 @@
1PREFS_ADD(button)
2PREFS_ADD(check)
3PREFS_ADD(datetime)
4PREFS_ADD(entry)
5PREFS_ADD(label)
6PREFS_ADD(separator)
7PREFS_ADD(slider)
8PREFS_ADD(spinner)
9PREFS_ADD(swallow)
diff --git a/src/modules/prefs/page_widgets.inc b/src/modules/prefs/page_widgets.inc
new file mode 100644
index 000000000..2bf3c1cbb
--- /dev/null
+++ b/src/modules/prefs/page_widgets.inc
@@ -0,0 +1,4 @@
1PREFS_ADD(vertical_box)
2PREFS_ADD(horizontal_box)
3PREFS_ADD(vertical_frame)
4PREFS_ADD(horizontal_frame)
diff --git a/src/modules/prefs/prefs_iface.c b/src/modules/prefs/prefs_iface.c
new file mode 100644
index 000000000..f3ec07199
--- /dev/null
+++ b/src/modules/prefs/prefs_iface.c
@@ -0,0 +1,283 @@
1#include "Elementary.h"
2#include "private.h"
3
4/* including declaration of each prefs item implementation iface struct */
5#define PREFS_ADD(w_name) \
6 extern const Elm_Prefs_Item_Iface prefs_##w_name##_impl;
7
8#include "item_widgets.inc"
9
10#undef PREFS_ADD
11
12int _elm_prefs_log_dom = -1;
13
14/* now building on array of those, to be put on a hash for lookup */
15static Elm_Prefs_Item_Iface_Info _elm_prefs_item_widgets[] =
16{
17#define PREFS_ADD(w_name) \
18 {"elm/" #w_name, &prefs_##w_name##_impl},
19
20#include "item_widgets.inc"
21
22#undef PREFS_ADD
23 {NULL, NULL}
24};
25
26/* including declaration of each prefs page implementation iface struct */
27#define PREFS_ADD(w_name) \
28 extern const Elm_Prefs_Page_Iface prefs_##w_name##_impl;
29
30#include "page_widgets.inc"
31
32#undef PREFS_ADD
33
34/* now building on array of those, to be put on a hash for lookup */
35static Elm_Prefs_Page_Iface_Info _elm_prefs_page_widgets[] =
36{
37#define PREFS_ADD(w_name) \
38 {"elm/" #w_name, &prefs_##w_name##_impl},
39
40#include "page_widgets.inc"
41
42#undef PREFS_ADD
43 {NULL, NULL}
44};
45
46Eina_Bool
47elm_prefs_page_item_value_set(Evas_Object *it,
48 const Elm_Prefs_Item_Iface *iface,
49 Eina_Bool val)
50{
51 Eina_Value value;
52
53 if (!iface->value_set) return EINA_FALSE;
54
55 if ((!eina_value_setup(&value, EINA_VALUE_TYPE_UCHAR)) ||
56 (!eina_value_set(&value, val)))
57 return EINA_FALSE;
58
59 return iface->value_set(it, &value);
60}
61
62static Evas_Object *
63_elm_prefs_page_box_add(Evas_Object *obj,
64 Evas_Object *it)
65{
66 Evas_Object *sbx;
67 double align_x, align_y;
68
69 evas_object_size_hint_align_get(it, &align_x, &align_y);
70
71 sbx = elm_box_add(obj);
72 elm_box_horizontal_set(sbx, EINA_TRUE);
73 evas_object_size_hint_weight_set(sbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74 evas_object_size_hint_align_set(sbx, align_x, align_y);
75 evas_object_data_set(obj, "sub_box", sbx);
76 evas_object_show(sbx);
77
78 return sbx;
79}
80
81static void
82_elm_prefs_page_item_hints_set(Evas_Object *it,
83 const Elm_Prefs_Item_Iface *iface)
84{
85 if (iface && iface->expand_want && iface->expand_want(it))
86 evas_object_size_hint_align_set(it, EVAS_HINT_FILL, EVAS_HINT_FILL);
87
88 evas_object_size_hint_weight_set(it, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
89}
90
91static void
92_elm_prefs_page_pack_setup(Evas_Object *it,
93 Evas_Object *obj,
94 const Elm_Prefs_Item_Iface *iface)
95{
96 Evas_Object *l, *i, *sbx;
97
98 _elm_prefs_page_item_hints_set(it, iface);
99
100 l = evas_object_data_get(it, "label_widget");
101 i = evas_object_data_get(it, "icon_widget");
102 if (i)
103 {
104 sbx = _elm_prefs_page_box_add(obj, it);
105 elm_box_pack_end(obj, sbx);
106
107 evas_object_size_hint_align_set(it, EVAS_HINT_FILL, EVAS_HINT_FILL);
108 evas_object_size_hint_align_set(i, 0.0, EVAS_HINT_FILL);
109 elm_box_pack_end(sbx, i);
110 elm_box_pack_end(sbx, it);
111
112 if (l) elm_box_pack_before(obj, l, sbx);
113 }
114 else
115 {
116 elm_box_pack_end(obj, it);
117 if (l) elm_box_pack_before(obj, l, it);
118 }
119}
120
121static void
122_elm_prefs_page_pack_before_setup(Evas_Object *it,
123 Evas_Object *it_before,
124 Evas_Object *obj,
125 const Elm_Prefs_Item_Iface *iface)
126{
127 Evas_Object *l, *i, *sbx;
128
129 _elm_prefs_page_item_hints_set(it, iface);
130
131 l = evas_object_data_get(it, "label_widget");
132 i = evas_object_data_get(it, "icon_widget");
133 if (i)
134 {
135 sbx = _elm_prefs_page_box_add(obj, it);
136 elm_box_pack_before(obj, sbx, it_before);
137
138 evas_object_size_hint_align_set(i, EVAS_HINT_FILL, 0.5);
139 elm_box_pack_end(sbx, i);
140 elm_box_pack_end(sbx, it);
141
142 if (l) elm_box_pack_before(obj, l, sbx);
143 }
144 else
145 {
146 elm_box_pack_before(obj, it, it_before);
147 if (l) elm_box_pack_before(obj, l, it);
148 }
149}
150
151static void
152_elm_prefs_page_pack_after_setup(Evas_Object *it,
153 Evas_Object *it_after,
154 Evas_Object *obj,
155 const Elm_Prefs_Item_Iface *iface)
156{
157 Evas_Object *l, *i, *sbx;
158
159 _elm_prefs_page_item_hints_set(it, iface);
160
161 l = evas_object_data_get(it, "label_widget");
162 i = evas_object_data_get(it, "icon_widget");
163 if (i)
164 {
165 sbx = _elm_prefs_page_box_add(obj, it);
166 elm_box_pack_after(obj, sbx, it_after);
167
168 evas_object_size_hint_align_set(i, EVAS_HINT_FILL, 0.5);
169 elm_box_pack_end(sbx, i);
170 elm_box_pack_end(sbx, it);
171
172 if (l) elm_box_pack_before(obj, l, sbx);
173 }
174 else
175 {
176 elm_box_pack_after(obj, it, it_after);
177 if (l) elm_box_pack_before(obj, l, it);
178 }
179}
180
181void
182elm_prefs_horizontal_page_common_pack(Evas_Object *it,
183 Evas_Object *obj,
184 const Elm_Prefs_Item_Iface *iface)
185{
186 evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL);
187 _elm_prefs_page_pack_setup(it, obj, iface);
188}
189
190void
191elm_prefs_horizontal_page_common_pack_before(Evas_Object *it,
192 Evas_Object *it_before,
193 Evas_Object *obj,
194 const Elm_Prefs_Item_Iface *iface)
195{
196 evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL);
197 _elm_prefs_page_pack_before_setup(it, it_before, obj, iface);
198}
199
200void
201elm_prefs_horizontal_page_common_pack_after(Evas_Object *it,
202 Evas_Object *it_after,
203 Evas_Object *obj,
204 const Elm_Prefs_Item_Iface *iface)
205{
206 evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL);
207 _elm_prefs_page_pack_after_setup(it, it_after, obj, iface);
208}
209
210void
211elm_prefs_vertical_page_common_pack(Evas_Object *it,
212 Evas_Object *obj,
213 const Elm_Prefs_Item_Iface *iface)
214{
215 evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5);
216 _elm_prefs_page_pack_setup(it, obj, iface);
217}
218
219void
220elm_prefs_vertical_page_common_pack_before(Evas_Object *it,
221 Evas_Object *it_before,
222 Evas_Object *obj,
223 const Elm_Prefs_Item_Iface *iface)
224{
225 evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5);
226 _elm_prefs_page_pack_before_setup(it, it_before, obj, iface);
227}
228
229void
230elm_prefs_vertical_page_common_pack_after(Evas_Object *it,
231 Evas_Object *it_after,
232 Evas_Object *obj,
233 const Elm_Prefs_Item_Iface *iface)
234{
235 evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5);
236 _elm_prefs_page_pack_after_setup(it, it_after, obj, iface);
237}
238
239void
240elm_prefs_page_common_unpack(Evas_Object *it,
241 Evas_Object *obj)
242{
243 Evas_Object *l, *i, *sbx;
244
245 l = evas_object_data_get(it, "label_widget");
246 if (l) elm_box_unpack(obj, l);
247
248 sbx = evas_object_data_get(it, "sub_box");
249 i = evas_object_data_get(it, "icon_widget");
250
251 if (i && sbx)
252 {
253 elm_box_unpack_all(sbx);
254 elm_box_unpack(obj, sbx);
255 evas_object_del(sbx);
256 }
257 else
258 elm_box_unpack(obj, it);
259}
260
261EAPI int
262elm_modapi_init(void *m __UNUSED__)
263{
264 _elm_prefs_log_dom = eina_log_domain_register
265 ("elm-prefs", EINA_COLOR_YELLOW);
266
267 elm_prefs_item_iface_register(_elm_prefs_item_widgets);
268 elm_prefs_page_iface_register(_elm_prefs_page_widgets);
269
270 return 1; // succeed always
271}
272
273EAPI int
274elm_modapi_shutdown(void *m __UNUSED__)
275{
276 elm_prefs_item_iface_unregister(_elm_prefs_item_widgets);
277 elm_prefs_page_iface_unregister(_elm_prefs_page_widgets);
278
279 if (_elm_prefs_log_dom >= 0) eina_log_domain_unregister(_elm_prefs_log_dom);
280 _elm_prefs_log_dom = -1;
281
282 return 1; // succeed always
283}
diff --git a/src/modules/prefs/private.h b/src/modules/prefs/private.h
new file mode 100644
index 000000000..6ad8661ae
--- /dev/null
+++ b/src/modules/prefs/private.h
@@ -0,0 +1,127 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include "Elementary.h"
5
6#undef CRITICAL
7#undef ERR
8#undef WRN
9#undef INF
10#undef DBG
11
12#define CRITICAL(...) EINA_LOG_DOM_CRIT(_elm_prefs_log_dom, __VA_ARGS__)
13#define ERR(...) EINA_LOG_DOM_ERR (_elm_prefs_log_dom, __VA_ARGS__)
14#define WRN(...) EINA_LOG_DOM_WARN(_elm_prefs_log_dom, __VA_ARGS__)
15#define INF(...) EINA_LOG_DOM_INFO(_elm_prefs_log_dom, __VA_ARGS__)
16#define DBG(...) EINA_LOG_DOM_DBG (_elm_prefs_log_dom, __VA_ARGS__)
17
18extern int _elm_prefs_log_dom;
19
20#define PREFS_ITEM_WIDGET_ADD(_w_name, \
21 _types, \
22 _value_set_fn, \
23 _value_get_fn, \
24 _value_validate_fn, \
25 _label_set_fn, \
26 _icon_set_fn, \
27 _editable_set_fn, \
28 _editable_get_fn, \
29 _expand_want_fn) \
30 static Evas_Object * \
31 _prefs_##_w_name##_add(const Elm_Prefs_Item_Iface * iface, \
32 Evas_Object * prefs, \
33 const Elm_Prefs_Item_Type type, \
34 const Elm_Prefs_Item_Spec spec, \
35 Elm_Prefs_Item_Changed_Cb it_changed_cb) \
36 { \
37 Evas_Object *obj = \
38 elm_prefs_##_w_name##_add(iface, prefs, type, spec, it_changed_cb); \
39 if (!obj) return NULL; \
40 if (!elm_prefs_item_widget_common_add(prefs, obj)) \
41 { \
42 evas_object_del(obj); \
43 return NULL; \
44 } \
45 \
46 return obj; \
47 } \
48 \
49 const Elm_Prefs_Item_Iface prefs_##_w_name##_impl = \
50 { \
51 .abi_version = ELM_PREFS_ITEM_IFACE_ABI_VERSION, \
52 .add = _prefs_##_w_name##_add, \
53 .types = _types, \
54 .value_set = _value_set_fn, \
55 .value_get = _value_get_fn, \
56 .value_validate = _value_validate_fn, \
57 .label_set = _label_set_fn, \
58 .icon_set = _icon_set_fn, \
59 .editable_set = _editable_set_fn, \
60 .editable_get = _editable_get_fn, \
61 .expand_want = _expand_want_fn \
62 }
63
64#define PREFS_PAGE_WIDGET_ADD(_w_name, \
65 _title_set_fn, \
66 _sub_title_set_fn, \
67 _icon_set_fn, \
68 _item_pack_fn, \
69 _item_unpack_fn, \
70 _item_pack_before_fn, \
71 _item_pack_after_fn) \
72 static Evas_Object * \
73 _prefs_##_w_name##_add(const Elm_Prefs_Page_Iface * iface, \
74 Evas_Object * prefs) \
75 { \
76 Evas_Object *obj = \
77 elm_prefs_##_w_name##_add(iface, prefs); \
78 if (!obj) return NULL; \
79 if (!elm_prefs_page_widget_common_add(prefs, obj)) \
80 { \
81 evas_object_del(obj); \
82 return NULL; \
83 } \
84 \
85 return obj; \
86 } \
87 \
88 const Elm_Prefs_Page_Iface prefs_##_w_name##_impl = \
89 { \
90 .abi_version = ELM_PREFS_PAGE_IFACE_ABI_VERSION, \
91 .add = _prefs_##_w_name##_add, \
92 .title_set = _title_set_fn, \
93 .sub_title_set = _sub_title_set_fn, \
94 .icon_set = _icon_set_fn, \
95 .item_pack = _item_pack_fn, \
96 .item_unpack = _item_unpack_fn, \
97 .item_pack_before = _item_pack_before_fn, \
98 .item_pack_after = _item_pack_after_fn \
99 }
100
101Eina_Bool elm_prefs_page_item_value_set(Evas_Object *it,
102 const Elm_Prefs_Item_Iface *iface,
103 Eina_Bool val);
104void elm_prefs_horizontal_page_common_pack(Evas_Object *,
105 Evas_Object *,
106 const Elm_Prefs_Item_Iface *);
107void elm_prefs_horizontal_page_common_pack_before(Evas_Object *,
108 Evas_Object *,
109 Evas_Object *,
110 const Elm_Prefs_Item_Iface *);
111void elm_prefs_horizontal_page_common_pack_after(Evas_Object *,
112 Evas_Object *,
113 Evas_Object *,
114 const Elm_Prefs_Item_Iface *);
115void elm_prefs_vertical_page_common_pack(Evas_Object *,
116 Evas_Object *,
117 const Elm_Prefs_Item_Iface *);
118void elm_prefs_vertical_page_common_pack_before(Evas_Object *,
119 Evas_Object *,
120 Evas_Object *,
121 const Elm_Prefs_Item_Iface *);
122void elm_prefs_vertical_page_common_pack_after(Evas_Object *,
123 Evas_Object *,
124 Evas_Object *,
125 const Elm_Prefs_Item_Iface *);
126void elm_prefs_page_common_unpack(Evas_Object *,
127 Evas_Object *);