add busy progress while text is still appending in the bg

for big txt files this is most useful.
This commit is contained in:
Carsten Haitzler 2021-04-08 16:23:14 +01:00
parent 401e315851
commit 964ac6b0dc
2 changed files with 35 additions and 2 deletions

View File

@ -16,6 +16,7 @@ typedef struct _Ecrire_Editor
{
Evas_Object *win;
Evas_Object *entry;
Evas_Object *busy;
Evas_Object *search_win;
Evas_Object *settings_popup;

View File

@ -103,6 +103,15 @@ _cb_sel_clear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
elm_object_item_disabled_set(inst->toolbar.cut, EINA_TRUE);
}
static void
_cb_text_set_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ecrire_Editor *inst = data;
elm_progressbar_pulse(inst->busy, EINA_FALSE);
}
static void
_update_cur_file(const char *file, Ecrire_Editor *inst)
{
@ -388,6 +397,7 @@ _editor_file_open(Ecrire_Editor *inst, const char *file)
else
{
_editor_reset(inst);
elm_progressbar_pulse(inst->busy, EINA_TRUE);
elm_entry_entry_append(inst->entry, buf);
elm_object_item_disabled_set(inst->menu.save, EINA_TRUE);
elm_object_item_disabled_set(inst->toolbar.save, EINA_TRUE);
@ -708,7 +718,7 @@ _ecrire_menu_add(Ecrire_Editor *inst)
void
ecrire_editor_add(const char *filename, const char *font_name, int font_size)
{
Evas_Object *win, *pad, *fr, *bx, *entry, *cur_info;
Evas_Object *win, *pad, *fr, *bx, *entry, *cur_info, *tab, *busy;
Evas_Object *toolbar;
Evas_Coord w = 600, h = 600;
@ -738,15 +748,36 @@ ecrire_editor_add(const char *filename, const char *font_name, int font_size)
toolbar = _ecrire_toolbar_add(inst);
elm_box_pack_end(bx, toolbar);
tab = elm_table_add(win);
evas_object_size_hint_align_set(tab, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(tab, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, tab);
evas_object_show(tab);
inst->entry = entry = elm_entry_add(win);
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_entry_line_wrap_set(entry, _ent_cfg->wrap_type);
elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, entry);
elm_table_pack(tab, entry, 0, 0, 1, 1);
evas_object_show(entry);
pad = elm_frame_add(win);
elm_object_style_set(pad, "pad_large");
evas_object_size_hint_align_set(pad, 1.0, 1.0);
evas_object_size_hint_weight_set(pad, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_table_pack(tab, pad, 0, 0, 1, 1);
evas_object_pass_events_set(pad, EINA_TRUE);
evas_object_show(pad);
inst->busy = busy = elm_progressbar_add(win);
elm_object_style_set(busy, "hidden_wheel");
elm_progressbar_pulse_set(busy, EINA_TRUE);
elm_object_content_set(pad, busy);
evas_object_pass_events_set(busy, EINA_TRUE);
evas_object_show(busy);
pad = elm_frame_add(win);
elm_object_style_set(pad, "pad_medium");
evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, 1.0);
@ -776,6 +807,7 @@ ecrire_editor_add(const char *filename, const char *font_name, int font_size)
evas_object_smart_callback_add(entry, "selection,start", _cb_sel_start, inst);
evas_object_smart_callback_add(entry, "selection,cleared", _cb_sel_clear, inst);
evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, _cb_key_down, inst);
evas_object_smart_callback_add(entry, "text,set,done", _cb_text_set_done, inst);
_ecrire_menu_add(inst);