summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/elm_entry.c')
-rw-r--r--src/lib/elementary/elm_entry.c134
1 files changed, 75 insertions, 59 deletions
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index 336b0f7..0334881 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -19,7 +19,7 @@
19 19
20#include "elm_entry_part.eo.h" 20#include "elm_entry_part.eo.h"
21#include "elm_part_helper.h" 21#include "elm_part_helper.h"
22#include "elm_hoversel.eo.h" 22#include "elm_hoversel_eo.h"
23 23
24#define MY_CLASS ELM_ENTRY_CLASS 24#define MY_CLASS ELM_ENTRY_CLASS
25#define MY_CLASS_PFX elm_entry 25#define MY_CLASS_PFX elm_entry
@@ -138,16 +138,14 @@ ok: // ok - return api
138} 138}
139 139
140static char * 140static char *
141_file_load(const char *file) 141_file_load(Eo *obj)
142{ 142{
143 Eina_File *f; 143 Eina_File *f;
144 char *text = NULL; 144 char *text = NULL;
145 void *tmp = NULL; 145 void *tmp = NULL;
146 size_t size; 146 size_t size;
147 147
148 f = eina_file_open(file, EINA_FALSE); 148 f = eina_file_dup(efl_file_mmap_get(obj));
149 if (!f) return NULL;
150
151 size = eina_file_size_get(f); 149 size = eina_file_size_get(f);
152 if (size) 150 if (size)
153 { 151 {
@@ -175,11 +173,11 @@ _file_load(const char *file)
175} 173}
176 174
177static char * 175static char *
178_plain_load(const char *file) 176_plain_load(Eo *obj)
179{ 177{
180 char *text; 178 char *text;
181 179
182 text = _file_load(file); 180 text = _file_load(obj);
183 if (text) 181 if (text)
184 { 182 {
185 char *text2; 183 char *text2;
@@ -192,47 +190,54 @@ _plain_load(const char *file)
192 return NULL; 190 return NULL;
193} 191}
194 192
195static Eina_Bool 193static Eina_Error
196_load_do(Evas_Object *obj) 194_load_do(Evas_Object *obj)
197{ 195{
198 char *text; 196 char *text;
197 Eina_Bool fail = EINA_FALSE;
198 Eina_Error err = 0;
199 199
200 ELM_ENTRY_DATA_GET(obj, sd); 200 ELM_ENTRY_DATA_GET(obj, sd);
201 201
202 if (!sd->file) 202 if (!sd->file)
203 { 203 {
204 elm_object_text_set(obj, ""); 204 elm_object_text_set(obj, "");
205 return EINA_TRUE; 205 return 0;
206 } 206 }
207 207
208 switch (sd->format) 208 switch (sd->format)
209 { 209 {
210 case ELM_TEXT_FORMAT_PLAIN_UTF8: 210 case ELM_TEXT_FORMAT_PLAIN_UTF8:
211 text = _plain_load(sd->file); 211 text = _plain_load(obj);
212 fail = !text;
212 break; 213 break;
213 214
214 case ELM_TEXT_FORMAT_MARKUP_UTF8: 215 case ELM_TEXT_FORMAT_MARKUP_UTF8:
215 text = _file_load(sd->file); 216 text = _file_load(obj);
217 fail = !text;
216 break; 218 break;
217 219
218 default: 220 default:
219 text = NULL; 221 text = NULL;
220 break; 222 break;
221 } 223 }
224 if (fail)
225 {
226 err = errno;
227 /* FIXME: this is more like a hint but not totally accurate... */
228 if (!err) err = ENOENT;
229 }
222 230
223 if (text) 231 if (text)
224 { 232 {
225 elm_object_text_set(obj, text); 233 elm_object_text_set(obj, text);
226 free(text); 234 free(text);
227 235
228 return EINA_TRUE; 236 return 0;
229 } 237 }
230 else 238 elm_object_text_set(obj, "");
231 {
232 elm_object_text_set(obj, "");
233 239
234 return EINA_FALSE; 240 return err;
235 }
236} 241}
237 242
238static void 243static void
@@ -800,11 +805,25 @@ _get_drop_format(Evas_Object *obj)
800 return ELM_SEL_FORMAT_MARKUP; 805 return ELM_SEL_FORMAT_MARKUP;
801} 806}
802 807
803/* we can't reuse layout's here, because it's on entry_edje only */ 808static void
804EOLIAN static Eina_Bool 809_flush_disabled_state(Eo *obj, Elm_Entry_Data *sd)
805_elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bool disabled)
806{ 810{
807 const char *emission; 811 const char *emission;
812 emission = efl_ui_widget_disabled_get(obj) ? "elm,state,disabled" : "elm,state,enabled";
813 edje_object_signal_emit(sd->entry_edje, emission, "elm");
814 if (sd->scroll)
815 {
816 edje_object_signal_emit(sd->scr_edje, emission, "elm");
817 elm_interface_scrollable_freeze_set(obj, efl_ui_widget_disabled_get(obj));
818 }
819}
820
821/* we can't reuse layout's here, because it's on entry_edje only */
822EOLIAN static void
823_elm_entry_efl_ui_widget_disabled_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool disabled)
824{
825
826 efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled);
808 827
809 elm_drop_target_del(obj, sd->drop_format, 828 elm_drop_target_del(obj, sd->drop_format,
810 _dnd_enter_cb, NULL, 829 _dnd_enter_cb, NULL,
@@ -812,16 +831,10 @@ _elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bo
812 _dnd_pos_cb, NULL, 831 _dnd_pos_cb, NULL,
813 _dnd_drop_cb, NULL); 832 _dnd_drop_cb, NULL);
814 833
815 emission = disabled ? "elm,state,disabled" : "elm,state,enabled"; 834 _flush_disabled_state(obj, sd);
816 edje_object_signal_emit(sd->entry_edje, emission, "elm"); 835 sd->disabled = efl_ui_widget_disabled_get(obj);
817 if (sd->scroll)
818 {
819 edje_object_signal_emit(sd->scr_edje, emission, "elm");
820 elm_interface_scrollable_freeze_set(obj, disabled);
821 }
822 sd->disabled = disabled;
823 836
824 if (!disabled) 837 if (!efl_ui_widget_disabled_get(obj))
825 { 838 {
826 sd->drop_format = _get_drop_format(obj); 839 sd->drop_format = _get_drop_format(obj);
827 elm_drop_target_add(obj, sd->drop_format, 840 elm_drop_target_add(obj, sd->drop_format,
@@ -830,8 +843,6 @@ _elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bo
830 _dnd_pos_cb, NULL, 843 _dnd_pos_cb, NULL,
831 _dnd_drop_cb, NULL); 844 _dnd_drop_cb, NULL);
832 } 845 }
833
834 return EINA_TRUE;
835} 846}
836 847
837/* It gets the background object from from_edje object and 848/* It gets the background object from from_edje object and
@@ -861,22 +872,22 @@ _elm_entry_background_switch(Evas_Object *from_edje, Evas_Object *to_edje)
861 872
862/* we can't issue the layout's theming code here, cause it assumes an 873/* we can't issue the layout's theming code here, cause it assumes an
863 * unique edje object, always */ 874 * unique edje object, always */
864EOLIAN static Efl_Ui_Theme_Apply_Result 875EOLIAN static Eina_Error
865_elm_entry_efl_ui_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) 876_elm_entry_efl_ui_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
866{ 877{
867 const char *str; 878 const char *str;
868 const char *t; 879 const char *t;
869 const char *stl_user; 880 const char *stl_user;
870 const char *style = elm_widget_style_get(obj); 881 const char *style = elm_widget_style_get(obj);
871 Efl_Ui_Theme_Apply_Result theme_apply; 882 Eina_Error theme_apply;
872 int cursor_pos; 883 int cursor_pos;
873 884
874 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_RESULT_FAIL); 885 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
875 886
876 // Note: We are skipping elm_layout here! This is by design. 887 // Note: We are skipping elm_layout here! This is by design.
877 // This assumes the following inheritance: my_class -> layout -> widget ... 888 // This assumes the following inheritance: my_class -> layout -> widget ...
878 theme_apply = efl_ui_widget_theme_apply(efl_cast(obj, EFL_UI_WIDGET_CLASS)); 889 theme_apply = efl_ui_widget_theme_apply(efl_cast(obj, EFL_UI_WIDGET_CLASS));
879 if (!theme_apply) return EFL_UI_THEME_APPLY_RESULT_FAIL; 890 if (theme_apply == EFL_UI_THEME_APPLY_ERROR_GENERIC) return EFL_UI_THEME_APPLY_ERROR_GENERIC;
880 891
881 evas_event_freeze(evas_object_evas_get(obj)); 892 evas_event_freeze(evas_object_evas_get(obj));
882 893
@@ -963,14 +974,14 @@ _elm_entry_efl_ui_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
963 974
964 if (sd->scroll) 975 if (sd->scroll)
965 { 976 {
966 Efl_Ui_Theme_Apply_Result ok = EFL_UI_THEME_APPLY_RESULT_FAIL; 977 Eina_Error err = EFL_UI_THEME_APPLY_ERROR_GENERIC;
967 978
968 efl_ui_mirrored_set(obj, efl_ui_mirrored_get(obj)); 979 efl_ui_mirrored_set(obj, efl_ui_mirrored_get(obj));
969 980
970 if (sd->single_line) 981 if (sd->single_line)
971 ok = elm_widget_theme_object_set 982 err = elm_widget_theme_object_set
972 (obj, sd->scr_edje, "scroller", "entry_single", style); 983 (obj, sd->scr_edje, "scroller", "entry_single", style);
973 if (!ok) 984 if (err)
974 elm_widget_theme_object_set 985 elm_widget_theme_object_set
975 (obj, sd->scr_edje, "scroller", "entry", style); 986 (obj, sd->scr_edje, "scroller", "entry", style);
976 987
@@ -1017,6 +1028,8 @@ _elm_entry_efl_ui_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
1017 1028
1018 evas_object_unref(obj); 1029 evas_object_unref(obj);
1019 1030
1031 _flush_disabled_state(obj, sd);
1032
1020 return theme_apply; 1033 return theme_apply;
1021} 1034}
1022 1035
@@ -1285,7 +1298,7 @@ _elm_entry_focus_update(Eo *obj, Elm_Entry_Data *sd)
1285 !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text")) 1298 !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text"))
1286 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON); 1299 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
1287 if (_elm_config->atspi_mode) 1300 if (_elm_config->atspi_mode)
1288 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_FOCUSED, EINA_TRUE); 1301 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_FOCUSED, EINA_TRUE);
1289 _return_key_enabled_check(obj); 1302 _return_key_enabled_check(obj);
1290 _validate(obj); 1303 _validate(obj);
1291 } 1304 }
@@ -1299,7 +1312,7 @@ _elm_entry_focus_update(Eo *obj, Elm_Entry_Data *sd)
1299 !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text")) 1312 !edje_object_part_text_imf_context_get(sd->entry_edje, "elm.text"))
1300 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF); 1313 elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
1301 if (_elm_config->atspi_mode) 1314 if (_elm_config->atspi_mode)
1302 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_FOCUSED, EINA_FALSE); 1315 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_FOCUSED, EINA_FALSE);
1303 1316
1304 if (_elm_config->selection_clear_enable) 1317 if (_elm_config->selection_clear_enable)
1305 { 1318 {
@@ -2841,8 +2854,8 @@ _item_get(void *data,
2841 } 2854 }
2842 2855
2843 o = edje_object_add(evas_object_evas_get(data)); 2856 o = edje_object_add(evas_object_evas_get(data));
2844 if (!_elm_theme_object_set 2857 if (_elm_theme_object_set
2845 (data, o, "entry", item, style)) 2858 (data, o, "entry", item, style) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
2846 _elm_theme_object_set 2859 _elm_theme_object_set
2847 (data, o, "entry/emoticon", "wtf", style); 2860 (data, o, "entry/emoticon", "wtf", style);
2848 return o; 2861 return o;
@@ -3786,10 +3799,10 @@ _elm_entry_efl_canvas_group_group_add(Eo *obj, Elm_Entry_Data *priv)
3786 _dnd_pos_cb, NULL, 3799 _dnd_pos_cb, NULL,
3787 _dnd_drop_cb, NULL); 3800 _dnd_drop_cb, NULL);
3788 3801
3789 if (!elm_widget_theme_object_set(obj, wd->resize_obj, 3802 if (elm_widget_theme_object_set(obj, wd->resize_obj,
3790 elm_widget_theme_klass_get(obj), 3803 elm_widget_theme_klass_get(obj),
3791 elm_widget_theme_element_get(obj), 3804 elm_widget_theme_element_get(obj),
3792 elm_widget_theme_style_get(obj))) 3805 elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
3793 CRI("Failed to set layout!"); 3806 CRI("Failed to set layout!");
3794 3807
3795 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj)); 3808 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
@@ -4969,24 +4982,34 @@ elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
4969{ 4982{
4970 Eina_Bool ret; 4983 Eina_Bool ret;
4971 elm_obj_entry_file_text_format_set(obj, format); 4984 elm_obj_entry_file_text_format_set(obj, format);
4972 ret = efl_file_set(obj, file, NULL); 4985 ret = efl_file_simple_load(obj, file, NULL);
4973 return ret; 4986 return ret;
4974} 4987}
4975 4988
4976EOLIAN static Eina_Bool 4989EOLIAN static Eina_Error
4977_elm_entry_efl_file_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file, const char *group EINA_UNUSED) 4990_elm_entry_efl_file_load(Eo *obj, Elm_Entry_Data *sd)
4978{ 4991{
4992 Eina_Error err;
4993
4994 if (efl_file_loaded_get(obj)) return 0;
4995 err = efl_file_load(efl_super(obj, MY_CLASS));
4996 if (err) return err;
4979 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del); 4997 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
4980 if (sd->auto_save) _save_do(obj); 4998 if (sd->auto_save) _save_do(obj);
4999 return _load_do(obj);
5000}
5001
5002EOLIAN static Eina_Error
5003_elm_entry_efl_file_file_set(Eo *obj, Elm_Entry_Data *sd, const char *file)
5004{
4981 eina_stringshare_replace(&sd->file, file); 5005 eina_stringshare_replace(&sd->file, file);
4982 Eina_Bool int_ret = _load_do(obj); 5006 return efl_file_set(efl_super(obj, MY_CLASS), file);
4983 return int_ret;
4984} 5007}
4985 5008
4986EAPI void 5009EAPI void
4987elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format) 5010elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
4988{ 5011{
4989 efl_file_get(obj, file, NULL); 5012 if (file) *file = efl_file_get(obj);
4990 if (format) 5013 if (format)
4991 { 5014 {
4992 ELM_ENTRY_DATA_GET(obj, sd); 5015 ELM_ENTRY_DATA_GET(obj, sd);
@@ -4996,13 +5019,6 @@ elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *f
4996} 5019}
4997 5020
4998EOLIAN static void 5021EOLIAN static void
4999_elm_entry_efl_file_file_get(const Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char **file, const char **group)
5000{
5001 if (file) *file = sd->file;
5002 if (group) *group = NULL;
5003}
5004
5005EOLIAN static void
5006_elm_entry_file_save(Eo *obj, Elm_Entry_Data *sd) 5022_elm_entry_file_save(Eo *obj, Elm_Entry_Data *sd)
5007{ 5023{
5008 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del); 5024 ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
@@ -6143,7 +6159,7 @@ _elm_entry_efl_access_object_state_set_get(const Eo *obj, Elm_Entry_Data *_pd EI
6143 ret = efl_access_object_state_set_get(efl_super(obj, ELM_ENTRY_CLASS)); 6159 ret = efl_access_object_state_set_get(efl_super(obj, ELM_ENTRY_CLASS));
6144 6160
6145 if (elm_entry_editable_get(obj)) 6161 if (elm_entry_editable_get(obj))
6146 STATE_TYPE_SET(ret, EFL_ACCESS_STATE_EDITABLE); 6162 STATE_TYPE_SET(ret, EFL_ACCESS_STATE_TYPE_EDITABLE);
6147 6163
6148 return ret; 6164 return ret;
6149} 6165}
@@ -6214,4 +6230,4 @@ ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
6214 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX), \ 6230 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX), \
6215 ELM_LAYOUT_SIZING_EVAL_OPS(elm_entry) 6231 ELM_LAYOUT_SIZING_EVAL_OPS(elm_entry)
6216 6232
6217#include "elm_entry.eo.c" 6233#include "elm_entry_eo.c"