Prefs: Use file interface.

This commit is contained in:
Tom Hacohen 2014-07-25 13:40:32 +01:00
parent 307e03c1b1
commit dc8ca9d436
3 changed files with 72 additions and 56 deletions

View File

@ -1127,7 +1127,7 @@ _elm_prefs_values_get_user(Elm_Prefs_Data *sd,
}
EOLIAN static Eina_Bool
_elm_prefs_file_set(Eo *obj, Elm_Prefs_Data *sd, const char *file, const char *page)
_elm_prefs_efl_file_file_set(Eo *obj, Elm_Prefs_Data *sd, const char *file, const char *page)
{
const char *prefix;
@ -1178,13 +1178,11 @@ _elm_prefs_file_set(Eo *obj, Elm_Prefs_Data *sd, const char *file, const char *p
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_elm_prefs_file_get(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd, const char **file, const char **page)
EOLIAN static void
_elm_prefs_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Prefs_Data *sd, const char **file, const char **page)
{
if (file) *file = sd->file;
if (page) *page = sd->page;
return EINA_TRUE;
}
EOLIAN static Eina_Bool
@ -1874,4 +1872,18 @@ _elm_prefs_class_constructor(Eo_Class *klass)
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}
EAPI Eina_Bool
elm_prefs_file_set(Eo *obj, const char *file, const char *page)
{
return eo_do((Eo *) obj, efl_file_set(file, page));
}
EAPI Eina_Bool
elm_prefs_file_get(const Eo *obj, const char **file, const char **page)
{
eo_do((Eo *) obj, efl_file_get(file, page));
return EINA_TRUE;
}
#include "elm_prefs.eo.c"

View File

@ -1,4 +1,4 @@
class Elm_Prefs (Elm_Widget)
class Elm_Prefs (Elm_Widget, Efl.File)
{
eo_prefix: elm_obj_prefs;
properties {
@ -51,56 +51,6 @@ class Elm_Prefs (Elm_Widget)
Elm_Prefs_Data *data; /*@ A valid prefs_data handle */
}
}
file {
set {
/*@
Set file and page to populate a given prefs widget's interface.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
Elm prefs widgets start blank, with no child widgets. It's meant to
have its viewport populated with child elements coming from a
declaration file. That file (usually with @b .epb extension), is a
binary format (Eet) one, coming from a human-readable textual
declaration. This textual form (usually with @b .epc extension) is
translated to the binary form by means of the @b prefs_cc compiler.
With this function, one thus populates a prefs widget with UI
elements.
If @a file is @c NULL, "elm_app_data_dir_get()/preferences.epb"
will be used, by default. If @a file is a @b relative path, the
prefix "elm_app_data_dir_get()/" will be implicitly used with it.
If @a page is @c NULL, it is considered "main", as default.
@warning If your binary is not properly installed and
elm_app_data_dir_get() can't be figured out, a fallback value of
"." will be tryed, instead.
@see elm_prefs_file_get()
@since 1.8 */
return: bool;
}
get {
/*@
Retrieve file and page bound to a given prefs widget.
@return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
@note Use @c NULL pointers on the components you're not
interested in: they'll be ignored by the function.
@see elm_prefs_file_set() for more information
@since 1.8 */
return: bool;
}
values {
const(char)* file; /*@ The @b .epb (binary) file to get contents from */
const(char)* page; /*@ The page, inside @a file, where to get item contents from */
}
}
autosave {
set {
/*@
@ -364,6 +314,8 @@ class Elm_Prefs (Elm_Widget)
implements {
class.constructor;
Eo.Base.constructor;
Efl.File.file.set;
Efl.File.file.get;
Evas.Object_Smart.del;
Evas.Object_Smart.add;
Elm_Widget.focus_next;

View File

@ -6,6 +6,58 @@
EAPI Eina_Bool elm_prefs_page_widget_common_add(Evas_Object *prefs,
Evas_Object *obj);
/**
*
* Set file and page to populate a given prefs widget's interface.
*
* @return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
*
* Elm prefs widgets start blank, with no child widgets. It's meant to
* have its viewport populated with child elements coming from a
* declaration file. That file (usually with @b .epb extension), is a
* binary format (Eet) one, coming from a human-readable textual
* declaration. This textual form (usually with @b .epc extension) is
* translated to the binary form by means of the @b prefs_cc compiler.
*
* With this function, one thus populates a prefs widget with UI
* elements.
*
* If @a file is @c NULL, "elm_app_data_dir_get()/preferences.epb"
* will be used, by default. If @a file is a @b relative path, the
* prefix "elm_app_data_dir_get()/" will be implicitly used with it.
* If @a page is @c NULL, it is considered "main", as default.
*
* @warning If your binary is not properly installed and
* elm_app_data_dir_get() can't be figured out, a fallback value of
* "." will be tryed, instead.
*
* @see elm_prefs_file_get()
*
* @since 1.8
*
* @param[in] file The @b .epb (binary) file to get contents from
* @param[in] page The page, inside @a file, where to get item contents from
*/
EAPI Eina_Bool elm_prefs_file_set(Eo *obj, const char *file, const char *page);
/**
*
* Retrieve file and page bound to a given prefs widget.
*
* @return @c EINA_TRUE, on success, @c EINA_FALSE otherwise
*
* @note Use @c NULL pointers on the components you're not
* interested in: they'll be ignored by the function.
*
* @see elm_prefs_file_set() for more information
*
* @since 1.8
*
* @param[out] file The @b .epb (binary) file to get contents from
* @param[out] page The page, inside @a file, where to get item contents from
*/
EAPI Eina_Bool elm_prefs_file_get(const Eo *obj, const char **file, const char **page);
#include "elm_prefs.eo.legacy.h"
/**
* @}