From d6f280a42f4ca2b097d08f9701ac385cfc15bde1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 5 Mar 2019 17:00:37 -0500 Subject: [PATCH] elm_prefs: remove all legacy usage from eo files this takes the current generated output from eolian for legacy code in efl and adds it to the tree, then removes legacy references from the corresponding eo files. in the case where the entire eo file was for a legacy object, that eo file has been removed from the tree ref T7724 Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D8194 --- src/Makefile_Elementary.am | 5 +- src/lib/elementary/elm_prefs.c | 4 +- src/lib/elementary/elm_prefs.eo | 227 -------------- src/lib/elementary/elm_prefs_eo.c | 159 ++++++++++ src/lib/elementary/elm_prefs_eo.h | 381 +++++++++++++++++++++++ src/lib/elementary/elm_prefs_eo.legacy.c | 96 ++++++ src/lib/elementary/elm_prefs_eo.legacy.h | 329 +++++++++++++++++++ src/lib/elementary/elm_prefs_legacy.h | 2 +- src/lib/elementary/meson.build | 3 +- 9 files changed, 974 insertions(+), 232 deletions(-) delete mode 100644 src/lib/elementary/elm_prefs.eo create mode 100644 src/lib/elementary/elm_prefs_eo.c create mode 100644 src/lib/elementary/elm_prefs_eo.h create mode 100644 src/lib/elementary/elm_prefs_eo.legacy.c create mode 100644 src/lib/elementary/elm_prefs_eo.legacy.h diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index b39f7d67a2..3bca800e9d 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -207,7 +207,6 @@ elm_legacy_eolian_files = \ lib/elementary/elm_actionslider_part.eo \ lib/elementary/elm_bubble_part.eo \ lib/elementary/elm_fileselector_part.eo \ - lib/elementary/elm_prefs.eo \ lib/elementary/elm_segment_control.eo \ lib/elementary/elm_segment_control_item.eo \ lib/elementary/elm_separator.eo \ @@ -379,6 +378,8 @@ lib/elementary/elm_plug_eo.legacy.c \ lib/elementary/elm_popup_eo.c \ lib/elementary/elm_popup_eo.legacy.c \ lib/elementary/elm_popup_item_eo.c \ +lib/elementary/elm_prefs_eo.c \ +lib/elementary/elm_prefs_eo.legacy.c \ $(NULL) elm_legacy_eo_headers = \ @@ -548,6 +549,8 @@ lib/elementary/elm_popup_eo.h \ lib/elementary/elm_popup_eo.legacy.h \ lib/elementary/elm_popup_item_eo.h \ lib/elementary/elm_popup_item_eo.legacy.h \ +lib/elementary/elm_prefs_eo.h \ +lib/elementary/elm_prefs_eo.legacy.h \ $(NULL) diff --git a/src/lib/elementary/elm_prefs.c b/src/lib/elementary/elm_prefs.c index 984557985c..edd2213b4a 100644 --- a/src/lib/elementary/elm_prefs.c +++ b/src/lib/elementary/elm_prefs.c @@ -7,7 +7,7 @@ #include #include "elm_priv.h" -#include "elm_prefs.eo.h" +#include "elm_prefs_eo.h" #include "elm_widget_prefs.h" #include "elm_prefs_edd.x" @@ -1860,4 +1860,4 @@ elm_prefs_file_get(const Eo *obj, const char **file, const char **page) #define ELM_PREFS_EXTRA_OPS \ EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_prefs) -#include "elm_prefs.eo.c" +#include "elm_prefs_eo.c" diff --git a/src/lib/elementary/elm_prefs.eo b/src/lib/elementary/elm_prefs.eo deleted file mode 100644 index e76e57db0d..0000000000 --- a/src/lib/elementary/elm_prefs.eo +++ /dev/null @@ -1,227 +0,0 @@ -type Elm_Prefs_Data: __undefined_type; [[Elementary preferences data type]] -type Elm_Prefs_Reset_Mode: __undefined_type; [[Elementary preferences reset mode type]] - -class Elm.Prefs extends Efl.Ui.Widget implements Efl.Ui.Legacy -{ - [[Elementary preferences class]] - legacy_prefix: elm_prefs; - eo_prefix: elm_obj_prefs; - event_prefix: elm_prefs; - methods { - @property data { - [[Set user data for a given prefs widget - - Once a prefs widget is created, after elm_prefs_file_set() is - issued on it, all of its UI elements will get default values, when - declared on that file. To fetch an user's own, personal set of - those values, one gets to pair a prefs data handle to the - prefs widget. This is what this call is intended for. - - Prefs data values from $prefs_data with keys matching the ones - present on the file passed on elm_prefs_file_set() to $obj will - have their values applied to the respective UI elements of the - widget. - - When $obj dies, the values of the elements declared on its - $.epb file (the one set on elm_prefs_file_set()) marked as permanent - will be written back to prefs_data, if it is writable. - One is also able to make this writing event to take place - automatically after each UI element modification by using - elm_prefs_autosave_set(). - - Note: $obj will keep a reference of its own for $prefs_data, - but you should still unreference it by yourself, after the widget - is gone. - - @since 1.8]] - set { - return: bool; [[$true, on success, $false otherwise]] - } - get { - } - values { - data: ptr(Elm_Prefs_Data) @nullable; [[A valid prefs_data handle]] - } - } - @property autosave { - [[Control whether a given prefs widget should save its values back (on - the user data file, if set) automatically on every UI element - changes. - - If $autosave is $true, every call to - elm_prefs_item_value_set(), every - Elm_Prefs_Data_Event_Type.ELM_PREFS_DATA_EVENT_ITEM_CHANGED event - coming for its prefs data and every UI element direct value - changing will implicitly make the prefs values to be flushed back - to it prefs data. If a prefs data handle with no writing - permissions or no prefs data is set on $prefs, naturally nothing - will happen. - - @since 1.8]] - set { - } - get { - } - values { - autosave: bool; [[$true to save automatically, $false otherwise.]] - } - } - reset { - [[Reset the values of a given prefs widget to a previous state. - - As can be seen on #Elm_Prefs_Reset_Mode, there are two possible - actions to be taken by this call -- either to reset $prefs' - values to the defaults (declared on the $.epb file it is bound - to) or to reset to the state they were before the last modification - it got. - - @since 1.8]] - - params { - @in mode: Elm_Prefs_Reset_Mode; [[The reset mode to apply on $prefs]] - } - } - item_value_set { - [[Set the value on a given prefs widget's item. - - This will change the value of item named $name programatically. - - @since 1.8]] - - return: bool; [[$true, on success, $false otherwise]] - params { - @in name: string; [[The name of the item (as declared in the prefs collection)]] - @in value: const(any_value_ptr); [[The value to set on the item. It should be typed as the item expects, preferably, or a conversion will take place]] - } - } - item_value_get @const { - [[Get the value of a given prefs widget's item. - - This will retrieve the value of item named $name. - - @since 1.8]] - return: bool; [[$true, on success, $false otherwise]] - - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to get value from]] - @out value: any_value; [[Where to store the value of the item. It will be overwritten and setup with the type the item is bound to]] - } - } - item_object_get { - [[Get the Elementary widget bound to a given prefs widget's item. - - This will retrieve a handle to the real widget implementing a given - item of $prefs, for read-only actions. - - Warning: You should never modify the state of the returned - widget, because it's meant to be managed by $prefs, solely. - - @since 1.8]] - - return: const(Efl.Canvas.Object); [[A valid widget handle, on success, or $NULL, otherwise]] - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to get object from]] - } - } - item_disabled_set { - [[Set whether the widget bound to a given prefs widget's item is disabled or not. - - @since 1.8]] - - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to act on]] - @in disabled: bool; [[$true, to make it disabled, $false otherwise]] - } - } - item_disabled_get @const { - [[Get whether the widget bound to a given prefs widget's item is disabled or not. - - @since 1.8]] - return: bool; [[$true, if it is disabled, $false otherwise]] - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to get disabled state from]] - } - } - item_swallow { - [["Swallows" an object into a SWALLOW item of a prefs widget. - - @since 1.8]] - - return: bool; [[$true, on success, $false otherwise]] - params { - @in name: string; [[The name of the SWALLOW item (as declared in the prefs collection)]] - @in child: Efl.Canvas.Object; [[The object to occupy the item]] - } - } - item_editable_set { - [[Set whether the widget bound to a given prefs widget's item is editable or not. - - Note: Only $TEXT or $TEXTAREA items' default widgets implement - the 'editable' property. Custom registered widgets may as well - implement them. - - @since 1.8]] - - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to act on]] - @in editable: bool; [[$true, to make it editable, $false otherwise]] - } - } - item_editable_get @const { - [[Get whether the widget bound to a given prefs widget's item is editable or not. - - @since 1.8]] - return: bool; [[$true, if it is editable, $false otherwise]] - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to get editable state from]] - } - } - item_unswallow { - [[Unswallow an object from a SWALLOW item of a prefs widget. - - @since 1.8]] - - return: Efl.Canvas.Object; [[The unswallowed object, or NULL on errors]] - params { - @in name: string; [[The name of the SWALLOW item (as declared in the prefs collection)]] - } - } - item_visible_set { - [[Set whether the widget bound to given prefs widget's item should be visible or not. - - Each prefs item may have a default visibility state, declared on - the $.epb $prefs it was loaded with. By this call one may alter - that state, programatically. - - @since 1.8]] - - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to change visibility of]] - @in visible: bool; [[$true, to make it visible, $false otherwise]] - } - } - item_visible_get @const { - [[Get whether the widget bound to a given prefs widget's item is visible or not. - - @since 1.8]] - return: bool; [[$true, if it is visible, $false otherwise]] - params { - @in name: string; [[The name of the item (as declared in the prefs collection) to get visibility state from]] - } - } - } - implements { - class.constructor; - Efl.Object.constructor; - } - events { - page,changed: string; [[Called when page changed]] - page,saved: string; [[Called when page was saved]] - /* FIXME: Nobody emits this - page,reset; [[Called when page was reset]] - */ - page,loaded: string; [[Called when page got loaded]] - item,changed: string; [[Called when item changed]] - action: string; [[Called when action was done]] - } -} diff --git a/src/lib/elementary/elm_prefs_eo.c b/src/lib/elementary/elm_prefs_eo.c new file mode 100644 index 0000000000..f56f214b2e --- /dev/null +++ b/src/lib/elementary/elm_prefs_eo.c @@ -0,0 +1,159 @@ +EWAPI const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_CHANGED = + EFL_EVENT_DESCRIPTION("page,changed"); +EWAPI const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_SAVED = + EFL_EVENT_DESCRIPTION("page,saved"); +EWAPI const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_LOADED = + EFL_EVENT_DESCRIPTION("page,loaded"); +EWAPI const Efl_Event_Description _ELM_PREFS_EVENT_ITEM_CHANGED = + EFL_EVENT_DESCRIPTION("item,changed"); +EWAPI const Efl_Event_Description _ELM_PREFS_EVENT_ACTION = + EFL_EVENT_DESCRIPTION("action"); + +Eina_Bool _elm_prefs_data_set(Eo *obj, Elm_Prefs_Data *pd, Elm_Prefs_Data *data); + +EOAPI EFL_FUNC_BODYV(elm_obj_prefs_data_set, Eina_Bool, 0, EFL_FUNC_CALL(data), Elm_Prefs_Data *data); + +Elm_Prefs_Data *_elm_prefs_data_get(const Eo *obj, Elm_Prefs_Data *pd); + +EOAPI EFL_FUNC_BODY_CONST(elm_obj_prefs_data_get, Elm_Prefs_Data *, NULL); + +void _elm_prefs_autosave_set(Eo *obj, Elm_Prefs_Data *pd, Eina_Bool autosave); + + +static Eina_Error +__eolian_elm_prefs_autosave_set_reflect(Eo *obj, Eina_Value val) +{ + Eina_Error r = 0; Eina_Bool cval; + if (!eina_value_bool_convert(&val, &cval)) + { + r = EINA_ERROR_VALUE_FAILED; + goto end; + } + elm_obj_prefs_autosave_set(obj, cval); + end: + eina_value_flush(&val); + return r; +} + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_prefs_autosave_set, EFL_FUNC_CALL(autosave), Eina_Bool autosave); + +Eina_Bool _elm_prefs_autosave_get(const Eo *obj, Elm_Prefs_Data *pd); + + +static Eina_Value +__eolian_elm_prefs_autosave_get_reflect(Eo *obj) +{ + Eina_Bool val = elm_obj_prefs_autosave_get(obj); + return eina_value_bool_init(val); +} + +EOAPI EFL_FUNC_BODY_CONST(elm_obj_prefs_autosave_get, Eina_Bool, 0); + +void _elm_prefs_reset(Eo *obj, Elm_Prefs_Data *pd, Elm_Prefs_Reset_Mode mode); + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_prefs_reset, EFL_FUNC_CALL(mode), Elm_Prefs_Reset_Mode mode); + +Eina_Bool _elm_prefs_item_value_set(Eo *obj, Elm_Prefs_Data *pd, const char *name, const Eina_Value *value); + +EOAPI EFL_FUNC_BODYV(elm_obj_prefs_item_value_set, Eina_Bool, 0, EFL_FUNC_CALL(name, value), const char *name, const Eina_Value *value); + +Eina_Bool _elm_prefs_item_value_get(const Eo *obj, Elm_Prefs_Data *pd, const char *name, Eina_Value *value); + +EOAPI EFL_FUNC_BODYV_CONST(elm_obj_prefs_item_value_get, Eina_Bool, 0, EFL_FUNC_CALL(name, value), const char *name, Eina_Value *value); + +const Efl_Canvas_Object *_elm_prefs_item_object_get(Eo *obj, Elm_Prefs_Data *pd, const char *name); + +EOAPI EFL_FUNC_BODYV(elm_obj_prefs_item_object_get, const Efl_Canvas_Object *, NULL, EFL_FUNC_CALL(name), const char *name); + +void _elm_prefs_item_disabled_set(Eo *obj, Elm_Prefs_Data *pd, const char *name, Eina_Bool disabled); + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_prefs_item_disabled_set, EFL_FUNC_CALL(name, disabled), const char *name, Eina_Bool disabled); + +Eina_Bool _elm_prefs_item_disabled_get(const Eo *obj, Elm_Prefs_Data *pd, const char *name); + +EOAPI EFL_FUNC_BODYV_CONST(elm_obj_prefs_item_disabled_get, Eina_Bool, 0, EFL_FUNC_CALL(name), const char *name); + +Eina_Bool _elm_prefs_item_swallow(Eo *obj, Elm_Prefs_Data *pd, const char *name, Efl_Canvas_Object *child); + +EOAPI EFL_FUNC_BODYV(elm_obj_prefs_item_swallow, Eina_Bool, 0, EFL_FUNC_CALL(name, child), const char *name, Efl_Canvas_Object *child); + +void _elm_prefs_item_editable_set(Eo *obj, Elm_Prefs_Data *pd, const char *name, Eina_Bool editable); + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_prefs_item_editable_set, EFL_FUNC_CALL(name, editable), const char *name, Eina_Bool editable); + +Eina_Bool _elm_prefs_item_editable_get(const Eo *obj, Elm_Prefs_Data *pd, const char *name); + +EOAPI EFL_FUNC_BODYV_CONST(elm_obj_prefs_item_editable_get, Eina_Bool, 0, EFL_FUNC_CALL(name), const char *name); + +Efl_Canvas_Object *_elm_prefs_item_unswallow(Eo *obj, Elm_Prefs_Data *pd, const char *name); + +EOAPI EFL_FUNC_BODYV(elm_obj_prefs_item_unswallow, Efl_Canvas_Object *, NULL, EFL_FUNC_CALL(name), const char *name); + +void _elm_prefs_item_visible_set(Eo *obj, Elm_Prefs_Data *pd, const char *name, Eina_Bool visible); + +EOAPI EFL_VOID_FUNC_BODYV(elm_obj_prefs_item_visible_set, EFL_FUNC_CALL(name, visible), const char *name, Eina_Bool visible); + +Eina_Bool _elm_prefs_item_visible_get(const Eo *obj, Elm_Prefs_Data *pd, const char *name); + +EOAPI EFL_FUNC_BODYV_CONST(elm_obj_prefs_item_visible_get, Eina_Bool, 0, EFL_FUNC_CALL(name), const char *name); + +Efl_Object *_elm_prefs_efl_object_constructor(Eo *obj, Elm_Prefs_Data *pd); + + +static Eina_Bool +_elm_prefs_class_initializer(Efl_Class *klass) +{ + const Efl_Object_Ops *opsp = NULL; + + const Efl_Object_Property_Reflection_Ops *ropsp = NULL; + +#ifndef ELM_PREFS_EXTRA_OPS +#define ELM_PREFS_EXTRA_OPS +#endif + + EFL_OPS_DEFINE(ops, + EFL_OBJECT_OP_FUNC(elm_obj_prefs_data_set, _elm_prefs_data_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_data_get, _elm_prefs_data_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_autosave_set, _elm_prefs_autosave_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_autosave_get, _elm_prefs_autosave_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_reset, _elm_prefs_reset), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_value_set, _elm_prefs_item_value_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_value_get, _elm_prefs_item_value_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_object_get, _elm_prefs_item_object_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_disabled_set, _elm_prefs_item_disabled_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_disabled_get, _elm_prefs_item_disabled_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_swallow, _elm_prefs_item_swallow), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_editable_set, _elm_prefs_item_editable_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_editable_get, _elm_prefs_item_editable_get), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_unswallow, _elm_prefs_item_unswallow), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_visible_set, _elm_prefs_item_visible_set), + EFL_OBJECT_OP_FUNC(elm_obj_prefs_item_visible_get, _elm_prefs_item_visible_get), + EFL_OBJECT_OP_FUNC(efl_constructor, _elm_prefs_efl_object_constructor), + ELM_PREFS_EXTRA_OPS + ); + opsp = &ops; + + static const Efl_Object_Property_Reflection refl_table[] = { + {"autosave", __eolian_elm_prefs_autosave_set_reflect, __eolian_elm_prefs_autosave_get_reflect}, + }; + static const Efl_Object_Property_Reflection_Ops rops = { + refl_table, EINA_C_ARRAY_LENGTH(refl_table) + }; + ropsp = &rops; + + return efl_class_functions_set(klass, opsp, ropsp); +} + +static const Efl_Class_Description _elm_prefs_class_desc = { + EO_VERSION, + "Elm.Prefs", + EFL_CLASS_TYPE_REGULAR, + sizeof(Elm_Prefs_Data), + _elm_prefs_class_initializer, + _elm_prefs_class_constructor, + NULL +}; + +EFL_DEFINE_CLASS(elm_prefs_class_get, &_elm_prefs_class_desc, EFL_UI_WIDGET_CLASS, EFL_UI_LEGACY_INTERFACE, NULL); + +#include "elm_prefs_eo.legacy.c" diff --git a/src/lib/elementary/elm_prefs_eo.h b/src/lib/elementary/elm_prefs_eo.h new file mode 100644 index 0000000000..5f6fad3bf2 --- /dev/null +++ b/src/lib/elementary/elm_prefs_eo.h @@ -0,0 +1,381 @@ +#ifndef _ELM_PREFS_EO_H_ +#define _ELM_PREFS_EO_H_ + +#ifndef _ELM_PREFS_EO_CLASS_TYPE +#define _ELM_PREFS_EO_CLASS_TYPE + +typedef Eo Elm_Prefs; + +#endif + +#ifndef _ELM_PREFS_EO_TYPES +#define _ELM_PREFS_EO_TYPES + + +#endif +/** Elementary preferences class + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_CLASS elm_prefs_class_get() + +EWAPI const Efl_Class *elm_prefs_class_get(void); + +/** + * @brief Set user data for a given prefs widget + * + * Once a prefs widget is created, after elm_prefs_file_set() is issued on it, + * all of its UI elements will get default values, when declared on that file. + * To fetch an user's own, personal set of those values, one gets to pair a + * prefs data handle to the prefs widget. This is what this call is intended + * for. + * + * Prefs data values from @c prefs_data with keys matching the ones present on + * the file passed on elm_prefs_file_set() to @c obj will have their values + * applied to the respective UI elements of the widget. + * + * When @c obj dies, the values of the elements declared on its $.epb file (the + * one set on elm_prefs_file_set()) marked as permanent will be written back to + * prefs_data, if it is writable. One is also able to make this writing event + * to take place automatically after each UI element modification by using + * elm_prefs_autosave_set(). + * + * @note @c obj will keep a reference of its own for @c prefs_data, but you + * should still unreference it by yourself, after the widget is gone. + * + * @param[in] obj The object. + * @param[in] data A valid prefs_data handle + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_data_set(Eo *obj, Elm_Prefs_Data *data); + +/** + * @brief Set user data for a given prefs widget + * + * Once a prefs widget is created, after elm_prefs_file_set() is issued on it, + * all of its UI elements will get default values, when declared on that file. + * To fetch an user's own, personal set of those values, one gets to pair a + * prefs data handle to the prefs widget. This is what this call is intended + * for. + * + * Prefs data values from @c prefs_data with keys matching the ones present on + * the file passed on elm_prefs_file_set() to @c obj will have their values + * applied to the respective UI elements of the widget. + * + * When @c obj dies, the values of the elements declared on its $.epb file (the + * one set on elm_prefs_file_set()) marked as permanent will be written back to + * prefs_data, if it is writable. One is also able to make this writing event + * to take place automatically after each UI element modification by using + * elm_prefs_autosave_set(). + * + * @note @c obj will keep a reference of its own for @c prefs_data, but you + * should still unreference it by yourself, after the widget is gone. + * + * @param[in] obj The object. + * + * @return A valid prefs_data handle + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Elm_Prefs_Data *elm_obj_prefs_data_get(const Eo *obj); + +/** + * @brief Control whether a given prefs widget should save its values back (on + * the user data file, if set) automatically on every UI element changes. + * + * If @c autosave is @c true, every call to elm_prefs_item_value_set(), every + * Elm_Prefs_Data_Event_Type.ELM_PREFS_DATA_EVENT_ITEM_CHANGED event coming for + * its prefs data and every UI element direct value changing will implicitly + * make the prefs values to be flushed back to it prefs data. If a prefs data + * handle with no writing permissions or no prefs data is set on @c prefs, + * naturally nothing will happen. + * + * @param[in] obj The object. + * @param[in] autosave @c true to save automatically, @c false otherwise. + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI void elm_obj_prefs_autosave_set(Eo *obj, Eina_Bool autosave); + +/** + * @brief Control whether a given prefs widget should save its values back (on + * the user data file, if set) automatically on every UI element changes. + * + * If @c autosave is @c true, every call to elm_prefs_item_value_set(), every + * Elm_Prefs_Data_Event_Type.ELM_PREFS_DATA_EVENT_ITEM_CHANGED event coming for + * its prefs data and every UI element direct value changing will implicitly + * make the prefs values to be flushed back to it prefs data. If a prefs data + * handle with no writing permissions or no prefs data is set on @c prefs, + * naturally nothing will happen. + * + * @param[in] obj The object. + * + * @return @c true to save automatically, @c false otherwise. + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_autosave_get(const Eo *obj); + +/** + * @brief Reset the values of a given prefs widget to a previous state. + * + * As can be seen on #Elm_Prefs_Reset_Mode, there are two possible actions to + * be taken by this call -- either to reset @c prefs' values to the defaults + * (declared on the $.epb file it is bound to) or to reset to the state they + * were before the last modification it got. + * + * @param[in] obj The object. + * @param[in] mode The reset mode to apply on @c prefs + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI void elm_obj_prefs_reset(Eo *obj, Elm_Prefs_Reset_Mode mode); + +/** + * @brief Set the value on a given prefs widget's item. + * + * This will change the value of item named @c name programatically. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * @param[in] value The value to set on the item. It should be typed as the + * item expects, preferably, or a conversion will take place + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_value_set(Eo *obj, const char *name, const Eina_Value *value); + +/** + * @brief Get the value of a given prefs widget's item. + * + * This will retrieve the value of item named @c name. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get value from + * @param[out] value Where to store the value of the item. It will be + * overwritten and setup with the type the item is bound to + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_value_get(const Eo *obj, const char *name, Eina_Value *value); + +/** + * @brief Get the Elementary widget bound to a given prefs widget's item. + * + * This will retrieve a handle to the real widget implementing a given item of + * @c prefs, for read-only actions. + * + * @warning You should never modify the state of the returned widget, because + * it's meant to be managed by @c prefs, solely. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get object from + * + * @return A valid widget handle, on success, or @c NULL, otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI const Efl_Canvas_Object *elm_obj_prefs_item_object_get(Eo *obj, const char *name); + +/** + * @brief Set whether the widget bound to a given prefs widget's item is + * disabled or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to act on + * @param[in] disabled @c true, to make it disabled, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI void elm_obj_prefs_item_disabled_set(Eo *obj, const char *name, Eina_Bool disabled); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * disabled or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get disabled state from + * + * @return @c true, if it is disabled, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_disabled_get(const Eo *obj, const char *name); + +/** + * @brief "Swallows" an object into a SWALLOW item of a prefs widget. + * + * @param[in] obj The object. + * @param[in] name The name of the SWALLOW item (as declared in the prefs + * collection) + * @param[in] child The object to occupy the item + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_swallow(Eo *obj, const char *name, Efl_Canvas_Object *child); + +/** + * @brief Set whether the widget bound to a given prefs widget's item is + * editable or not. + * + * @note Only @c TEXT or @c TEXTAREA items' default widgets implement the + * 'editable' property. Custom registered widgets may as well implement them. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to act on + * @param[in] editable @c true, to make it editable, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI void elm_obj_prefs_item_editable_set(Eo *obj, const char *name, Eina_Bool editable); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * editable or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get editable state from + * + * @return @c true, if it is editable, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_editable_get(const Eo *obj, const char *name); + +/** + * @brief Unswallow an object from a SWALLOW item of a prefs widget. + * + * @param[in] obj The object. + * @param[in] name The name of the SWALLOW item (as declared in the prefs + * collection) + * + * @return The unswallowed object, or NULL on errors + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Efl_Canvas_Object *elm_obj_prefs_item_unswallow(Eo *obj, const char *name); + +/** + * @brief Set whether the widget bound to given prefs widget's item should be + * visible or not. + * + * Each prefs item may have a default visibility state, declared on the $.epb + * @c prefs it was loaded with. By this call one may alter that state, + * programatically. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to change visibility of + * @param[in] visible @c true, to make it visible, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI void elm_obj_prefs_item_visible_set(Eo *obj, const char *name, Eina_Bool visible); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * visible or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get visibility state from + * + * @return @c true, if it is visible, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs + */ +EOAPI Eina_Bool elm_obj_prefs_item_visible_get(const Eo *obj, const char *name); + +EWAPI extern const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_CHANGED; + +/** Called when page changed + * @return const char * + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_EVENT_PAGE_CHANGED (&(_ELM_PREFS_EVENT_PAGE_CHANGED)) + +EWAPI extern const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_SAVED; + +/** Called when page was saved + * @return const char * + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_EVENT_PAGE_SAVED (&(_ELM_PREFS_EVENT_PAGE_SAVED)) + +EWAPI extern const Efl_Event_Description _ELM_PREFS_EVENT_PAGE_LOADED; + +/** Called when page got loaded + * @return const char * + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_EVENT_PAGE_LOADED (&(_ELM_PREFS_EVENT_PAGE_LOADED)) + +EWAPI extern const Efl_Event_Description _ELM_PREFS_EVENT_ITEM_CHANGED; + +/** Called when item changed + * @return const char * + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_EVENT_ITEM_CHANGED (&(_ELM_PREFS_EVENT_ITEM_CHANGED)) + +EWAPI extern const Efl_Event_Description _ELM_PREFS_EVENT_ACTION; + +/** Called when action was done + * @return const char * + * + * @ingroup Elm_Prefs + */ +#define ELM_PREFS_EVENT_ACTION (&(_ELM_PREFS_EVENT_ACTION)) + +#endif diff --git a/src/lib/elementary/elm_prefs_eo.legacy.c b/src/lib/elementary/elm_prefs_eo.legacy.c new file mode 100644 index 0000000000..2eef8f3b0b --- /dev/null +++ b/src/lib/elementary/elm_prefs_eo.legacy.c @@ -0,0 +1,96 @@ + +EAPI Eina_Bool +elm_prefs_data_set(Elm_Prefs *obj, Elm_Prefs_Data *data) +{ + return elm_obj_prefs_data_set(obj, data); +} + +EAPI Elm_Prefs_Data * +elm_prefs_data_get(const Elm_Prefs *obj) +{ + return elm_obj_prefs_data_get(obj); +} + +EAPI void +elm_prefs_autosave_set(Elm_Prefs *obj, Eina_Bool autosave) +{ + elm_obj_prefs_autosave_set(obj, autosave); +} + +EAPI Eina_Bool +elm_prefs_autosave_get(const Elm_Prefs *obj) +{ + return elm_obj_prefs_autosave_get(obj); +} + +EAPI void +elm_prefs_reset(Elm_Prefs *obj, Elm_Prefs_Reset_Mode mode) +{ + elm_obj_prefs_reset(obj, mode); +} + +EAPI Eina_Bool +elm_prefs_item_value_set(Elm_Prefs *obj, const char *name, const Eina_Value *value) +{ + return elm_obj_prefs_item_value_set(obj, name, value); +} + +EAPI Eina_Bool +elm_prefs_item_value_get(const Elm_Prefs *obj, const char *name, Eina_Value *value) +{ + return elm_obj_prefs_item_value_get(obj, name, value); +} + +EAPI const Efl_Canvas_Object * +elm_prefs_item_object_get(Elm_Prefs *obj, const char *name) +{ + return elm_obj_prefs_item_object_get(obj, name); +} + +EAPI void +elm_prefs_item_disabled_set(Elm_Prefs *obj, const char *name, Eina_Bool disabled) +{ + elm_obj_prefs_item_disabled_set(obj, name, disabled); +} + +EAPI Eina_Bool +elm_prefs_item_disabled_get(const Elm_Prefs *obj, const char *name) +{ + return elm_obj_prefs_item_disabled_get(obj, name); +} + +EAPI Eina_Bool +elm_prefs_item_swallow(Elm_Prefs *obj, const char *name, Efl_Canvas_Object *child) +{ + return elm_obj_prefs_item_swallow(obj, name, child); +} + +EAPI void +elm_prefs_item_editable_set(Elm_Prefs *obj, const char *name, Eina_Bool editable) +{ + elm_obj_prefs_item_editable_set(obj, name, editable); +} + +EAPI Eina_Bool +elm_prefs_item_editable_get(const Elm_Prefs *obj, const char *name) +{ + return elm_obj_prefs_item_editable_get(obj, name); +} + +EAPI Efl_Canvas_Object * +elm_prefs_item_unswallow(Elm_Prefs *obj, const char *name) +{ + return elm_obj_prefs_item_unswallow(obj, name); +} + +EAPI void +elm_prefs_item_visible_set(Elm_Prefs *obj, const char *name, Eina_Bool visible) +{ + elm_obj_prefs_item_visible_set(obj, name, visible); +} + +EAPI Eina_Bool +elm_prefs_item_visible_get(const Elm_Prefs *obj, const char *name) +{ + return elm_obj_prefs_item_visible_get(obj, name); +} diff --git a/src/lib/elementary/elm_prefs_eo.legacy.h b/src/lib/elementary/elm_prefs_eo.legacy.h new file mode 100644 index 0000000000..47fb914d56 --- /dev/null +++ b/src/lib/elementary/elm_prefs_eo.legacy.h @@ -0,0 +1,329 @@ +#ifndef _ELM_PREFS_EO_LEGACY_H_ +#define _ELM_PREFS_EO_LEGACY_H_ + +#ifndef _ELM_PREFS_EO_CLASS_TYPE +#define _ELM_PREFS_EO_CLASS_TYPE + +typedef Eo Elm_Prefs; + +#endif + +#ifndef _ELM_PREFS_EO_TYPES +#define _ELM_PREFS_EO_TYPES + + +#endif + +/** + * @brief Set user data for a given prefs widget + * + * Once a prefs widget is created, after elm_prefs_file_set() is issued on it, + * all of its UI elements will get default values, when declared on that file. + * To fetch an user's own, personal set of those values, one gets to pair a + * prefs data handle to the prefs widget. This is what this call is intended + * for. + * + * Prefs data values from @c prefs_data with keys matching the ones present on + * the file passed on elm_prefs_file_set() to @c obj will have their values + * applied to the respective UI elements of the widget. + * + * When @c obj dies, the values of the elements declared on its $.epb file (the + * one set on elm_prefs_file_set()) marked as permanent will be written back to + * prefs_data, if it is writable. One is also able to make this writing event + * to take place automatically after each UI element modification by using + * elm_prefs_autosave_set(). + * + * @note @c obj will keep a reference of its own for @c prefs_data, but you + * should still unreference it by yourself, after the widget is gone. + * + * @param[in] obj The object. + * @param[in] data A valid prefs_data handle + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_data_set(Elm_Prefs *obj, Elm_Prefs_Data *data); + +/** + * @brief Set user data for a given prefs widget + * + * Once a prefs widget is created, after elm_prefs_file_set() is issued on it, + * all of its UI elements will get default values, when declared on that file. + * To fetch an user's own, personal set of those values, one gets to pair a + * prefs data handle to the prefs widget. This is what this call is intended + * for. + * + * Prefs data values from @c prefs_data with keys matching the ones present on + * the file passed on elm_prefs_file_set() to @c obj will have their values + * applied to the respective UI elements of the widget. + * + * When @c obj dies, the values of the elements declared on its $.epb file (the + * one set on elm_prefs_file_set()) marked as permanent will be written back to + * prefs_data, if it is writable. One is also able to make this writing event + * to take place automatically after each UI element modification by using + * elm_prefs_autosave_set(). + * + * @note @c obj will keep a reference of its own for @c prefs_data, but you + * should still unreference it by yourself, after the widget is gone. + * + * @param[in] obj The object. + * + * @return A valid prefs_data handle + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Elm_Prefs_Data *elm_prefs_data_get(const Elm_Prefs *obj); + +/** + * @brief Control whether a given prefs widget should save its values back (on + * the user data file, if set) automatically on every UI element changes. + * + * If @c autosave is @c true, every call to elm_prefs_item_value_set(), every + * Elm_Prefs_Data_Event_Type.ELM_PREFS_DATA_EVENT_ITEM_CHANGED event coming for + * its prefs data and every UI element direct value changing will implicitly + * make the prefs values to be flushed back to it prefs data. If a prefs data + * handle with no writing permissions or no prefs data is set on @c prefs, + * naturally nothing will happen. + * + * @param[in] obj The object. + * @param[in] autosave @c true to save automatically, @c false otherwise. + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI void elm_prefs_autosave_set(Elm_Prefs *obj, Eina_Bool autosave); + +/** + * @brief Control whether a given prefs widget should save its values back (on + * the user data file, if set) automatically on every UI element changes. + * + * If @c autosave is @c true, every call to elm_prefs_item_value_set(), every + * Elm_Prefs_Data_Event_Type.ELM_PREFS_DATA_EVENT_ITEM_CHANGED event coming for + * its prefs data and every UI element direct value changing will implicitly + * make the prefs values to be flushed back to it prefs data. If a prefs data + * handle with no writing permissions or no prefs data is set on @c prefs, + * naturally nothing will happen. + * + * @param[in] obj The object. + * + * @return @c true to save automatically, @c false otherwise. + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_autosave_get(const Elm_Prefs *obj); + +/** + * @brief Reset the values of a given prefs widget to a previous state. + * + * As can be seen on #Elm_Prefs_Reset_Mode, there are two possible actions to + * be taken by this call -- either to reset @c prefs' values to the defaults + * (declared on the $.epb file it is bound to) or to reset to the state they + * were before the last modification it got. + * + * @param[in] obj The object. + * @param[in] mode The reset mode to apply on @c prefs + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI void elm_prefs_reset(Elm_Prefs *obj, Elm_Prefs_Reset_Mode mode); + +/** + * @brief Set the value on a given prefs widget's item. + * + * This will change the value of item named @c name programatically. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * @param[in] value The value to set on the item. It should be typed as the + * item expects, preferably, or a conversion will take place + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_value_set(Elm_Prefs *obj, const char *name, const Eina_Value *value); + +/** + * @brief Get the value of a given prefs widget's item. + * + * This will retrieve the value of item named @c name. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get value from + * @param[out] value Where to store the value of the item. It will be + * overwritten and setup with the type the item is bound to + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_value_get(const Elm_Prefs *obj, const char *name, Eina_Value *value); + +/** + * @brief Get the Elementary widget bound to a given prefs widget's item. + * + * This will retrieve a handle to the real widget implementing a given item of + * @c prefs, for read-only actions. + * + * @warning You should never modify the state of the returned widget, because + * it's meant to be managed by @c prefs, solely. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get object from + * + * @return A valid widget handle, on success, or @c NULL, otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI const Efl_Canvas_Object *elm_prefs_item_object_get(Elm_Prefs *obj, const char *name); + +/** + * @brief Set whether the widget bound to a given prefs widget's item is + * disabled or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to act on + * @param[in] disabled @c true, to make it disabled, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI void elm_prefs_item_disabled_set(Elm_Prefs *obj, const char *name, Eina_Bool disabled); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * disabled or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get disabled state from + * + * @return @c true, if it is disabled, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_disabled_get(const Elm_Prefs *obj, const char *name); + +/** + * @brief "Swallows" an object into a SWALLOW item of a prefs widget. + * + * @param[in] obj The object. + * @param[in] name The name of the SWALLOW item (as declared in the prefs + * collection) + * @param[in] child The object to occupy the item + * + * @return @c true, on success, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_swallow(Elm_Prefs *obj, const char *name, Efl_Canvas_Object *child); + +/** + * @brief Set whether the widget bound to a given prefs widget's item is + * editable or not. + * + * @note Only @c TEXT or @c TEXTAREA items' default widgets implement the + * 'editable' property. Custom registered widgets may as well implement them. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to act on + * @param[in] editable @c true, to make it editable, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI void elm_prefs_item_editable_set(Elm_Prefs *obj, const char *name, Eina_Bool editable); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * editable or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get editable state from + * + * @return @c true, if it is editable, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_editable_get(const Elm_Prefs *obj, const char *name); + +/** + * @brief Unswallow an object from a SWALLOW item of a prefs widget. + * + * @param[in] obj The object. + * @param[in] name The name of the SWALLOW item (as declared in the prefs + * collection) + * + * @return The unswallowed object, or NULL on errors + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Efl_Canvas_Object *elm_prefs_item_unswallow(Elm_Prefs *obj, const char *name); + +/** + * @brief Set whether the widget bound to given prefs widget's item should be + * visible or not. + * + * Each prefs item may have a default visibility state, declared on the $.epb + * @c prefs it was loaded with. By this call one may alter that state, + * programatically. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to change visibility of + * @param[in] visible @c true, to make it visible, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI void elm_prefs_item_visible_set(Elm_Prefs *obj, const char *name, Eina_Bool visible); + +/** + * @brief Get whether the widget bound to a given prefs widget's item is + * visible or not. + * + * @param[in] obj The object. + * @param[in] name The name of the item (as declared in the prefs collection) + * to get visibility state from + * + * @return @c true, if it is visible, @c false otherwise + * + * @since 1.8 + * + * @ingroup Elm_Prefs_Group + */ +EAPI Eina_Bool elm_prefs_item_visible_get(const Elm_Prefs *obj, const char *name); + +#endif diff --git a/src/lib/elementary/elm_prefs_legacy.h b/src/lib/elementary/elm_prefs_legacy.h index d3c1785fd2..e93d045757 100644 --- a/src/lib/elementary/elm_prefs_legacy.h +++ b/src/lib/elementary/elm_prefs_legacy.h @@ -61,7 +61,7 @@ EAPI Eina_Bool elm_prefs_file_set(Eo *obj, const char *file, const char *page); */ EAPI Eina_Bool elm_prefs_file_get(const Eo *obj, const char **file, const char **page); -#include "elm_prefs.eo.legacy.h" +#include "elm_prefs_eo.legacy.h" /** * @} */ diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build index 3b840e02c3..194804b98f 100644 --- a/src/lib/elementary/meson.build +++ b/src/lib/elementary/meson.build @@ -24,7 +24,6 @@ pub_legacy_eo_files = [ 'elm_actionslider_part.eo', 'elm_bubble_part.eo', 'elm_fileselector_part.eo', - 'elm_prefs.eo', 'elm_segment_control.eo', 'elm_segment_control_item.eo', 'elm_separator.eo', @@ -785,6 +784,8 @@ elementary_pub_headers = [ 'elm_popup_eo.legacy.h', 'elm_popup_item_eo.h', 'elm_popup_item_eo.legacy.h', + 'elm_prefs_eo.h', + 'elm_prefs_eo.legacy.h', ] elementary_header_src = [