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)
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:
4507 evas_object_smart_callback_call(entry, SIG_REJECTED, NULL); 4507 evas_object_smart_callback_call(entry, SIG_REJECTED, NULL);
4508} 4508}
4509 4509
4510EOLIAN static void
4511_elm_entry_file_text_format_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, Elm_Text_Format format)
4512{
4513 sd->format = format;
4514}
4515
4516EAPI Eina_Bool
4517elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4518{
4519 Eina_Bool ret;
4520 eo_do(obj, elm_obj_entry_file_text_format_set(format),
4521 ret = efl_file_set(file, NULL));
4522 return ret;
4523}
4524
4510EOLIAN static Eina_Bool 4525EOLIAN static Eina_Bool
4511_elm_entry_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file, Elm_Text_Format format) 4526_elm_entry_efl_file_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file, const char *group EINA_UNUSED)
4512{ 4527{
4513 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del); 4528 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
4514 if (sd->auto_save) _save_do(obj); 4529 if (sd->auto_save) _save_do(obj);
4515 eina_stringshare_replace(&sd->file, file); 4530 eina_stringshare_replace(&sd->file, file);
4516 sd->format = format;
4517 Eina_Bool int_ret = _load_do(obj); 4531 Eina_Bool int_ret = _load_do(obj);
4518 return int_ret; 4532 return int_ret;
4519} 4533}
4520 4534
4535EAPI void
4536elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4537{
4538 eo_do(obj, efl_file_get(file, NULL));
4539 if (format)
4540 {
4541 ELM_ENTRY_DATA_GET(obj, sd);
4542 if (!sd) return;
4543 *format = sd->format;
4544 }
4545}
4546
4521EOLIAN static void 4547EOLIAN static void
4522_elm_entry_file_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char **file, Elm_Text_Format *format) 4548_elm_entry_efl_file_file_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char **file, const char **group)
4523{ 4549{
4524 if (file) *file = sd->file; 4550 if (file) *file = sd->file;
4525 if (format) *format = sd->format; 4551 if (group) *group = NULL;
4526} 4552}
4527 4553
4528EOLIAN static void 4554EOLIAN 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 @@
1enum Elm.Text_Format
2{
3 [[Text Format types.
4 @see elm_entry_file_text_format()
5 ]]
6 plain_utf8, [[ Plain UTF8 type ]]
7 markup_utf8 [[ Markup UTF8 type ]]
8}
9
1class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface, 10class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
2 Elm_Interface_Atspi_Text, Elm_Interface_Atspi_Editable_Text) 11 Elm_Interface_Atspi_Text, Elm_Interface_Atspi_Editable_Text, Efl.File)
3{ 12{
4 eo_prefix: elm_obj_entry; 13 eo_prefix: elm_obj_entry;
5 methods { 14 methods {
@@ -98,6 +107,28 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
98 cnp_mode: Elm_Cnp_Mode; /*@ One of #Elm_Cnp_Mode: #ELM_CNP_MODE_MARKUP, #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT. */ 107 cnp_mode: Elm_Cnp_Mode; /*@ One of #Elm_Cnp_Mode: #ELM_CNP_MODE_MARKUP, #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT. */
99 } 108 }
100 } 109 }
110 @property file_text_format {
111 [[Text format used to load and save the file, which could be plain text or markup text.
112
113 Default is @c ELM_TEXT_FORMAT_PLAIN_UTF8, if you want to use
114 @c ELM_TEXT_FORMAT_MARKUP_UTF8 then you need to set the text format
115 before calling @ref efl_file_set.
116
117 You could also set it before a call to @ref elm_obj_entry_file_save
118 in order to save with the given format.
119
120 @ingroup Entry
121 ]]
122
123 set {
124 [[Use it before calling @ref efl_file_set or @ref elm_obj_entry_file_save.
125 @ingroup Entry
126 ]]
127 }
128 values {
129 format: Elm.Text_Format(Elm.Text_Format.plain_utf8); [[ The file format ]]
130 }
131 }
101 @property input_panel_language { 132 @property input_panel_language {
102 set { 133 set {
103 /*@ 134 /*@
@@ -296,36 +327,6 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
296 password: bool; /*@ If true, password mode is enabled. */ 327 password: bool; /*@ If true, password mode is enabled. */
297 } 328 }
298 } 329 }
299 @property file {
300 set {
301 /*@
302 This sets the file (and implicitly loads it) for the text to display and
303 then edit. All changes are written back to the file after a short delay if
304 the entry object is set to autosave (which is the default).
305
306 If the entry had any other file set previously, any changes made to it
307 will be saved if the autosave feature is enabled, otherwise, the file
308 will be silently discarded and any non-saved changes will be lost.
309
310 @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
311
312 @ingroup Entry */
313 return: bool;
314 }
315 get {
316 /*@
317 Get the file being edited by the entry.
318
319 This function can be used to retrieve any file set on the entry for
320 edition, along with the format used to load and save it.
321
322 @ingroup Entry */
323 }
324 values {
325 file: const(char)*; /*@ The path to the file to load and save */
326 format: Elm_Text_Format; /*@ The file format */
327 }
328 }
329 @property input_panel_return_key_disabled { 330 @property input_panel_return_key_disabled {
330 set { 331 set {
331 /*@ 332 /*@
@@ -1225,6 +1226,8 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
1225 Elm_Interface_Atspi_Editable_Text.cut; 1226 Elm_Interface_Atspi_Editable_Text.cut;
1226 Elm_Interface_Atspi_Editable_Text.delete; 1227 Elm_Interface_Atspi_Editable_Text.delete;
1227 Elm_Interface_Atspi_Editable_Text.paste; 1228 Elm_Interface_Atspi_Editable_Text.paste;
1229 Efl.File.file.set;
1230 Efl.File.file.get;
1228 } 1231 }
1229 events { 1232 events {
1230 language,changed; 1233 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 @@
5 */ 5 */
6 6
7/** 7/**
8 * Text Format types.
9 *
10 * @see elm_entry_file_set()
11 */
12typedef enum
13{
14 ELM_TEXT_FORMAT_PLAIN_UTF8, /**< Plain UTF8 type */
15 ELM_TEXT_FORMAT_MARKUP_UTF8 /**< Markup UTF8 type */
16} Elm_Text_Format;
17
18/**
19 * Line wrapping types. 8 * Line wrapping types.
20 * 9 *
21 * @see elm_entry_line_wrap_set() 10 * @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 @@
1#include "elm_entry.eo.legacy.h"
2
1/** 3/**
2 * This adds an entry to @p parent object. 4 * This adds an entry to @p parent object.
3 * 5 *
@@ -37,4 +39,35 @@ EAPI void elm_entry_entry_set(Evas_Object *obj, const char *entry)
37 */ 39 */
38EAPI const char *elm_entry_entry_get(const Evas_Object *obj); 40EAPI const char *elm_entry_entry_get(const Evas_Object *obj);
39 41
40#include "elm_entry.eo.legacy.h" 42/**
43 *
44 * This sets the file (and implicitly loads it) for the text to display and
45 * then edit. All changes are written back to the file after a short delay if
46 * the entry object is set to autosave (which is the default).
47 *
48 * If the entry had any other file set previously, any changes made to it
49 * will be saved if the autosave feature is enabled, otherwise, the file
50 * will be silently discarded and any non-saved changes will be lost.
51 *
52 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
53 *
54 * @ingroup Entry
55 *
56 * @param[in] file The path to the file to load and save
57 * @param[in] format The file format
58 */
59EAPI Eina_Bool elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format);
60
61/**
62 *
63 * Get the file being edited by the entry.
64 *
65 * This function can be used to retrieve any file set on the entry for
66 * edition, along with the format used to load and save it.
67 *
68 * @ingroup Entry
69 *
70 * @param[out] file The path to the file to load and save
71 * @param[out] format The file format
72 */
73EAPI void elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format);