summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-06-21 17:54:56 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-06-24 16:57:04 +0900
commit47a1fae200c824672c06c6b63a098dc54af033a4 (patch)
tree530596e24977f3780a213b2af34fffe1d437724c /src
parente1d5d5e4a1817e148e51a8e1ae15969f826f4b1d (diff)
efl: Introduce general Efl.Config API
This is to port elm_config to EO APIs. The current implementation relies on the legacy API, by simply forwarding calls. The new API is simply efl_config_set("config_name", value) where value is an Eina_Value (aka. generic_value). The C interface proposes a few helpers like config_int_set, config_double_set, etc... Unfortunately at the moment, not all config options are supported, as some rely on more complex types: - lists - color class and multiple arguments - unset functions - enums Profiles are also not handled at this point. @feature
Diffstat (limited to '')
-rw-r--r--src/Makefile_Efl.am2
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/efl/Efl.h5
-rw-r--r--src/lib/efl/interfaces/efl_config.c128
-rw-r--r--src/lib/efl/interfaces/efl_config.eo119
-rw-r--r--src/lib/elementary/efl_config_internal.eo10
-rw-r--r--src/lib/elementary/efl_ui_win.eo2
-rw-r--r--src/lib/elementary/elm_config.c266
-rw-r--r--src/lib/elementary/elm_priv.h1
-rw-r--r--src/lib/elementary/elm_widget.c3
-rw-r--r--src/tests/elementary/elm_suite.c1
-rw-r--r--src/tests/elementary/elm_suite.h1
-rw-r--r--src/tests/elementary/elm_test_config.c120
13 files changed, 659 insertions, 1 deletions
diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am
index c8fe1f001d..0a3e52125b 100644
--- a/src/Makefile_Efl.am
+++ b/src/Makefile_Efl.am
@@ -9,6 +9,7 @@ efl_eolian_legacy_files = \
9 9
10efl_eolian_files = \ 10efl_eolian_files = \
11 lib/efl/interfaces/efl_canvas.eo \ 11 lib/efl/interfaces/efl_canvas.eo \
12 lib/efl/interfaces/efl_config.eo \
12 lib/efl/interfaces/efl_control.eo \ 13 lib/efl/interfaces/efl_control.eo \
13 lib/efl/interfaces/efl_file.eo \ 14 lib/efl/interfaces/efl_file.eo \
14 lib/efl/interfaces/efl_image_load.eo \ 15 lib/efl/interfaces/efl_image_load.eo \
@@ -82,6 +83,7 @@ lib_LTLIBRARIES += lib/efl/libefl.la
82 83
83lib_efl_libefl_la_SOURCES = \ 84lib_efl_libefl_la_SOURCES = \
84lib/efl/interfaces/efl_interfaces_main.c \ 85lib/efl/interfaces/efl_interfaces_main.c \
86lib/efl/interfaces/efl_config.c \
85lib/efl/interfaces/efl_model_common.c \ 87lib/efl/interfaces/efl_model_common.c \
86lib/efl/interfaces/efl_gfx_shape.c \ 88lib/efl/interfaces/efl_gfx_shape.c \
87lib/efl/interfaces/efl_vpath_file.c \ 89lib/efl/interfaces/efl_vpath_file.c \
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 27948dea72..fbe6e089c3 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -146,6 +146,7 @@ elm_public_eolian_files = \
146# Private classes (not exposed or shipped) 146# Private classes (not exposed or shipped)
147elm_private_eolian_files = \ 147elm_private_eolian_files = \
148 lib/elementary/efl_ui_internal_text_interactive.eo \ 148 lib/elementary/efl_ui_internal_text_interactive.eo \
149 lib/elementary/efl_config_internal.eo \
149 $(NULL) 150 $(NULL)
150 151
151# Legacy classes - not part of public EO API 152# Legacy classes - not part of public EO API
@@ -1338,6 +1339,7 @@ tests_elementary_elm_suite_SOURCES = \
1338 tests/elementary/elm_test_slideshow.c \ 1339 tests/elementary/elm_test_slideshow.c \
1339 tests/elementary/elm_test_spinner.c \ 1340 tests/elementary/elm_test_spinner.c \
1340 tests/elementary/elm_test_plug.c \ 1341 tests/elementary/elm_test_plug.c \
1342 tests/elementary/elm_test_config.c \
1341 tests/elementary/elm_code_file_test_load.c \ 1343 tests/elementary/elm_code_file_test_load.c \
1342 tests/elementary/elm_code_file_test_memory.c \ 1344 tests/elementary/elm_code_file_test_memory.c \
1343 tests/elementary/elm_code_test_basic.c \ 1345 tests/elementary/elm_code_test_basic.c \
diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h
index c5ff46b1ea..731f318c88 100644
--- a/src/lib/efl/Efl.h
+++ b/src/lib/efl/Efl.h
@@ -68,6 +68,7 @@ typedef struct tm Efl_Time;
68typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; 68typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
69 69
70/* Interfaces */ 70/* Interfaces */
71#include "interfaces/efl_config.eo.h"
71#include "interfaces/efl_control.eo.h" 72#include "interfaces/efl_control.eo.h"
72#include "interfaces/efl_file.eo.h" 73#include "interfaces/efl_file.eo.h"
73#include "interfaces/efl_image.eo.h" 74#include "interfaces/efl_image.eo.h"
@@ -140,6 +141,10 @@ static inline void efl_gfx_color16_type_set(Efl_Gfx_Color *color,
140#include "interfaces/efl_input_interface.eo.h" 141#include "interfaces/efl_input_interface.eo.h"
141#include "interfaces/efl_event.eo.h" 142#include "interfaces/efl_event.eo.h"
142 143
144#ifdef EFL_EFL_BUILD
145EAPI void __efl_internal_elm_config_set(Efl_Config *cfg);
146#endif
147
143#else 148#else
144 149
145#ifndef EFL_NOLEGACY_API_SUPPORT 150#ifndef EFL_NOLEGACY_API_SUPPORT
diff --git a/src/lib/efl/interfaces/efl_config.c b/src/lib/efl/interfaces/efl_config.c
new file mode 100644
index 0000000000..75d8388d44
--- /dev/null
+++ b/src/lib/efl/interfaces/efl_config.c
@@ -0,0 +1,128 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Efl.h>
6
7static Efl_Config *_main_config = NULL;
8
9EAPI void
10__efl_internal_elm_config_set(Efl_Config *cfg)
11{
12 _main_config = cfg;
13}
14
15EOLIAN static Eina_Bool
16_efl_config_config_bool_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, Eina_Bool val)
17{
18 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_UCHAR);
19 Eina_Bool b;
20 eina_value_set(v, val);
21 b = efl_config_set(obj, name, v);
22 eina_value_free(v);
23 return b;
24}
25
26EOLIAN static Eina_Bool
27_efl_config_config_bool_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
28{
29 Eina_Value *v = efl_config_get(obj, name);
30 Eina_Bool b = 0;
31 eina_value_get(v, &b);
32 eina_value_free(v);
33 return b;
34}
35
36EOLIAN static Eina_Bool
37_efl_config_config_int_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, int val)
38{
39 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_INT);
40 Eina_Bool b;
41 eina_value_set(v, val);
42 b = efl_config_set(obj, name, v);
43 eina_value_free(v);
44 return b;
45}
46
47EOLIAN static int
48_efl_config_config_int_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
49{
50 Eina_Value *v = efl_config_get(obj, name);
51 int b = 0;
52 eina_value_get(v, &b);
53 eina_value_free(v);
54 return b;
55}
56
57EOLIAN static Eina_Bool
58_efl_config_config_uint_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, unsigned int val)
59{
60 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_UINT);
61 Eina_Bool b;
62 eina_value_set(v, val);
63 b = efl_config_set(obj, name, v);
64 eina_value_free(v);
65 return b;
66}
67
68EOLIAN static unsigned int
69_efl_config_config_uint_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
70{
71 Eina_Value *v = efl_config_get(obj, name);
72 unsigned int b = 0;
73 eina_value_get(v, &b);
74 eina_value_free(v);
75 return b;
76}
77
78EOLIAN static Eina_Bool
79_efl_config_config_double_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, double val)
80{
81 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
82 Eina_Bool b;
83 eina_value_set(v, val);
84 b = efl_config_set(obj, name, v);
85 eina_value_free(v);
86 return b;
87}
88
89EOLIAN static double
90_efl_config_config_double_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
91{
92 Eina_Value *v = efl_config_get(obj, name);
93 double b = 0;
94 eina_value_get(v, &b);
95 eina_value_free(v);
96 return b;
97}
98
99EOLIAN static Eina_Bool
100_efl_config_config_string_set(Eo *obj, void *_pd EINA_UNUSED, const char *name, const char *val)
101{
102 Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_STRING);
103 Eina_Bool b;
104 eina_value_set(v, val);
105 b = efl_config_set(obj, name, v);
106 eina_value_free(v);
107 return b;
108}
109
110EOLIAN static const char *
111_efl_config_config_string_get(Eo *obj, void *_pd EINA_UNUSED, const char *name)
112{
113 Eina_Value *v = efl_config_get(obj, name);
114 Eina_Stringshare *s;
115 const char *b = 0;
116 eina_value_get(v, &b);
117 s = eina_stringshare_add(b);
118 eina_value_free(v);
119 return s;
120}
121
122EOLIAN static Efl_Config *
123_efl_config_config_global_get(Eo *klass EINA_UNUSED, void *_pd EINA_UNUSED)
124{
125 return _main_config;
126}
127
128#include "interfaces/efl_config.eo.c"
diff --git a/src/lib/efl/interfaces/efl_config.eo b/src/lib/efl/interfaces/efl_config.eo
new file mode 100644
index 0000000000..97266723c8
--- /dev/null
+++ b/src/lib/efl/interfaces/efl_config.eo
@@ -0,0 +1,119 @@
1mixin Efl.Config (Eo.Interface)
2{
3 [[A generic configuration interface, that holds key-value pairs.]]
4 data: null;
5 methods {
6 /* FIXME: make this a property -- @own is a problem */
7 /*
8 @property config @virtual_pure {
9 [[Holds a generic value under a given key.
10
11 Most common value types are: string, int, uint, bool, double.
12 ]]
13 keys {
14 name: string;
15 }
16 values {
17 val: const(generic_value)*;
18 }
19 get {
20 return: free(own(generic_value *), eina_value_free);
21 }
22 }
23 */
24 config_set @virtual_pure {
25 params {
26 name: string;
27 val: const(generic_value)*;
28 }
29 return: bool; [[$false in case of error: value type was invalid, the
30 config can't be changed, config does not exist...]]
31 }
32 config_get @virtual_pure @const {
33 params {
34 name: string;
35 }
36 return: free(own(generic_value *), eina_value_free);
37 }
38 config_list_get @virtual_pure @const {
39 [[Returns a list of generic values under a given key.]]
40 params {
41 @in name: string;
42 }
43 return: free(own(iterator<generic_value*>), eina_iterator_free);
44 }
45 @property config_bool {
46 [[Helper for boolean properties (most useful in C).]]
47 keys {
48 name: string;
49 }
50 values {
51 val: bool;
52 }
53 get {}
54 set { return: bool; }
55 }
56 @property config_int {
57 [[Helper for int properties (most useful in C).]]
58 keys {
59 name: string;
60 }
61 values {
62 val: int;
63 }
64 get {}
65 set { return: bool; }
66 }
67 @property config_uint {
68 [[Helper for unsigned int properties (most useful in C).]]
69 keys {
70 name: string;
71 }
72 values {
73 val: uint;
74 }
75 get {}
76 set { return: bool; }
77 }
78 @property config_double {
79 [[Helper for double properties (most useful in C).]]
80 keys {
81 name: string;
82 }
83 values {
84 val: double;
85 }
86 get {}
87 set { return: bool; }
88 }
89 @property config_string {
90 [[Helper for string properties (most useful in C).]]
91 keys {
92 name: string;
93 }
94 values {
95 val: string;
96 }
97 set { return: bool; }
98 }
99 config_string_get {
100 [[Helper for string properties (most useful in C).]]
101 params {
102 name: string;
103 }
104 return: stringshare;
105 }
106 config_global_get @class {
107 [[Get a handle on the main configuration.]]
108 return: Efl.Config;
109 }
110 }
111}
112
113/* NOTES:
114 - Elm_Color_Class list -> no need to return the struct, only the name matters
115 but also provide func to get desc from name
116 - Elm_Color_Overlay -> see with Jee-Yong and his color patch (common intf)
117 - elm_config_font_overlay_set -> ?
118 - what else?
119*/
diff --git a/src/lib/elementary/efl_config_internal.eo b/src/lib/elementary/efl_config_internal.eo
new file mode 100644
index 0000000000..b7d13f0a03
--- /dev/null
+++ b/src/lib/elementary/efl_config_internal.eo
@@ -0,0 +1,10 @@
1class Efl.Config.Internal (Eo.Base, Efl.Config)
2{
3 [[Internal class translating between Efl.Config and legacy elm_config.]]
4 data: null;
5 implements {
6 Efl.Config.config_set;
7 Efl.Config.config_get;
8 Efl.Config.config_list_get;
9 }
10}
diff --git a/src/lib/elementary/efl_ui_win.eo b/src/lib/elementary/efl_ui_win.eo
index b17add4805..590952f24d 100644
--- a/src/lib/elementary/efl_ui_win.eo
+++ b/src/lib/elementary/efl_ui_win.eo
@@ -146,7 +146,7 @@ enum Efl.Ui.Win.Urgent_Mode
146class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window, 146class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
147 Elm.Interface.Atspi_Widget_Action, Efl.Pack, 147 Elm.Interface.Atspi_Widget_Action, Efl.Pack,
148 Efl.Input.State, Efl.Input.Interface, Efl.Screen, 148 Efl.Input.State, Efl.Input.Interface, Efl.Screen,
149 Efl.Gfx.Size.Hint, Efl.Text) 149 Efl.Gfx.Size.Hint, Efl.Text, Efl.Config)
150{ 150{
151 legacy_prefix: elm_win; 151 legacy_prefix: elm_win;
152 eo_prefix: efl_ui_win; 152 eo_prefix: efl_ui_win;
diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c
index 7dcd06b22b..9d08a2e50a 100644
--- a/src/lib/elementary/elm_config.c
+++ b/src/lib/elementary/elm_config.c
@@ -6,9 +6,13 @@
6#include "elm_priv.h" 6#include "elm_priv.h"
7#include <pwd.h> 7#include <pwd.h>
8 8
9#include "efl_config_internal.eo.h"
10
9EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0; 11EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0;
12EAPI void __efl_internal_elm_config_set(Efl_Config *cfg);
10 13
11Elm_Config *_elm_config = NULL; 14Elm_Config *_elm_config = NULL;
15Efl_Config *_efl_config_obj = NULL;
12static char *_elm_profile = NULL; 16static char *_elm_profile = NULL;
13static Eet_Data_Descriptor *_config_edd = NULL; 17static Eet_Data_Descriptor *_config_edd = NULL;
14static Eet_Data_Descriptor *_config_font_overlay_edd = NULL; 18static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
@@ -1678,6 +1682,8 @@ _config_system_load(void)
1678static void 1682static void
1679_config_load(void) 1683_config_load(void)
1680{ 1684{
1685 _efl_config_obj = eo_add(EFL_CONFIG_INTERNAL_CLASS, NULL);
1686 __efl_internal_elm_config_set(_efl_config_obj);
1681 _elm_config = _config_user_load(); 1687 _elm_config = _config_user_load();
1682 if (_elm_config) 1688 if (_elm_config)
1683 { 1689 {
@@ -4236,6 +4242,8 @@ _elm_config_profile_set(const char *profile)
4236void 4242void
4237_elm_config_shutdown(void) 4243_elm_config_shutdown(void)
4238{ 4244{
4245 ELM_SAFE_FREE(_efl_config_obj, eo_del);
4246 __efl_internal_elm_config_set(NULL);
4239 ELM_SAFE_FREE(_elm_config, _config_free); 4247 ELM_SAFE_FREE(_elm_config, _config_free);
4240 ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del); 4248 ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del);
4241 ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del); 4249 ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del);
@@ -4247,3 +4255,261 @@ _elm_config_shutdown(void)
4247 4255
4248 ELM_SAFE_FREE(_elm_key_bindings, eina_hash_free); 4256 ELM_SAFE_FREE(_elm_key_bindings, eina_hash_free);
4249} 4257}
4258
4259
4260/* Efl.Config implementation */
4261
4262typedef const char * cstring;
4263
4264static inline Eina_Bool
4265_eina_value_to_int(const Eina_Value *val, int *i)
4266{
4267 Eina_Value *ival = eina_value_new(EINA_VALUE_TYPE_INT);
4268 Eina_Bool ret = EINA_TRUE;
4269 if (!eina_value_convert(val, ival))
4270 ret = EINA_FALSE;
4271 else
4272 ret = eina_value_get(ival, i);
4273 eina_value_free(ival);
4274 return ret;
4275}
4276
4277static inline Eina_Bool
4278_eina_value_to_cstring(const Eina_Value *val, cstring *s)
4279{
4280 Eina_Value *sval = eina_value_new(EINA_VALUE_TYPE_STRING);
4281 Eina_Bool ret = EINA_TRUE;
4282 if (!eina_value_convert(val, sval))
4283 ret = EINA_FALSE;
4284 else
4285 ret = eina_value_get(sval, s);
4286 eina_value_free(sval);
4287 return ret;
4288}
4289
4290EOLIAN static Eina_Bool
4291_efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
4292 const char *name, const Eina_Value *val)
4293{
4294 if (!name) return EINA_FALSE;
4295 // TODO: if (!val) reset to default
4296
4297#define CONFIG_SET(opt, primityp, valtyp, alttyp) do { \
4298 if (!strcmp(name, #opt)) \
4299 { \
4300 primityp v = 0; \
4301 alttyp alt = 0; \
4302 const Eina_Value_Type *typ = EINA_VALUE_TYPE_ ## valtyp; \
4303 if (eina_value_type_get(val) == typ) \
4304 { \
4305 if (!eina_value_get(val, &v)) return EINA_FALSE; \
4306 } \
4307 else if (_eina_value_to_ ## alttyp(val, &alt)) \
4308 { \
4309 v = alt; \
4310 } \
4311 else \
4312 { \
4313 ERR("Invalid value type for config '%s' (got %s wanted %s)", \
4314 name, eina_value_type_name_get(eina_value_type_get(val)), \
4315 eina_value_type_name_get(EINA_VALUE_TYPE_ ## valtyp)); \
4316 return EINA_FALSE; \
4317 } \
4318 elm_config_ ## opt ## _set(v); \
4319 return EINA_TRUE; \
4320 } \
4321 } while (0)
4322
4323#define CONFIG_SETB(opt) CONFIG_SET(opt, Eina_Bool, UCHAR, int)
4324#define CONFIG_SETI(opt) CONFIG_SET(opt, int, INT, int)
4325#define CONFIG_SETU(opt) CONFIG_SET(opt, unsigned int, UINT, int)
4326#define CONFIG_SETD(opt) CONFIG_SET(opt, double, DOUBLE, int)
4327#define CONFIG_SETS(opt) CONFIG_SET(opt, const char *, STRING, cstring)
4328
4329 CONFIG_SETB(scroll_bounce_enabled);
4330 CONFIG_SETD(scroll_bounce_friction);
4331 CONFIG_SETD(scroll_page_scroll_friction);
4332 CONFIG_SETB(context_menu_disabled);
4333 CONFIG_SETD(scroll_bring_in_scroll_friction);
4334 CONFIG_SETD(scroll_zoom_friction);
4335 CONFIG_SETB(scroll_thumbscroll_enabled);
4336 CONFIG_SETU(scroll_thumbscroll_threshold);
4337 CONFIG_SETU(scroll_thumbscroll_hold_threshold);
4338 CONFIG_SETD(scroll_thumbscroll_momentum_threshold);
4339 CONFIG_SETU(scroll_thumbscroll_flick_distance_tolerance);
4340 CONFIG_SETD(scroll_thumbscroll_friction);
4341 CONFIG_SETD(scroll_thumbscroll_min_friction);
4342 CONFIG_SETD(scroll_thumbscroll_friction_standard);
4343 CONFIG_SETD(scroll_thumbscroll_border_friction);
4344 CONFIG_SETD(scroll_thumbscroll_sensitivity_friction);
4345 CONFIG_SETB(scroll_thumbscroll_smooth_start);
4346 CONFIG_SETB(scroll_animation_disable);
4347 CONFIG_SETD(scroll_accel_factor);
4348 CONFIG_SETD(scroll_thumbscroll_smooth_amount);
4349 CONFIG_SETD(scroll_thumbscroll_smooth_time_window);
4350 CONFIG_SETD(scroll_thumbscroll_acceleration_threshold);
4351 CONFIG_SETD(scroll_thumbscroll_acceleration_time_limit);
4352 CONFIG_SETD(scroll_thumbscroll_acceleration_weight);
4353 //focus_autoscroll_mode Elm_Focus_Autoscroll_Mode mode);
4354 //slider_indicator_visible_mode Elm_Slider_Indicator_Visible_Mode mode);
4355 CONFIG_SETD(longpress_timeout);
4356 //softcursor_mode Elm_Softcursor_Mode mode);
4357 CONFIG_SETD(tooltip_delay);
4358 CONFIG_SETB(cursor_engine_only);
4359 CONFIG_SETD(scale);
4360 CONFIG_SETS(icon_theme);
4361 CONFIG_SETB(password_show_last);
4362 CONFIG_SETD(password_show_last_timeout);
4363 CONFIG_SETS(preferred_engine);
4364 CONFIG_SETS(accel_preference);
4365 //font_overlay const char *text_class, const char *font, Evas_Font_Size size);
4366 CONFIG_SETB(access);
4367 CONFIG_SETB(selection_unfocused_clear);
4368 //elm_config.h:EAPI void elm_config_font_overlay_unset(const char *text_class);
4369 CONFIG_SETI(font_hint_type);
4370 CONFIG_SETI(finger_size);
4371 CONFIG_SETI(cache_flush_interval);
4372 CONFIG_SETB(cache_flush_enabled);
4373 CONFIG_SETI(cache_font_cache_size);
4374 CONFIG_SETI(cache_image_cache_size);
4375 CONFIG_SETI(cache_edje_file_cache_size);
4376 CONFIG_SETI(cache_edje_collection_cache_size);
4377 CONFIG_SETB(vsync);
4378 CONFIG_SETB(accel_preference_override);
4379 CONFIG_SETB(focus_highlight_enabled);
4380 CONFIG_SETB(focus_highlight_animate);
4381 CONFIG_SETB(focus_highlight_clip_disabled);
4382 //focus_move_policy Elm_Focus_Move_Policy policy);
4383 CONFIG_SETB(item_select_on_focus_disabled);
4384 CONFIG_SETB(first_item_focus_on_first_focusin);
4385 CONFIG_SETB(mirrored);
4386 CONFIG_SETB(clouseau_enabled);
4387 CONFIG_SETD(glayer_long_tap_start_timeout);
4388 CONFIG_SETD(glayer_double_tap_timeout);
4389 //color_overlay const char *color_class,
4390 //elm_config.h:EAPI void elm_config_color_overlay_unset(const char *color_class);
4391 CONFIG_SETB(magnifier_enable);
4392 CONFIG_SETD(magnifier_scale);
4393 //audio_mute Edje_Channel channel,);
4394 CONFIG_SETB(window_auto_focus_enable);
4395 CONFIG_SETB(window_auto_focus_animate);
4396 CONFIG_SETB(popup_scrollable);
4397 CONFIG_SETB(atspi_mode);
4398 CONFIG_SETD(transition_duration_factor);
4399 CONFIG_SETS(web_backend);
4400
4401 ERR("Config '%s' does not exist", name);
4402 return EINA_FALSE;
4403}
4404
4405EOLIAN static Eina_Value *
4406_efl_config_internal_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
4407 const char *name)
4408{
4409 Eina_Value *val = NULL;
4410
4411 if (!name) return NULL;
4412
4413 // NOTE: returning INT instead of UINT for unsigned int types
4414
4415#define CONFIG_GET(opt, primityp, valtyp) do { \
4416 if (!strcmp(name, #opt)) \
4417 { \
4418 val = eina_value_new(EINA_VALUE_TYPE_ ## valtyp); \
4419 eina_value_set(val, elm_config_ ## opt ## _get()); \
4420 return val; \
4421 } \
4422 } while (0)
4423
4424#define CONFIG_GETB(opt) CONFIG_GET(opt, Eina_Bool, UCHAR)
4425#define CONFIG_GETI(opt) CONFIG_GET(opt, int, INT)
4426#define CONFIG_GETU(opt) CONFIG_GET(opt, int, INT)
4427#define CONFIG_GETD(opt) CONFIG_GET(opt, double, DOUBLE)
4428#define CONFIG_GETS(opt) CONFIG_GET(opt, const char *, STRING)
4429
4430 CONFIG_GETB(scroll_bounce_enabled);
4431 CONFIG_GETD(scroll_bounce_friction);
4432 CONFIG_GETD(scroll_page_scroll_friction);
4433 CONFIG_GETB(context_menu_disabled);
4434 CONFIG_GETD(scroll_bring_in_scroll_friction);
4435 CONFIG_GETD(scroll_zoom_friction);
4436 CONFIG_GETB(scroll_thumbscroll_enabled);
4437 CONFIG_GETU(scroll_thumbscroll_threshold);
4438 CONFIG_GETU(scroll_thumbscroll_hold_threshold);
4439 CONFIG_GETD(scroll_thumbscroll_momentum_threshold);
4440 CONFIG_GETU(scroll_thumbscroll_flick_distance_tolerance);
4441 CONFIG_GETD(scroll_thumbscroll_friction);
4442 CONFIG_GETD(scroll_thumbscroll_min_friction);
4443 CONFIG_GETD(scroll_thumbscroll_friction_standard);
4444 CONFIG_GETD(scroll_thumbscroll_border_friction);
4445 CONFIG_GETD(scroll_thumbscroll_sensitivity_friction);
4446 CONFIG_GETB(scroll_thumbscroll_smooth_start);
4447 CONFIG_GETB(scroll_animation_disable);
4448 CONFIG_GETD(scroll_accel_factor);
4449 CONFIG_GETD(scroll_thumbscroll_smooth_amount);
4450 CONFIG_GETD(scroll_thumbscroll_smooth_time_window);
4451 CONFIG_GETD(scroll_thumbscroll_acceleration_threshold);
4452 CONFIG_GETD(scroll_thumbscroll_acceleration_time_limit);
4453 CONFIG_GETD(scroll_thumbscroll_acceleration_weight);
4454 //focus_autoscroll_mode
4455 //slider_indicator_visible_mode
4456 CONFIG_GETD(longpress_timeout);
4457 //softcursor_mode
4458 CONFIG_GETD(tooltip_delay);
4459 CONFIG_GETB(cursor_engine_only);
4460 CONFIG_GETD(scale);
4461 CONFIG_GETS(icon_theme);
4462 CONFIG_GETB(password_show_last);
4463 CONFIG_GETD(password_show_last_timeout);
4464 CONFIG_GETS(preferred_engine);
4465 CONFIG_GETS(accel_preference);
4466 //font_overlay
4467 CONFIG_GETB(access);
4468 CONFIG_GETB(selection_unfocused_clear);
4469 //elm_config_font_overlay_unset
4470 //CONFIG_GETI(font_hint_type); // this has no get!
4471 CONFIG_GETI(finger_size);
4472 CONFIG_GETI(cache_flush_interval);
4473 CONFIG_GETB(cache_flush_enabled);
4474 CONFIG_GETI(cache_font_cache_size);
4475 CONFIG_GETI(cache_image_cache_size);
4476 CONFIG_GETI(cache_edje_file_cache_size);
4477 CONFIG_GETI(cache_edje_collection_cache_size);
4478 CONFIG_GETB(vsync);
4479 CONFIG_GETB(accel_preference_override);
4480 CONFIG_GETB(focus_highlight_enabled);
4481 CONFIG_GETB(focus_highlight_animate);
4482 CONFIG_GETB(focus_highlight_clip_disabled);
4483 //focus_move_policy
4484 CONFIG_GETB(item_select_on_focus_disabled);
4485 CONFIG_GETB(first_item_focus_on_first_focusin);
4486 CONFIG_GETB(mirrored);
4487 CONFIG_GETB(clouseau_enabled);
4488 CONFIG_GETD(glayer_long_tap_start_timeout);
4489 CONFIG_GETD(glayer_double_tap_timeout);
4490 //color_overlay
4491 //color_overlay_unset
4492 CONFIG_GETB(magnifier_enable);
4493 CONFIG_GETD(magnifier_scale);
4494 //audio_mute
4495 CONFIG_GETB(window_auto_focus_enable);
4496 CONFIG_GETB(window_auto_focus_animate);
4497 CONFIG_GETB(popup_scrollable);
4498 CONFIG_GETB(atspi_mode);
4499 CONFIG_GETD(transition_duration_factor);
4500 CONFIG_GETS(web_backend);
4501
4502 ERR("Config '%s' does not exist", name);
4503 return NULL;
4504}
4505
4506EOLIAN static Eina_Iterator *
4507_efl_config_internal_efl_config_config_list_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
4508 const char *name)
4509{
4510 // Not implemented: none of the elm_config functions returns a list of primitive types
4511 (void) name;
4512 return NULL;
4513}
4514
4515#include "efl_config_internal.eo.c"
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index ff33e4de99..09f3ce9249 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -567,6 +567,7 @@ Eina_Bool _elm_config_accel_preference_parse(const char *pref, Eina_Stringshare
567 567
568extern char *_elm_appname; 568extern char *_elm_appname;
569extern Elm_Config *_elm_config; 569extern Elm_Config *_elm_config;
570extern Efl_Config *_efl_config_obj;
570extern const char *_elm_data_dir; 571extern const char *_elm_data_dir;
571extern const char *_elm_lib_dir; 572extern const char *_elm_lib_dir;
572extern int _elm_log_dom; 573extern int _elm_log_dom;
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index 8d1d8b28e8..744de60866 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -6073,6 +6073,9 @@ _elm_widget_eo_base_provider_find(Eo *obj, Elm_Widget_Smart_Data *pd, const Eo_B
6073{ 6073{
6074 Eo_Base *lookup = NULL; 6074 Eo_Base *lookup = NULL;
6075 6075
6076 if (klass == EFL_CONFIG_MIXIN)
6077 return _efl_config_obj;
6078
6076 if (pd->provider_lookup) return NULL; 6079 if (pd->provider_lookup) return NULL;
6077 pd->provider_lookup = EINA_TRUE; 6080 pd->provider_lookup = EINA_TRUE;
6078 6081
diff --git a/src/tests/elementary/elm_suite.c b/src/tests/elementary/elm_suite.c
index a612e7edc3..0507325a5c 100644
--- a/src/tests/elementary/elm_suite.c
+++ b/src/tests/elementary/elm_suite.c
@@ -8,6 +8,7 @@
8 8
9static const Efl_Test_Case etc[] = { 9static const Efl_Test_Case etc[] = {
10 { "Elementary", elm_test_init }, 10 { "Elementary", elm_test_init },
11 { "elm_config", elm_test_config },
11 { "elm_check", elm_test_check }, 12 { "elm_check", elm_test_check },
12 { "elm_colorselector", elm_test_colorselector }, 13 { "elm_colorselector", elm_test_colorselector },
13 { "elm_entry", elm_test_entry}, 14 { "elm_entry", elm_test_entry},
diff --git a/src/tests/elementary/elm_suite.h b/src/tests/elementary/elm_suite.h
index bf87d1b622..076bb60154 100644
--- a/src/tests/elementary/elm_suite.h
+++ b/src/tests/elementary/elm_suite.h
@@ -5,6 +5,7 @@
5#include "elm_test_helper.h" 5#include "elm_test_helper.h"
6 6
7void elm_test_init(TCase *tc); 7void elm_test_init(TCase *tc);
8void elm_test_config(TCase *tc);
8void elm_test_check(TCase *tc); 9void elm_test_check(TCase *tc);
9void elm_test_colorselector(TCase *tc); 10void elm_test_colorselector(TCase *tc);
10void elm_test_entry(TCase *tc); 11void elm_test_entry(TCase *tc);
diff --git a/src/tests/elementary/elm_test_config.c b/src/tests/elementary/elm_test_config.c
new file mode 100644
index 0000000000..ed9745c263
--- /dev/null
+++ b/src/tests/elementary/elm_test_config.c
@@ -0,0 +1,120 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6#include <Elementary.h>
7#include "elm_suite.h"
8
9#include <stdbool.h>
10typedef unsigned int uint;
11
12START_TEST (elm_config_eoapi)
13{
14 elm_init(1, NULL);
15
16 Eo *cfg = efl_config_global_get(EFL_CONFIG_MIXIN);
17 fail_if(!cfg);
18
19#define CONFIG_CHK(opt, typ, val) do { \
20 typ old = elm_config_ ## opt ## _get(); \
21 fail_if(old != efl_config_ ## typ ## _get(cfg, #opt)); \
22 fail_if(!efl_config_ ## typ ## _set(cfg, #opt, val)); \
23 fail_if(elm_config_ ## opt ## _get() != val); \
24 fail_if(efl_config_ ## typ ## _get(cfg, #opt) != val); \
25 } while (0)
26
27#define CONFIG_CHKB(opt, val) CONFIG_CHK(opt, bool, val)
28#define CONFIG_CHKI(opt, val) CONFIG_CHK(opt, int, val)
29#define CONFIG_CHKU(opt, val) CONFIG_CHK(opt, uint, val)
30#define CONFIG_CHKD(opt, val) CONFIG_CHK(opt, double, val)
31
32 // note: leaks badly
33#define CONFIG_CHKS(opt, val) do { \
34 const char *old = elm_config_ ## opt ## _get(); \
35 fail_if(!eina_streq(old, efl_config_string_get(cfg, #opt))); \
36 fail_if(!efl_config_string_set(cfg, #opt, val)); \
37 fail_if(!eina_streq(elm_config_ ## opt ## _get(), val)); \
38 fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
39 } while (0)
40
41 CONFIG_CHKB(scroll_bounce_enabled, !old);
42 CONFIG_CHKD(scroll_bounce_friction, 0);
43 CONFIG_CHKD(scroll_page_scroll_friction, 0);
44 CONFIG_CHKB(context_menu_disabled, !old);
45 CONFIG_CHKD(scroll_bring_in_scroll_friction, 0);
46 CONFIG_CHKD(scroll_zoom_friction, 0);
47 CONFIG_CHKB(scroll_thumbscroll_enabled, !old);
48 CONFIG_CHKU(scroll_thumbscroll_threshold, 0);
49 CONFIG_CHKU(scroll_thumbscroll_hold_threshold, 0);
50 CONFIG_CHKD(scroll_thumbscroll_momentum_threshold, 0);
51 CONFIG_CHKU(scroll_thumbscroll_flick_distance_tolerance, 0);
52 CONFIG_CHKD(scroll_thumbscroll_friction, 0);
53 CONFIG_CHKD(scroll_thumbscroll_min_friction, 0);
54 CONFIG_CHKD(scroll_thumbscroll_friction_standard, 0);
55 CONFIG_CHKD(scroll_thumbscroll_border_friction, 0);
56 CONFIG_CHKD(scroll_thumbscroll_sensitivity_friction, 1.0);
57 CONFIG_CHKB(scroll_thumbscroll_smooth_start, 0);
58 CONFIG_CHKB(scroll_animation_disable, 0);
59 CONFIG_CHKD(scroll_accel_factor, 0);
60 CONFIG_CHKD(scroll_thumbscroll_smooth_amount, 0);
61 CONFIG_CHKD(scroll_thumbscroll_smooth_time_window, 0);
62 CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
63 CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
64 CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
65 //focus_autoscroll_mode
66 //slider_indicator_visible_mode
67 CONFIG_CHKD(longpress_timeout, 0);
68 //softcursor_mode
69 CONFIG_CHKD(tooltip_delay, 0);
70 CONFIG_CHKB(cursor_engine_only, 0);
71 CONFIG_CHKD(scale, 0);
72 CONFIG_CHKS(icon_theme, ELM_CONFIG_ICON_THEME_ELEMENTARY);
73 CONFIG_CHKB(password_show_last, 0);
74 CONFIG_CHKD(password_show_last_timeout, 0);
75 CONFIG_CHKS(preferred_engine, 0);
76 CONFIG_CHKS(accel_preference, 0);
77 //font_overlay
78 CONFIG_CHKB(access, 0);
79 CONFIG_CHKB(selection_unfocused_clear, 0);
80 //elm_config_font_overlay_unset
81 //CONFIG_CHKI(font_hint_type, 0); // this has no get!
82 CONFIG_CHKI(finger_size, 0);
83 CONFIG_CHKI(cache_flush_interval, 10);
84 CONFIG_CHKB(cache_flush_enabled, !old);
85 CONFIG_CHKI(cache_font_cache_size, 0);
86 CONFIG_CHKI(cache_image_cache_size, 0);
87 CONFIG_CHKI(cache_edje_file_cache_size, 0);
88 CONFIG_CHKI(cache_edje_collection_cache_size, 0);
89 CONFIG_CHKB(vsync, 0);
90 CONFIG_CHKB(accel_preference_override, 0);
91 CONFIG_CHKB(focus_highlight_enabled, !old);
92 CONFIG_CHKB(focus_highlight_animate, 0);
93 CONFIG_CHKB(focus_highlight_clip_disabled, !old);
94 //focus_move_policy
95 CONFIG_CHKB(item_select_on_focus_disabled, !old);
96 CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
97 CONFIG_CHKB(mirrored, 0);
98 CONFIG_CHKB(clouseau_enabled, !old);
99 CONFIG_CHKD(glayer_long_tap_start_timeout, 0);
100 CONFIG_CHKD(glayer_double_tap_timeout, 0);
101 //color_overlay
102 //color_overlay_unset
103 CONFIG_CHKB(magnifier_enable, 0);
104 CONFIG_CHKD(magnifier_scale, 0);
105 //audio_mute
106 CONFIG_CHKB(window_auto_focus_enable, 0);
107 CONFIG_CHKB(window_auto_focus_animate, 0);
108 CONFIG_CHKB(popup_scrollable, 0);
109 CONFIG_CHKB(atspi_mode, 0);
110 CONFIG_CHKD(transition_duration_factor, 0);
111 CONFIG_CHKS(web_backend, old); // no value change (requires web support)
112
113 elm_shutdown();
114}
115END_TEST
116
117void elm_test_config(TCase *tc)
118{
119 tcase_add_test(tc, elm_config_eoapi);
120}