elm_entry: use Efl.File in Elm_Entry

Summary:
Also using the second optional string parameter of efl_file_set as the
text format specifier.
Added string constants to represent the possible values.

Address the issue:
- Elm entry and the file interface clash on file_set.
Specified in the page:
https://phab.enlightenment.org/w/efl_interfaces/

Reviewers: felipealmeida, tasn

Reviewed By: tasn

Subscribers: thiepha, raster

Differential Revision: https://phab.enlightenment.org/D2353
This commit is contained in:
Vitor Sousa 2015-07-01 18:30:23 +01:00 committed by Tom Hacohen
parent 5a737f7187
commit 2e7b6d38af
4 changed files with 98 additions and 47 deletions

View File

@ -4507,22 +4507,48 @@ inserting:
evas_object_smart_callback_call(entry, SIG_REJECTED, NULL);
}
EOLIAN static void
_elm_entry_file_text_format_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, Elm_Text_Format format)
{
sd->format = format;
}
EAPI Eina_Bool
elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
{
Eina_Bool ret;
eo_do(obj, elm_obj_entry_file_text_format_set(format),
ret = efl_file_set(file, NULL));
return ret;
}
EOLIAN static Eina_Bool
_elm_entry_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file, Elm_Text_Format format)
_elm_entry_efl_file_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file, const char *group EINA_UNUSED)
{
ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
if (sd->auto_save) _save_do(obj);
eina_stringshare_replace(&sd->file, file);
sd->format = format;
Eina_Bool int_ret = _load_do(obj);
return int_ret;
}
EAPI void
elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
{
eo_do(obj, efl_file_get(file, NULL));
if (format)
{
ELM_ENTRY_DATA_GET(obj, sd);
if (!sd) return;
*format = sd->format;
}
}
EOLIAN static void
_elm_entry_file_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char **file, Elm_Text_Format *format)
_elm_entry_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char **file, const char **group)
{
if (file) *file = sd->file;
if (format) *format = sd->format;
if (group) *group = NULL;
}
EOLIAN static void

View File

@ -1,5 +1,14 @@
enum Elm.Text_Format
{
[[Text Format types.
@see elm_entry_file_text_format()
]]
plain_utf8, [[ Plain UTF8 type ]]
markup_utf8 [[ Markup UTF8 type ]]
}
class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
Elm_Interface_Atspi_Text, Elm_Interface_Atspi_Editable_Text)
Elm_Interface_Atspi_Text, Elm_Interface_Atspi_Editable_Text, Efl.File)
{
eo_prefix: elm_obj_entry;
methods {
@ -98,6 +107,28 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
cnp_mode: Elm_Cnp_Mode; /*@ One of #Elm_Cnp_Mode: #ELM_CNP_MODE_MARKUP, #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT. */
}
}
@property file_text_format {
[[Text format used to load and save the file, which could be plain text or markup text.
Default is @c ELM_TEXT_FORMAT_PLAIN_UTF8, if you want to use
@c ELM_TEXT_FORMAT_MARKUP_UTF8 then you need to set the text format
before calling @ref efl_file_set.
You could also set it before a call to @ref elm_obj_entry_file_save
in order to save with the given format.
@ingroup Entry
]]
set {
[[Use it before calling @ref efl_file_set or @ref elm_obj_entry_file_save.
@ingroup Entry
]]
}
values {
format: Elm.Text_Format(Elm.Text_Format.plain_utf8); [[ The file format ]]
}
}
@property input_panel_language {
set {
/*@
@ -296,36 +327,6 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
password: bool; /*@ If true, password mode is enabled. */
}
}
@property file {
set {
/*@
This sets the file (and implicitly loads it) for the text to display and
then edit. All changes are written back to the file after a short delay if
the entry object is set to autosave (which is the default).
If the entry had any other file set previously, any changes made to it
will be saved if the autosave feature is enabled, otherwise, the file
will be silently discarded and any non-saved changes will be lost.
@return @c EINA_TRUE on success, @c EINA_FALSE otherwise
@ingroup Entry */
return: bool;
}
get {
/*@
Get the file being edited by the entry.
This function can be used to retrieve any file set on the entry for
edition, along with the format used to load and save it.
@ingroup Entry */
}
values {
file: const(char)*; /*@ The path to the file to load and save */
format: Elm_Text_Format; /*@ The file format */
}
}
@property input_panel_return_key_disabled {
set {
/*@
@ -1225,6 +1226,8 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
Elm_Interface_Atspi_Editable_Text.cut;
Elm_Interface_Atspi_Editable_Text.delete;
Elm_Interface_Atspi_Editable_Text.paste;
Efl.File.file.set;
Efl.File.file.get;
}
events {
language,changed;

View File

@ -4,17 +4,6 @@
* @{
*/
/**
* Text Format types.
*
* @see elm_entry_file_set()
*/
typedef enum
{
ELM_TEXT_FORMAT_PLAIN_UTF8, /**< Plain UTF8 type */
ELM_TEXT_FORMAT_MARKUP_UTF8 /**< Markup UTF8 type */
} Elm_Text_Format;
/**
* Line wrapping types.
*

View File

@ -1,3 +1,5 @@
#include "elm_entry.eo.legacy.h"
/**
* This adds an entry to @p parent object.
*
@ -37,4 +39,35 @@ EAPI void elm_entry_entry_set(Evas_Object *obj, const char *entry)
*/
EAPI const char *elm_entry_entry_get(const Evas_Object *obj);
#include "elm_entry.eo.legacy.h"
/**
*
* This sets the file (and implicitly loads it) for the text to display and
* then edit. All changes are written back to the file after a short delay if
* the entry object is set to autosave (which is the default).
*
* If the entry had any other file set previously, any changes made to it
* will be saved if the autosave feature is enabled, otherwise, the file
* will be silently discarded and any non-saved changes will be lost.
*
* @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
*
* @ingroup Entry
*
* @param[in] file The path to the file to load and save
* @param[in] format The file format
*/
EAPI Eina_Bool elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format);
/**
*
* Get the file being edited by the entry.
*
* This function can be used to retrieve any file set on the entry for
* edition, along with the format used to load and save it.
*
* @ingroup Entry
*
* @param[out] file The path to the file to load and save
* @param[out] format The file format
*/
EAPI void elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format);