efl: Introduce general Efl.Config API
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 21 Jun 2016 08:54:56 +0000 (17:54 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Fri, 24 Jun 2016 07:57:04 +0000 (16:57 +0900)
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

13 files changed:
src/Makefile_Efl.am
src/Makefile_Elementary.am
src/lib/efl/Efl.h
src/lib/efl/interfaces/efl_config.c [new file with mode: 0644]
src/lib/efl/interfaces/efl_config.eo [new file with mode: 0644]
src/lib/elementary/efl_config_internal.eo [new file with mode: 0644]
src/lib/elementary/efl_ui_win.eo
src/lib/elementary/elm_config.c
src/lib/elementary/elm_priv.h
src/lib/elementary/elm_widget.c
src/tests/elementary/elm_suite.c
src/tests/elementary/elm_suite.h
src/tests/elementary/elm_test_config.c [new file with mode: 0644]

index c8fe1f0..0a3e521 100644 (file)
@@ -9,6 +9,7 @@ efl_eolian_legacy_files = \
 
 efl_eolian_files = \
       lib/efl/interfaces/efl_canvas.eo \
+      lib/efl/interfaces/efl_config.eo \
       lib/efl/interfaces/efl_control.eo \
       lib/efl/interfaces/efl_file.eo \
       lib/efl/interfaces/efl_image_load.eo \
@@ -82,6 +83,7 @@ lib_LTLIBRARIES += lib/efl/libefl.la
 
 lib_efl_libefl_la_SOURCES = \
 lib/efl/interfaces/efl_interfaces_main.c \
+lib/efl/interfaces/efl_config.c \
 lib/efl/interfaces/efl_model_common.c \
 lib/efl/interfaces/efl_gfx_shape.c \
 lib/efl/interfaces/efl_vpath_file.c \
index 27948de..fbe6e08 100644 (file)
@@ -146,6 +146,7 @@ elm_public_eolian_files = \
 # Private classes (not exposed or shipped)
 elm_private_eolian_files = \
        lib/elementary/efl_ui_internal_text_interactive.eo \
+       lib/elementary/efl_config_internal.eo \
        $(NULL)
 
 # Legacy classes - not part of public EO API
@@ -1338,6 +1339,7 @@ tests_elementary_elm_suite_SOURCES = \
        tests/elementary/elm_test_slideshow.c \
        tests/elementary/elm_test_spinner.c \
        tests/elementary/elm_test_plug.c \
+       tests/elementary/elm_test_config.c \
        tests/elementary/elm_code_file_test_load.c \
        tests/elementary/elm_code_file_test_memory.c \
        tests/elementary/elm_code_test_basic.c \
index c5ff46b..731f318 100644 (file)
@@ -68,6 +68,7 @@ typedef struct tm Efl_Time;
 typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
 
 /* Interfaces */
+#include "interfaces/efl_config.eo.h"
 #include "interfaces/efl_control.eo.h"
 #include "interfaces/efl_file.eo.h"
 #include "interfaces/efl_image.eo.h"
@@ -140,6 +141,10 @@ static inline void efl_gfx_color16_type_set(Efl_Gfx_Color *color,
 #include "interfaces/efl_input_interface.eo.h"
 #include "interfaces/efl_event.eo.h"
 
+#ifdef EFL_EFL_BUILD
+EAPI void __efl_internal_elm_config_set(Efl_Config *cfg);
+#endif
+
 #else
 
 #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 (file)
index 0000000..75d8388
--- /dev/null
@@ -0,0 +1,128 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Efl.h>
+
+static Efl_Config *_main_config = NULL;
+
+EAPI void
+__efl_internal_elm_config_set(Efl_Config *cfg)
+{
+   _main_config = cfg;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_bool_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, Eina_Bool val)
+{
+   Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_UCHAR);
+   Eina_Bool b;
+   eina_value_set(v, val);
+   b = efl_config_set(obj, name, v);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_bool_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
+{
+   Eina_Value *v = efl_config_get(obj, name);
+   Eina_Bool b = 0;
+   eina_value_get(v, &b);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_int_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, int val)
+{
+   Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_INT);
+   Eina_Bool b;
+   eina_value_set(v, val);
+   b = efl_config_set(obj, name, v);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static int
+_efl_config_config_int_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
+{
+   Eina_Value *v = efl_config_get(obj, name);
+   int b = 0;
+   eina_value_get(v, &b);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_uint_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, unsigned int val)
+{
+   Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_UINT);
+   Eina_Bool b;
+   eina_value_set(v, val);
+   b = efl_config_set(obj, name, v);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static unsigned int
+_efl_config_config_uint_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
+{
+   Eina_Value *v = efl_config_get(obj, name);
+   unsigned int b = 0;
+   eina_value_get(v, &b);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_double_set(Eo *obj, void *_pd EINA_UNUSED, const char * name, double val)
+{
+   Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_DOUBLE);
+   Eina_Bool b;
+   eina_value_set(v, val);
+   b = efl_config_set(obj, name, v);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static double
+_efl_config_config_double_get(Eo *obj, void *_pd EINA_UNUSED, const char * name)
+{
+   Eina_Value *v = efl_config_get(obj, name);
+   double b = 0;
+   eina_value_get(v, &b);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_config_string_set(Eo *obj, void *_pd EINA_UNUSED, const char *name, const char *val)
+{
+   Eina_Value *v = eina_value_new(EINA_VALUE_TYPE_STRING);
+   Eina_Bool b;
+   eina_value_set(v, val);
+   b = efl_config_set(obj, name, v);
+   eina_value_free(v);
+   return b;
+}
+
+EOLIAN static const char *
+_efl_config_config_string_get(Eo *obj, void *_pd EINA_UNUSED, const char *name)
+{
+   Eina_Value *v = efl_config_get(obj, name);
+   Eina_Stringshare *s;
+   const char *b = 0;
+   eina_value_get(v, &b);
+   s = eina_stringshare_add(b);
+   eina_value_free(v);
+   return s;
+}
+
+EOLIAN static Efl_Config *
+_efl_config_config_global_get(Eo *klass EINA_UNUSED, void *_pd EINA_UNUSED)
+{
+   return _main_config;
+}
+
+#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 (file)
index 0000000..9726672
--- /dev/null
@@ -0,0 +1,119 @@
+mixin Efl.Config (Eo.Interface)
+{
+   [[A generic configuration interface, that holds key-value pairs.]]
+   data: null;
+   methods {
+      /* FIXME: make this a property -- @own is a problem */
+      /*
+      @property config @virtual_pure {
+         [[Holds a generic value under a given key.
+
+           Most common value types are: string, int, uint, bool, double.
+         ]]
+         keys {
+            name: string;
+         }
+         values {
+            val: const(generic_value)*;
+         }
+         get {
+            return: free(own(generic_value *), eina_value_free);
+         }
+      }
+      */
+      config_set @virtual_pure {
+         params {
+            name: string;
+            val: const(generic_value)*;
+         }
+         return: bool; [[$false in case of error: value type was invalid, the
+                         config can't be changed, config does not exist...]]
+      }
+      config_get @virtual_pure @const {
+         params {
+            name: string;
+         }
+         return: free(own(generic_value *), eina_value_free);
+      }
+      config_list_get @virtual_pure @const {
+         [[Returns a list of generic values under a given key.]]
+         params {
+            @in name: string;
+         }
+         return: free(own(iterator<generic_value*>), eina_iterator_free);
+      }
+      @property config_bool {
+         [[Helper for boolean properties (most useful in C).]]
+         keys {
+            name: string;
+         }
+         values {
+            val: bool;
+         }
+         get {}
+         set { return: bool; }
+      }
+      @property config_int {
+         [[Helper for int properties (most useful in C).]]
+         keys {
+            name: string;
+         }
+         values {
+            val: int;
+         }
+         get {}
+         set { return: bool; }
+      }
+      @property config_uint {
+         [[Helper for unsigned int properties (most useful in C).]]
+         keys {
+            name: string;
+         }
+         values {
+            val: uint;
+         }
+         get {}
+         set { return: bool; }
+      }
+      @property config_double {
+         [[Helper for double properties (most useful in C).]]
+         keys {
+            name: string;
+         }
+         values {
+            val: double;
+         }
+         get {}
+         set { return: bool; }
+      }
+      @property config_string {
+         [[Helper for string properties (most useful in C).]]
+         keys {
+            name: string;
+         }
+         values {
+            val: string;
+         }
+         set { return: bool; }
+      }
+      config_string_get {
+         [[Helper for string properties (most useful in C).]]
+         params {
+            name: string;
+         }
+         return: stringshare;
+      }
+      config_global_get @class {
+         [[Get a handle on the main configuration.]]
+         return: Efl.Config;
+      }
+   }
+}
+
+/* NOTES:
+ - Elm_Color_Class list -> no need to return the struct, only the name matters
+                           but also provide func to get desc from name
+ - Elm_Color_Overlay -> see with Jee-Yong and his color patch (common intf)
+ - elm_config_font_overlay_set -> ?
+ - what else?
+*/
diff --git a/src/lib/elementary/efl_config_internal.eo b/src/lib/elementary/efl_config_internal.eo
new file mode 100644 (file)
index 0000000..b7d13f0
--- /dev/null
@@ -0,0 +1,10 @@
+class Efl.Config.Internal (Eo.Base, Efl.Config)
+{
+   [[Internal class translating between Efl.Config and legacy elm_config.]]
+   data: null;
+   implements {
+      Efl.Config.config_set;
+      Efl.Config.config_get;
+      Efl.Config.config_list_get;
+   }
+}
index b17add4..590952f 100644 (file)
@@ -146,7 +146,7 @@ enum Efl.Ui.Win.Urgent_Mode
 class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
                Elm.Interface.Atspi_Widget_Action, Efl.Pack,
                Efl.Input.State, Efl.Input.Interface, Efl.Screen,
-               Efl.Gfx.Size.Hint, Efl.Text)
+               Efl.Gfx.Size.Hint, Efl.Text, Efl.Config)
 {
    legacy_prefix: elm_win;
    eo_prefix: efl_ui_win;
index 7dcd06b..9d08a2e 100644 (file)
@@ -6,9 +6,13 @@
 #include "elm_priv.h"
 #include <pwd.h>
 
+#include "efl_config_internal.eo.h"
+
 EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0;
+EAPI void __efl_internal_elm_config_set(Efl_Config *cfg);
 
 Elm_Config *_elm_config = NULL;
+Efl_Config *_efl_config_obj = NULL;
 static char *_elm_profile = NULL;
 static Eet_Data_Descriptor *_config_edd = NULL;
 static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
@@ -1678,6 +1682,8 @@ _config_system_load(void)
 static void
 _config_load(void)
 {
+   _efl_config_obj = eo_add(EFL_CONFIG_INTERNAL_CLASS, NULL);
+   __efl_internal_elm_config_set(_efl_config_obj);
    _elm_config = _config_user_load();
    if (_elm_config)
      {
@@ -4236,6 +4242,8 @@ _elm_config_profile_set(const char *profile)
 void
 _elm_config_shutdown(void)
 {
+   ELM_SAFE_FREE(_efl_config_obj, eo_del);
+   __efl_internal_elm_config_set(NULL);
    ELM_SAFE_FREE(_elm_config, _config_free);
    ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del);
    ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del);
@@ -4247,3 +4255,261 @@ _elm_config_shutdown(void)
 
    ELM_SAFE_FREE(_elm_key_bindings, eina_hash_free);
 }
+
+
+/* Efl.Config implementation */
+
+typedef const char * cstring;
+
+static inline Eina_Bool
+_eina_value_to_int(const Eina_Value *val, int *i)
+{
+   Eina_Value *ival = eina_value_new(EINA_VALUE_TYPE_INT);
+   Eina_Bool ret = EINA_TRUE;
+   if (!eina_value_convert(val, ival))
+     ret = EINA_FALSE;
+   else
+     ret = eina_value_get(ival, i);
+   eina_value_free(ival);
+   return ret;
+}
+
+static inline Eina_Bool
+_eina_value_to_cstring(const Eina_Value *val, cstring *s)
+{
+   Eina_Value *sval = eina_value_new(EINA_VALUE_TYPE_STRING);
+   Eina_Bool ret = EINA_TRUE;
+   if (!eina_value_convert(val, sval))
+     ret = EINA_FALSE;
+   else
+     ret = eina_value_get(sval, s);
+   eina_value_free(sval);
+   return ret;
+}
+
+EOLIAN static Eina_Bool
+_efl_config_internal_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
+                                           const char *name, const Eina_Value *val)
+{
+   if (!name) return EINA_FALSE;
+   // TODO: if (!val) reset to default
+
+#define CONFIG_SET(opt, primityp, valtyp, alttyp) do { \
+   if (!strcmp(name, #opt)) \
+     { \
+        primityp v = 0; \
+        alttyp alt = 0; \
+        const Eina_Value_Type *typ = EINA_VALUE_TYPE_ ## valtyp; \
+        if (eina_value_type_get(val) == typ)  \
+          { \
+             if (!eina_value_get(val, &v)) return EINA_FALSE; \
+          } \
+        else if (_eina_value_to_ ## alttyp(val, &alt)) \
+          { \
+             v = alt; \
+          } \
+        else \
+          { \
+             ERR("Invalid value type for config '%s' (got %s wanted %s)", \
+                 name, eina_value_type_name_get(eina_value_type_get(val)), \
+                 eina_value_type_name_get(EINA_VALUE_TYPE_ ## valtyp)); \
+             return EINA_FALSE; \
+          } \
+        elm_config_ ## opt ## _set(v); \
+        return EINA_TRUE; \
+     } \
+   } while (0)
+
+#define CONFIG_SETB(opt) CONFIG_SET(opt, Eina_Bool, UCHAR, int)
+#define CONFIG_SETI(opt) CONFIG_SET(opt, int, INT, int)
+#define CONFIG_SETU(opt) CONFIG_SET(opt, unsigned int, UINT, int)
+#define CONFIG_SETD(opt) CONFIG_SET(opt, double, DOUBLE, int)
+#define CONFIG_SETS(opt) CONFIG_SET(opt, const char *, STRING, cstring)
+
+   CONFIG_SETB(scroll_bounce_enabled);
+   CONFIG_SETD(scroll_bounce_friction);
+   CONFIG_SETD(scroll_page_scroll_friction);
+   CONFIG_SETB(context_menu_disabled);
+   CONFIG_SETD(scroll_bring_in_scroll_friction);
+   CONFIG_SETD(scroll_zoom_friction);
+   CONFIG_SETB(scroll_thumbscroll_enabled);
+   CONFIG_SETU(scroll_thumbscroll_threshold);
+   CONFIG_SETU(scroll_thumbscroll_hold_threshold);
+   CONFIG_SETD(scroll_thumbscroll_momentum_threshold);
+   CONFIG_SETU(scroll_thumbscroll_flick_distance_tolerance);
+   CONFIG_SETD(scroll_thumbscroll_friction);
+   CONFIG_SETD(scroll_thumbscroll_min_friction);
+   CONFIG_SETD(scroll_thumbscroll_friction_standard);
+   CONFIG_SETD(scroll_thumbscroll_border_friction);
+   CONFIG_SETD(scroll_thumbscroll_sensitivity_friction);
+   CONFIG_SETB(scroll_thumbscroll_smooth_start);
+   CONFIG_SETB(scroll_animation_disable);
+   CONFIG_SETD(scroll_accel_factor);
+   CONFIG_SETD(scroll_thumbscroll_smooth_amount);
+   CONFIG_SETD(scroll_thumbscroll_smooth_time_window);
+   CONFIG_SETD(scroll_thumbscroll_acceleration_threshold);
+   CONFIG_SETD(scroll_thumbscroll_acceleration_time_limit);
+   CONFIG_SETD(scroll_thumbscroll_acceleration_weight);
+   //focus_autoscroll_mode Elm_Focus_Autoscroll_Mode mode);
+   //slider_indicator_visible_mode Elm_Slider_Indicator_Visible_Mode mode);
+   CONFIG_SETD(longpress_timeout);
+   //softcursor_mode Elm_Softcursor_Mode mode);
+   CONFIG_SETD(tooltip_delay);
+   CONFIG_SETB(cursor_engine_only);
+   CONFIG_SETD(scale);
+   CONFIG_SETS(icon_theme);
+   CONFIG_SETB(password_show_last);
+   CONFIG_SETD(password_show_last_timeout);
+   CONFIG_SETS(preferred_engine);
+   CONFIG_SETS(accel_preference);
+   //font_overlay const char *text_class, const char *font, Evas_Font_Size size);
+   CONFIG_SETB(access);
+   CONFIG_SETB(selection_unfocused_clear);
+   //elm_config.h:EAPI void             elm_config_font_overlay_unset(const char *text_class);
+   CONFIG_SETI(font_hint_type);
+   CONFIG_SETI(finger_size);
+   CONFIG_SETI(cache_flush_interval);
+   CONFIG_SETB(cache_flush_enabled);
+   CONFIG_SETI(cache_font_cache_size);
+   CONFIG_SETI(cache_image_cache_size);
+   CONFIG_SETI(cache_edje_file_cache_size);
+   CONFIG_SETI(cache_edje_collection_cache_size);
+   CONFIG_SETB(vsync);
+   CONFIG_SETB(accel_preference_override);
+   CONFIG_SETB(focus_highlight_enabled);
+   CONFIG_SETB(focus_highlight_animate);
+   CONFIG_SETB(focus_highlight_clip_disabled);
+   //focus_move_policy Elm_Focus_Move_Policy policy);
+   CONFIG_SETB(item_select_on_focus_disabled);
+   CONFIG_SETB(first_item_focus_on_first_focusin);
+   CONFIG_SETB(mirrored);
+   CONFIG_SETB(clouseau_enabled);
+   CONFIG_SETD(glayer_long_tap_start_timeout);
+   CONFIG_SETD(glayer_double_tap_timeout);
+   //color_overlay const char *color_class,
+   //elm_config.h:EAPI void      elm_config_color_overlay_unset(const char *color_class);
+   CONFIG_SETB(magnifier_enable);
+   CONFIG_SETD(magnifier_scale);
+   //audio_mute Edje_Channel channel,);
+   CONFIG_SETB(window_auto_focus_enable);
+   CONFIG_SETB(window_auto_focus_animate);
+   CONFIG_SETB(popup_scrollable);
+   CONFIG_SETB(atspi_mode);
+   CONFIG_SETD(transition_duration_factor);
+   CONFIG_SETS(web_backend);
+
+   ERR("Config '%s' does not exist", name);
+   return EINA_FALSE;
+}
+
+EOLIAN static Eina_Value *
+_efl_config_internal_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
+                                           const char *name)
+{
+   Eina_Value *val = NULL;
+
+   if (!name) return NULL;
+
+   // NOTE: returning INT instead of UINT for unsigned int types
+
+#define CONFIG_GET(opt, primityp, valtyp) do { \
+   if (!strcmp(name, #opt)) \
+     { \
+        val = eina_value_new(EINA_VALUE_TYPE_ ## valtyp); \
+        eina_value_set(val, elm_config_ ## opt ## _get()); \
+        return val; \
+     } \
+   } while (0)
+
+#define CONFIG_GETB(opt) CONFIG_GET(opt, Eina_Bool, UCHAR)
+#define CONFIG_GETI(opt) CONFIG_GET(opt, int, INT)
+#define CONFIG_GETU(opt) CONFIG_GET(opt, int, INT)
+#define CONFIG_GETD(opt) CONFIG_GET(opt, double, DOUBLE)
+#define CONFIG_GETS(opt) CONFIG_GET(opt, const char *, STRING)
+
+   CONFIG_GETB(scroll_bounce_enabled);
+   CONFIG_GETD(scroll_bounce_friction);
+   CONFIG_GETD(scroll_page_scroll_friction);
+   CONFIG_GETB(context_menu_disabled);
+   CONFIG_GETD(scroll_bring_in_scroll_friction);
+   CONFIG_GETD(scroll_zoom_friction);
+   CONFIG_GETB(scroll_thumbscroll_enabled);
+   CONFIG_GETU(scroll_thumbscroll_threshold);
+   CONFIG_GETU(scroll_thumbscroll_hold_threshold);
+   CONFIG_GETD(scroll_thumbscroll_momentum_threshold);
+   CONFIG_GETU(scroll_thumbscroll_flick_distance_tolerance);
+   CONFIG_GETD(scroll_thumbscroll_friction);
+   CONFIG_GETD(scroll_thumbscroll_min_friction);
+   CONFIG_GETD(scroll_thumbscroll_friction_standard);
+   CONFIG_GETD(scroll_thumbscroll_border_friction);
+   CONFIG_GETD(scroll_thumbscroll_sensitivity_friction);
+   CONFIG_GETB(scroll_thumbscroll_smooth_start);
+   CONFIG_GETB(scroll_animation_disable);
+   CONFIG_GETD(scroll_accel_factor);
+   CONFIG_GETD(scroll_thumbscroll_smooth_amount);
+   CONFIG_GETD(scroll_thumbscroll_smooth_time_window);
+   CONFIG_GETD(scroll_thumbscroll_acceleration_threshold);
+   CONFIG_GETD(scroll_thumbscroll_acceleration_time_limit);
+   CONFIG_GETD(scroll_thumbscroll_acceleration_weight);
+   //focus_autoscroll_mode
+   //slider_indicator_visible_mode
+   CONFIG_GETD(longpress_timeout);
+   //softcursor_mode
+   CONFIG_GETD(tooltip_delay);
+   CONFIG_GETB(cursor_engine_only);
+   CONFIG_GETD(scale);
+   CONFIG_GETS(icon_theme);
+   CONFIG_GETB(password_show_last);
+   CONFIG_GETD(password_show_last_timeout);
+   CONFIG_GETS(preferred_engine);
+   CONFIG_GETS(accel_preference);
+   //font_overlay
+   CONFIG_GETB(access);
+   CONFIG_GETB(selection_unfocused_clear);
+   //elm_config_font_overlay_unset
+   //CONFIG_GETI(font_hint_type); // this has no get!
+   CONFIG_GETI(finger_size);
+   CONFIG_GETI(cache_flush_interval);
+   CONFIG_GETB(cache_flush_enabled);
+   CONFIG_GETI(cache_font_cache_size);
+   CONFIG_GETI(cache_image_cache_size);
+   CONFIG_GETI(cache_edje_file_cache_size);
+   CONFIG_GETI(cache_edje_collection_cache_size);
+   CONFIG_GETB(vsync);
+   CONFIG_GETB(accel_preference_override);
+   CONFIG_GETB(focus_highlight_enabled);
+   CONFIG_GETB(focus_highlight_animate);
+   CONFIG_GETB(focus_highlight_clip_disabled);
+   //focus_move_policy
+   CONFIG_GETB(item_select_on_focus_disabled);
+   CONFIG_GETB(first_item_focus_on_first_focusin);
+   CONFIG_GETB(mirrored);
+   CONFIG_GETB(clouseau_enabled);
+   CONFIG_GETD(glayer_long_tap_start_timeout);
+   CONFIG_GETD(glayer_double_tap_timeout);
+   //color_overlay
+   //color_overlay_unset
+   CONFIG_GETB(magnifier_enable);
+   CONFIG_GETD(magnifier_scale);
+   //audio_mute
+   CONFIG_GETB(window_auto_focus_enable);
+   CONFIG_GETB(window_auto_focus_animate);
+   CONFIG_GETB(popup_scrollable);
+   CONFIG_GETB(atspi_mode);
+   CONFIG_GETD(transition_duration_factor);
+   CONFIG_GETS(web_backend);
+
+   ERR("Config '%s' does not exist", name);
+   return NULL;
+}
+
+EOLIAN static Eina_Iterator *
+_efl_config_internal_efl_config_config_list_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED,
+                                                const char *name)
+{
+   // Not implemented: none of the elm_config functions returns a list of primitive types
+   (void) name;
+   return NULL;
+}
+
+#include "efl_config_internal.eo.c"
index ff33e4d..09f3ce9 100644 (file)
@@ -567,6 +567,7 @@ Eina_Bool _elm_config_accel_preference_parse(const char *pref, Eina_Stringshare
 
 extern char *_elm_appname;
 extern Elm_Config *_elm_config;
+extern Efl_Config *_efl_config_obj;
 extern const char *_elm_data_dir;
 extern const char *_elm_lib_dir;
 extern int _elm_log_dom;
index 8d1d8b2..744de60 100644 (file)
@@ -6073,6 +6073,9 @@ _elm_widget_eo_base_provider_find(Eo *obj, Elm_Widget_Smart_Data *pd, const Eo_B
 {
    Eo_Base *lookup = NULL;
 
+   if (klass == EFL_CONFIG_MIXIN)
+     return _efl_config_obj;
+
    if (pd->provider_lookup) return NULL;
    pd->provider_lookup = EINA_TRUE;
 
index a612e7e..0507325 100644 (file)
@@ -8,6 +8,7 @@
 
 static const Efl_Test_Case etc[] = {
   { "Elementary", elm_test_init },
+  { "elm_config", elm_test_config },
   { "elm_check", elm_test_check },
   { "elm_colorselector", elm_test_colorselector },
   { "elm_entry", elm_test_entry},
index bf87d1b..076bb60 100644 (file)
@@ -5,6 +5,7 @@
 #include "elm_test_helper.h"
 
 void elm_test_init(TCase *tc);
+void elm_test_config(TCase *tc);
 void elm_test_check(TCase *tc);
 void elm_test_colorselector(TCase *tc);
 void 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 (file)
index 0000000..ed9745c
--- /dev/null
@@ -0,0 +1,120 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
+#include <Elementary.h>
+#include "elm_suite.h"
+
+#include <stdbool.h>
+typedef unsigned int uint;
+
+START_TEST (elm_config_eoapi)
+{
+   elm_init(1, NULL);
+
+   Eo *cfg = efl_config_global_get(EFL_CONFIG_MIXIN);
+   fail_if(!cfg);
+
+#define CONFIG_CHK(opt, typ, val) do { \
+   typ old = elm_config_ ## opt ## _get(); \
+   fail_if(old != efl_config_ ## typ ## _get(cfg, #opt)); \
+   fail_if(!efl_config_ ## typ ## _set(cfg, #opt, val)); \
+   fail_if(elm_config_ ## opt ## _get() != val); \
+   fail_if(efl_config_ ## typ ## _get(cfg, #opt) != val); \
+   } while (0)
+
+#define CONFIG_CHKB(opt, val) CONFIG_CHK(opt, bool, val)
+#define CONFIG_CHKI(opt, val) CONFIG_CHK(opt, int, val)
+#define CONFIG_CHKU(opt, val) CONFIG_CHK(opt, uint, val)
+#define CONFIG_CHKD(opt, val) CONFIG_CHK(opt, double, val)
+
+   // note: leaks badly
+#define CONFIG_CHKS(opt, val) do { \
+   const char *old = elm_config_ ## opt ## _get(); \
+   fail_if(!eina_streq(old, efl_config_string_get(cfg, #opt))); \
+   fail_if(!efl_config_string_set(cfg, #opt, val)); \
+   fail_if(!eina_streq(elm_config_ ## opt ## _get(), val)); \
+   fail_if(!eina_streq(efl_config_string_get(cfg, #opt), val)); \
+   } while (0)
+
+   CONFIG_CHKB(scroll_bounce_enabled, !old);
+   CONFIG_CHKD(scroll_bounce_friction, 0);
+   CONFIG_CHKD(scroll_page_scroll_friction, 0);
+   CONFIG_CHKB(context_menu_disabled, !old);
+   CONFIG_CHKD(scroll_bring_in_scroll_friction, 0);
+   CONFIG_CHKD(scroll_zoom_friction, 0);
+   CONFIG_CHKB(scroll_thumbscroll_enabled, !old);
+   CONFIG_CHKU(scroll_thumbscroll_threshold, 0);
+   CONFIG_CHKU(scroll_thumbscroll_hold_threshold, 0);
+   CONFIG_CHKD(scroll_thumbscroll_momentum_threshold, 0);
+   CONFIG_CHKU(scroll_thumbscroll_flick_distance_tolerance, 0);
+   CONFIG_CHKD(scroll_thumbscroll_friction, 0);
+   CONFIG_CHKD(scroll_thumbscroll_min_friction, 0);
+   CONFIG_CHKD(scroll_thumbscroll_friction_standard, 0);
+   CONFIG_CHKD(scroll_thumbscroll_border_friction, 0);
+   CONFIG_CHKD(scroll_thumbscroll_sensitivity_friction, 1.0);
+   CONFIG_CHKB(scroll_thumbscroll_smooth_start, 0);
+   CONFIG_CHKB(scroll_animation_disable, 0);
+   CONFIG_CHKD(scroll_accel_factor, 0);
+   CONFIG_CHKD(scroll_thumbscroll_smooth_amount, 0);
+   CONFIG_CHKD(scroll_thumbscroll_smooth_time_window, 0);
+   CONFIG_CHKD(scroll_thumbscroll_acceleration_threshold, 0);
+   CONFIG_CHKD(scroll_thumbscroll_acceleration_time_limit, 0);
+   CONFIG_CHKD(scroll_thumbscroll_acceleration_weight, 0);
+   //focus_autoscroll_mode
+   //slider_indicator_visible_mode
+   CONFIG_CHKD(longpress_timeout, 0);
+   //softcursor_mode
+   CONFIG_CHKD(tooltip_delay, 0);
+   CONFIG_CHKB(cursor_engine_only, 0);
+   CONFIG_CHKD(scale, 0);
+   CONFIG_CHKS(icon_theme, ELM_CONFIG_ICON_THEME_ELEMENTARY);
+   CONFIG_CHKB(password_show_last, 0);
+   CONFIG_CHKD(password_show_last_timeout, 0);
+   CONFIG_CHKS(preferred_engine, 0);
+   CONFIG_CHKS(accel_preference, 0);
+   //font_overlay
+   CONFIG_CHKB(access, 0);
+   CONFIG_CHKB(selection_unfocused_clear, 0);
+   //elm_config_font_overlay_unset
+   //CONFIG_CHKI(font_hint_type, 0); // this has no get!
+   CONFIG_CHKI(finger_size, 0);
+   CONFIG_CHKI(cache_flush_interval, 10);
+   CONFIG_CHKB(cache_flush_enabled, !old);
+   CONFIG_CHKI(cache_font_cache_size, 0);
+   CONFIG_CHKI(cache_image_cache_size, 0);
+   CONFIG_CHKI(cache_edje_file_cache_size, 0);
+   CONFIG_CHKI(cache_edje_collection_cache_size, 0);
+   CONFIG_CHKB(vsync, 0);
+   CONFIG_CHKB(accel_preference_override, 0);
+   CONFIG_CHKB(focus_highlight_enabled, !old);
+   CONFIG_CHKB(focus_highlight_animate, 0);
+   CONFIG_CHKB(focus_highlight_clip_disabled, !old);
+   //focus_move_policy
+   CONFIG_CHKB(item_select_on_focus_disabled, !old);
+   CONFIG_CHKB(first_item_focus_on_first_focusin, 0);
+   CONFIG_CHKB(mirrored, 0);
+   CONFIG_CHKB(clouseau_enabled, !old);
+   CONFIG_CHKD(glayer_long_tap_start_timeout, 0);
+   CONFIG_CHKD(glayer_double_tap_timeout, 0);
+   //color_overlay
+   //color_overlay_unset
+   CONFIG_CHKB(magnifier_enable, 0);
+   CONFIG_CHKD(magnifier_scale, 0);
+   //audio_mute
+   CONFIG_CHKB(window_auto_focus_enable, 0);
+   CONFIG_CHKB(window_auto_focus_animate, 0);
+   CONFIG_CHKB(popup_scrollable, 0);
+   CONFIG_CHKB(atspi_mode, 0);
+   CONFIG_CHKD(transition_duration_factor, 0);
+   CONFIG_CHKS(web_backend, old); // no value change (requires web support)
+
+   elm_shutdown();
+}
+END_TEST
+
+void elm_test_config(TCase *tc)
+{
+ tcase_add_test(tc, elm_config_eoapi);
+}