summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-07-01 18:30:23 +0100
committerTom Hacohen <tom@stosb.com>2015-07-01 18:30:23 +0100
commitef8b20372b7bc1eb2b401d6e7a79e76496418f5c (patch)
treef08066dcc748e50f0c544187b1249bfddc3b6423
parentad19eee93b2a08a6c05986adbade5e25f8352ea7 (diff)
downloadelementary-ef8b20372b7bc1eb2b401d6e7a79e76496418f5c.tar.gz
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
-rw-r--r--src/lib/elm_entry.c34
-rw-r--r--src/lib/elm_entry.eo65
-rw-r--r--src/lib/elm_entry_common.h11
-rw-r--r--src/lib/elm_entry_legacy.h35
4 files changed, 98 insertions, 47 deletions
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index f307dd571..93346042b 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -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
diff --git a/src/lib/elm_entry.eo b/src/lib/elm_entry.eo
index 6da7b48da..9207845fe 100644
--- a/src/lib/elm_entry.eo
+++ b/src/lib/elm_entry.eo
@@ -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;
diff --git a/src/lib/elm_entry_common.h b/src/lib/elm_entry_common.h
index 48a9e8b56..e06fbd824 100644
--- a/src/lib/elm_entry_common.h
+++ b/src/lib/elm_entry_common.h
@@ -5,17 +5,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.
*
* @see elm_entry_line_wrap_set()
diff --git a/src/lib/elm_entry_legacy.h b/src/lib/elm_entry_legacy.h
index 55e87e717..14827106d 100644
--- a/src/lib/elm_entry_legacy.h
+++ b/src/lib/elm_entry_legacy.h
@@ -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);